|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Damöb How do I cheat? Reputation: 0
Joined: 31 Oct 2018 Posts: 3
|
Posted: Wed Oct 31, 2018 3:48 pm Post subject: How to make a custom Type for integer between known values? |
|
|
Excuse the title, didn't know how to phrase it best.
I can't seem to wrap my head around how to make a custom type so I'm just going to ask how to do this.
Searching for x, the value stored will be somewhere between x*1000 and (x+1)*1000. I can easily search for it with 4 bytes value between, but I'd like to have a custom type that skips having to input two values. i.e a value of 120 is stored as an integer between 120000 and 121000
How would that work as a custom type in lua?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Wed Oct 31, 2018 4:51 pm Post subject: |
|
|
Interpret the 4 bytes as an integer, divide that integer by 1000 and truncate the result (cut of the part behind the decimal)
then return that integer as result
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Damöb How do I cheat? Reputation: 0
Joined: 31 Oct 2018 Posts: 3
|
Posted: Wed Oct 31, 2018 5:29 pm Post subject: |
|
|
Ok, i'm probably doing something wrong since it's really slow to scan. Or is it slow because I'm using lua?
Code: | --Note: keep the function base name unique.
typename="Custom 3" --shown as the typename in ce
bytecount=4 --number of bytes of this type
functionbasename="customvaluetype3"
function customvaluetype3_bytestovalue(b1,b2,b3,b4,address)
--Add extra byte parameters as required
local val = math.floor(byteTableToDword({b1,b2,b3,b4})/1000)
return val
end
function customvaluetype3_valuetobytes(i,address)
--return the bytes to write (usually only used when you change the value)
local bt = dwordToByteTable(i)
return bt
end
return typename,bytecount,functionbasename |
Am I doing it right?
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4289
|
Posted: Wed Oct 31, 2018 5:57 pm Post subject: |
|
|
Most scans are done using multiple threads, but Lua isn't inherently thread safe.
Try AA instead:
Code: | alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(UsesFloat,1)
alloc(CallMethod,1)
TypeName:
db '4 Byte * 1000',0
ByteSize:
dd 4
UsesFloat:
db 0
CallMethod:
db 1
// cdecl int ConvertRoutine(unsigned char *input, PTR_UINT address);
ConvertRoutine:
[64-bit]
mov eax,10624dd3
mul dword ptr[rcx]
[/64-bit]
[32-bit]
mov ecx,[esp+4]
mov eax,10624dd3
mul dword ptr[ecx]
[/32-bit]
shr edx,6
mov eax,edx
ret
// cdecl void ConvertBackRoutine(int i, PTR_UINT address, unsigned char *output);
ConvertBackRoutine:
[64-bit]
imul eax,ecx,3e8
mov dword ptr[r8],eax
[/64-bit]
[32-bit]
imul ecx,[esp+4],3e8
mov eax,[esp+c]
mov [eax],ecx
[/32-bit]
ret |
This should be as fast as you can reasonably get.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Damöb How do I cheat? Reputation: 0
Joined: 31 Oct 2018 Posts: 3
|
Posted: Wed Oct 31, 2018 6:20 pm Post subject: |
|
|
ParkourPenguin wrote: | Most scans are done using multiple threads, but Lua isn't inherently thread safe.
Try AA instead:
Code: | alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(UsesFloat,1)
alloc(CallMethod,1)
TypeName:
db '4 Byte * 1000',0
ByteSize:
dd 4
UsesFloat:
db 0
CallMethod:
db 1
// cdecl int ConvertRoutine(unsigned char *input, PTR_UINT address);
ConvertRoutine:
[64-bit]
mov eax,10624dd3
mul dword ptr[rcx]
[/64-bit]
[32-bit]
mov ecx,[esp+4]
mov eax,10624dd3
mul dword ptr[ecx]
[/32-bit]
shr edx,6
mov eax,edx
ret
// cdecl void ConvertBackRoutine(int i, PTR_UINT address, unsigned char *output);
ConvertBackRoutine:
[64-bit]
imul eax,ecx,3e8
mov dword ptr[r8],eax
[/64-bit]
[32-bit]
imul ecx,[esp+4],3e8
mov eax,[esp+c]
mov [eax],ecx
[/32-bit]
ret |
This should be as fast as you can reasonably get. |
Yeah that worked, I guess I better sit down and try to figure out AA. Thanks!
|
|
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
|
|