Exetools  

Go Back   Exetools > General > Source Code

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #16  
Old 05-12-2016, 14:42
atom0s's Avatar
atom0s atom0s is offline
Family
 
Join Date: Jan 2015
Location: 127.0.0.1
Posts: 431
Rept. Given: 26
Rept. Rcvd 130 Times in 67 Posts
Thanks Given: 54
Thanks Rcvd at 837 Times in 306 Posts
atom0s Reputation: 100-199 atom0s Reputation: 100-199
Here is an example of hooking Win32 API without a trampoline since they are not always needed:
(Error checking code omitted for ease of reading.)

PHP Code:
extern "C"
{
    
HWND (WINAPI *Real_CreateWindowExA)(DWORDLPCSTRLPCSTRDWORDintintintintHWNDHMENUHINSTANCELPVOID) = CreateWindowExA;
};

/**
 * user32!CreateWindowExA detour callback.
 */
HWND __stdcall Mine_CreateWindowExA(DWORD dwExStyleLPCSTR lpClassNameLPCSTR lpWindowNameDWORD dwStyleint xint yint nWidthint nHeightHWND hWndParentHMENU hMenuHINSTANCE hInstanceLPVOID lpParam)
{
    
// Do your personal alterations and such here..
    
    
return Real_CreateWindowExA(dwExStylelpClassNamelpWindowNamedwStylexynWidthnHeighthWndParenthMenuhInstancelpParam);
}

// Attach the detour..
DetourTransactionBegin();
DetourUpdateThread(::GetCurrentThread());
DetourAttach(&(PVOID&)Real_CreateWindowExAMine_CreateWindowExA);
DetourTransactionCommit(); 
Reply With Quote
The Following 6 Users Say Thank You to atom0s For This Useful Post:
chants (09-02-2018), NeWOT (08-12-2016), sh3dow (05-13-2016), xenocidewiki (05-13-2016)
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SignatureToDetour: Converts IDA Pro signatures to C++ Detours sh3dow Source Code 2 01-23-2017 21:14
microsoft ddk kP^ General Discussion 3 10-20-2003 20:39


All times are GMT +8. The time now is 08:06.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )