正如标题所述,Im试图用Dev-C++汇编一部使用Detours的简明的DLL,但我发现这一错误:
syntax error before token &
为此:
DetourAttach(&(PVOID &)trueMessageBox, hookedMessageBox)
DetourDetach(&(PVOID &)trueMessageBox, hookedMessageBox)
完整的法典
#include <windows.h>
#include <detours.h>
#pragma comment( lib, "Ws2_32.lib" )
#pragma comment( lib, "detours.lib" )
#pragma comment( lib, "detoured.lib" )
int (WINAPI * trueMessageBox)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) = MessageBox;
int WINAPI hookedMessageBox(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType)
{
LPCSTR lpNewCaption = "You ve been hijacked";
int iReturn = trueMessageBox(hWnd, lpText, lpNewCaption, uType);
return iReturn;
}
BOOL WINAPI DllMain( HINSTANCE, DWORD dwReason, LPVOID ) {
switch ( dwReason ) {
case DLL_PROCESS_ATTACH:
DetourTransactionBegin();
DetourUpdateThread( GetCurrentThread() );
DetourAttach(&(PVOID &)trueMessageBox, hookedMessageBox)
DetourTransactionCommit();
break;
case DLL_PROCESS_DETACH:
DetourTransactionBegin();
DetourUpdateThread( GetCurrentThread() );
DetourDetach(&(PVOID &)trueMessageBox, hookedMessageBox)
DetourTransactionCommit();
break;
}
return TRUE;
}