|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
movss Cheater Reputation: 0
Joined: 10 Feb 2018 Posts: 38
|
Posted: Mon Mar 05, 2018 6:02 am Post subject: can lua script call AA symbols? |
|
|
i write a dll file for getMainThreadFromName,
when i inject ,it works,i can see the correct value with AA script,
but when i call it with lua script,is doesn't work
print( readInteger(myaddr)),printing nothing,
where is wrong?
can lua script call "myaddr"?
Code: |
MainThreadFromName=[[
alloc(mem,1000)
alloc(name,10)
globalalloc(myaddr,4)
registersymbol(myaddr)
name:
db 'win.exe'
mem:
push name
call getMainThreadFromName
mov [addr],eax
ret
createthread(mem)
]]
if autoAssemble(MainThreadFromName) then
print("OK")
print( readInteger(myaddr))
else
print("NO")
end
|
_________________
A wild programmer |
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Mon Mar 05, 2018 12:42 pm Post subject: |
|
|
1. You have to pass it as a string which CE will interpret as a symbol and look up the address, or get the address with getAddress/getAddressSafe otherwise lua thinks you're referring to the lua variable "myaddr" not the AA symbol.
2. you have "mov [addr], eax" not myaddr so it's never being written to (the alloc would set it to 0 though).
3. globalalloc does registersymbol for you, that's essentially what makes it different from alloc, you'll actually get an error in this case using it "myaddr was supposed to be added to the symbollist, but it isn't declared"
4. I'm pretty sure it's possible that the asm code wouldn't run before the rest of the lua code does, it only waits for the auto assemble to finish, especially in the case of a hook which may only run when the player does something (eg. shoot) or a long calculation. So you may need a second address that's set to 1 when the asm code is done and a loop that runs until that's not 0, then you read the value you actually care about (though if you know the value won't be 0 you can combine those).
here's a slightly simplified example that worked for me Code: | MainThreadFromName=[[
alloc(mem,1000)
globalalloc(myaddr,4)
mem:
mov [myaddr], 1
add [myaddr], #99
ret
createthread(mem)
]]
if autoAssemble(MainThreadFromName) then
print("OK")
print(readInteger("myaddr"))
else
-- I think autoAssembleCheck was added in CE 6.7
-- but it prints the syntax message returned by
-- autoAssemble as it's second value if it fails
print("NO", autoAssembleCheck(MainThreadFromName))
end |
alternatively you could capture the result before the if statement Code: | local success, info = autoAssemble(MainThreadFromName)
if success then
print("OK, info can be used to run the disable section if one exists")
print(readInteger("myaddr"))
else
print("NO", info)
end |
edit: apparently having autoAssemble return the error (and the disable info, forgot about that) was only added in 6.7 as well, oh well lol. You'd just have to test it in a normal AA script with [enable] and an empty [disable] section.
_________________
|
|
Back to top |
|
|
movss Cheater Reputation: 0
Joined: 10 Feb 2018 Posts: 38
|
Posted: Tue Mar 06, 2018 4:16 am Post subject: |
|
|
thanks,,,,
i know now
_________________
A wild programmer |
|
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
|
|