Hi all
I finally installed printer UI wrapper which i’ve made.
but some worked, and some didn’t. As i mentioned before, every function
except DrvDocumentEvent, I just load the library “unidrvui.dll” and call
GetProcAddress function giving the corresponding function name as an
argument.
when installing, it seemed like it was working fine.
when i viewed the properties of the printer, it worked very well.
But the problem occured when
- using Microsoft Word,
- and trying to print(in every application supporting printer),
- and selecting the “File -> Print” menu.(also in every application
supporting printer)
The Error message was “0x00000000 Access violation. this cannot be read”
I Thought it was because DrvDocumentEvent function which i’ve made, but
there were a message following in the logfile.
“DrvDocumentPropertySheets - Loading unidrvui.dll failed”
(I made the program to write a logfile for every function calls, whether
it success of not.)
And then i guessed it was because of the returning NULL pointer after
failing to load the library.
all i do in the DrvDocumentPropertySheets function is as follows.
LONG
DrvDocumentPropertySheets(
PPROPSHEETUI_INFO pPSUIInfo,
LPARAM lParam
)
{
FARPROC UIDllFunc;
LONG Value;
UIDllFunc = WrapUnidrvUI(“DrvDocumentPropertySheets”);
// WrapUnidrvUi function obtains the function pointer of the
// corresponding argument.
Value = (*UIDllFunc)(pPSUIInfo, lParam);
return (Value);
}
the strange thing is this.
DrvDocumentPropertySheets function works when trying to view the
properties of the printer. It means it loads the library successfully and
obtains the valid function pointer. I can confirm this in the logfile.
Other function calls success everytime when it gets called(fortunately).
I tested the same situation with “msplot” (NTDDK\src\print\msplot) and i
could see the DrvDocumentPropertySheets function being called from the
system in the same situation.
But the implementation of DrvDocumentPropertySheets were very complicated.
(NTDDK\src\print\msplot\plotui\docprop.c)
Why does the Loading fails only in situation which i’ve mentioned?
What do i have to do to make the library loads successfully for every
situation?
following is the module loading library and returning the function pointer
FARPROC
WrapUnidrvUI(
char *function_name // the name of the function trying to use
)
{
HINSTANCE hInstUniUI; // handling the library
FARPROC UIDllFunc; // Function pointer
MyFilePrintLine(function_name);
// MyFilePrintLine writes the string argument in the logfile.
if (hInstUniUI = LoadLibrary(_T(“UNIDRVUI.DLL”)))
{
MyFilePrintLine(“Successfully Loaded UNIDRVUI.dll”);
UIDllFunc = (FARPROC)GetProcAddress(hInstUniUI, function_name);
if (!UIDllFunc)
{
MyFilePrintLine(“Unable to GetProcAddress.\n”);
// handle the error
FreeLibrary(hInstPSUI);
UIDllFunc = NULL;
}
else
{
MyFilePrintLine(“Successfully found procedure!\n”);
}
}
else
MyFilePrintLine(“Loading UIDRVUI.dll failed\n”);
return UIDllFunc;
}
I wish i could listen for advice.
Please help me with it. I’ll be looking forward to it.
-with respect
Souneil