Skip to content

Commit 7c174be

Browse files
committed
1 parent 9b7ae30 commit 7c174be

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

UnityResolve.hpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,23 @@ class UnityResolve final {
188188
auto SetStaticValue(T* value) const -> void {
189189
if (!static_field) return;
190190
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+
}
191197
}
192198

193199
template <typename T>
194200
auto GetStaticValue(T* value) const -> void {
195201
if (!static_field) return;
196202
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+
}
197208
}
198209

199210
template <typename T, typename C>
@@ -708,7 +719,12 @@ class UnityResolve final {
708719
if ((field = Invoke<void*>("mono_class_get_fields", pKlass, &iter))) {
709720
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 };
710721
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+
}
712728
pField->type->name = Invoke<const char*>("mono_type_get_name", pField->type->address);
713729
pField->type->size = Invoke<int>("mono_type_size", pField->type->address, &tSize);
714730
klass->fields.push_back(pField);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy