The dll code below :
Code: Select all
library WinText;
{$IMAGEBASE $5a800000}
uses Windows, madCodeHook, madRemote, madStrings, SysUtils;
var
SetWindowTextANext : function (hWnd: HWND; lpString: PAnsiChar): BOOL; stdcall;
SetWindowTextWNext : function (hWnd: HWND; lpString: PWideChar): BOOL; stdcall;
TextOutANext : function (DC: HDC; X, Y: Integer; Str: PAnsiChar; Count: Integer): BOOL; stdcall;
TextOutWNext : function (DC: HDC; X, Y: Integer; Str: PWideChar; Count: Integer): BOOL; stdcall;
ExtTextOutANext : function (DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PAnsiChar; Count: Longint; Dx: PInteger): BOOL; stdcall;
ExtTextOutWNext : function (DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PWideChar; Count: Longint; Dx: PInteger): BOOL; stdcall;
procedure WriteLog(Log : String);
var
f : TextFile;
begin
AssignFile(f, 'log.txt');
if FileExists('log.txt') then
Reset(f)
else
Rewrite(f);
Writeln(f, Log);
CloseFile(f);
end;
function SetWindowTextACallback(hWnd: HWND; lpString: PAnsiChar): BOOL; stdcall;
begin
WriteLog(lpString);
Result :=SetWindowTextANext(hWnd, lpString);
end;
function SetWindowTextWCallback(hWnd: HWND; lpString: PWideChar): BOOL; stdcall;
begin
WriteLog(lpString);
Result :=SetWindowTextWNext(hWnd, lpString);
end;
function TextOutACallback(DC: HDC; X, Y: Integer; Str: PAnsiChar; Count: Integer): BOOL; stdcall;
begin
WriteLog(Str);
Result :=TextOutANext(DC, X, Y, Str, Count);
end;
function TextOutWCallback(DC: HDC; X, Y: Integer; Str: PWideChar; Count: Integer): BOOL; stdcall;
begin
WriteLog(Str);
Result :=TextOutWNext(DC, X, Y, Str, Count);
end;
begin
if GetVersion and $80000000 = 0 then
begin
HookAPI('user32.dll', 'SetWindowTextA', @SetWindowTextACallback, @SetWindowTextANext);
HookAPI('user32.dll', 'SetWindowTextW', @SetWindowTextWCallback, @SetWindowTextWNext);
HookAPI('gdi32.dll', 'TextOutA', @TextOutACallback, @TextOutANext);
HookAPI('gdi32.dll', 'TextOutW', @TextOutWCallback, @TextOutWNext);
end;
end.