delphi 突破主动防御


本文整理自网络,侵删。

 Delphi:

  {注意加载TlHelp32.pas单元}

 procedure CheckParentProc;
var //检查自己的进程的父进程
Pn: TProcesseNtry32;
sHandle:THandle;
H,ExplProc,ParentProc:Hwnd;
Found:Boolean;
Buffer:array[0..1023]of Char;
Path:string;
begin
H:= 0;
ExplProc:= 0;
ParentProc:= 0;
//得到Windows的目录;
SetString(Path,Buffer,GetWindowsDirectory(Buffer,Sizeof(Buffer)- 1));
Path:= UpperCase(Path)+ '\Explorer.EXE';//得到Explorer的路径
//得到所有进程的列表快照
sHandle:= CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
Found:= Process32First(sHandle,Pn);//查找进程
while Found do //遍历所有进程
begin
if Pn.szExeFile = ParamStr(0) then //自己的进程
begin
ParentProc:= Pn.th32ParentProcessID;//得到父进程的进程ID
//父进程的句柄
H:= OpenProcess(PROCESS_ALL_ACCESS,True,Pn.th32ParentProcessID);
end
else if UpperCase(Pn.szExeFile)= Path then
begin
ExplProc:= Pn.th32ProcessID;//Ex plorer的PID
Found:= Process32Next(sHandle,Pn);//查找下一个
end;

//父进程不是Explorer,是调试器……
if ParentProc <> ExplProc then
begin
TerminateProcess(H,0);
while 1<>1 do
Application.MessageBox('', '', MB_OK + MB_ICONSTOP);
end;
end;
end;

相关阅读 >>

Delphi下遍历指定目录下指定类型文件的函数

Delphi firedac sqlite不能插入"&"符号

Delphi strutils.reversestring - 翻转字符串

Delphi 用内存流文件流资源生成客户端

Delphi 在unicodestring中使用utf-8字符串

Delphi 保存hotkey1.hotkey值

Delphi 字符串常识

Delphi 判断一个颜色是否是亮色

Delphi xe10 创建匿名线程

isleapyear:返回给定的年份是否是闰年

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...