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 


How to get mono (il2cpp) static field address ?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Y.A.K.E
Advanced Cheater
Reputation: 0

Joined: 15 Jul 2019
Posts: 56

PostPosted: Sat Feb 04, 2023 11:14 pm    Post subject: How to get mono (il2cpp) static field address ? Reply with quote

Code:

local cId = mono_findClass('', 'PlayerManager')
return mono_class_getStaticFieldAddress(mono_enumDomains()[1], cId)



return null:
Code:

1:0



I found a new way, but I don't know how to get the address.



Code:

local mea=mono_enumAssemblies()
local all_static = {}
if mea~=nil then
   for i=1, #mea do
      local iid = mono_getImageFromAssembly(mea[i])
      local iname = mono_image_get_name(iid)
      if ('Assembly-CSharp.dll' == iname) then
         local classes = mono_image_enumClasses(iid)
         if classes~=nil then
            for j=1, #classes do
                                        --print(classes[j].classname)
               if('PlayerManager' == classes[j].classname)then
                  local fields=mono_class_enumFields(classes[j].class, true)
                  for l,v in ipairs(fields) do
                                                        --print(fields.name)
                     if v.isStatic == true and v.name == [[Owner]] then
                        table.insert(all_static,v)
                     end
                  end
               end
            end
         end
      end
   end
end
return all_static



return :



Code:

1:table
  [
     1 = table
     [
        flags = 22
        offset = 0
        isConst = false
        monotype = 18
        field = 2899850670568
        parent = 2899841166912
        name = Owner
        typename = PlayerManager
        isStatic = true
        type = 140737344506736
     ]
  ]




Screenshot 2023-02-05 125008.png
 Description:
 Filesize:  136.54 KB
 Viewed:  2307 Time(s)

Screenshot 2023-02-05 125008.png


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