Commit
Apply John McDonald's patch to the correct files
- Loading branch information
There are no files selected for viewing
1 comment
on commit e58a58c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, when I hook OpenPrinterW, I find it does not work under x64 .
Test Code:
typedef BOOL (WINAPI* PFNOPENPRINTERW)( LPWSTR pPrinterName,
LPHANDLE phPrinter,
LPPRINTER_DEFAULTSW pDefault);
PFNOPENPRINTERW fpOpenPrinterW=(PFNOPENPRINTERW)GetProcAddress(LoadLibraryW(L"winspool.drv"), "OpenPrinterW");
BOOL
WINAPI
MyOpenPrinterW(
LPWSTR pPrinterName,
LPHANDLE phPrinter,
LPPRINTER_DEFAULTSW pDefault)
{
BOOL Status;
char temp[MAX_PATH]={0x00};
GetModuleFileNameA(NULL,temp,MAX_PATH);
printf("%s[%d] m_sProcessName=%s \n",FILE,LINE,temp);
Status = fpOpenPrinterW (pPrinterName,
phPrinter,
pDefault);
return Status;
}
//=========================================================================
// This is where the work gets done.
//
int wmain(int argc, WCHAR* argv[])
{
HANDLE hProc = NULL;
HANDLE m_handle=NULL;
if(Mhook_SetHook((PVOID_)&fpOpenPrinterW, MyOpenPrinterW)){
OpenPrinterW(L"Brother MFC-7860DN Printer",&m_handle,NULL);
if(m_handle)
CloseHandle(m_handle);
Mhook_Unhook((PVOID_)&fpOpenPrinterW);
}else{
printf("%s[%d].OpenPrinterW hook fail\n",FILE,LINE);
}
return 0;
}
A running test program, immediately crash!!!!