Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compilation of detours on vs2012 (Windows 8.1)

Using the visual studio 2012 command tools (i.e. in the 'native tools command prompt' command console) I have run vcvars32.bat, and navigated to *c:\program file(x86)\Microsoft Research\Detours Express 3.0*.

On running nmake in this directory, it begins building successfully, however it then exits with the error:

cl /nologo /nologo /Zi /MT /Gm- /W4 /WX /Od /DDETOURS_BITS=32 /I..\..\include /Gs /DDETOURS_X86=1 /DDETOURS_32BIT=1 /D_X86_ /DDETOURS_OPTION_BITS=64 /Fdobj.X86\vc.pdb /Foobj.X86\member.obj /c member.cpp

member.cpp
member.cpp(88) : error C2440: 'type cast' : cannot convert from 'void (__thiscall CMember::* )(void)' to 'PBYTE &'
Reason: cannot convert from 'overloaded-function' to 'PBYTE *'
There is no context in which this conversion is possible 

member.cpp(90) : error C2440: 'type cast' : cannot convert from 'void (__thiscall CDetour::* )(void)' to 'PBYTE &'
Reason: cannot convert from 'overloaded-function' to 'PBYTE *'
There is no context in which this conversion is possible

// error repeated member.cpp lines 105, 120, 122.

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

Not sure how to move on with this error. I also attempted to:

set DETOURS_TARGET_PROCESSOR=X86

and then "nmake clean" followed by a new "nmake" - however this results in the same error.

as specified in the title, I am building with vs2012, on a windows 8.1 box (x64).

thank you

like image 234
wibble Avatar asked Feb 06 '14 00:02

wibble


1 Answers

ok, so i solved it, so i thought i'd post the answer if anyone else finds it useful.

I've done this by trial and error, so I would still like someone to come on and explain why/what this error is and what caused it etc.

however, here are the changes i made to get it to compile:

#if (_MSC_VER < 1310)
    pfTarget = CMember::Target;
    pfMine = CDetour::Mine_Target;

    Verify("CMember::Target", *(PBYTE*)&pfTarget);
    Verify("*CDetour::Real_Target", *(&(PBYTE&)CDetour::Real_Target));
    Verify("CDetour::Mine_Target", *(PBYTE*)&pfMine);
#else
    //Verify("CMember::Target", (PBYTE)(&(PBYTE&)CMember::Target));
    //Verify("*CDetour::Real_Target", *(&(PBYTE&)CDetour::Real_Target));
    //Verify("CDetour::Mine_Target", (PBYTE)(&(PBYTE&)CDetour::Mine_Target));

    pfTarget = &CMember::Target;
    pfMine = &CDetour::Mine_Target;

    Verify("CMember::Target", *(PBYTE*)&pfTarget);
    Verify("*CDetour::Real_Target", *(&(PBYTE&)CDetour::Real_Target));
    Verify("CDetour::Mine_Target", *(PBYTE*)&pfMine);
#endif

my changes are in the 2nd half 'else' statement, original code is commented out.

For each error (relevant line numbers in original question) - I commented out what was there, copied and pasted from the 1st half "if" section", but changed from "pfTarget = CMember::Target;" to "pfTarget = &CMember::Target;" (based on instruction from the compiler).

seems to be two different issues, first taking the wrong path in the if/else block (_MSC_VER supposed to be set somewhere and isn't?) and secondly the required change from CMember::Target to &CMember::Target.

thanks

like image 50
wibble Avatar answered Sep 30 '22 07:09

wibble