简体   繁体   中英

Compiling Microsoft Detours for 64-bit

The detours package claims to support 64-bit but I don't see a way to compile 64-bit binaries:

Detouring 32-bit and 64-bit Processes

Using nmake all compiles only 32-bit stuff:

>dir
 Volume in drive D is Volume
 Volume Serial Number is XXXX-XXXX

 Directory of D:\Detours

06/21/2018  03:46 PM    <DIR>          .
06/21/2018  03:46 PM    <DIR>          ..
06/23/2018  08:13 PM    <DIR>          bin.X86
06/20/2017  09:03 AM             5,105 CREDITS.TXT
06/22/2017  03:06 PM                31 Detours Version 3.0 Build_343
10/19/2016  12:06 PM           113,685 Detours.chm
06/23/2018  08:12 PM    <DIR>          include
06/23/2018  08:12 PM    <DIR>          lib.X86
10/29/2015  02:19 PM             7,144 LICENSE.RTF
12/21/2016  01:22 PM             1,851 Makefile
06/22/2017  03:06 PM            14,961 README.TXT
06/21/2018  03:04 PM    <DIR>          samples
06/23/2018  08:12 PM    <DIR>          src
10/29/2015  02:19 PM             4,841 system.mak
06/22/2017  03:06 PM                31 VERSION.TXT

The nmake size64 command is invalid.

If I use the library ( lib.X86 folder) in my Visual Studio C++ project which is configured to produce a 64-bit DLL , I get the respective error and it won't build:

library machine type 'x86' conflicts with target machine type 'x64'

Renaming the folder lib.X86 to lib.X64 also does not work.

How can I get it to work in a 64-bit environment or is it not possible?

It seems like you have to set the target processor to 64-bit and then compile . A working batch ( .bat ) script may be something like the following (depending on your Visual Studio installation):

SET DETOURS_TARGET_PROCESSOR=X64
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
NMAKE

With this, the 64-bit binaries should compile successfully.

On the command line, you can say

set DETOURS_TARGET_PROCESSOR=X64

and then do the nmake command.

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