Newbie pointer confusion for ExtTextOutA

c++ / delphi package - dll injection and api hooking
Post Reply
mdevoe
Posts: 14
Joined: Thu Jul 14, 2005 5:42 pm
Location: South Florida
Contact:

Newbie pointer confusion for ExtTextOutA

Post by mdevoe »

Hi All,

This is no doubt something I’m doing wrong. I’ve not run into trouble hooking most API’s but for some reason, the target app crashes when I hook ExtTextOutA. The app is crashing after my code executes. I’m probably not defining the next hook or the hook proc properly but still can’t figure it out.

Here is my definition for the “next hook”

BOOL (WINAPI *ExtTextOutANext) (HDC hdc,
int X,
int Y,
UINT fuOptions,
const RECT *lprc,
LPCSTR lpString,
UINT cbCount,
const INT *lpDx);


Here is my hook proc…

// ****************************** ExtTextOutA
BOOL ExtTextOutAHookProc(HDC hdc,
int X,
int Y,
UINT fuOptions,
const RECT *lprc,
LPCSTR lpString,
UINT cbCount,
const INT *lpDx)
{


BOOL result = ExtTextOutANext(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx);

sendWindowMessage("999" + DL + "ExtTextOutA:" + lpString);

return result;
}

I’ve been API hooking for years in PowerBasic and just recently switched to MS C++ so I’m probably screwing this up because of pointers. Any idea what I need to change keep the target app from crashing? The target app crashes after my call returns… not before, not in my code but after my code returns.

Thanks in advance for any words of wisdom.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Newbie pointer confusion for ExtTextOutA

Post by madshi »

You're missing the "WINAPI" for your hook proc.

That's the most common mistake, and always the first thing I check... :)
mdevoe
Posts: 14
Joined: Thu Jul 14, 2005 5:42 pm
Location: South Florida
Contact:

Re: Newbie pointer confusion for ExtTextOutA

Post by mdevoe »

Well that is embarrassing. Thanks for the quick reply. I couldn’t see the forest for the trees and got hung up on the const definition and pointers. Thanks again. I can now stop pounding my head on the keyboard.
Post Reply