|
|
unit myDLl;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls , ComCtrls, XPMan;
type
TfrmCall = class(TForm)
XPManifest1: TXPManifest;
btnCall: TButton;
procedure btnCallClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmCall: TfrmCall;
function HookProc(nCode:Integer;WParam: WPARAM;LParam PARAM) RESULT;stdcall;
function HookOn(lpHwnd:HWND;lpType ongint) ongint;stdcall;export;
function HookOff:Boolean;stdcall;export;
implementation
var
hHk: HHOOK=0;
hmod: Pointer; //Hinstance
{$R *.dfm}
function HookProc(nCode:Integer;WParam: WPARAM;LParam PARAM) RESULT;stdcall;
var
bKeyUp:boolean;
begin
//接收按键*开始挂钩DLL
bKeyUp := lparam and (1 shl 31) = 0;
if (wParam = VK_MULTIPLY) and (nCode = HC_ACTION) and bKeyUp then
begin
if frmCall = nil then
begin
frmCall := TfrmCall.Create(Application);
frmCall.Show;
end
else
frmCall.Visible := not frmCall.Visible ;
end;
Result := CallNextHookEx(hHk,nCode,WParam,LParam);
end;
function HookOn(lpHwnd:HWND;lpType ongint): Longint;stdcall; export;
var
hThread :Cardinal;
begin
hThread :=GetWindowThreadProcessId(lpHwnd,hmod);
//注入开始
hHk :=SetWindowsHookEx(lpType,@HookProc,hInstance,hThread); // WH_KEYBOARD
Result :=hHk
end;
function HookOff:Boolean;stdcall; export;
begin
if hHk<>0 then
begin
//移除挂钩
UnHookWindowsHookEx(hHk);
hHk :=0;
Result :=true;
end
else
Result :=false;
end;
procedure TfrmCall.btnCallClick(Sender: TObject);
var
Address ointer;
begin
Address := Pointer($0045B868); //CALL地址
asm
// 汇编代码开始处;
//注意,Delphi 的16进制表示法是$开头,VB是 &H C++ 是0x
pushad
mov eax,$1
mov ebx,$2
mov ecx,$3
call Address //CALL 调用
popad
end;
end;
end.
http://yunpan.cn/QX56iwJNKLAw8 |
|