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

📄 cefuncproc.pas.svn-base

📁 这是一段游戏修改工具的源代码.ring3功能由dephi开发,驱动是C开发.希望对大家有帮助
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
  result:=0;
  for i:=length(s) downto 1 do
    if s[i]='1' then result:=result+trunc(power(2,length(s)-i ));
end;

function Inttobin(i: int64): string;
var temp,temp2: string;
    j: integer;
begin
  temp:='';
  while i>0 do
  begin
    if (i mod 2)>0 then temp:=temp+'1'
                   else temp:=temp+'0';
    i:=i div 2;
  end;

  temp2:='';
  for j:=length(temp) downto 1 do
    temp2:=temp2+temp[j];
  result:=temp2;
end;

function getbit(bitnr: integer; bt: Byte):integer;
begin
  if (trunc(power(2,bitnr)) and bt)>0 then result:=1 else result:=0;
end;

function scanbits(var found: dword;number:dword;var bytep: pbyte;nrofbits,i,actualread: integer): boolean;
var j,k,l,m: integer;
    actualwrite: dword;
    tempcount: integer;
    tempj,tempk: integer;
    tempb: pbyte;
begin
  for j:=0 to actualread-1 do
  begin

    //scan each bit till you find  bitarray[bittofind]
    for k:=0 to 7 do
    begin
      tempb:=bytep;
      //see if there are enough bits to scan, if not, save the bits to be scanned and exit
      //bitsleft=((actualread-j)*8) - k
      if nrofbits>(((actualread-j)*8) - k) then
      begin
        tempcount:=(((actualread-j)*8) - k);     //should always be nrofbits-1
        setlength(tempbits,nrofbits);

        tempk:=k;
        for l:=1 to tempcount do
        begin
          tempbits[l]:=getbit(tempk,bytep^);
          inc(tempk);
          if tempk>7 then
          begin
            inc(bytep);
            tempk:=0;
          end;
        end;
        result:=true;
        exit;
      end;

      m:=k;
      for l:=0 to nrofbits-1 do
      begin
        if bitscan[l]<>2 then
          if getbit(m,tempb^)<>bitscan[l] then break;

        if l=nrofbits-1 then
        begin
          //foundit
          foundaddressb[found].address:=memoryregion[i].BaseAddress+j;
          foundaddressb[found].bit:=k;
          inc(found);
          if found=number then
          begin
            blockwrite(Addressfile,pointer(foundaddressB)^,found*(sizeof(Tbitaddress)),actualwrite);
            found:=0;
          end;
        end;

        inc(m);
        if m>7 then
        begin
          m:=0;
          inc(tempb);
        end;
      end;

    end;
    inc(bytep);
  end;


  result:=true;
end;

procedure setbit(bitnr: integer; var bt: dword;state:integer); overload;
{
 pre: bitnr=bit between 0 and 7
         bt=pointer to the byte
 post: bt has the bit set specified in state
 result: bt has a bit set or unset
}
begin
  if state=1 then
    bt:=bt or trunc(power(2,bitnr))  //set that bit to 1
  else
    bt:=bt and ($ffffffff xor trunc(power(2,bitnr))); //set the bit to 0
end;

procedure setbit(bitnr: integer; var bt: Byte;state:integer); overload;
{
 pre: bitnr=bit between 0 and 7
         bt=pointer to the byte
 post: bt has the bit set specified in state
 result: bt has a bit set or unset
}
var d: dword;
begin
  d:=bt;
  setbit(bitnr,d,state);
  bt:=d;
end;

function undolastscan(valtype: integer;hexadecimal:boolean): integer;
begin
  deletefile(CheatEngineDir+'Memory.tmp');
  deletefile(CheatEngineDir+'Addresses.tmp');

  renamefile(CheatEngineDir+'Memory.UNDO',CheatEngineDir+'Memory.tmp');
  renamefile(CheatEngineDir+'Addresses.UNDO',CheatEngineDir+'Addresses.tmp');

  assignfile(addressfile,CheatEngineDir+'Addresses.tmp');
  assignfile(memoryfile,CheatEngineDir+'Memory.tmp');
end;

procedure closefiles;
begin
  try closefile(addressfile); except end;
  try closefile(memoryfile); except end;
  try closefile(newAddressfile); except end;
  try closefile(newmemoryfile); except end;
end;

procedure Freememory;
var i: integer;
    fm: tfreememorythread;
begin
//  freeingmemory:=true;

  fm:=tfreememorythread.Create(true);
  fm.FreeOnTerminate:=true;

  fm.Bitscan:=pointer(bitscan);
  bitscan:=nil;

  fm.tempbits:=pointer(tempbits);
  tempbits:=nil;

  fm.FoundAddress:=pointer(foundaddress);
  foundaddress:=nil;
  foundaddressswitch:=nil;

  fm.FoundValue1:=pointer(foundvalue1);
  fm.FoundValue1switch:=pointer(foundvalue1switch);
  foundvalue1:=nil;
  foundvalue1switch:=nil;

  fm.FoundValue2:=pointer(foundvalue2);
  fm.FoundValue2switch:=pointer(foundvalue2switch);
  FoundValue2:=nil;
  FoundValue2switch:=nil;

  fm.FoundValue3:=pointer(foundvalue3);
  fm.foundvalue3switch:=pointer(foundvalue3switch);
  FoundValue3:=nil;
  foundvalue3switch:=nil;

  fm.FoundValue4:=pointer(foundvalue4);
  fm.foundvalue4switch:=pointer(foundvalue4switch);
  FoundValue4:=nil;
  foundvalue4switch:=nil;

  fm.FoundValue5:=pointer(foundvalue5);
  fm.foundvalue5switch:=pointer(foundvalue5switch);
  FoundValue5:=nil;
  FoundValue5switch:=nil;

  fm.foundValue6:=pointer(foundvalue6);
  fm.foundvalue6switch:=pointer(foundvalue6switch);
  foundValue6:=nil;
  foundvalue6switch:=nil;

  fm.FoundValue7:=pointer(foundvalue7);
  fm.foundvalue7switch:=pointer(foundvalue7switch);
  FoundValue7:=nil;
  foundvalue7switch:=nil;

  fm.FoundValue8:=pointer(foundvalue8);
  fm.foundvalue8switch:=pointer(foundvalue8switch);
  FoundValue8:=nil;
  foundvalue8switch:=nil;  

  fm.foundaddressB:=pointer(foundaddressb);
  foundaddressB:=nil;
  foundaddressbswitch:=nil;


  fm.previousmemory:=pointer(previousmemory);
  previousmemory:=nil;

  fm.SearchAddress:=pointer(searchaddress);
  SearchAddress:=nil;

  fm.SearchAddressB:=pointer(searchaddressb);
  SearchAddressB:=nil;

  fm.previousmemory1:=pointer(previousmemory1);
  fm.previousmemory1switch:=pointer(previousmemory1switch);
  previousmemory1:=nil;

  fm.previousmemory2:=pointer(previousmemory2);
  fm.previousmemory2switch:=pointer(previousmemory2switch);
  previousmemory2:=nil;

  fm.previousmemory3:=pointer(previousmemory3);
  fm.previousmemory3switch:=pointer(previousmemory3switch);
  previousmemory3:=nil;

  fm.previousmemory4:=pointer(previousmemory4);
  fm.previousmemory4switch:=pointer(previousmemory4switch);
  previousmemory4:=nil;

  fm.previousmemory5:=pointer(previousmemory5);
  fm.previousmemory5switch:=pointer(previousmemory5switch);
  previousmemory5:=nil;

  fm.previousmemory6:=pointer(previousmemory6);
  fm.previousmemory6switch:=pointer(previousmemory6switch);
  previousmemory6:=nil;

  fm.PreviousMemory7:=pointer(previousmemory7);
  fm.previousmemory7switch:=pointer(previousmemory7switch);
  PreviousMemory7:=nil;

  fm.PreviousMemory8:=pointer(previousmemory8);
  fm.previousmemory8switch:=pointer(previousmemory8switch);
  PreviousMemory8:=nil;

  fm.Memory:=pointer(memory);
  Memory:=nil;

  fm.memory2:=pointer(memory2);
  memory2:=nil;

  fm.bytes:=pointer(bytes);
  bytes:=nil;

  fm.bytearray:=pointer(bytearray);
  bytearray:=nil;

  fm.resume;
end;

function AvailMem:dword;
var x: _MEMORYSTATUS;
begin
  x.dwLength:=sizeof(x);
  GlobalMemoryStatus(x);

  if x.dwAvailVirtual>(x.dwAvailPhys+x.dwAvailPageFile) then
    result:=x.dwAvailPhys+x.dwAvailPageFile
  else
    result:=x.dwAvailVirtual;

end;

procedure RemoveAddress(address: Dword;bit: Byte; vartype: Integer);
type bitaddress = record
  address: dword;
  bit: dword;
end;

var

    Addresses: Array [1..number] of Dword;
    BAddress: Array [1..number] of BitAddress;
    Memory: Array [1..8*number] of Byte;
    i,j: Integer;

    str: pchar;

    found: boolean;
    check,check2: Integer;


begin
  assignfile(memoryfile,CheatEngineDir+'Memory.TMP');
  assignfile(addressfile,CheatEngineDir+'Addresses.TMP');
  reset(memoryfile,1);
  reset(addressfile,1);

  assignfile(newmemoryfile,CheatEngineDir+'Memory2.TMP');
  assignfile(newaddressfile,CheatEngineDir+'Address2.TMP');
  rewrite(newmemoryfile,1);
  rewrite(newaddressfile,1);

  blockread(addressfile,memory,7,check);
  blockwrite(newaddressfile,memory,7,check);

  found:=false;
  i:=0;

  if vartype=7 then  //text scan
  begin
    i:=filesize(memoryfile);

    getmem(str,i+1);
    blockread(memoryfile,pointer(str)^,i,check);
    str[i]:=chr(0);
    blockwrite(newmemoryfile,pointer(str)^,i,check);

    check:=4*number;
    while (check=4*number) do
    begin
      blockread(addressfile,addresses,4*number,check);
      i:=0;
      j:=0;
      while (i<check div 4) do
      begin
        inc(i);
        if addresses[i]<>address then //if it's not the selected address write it else dont write it.
          blockwrite(newaddressfile,addresses[i],4,check2);
      end;
    end;
  end
  else
  if vartype<>5 then
  begin
    check:=4*number;
    while ((not found) and (check=4*number)) do
    begin
      blockread(addressfile,addresses,4*number,check);
      i:=0;
      while (not found) and (i<(check div 4)) do
      begin
        inc(i);
        if addresses[i]=address then
        begin
          found:=true;
          break;
        end;
      end;

      if not found then
      begin
        blockwrite(newaddressfile,addresses,4*number,check2);
        case vartype of
          0:    begin //byte
                  blockread(memoryfile,memory,number,check2);
                  blockwrite(newmemoryfile,memory,check2,check2);
                end;

          1:    begin //word
                  blockread(memoryfile,memory,2*number,check2);
                  blockwrite(newmemoryfile,memory,check2,check2);
                end;

          2:    begin //dword
                  blockread(memoryfile,memory,4*number,check2);
                  blockwrite(newmemoryfile,memory,check2,check2);
                end;


          3:    begin //float
                  blockread(memoryfile,memory,4*number,check2);
                  blockwrite(newmemoryfile,memory,check2,check2);
                end;

          4:    begin //double
                  blockread(memoryfile,memory,8*number,check2);
                  blockwrite(newmemoryfile,memory,check2,check2);
                end;

          6:    begin //int64
                  blockread(memoryfile,memory,8*number,check2);
                  blockwrite(newmemoryfile,memory,check2,check2);
                end;


          //bit doesnt come here
        end;
      end;
    end;

    if found then
    begin
      for j:=i to number-1 do
        addresses[j]:=addresses[j+1];

      blockwrite(newaddressfile,addresses,check-4,check2);

      case vartype of
        0:    begin //byte
                blockread(memoryfile,memory,number,check2);
                for j:=i to number-1 do memory[j]:=memory[j+1];
                blockwrite(newmemoryfile,memory,check2-1,check2);
              end;

        1:    begin //word
                blockread(memoryfile,memory,2*number,check2);
                for j:=i to number-4 do
                begin
                  memory[j]:=memory[j+2];
                  memory[j+1]:=memory[j+3];
                end;
                blockwrite(newmemoryfile,memory,check2-2,check2);
              end;

        2:    begin //dword
                blockread(memoryfile,memory,4*number,check2);
                for j:=i to number-8 do
                begin
                  memory[j]:=memory[j+4];
                  memory[j+1]:=memory[j+5];
                  memory[j+2]:=memory[j+6];
                  memory[j+3]:=memory[j+7];
                end;

                blockwrite(newmemoryfile,memory,check2-4,check2);
              end;


        3:    begin //float
                blockread(memoryfile,memory,4*number,check2);
                for j:=i to number-8 do
                begin
                  memory[j]:=memory[j+4];
                  memory[j+1]:=memory[j+5];
                  memory[j+2]:=memory[j+6];
                  memory[j+3]:=memory[j+7];
                end;
                blockwrite(newmemoryfile,memory,check2-4,check2);
              end;

        4:    begin //double
                blockread(memoryfile,memory,8*number,check2);
                for j:=i to number-16 do
                begin
                  memory[j]:=memory[j+8];
                  memory[j+1]:=memory[j+9];
                  memory[j+2]:=memory[j+10];
                  memory[j+3]:=memory[j+11];
                  memory[j+4]:=memory[j+12];
                  memory[j+5]:=memory[j+13];
                  memory[j+6]:=memory[j+14];
                  memory[j+7]:=memory[j+15];
                end;
                blockwrite(newmemoryfile,memory,check2-8,check2);
              end;

        6:    begin //Int64
                blockread(memoryfile,memory,8*number,check2);
                for j:=i to number-16 do
                begin
                  memory[j]:=memory[j+8];
                  memory[j+1]:=memory[j+9];
                  memory[j+2]:=memory[j+10];
                  memory[j+3]:=memory[j+11];
                  memory[j+4]:=memory[j+12];
                  memory[j+5]:=memory[j+13];
                  memory[j+6]:=memory[j+14];
                  memory[j+7]:=memory[j+15];
               

⌨️ 快捷键说明

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