您的位置:首页 >> 编程开发 >> Delphi >> 正文
RSS
 

Delphi中Hook技术全接触

http://www.rdxx.com 01年10月22日 10:31 互联网 我要投稿

关键词: Hook , Delphi , 技术 , OO
看到有的兄弟说Delphi下的Hook不好做,所以在下把每个Hook都在Delphi做了一下,觉得没啥问题,而且处理的方法较新颖,拿来让兄弟们探讨,关于hook问题,有不懂的问我就行,不过有的Hook我只做了个框架,没有具体实用作用,要做的兄弟自已完善就行了,呵呵,代码在下面,自已看啦..........
-------------------------------------------
                 我的联系方法:
                 oicq;       10772919
                 e-mail:     njhhack@21cn.com
                 homepage:   hotsky.363.net
--------------------------------------------

----------这是*.dll中的单元---------------
unit HookProc;


interface

uses windows,messages,sysutils;

const
 HTName:array[1..13] of pchar=(
 'CALLWNDPROC','CALLWNDPROCRET','CBT','DEBUG','GETMESSAGE','JOURNALPLAYBACK',
 'JOURNALRECORD','KEYBOARD','MOUSE','MSGFILTER','SHELL','SYSMSGFILTER','FOREGROUNDIDLE'
 );


function CallWndProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function CallWndRetProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function CBTProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function DebugProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function GetMsgProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function JournalPlaybackProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function JournalRecordProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function KeyboardProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function MouseProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function MessageProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function ShellProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function SysMsgProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function ForegroundIdleProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;

implementation

procedure SaveInfo(k:integer;str:string);stdcall;
var
 f:textfile;
 WorkPath:string;
begin
 WorkPath:=ExtractFilePath(ParamStr(0));
 assignfile(f,WorkPath+'Records.txt');
 if fileexists(WorkPath+'Records.txt')=false then rewrite(f)
 else append(f);
 //if strcomp(pchar(str),pchar('#13#10'))=0 then writeln(f,')
 //else write(f,str);
 writeln(f,HTName[k]+'----'+str);
 closefile(f);
end;



function CallWndProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
var
 pcs:TCWPSTRUCT;
begin
 pcs:=TCWPSTRUCT(PCWPSTRUCT(lParam)^);
 if nCode>=0 then
 begin
   if pcs.message=wm_lbuttonup then
   SaveInfo(1,format('hwnd=%x',[pcs.hwnd]));
 end;
 Result:=CallNextHookEx(0,nCode,wParam,lParam);
end;
//
function CallWndRetProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
begin
 Result:=CallNextHookEx(0,nCode,wParam,lParam);
end;
//
function CBTProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
共6页  第1页 第2页 第3页 第4页 第5页 第6页

 
 
标签: Hook , Delphi , 技术 , OO 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站