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 


for Auto Assemble, can I use defined symbol in aobscan?

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

Joined: 23 Jan 2024
Posts: 4

PostPosted: Tue Jan 23, 2024 12:01 pm    Post subject: for Auto Assemble, can I use defined symbol in aobscan? Reply with quote

For example, if I wrote
Code:

define(addr,00007FFEA5D7BD10)
aobscanregion(SpecialGuestMustVisit,addr,addr+200,83 F8 FF)

then the compiler tells me "Failure determining what addr means"
I tried
Code:

define(addr,0x00007FFEA5D7BD10)

or
Code:

define(addr,'00007FFEA5D7BD10')

or
Code:

define(addr,00007FFEA5D7BD10)
registersymbol(addr)

They all failed
If I wrote
Code:

aobscanregion(SpecialGuestMustVisit,00007FFEA5D7BD10,00007FFEA5D7BD10+200,83 F8 FF)

It works perfectly.
I want to know if I can use such a defined symbol in the aobscan.
Currently, I'm using Cheat Engine 7.5
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4719

PostPosted: Tue Jan 23, 2024 2:02 pm    Post subject: Reply with quote

No. `aobscan*` calls get replaced with `define(name,address)`. `define` substitutions get parsed after aobscans.

Use {$lua} to return a formatted string:
Code:
[ENABLE]
{$lua}
if syntaxcheck then return 'aobscanregion(SpecialGuestMustVisit,0,0,83 F8 FF)' end

-- get region info here
local start = 0x7FFEA5D7BD10
local finish = start + 0x200

return ('aobscanregion(SpecialGuestMustVisit,%X,%X,83 F8 FF)'):format(start, finish)
{$asm}

Alternatively, the start / finish string arguments to `aobscanregion` get passed to the symbol handler, meaning you can use a registered symbol. (the symbol must be registered before executing the script)

_________________
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
geleisisisi
How do I cheat?
Reputation: 0

Joined: 23 Jan 2024
Posts: 4

PostPosted: Tue Jan 23, 2024 7:02 pm    Post subject: Reply with quote

Here is a weird situation:
I tried
Code:

{$lua}
function defineMethod(defineName,methodName,fieldTypeName)
   --addr = getMethodAddr(methodName,fieldTypeName)
   addr = 0x7FFE7A98BD10
   return string.format("\ndefine(%s,%016X)\n",defineName,addr)
end
function AOBScanRegion(symbolName,addrName,offset,aobStr)
   return string.format("\naobscanregion(%s,%s,%s+%x,%s)\n",symbolName,addrName,addrName,offset,aobStr)
end

if syntaxcheck then return "aobscanregion(SpecialGuestMustVisit,00007FFEA5D7BD10,00007FFEA5D7BD10+200,83 F8 FF)"end
local defineName = "addr"
local symbolName = "SpecialGuestMustVisit"
return defineMethod(defineName,"OnSpecialGuestInstantiate,MoveNext","")..AOBScanRegion(symbolName,defineName,0x200,"83 F8 FF")
{$asm}

It works.
Then, I change that global variable "addr" inside function defineMethod to local variable, like
Code:

function defineMethod(defineName,methodName,fieldTypeName)
   --addr = getMethodAddr(methodName,fieldTypeName)
   local addr = 0x7FFE7A98BD10
   return string.format("\ndefine(%s,%016X)\n",defineName,addr)
end

It also works.
However, if I save the CT file, close the Cheat Engine, then reopen it, the script with the "local addr = 0x7FFE7A98BD10" failed. With the global one -- "addr = 0x7FFE7A98BD10", it always works.
I am confused.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4719

PostPosted: Tue Jan 23, 2024 7:56 pm    Post subject: Reply with quote

I don't know what you're trying to do here... what was wrong with the code I posted? What modifications are you trying to make and why?

First of all, get rid of the functions. You're making this more complicated for no reason.

As for why local variables don't work but globals do: apparently CE will sometimes look for global Lua variables when searching for names of things.

You're making the exact same mistake as in your first post... this time in Lua. Why add `define(name, whatever)` in addition to `aobscanregion(...)`? The `define` does nothing.

_________________
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
geleisisisi
How do I cheat?
Reputation: 0

Joined: 23 Jan 2024
Posts: 4

PostPosted: Wed Jan 24, 2024 9:52 am    Post subject: Reply with quote

I like using functions because if I find something wrong with my code in latter time, it will be easier to change the codes in one function instead of several scripts
Why add define(name, whatever)?
I am looking for a method named "<OnSpecialGuestInstantiate>d__434.MoveNext". However, when the game updates, the method name may change, like "<OnSpecialGuestInstantiate>d__424.MoveNext".
I want to simply use ctrl + H to replace all the "<OnSpecialGuestInstantiate>d__434.MoveNext" with "addr" in my original script. Then use lua to find the method with the name contains "OnSpecialGuestInstantiate" and "MoveNext". Get that method address and add "define(addr, method adress)" at the beginning.
It would be easier than delete the original aobscan and add another "string.format("aobscan bla bla bla")"
That's why I want to know if I can use such a defined symbol in aobscan
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4719

PostPosted: Wed Jan 24, 2024 12:39 pm    Post subject: Reply with quote

Again, no, you can't use a `define` symbol in an aobscan.

I'm guessing the aobscan is searching for a pattern inside of the function "<OnSpecialGuestInstantiate>d__434.MoveNext". Do you really need to know where the function begins in the AA script? You should only need one or the other.
e.g. after the {$lua} block in the code in my first post gets executed, the AA script will look something like this:
Code:
[ENABLE]
aobscanregion(SpecialGuestMustVisit,7FFEA5D7BD10,7FFEA5D7BF10,83 F8 FF)
alloc(newmem,$1000,SpecialGuestMustVisit)

label(return)

newmem:
  // code here
  jmp return

SpecialGuestMustVisit:
  jmp newmem
  nop
return:
registersymbol(SpecialGuestMustVisit)

[DISABLE]
SpecialGuestMustVisit:
  db 83 F8 FF 01 02 03

unregistersymbol(SpecialGuestMustVisit)
dealloc(newmem)
You use the symbol defined by "aobscanregion". No need to know anything about mono symbols.
_________________
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
geleisisisi
How do I cheat?
Reputation: 0

Joined: 23 Jan 2024
Posts: 4

PostPosted: Thu Jan 25, 2024 12:36 pm    Post subject: Reply with quote

Thank you very much!
I will rewrite all my aobscan code.
That's a lot of work
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 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