Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook OpenPrinterW failed under X64 platform #11

Open
lhg19202212 opened this issue Jun 11, 2015 · 4 comments
Open

Hook OpenPrinterW failed under X64 platform #11

lhg19202212 opened this issue Jun 11, 2015 · 4 comments

Comments

@lhg19202212
Copy link

Error message: ANOMALY: use of REX.w is meaningless (default operand size is 64).
My 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;
}

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;
}

@poizan42
Copy link
Contributor

poizan42 commented Feb 7, 2016

I cannot reproduce this. Which version of winspool.drv do you have?

@Bonjour123
Copy link

Bonjour123 commented Nov 12, 2018

@lhg19202212 Hi, I'm also having this problem.
Some of the GDI hooks I did work, some of them not, and none of the winspool.drv hooked functions work...
How did you fixed this ?

@poizan42
Copy link
Contributor

@Bonjour123 see #17

@Bonjour123
Copy link

@poizan42 You were right, I was convinced I had the last version, but actually no. Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants