私は OpenPrinter API にフックしていますが、 Hook を取得していません。コードは次のとおりです。私はこの関数をフックすることができません.いくつかのパラメータ(署名)が正しくない場合は助けてください....
typedef BOOL (WINAPI *OpenPrinterANext)(__in_opt LPSTR pPrinterName,__out LPHANDLE phPrinter,__in_opt LPPRINTER_DEFAULTSA pDefault);
OpenPrinterANext Real_OpenPrinterA = NULL;
typedef BOOL (WINAPI *OpenPrinterWNext)(__in_opt LPWSTR pPrinterName,__out LPHANDLE phPrinter,__in_opt LPPRINTER_DEFAULTSW pDefault);
OpenPrinterWNext Real_OpenPrinterW = NULL;
BOOL WINAPI OpenPrinterACallback(__in_opt LPSTR pPrinterName,__out LPHANDLE phPrinter,__in_opt LPPRINTER_DEFAULTSA pDefault)
{
MessageBoxA(NULL,"OpenPrinterA Function Called","Info",MB_OK);
return Real_OpenPrinterA(pPrinterName,phPrinter, pDefault);
}
BOOL WINAPI OpenPrinterWCallback(__in_opt LPWSTR pPrinterName,__out LPHANDLE phPrinter,__in_opt LPPRINTER_DEFAULTSW pDefault)
{
MessageBoxA(NULL,"OpenPrinterW Function Called","Info",MB_OK);
return Real_OpenPrinterW(pPrinterName,phPrinter, pDefault);
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
if (MH_Initialize() != MH_OK)
{
MessageBoxW(NULL,L"Failed Initialize",L"Info!",MB_ICONWARNING|MB_OK);
}
if
if (MH_CreateHook(&OpenPrinterA, &OpenPrinterACallback, reinterpret_cast<void**>(&Real_OpenPrinterA)) != MH_OK)
{
MessageBoxW(NULL,L"Printing Disabled by hooking",L"Info!",MB_ICONWARNING|MB_OK);
}
if (MH_EnableHook(&OpenPrinterA) != MH_OK)
{
MessageBoxW(NULL,L"Failed EnableHook Printing",L"Info!",MB_ICONWARNING|MB_OK);
}
if (MH_CreateHook(&OpenPrinterW, &OpenPrinterWCallback, reinterpret_cast<void**>(&Real_OpenPrinterW)) != MH_OK)
{
MessageBoxW(NULL,L"Printing Disabled by hooking",L"Info!",MB_ICONWARNING|MB_OK);
}
if (MH_EnableHook(&OpenPrinterW) != MH_OK)
{
MessageBoxW(NULL,L"Failed EnableHook Printing",L"Info!",MB_ICONWARNING|MB_OK);
}
break ;
case DLL_PROCESS_DETACH:
if (MH_DisableHook(&OpenPrinterA) != MH_OK)
{
}
if (MH_DisableHook(&OpenPrinterW) != MH_OK)
{
}
if (MH_Uninitialize() != MH_OK)
{
}
break;
}
return TRUE;
}
誰でも助けてください よろしくお願い
します