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 


Scan results XOR with LUA

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
god-velocity
How do I cheat?
Reputation: 0

Joined: 18 May 2017
Posts: 1

PostPosted: Fri May 19, 2017 3:48 am    Post subject: Scan results XOR with LUA Reply with quote

Hallo, I am new to LUA and scripting in Cheat Engine.
After doing an "unknown initial value" 4Byte scan and doing a next scan with "changed value" I found around 4000 addresses from my scan results. After this I am looking for 2 addresses with a XOR value of, let's say 3. The offset of the 2 addreses should only be a multiple of 0x10 (eg. 0x10,0x20,0x30 etc.).

I managed to find the addresses manually and wanted to write a script to make the process easier, but Cheat Engine went totally unresponsive (not responding) when I execute my script. Below is my script:

getCurrentMemscan()
b=0xba01a400
for a=0xba0173d0,b,16 do
for c=a,b,16 do
val1 = readInteger(a)
val2 = readInteger(c)
e = bXor(val1,val2)
if e==3 then print(a,c) end
end
end


0xBA0173D0 is the beginning and 0xBA01A400 is the end of my found address.
Can someone give me a clue as to why the script went unresponsive or any idea to make the script better?

Thanks in advance.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri May 19, 2017 6:41 am    Post subject: Reply with quote

Right-click on the Value Type dropdown and define a new custom type.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Fri May 19, 2017 7:32 am    Post subject: Reply with quote

While lua is easier to write/understand it is also going to be slower than an assembly script (not sure of any way to get the currentScan in typical asm but you could use a custom type like Zanzer mentioned and each value would be passed to your script as it scans)...

However it looks like you're trying to xor every value with every value that comes after it, if you have 4000 values then the first gets tested with 3999 values, the second with 3998 https://www.mathsisfun.com/numbers/sigma-calculator.html says that'd be about 7998000 checks in total.... you can't narrow it down any? Even in asm that's going to take awhile.... If you really need to do that then at least read val1 (a) only 1 time (in the first loop) since it (in theory) shouldn't be changing while being tested against every other value...

As for "the offset of the 2 addreses should only be a multiple of 0x10" you can do that simply by setting the alignment to "10" when scanning, and the range of 0xba0173d0 - 0xba01a400 can be done by setting the start and stop values when scanning. No need to implement that logic in your script.
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