messageboxhook.dpr

来自「how you can hook functions by small size」· DPR 代码 · 共 22 行

DPR
22
字号
program MessageBoxHook;

uses Windows, MagicApiHook;

var
 MainMessageBoxA: function(hWnd:HWND; lpText,lpCaption:PAnsiChar; uType:UINT):Integer; stdcall;

(******************************************************************************)
function HookMessageBoxA(hWnd:HWND; lpText,lpCaption:PAnsiChar; uType:UINT):Integer; stdcall;
begin
 Result:=MainMessageBoxA(hWnd,'Hooked MessageBox',lpCaption,uType);
end;
(******************************************************************************)
begin
 MessageBox(0,'Message1','Message',MB_ICONINFORMATION);
 ApiHook('user32.dll','MessageBoxA',nil,@HookMessageBoxA,@MainMessageBoxA);
 MessageBox(0,'Message1','Message',MB_ICONINFORMATION);
 MainMessageBoxA(0,'Message1','Message',MB_ICONINFORMATION);
 ApiUnHook('user32.dll','MessageBoxA',nil,@HookMessageBoxA,@MainMessageBoxA);
 MessageBox(0,'Message1','Message',MB_ICONINFORMATION);
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?