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 


Aobscan and writeBytes

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

Joined: 09 Jun 2015
Posts: 77

PostPosted: Fri Aug 02, 2019 9:48 pm    Post subject: Aobscan and writeBytes Reply with quote

So, I wanted to create a script that writes to addresses near an AOBScan signature. Here's my AOBScan Code:

Code:

[ENABLE]
aobscan(EnemyData, 80 00 03 40 00 00 00 01 80 4A BD DC 80 83 36 08 80 4A 86 98 00 00 00 01 80 4A BD DC 80 83 36 18 80 00 C6 28 00 00 00 00 00 00 00 02 80 83 36 38 80 1F C5 4C 00 00 00 00 00 00 00 00 00 00 00 00 80 4A 86 CC)
label(_EnemyData)
registersymbol(_EnemyData)

EnemyData:
_EnemyData:

[DISABLE]
unregistersymbol(_EnemyData)


Let's say I want to write the address that is 0x6C bytes away from this signature. How would I go about doing that? I tried through all of these ways, but they don't work for me:
Code:

writeBytes(_EnemyData+6C,01,01)
writeBytes("_EnemyData+6C",01,01)
writeBytes(EnemyData+6C,01,01)
writeBytes("EnemyData+6C",01,01)


The EnemyData address would need to be stored as a global variable, as this will be subsequently accessed by several different functions.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sat Aug 03, 2019 7:54 am    Post subject: Reply with quote

writeBytes("_EnemyData+6C",01,01)

should work, assuming that the script as actually been activated to add _EnemyData to the symbol table, and you wanted to write two 1 bytes (note that lua sees numbers as decimal unless you use 0x but for 1-9 it's the same anyway).

There's really no need for the extra label btw, you can directly register the one aobscan creates eg.
Code:
[ENABLE]
aobscan(_EnemyData, 80 00 03 40 00 00 00 01 80 4A BD DC 80 83 36 08 80 4A 86 98 00 00 00 01 80 4A BD DC 80 83 36 18 80 00 C6 28 00 00 00 00 00 00 00 02 80 83 36 38 80 1F C5 4C 00 00 00 00 00 00 00 00 00 00 00 00 80 4A 86 CC)

[DISABLE]
unregistersymbol(_EnemyData)

just to test the lua code you could do something like this
Code:

-- fake the AA script registering the symbol
unregisterSymbol('_EnemyData') -- can't register when already registered
registerSymbol('_EnemyData', 0x400000) -- whatever the real address is for testing

-- test whatever with the symbol registered
local address = getAddress('_EnemyData+6C')
return ('%X'):format(address) -- just printing the address in hex
Then you know if it's the lua code or the AA code.
_________________
https://github.com/FreeER/ has a few CE related repos
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