Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Confuser.Runtime/AntiDump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 });
}
}
}
}
7 changes: 6 additions & 1 deletion Confuser.Runtime/AntiTamper.Anti.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
}
}
}
7 changes: 6 additions & 1 deletion Confuser.Runtime/AntiTamper.JIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion Confuser.Runtime/AntiTamper.Normal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
}
}
}
2 changes: 1 addition & 1 deletion Confuser.Runtime/Confuser.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Import Project="..\ConfuserEx.Common.props" Condition="Exists('..\ConfuserEx.Common.props')" />

<PropertyGroup Label="Assembly Settings">
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

Expand Down
Loading