0

I need help for a project that uses Microsoft Detours.

Premise: I am trying to use a class I found in a project on CodeProject that uses the Detours library. I downloaded the latest version of Detuors from Github and recompiled it, but I can't find the definition of the macro DETOUR_TRAMPOLINE. I imagine that in the new version of Detours it has been replaced in some way.

In the project that uses this missing macro, it's used like this:

DETOUR_TRAMPOLINE(BOOL WINAPI Detour_EnableScrollBar(HWND hwnd, int wSBflags, UINT wArrows), EnableScrollBar);
DETOUR_TRAMPOLINE(BOOL WINAPI Detour_GetScrollInfo  (HWND hwnd, int fnBar, LPSCROLLINFO lpsi), GetScrollInfo);
DETOUR_TRAMPOLINE(int  WINAPI Detour_GetScrollPos   (HWND hwnd, int nBar), GetScrollPos);
DETOUR_TRAMPOLINE(BOOL WINAPI Detour_GetScrollRange (HWND hwnd, int nBar, LPINT lpMinPos, LPINT lpMaxPos), GetScrollRange);
DETOUR_TRAMPOLINE(int  WINAPI Detour_SetScrollInfo  (HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw), SetScrollInfo);
DETOUR_TRAMPOLINE(int  WINAPI Detour_SetScrollPos   (HWND hwnd, int nBar, int nPos, BOOL fRedraw), SetScrollPos);
DETOUR_TRAMPOLINE(int  WINAPI Detour_SetScrollRange (HWND hwnd, int nBar, int nMinPos, int nMaxPos, BOOL fRedraw), SetScrollRange);
DETOUR_TRAMPOLINE(BOOL WINAPI Detour_ShowScrollBar  (HWND hwnd, int wBar, BOOL fShow), ShowScrollBar);

Question:

  • Is there a way in the new version of Detours to get the same effect as the old macro?
  • If it is not asking too much, can I ask you some advice on how I could rewrite the code I reported above to be compatible with the new method?

Thanks in advance for the help!

pallagommosa
  • 558
  • 7
  • 15
  • 1
    Lol, I entereded "DETOUR_TRAMPOLINE" in the search box of the Microsoft GitHub page, and GitHub responded: "Whoa there! You have triggered an abuse detection mechanism. Please wait a few minutes before you try again; in some cases this may take up to an hour. " :P – JHBonarius Nov 28 '19 at 08:48
  • 1
    I did some googling on the macro, and it seems that the macro was in v1.5 of detours... while they're at >v4 now.. there is no guarantee just rewriting the code you show will fix the issue. You probably need to run your code with the detours version it was designed for... or largely rewrite it. – JHBonarius Nov 28 '19 at 08:59
  • @JHBonarius I was afraid it was the case ... thanks for the help! – pallagommosa Nov 28 '19 at 09:33

2 Answers2

0

Googling for "#define DETOUR_TRAMPOLINE" brings up:

#define DETOUR_TRAMPOLINE(trampoline,target) \
static PVOID __fastcall _Detours_GetVA_##target(VOID) \
{ \
    return ⌖ \
} \
Jonathan Potter
  • 36,172
  • 4
  • 64
  • 79
0

As JHBonarius explained in his comment, many versions of Detours have been released since the macro in question was deleted, so it's probably not so easy to make a quick change to the code in question.

I wanted to point out to those interested a very simple and contained library that, like Detours, allows you to redirect the Windows API (even if it provides much less functionality).

The library in question is MinHook, and the source code is still available here.

pallagommosa
  • 558
  • 7
  • 15