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 


monoAA_GETMONOSTRUCT, str is a reserved word

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

Joined: 27 Jul 2018
Posts: 25

PostPosted: Mon Mar 31, 2025 10:08 pm    Post subject: monoAA_GETMONOSTRUCT, str is a reserved word Reply with quote

My code is as followed. I was using monoAA_GETMONOSTRUCT and it was working very well until this error happen
From what I understand, the class name Player_Attributes somehow is a reserved word and cannot be used, how can I go around it?
Code:
{$lua}
return monoAA_GETMONOSTRUCT("Player_Attributes", false)
{$asm}
[ENABLE]
aobscanregion(playercontrol2,Player_Attributes:Update,Player_Attributes:Update+30,8B * * * * * 85 * 75 * 0F) // should be unique
alloc(newmem,$100)


label(code2)
label(return)

newmem:
  push ebx
  mov [edi+Player_Attributes.stat_points],#10
  pop ebx
code2:
  readmem(playercontrol2,6)
  //db 8B 87 D8 01 00 00
  jmp return

playercontrol2:
  jmp newmem
  nop
return:
registersymbol(playercontrol2 code2)

[DISABLE]
//code from here till the end of the code will be used to disable the cheat
playercontrol2:
  readmem(code2,6)
  //db 8B 87 D8 01 00 00

unregistersymbol(*)
dealloc(*)
Back to top
View user's profile Send private message
HenryEx
Expert Cheater
Reputation: 2

Joined: 18 Dec 2011
Posts: 100

PostPosted: Sun Apr 06, 2025 4:38 am    Post subject: Reply with quote

That function is prefixed with monoAA_ because.... you guessed it, it's supposed to be used from Auto Assembler. Why are you using it from a LUA block instead of ASM?

Call it from ASM with getMonoStruct(Player_Attributes), and maybe put it into the [ENABLE] block since you don't seem to need it for the disable anyways. Maybe that fixes the problem.

I've had some weird problems with getMonoStruct too, where sometimes fields from multiple structs conflict and don't assemble unless i put them in a certain order. Like, "getMonoStruct(X) getMonoStruct(Y)" fails, but "getMonoStruct(Y) getMonoStruct(X)" works.
Sometimes, it worked just fine, until i saved and reopened the table and then a previously working script didn't assemble anymore.


So in difficult cases or ones where i only need 1 or 2 fields from a mono class, i usually get them manually instead of using getMonoStruct to define the whole structure. Something like this in your case.

Code:
{$lua}
if syntaxcheck then return 'define(stat_points,0)' end
local fAttributes = getMonoFields('Player_Attributes')
local off = fAttributes['stat_points'][1]
return string.format('define(stat_points,%X)',off)
{$asm}
[ENABLE]
aobscanregion(playercontrol2,Player_Attributes:Update,Player_Attributes:Update+30,8B * * * * * 85 * 75 * 0F) // should be unique
alloc(newmem,$100)


label(code2)
label(return)

newmem:
  push ebx
  mov [edi+stat_points],#10
  pop ebx
code2:
  readmem(playercontrol2,6)
  //db 8B 87 D8 01 00 00
  jmp return

playercontrol2:
  jmp newmem
  nop
return:
registersymbol(playercontrol2 code2)

[DISABLE]
//code from here till the end of the code will be used to disable the cheat
playercontrol2:
  readmem(code2,6)
  //db 8B 87 D8 01 00 00

unregistersymbol(*)
dealloc(*)


You will need a way to fetch class fields first though, i've used my getMonoFields function in this example which i have posted here.
Back to top
View user's profile Send private message
Beginner999
Cheater
Reputation: 0

Joined: 27 Jul 2018
Posts: 25

PostPosted: Tue Apr 08, 2025 8:28 am    Post subject: Reply with quote

HenryEx wrote:
That function is prefixed with monoAA_ because.... you guessed it, it's supposed to be used from Auto Assembler. Why are you using it from a LUA block instead of ASM?

I read about it here, so I just follow the formula Crying or Very sad
But thanks for your help, I will try it once I'm home Very Happy
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 958

PostPosted: Wed Apr 09, 2025 1:27 am    Post subject: Reply with quote

'str' is a x86 instruction, so the error. ( https://www.felixcloutier.com/x86/str )

As the function return an AA structure definition as string, we can do a string gsub etc to replace the 'invalid' name to something ok.

This is an example for Lua and AA :
Code:


function monoStruct(kls, renames)
  local struct, err = monoAA_GETMONOSTRUCT(kls)
  if type(struct)=='string'then
    if type(renames)=='string'then
      for from,to in renames:gmatch('(%S+)%s*=%s*(%S+)')do
        from = '(%s*)%f[%S]'..from..':'
        to = '%1'..to..':'
        struct = struct:gsub( from, to )
      end
    end
    return struct
  else
    return struct, err
  end
end

local cmd = 'monoStructure'
unregisterAutoAssemblerCommand(cmd)
registerAutoAssemblerCommand(cmd, function(s, sc)
  local symcls, renames = s:match'^(.-);+(.*)$'
  if not symcls then symcls = s end
  return monoStruct(symcls, renames)
end)


-- eg. in lua
print(monoStruct('pp,DuloGames.UI:TimingAttackBar','MarginSpacingPercent = MSP'))
-- in AA : monoStructure(pp,DuloGames.UI:TimingAttackBar ; MarginSpacingPercent = MSP)


-- MarginSpacingPercent, or pp.MarginSpacingPercent is removed, instead
-- MSP or pp.MSP is usable.



btw, il2cpp game may also applied, but il2cpp symbol to seperate namespace and class is '.', remember to change it to ':',
For example, above 'DuloGames.UI.TimingAttackBar' -> 'DuloGames.UI:TimingAttackBar'

_________________
- Retarded.
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 Lua Scripting 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