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 


lua script fetch address only once

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Fri Feb 08, 2019 7:12 am    Post subject: lua script fetch address only once Reply with quote

Hi friends i have made a lua script to fetch EAX register value from selected address in a unity game named shuyan saga. My problem is that when i enable script then it hangs the game for 1-2 second for fetching eax register value to a variable. Second and main problem that it fetch eax only when i activate the script not after that. So in every fight unity players address is changing and so after one fight i have to disable and re enable this script to update the new address. can anybody help me to solve this problem. I'm learning lua so i have not very good knowledge of it. Here is the script i'm using.

Code:
LaunchMonoDataCollector()
debugProcess()
local methadd = getAddress('EnemyBase:IsAttackTargetShuyan+2b')
debug_setBreakpoint(methadd); -- Address where to set breakpoint
function debugger_onBreakpoint()
_pbase = EAX
registerSymbol("_pbase")
debug_continueFromBreakpoint(co_run)
debug_removeBreakpoint(methadd)
return 1
end
Back to top
View user's profile Send private message
salumor
Advanced Cheater
Reputation: 0

Joined: 14 Jan 2019
Posts: 87

PostPosted: Mon Feb 11, 2019 2:57 pm    Post subject: Reply with quote

I am new too so just some ideas popping up reading that

- debugProcess before getting the address? Attaching it the first time usually breaks mono features. So would it even work on first activation?
- On activation: for first time attaching mono does take 1-2 secs, nothing to do about. On those debug functions - have you tried it manually - how many steps to continue point?
- On the main problem, you prob. need to add a timer to act. the value: https://wiki.cheatengine.org/index.php?title=Lua:Class:Timer
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 51

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Mon Feb 11, 2019 4:35 pm    Post subject: Re: lua script fetch address only once Reply with quote

dharmang1910 wrote:
Hi friends i have made a lua script to fetch EAX register value from selected address in a unity game named shuyan saga. My problem is that when i enable script then it hangs the game for 1-2 second for fetching eax register value to a variable. Second and main problem that it fetch eax only when i activate the script not after that. So in every fight unity players address is changing and so after one fight i have to disable and re enable this script to update the new address. can anybody help me to solve this problem. I'm learning lua so i have not very good knowledge of it. Here is the script i'm using.

Code:
LaunchMonoDataCollector()
debugProcess()
local methadd = getAddress('EnemyBase:IsAttackTargetShuyan+2b')
debug_setBreakpoint(methadd); -- Address where to set breakpoint
function debugger_onBreakpoint()
_pbase = EAX
registerSymbol("_pbase")
debug_continueFromBreakpoint(co_run)
debug_removeBreakpoint(methadd)
return 1
end


As salumor said it be coming slow is mostly the mono data collector. And you remove the breakpoint so that's why it only works once, I would actually suggest using ASM and code injection.

And I think you misspelled "method", unless this code adds meth to the player or something.

_________________
Back to top
View user's profile Send private message Visit poster's website
salumor
Advanced Cheater
Reputation: 0

Joined: 14 Jan 2019
Posts: 87

PostPosted: Tue Feb 12, 2019 5:53 pm    Post subject: Re: lua script fetch address only once Reply with quote

TheyCallMeTim13 wrote:
As salumor said it be coming slow is mostly the mono data collector. And you remove the breakpoint so that's why it only works once, I would actually suggest using ASM and code injection.

And I think you misspelled "method", unless this code adds meth to the player or something.


If the above code would be all, it prob. would be enough to do in AA (Auto Assemble). But it's clear there is more to it, there are also legit reasons to use a breakpoint. So why do you suggest that before asking on any details?

Is the misspelling a joke? I don't get. I mean you wouldn't force naming conventions on others, but it's not funny either, so ...?
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 51

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Tue Feb 12, 2019 10:13 pm    Post subject: Re: lua script fetch address only once Reply with quote

salumor wrote:
TheyCallMeTim13 wrote:
As salumor said it be coming slow is mostly the mono data collector. And you remove the breakpoint so that's why it only works once, I would actually suggest using ASM and code injection.

And I think you misspelled "method", unless this code adds meth to the player or something.


If the above code would be all, it prob. would be enough to do in AA (Auto Assemble). But it's clear there is more to it, there are also legit reasons to use a breakpoint. So why do you suggest that before asking on any details?

Is the misspelling a joke? I don't get. I mean you wouldn't force naming conventions on others, but it's not funny either, so ...?


Just cause AA will tend to run better/faster than a Lua interpreter and breakpoints. As far as "using" a breakpoint, I was more telling you that removing the breakpoint is why it's only hit once.

And as far as the misspelling, "/meTHəd/" (method) vs "/meTH/" "/ad/" (methadd), I take it you've not heard of r/BoneAppleTea.

_________________
Back to top
View user's profile Send private message Visit poster's website
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Sun Feb 17, 2019 12:47 am    Post subject: Reply with quote

Code:
{$lua}
LaunchMonoDataCollector()
local methadd = getAddress('EnemyBase:IsAttackTargetShuyan+2b')
debug_removeBreakpoint(methadd)

function debugger_onBreakpoint()
EIP = methadd
_pbase = EAX
registerSymbol("_pbase")
debug_continueFromBreakpoint(co_run)
debugProcess(2)

return 1
end
debug_setBreakpoint(methadd)


above code is working perfectly. Actually using AA script is very easy and my first line of choice but in aa script game getting crash anytime during fight so i have tried the lua. In above script, game crashes only when fight is over. I have analyze but found that in every fight address of player get chaged, may be because of "jit"(unity game). Now i can not figure out how can i solve this problem. I have tried code to remove breakpoint when health become zero(because when end the fight player address become zero and so health become zero), but still crashing. Can anyone give some suggestion for that.

TheyCallMeTim13 wrote:
dharmang1910 wrote:
Hi friends i have made a lua script to fetch EAX register value from selected address in a unity game named shuyan saga. My problem is that when i enable script then it hangs the game for 1-2 second for fetching eax register value to a variable. Second and main problem that it fetch eax only when i activate the script not after that. So in every fight unity players address is changing and so after one fight i have to disable and re enable this script to update the new address. can anybody help me to solve this problem. I'm learning lua so i have not very good knowledge of it. Here is the script i'm using.

Code:
LaunchMonoDataCollector()
debugProcess()
local methadd = getAddress('EnemyBase:IsAttackTargetShuyan+2b')
debug_setBreakpoint(methadd); -- Address where to set breakpoint
function debugger_onBreakpoint()
_pbase = EAX
registerSymbol("_pbase")
debug_continueFromBreakpoint(co_run)
debug_removeBreakpoint(methadd)
return 1
end


As salumor said it be coming slow is mostly the mono data collector. And you remove the breakpoint so that's why it only works once, I would actually suggest using ASM and code injection.

And I think you misspelled "method", unless this code adds meth to the player or something.


In asm this game crashes anytime so i am not using it now. "methadd" is variable i have assigned as a short form of "method address" for the "IsAttackTargetShuyan" method of class "EnemyBase" so i am sure it is not misspelled but can you please help me in above new code.??!!!
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 51

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Sun Feb 17, 2019 2:03 am    Post subject: Reply with quote

dharmang1910 wrote:
Code:
{$lua}
LaunchMonoDataCollector()
local methadd = getAddress('EnemyBase:IsAttackTargetShuyan+2b')
debug_removeBreakpoint(methadd)

function debugger_onBreakpoint()
EIP = methadd
_pbase = EAX
registerSymbol("_pbase")
debug_continueFromBreakpoint(co_run)
debugProcess(2)

return 1
end
debug_setBreakpoint(methadd)


above code is working perfectly. Actually using AA script is very easy and my first line of choice but in aa script game getting crash anytime during fight so i have tried the lua. In above script, game crashes only when fight is over. I have analyze but found that in every fight address of player get chaged, may be because of "jit"(unity game). Now i can not figure out how can i solve this problem. I have tried code to remove breakpoint when health become zero(because when end the fight player address become zero and so health become zero), but still crashing. Can anyone give some suggestion for that.

TheyCallMeTim13 wrote:
dharmang1910 wrote:
Hi friends i have made a lua script to fetch EAX register value from selected address in a unity game named shuyan saga. My problem is that when i enable script then it hangs the game for 1-2 second for fetching eax register value to a variable. Second and main problem that it fetch eax only when i activate the script not after that. So in every fight unity players address is changing and so after one fight i have to disable and re enable this script to update the new address. can anybody help me to solve this problem. I'm learning lua so i have not very good knowledge of it. Here is the script i'm using.

Code:
LaunchMonoDataCollector()
debugProcess()
local methadd = getAddress('EnemyBase:IsAttackTargetShuyan+2b')
debug_setBreakpoint(methadd); -- Address where to set breakpoint
function debugger_onBreakpoint()
_pbase = EAX
registerSymbol("_pbase")
debug_continueFromBreakpoint(co_run)
debug_removeBreakpoint(methadd)
return 1
end


As salumor said it be coming slow is mostly the mono data collector. And you remove the breakpoint so that's why it only works once, I would actually suggest using ASM and code injection.

And I think you misspelled "method", unless this code adds meth to the player or something.


In asm this game crashes anytime so i am not using it now. "methadd" is variable i have assigned as a short form of "method address" for the "IsAttackTargetShuyan" method of class "EnemyBase" so i am sure it is not misspelled but can you please help me in above new code.??!!!


Ha, method address; didn't think of that.
As for the code, I'd try and see what happens to the games code at the end of the fight; seems like there might be more going through that code.

_________________
Back to top
View user's profile Send private message Visit poster's website
salumor
Advanced Cheater
Reputation: 0

Joined: 14 Jan 2019
Posts: 87

PostPosted: Sun Feb 17, 2019 2:54 pm    Post subject: Reply with quote

- First i'd check debugging options. Which debugger are you using? VEH is act. recommended - many games crash with windows debugger.
- Second if you do not know (if, let us know), try to simply attach mono without activating the script at all. (In CE menu or a simple script). Some games do crash when mono is attached.
- If it's not the debugger or mono features I'd actually do a conditional "break and trace" (you can use it also on registers like eax==0) to when your health is zero and try to find out at which point it breaks/what's different.
-- Or you could also go and debug why it's crashing with an AA script.

There are quite some tutorials out there on debugging / break & trace / conditional break with CE. There will be also many times you will have to make use of it, so if you aren't used to it by now it might be time to dig in.
Back to top
View user's profile Send private message
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Mon Feb 18, 2019 10:00 pm    Post subject: Reply with quote

yesterday i have played game to check where is my crashing but my game was not crashed even i have completed tournament. There is no change in my new code , the only change is done that i have updated cheat engine to latest version from previous version 6.8.2. Thanks salumor and TheyCallMeTim13 for your suggestions.
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