📄 cefuncproc.pas
字号:
i,j: integer;
records: integer;
bytes: dword;
nrofbytes: integer;
ident: string[7];
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');
reset(addressfile,1);
reset(memoryfile,1);
blockread(addressfile,ident,7,bytes);
if valtype=5 then
records:=(filesize(addressfile)-7) div 8
else
records:=(filesize(addressfile)-7) div 4;
if valtype=7 then
begin
getmem(x,filesize(memoryfile)+1);
blockread(memoryfile,pointer(x)^,filesize(memoryfile),bytes);
x[filesize(memoryfile)]:=#0;
value7:=x;
freemem(x);
end;
if valtype=8 then
begin
blockread(memoryfile,nrofbytes,4,bytes);
setlength(value8,nrofbytes);
end;
if records<=max then
begin
//now read the addresses list and the memory list
for i:=0 to records-1 do
begin
if valtype=0 then //byte
begin
blockread(addressfile,address,4,bytes);
blockread(memoryfile,value1,1,bytes);
if hexadecimal then results.Add(IntToHex(address,8)+'-'+IntTohex(value1,2))
else results.Add(IntToHex(address,8)+'-'+IntToStr(value1));
end;
if valtype=1 then //word
begin
blockread(addressfile,address,4,bytes);
blockread(memoryfile,value2,2,bytes);
if hexadecimal then results.Add(IntToHex(address,8)+'-'+IntTohex(value2,4))
else results.Add(IntToHex(address,8)+'-'+IntToStr(value2));
end;
if valtype=2 then //dword
begin
blockread(addressfile,address,4,bytes);
blockread(memoryfile,value3,4,bytes);
if hexadecimal then results.Add(IntToHex(address,8)+'-'+IntTohex(value3,8))
else results.Add(IntToHex(address,8)+'-'+IntToStr(value3));
end;
if valtype=3 then //float
begin
blockread(addressfile,address,4,bytes);
blockread(memoryfile,value4,4,bytes);
results.Add(IntToHex(address,8)+'-'+FloatToStr(value4));
end;
if valtype=4 then //double
begin
blockread(addressfile,address,4,bytes);
blockread(memoryfile,value5,8,bytes);
results.Add(IntToHex(address,8)+'-'+FloatToStr(value5));
end;
if valtype=5 then //bit
begin
blockread(addressfile,address2,8,bytes);
blockread(memoryfile,value1,1,bytes);
results.Add(IntToHex(address2.address,8)+'^'+IntToStr(address2.bit)+'-'+FloatToStr(value1));
end;
if valtype=6 then //Int64
begin
blockread(addressfile,address,4,bytes);
blockread(memoryfile,value6,8,bytes);
if hexadecimal then results.Add(IntToHex(address,8)+'-'+IntTohex(value6,16))
else results.Add(IntToHex(address,8)+'-'+IntToStr(value6));
end;
if valtype=7 then //string
begin
blockread(addressfile,address,4,bytes);
results.Add(IntToHex(address,8)+'-'+value7);
end;
if valtype=8 then //array of byte
begin
blockread(addressfile,address,4,bytes);
blockread(memoryfile,pointer(value8)^,nrofbytes,bytes);
value7:='';
for j:=0 to nrofbytes-1 do
value7:=value7+' '+Inttohex(value8[j],2);
results.Add(IntToHex(address,8)+'-'+FloatToStr(value5));
end;
end;
end;
closefile(addressfile);
closefile(memoryfile);
result:=records;
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];
end;
blockwrite(newmemoryfile,memory,check2-8,check2);
end;
end;
//an
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -