@@ -188,12 +188,23 @@ class UnityResolve final {
188
188
auto SetStaticValue (T* value) const -> void {
189
189
if (!static_field) return ;
190
190
if (mode_ == Mode::Il2Cpp) return Invoke<void , void *, T*>(" il2cpp_field_static_set_value" , address, value);
191
+ else
192
+ {
193
+ void * VTable = Invoke<void *>(" mono_class_vtable" , pDomain, klass->address );
194
+ return Invoke<void , void *, void *, T*>(" mono_field_static_set_value" , VTable, address, value);
195
+
196
+ }
191
197
}
192
198
193
199
template <typename T>
194
200
auto GetStaticValue (T* value) const -> void {
195
201
if (!static_field) return ;
196
202
if (mode_ == Mode::Il2Cpp) return Invoke<void , void *, T*>(" il2cpp_field_static_get_value" , address, value);
203
+ else
204
+ {
205
+ void * VTable = Invoke<void *>(" mono_class_vtable" , pDomain, klass->address );
206
+ return Invoke<void , void *, void *, T*>(" mono_field_static_get_value" , VTable, address, value);
207
+ }
197
208
}
198
209
199
210
template <typename T, typename C>
@@ -708,7 +719,12 @@ class UnityResolve final {
708
719
if ((field = Invoke<void *>(" mono_class_get_fields" , pKlass, &iter))) {
709
720
const auto pField = new Field{ .address = field, .name = Invoke<const char *>(" mono_field_get_name" , field), .type = new Type{.address = Invoke<void *>(" mono_field_get_type" , field)}, .klass = klass, .offset = Invoke<int >(" mono_field_get_offset" , field), .static_field = false , .vTable = nullptr };
710
721
int tSize{};
711
- pField->static_field = pField->offset <= 0 ;
722
+ /* pField->static_field = pField->offset <= 0;*/
723
+ int flags = Invoke<int >(" mono_field_get_flags" , field);
724
+ if (flags & 0x10 )// 0x10=FIELD_ATTRIBUTE_STATIC
725
+ {
726
+ pField->static_field = true ;
727
+ }
712
728
pField->type ->name = Invoke<const char *>(" mono_type_get_name" , pField->type ->address );
713
729
pField->type ->size = Invoke<int >(" mono_type_size" , pField->type ->address , &tSize);
714
730
klass->fields .push_back (pField);
0 commit comments