Fix Windows 8 compatibility
This commit is contained in:
Родитель
f1df614d03
Коммит
bacf24bbde
|
@ -47,9 +47,9 @@ namespace Confuser.Protections.AntiTamper {
|
|||
deriver.Init(context, random);
|
||||
|
||||
var rt = context.Registry.GetService<IRuntimeService>();
|
||||
MethodDef initMethod = rt.GetRuntimeType("Confuser.Runtime.AntiTamperNormal").FindMethod("Initialize");
|
||||
initMethod = InjectHelper.Inject(initMethod, context.CurrentModule);
|
||||
context.CurrentModule.GlobalType.Methods.Add(initMethod);
|
||||
TypeDef initType = rt.GetRuntimeType("Confuser.Runtime.AntiTamperNormal");
|
||||
IEnumerable<IDnlibDef> members = InjectHelper.Inject(initType, context.CurrentModule.GlobalType, context.CurrentModule);
|
||||
var initMethod = (MethodDef)members.Single(m => m.Name == "Initialize");
|
||||
|
||||
initMethod.Body.SimplifyMacros(initMethod.Parameters);
|
||||
List<Instruction> instrs = initMethod.Body.Instructions.ToList();
|
||||
|
@ -81,13 +81,16 @@ namespace Confuser.Protections.AntiTamper {
|
|||
|
||||
var name = context.Registry.GetService<INameService>();
|
||||
var marker = context.Registry.GetService<IMarkerService>();
|
||||
name.MarkHelper(initMethod, marker);
|
||||
foreach (IDnlibDef def in members) {
|
||||
name.MarkHelper(def, marker);
|
||||
if (def is MethodDef)
|
||||
parent.ExcludeMethod(context, (MethodDef)def);
|
||||
}
|
||||
|
||||
MethodDef cctor = context.CurrentModule.GlobalType.FindStaticConstructor();
|
||||
cctor.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, initMethod));
|
||||
|
||||
parent.ExcludeMethod(context, cctor);
|
||||
parent.ExcludeMethod(context, initMethod);
|
||||
}
|
||||
|
||||
public void HandleMD(AntiTamperProtection parent, ConfuserContext context, ProtectionParameters parameters) {
|
||||
|
|
|
@ -3,9 +3,12 @@ using System.Reflection;
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Confuser.Runtime {
|
||||
internal class AntiTamperNormal {
|
||||
internal static class AntiTamperNormal {
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern bool VirtualProtect(IntPtr lpAddress, uint dwSize, uint flNewProtect, out uint lpflOldProtect);
|
||||
|
||||
private static unsafe void Initialize() {
|
||||
Module m = typeof (AntiTamperNormal).Module;
|
||||
Module m = typeof(AntiTamperNormal).Module;
|
||||
string n = m.FullyQualifiedName;
|
||||
bool f = n.Length > 0 && n[0] == '<';
|
||||
var b = (byte*)Marshal.GetHINSTANCE(m);
|
||||
|
@ -47,6 +50,9 @@ namespace Confuser.Runtime {
|
|||
}
|
||||
Mutation.Crypt(y, d);
|
||||
|
||||
uint w = 0x40;
|
||||
VirtualProtect((IntPtr)e, l << 2, w, out w);
|
||||
|
||||
uint h = 0;
|
||||
for (uint i = 0; i < l; i++) {
|
||||
*e ^= y[h & 0xf];
|
||||
|
|
Загрузка…
Ссылка в новой задаче