0

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;
}
crazyscot
  • 11,819
  • 2
  • 39
  • 40
Julio
  • 1
  • the includes are ok, but i don't know how to display the and here cause it strips out. – Julio Jun 05 '10 at 15:17
  • you have to write > and <, or use a
     tag :)
    – garph0 Jun 05 '10 at 15:20
  • 3
    No, don't use a pre tag, use the correct markup. There's a button in the editor which does this for you (highlight code, press button) or you can manually indent every line with four spaces. – crazyscot Jun 05 '10 at 15:22
  • 2
    You could start by throwing out Dev-C++. Seriously, why do people think using an IDE that hasn't been maintained for 5 years (and sucked even when it *was* maintained) is a good idea? There are several **good** free IDE's available. Why do you use the *only* one that never actually worked? – jalf Jun 05 '10 at 15:30
  • A new major release of Code::Blocks has just come out - superior to DevC++ in every way - see http://www.codeblocks.org. –  Jun 05 '10 at 17:14
  • where is the fault of IDE in the asker case?! syntax error are raised by the compiler, which is an old version of gcc, and can be updated with recent MinGW. I am not saying Dev-C++ is the best IDE of course; I am saying the error would happen even using notepad as editor. – ShinTakezou Jun 10 '10 at 16:31

2 Answers2

0

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.

crazyscot
  • 11,819
  • 2
  • 39
  • 40
0

Shouldn't it be LPVOID instead of PVOID?

jalf
  • 243,077
  • 51
  • 345
  • 550
  • it does not answer the question, it does not solve the problem, it should have been a comment, and it is totally unessential, since nowadays LPVOID and PVOID are the same thing. But still > -1... Virtual downvote. – ShinTakezou Jun 10 '10 at 16:36