简体   繁体   中英

Dev-C++ and Detours compiling error

As title says I'm trying to compile with Dev-C++ a simple DLL using Detours, but I get this error:

syntax error before token '&'

on this lines:

DetourAttach(&(PVOID &)trueMessageBox, hookedMessageBox)
DetourDetach(&(PVOID &)trueMessageBox, hookedMessageBox)

The complete code is

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

You don't have semicolons on those lines.

Not knowing about detours, I was going to query the typecast to PVOID & , which looks odd - but there are several examples of it around the net, so it seems plausible.

它不是LPVOID而不是PVOID吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM