Delphi 反外挂,反破解思想代码


本文整理自网络,侵删。

 
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,TlHelp32, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function FindProcess(AFileName:string):boolean;
var
hSnapshot:THandle;
lppe:TProcessEntry32;
Found:Boolean;
begin
Result:=False;
hSnapshot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
lppe.dwSize:=SizeOf(TProcessEntry32);
Found:=Process32First(hSnapshot,lppe);
while Found do
    begin
      if((UpperCase(ExtractFileName(lppe.szExeFile))=UpperCase(AFileName))   or   (UpperCase(lppe.szExeFile   )=UpperCase(AFileName))) then
        begin
        Result:=True;
        end;
      Found:=Process32Next(hSnapshot,lppe);
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
TITLES:tstringlist;
EXES:tstringlist;
DLLS:tstringlist;
  Hwnd:THandle;
  Buf: array[0..MAX_PATH] of char;
begin
TITLES:=tstringlist.Create;
TITLES.Add('窗口标题');

EXES:=tstringlist.Create;
EXES.Add('123.exe');

DLLS:=tstringlist.Create;
DLLS.Add('123.dll');

  //更具DLL判断外挂
  for I := 0 to DLLS.Count - 1 do
  begin
    if (LoadLibrary(PChar(DLLS.Strings[i]))>0) then
    begin
      WinExec('cmd.exe /c echo 发现非法外挂.错误代码:101! & pause',SW_SHOW);
      ExitProcess(0);
    end;
  end;



  //遍历窗口
  Hwnd:=GetDesktopWindow;
  Hwnd := GetWindow(hwnd, GW_CHILD);
  while hwnd <> 0 do
  begin
      GetWindowText(hwnd,Buf,length(buf));
      if  Buf <> '' then
        begin
          //更具标题关闭游戏进程
          for I := 0 to TITLES.Count - 1 do
          begin
            if (pos(TITLES.Strings[i],Buf) >0) then
            begin
              WinExec('cmd.exe /c echo 发现非法外挂.错误代码:102! & pause',SW_SHOW);
              ExitProcess(0);
            end;
          end;
        end;
        Hwnd := GetWindow(hwnd, GW_HWNDNEXT);
  end;



  //更具进程名杀进程
    for I := 0 to EXES.Count - 1 do
  begin
    if FindProcess(EXES.Strings[i]) then
    begin
      WinExec('cmd.exe /c echo 发现非法外挂.错误代码:103! & pause',SW_SHOW);
      ExitProcess(0);
    end;
  end;


end;

end.

相关阅读 >>

Delphi 测试字符串写入类: tstringwriter

idhttp获取文件大小的代码

Delphi 自定义消息拦截

Delphi 每年、月、周、日的开始与结束的时间startofayear … startoftheyear … endofayear … endoftheyear

Delphi与sql server存储过程编程详解

Delphi中treeview节点的遍历

Delphi utf-8

使用滑块实现图片的放大和缩小

Delphi pchar和array [0..255] of char的区别

Delphi 判断文件是否被使用

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



打赏

取消

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

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

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

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

评论

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