[无聊]扫雷外挂(for win2000)

终于有时间干些无聊的事情了.于是偶打开Delphi,在Form1上摆了一个按钮,命名为Button1(汗,多标准的名字),然后输入以下代码:

unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

const
  BOMB_MAP_MAX_SIZE = 32 * 24;
  ADDR_MAPHEIGHT    = $01005A68;
  ADDR_MAPWIDTH     = $010056F8;
  ADDR_BOMBMAP      = $01005720;

type

  TWinMineData = class
  private
    FData: PByteArray;
    FWidth: Integer;
    FHeight: Integer;
  public
    constructor Create;
    destructor Destroy; override;
    procedure Init(AWnd: HWND);
    function GetAt(X, Y: Integer): Byte;
    property Width: Integer read FWidth;
    property Height: Integer read FHeight;
  end;

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    function GetBlockPoint(AWnd: HWND; X, Y: Integer): TPoint;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  Wnd: HWND;
  Data: TWinMineData;
  I, J: Integer;
  Pt: TPoint;
begin
  Wnd := FindWindow('扫雷', nil);
  if Wnd = 0 then ShowMessage('请先启动扫雷')
  else
  begin
    Data := TWinMineData.Create;
    try
      Data.Init(Wnd);
      for J := 0 to Data.Height - 1 do
      begin
        for I := 0 to Data.Width - 1 do
        begin
          Pt := GetBlockPoint(Wnd, I, J);
          if (Data.GetAt(I, J) and $80) <> 0 then
          begin
            PostMessage(Wnd, WM_RBUTTONDOWN, 0, MAKELPARAM(Pt.X, Pt.Y));
            PostMessage(Wnd, WM_RBUTTONUP, 0, MAKELPARAM(Pt.X, Pt.Y));
          end
          else
          begin
            PostMessage(Wnd, WM_LBUTTONDOWN, 0, MAKELPARAM(Pt.X, Pt.Y));
            PostMessage(Wnd, WM_LBUTTONUP, 0, MAKELPARAM(Pt.X, Pt.Y));
          end;
        end;
      end;
    finally
      FreeAndNil(Data);
    end;
  end;
end;

{ TWinMineData }

constructor TWinMineData.Create;
begin
  FData := AllocMem(BOMB_MAP_MAX_SIZE);
end;

destructor TWinMineData.Destroy;
begin
  FreeMem(FData);
  inherited;
end;

function TWinMineData.GetAt(X, Y: Integer): Byte;
begin
  Result := FData[Y * 32 + (X + 1)];
end;

procedure TWinMineData.Init(AWnd: HWND);
var
  ProcId: Cardinal;
  HProc: HMODULE;
  Readed: Cardinal;
begin
  ProcId := 0;
  GetWindowThreadProcessId(AWnd, ProcId);
  if ProcId = 0 then raise Exception.Create('process id get failed');
  HProc := OpenProcess(PROCESS_VM_READ, False, ProcId);
  try
    ReadProcessMemory(HProc, Pointer(ADDR_MAPWIDTH), @FWidth, 4, Readed);
    ReadProcessMemory(HProc, Pointer(ADDR_MAPHEIGHT), @FHeight, 4, Readed);
    ReadProcessMemory(HProc, Pointer(ADDR_BOMBMAP), FData, BOMB_MAP_MAX_SIZE, Readed);
  finally
    CloseHandle(HProc);
  end;
end;

function TForm1.GetBlockPoint(AWnd: HWND; X, Y: Integer): TPoint;
begin
  Result.X := X * 16 + 19;
  Result.Y := Y * 16 + 64;
end;

end.

于是偶也当了一回达淫-___-b 惭愧惭愧~~

这是运行后的截图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值