 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
yakov1 How do I cheat?
Reputation: 0
Joined: 09 Dec 2019 Posts: 4
|
Posted: Fri Dec 20, 2019 2:59 am Post subject: How to define a new scan type |
|
|
Data of some games made by RPG Maker are often encrypted by formula 2x + 1, so I want to define a new custom type (LUA). I found a sample and changed it to my own. The code is as the following:
| Code: | typename = "Multiply 2 Plus 1"
bytecount = 4 --number of bytes of this type
functionbasename = "M2Plus1"
function M2Plus1_bytestovalue(b1, b2, b3, b4, address)
local value = (b1 + b2 << 8 + b3 << 16 + b4 << 24) * 2 + 1;
return readInteger(value)
--or: return value
end
function M2Plus1_valuetobytes(i, address)
local OriginalValue = readInteger(address)
local ReturnValue = dwordToByteTable(OriginalValue)
writeInteger(OriginalValue * 2 + 1, i)
return ReturnValue[1], ReturnValue[2], ReturnValue[3], ReturnValue[4]
end
return typename, bytecount, functionbasename |
But it doesn' work. And also, if use "readInteger(value)", the scan speed is very slow.
Anyone who could help will be highly appreciated![/code]
|
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Dec 20, 2019 10:25 am Post subject: |
|
|
This 2x+1 means you see a value 4 in game and 9 in process memory. If yes, you can use this Custom Type (autoassemble custom type).
Inside ConvertRoutine you see "dec eax" and "shr eax,1". It means decrement by one, divide by 2.
Inside ConvertBackRoutine you will see "shl ecx,1" and "inc ecx". It means multiply by 2, increment by one.
| Code: | alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(CallMethod,1)
TypeName:
db '2xplus1',0
ByteSize:
dd 4
CallMethod:
db 1
ConvertRoutine:
[64-bit]
mov eax,[rcx]
[/64-bit]
[32-bit]
push ebp
mov ebp,esp
mov eax,[ebp+8]
mov eax,[eax]
[/32-bit]
dec eax
shr eax,1
[64-bit]
ret
[/64-bit]
[32-bit]
pop ebp
ret
[/32-bit]
ConvertBackRoutine:
[32-bit]
push ebp
mov ebp,esp
push ecx
push ebx
mov ecx,[ebp+8]
mov ebx,[ebp+10]
[/32-bit]
shl ecx,1
inc ecx
[64-bit]
mov [r8],ecx
ret
[/64-bit]
[32-bit]
mov [ebx],ecx
pop ebx
pop ecx
pop ebp
ret
[/32-bit]
|
Edit:
a proper custom type Lua would be this:
| Code: | typename="2xplus1 (Lua)"
bytecount=4
functionbasename="the2xplus1"
function the2xplus1_bytestovalue(b1,b2,b3,b4,address)
local value = byteTableToDword({b1,b2,b3,b4})
return (value - 1) / 2
end
function the2xplus1_valuetobytes(i,address)
local bytes = dwordToByteTable( i * 2 + 1)
return bytes[1],bytes[2],bytes[3],bytes[4]
end
return typename,bytecount,functionbasename |
As you can see, you do not need the address parameter or read functions (e.g. readInteger)
Address parameter is useful for other cases, like simple encrypting (e.g. value is xor'ed with an address, where it is stored)
_________________
|
|
| Back to top |
|
 |
yakov1 How do I cheat?
Reputation: 0
Joined: 09 Dec 2019 Posts: 4
|
Posted: Fri Dec 20, 2019 6:40 pm Post subject: |
|
|
I tried both codes and they worked well. Especially autoassemble one runs very fast. And I have understood why few people choose Lua custom type.
Thank you very much for great codes!
|
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Dec 21, 2019 2:16 pm Post subject: |
|
|
customTypeAA - more difficult to implement, you have to consider which cpu architecture people will use (32,64bit or both)
customTypeLua - two functions which already will work on both architectures.
CustomTypeAA and customTypeLua, both have pros and cons. For memory scanning, CustomTypeAA is always a better choice.
For other things, e.g. cheat tables with character stats, inventory, ... you can use customTypeLua.
_________________
|
|
| Back to top |
|
 |
yakov1 How do I cheat?
Reputation: 0
Joined: 09 Dec 2019 Posts: 4
|
Posted: Sat Dec 21, 2019 10:59 pm Post subject: |
|
|
| Thank you very much for explanation!
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|