看流星社区

 找回密码
 注册账号
查看: 2898|回复: 0

[Delphi] 检测自己程序执行是否为系统执行,防止自动脱壳或反编译

[复制链接]

该用户从未签到

发表于 2011-3-31 08:53:16 | 显示全部楼层 |阅读模式
uses TlHelp32;
------------

var
//检查自己的进程的父进程
        Pn:TProcesseNtry32;
        sHandle:THandle;

  Found:Boolean;
  Buffer:array[0..1023]of Char;
  runexe,ExeFile,Path:string;
  begin
//反调试

// H:= 0;
// ExplProc:= 0;
  //ParentProc:= 0;
  //得到Windows的目录
  SetString(Path,Buffer, GetWindowsDirectory(Buffer,Sizeof(Buffer)- 1));
  ExeFile:= UpperCase(Path)+ '\EXPLORER.EXE';//得到Explorer的路径
  //得到所有进程的列表快照
//  ShowMessage(ParamStr(0));
  sHandle:= CreateToolHelp32SnapShot(TH32CS_SNAPALL,0);
  Found:= Process32First(sHandle,Pn);//查找进程
// if found then  ShowMessage('1');
  while Found do //遍历所有进程
  begin

  if pos(UpperCase(Pn.szExeFile),UpperCase( ParamStr(0)))>0 then //自己的进程
  begin
//        ShowMessage(UpperCase(Pn.szExeFile));
          ParentProc:= Pn.th32ParentProcessID;//得到父进程的进程ID
//        ShowMessage(UpperCase(get_proc_name_nt(ParentProc)));
  //      ShowMessage(UpperCase(ExeFile));
  //父进程不是系统进程
  if  UpperCase(get_proc_name_nt(ParentProc))<> UpperCase(ExeFile) then
      begin
          //父进程的句柄
    ParentHandle:= OpenProcess(PROCESS_ALL_ACCESS,True,Pn.th32ParentProcessID);
    Application.Terminate;
      TerminateProcess(ParentHandle,0);
      end;
  //      ShowMessage(inttostr(ParentHandle));
  end;
  Found:= Process32Next(sHandle,Pn);//查找下一个

  end;


end;

现在很多人喜欢用DEDE或其他软件进行自动反编译delphi的程序,把这子程序加入到程序建窗体里,可以达到目的
以后教大家如何用vmp加壳进行虚拟机加密
点击按钮快速添加回复内容: 支持 高兴 激动 给力 加油 苦寻 生气 回帖 路过 感恩
您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

小黑屋|手机版|Archiver|看流星社区 |网站地图

GMT+8, 2024-3-29 17:34

Powered by Kanliuxing X3.4

© 2010-2019 kanliuxing.com

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