diff --git a/Confuser.Runtime/AntiDump.cs b/Confuser.Runtime/AntiDump.cs
index 798707c3..581190a8 100644
--- a/Confuser.Runtime/AntiDump.cs
+++ b/Confuser.Runtime/AntiDump.cs
@@ -10,7 +10,7 @@ internal static class AntiDump {
static unsafe void Initialize() {
uint old;
Module module = typeof(AntiDump).Module;
- var bas = (byte*)Marshal.GetHINSTANCE(module);
+ var bas = (byte*)GetHINSTANCE(module);
byte* ptr = bas + 0x3c;
byte* ptr2;
ptr = ptr2 = bas + *(uint*)ptr;
@@ -234,5 +234,10 @@ static unsafe void Initialize() {
}
}
}
+
+ public static IntPtr GetHINSTANCE(Module module) {
+ var method = typeof(Marshal).GetMember("GetHINSTANCE", BindingFlags.Public | BindingFlags.Static)[0] as MethodInfo;
+ return (IntPtr)method.Invoke(null, new object[] { module });
+ }
}
-}
\ No newline at end of file
+}
diff --git a/Confuser.Runtime/AntiTamper.Anti.cs b/Confuser.Runtime/AntiTamper.Anti.cs
index f1be244c..b1ceef66 100644
--- a/Confuser.Runtime/AntiTamper.Anti.cs
+++ b/Confuser.Runtime/AntiTamper.Anti.cs
@@ -16,7 +16,7 @@ static unsafe void Initialize() {
Module m = typeof(AntiTamperAnti).Module;
string n = m.FullyQualifiedName;
bool f = n.Length > 0 && n[0] == '<';
- var b = (byte*)Marshal.GetHINSTANCE(m);
+ var b = (byte*)GetHINSTANCE(m);
byte* p = b + *(uint*)(b + 0x3c);
ushort s = *(ushort*)(p + 0x6);
ushort o = *(ushort*)(p + 0x14);
@@ -88,5 +88,10 @@ static unsafe void Initialize() {
h++;
}
}
+
+ public static IntPtr GetHINSTANCE(Module module) {
+ var method = typeof(Marshal).GetMember("GetHINSTANCE", BindingFlags.Public | BindingFlags.Static)[0] as MethodInfo;
+ return (IntPtr)method.Invoke(null, new object[] { module });
+ }
}
}
diff --git a/Confuser.Runtime/AntiTamper.JIT.cs b/Confuser.Runtime/AntiTamper.JIT.cs
index ca0535fb..fd07bc28 100644
--- a/Confuser.Runtime/AntiTamper.JIT.cs
+++ b/Confuser.Runtime/AntiTamper.JIT.cs
@@ -19,7 +19,7 @@ public static void Initialize() {
Module m = typeof(AntiTamperNormal).Module;
string n = m.FullyQualifiedName;
bool f = n.Length > 0 && n[0] == '<';
- var b = (byte*)Marshal.GetHINSTANCE(m);
+ var b = (byte*)GetHINSTANCE(m);
byte* p = b + *(uint*)(b + 0x3c);
ushort s = *(ushort*)(p + 0x6);
ushort o = *(ushort*)(p + 0x14);
@@ -86,6 +86,11 @@ public static void Initialize() {
Hook();
}
+ public static IntPtr GetHINSTANCE(Module module) {
+ var method = typeof(Marshal).GetMember("GetHINSTANCE", BindingFlags.Public | BindingFlags.Static)[0] as MethodInfo;
+ return (IntPtr)method.Invoke(null, new object[] { module });
+ }
+
static object GetFieldValue(object obj, string fieldName) {
var field = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field == null)
diff --git a/Confuser.Runtime/AntiTamper.Normal.cs b/Confuser.Runtime/AntiTamper.Normal.cs
index 6fc882ff..2abb75c6 100644
--- a/Confuser.Runtime/AntiTamper.Normal.cs
+++ b/Confuser.Runtime/AntiTamper.Normal.cs
@@ -11,7 +11,7 @@ static unsafe void Initialize() {
Module m = typeof(AntiTamperNormal).Module;
string n = m.FullyQualifiedName;
bool f = n.Length > 0 && n[0] == '<';
- var b = (byte*)Marshal.GetHINSTANCE(m);
+ var b = (byte*)GetHINSTANCE(m);
byte* p = b + *(uint*)(b + 0x3c);
ushort s = *(ushort*)(p + 0x6);
ushort o = *(ushort*)(p + 0x14);
@@ -64,5 +64,10 @@ static unsafe void Initialize() {
h++;
}
}
+
+ public static IntPtr GetHINSTANCE(Module module) {
+ var method = typeof(Marshal).GetMember("GetHINSTANCE", BindingFlags.Public | BindingFlags.Static)[0] as MethodInfo;
+ return (IntPtr)method.Invoke(null, new object[] { module });
+ }
}
}
diff --git a/Confuser.Runtime/Confuser.Runtime.csproj b/Confuser.Runtime/Confuser.Runtime.csproj
index be144811..8ac37535 100644
--- a/Confuser.Runtime/Confuser.Runtime.csproj
+++ b/Confuser.Runtime/Confuser.Runtime.csproj
@@ -4,7 +4,7 @@
- net472;net8.0
+ netstandard2.0
true