View previous topic :: View next topic |
Author |
Message |
zezikaaikwe How do I cheat? Reputation: 0
Joined: 31 Mar 2012 Posts: 4
|
Posted: Sat Mar 31, 2012 11:15 pm Post subject: How do I call/hook(?) a lua script inside AA? |
|
|
Trying to run a Lua script every time a certain address changes its value.
Is there an easy way to do this? I don't want to run a silly timer that just loops every 15ms. The Lua code I currently have is:
Code: |
local userDesktop = os.getenv("USERPROFILE") .. "\\Desktop";
local logfile = userDesktop .. "\\tmpout.txt"
local gameline = readString("0018CB60", 4000)
f = io.open(logfile,"a+")
f:write(gameline.."\n")
f:close()
|
Which reads the value at 0018CB60 and outputs it into a text file. That works nicely when I execute it via lua engine, but I want it to instantly execute the moment that value changes. I've found the assembly code for the moment it's written to, but I can't figure out how to say "hey, before you update this address, run this Lua script real quick."
Do I have to compile lua down to assembly and just inject that? Is there some way I can use the api hook to run that code?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sun Apr 01, 2012 5:22 am Post subject: |
|
|
You're close, you do this by using the debugger and breakpoints instead of a real hook (if you need a real hook, you'll have to do asm and do api calls like CreateFile, WriteFile, etc...)
Check out http://forum.cheatengine.org/viewtopic.php?t=530032
but instead of pmAddress=getAddress("PeekMessageA"); you'd do pmAddress=getAddress("addressthatwritestotheaddress");
(Although I recommend setting the breakpoint to the location after the full string has been updated, and not when it just starts. Try finding the exit of the function and hook there)
and in the debugger_onBreakpoint function you can write that log function you wrote above.
Tip: Try keeping a "PreviousText" line and compare if it's changed or not before writing. Might save some diskspace
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
zezikaaikwe How do I cheat? Reputation: 0
Joined: 31 Mar 2012 Posts: 4
|
Posted: Sun Apr 01, 2012 12:13 pm Post subject: |
|
|
Hmm...okay, thanks for that. Here's what I've got now - the problem is, when I "Execute script", it logs one message to the file upon update, but then stops logging from then on. I disabled the removeBreakpoint, so I'm not entirely sure why. When I "return 1", does the breakpoint automatically get removed?
Code: |
pmAddress=getAddress("00460013"); --addy that writes to 0018CB60
function debugger_onBreakpoint()
--if (EIP == pmAddress) then --not sure if I need this...
if (gameline ~= readString("0018CB60", 4000)) then --checking against prior value?
local userDesktop = os.getenv("USERPROFILE") .. "\\Desktop"
local logfile = userDesktop .. "\\tmpout.txt"
local gameline = readString("0018CB60", 4000)
f = io.open(logfile,"a+")
f:write(gameline.."\n")
f:close()
end
--debug_removeBreakpoint(pmAddress);
return 1
else
return 0
end
end
debug_setBreakpoint("00460013");
|
Also, ponies.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sun Apr 01, 2012 12:22 pm Post subject: |
|
|
The breakpoint doesn't get automatically removed so that's fine, the problem here is something else.
First, remove the "local" in front of gameline, else the if in front won't know what gameline is (it thinks it's nil )
But the main issue is that I'm not sure why that code even works
the "else return 0 end" makes no sense here
Run the code using the lua engine window you can get to from memoryview window, not the luatable
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
zezikaaikwe How do I cheat? Reputation: 0
Joined: 31 Mar 2012 Posts: 4
|
Posted: Sun Apr 01, 2012 12:51 pm Post subject: |
|
|
That's probably because I'm retarded and uncommented it when i pasted it here. Sorry
Also, I was being silly because I wasn't getting the correct address as you advised - I was grabbing from somewhere in the middle where the string hadn't been finalized. Moving it down the chain a bit is working perfectly.
The final code:
Code: | pmAddress=getAddress("00460062");
logfile = os.getenv("USERPROFILE") .. "\\Desktop" .. "\\tmpout.txt"
function debugger_onBreakpoint()
if (gameline ~= readString("0018CB60", 4000)) then
gameline = readString("0018CB60", 4000)
f = io.open(logfile,"a+")
f:write(gameline.."\n")
f:close()
end
return 1
end
debug_setBreakpoint(pmAddress); |
Pretty awesome. Thanks for taking your time to help me. Have a beer, on me.
(I will probably have more questions in the future though you're creating a monster)
|
|
Back to top |
|
|
|