From: DB on
I'm working on transferring a Kernel Mode printer driver to User Mode
driver. I have made changes to the driver according to the document provided
at http://www.unixwiz.net/techtips/win32-pdriver-ktou.html, but the Vista
system still thinks it's a Kernel mode driver.

Some documents suggested signing the driver's .cat file, which I did. But
that did not solve the hanging problem.

After many days of debugging and searching on the net, I tracked down the
point where I think the user privilege might be culprit. I tried to use the
UploadPrinterDriverPackage() and InstallPrinterDriverFromPackage().
Apparently, UploadPrinterDriverPackage() runs sucessfully, but the call to
InstallPrinterDriverFromPackage() would hang.

I'm developing this on Windows Vista Business, service pack 1. The whole
thing works fine on Windows XP.

Dave

From: Christoph Lindemann on
I dont know if this helps, but I have had troubles before with this
when you have build your driver files checkout;

-the VS_FIXEDFILEINFO structure:
dwFileOS == VOS_NT_WINDOWS32
dwFileType == VFT_DRV
dwFileSubtype == VFT2_DRV_PRINTER or VFT2_DRV_VERSIONED_PRINTER
VER_FILEVERSION:
----------------------------------------------------------
First WORD | Ignore; Should be 0x0000
----------------------------------------------------------
Second WORD | 0x0003 = user-mode driver
| 0x0002 = kernel-mode driver
----------------------------------------------------------
Third WORD | 0x05 major feature set release / OS version
High byte |
----------------------------------------------------------
Low byte | 0x00 minor feature set release / OS version
----------------------------------------------------------
Fourth WORD | bug fix or service pack release / OS version
----------------------------------------------------------


-and more subtle, if the driver is compiled with some NT4 sdk the subsystem
specified in the PE Header was IMAGE_SUBSYSTEM_NATIVE,
so make sure the PE Header of you drivers for Win2K and later is
IMAGE_SUBSYSTEM_WINDOWS_GUI
IMAGE_NT_HEADERS->IMAGE_OPTIONAL_HEADER->Subsystem ==
IMAGE_SUBSYSTEM_WINDOWS_GUI

-Support "DrvQueryDriverInfo"

-Support correct version in "DrvEnableDriver"

-Support "DrvQueryDeviceSupport"

-build TARGETTYPE must be DYNLINK. Check that the files are linked against
umpdddi.lib and gdi32.lib

-Preprocessor macro USERMODE_DRIVER must be defined in source files before
winddi.h is included.

--
Christoph Lindemann
Undocumented Printing
http://www.undocprint.org/


"DB" <dburns(a)newsgroup.nospam> wrote in message
news:umyZ442PJHA.1012(a)TK2MSFTNGP04.phx.gbl...
> I'm working on transferring a Kernel Mode printer driver to User Mode
> driver. I have made changes to the driver according to the document
> provided at http://www.unixwiz.net/techtips/win32-pdriver-ktou.html, but
> the Vista system still thinks it's a Kernel mode driver.
>
> Some documents suggested signing the driver's .cat file, which I did. But
> that did not solve the hanging problem.
>
> After many days of debugging and searching on the net, I tracked down the
> point where I think the user privilege might be culprit. I tried to use
> the UploadPrinterDriverPackage() and InstallPrinterDriverFromPackage().
> Apparently, UploadPrinterDriverPackage() runs sucessfully, but the call to
> InstallPrinterDriverFromPackage() would hang.
>
> I'm developing this on Windows Vista Business, service pack 1. The whole
> thing works fine on Windows XP.
>
> Dave


From: Dave Burns on
Thanks for your reply, Christoph.

I'm using Visual Stduio 8 to compile the driver project.

So the version string in VER_FILEVERSION should be something like 0,3,5,0?

Also, I don't see any mention of IMAGE_SUBSYSTEM_NATIVE in the code, is it
the 'Subsystem' in the 'Propperties' page? Under 'Link->system->subsytem', I
do see some choices like '/SUBSYSTEM:NATIVE' but I don't have a choice of
'/SUBSYSTEM:IMAGE_SUBSYSTEM_WINDOWS_GUI'. Am I looking at the wrong place?

In the driver, there is another version in the GDIINFO, ulVersion. What
version value should I set for Vista? I'm using 0x501 now, would that be ok?

> -Support "DrvQueryDriverInfo"

I have this one and it's exported in the .DEF file too. It returns TRUE when
querying with DRVQUERY_USERMODE.

> -Support correct version in "DrvEnableDriver"

I have this one and it's exported in the .DEF file too. It sets the
iDriverVersion of the DRVENABLEDATA to DDI_DRIVER_VERSION_NT5_01.

> -Support "DrvQueryDeviceSupport"

I did not have this function. Do I have to implement this and export it in
the ,DEF file? I just added a dummy implementaion now (just returning TRUE).


> -build TARGETTYPE must be DYNLINK. Check that the files are linked against

> umpdddi.lib and gdi32.lib

In Visual Studio 8, where do you specify TARGETTYPE = DYNLINK? I had it in
the 'Preprocessor Definitions' section.

> -Preprocessor macro USERMODE_DRIVER must be defined in source files before

> winddi.h is included.

I had that, it's in the 'Preprocessor Definitions' .

Regards, Dave




From: Christoph Lindemann on
Hi Dave,

I strongly suggest to build the driver with the DDK, and not to use Visual
Studio for this. (You can of course use it as you editor) There are subtle
differences between the DDK include files and the VS/Platform include files.
I have had nothing than trouble building with VS (even thoug it is a >user
mode< printer driver), so I went back to build everything with the DDK.

Additional comments below:

> I'm using Visual Stduio 8 to compile the driver project.

I strongly suggest you use the DDK.

> So the version string in VER_FILEVERSION should be something like 0,3,5,0?

0x0000.0x0003.0x0500.0x0000
or
0x0000.0x0003.0x0501.0x0000

> Also, I don't see any mention of IMAGE_SUBSYSTEM_NATIVE in the code, is it
> the 'Subsystem' in the 'Propperties' page? Under 'Link->system->subsytem',
> I do see some choices like '/SUBSYSTEM:NATIVE' but I don't have a choice
> of '/SUBSYSTEM:IMAGE_SUBSYSTEM_WINDOWS_GUI'. Am I looking at the wrong
> place?

I dont know where to set it in VS. Check out the build DLL. Look in the PE
header.
When you build with the DDK, you should not need to set this.

> In the driver, there is another version in the GDIINFO, ulVersion. What
> version value should I set for Vista? I'm using 0x501 now, would that be
> ok?

it should be 0x0500 or 0x0501 depending on what system you want to support,
VER_FILEVERSION should be set to same.

>> -Support "DrvQueryDeviceSupport"
>
> I did not have this function. Do I have to implement this and export it in
> the ,DEF file? I just added a dummy implementaion now (just returning
> TRUE).

You don't have to according to DDK.

Remember DEVMODE.dmSpecVersion should be 0x0401 for Windows 2000 and later.
The same for DrvDeviceCapabilities DC_VERSION


From: Dave Burns on
Thank you for your quick reply. I'm in process of making the WDK Build
utility to compile the driver, but I'm having the following problems.

error C2220: warning treated as error - no 'object' file generated

But my SOURCES file specifically removes the /Wx flag. Here is my SOURCES
file, could you see any problem with this file?

I copied this one from a friend of mine, but I don't see anything about the
VS_FIXEDFILEINFO or PE Header. Where should I specify those?

Any directions will be greatly appreciated.

Dave



# Printer Graphic Driver Source File

TARGETNAME=CCDXPVISTA

TARGETTYPE=DYNLINK

!IF 0

TARGETPATH=$(BASEDIR)\lib

!ENDIF

TARGETPATH=obj

INCLUDES=.;..\inc;..\..\..\inc;..\..\..\..\inc

C_DEFINES=$(C_DEFINES) -DSTRICT -DUNICODE -DUSERMODE_DRIVER -DEVE40 -DEVE30
-DEVE_WIDECARD -DUSE_OUTER_DLL -D_USE_RGBTRIPLE_

USE_MSVCRT=1

TARGETLIBS=$(SDK_LIB_PATH)\winspool.lib \

$(SDK_LIB_PATH)\user32.lib \

$(SDK_LIB_PATH)\gdi32.lib \

$(SDK_LIB_PATH)\advapi32.lib \

$(SDK_LIB_PATH)\umpdddi.lib \

USE_NOLIBS=1

###

### for DDK

###

DLLENTRY=DllMain

###

### for WDK

###

### need DllMain()

#DLLENTRY=_DllMainCRTStartup

NTPROFILEINPUT=yes

### !IFNDEF MSC_WARNING_LEVEL

### MSC_WARNING_LEVEL=/W2

### !ENDIF

MSC_WARNING_LEVEL=/W1

SOURCES= ccd2kxp.c \

ccd2kxpUtils.c \

RimageRes300UIDriver.c \

ccd2kxp.RC

#PRECOMPILED_INCLUDE=rimeveg.h

#PRECOMPILED_PCH=precomp.pch

#PRECOMPILED_OBJ=precomp.obj