function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
local domainId = mono_enumDomains()[1]
print('domainId = ' .. domainId)
local classId = mono_findClass('', 'CombatManager')
print('classId = ' .. classId)
local methodId = mono_class_findMethod(classId, 'SceneStart')
print('methodId = ' .. methodId)
methodId = mono_findMethod('', 'CombatManager', 'SceneStart')
print('methodId = ' .. methodId)
--print(dump(mono_class_enumFields(classId)))
--print(dump(mono_enumDomains()))
--print()
print(mono_class_getStaticFieldAddress(domainId, classId))
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
local domainId = mono_enumDomains()[1]
print('domainId = ' .. domainId)
local classId = mono_findClass('', 'CombatManager')
print('classId = ' .. classId)
local methodId = mono_class_findMethod(classId, 'SceneStart')
print('methodId = ' .. methodId)
methodId = mono_findMethod('', 'CombatManager', 'SceneStart')
print('methodId = ' .. methodId)
--print(dump(mono_class_enumFields(classId)))
--print(dump(mono_enumDomains()))
--print()
print(mono_class_getStaticFieldAddress(domainId, classId))
local function getCombatManager()
local c = mono_findClass('Assembly-CSharp.dll', 'CombatManager')
local f = mono_class_enumFields(c, true)
for i in pairs(f) do
if f[i].isStatic and f[i].Name == 'instance' then
local v = mono_class_getStaticFieldValue(c, f[i].field)
return v
end
end
end
print(string.format('%X', getCombatManager()))
Thank you so much for nudging in the right direction!
So the change that made stuff work was the true param in mono_class_enumFields which is "includeParents". That seems to make the static field appear.
Since your code didnt work, here is the small correction. As the field "name" is case sensitive, this is what made it work. (fields.name instead of fields.Name)
local classId = mono_findClass('Assembly-CSharp.dll', 'CombatManager')
print(classId)
local fields = mono_class_enumFields(classId, true)
for i in pairs(fields) do
if fields[i].isStatic and fields[i].name == 'instance' then
local instance = mono_class_getStaticFieldValue(classId, fields[i].field)
print(instance)
local methodId = mono_class_findMethod(classId, 'SceneStart')
print(methodId)
mono_invoke_method('Assembly-CSharp.dll', methodId, instance, {})
end
end
Thank you so much for nudging in the right direction!
So the change that made stuff work was the true param in mono_class_enumFields which is "includeParents". That seems to make the static field appear.
Since your code didnt work, here is the small correction. As the field "name" is case sensitive, this is what made it work. (fields.name instead of fields.Name)
local classId = mono_findClass('Assembly-CSharp.dll', 'CombatManager')
print(classId)
local fields = mono_class_enumFields(classId, true)
for i in pairs(fields) do
if fields[i].isStatic and fields[i].name == 'instance' then
local instance = mono_class_getStaticFieldValue(classId, fields[i].field)
print(instance)
local methodId = mono_class_findMethod(classId, 'SceneStart')
print(methodId)
mono_invoke_method('Assembly-CSharp.dll', methodId, instance, {})
end
end
Again thank you so much for the quick help!
You're welcome . Ah yes, my mistake. Force of habit with typing in camelCase