⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dissectcodethread.pas

📁 冒险岛吸怪源码UCE的制作材料 用于冒险岛游戏的外挂
💻 PAS
📖 第 1 页 / 共 2 页
字号:

    //add new after i
    try
      inc(currentsize);
      if currentsize>=length(list) then
        setlength(list,length(list)+length(list)+512); //allocate more

      for j:=currentsize-1 downto i+1 do
        list[j]:=list[j-1];

      list[i].address:=address.address;
      list[i].codes:=1;
      list[i].code[0]:=address.code;

      list[i].nrofextracodes:=0;
      setlength(list[i].extracodes,0);
    except
      //

    end;
  end;

  procedure flushdata(prefix: string; var buffer: tjumparray);
  {
   //sorted and indexed. that should be fast enough
  }
  var i,j: integer;
      f: tfilestream;
      index: array of record  //
        address: dword;
        offset: dword;  //sure, you might want to use a 64 bit integer, but if that would be needed I'd rather put my head in a automated meatgrinder
      end;

      fname,fname2: string;

  begin
  exit; //dont flush

    if length(buffer)=0 then exit;
    
    fname:=cheatenginedir+'dissect\'+prefix+inttohex(buffer[0].address,8)+inttohex(buffer[length(buffer)-1].address,8);
    fname2:=fname;

    i:=2;
    while fileexists(fname) do
    begin
      fname:=fname2+'_'+inttostr(i);
      inc(i);
    end;
    fname:=fname+'.cod';

    i:=length(buffer);
    setlength(index,i); //max possible

    ForceDirectories(cheatenginedir+'dissect\');
    f:=tfilestream.Create(fname,fmcreate);
    try
      f.WriteBuffer(i,4); //number of addresses
      f.Seek(i*8,soFromCurrent); //fill in the index during the loop

      for i:=0 to length(buffer)-1 do
      begin
        index[i].address:=buffer[i].address;
        index[i].offset:=f.Position;
        f.WriteBuffer(buffer[i].address,4);
        j:=length(buffer[i].code);
        f.WriteBuffer(j,4);
        f.WriteBuffer(buffer[i].code[0],4*j);
      end;

      //write index
      f.Seek(4,soFromBeginning);
      f.WriteBuffer(index[0],i*8);
    finally
      f.free;
    end;

    //delete the old list to make room for the new one
    //for i:=0 to length(buffer)-1 do
      //setlength(buffer[i].code,0);
    setlength(buffer,0);
  end;

  procedure updatelist;
  var k,l,x,y: integer;

  begin


    if terminated then
    begin
      cun:=0;
      cc:=0;
      ccls:=0;
      exit;
    end;

    totalread:=bytesread+j;
    percentagedone:=trunc((bytesread+j)/totalmemory*100.0);
    currentaddress:=memoryregion[i].BaseAddress+j;

    if cun>0 then
    begin

      for k:=0 to cun-1 do
        insert(unconditionaljump,nrofunconditionaljumps,tempunconditionaljumplist[k]);

      inc(a);

      if a=buffersize div 2048 then
      begin
        //create the file to store it to
        flushdata('unc',unconditionaljump);
        a:=0;
      end;

    end;

    if cc>0 then
    begin
      for k:=0 to cc-1 do
        insert(conditionaljump,nrofconditionaljumps,tempconditionaljumplist[k]);

      inc(b);
      if b=buffersize div 2048 then
      begin
        flushdata('con',conditionaljump);
        b:=0;
      end;
    end;

    if ccls>0 then
    begin
      for k:=0 to ccls-1 do
        insert(calls,nrofcalls,tempcalls[k]);

      inc(c);
      if c=buffersize div 2048 then
      begin
        flushdata('call',calls);
        c:=0;
      end;
    end;


    cun:=0;
    cc:=0;
    ccls:=0;
  end;

  var sr: tsearchrec;
begin
  { Place thread code here }

  //delete the old dissection
  if ForceDirectories(cheatenginedir+'dissect\') then
  begin
    if findfirst(cheatenginedir+'dissect\*.*',faAnyFile,sr)=0 then
    begin
      repeat
        deletefile(cheatenginedir+'dissect\'+sr.Name);
      until findnext(sr)<>0;
    end;
  end;


  processid:=cefuncproc.ProcessID;
  address:=0;
  zeromemory(@mbi,sizeof(mbi));
  a:=0;
  b:=0;
  c:=0;
  totalmemory:=0;
  totalread:=0;

  maxregionsize:=0;
  totalmemory:=0;
  bytesread:=0;
  for i:=0 to length(memoryregion)-1 do
  begin
    if maxregionsize<memoryregion[i].MemorySize then
      maxregionsize:=memoryregion[i].MemorySize;
    inc(totalmemory,memoryregion[i].MemorySize);
  end;

  if totalmemory>0 then
  begin
    start:=memoryregion[0].BaseAddress;
    stop:=memoryregion[length(memoryregion)-1].BaseAddress+memoryregion[length(memoryregion)-1].MemorySize;
  end;

  setlength(temp,maxregionsize);

  cun:=0;
  cc:=0;
  ccls:=0;

  for i:=0 to length(memoryregion)-1 do
  begin
    if terminated then break;

    if readprocessmemory(processhandle,pointer(memoryregion[i].BaseAddress),@temp[0],memoryregion[i].MemorySize,br) then
    begin
      for j:=0 to memoryregion[i].MemorySize-1 do
      begin
        case temp[j] of
          $0f: //extra jump
          begin
            if j<memoryregion[i].MemorySize-5 then
            begin
              case temp[j+1] of
                $80..$8f: //conditional 4 bytes
                begin
                  ta:=memoryregion[i].BaseAddress+j+pdword(@temp[j+1])^+5;
                  if (ta<start) or (ta>stop) then continue;

                  tempconditionaljumplist[cc].address:=ta;
                  tempconditionaljumplist[cc].code:=memoryregion[i].baseaddress+j;
                  inc(cc);
                  if cc=128 then
                  begin
                    updatelist;
                    if terminated then break;
                  end;
                end;
              end;
            end;
          end;

          $70..$7f,$e3: //conditional jump (1 byte)
          begin
            if j<memoryregion[i].MemorySize-1 then
            begin
              ta:=memoryregion[i].BaseAddress+j+pbyte(@temp[j+1])^+2;
              if (ta<start) or (ta>stop) then continue;

              tempconditionaljumplist[cc].address:=ta;
              tempconditionaljumplist[cc].code:=memoryregion[i].baseaddress+j;
              inc(cc);
              if cc=128 then
              begin
                updatelist;
                if terminated then break;
              end;
            end;
          end;


          $e8: //call
          begin
            if j<memoryregion[i].MemorySize-4 then
            begin
              ta:=memoryregion[i].BaseAddress+j+pdword(@temp[j+1])^+5;
              if (ta<start) or (ta>stop) then continue;

              tempcalls[ccls].address:=ta;
              tempcalls[ccls].code:=memoryregion[i].baseaddress+j;
              inc(ccls);
              if ccls=128 then
              begin
                updatelist;
                if terminated then break;
              end;
            end;
          end;

          $e9: //jump onconditional (4 byte)
          begin
            if j<memoryregion[i].MemorySize-4 then
            begin
              ta:=memoryregion[i].BaseAddress+j+pdword(@temp[j+1])^+5;
              if (ta<start) or (ta>stop) then continue;

              tempunconditionaljumplist[cun].address:=ta;
              tempunconditionaljumplist[cun].code:=memoryregion[i].BaseAddress+j;
              inc(cun);
              if cun=128 then
              begin
                updatelist;
                if terminated then break;
              end;
            end;
          end;

          $eb: //jump (unconditional) 1 byte
          begin
            if j<memoryregion[i].MemorySize-1 then
            begin
              ta:=dword(memoryregion[i].BaseAddress)+j+pbyte(@temp[j+1])^+2;
              if (ta<start) or (ta>stop) then continue;
              
              tempunconditionaljumplist[cun].address:=ta;
              tempunconditionaljumplist[cun].code:=memoryregion[i].BaseAddress+j;
              inc(cun);
              if cun=128 then
              begin
                updatelist;
                if terminated then break;
              end;
            end;
          end;

        end;
      end;
    end;

    inc(bytesread,memoryregion[i].MemorySize);
    totalread:=bytesread;
    percentagedone:=trunc(bytesread/totalmemory*100.0);
    updatelist;
  end;


  flushdata('unc',unconditionaljump);
  flushdata('con',conditionaljump);
  flushdata('call',calls);
  done:=true;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -