{ 检查自己的进程的父进程是否为Explorer.exe,否则是被调试器加载了 } { 不过注意,控制台程序的父进程在WinNT下是Cmd.exe哦!} { 注意加载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 ExplProc := Pn.th32ProcessID; //Explorer的PID Found := Process32Next(sHandle, Pn); //查找下一个 end; //嗯,父进程不是Explorer,是调试器…… if ParentProc <> ExplProc then begin TerminateProcess(H, 0); //杀之!除之而后快耶! :) //你还可以加上其它什么死机代码来消遣消遣这位可爱的Cracker :) end; end;
上一页 [1] [2]
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18