There are a couple of potential problems you may run into when trying to build detours using the VS 2008 SDK 6.1 tools and headers:
- on an x64 system the make file will default to building for x64, which is disabled in the free version. To build for x64 you must get a license from Microsoft for $10000 — most likely you just want to build the x86 version though. You can configure building to x86 by setting an environment variable:
set DETOURS_TARGET_PROCESSOR=x86
- your lib and include paths might not be set correctly, I recommend setting both to first the SDKs directory, then the VS directory like:
set lib=C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib
set include=C:\Program Files\Microsoft SDKs\Windows\v6.1\Include;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include
- When you do a “nmake all” now, detours itself should build, but the compilation of the samples will abort with an error:
symtest.cpp(270) : error C2664: 'BOOL (HANDLE,PSYM_ENUMMODULES_CALLBACK64,PVOID)' :
cannot convert parameter 2 from 'overloaded-function' to 'PSYM_ENUMMODULES_CALLBACK64'
of the functions with this name in scope match the target type
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.EXE"' :
return code 0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
Austin Donnelly has posted a patch for this problem, you’ll need to patch two files, first samples/findfunc/symtest.cpp:
Index: symtest.cpp
===================================================================
--- symtest.cpp (revision 1)
+++ symtest.cpp (revision 2)
@@ -80,7 +80,7 @@
////////////////////////////////////////////////////////////////////////////////#if (_MSC_VER > 1299)-static BOOL WINAPI SymEnumerateCallback(PSTR pszModule,+static BOOL WINAPI SymEnumerateCallback(PCSTR pszModule,DWORD64 base,PVOID pvUserContext)
{Second samples/traceapi/_win32.cpp:
Index: _win32.cpp
===================================================================
--- _win32.cpp (revision 1)
+++ _win32.cpp (revision 2)
@@ -389,7 +389,7 @@
= CharUpperW;
BOOL (__stdcall * Real_CheckColorsInGamut)(HDC a0,
- LPVOID a1,
+ LPRGBTRIPLE a1,
LPVOID a2,
DWORD a3)
= CheckColorsInGamut;
@@ -5979,7 +5979,7 @@
LPVOID a1,
DWORD a2,
LPDWORD a3,
- LPVOID a4)
+ PCONSOLE_READCONSOLE_CONTROL a4)
= ReadConsoleA;
BOOL (__stdcall * Real_ReadConsoleInputA)(HANDLE a0,
@@ -6033,7 +6033,7 @@
LPVOID a1,
DWORD a2,
LPDWORD a3,
- LPVOID a4)
+ PCONSOLE_READCONSOLE_CONTROL a4)
= ReadConsoleW;
BOOL (__stdcall * Real_ReadDirectoryChangesW)(HANDLE a0,
@@ -7373,8 +7373,8 @@
LPFILETIME a1)
= SystemTimeToFileTime;
-BOOL (__stdcall * Real_SystemTimeToTzSpecificLocalTime)(LPTIME_ZONE_INFORMATION a0,
- LPSYSTEMTIME a1,
+BOOL (__stdcall * Real_SystemTimeToTzSpecificLocalTime)(const TIME_ZONE_INFORMATION* a0,+ const SYSTEMTIME *a1,LPSYSTEMTIME a2)
= SystemTimeToTzSpecificLocalTime;
@@ -7638,7 +7638,8 @@
BOOL (__stdcall * Real_UpdateColors)(HDC a0)
= UpdateColors;
-
+#pragma warning(push)
+#pragma warning(disable:4995)
BOOL (__stdcall * Real_UpdateICMRegKeyA)(DWORD a0,
LPSTR a1,
LPSTR a2,
@@ -7658,7 +7659,7 @@
LPVOID a4,
DWORD a5)
= UpdateResourceA;
-
+#pragma warning(pop)
BOOL (__stdcall * Real_UpdateResourceW)(HANDLE a0,
LPCWSTR a1,
LPCWSTR a2,
@@ -9709,7 +9710,7 @@
}
BOOL __stdcall Mine_CheckColorsInGamut(HDC a0,
- LPVOID a1,
+ LPRGBTRIPLE a1,
LPVOID a2,
DWORD a3)
{@@ -26018,7 +26019,7 @@
LPVOID a1,
DWORD a2,
LPDWORD a3,
- LPVOID a4)
+ PCONSOLE_READCONSOLE_CONTROL a4)
{_PrintEnter("ReadConsoleA(%p,%p,%p,%p,%p)\n", a0, a1, a2, a3, a4);@@ -26152,7 +26153,7 @@
LPVOID a1,
DWORD a2,
LPDWORD a3,
- LPVOID a4)
+ PCONSOLE_READCONSOLE_CONTROL a4)
{_PrintEnter("ReadConsoleW(%p,%p,%p,%p,%p)\n", a0, a1, a2, a3, a4);@@ -30240,8 +30241,9 @@
return rv;}
-BOOL __stdcall Mine_SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION a0,
- LPSYSTEMTIME a1,
+BOOL __stdcall Mine_SystemTimeToTzSpecificLocalTime(const TIME_ZONE_INFORMATION+ * a0,
+ const SYSTEMTIME * a1,LPSYSTEMTIME a2)
{_PrintEnter("SystemTimeToTzSpecificLocalTime(%p,%p,%p)\n", a0, a1, a2);After you applied those two patches, “nmake all” should successfully build detours and all the samples.
