正如标题所说,我正在尝试使用Detours使用Dev-C ++编译一个简单的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;
}
答案 0 :(得分:0)
这些行上没有分号。
不知道走路,我打算查询类型为PVOID &
,这看起来很奇怪 - 但网上有几个例子,所以看起来似乎有道理。
答案 1 :(得分:0)
不应该是LPVOID
而不是PVOID
吗?