|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
dankedgelord How do I cheat? Reputation: 0
Joined: 21 Mar 2017 Posts: 2
|
Posted: Sun Apr 09, 2017 9:55 am Post subject: New to lua, can I do XOR? |
|
|
Hi, is it possible to do something like this in cheat engine lua scripting?
1. Go to a specific address
2. XOR the first 4 bytes, and the next 4 bytes.
3. If it returns something like 8F000000 for example, I want to take the first byte 8F, convert it to decimal and add 1 to it and return this value as an integer.
Thanks in advance if you have an answer for this.
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Sun Apr 09, 2017 11:02 am Post subject: |
|
|
The main.lua (and wiki) shows that these exist in lua:
Code: | bOr(int1, int2) : Binary Or
bXor(int1, int2) : Binary Xor
bAnd(int1, int2) : Binary And
bShl(int, int2) : Binary shift left
bShr(int, int2) : Binary shift right
bNot(int) : Binary not |
So I think something like this should work:
Code: | addr = "address of information"
val = readInteger(addr)
val2 = readInteger(addr.."+4") -- assuming a string address
xored = bXor(val, val2)
if xored == 0x8F000000 then
return 0x90
--[[
8F+1, lua knows it's a number so unless it needs to be a string it doesn't matter
if you use decimal 144 or hexadecimal 0x90 notation to write it.
if you did need it as a string then tostring(0x90) is all you need
though since you know the value you can do it with just return "144"
for a hex string string.format("%#X", 0x9a) would work
note that I used 9a to demonstrate the formatting better
the # adds 0x to the string, and the case of the X determines
the case of the letters in the hex value (x = a, X = A)
--]]
end |
Though you can probably forgo the variables and use:
Code: | if bXor(readInteger("addr"), readInteger("addr+4")) == 0x8F000000 then
return 144
end |
If you don't know what the result will be and just want to return the result plus 1 then: Code: | return bShr(bXor(readInteger("addr"), readInteger("addr+4")),24)+1 | or Code: | return tostring(bShr(bXor(readInteger("addr"), readInteger("addr+4")),24)+1) | if you want/need it as a string
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4291
|
Posted: Sun Apr 09, 2017 11:05 am Post subject: |
|
|
Code: | function xor_cmp(address, value)
address = getAddress(address)
return readInteger(address) ~ readInteger(address+4) == value and (value >> 24) + 1 or nil
end
-- usage:
xor_cmp(0x038F192C, 0x8f000000) |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
dankedgelord How do I cheat? Reputation: 0
Joined: 21 Mar 2017 Posts: 2
|
Posted: Sun Apr 09, 2017 12:08 pm Post subject: |
|
|
Thank you for the replies
|
|
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
|
|