| 发表于:2007-04-18 10:16:30 楼主 |
hook api-之進程保護 http://www.98exe.net/article/c/2006-04-05/1504.html 在網上看到了這一篇文章,按提供的源碼編譯一下該dll,發現裡面用到的processhandletoid,processidtofilename和postext函數代碼沒有附上,請問如何解決?或有沒有其他方法能達到同樣的效果?dll代碼如下: library dll; uses windows, sysutils, classes; const prg_name = 'ddos.exe '; var terminateprocessnext : function (processhandle, exitcode: dword) : bool; stdcall; ntterminateprocessnext : function (processhandle, exitcode: dword) : dword; stdcall; {$r *.res} function thisisourprocess(processhandle: dword) : boolean; var pid : dword; arrch : array [0..max_path] of char; begin pid := processhandletoid(processhandle); result := (pid <> 0) and processidtofilename(pid, arrch) and (postext(prg_name, arrch) > 0); end; function terminateprocesscallback(processhandle, exitcode: dword) : bool; stdcall; begin if thisisourprocess(processhandle) then begin result := false; setlasterror(error_access_denied); end else result := terminateprocessnext(processhandle, exitcode); end; function ntterminateprocesscallback(processhandle, exitcode: dword) : dword; stdcall; const status_access_denied = $c0000022; begin if thisisourprocess(processhandle) then begin result := status_access_denied end else result := ntterminateprocessnext(processhandle, exitcode); end; begin if getversion and $80000000 = 0 then hookapi( 'ntdll.dll ', 'ntterminateprocess ', @ntterminateprocesscallback, @ntterminateprocessnext) else hookapi( 'kernel32.dll ', 'terminateprocess ', @terminateprocesscallback, @terminateprocessnext); end. |
|
|
|
|