0

正如标题所说,我正在尝试使用 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;
}
4

2 回答 2

0

这些行上没有分号。

不知道走弯路,我打算查询 typecast to PVOID &,这看起来很奇怪 - 但网络上有几个例子,所以它似乎是合理的。

于 2010-06-05T15:34:29.723 回答
0

不应该LPVOID代替PVOID吗?

于 2010-06-05T16:58:28.850 回答