Hooking FindResourceExA problem

c++ / delphi package - dll injection and api hooking
Post Reply
Mazinger
Posts: 33
Joined: Wed Jan 26, 2005 6:26 am

Hooking FindResourceExA problem

Post by Mazinger »

Hi,

I'm hooking FindResourceExA API from kernel32.dll. This is my hooked function:

Function FindResourceExA_API(hModule: HMODULE; lpType, lpName: PAnsiChar; wLanguage: Word): HRSRC; stdcall;
Begin
{$IFDEF DEBUG}
Try
writeDebug(Format('findResourceExA: API lpName=%s',[StrPas(lpName)]));
Except
On E:Exception do MessageBox(0,PChar(E.Message),'FindResourceExA Exception 3',MB_OK);
End;
{$ENDIF}

Result:=FindResourceExA_Next(hModule,lpType,lpName,wLanguage);

End;

The problem is the line with the writeDebug procedure is allways signaling an Access Violation Exception. Why?

Thanks in advance for your help.
Nico Bendlin
Posts: 46
Joined: Fri Apr 28, 2006 1:17 pm

Post by Nico Bendlin »

lpName can be a string pointer or a resource identifier (see MakeIntResource).

Code: Select all

function IsIntResource(AName: Pointer): Boolean; inline;
begin
  Result := (Cardinal(AName) shr 16) = 0;
end;
Mazinger
Posts: 33
Joined: Wed Jan 26, 2005 6:26 am

Post by Mazinger »

Ten points to you!

Thanks for your help.
Post Reply