Click here to Skip to main content
15,893,337 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Question_DebugHeapTag error Pin
Eytukan6-Mar-06 5:13
Eytukan6-Mar-06 5:13 
AnswerRe: _DebugHeapTag error Pin
toxcct6-Mar-06 6:59
toxcct6-Mar-06 6:59 
QuestionMicrosoft detour + hook winapi functions Pin
David-coder6-Mar-06 5:08
David-coder6-Mar-06 5:08 
AnswerRe: Microsoft detour + hook winapi functions Pin
Stephen Hewitt6-Mar-06 11:46
Stephen Hewitt6-Mar-06 11:46 
GeneralRe: Microsoft detour + hook winapi functions Pin
David-coder7-Mar-06 6:06
David-coder7-Mar-06 6:06 
GeneralRe: Microsoft detour + hook winapi functions Pin
Stephen Hewitt7-Mar-06 12:08
Stephen Hewitt7-Mar-06 12:08 
GeneralRe: Microsoft detour + hook winapi functions Pin
David-coder8-Mar-06 3:46
David-coder8-Mar-06 3:46 
GeneralRe: Microsoft detour + hook winapi functions Pin
Stephen Hewitt8-Mar-06 11:29
Stephen Hewitt8-Mar-06 11:29 
Here's how I use detours:

DETOUR_TRAMPOLINE( BOOL WINAPI Tram_EnableWindow(HWND hWnd, BOOL bEnable),
     EnableWindow )
 
BOOL WINAPI My_EnableWindow( HWND hWnd, BOOL bEnable )
{
     // Do stuff here.
 
     return Tram_EnableWindow(hWnd, bEnable); // Call original API.
}
  
void ApplyDetours()
{
     DetourFunctionWithTrampoline((PBYTE)Tram_EnableWindow, (PBYTE)My_EnableWindow); // Apply.
}
 
void RemoveDetours()
{
     DetourRemove((PBYTE)Tram_EnableWindow, (PBYTE)My_EnableWindow); // Remove.
}


Because of the way Detours works, the address of the API before the detours is applied is the address of the modified function after it is applied - This is why it's do powerful as the hook function is called regardless of the calling mechanism (unlike IAT patching for example). The address of the original function after the detours has been applied is the address of the trampoline function. I don't know what you mean when you say, "Then read the bytes and copy them with CopyMemory()" - Detours takes care of all this for you.

Steve
GeneralRe: Microsoft detour + hook winapi functions Pin
David-coder9-Mar-06 7:29
David-coder9-Mar-06 7:29 
GeneralRe: Microsoft detour + hook winapi functions Pin
Stephen Hewitt9-Mar-06 11:25
Stephen Hewitt9-Mar-06 11:25 
GeneralRe: Microsoft detour + hook winapi functions Pin
David-coder20-Mar-06 2:47
David-coder20-Mar-06 2:47 
QuestionArrays and SendMessage Pin
Waldermort6-Mar-06 4:33
Waldermort6-Mar-06 4:33 
AnswerRe: Arrays and SendMessage Pin
Iain Clarke, Warrior Programmer6-Mar-06 4:46
Iain Clarke, Warrior Programmer6-Mar-06 4:46 
GeneralRe: Arrays and SendMessage Pin
Waldermort6-Mar-06 4:56
Waldermort6-Mar-06 4:56 
Questionisolate differents parts of the string Pin
SWDevil6-Mar-06 4:20
SWDevil6-Mar-06 4:20 
AnswerRe: isolate differents parts of the string Pin
toxcct6-Mar-06 4:24
toxcct6-Mar-06 4:24 
GeneralRe: isolate differents parts of the string Pin
Roger Stoltz6-Mar-06 5:01
Roger Stoltz6-Mar-06 5:01 
GeneralRe: isolate differents parts of the string Pin
SWDevil6-Mar-06 5:04
SWDevil6-Mar-06 5:04 
GeneralRe: isolate differents parts of the string Pin
David Crow6-Mar-06 5:41
David Crow6-Mar-06 5:41 
AnswerRe: isolate differents parts of the string Pin
James R. Twine6-Mar-06 5:15
James R. Twine6-Mar-06 5:15 
QuestionEvents disappearing Pin
RichardS6-Mar-06 4:13
RichardS6-Mar-06 4:13 
AnswerRe: Events disappearing Pin
Blake Miller6-Mar-06 5:48
Blake Miller6-Mar-06 5:48 
GeneralRe: Events disappearing Pin
RichardS6-Mar-06 6:19
RichardS6-Mar-06 6:19 
Questionerror handle Pin
derek76-Mar-06 3:59
derek76-Mar-06 3:59 
AnswerRe: error handle Pin
toxcct6-Mar-06 4:11
toxcct6-Mar-06 4:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.