Ask a questionAsk a question
 

AnswerCannot make detours.lib....

Answers

  • Wednesday, January 16, 2008 7:22 AMSimple Samples Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Please understand that Detours assumes that the developer using it has advanced experience with Windows programming and experience with use of Visual Studio and Visual C+.

     

    Detours is not documented well and there is a good chance you will get help with details that the documentation is not clear about. Technically speaking, this question is outside the scope of this forum but you might get help here anyway. There are forums in other web sites for which this question is relevant and where you could get help.

     

    I suspect you are not experienced with the use of VC. I also suspect that you are not familiar with the need to set environment variables to use command-line tools such as nmake. Are you familiar with VCVARS32.BAT? If not then look in the documentation for descriptions of using VC command-line tools.

     

    Also, expect to spend time learning. To use Detours, you probably will need to invest more than two months learning about many things.

All Replies

  • Wednesday, January 16, 2008 7:22 AMSimple Samples Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Please understand that Detours assumes that the developer using it has advanced experience with Windows programming and experience with use of Visual Studio and Visual C+.

     

    Detours is not documented well and there is a good chance you will get help with details that the documentation is not clear about. Technically speaking, this question is outside the scope of this forum but you might get help here anyway. There are forums in other web sites for which this question is relevant and where you could get help.

     

    I suspect you are not experienced with the use of VC. I also suspect that you are not familiar with the need to set environment variables to use command-line tools such as nmake. Are you familiar with VCVARS32.BAT? If not then look in the documentation for descriptions of using VC command-line tools.

     

    Also, expect to spend time learning. To use Detours, you probably will need to invest more than two months learning about many things.

  • Wednesday, January 16, 2008 3:10 PMAkooo Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello!

     

    Bad to hear... But I got it working with calling vcvars32 before nmake in the same command prompt. And now... it stops at a different point but with a compiling error:

     

    symtest.cpp(270) : error C2664 : 'BOOL (HANDLE,PSYM_ENUMMODULES_CALLBACK64,PVOID)' : cannot convert parameter 2 from 'overloaded-function' to 'PSYM_ENUMMODULES_CALLBACK64'

    None of the functions with this name in scope match the target type

     

    So... why is there an error in code?

    Thanks!

    Greets

  • Tuesday, January 22, 2008 7:04 AMBite Qiu - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Just tried to download and install Detours in my test machine, the detours.lib successfully generated with the simple instruction in readme.txt file:
    Code Block

    2. BUILD INSTRUCTIONS:
    ======================
    To build the libraries and the sample applications, type "nmake".

    and there is no such compilation errors, so I think the problem is elsewhere.

    If problem still persist, please elaborate your steps to build the libraries in detail in a new thread. Since the original question is answered, the answer "VCVARS32.BAT" first appear in Sam's post, so I am marking the thread as answered.

    thanks
    rico

  • Tuesday, January 22, 2008 4:04 PMAustin Donnelly MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    It looks like Visual Studio 2008 ships with standard libraries with different types to what detours expects.  At this stage, I'm not sure what the best work-around is: you could always try building with VS 2005.

     

    Austin

     

  • Tuesday, January 22, 2008 5:33 PMAustin Donnelly MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer

    Right, I now have a working Detours package, built using the Windows SDK.

     

    VS 2008 uses the new Windows SDK (the SDK formerly known as the Platform SDK), which has changed the types of a few of the APIs.  Since Detours includes a sample where pretty much the entire Win32 API is traced, these changes break the build when it comes to compiling two of the samples.

     

    The API changes are mainly adding "const" to pointer types.  You'll need to change the following two files ("+" means a line needs adding, "-" means a line needs deleting, "@@" gives approximate line numbers, everything else is context for humans):

     

    ==== detours-2.1\samples\findfunc\symtest.cpp ====
    @@ -80,7 +80,7 @@
     //////////////////////////////////////////////////////////////////////////////
     //
     #if (_MSC_VER > 1299)
    -static BOOL WINAPI SymEnumerateCallback(PSTR pszModule,
    +static BOOL WINAPI SymEnumerateCallback(PCSTR pszModule,
                                             DWORD64 base,
                                             PVOID pvUserContext)
     {
    ==== detours-2.1\samples\traceapi\_win32.cpp ====
    @@ -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_INFORMA
    TION *a0,
    +                                                        const SYSTEMTIME *a1,
                                                             LPSYSTEMTIME a2)
         = SystemTimeToTzSpecificLocalTime;
     
    @@ -7639,6 +7639,11 @@
     BOOL (__stdcall * Real_UpdateColors)(HDC a0)
         = UpdateColors;
     
    +/* Temporarily disable the "deprecated" warning for
    + * UpdateICMRegKeyA() and UpdateICMRegKeyW()
    + * since we still want to trace callers of the API. */
    +#pragma warning(push)
    +#pragma warning(disable:4995)
     BOOL (__stdcall * Real_UpdateICMRegKeyA)(DWORD a0,
                                              LPSTR a1,
                                              LPSTR a2,
    @@ -7650,6 +7655,7 @@
                                              LPWSTR a2,
                                              UINT a3)
         = UpdateICMRegKeyW;
    +#pragma warning(pop)
     
     BOOL (__stdcall * Real_UpdateResourceA)(HANDLE a0,
                                             LPCSTR a1,
    @@ -9709,7 +9715,7 @@
     }
     
     BOOL __stdcall Mine_CheckColorsInGamut(HDC a0,
    -                                       LPVOID a1,
    +                                       LPRGBTRIPLE a1,
                                            LPVOID a2,
                                            DWORD a3)
     {
    @@ -26018,7 +26024,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 +26158,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 +30246,8 @@
         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);

     

     

    Austin

     

    • Proposed As Answer bycodejedi Friday, June 06, 2008 4:32 PM
    •  
  • Saturday, April 12, 2008 3:15 AMbiff_tannen Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Austin:

     

    This worked perfectly! ( I had the same problem as the OP)

     

    Thanks for for posting the dif. I really appreciate it.

     

    I sucessfully built detours with:

     

    Microsoft Visual Studio 2008 Version 9.0.21022.8 RTM

     

     

    The only thing I am having trouble with now is that the cping client crashes whenever trying to connect to a cping server. I guess this is not a big deal but I cannot find out why it crashes. Other than that, all the tests seem to work.

     

    Thanks again,

    Biff

  • Thursday, November 13, 2008 7:02 PMMartin Johnston Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    That worked :)
  • Tuesday, March 10, 2009 6:12 PMMikeStramba Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Austin,

    Thanks for posting that "fix" !!!

    I just installed VC 8 Express and ran into the same errors.

    It would be nice if the code was "smart enough" (conditional compilation / ifdefs .. etc) to be able to compile with different versions of VC.

    Mike

    p.s. That _win32.cpp file is quite the beast .. or maybe it's small by M.S. standards ;\