Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


how to set the value of multiple encrypted addresses?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 83

PostPosted: Sun Aug 28, 2022 10:22 pm    Post subject: how to set the value of multiple encrypted addresses? Reply with quote

A game is encrypted but can be decrypted with a custom value type,When need to change a lot of Continuous addresses,
adding them all to one table and set to custom value type. and use this.

Code:

local list = getAddressList()
 for n = 0, list.Count - 1 do
 local rec = list[n]
 cp = tonumber(rec.value)
 if  cp ~= nil
  then
 if cp > 0 then
 rec.value = 999
end
end
end


Is there any other way?
Back to top
View user's profile Send private message
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Sun Aug 28, 2022 11:12 pm    Post subject: Reply with quote

Build the custom type in lua and do it all from there?

https://wiki.cheatengine.org/index.php?title=Lua:registerCustomTypeLua
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4721

PostPosted: Sun Aug 28, 2022 11:28 pm    Post subject: Reply with quote

See the CustomType class in celua.txt. In particular, the global function `getCustomType` and the methods `byteTableToValue` and `valueToByteTable`. With that, you can get a byte table with `readBytes(address, true)` and run it through a custom type handler (and vise versa w/ `writeBytes`).

Note that the `valueToByteTable` function uses uninitialized memory for the output buffer, so a `ConvertBackRoutine` implementation that reads from the output buffer may produce unpredictable results. I don't know any easy way of solving this.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25837
Location: The netherlands

PostPosted: Sun Aug 28, 2022 11:31 pm    Post subject: Reply with quote

the addresslist is the easiest way,
but you could access custom types yourself and pass them bytearrays to get the converted value and then use writeBytes to write it

https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/bin/celua.txt#L3322

_________________
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
View user's profile Send private message MSN Messenger
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 83

PostPosted: Mon Aug 29, 2022 2:17 am    Post subject: Reply with quote

It looks more complicated than repeating the encryption

about Convert assembly instructions ' xor , rol ,ror , 'to lua


Is this correct?

xor = bXor

rol num n = num * 2^n ,Rotate left is equal to multiplying by 2 to the nth power ,

ror num n = num / 2^n

someone calculate rol a number in lua ,like rol eax 14 ,he use multiply 16384(2^14=16384).


Last edited by etioplmld on Mon Aug 29, 2022 6:43 am; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25837
Location: The netherlands

PostPosted: Mon Aug 29, 2022 3:54 am    Post subject: Reply with quote

xor is value ~ x

rol and ror are a bit more tricky, as lua only has shl (value << x) and shr(value >> x), and ror/rol are also more dependand on bitsize of the value operated on

_________________
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
View user's profile Send private message MSN Messenger
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 83

PostPosted: Wed Aug 31, 2022 8:02 am    Post subject: Reply with quote

a related script found on other sites
Code:

function bRot32(i, n)
n = n & 31
return i >> n | i << (32 - n) & 0xFFFFFFFF
end

AGEbitFields3 = registerCustomTypeLua('AGEbitFields3', 4, function(...)
local v = byteTableToDword({...})
return bRot32(v ~ readInteger("AUX"), 0x0E) >> 3 & 1
end, function(b, a)
local c = bRot32(readInteger(a) ~ readInteger("AUX"), 0x0E) & ~(1 << 3) | (b & 1) << 3
return unpack(dwordToByteTable(bRot32(c, -0x0E) ~ readInteger("AUX")))
end, false)

it's difficult to understand

Is the function bRot32 equal to rol ?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites