I've made a printer UI wrapper dll file but..

I’ve posted here few times, that i’m trying to use the DrvDocumentEvent
function. I’m trying to use it on w2k.

following tips obtained from here, i’ve made a UI dll which act as a
wrapper, exporting every function defined by Printer Interface dll.
But for every function except DrvDocumentEvent, i’ve just loaded the
library “UNIDRVUI.DLL” and called GetProcAddress giving corresponding
unidrvui function as an argument.
The Entry point function name of the dll was “DllInitialize” but during
building, the following error occured.
“libc.lib(crt0.obj) : error LNK2001:unresolved external symbol _main”

I already declared that the entry function name was “DllInitialize” in
the SOURCES file adding the following sentence.
“DLLENTRY=DllInitialize”

but the error kept occured. So i changed the Entry function name as
“DllMain” and edited the line as “DLLENTRY=_DllMainCRTStartup”
Then the build command successed, And I Obtained the dll file.
So i installed with print driver dll file using *.inf file.
I thought it would success. I tried to make a MessageBox before
printing job start, but it didn’t work. I guess my dll isn’t being
called from the system.
Any idea about this problem? Why is the Dll file isn’t being called?
is there any missing process?

following codes are the files in the directory.
***Ashwin helped with The core structure of the files, and the
parts of the source code was writtened by DC with no warranties, and
confers no rights. ****

this is the .def file

LIBRARY UIWRAPPER

EXPORTS
DrvDeviceCapabilities
DevQueryPrintEx
DrvUpgradePrinter
DrvDocumentPropertySheets
DrvDevicePropertySheets
DrvConvertDevMode
DrvPrinterEvent
DrvQueryJobAttributes
DrvQueryColorProfile
DrvDriverEvent
DrvDocumentEvent

DrvSplDeviceCaps @ 254 PRIVATE

and the source code of the DllMain function(dll entry function)

BOOL WINAPI
DllMain(
HINSTANCE hModule,
DWORD Reason,
LPVOID pReserved
)
{
UNREFERENCED_PARAMETER(pReserved);

switch(Reason){
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hModule);
// LogDebug(DBG_PROCESS_ATTACH, (LPWSTR)(“DllInitialize:
DLL_PROCESS_ATTACH”));
break;
case DLL_PROCESS_DETACH:
// LogDebug(DBG_PROCESS_DETACH,
// (LPWSTR)(“DllInitialize:
// LL_PROCESS_DETACH Destroy CACHED data”));
break;
}
return (TRUE);
}

The structure of other functions(DrvDeviceCapabilities,
DrvDeviceCapabilities, DrvUpgradePrinter, etc…)

LONG
DrvDevicePropertySheets(
PPROPSHEETUI_INFO pPSUIInfo,
LPARAM lParam
)
{
FARPROC UIDllFunc;

UIDllFunc = WrapUnidrvUI(“DrvDevicePropertySheets”);
// The function WrapUnidrvUI loads the library and
// calls the corresponding function using GetProcAddress

return ((*UIDllFunc)(pPSUIInfo, lParam));
}

And last the SOURCES file

TARGETNAME=UIWRAPPER
TARGETPATH=obj
TARGETTYPE=DYNLINK

PRECOMPILED_CXX=1
PRECOMPILED_INCLUDE=precomp.h
PRECOMPILED_PCH=precomp.pch
PRECOMPILED_OBJ=precomp.obj

C_DEFINES=$(C_DEFINES) -DUMODE -DSTRICT -D_UNICODE -DUNICODE

TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\user32.lib \
$(SDK_LIB_PATH)\advapi32.lib \
$(SDK_LIB_PATH)\winspool.lib \
$(SDK_LIB_PATH)\ole32.lib \
$(SDK_LIB_PATH)\uuid.lib

DLLENTRY=_DllMainCRTStartup

INCLUDES=.;$(SDK_INC_PATH)\MFC42

MSC_WARNING_LEVEL=/W3

MSC_WARNING_LEVEL=$(MSC_WARNING_LEVEL) /WX

SOURCES= UIWrapper.c

and also, precomp.h(Including many header files-stdio.h, winddi.h,
stdlib.h
etc…), makefile(same as DDK example file), UIWrapper.h(header for my
UIWrapper.c file) are in the directory.

Anyone can help?
I really have to make this happen.

i’ll be looking forward for advice.

-with respect
Souneil Park.-

You probably need to include this in your sources file.

USE_MSVCRT=1
USE_CTRLDLL=1

INCLUDES=.;$(SDK_INC_PATH)\MFC42

As for your dll not being loaded, the problem could be due to numerous
factors. Are you sure that your driver is being installed correctly? For
example, after printer installation, are you able to view the printer
properties? If you are, then there is no way that your dll is *not*
being loaded. Remember that you are the printer interface dll as far as
the print subsystem is concerned. It is blissfully unaware of the fact
that you actually punt all the calls to unidrvui. So you need to make
sure of what is going on in the first place. In any case, the only sure
way to check is through a debugger. You can find more information on the
debugger at http://www.microsoft.com/ddk/debugging. Debugging this will
help only if you are sure that your printer is being installed
correctly. You can then step through various functions.

  • Ashwin

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Souneil Park [mailto:xxxxx@hanmail.net]
Sent: Saturday, August 24, 2002 10:18 AM
To: NT Developers Interest List
Subject: [ntdev] I’ve made a printer UI wrapper dll file but…

I’ve posted here few times, that i’m trying to use the DrvDocumentEvent
function. I’m trying to use it on w2k.

following tips obtained from here, i’ve made a UI dll which act as a
wrapper, exporting every function defined by Printer Interface dll. But
for every function except DrvDocumentEvent, i’ve just loaded the library
“UNIDRVUI.DLL” and called GetProcAddress giving corresponding unidrvui
function as an argument. The Entry point function name of the dll was
“DllInitialize” but during building, the following error occured.
“libc.lib(crt0.obj) : error LNK2001:unresolved external symbol _main”

I already declared that the entry function name was “DllInitialize” in
the SOURCES file adding the following sentence. “DLLENTRY=DllInitialize”

but the error kept occured. So i changed the Entry function name as
“DllMain” and edited the line as “DLLENTRY=_DllMainCRTStartup” Then the
build command successed, And I Obtained the dll file. So i installed
with print driver dll file using *.inf file. I thought it would success.
I tried to make a MessageBox before printing job start, but it didn’t
work. I guess my dll isn’t being called from the system. Any idea about
this problem? Why is the Dll file isn’t being called? is there any
missing process?

following codes are the files in the directory.
***Ashwin helped with The core structure of the files, and the parts of
the source code was writtened by DC with no warranties, and confers no
rights. ****

this is the .def file

LIBRARY UIWRAPPER

EXPORTS
DrvDeviceCapabilities
DevQueryPrintEx
DrvUpgradePrinter
DrvDocumentPropertySheets
DrvDevicePropertySheets
DrvConvertDevMode
DrvPrinterEvent
DrvQueryJobAttributes
DrvQueryColorProfile
DrvDriverEvent
DrvDocumentEvent

DrvSplDeviceCaps @ 254 PRIVATE

and the source code of the DllMain function(dll entry function)

BOOL WINAPI
DllMain(
HINSTANCE hModule,
DWORD Reason,
LPVOID pReserved
)
{
UNREFERENCED_PARAMETER(pReserved);

switch(Reason){
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hModule);
// LogDebug(DBG_PROCESS_ATTACH,
(LPWSTR)(“DllInitialize:
DLL_PROCESS_ATTACH”));
break;
case DLL_PROCESS_DETACH:
// LogDebug(DBG_PROCESS_DETACH,
// (LPWSTR)(“DllInitialize:
// LL_PROCESS_DETACH Destroy CACHED data”));
break;
}
return (TRUE);
}

The structure of other functions(DrvDeviceCapabilities,
DrvDeviceCapabilities, DrvUpgradePrinter, etc…)

LONG
DrvDevicePropertySheets(
PPROPSHEETUI_INFO pPSUIInfo,
LPARAM lParam
)
{
FARPROC UIDllFunc;

UIDllFunc = WrapUnidrvUI(“DrvDevicePropertySheets”);
// The function WrapUnidrvUI loads the library and
// calls the corresponding function using
GetProcAddress

return ((*UIDllFunc)(pPSUIInfo, lParam));
}

And last the SOURCES file

TARGETNAME=UIWRAPPER
TARGETPATH=obj
TARGETTYPE=DYNLINK

PRECOMPILED_CXX=1
PRECOMPILED_INCLUDE=precomp.h
PRECOMPILED_PCH=precomp.pch
PRECOMPILED_OBJ=precomp.obj

C_DEFINES=$(C_DEFINES) -DUMODE -DSTRICT -D_UNICODE -DUNICODE

TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\user32.lib \
$(SDK_LIB_PATH)\advapi32.lib \
$(SDK_LIB_PATH)\winspool.lib \
$(SDK_LIB_PATH)\ole32.lib \
$(SDK_LIB_PATH)\uuid.lib

DLLENTRY=_DllMainCRTStartup

INCLUDES=.;$(SDK_INC_PATH)\MFC42

MSC_WARNING_LEVEL=/W3

MSC_WARNING_LEVEL=$(MSC_WARNING_LEVEL) /WX

SOURCES= UIWrapper.c

and also, precomp.h(Including many header files-stdio.h, winddi.h,
stdlib.h etc…), makefile(same as DDK example file), UIWrapper.h(header
for my
UIWrapper.c file) are in the directory.

Anyone can help?
I really have to make this happen.

i’ll be looking forward for advice.

-with respect
Souneil Park.-


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%