码迷,mamicode.com
首页 > 其他好文 > 详细

扫扫扫

时间:2018-07-11 22:57:18      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:get   pre   string   edit   obj   orm   lse   hand   ring   

procedure TForm1.Button1Click(Sender: TObject);
var
  hGame: THandle;
  pid, ProcessID: Cardinal;
  readCount: Cardinal;
  arrByte:array[0..1023] of Byte;
  gWidth, gHeight: Integer;
  totalBytes: Integer;
  x, y: Integer;
  index: Byte;
  str, str2: string;
begin
  RichEdit1.Clear;
  str := ‘‘;
  hGame := FindWindow(‘扫雷‘, ‘扫雷‘);
  if hGame > 0 then
  begin
    RichEdit1.Lines.Add(‘游戏句柄:‘ + IntToStr(hGame));
    GetWindowThreadProcessId(hGame, pid);
    RichEdit1.Lines.Add(‘游戏PID:‘ + IntToStr(pid));


    ProcessID:=OpenProcess(PROCESS_ALL_ACCESS,False,PID);   // 打开进程
    RichEdit1.Lines.Add(‘游戏ProcessID:‘ + IntToStr(ProcessID));

    ReadProcessMemory(ProcessID, Pointer(16798520), @gHeight, SizeOf(gHeight), readCount);
    RichEdit1.Lines.Add(‘游戏高度:‘ + IntToStr(gHeight));
    ReadProcessMemory(ProcessID, Pointer(16798516), @gWidth, SizeOf(gWidth), readCount);
    RichEdit1.Lines.Add(‘游戏宽度:‘ + IntToStr(gWidth));

    totalBytes := 765;//gHeight * 32;

    ZeroMemory(@arrByte[0], SizeOf(arrByte));
    ReadProcessMemory(ProcessID, Pointer(16798561), @arrByte, totalBytes, readCount);
    RichEdit1.Lines.Add(‘读取内存字节数:‘ + IntToStr(readCount));

    for y := 0 to gHeight - 1 do
    begin
      str2 := ‘‘;
      for x := 0 to gWidth - 1 do
      begin
        index := x + y * 32;

        if arrByte[index] <> $8F then
        begin
          str := str + ‘0  ‘;
          str2 := str2 + IntToHex(arrByte[index], 2) + ‘  ‘;
          SendMessage(hGame, WM_LBUTTONDOWN, 0, MakeLParam(20 + x * 16, 62 + y * 16));
          SendMessage(hGame, WM_LBUTTONUP, 0, MakeLParam(20 + x * 16, 62 + y * 16));
        end
        else
        begin
          str := str + ‘X  ‘;
          str2 := str2 + ‘8F  ‘;
        end;
      end;
      str := str + ‘        ‘ + str2 + #13;
    end;
    RichEdit1.Lines.Add(str);
  end
  else
    ShowMessage(‘没有打开游戏‘);
end;

  

扫扫扫

标签:get   pre   string   edit   obj   orm   lse   hand   ring   

原文地址:https://www.cnblogs.com/onlyou13/p/9296929.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!