Compilation of detours on vs2012 (Windows 8.1)
Asked Answered
G

2

5

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

Greene answered 6/2, 2014 at 0:35 Comment(0)
G
6

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

Greene answered 6/2, 2014 at 0:55 Comment(1)
We can also change all "#if (_MSC_VER < 1310)" to "#if (_MSC_VER < 1900)" (MSVC 2012 has _MSC_VER==1800), and add "&" in "pfTarget = CMember::Target;", etc, changing them to things like "pfTarget = &CMember::Target;". By doing so, we change less code.Manama
D
1

The solution provided by wibble didn't work for me but since the compiler errors are only occurring when compiling the samples (after MS Detours compiled successfully), the errors aren't important anymore if you just want to use the library.

Diapause answered 21/12, 2014 at 21:39 Comment(1)
I simply ctrl+f'd out every line with member and the following build command in /samples/MakefileBrest

© 2022 - 2024 — McMap. All rights reserved.