找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 185|回复: 0

hook32

[复制链接]

1793

主题

457

回帖

0

积分

管理员

积分
0
发表于 2013-8-29 08:32:40 | 显示全部楼层 |阅读模式
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;LParamPARAM)RESULT;stdcall;
function HookOn(lpHwnd:HWND;lpTypeongint)ongint;stdcall;export;
function HookOff:Boolean;stdcall;export;

implementation

var
hHk: HHOOK=0;
hmod: Pointer; //Hinstance


{$R *.dfm}

function HookProc(nCode:Integer;WParam: WPARAM;LParamPARAM)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;lpTypeongint): 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
  Addressointer;
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
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

果子博客
扫码关注微信公众号

Archiver|手机版|小黑屋|风叶林

GMT+8, 2026-2-1 12:36 , Processed in 0.078883 second(s), 21 queries .

Powered by 风叶林

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表