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 


Using Mono structures in aa scripts

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials
View previous topic :: View next topic  
Author Message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Tue Aug 19, 2014 6:55 am    Post subject: Using Mono structures in aa scripts Reply with quote

Sometimes when a game gets patches, the offsets of structure elements change as well

One way to make this easier for you is using the monoAA_GETMONOSTRUCT() function to build an auto assembler struct
(you could use aa command GETMONOSTRUCT as well, but that'll show an annoying popup due to a (de)bug in ce 6.4)

Code:

{$lua}
return monoAA_GETMONOSTRUCT("PlayerClass", syntaxcheck)
{$asm}

...
mov [registerwithobject+PlayerClass.Health],#100
...


_________________
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


Last edited by Dark Byte on Thu Sep 14, 2017 3:02 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Hatschi
Master Cheater
Reputation: 2

Joined: 28 Jan 2010
Posts: 327

PostPosted: Wed Aug 27, 2014 2:16 pm    Post subject: Reply with quote

Hm it says "..\autorun\monoscript.lua:360: attempt to index global 'monopipe' (a nil value)"

Do I have to dissect mono first or so to use that command?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Wed Aug 27, 2014 3:11 pm    Post subject: Reply with quote

ah yes, the mono data collector needs to be injected in the target and activated in ce.

Easiest way is just call LaunchMonoDataCollector()

you can call it as often as you like, so
Code:

{$lua}
LaunchMonoDataCollector()
return monoAA_GETMONOSTRUCT("PlayerClass", syntaxcheck)
{$asm}
...

should work too

_________________
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
View user's profile Send private message MSN Messenger
Belnick
Expert Cheater
Reputation: 0

Joined: 02 Feb 2012
Posts: 100

PostPosted: Thu Feb 04, 2016 7:22 pm    Post subject: Reply with quote

Dark Byte wrote:
ah yes, the mono data collector needs to be injected in the target and activated in ce.

Easiest way is just call LaunchMonoDataCollector()

you can call it as often as you like, so
Code:

{$lua}
LaunchMonoDataCollector()
return monoAA_GETMONOSTRUCT("PlayerClass", syntaxcheck)
{$asm}
...

should work too


what do i open to paste that line into ?
Back to top
View user's profile Send private message
h3x1c
Master Cheater
Reputation: 17

Joined: 27 Apr 2013
Posts: 306

PostPosted: Wed Jul 27, 2016 2:23 pm    Post subject: Reply with quote

Quick question: Is there a way to close, or "uninject", the Mono Data Collector via the [DISABLE] section of a script? I'm running into sub-scripts in a group still being able to be enabled/disabled even after the group header is disabled since the Mono Data Collector is still running.

I can just set children to hide when not enabled as a visual way to make sure the header is always enabled/disabled, but just wondering about the aforementioned. Thanks! Very Happy

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

Joined: 20 Nov 2013
Posts: 69
Location: bachLai

PostPosted: Thu Sep 14, 2017 2:43 am    Post subject: Re: Using Mono structures in aa scripts Reply with quote

Dark Byte wrote:
Code:

{$lua}
return monoAA_GETMONOSTRUCT("PlayerClass", syntaxcheck)
{$asm}

...
mov [PlayerClass.Health],#100
...


...sorry for resurrecting this, but...

If you have mono structure like this in Structure dissect:



...and have the desired Unit instance address in f.e. RCX - how do I get to the Unit.state.hp address in AA?

Is it better to use saved structures from Structure dissect or just monoAA_GETMONOSTRUCT() to "freshly" re-register the desired classes and be "update proof"?

Thanks for your help.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Thu Sep 14, 2017 3:03 am    Post subject: Reply with quote

first you need to dissect both unit and state (or whatever it's called)

then do something like:
Code:

push rax
mov rax,[rcx+Unit.state]
lea rax,[rax+State.hp]
mov [hpaddress],rax
pop rax


it's recommended to use mono_getmonostruct but often you can also just hardcode it. It only changes when something in those classes change

_________________
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
View user's profile Send private message MSN Messenger
FauDrei
Advanced Cheater
Reputation: 4

Joined: 20 Nov 2013
Posts: 69
Location: bachLai

PostPosted: Thu Sep 14, 2017 3:13 am    Post subject: Reply with quote

Many thanks. Very Happy (and sorry for duplicating the question in another thread)

EDIT:
Embarassed Err... one more thing...

Is it possible to stack multiple monoAA_GETMONOSTRUCT() lines in some kind of "registerStructs" lua function in "main" AA script, in a way that you just call "registerStructs" lua function in all other AA (sub)scripts?

I have problem with putting just two monoAA_GETMONOSTRUCT() calls in same lua chunk... Sad

EDIT2:
Some sniffing of experienced lua coder's scripts and some trial and error have solved my problem... Cool

This:
Code:
function registerStructs()
  structs =          monoAA_GETMONOSTRUCT("Unit", syntaxcheck)
  structs = structs..monoAA_GETMONOSTRUCT("UnitPrototype", syntaxcheck)
  structs = structs..monoAA_GETMONOSTRUCT("UnitResources", syntaxcheck)
  structs = structs..monoAA_GETMONOSTRUCT("UnitState", syntaxcheck)
  return structs
end

...goes as lua chunk in main AA script, while this
Code:
return registerStructs()

...goes (also as lua chunk) in every script that uses mono structures.

Thanks, I have learned something today. Wink
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Sep 14, 2017 11:50 am    Post subject: Reply with quote

FauDrei wrote:
I have problem with putting just two monoAA_GETMONOSTRUCT() calls in same lua chunk... Sad


if you're trying
Code:
{$lua}
return monoAA_GETMONOSTRUCT(...1)
return monoAA_GETMONOSTRUCT(...2)
{$asm}
then yeah, you can't return two things, separating them into two parts or concatenating the results should work
Code:
{$lua}
LaunchMonoDataCollector() -- should only need to be done once
return monoAA_GETMONOSTRUCT(...1)
{$asm}

{$lua}
return monoAA_GETMONOSTRUCT(...2)
{$asm}
or
Code:
{$lua}
LaunchMonoDataCollector()
-- concatenate together, not sure if the \r\n is necessary
-- lua immutable strings will cause memory allocations for concatenation...
return monoAA_GETMONOSTRUCT(...1) .. '\r\n' .. monoAA_GETMONOSTRUCT(...2)
{$asm}
@DB since monoscript.lua uses registerAutoAssemblerCommand shouldn't it also be possible to use just
Code:
USEMONO()
GETMONOSTRUCT(...1)
GETMONOSTRUCT(...2)
Back to top
View user's profile Send private message
MMM-304
Expert Cheater
Reputation: 0

Joined: 17 Aug 2020
Posts: 166
Location: Milkey Way

PostPosted: Sun Aug 22, 2021 10:16 pm    Post subject: Reply with quote

can i get field names using an address instead of class name?

cuz when I try using class name, it says this class doesnt have any fields, but when i use the address, the autoGuess system gives it the same name as of that class, and also populates the fields
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 Tutorials 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