 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
ShaRose Cheater
Reputation: 0
Joined: 12 Jan 2010 Posts: 26
|
Posted: Sun Oct 25, 2020 1:12 pm Post subject: [7.2 Beta] mono_getStaticFieldValue usage? |
|
|
I can't seem to figure out how to coax mono_getStaticFieldValue to give me the same pointers that mono_class_getStaticFieldAddress + offset gives me. They should be able to get the same values, but it seems they are always off. Test code below:
| Code: | if syntaxcheck then return end
if LaunchMonoDataCollector() == 0 then return end
local className = "MainManager"
local classID = mono_findClass("", className)
local staticField = nil
local staticOffset = nil
local fields = mono_class_enumFields(classID)
for i=1,#fields do
local field = fields[i]
if field.name == "instance" then
staticField = field.field
staticOffset = field.offset
end
end
function numornil(input)
if input == nil then
return "NIL"
end
return string.format("%X", input)
end
print("staticOffset is",staticOffset)
local domain = mono_enumDomains()[1]
print("OLD "..numornil(mono_class_getStaticFieldAddress(domain, classID)))
print("NEW 1 "..numornil(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),staticField)))
print("NEW 2 "..numornil(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),readPointer(staticField))))
print("NEW 3 "..numornil(readPointer(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),staticField))))
print("NEW 4 "..numornil(readPointer(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),readPointer(staticField)))))
|
And the results:
| Code: | staticOffset is 0
OLD 168E6B73450
NEW 1 16AB3351B40
NEW 2 168E6C93456
NEW 3 16A4FC66CD0
NEW 4 NIL |
From what I can gather, field.field is what I'm supposed to pass (Most other values either aren't valid or crash the game), but I can't be sure.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25833 Location: The netherlands
|
Posted: Sun Oct 25, 2020 1:46 pm Post subject: |
|
|
mono_getStaticFieldValue may return a new Object wrapping the old object, whereas reading by offset accesses it directly.
_________________
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 |
|
 |
ShaRose Cheater
Reputation: 0
Joined: 12 Jan 2010 Posts: 26
|
Posted: Sun Oct 25, 2020 2:33 pm Post subject: |
|
|
If it returns a wrapped object, how do I access the original? It doesn't seem like all the pointers are wrapped the same.
| Code: | if syntaxcheck then return end
if LaunchMonoDataCollector() == 0 then return end
local className = "MainManager"
local classID = mono_findClass("", className)
local staticField = nil
local staticOffset = nil
local fields = mono_class_enumFields(classID)
for i=1,#fields do
local field = fields[i]
if field.name == "instance" then
staticField = field.field
staticOffset = field.offset
end
end
function testStoreManager(input)
if input == nil then
return nil
end
local currentAddress = readPointer(input)
if currentAddress == nil or currentAddress == 0 then
return nil
end
local offset = getAddressSafe("MainManager.storeSDKManager")
if offset == nil then
return nil
end
currentAddress = readPointer(currentAddress + offset)
if currentAddress == nil or currentAddress == 0 then
return nil
end
return currentAddress
end
function numornil(input)
if input == nil then
return "NIL"
end
return string.format("%X", input)
end
print("staticOffset is",staticOffset)
local domain = mono_enumDomains()[1]
print("OLD "..numornil(testStoreManager(mono_class_getStaticFieldAddress(domain, classID))))
print("NEW 1 "..numornil(testStoreManager(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),staticField))))
print("NEW 2 "..numornil(testStoreManager(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),readPointer(staticField)))))
print("NEW 3 "..numornil(testStoreManager(readPointer(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),staticField)))))
print("NEW 4 "..numornil(testStoreManager(readPointer(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),readPointer(staticField)))))) |
Returns:
| Code: | staticOffset is 0
OLD 13F305EF540
NEW 1 13E841D3450
NEW 2 NIL
NEW 3 NIL
NEW 4 NIL |
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25833 Location: The netherlands
|
Posted: Sun Oct 25, 2020 7:01 pm Post subject: |
|
|
have you checked out the data it points to? If it's the correct variable type in structure dissect ?
_________________
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 |
|
 |
ShaRose Cheater
Reputation: 0
Joined: 12 Jan 2010 Posts: 26
|
Posted: Mon Oct 26, 2020 12:46 pm Post subject: |
|
|
Yeah, the new method's pointer gives me invalid data. storeBranchType was 404 instead of the correct 0 (It's an enum that only goes 0-3).
MainManager is similarly invalid (But it doesn't have any obvious hints like an enum as almost all fields are pointers to other objects).
Edit:
I just figured it out thanks to taking a shower, as per usual. Here's the updated code:
| Code: | if syntaxcheck then return end
if LaunchMonoDataCollector() == 0 then return end
local className = "MainManager"
local classID = mono_findClass("", className)
local staticField = nil
local staticOffset = nil
local fields = mono_class_enumFields(classID)
for i=1,#fields do
local field = fields[i]
if field.name == "instance" then
staticField = field.field
staticOffset = field.offset
end
end
function testStoreManager(input)
if input == nil then
return nil
end
-- Notice I'm not reading the pointer this time?
local currentAddress = input
if currentAddress == 0 then
return nil
end
local offset = getAddressSafe("MainManager.storeSDKManager")
if offset == nil then
return nil
end
currentAddress = readPointer(currentAddress + offset)
if currentAddress == nil or currentAddress == 0 then
return nil
end
return currentAddress
end
function numornil(input)
if input == nil then
return "NIL"
end
return string.format("%X", input)
end
print("staticOffset is",staticOffset)
local domain = mono_enumDomains()[1]
-- Notice the readPointer for the old Method?
print("OLD "..numornil(testStoreManager(readPointer(mono_class_getStaticFieldAddress(domain, classID)))))
print("NEW 1 "..numornil(testStoreManager(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),staticField))))
print("NEW 2 "..numornil(testStoreManager(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),readPointer(staticField)))))
print("NEW 3 "..numornil(testStoreManager(readPointer(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),staticField)))))
print("NEW 4 "..numornil(testStoreManager(readPointer(mono_getStaticFieldValue(mono_class_getVTable(domain,classID),readPointer(staticField)))))) |
So yeah, mono_getStaticFieldValue obviously returns the VALUE, not a pointer to it. Which should have been obvious.
Works now, though.
|
|
| Back to top |
|
 |
|
|
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
|
|