代码清理
parent
cfe9dcdd08
commit
0ad96daa32
|
@ -172,7 +172,7 @@ namespace Obfuz.Emit
|
|||
Assert.IsNotNull(_multiplyFloat, "ExprUtility.Multiply(float, float) not found");
|
||||
_multiplyDouble = mod.Import(exprUtilityType.GetMethod("Multiply", new[] { typeof(double), typeof(double) }));
|
||||
Assert.IsNotNull(_multiplyDouble, "ExprUtility.Multiply(double, double) not found");
|
||||
_divideInt = mod.Import(exprUtilityType.GetMethod("Divide", new[] {typeof(int), typeof(int) }));
|
||||
_divideInt = mod.Import(exprUtilityType.GetMethod("Divide", new[] { typeof(int), typeof(int) }));
|
||||
Assert.IsNotNull(_divideInt, "ExprUtility.Divide(int, int) not found");
|
||||
_divideLong = mod.Import(exprUtilityType.GetMethod("Divide", new[] { typeof(long), typeof(long) }));
|
||||
Assert.IsNotNull(_divideLong);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using dnlib.DotNet;
|
||||
using dnlib.DotNet.Emit;
|
||||
using dnlib.DotNet.Writer;
|
||||
using Obfuz.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -153,7 +152,7 @@ namespace Obfuz.Emit
|
|||
datas.Add(type);
|
||||
}
|
||||
|
||||
private EvalDataType CalcBasicBinOpRetType(List<EvalDataType> datas, EvalDataType op1, EvalDataType op2)
|
||||
private EvalDataType CalcBasicBinOpRetType(List<EvalDataType> datas, EvalDataType op1, EvalDataType op2)
|
||||
{
|
||||
switch (op1)
|
||||
{
|
||||
|
@ -174,7 +173,7 @@ namespace Obfuz.Emit
|
|||
case EvalDataType.Int32: return EvalDataType.Int64;
|
||||
case EvalDataType.Int64:
|
||||
case EvalDataType.I:
|
||||
return EvalDataType.Int64;
|
||||
return EvalDataType.Int64;
|
||||
default: throw new Exception($"Unsupported operand type: {op2} for {op1} in binary operation.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using NUnit.Framework;
|
||||
using Obfuz.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Obfuz.EncryptionVM.Instructions
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using dnlib.DotNet.Emit;
|
||||
using Obfuz.Emit;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Obfuz.ObfusPasses
|
||||
{
|
||||
|
|
|
@ -237,7 +237,7 @@ namespace Obfuz.ObfusPasses.CallObfus
|
|||
salt = salt,
|
||||
encryptedIndex = encryptedIndex,
|
||||
};
|
||||
methodDispatcher.methods.Add(new CallInfo { id = $"{method}{(callVir ? "" : "v")}", method = method, callVir = callVir });
|
||||
methodDispatcher.methods.Add(new CallInfo { id = $"{method}{(callVir ? "" : "v")}", method = method, callVir = callVir });
|
||||
_methodProxys.Add(key, proxyInfo);
|
||||
}
|
||||
return new ProxyCallMethodData(proxyInfo.proxyMethod, proxyInfo.encryptedOps, proxyInfo.salt, proxyInfo.encryptedIndex, proxyInfo.index);
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
using dnlib.DotNet;
|
||||
using Obfuz.Conf;
|
||||
using Obfuz.Settings;
|
||||
using Obfuz.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using UnityEditor.VersionControl;
|
||||
|
||||
namespace Obfuz.ObfusPasses.EvalStackObfus
|
||||
{
|
||||
|
|
|
@ -4,12 +4,7 @@ using Obfuz.Data;
|
|||
using Obfuz.Emit;
|
||||
using Obfuz.Settings;
|
||||
using Obfuz.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Obfuz.ObfusPasses.EvalStackObfus
|
||||
{
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using dnlib.DotNet;
|
||||
using dnlib.DotNet.Emit;
|
||||
using Obfuz.Emit;
|
||||
using dnlib.DotNet.Emit;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Obfuz.ObfusPasses.EvalStackObfus
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
using dnlib.DotNet;
|
||||
using Obfuz.Conf;
|
||||
using Obfuz.Settings;
|
||||
using Obfuz.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using UnityEditor.VersionControl;
|
||||
|
||||
namespace Obfuz.ObfusPasses.ExprObfus
|
||||
{
|
||||
|
|
|
@ -6,8 +6,6 @@ using Obfuz.ObfusPasses.ExprObfus.Obfuscators;
|
|||
using Obfuz.Settings;
|
||||
using Obfuz.Utils;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Obfuz.ObfusPasses.ExprObfus
|
||||
{
|
||||
|
@ -72,7 +70,7 @@ namespace Obfuz.ObfusPasses.ExprObfus
|
|||
return _obfuscationPolicy.NeedObfuscate(method);
|
||||
}
|
||||
|
||||
protected bool TryObfuscateInstruction(IObfuscator obfuscator, InstructionParameterInfo pi, Instruction inst, List<Instruction> outputInstructions, ObfusMethodContext ctx)
|
||||
protected bool TryObfuscateInstruction(IObfuscator obfuscator, InstructionParameterInfo pi, Instruction inst, List<Instruction> outputInstructions, ObfusMethodContext ctx)
|
||||
{
|
||||
//Debug.Log($"Obfuscating instruction: {inst} in method: {ctx.method.FullName}");
|
||||
IRandom localRandom = ctx.localRandom;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using dnlib.DotNet;
|
||||
using dnlib.DotNet.Emit;
|
||||
using dnlib.DotNet.Emit;
|
||||
using Obfuz.Emit;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
using dnlib.DotNet.Emit;
|
||||
using dnlib.DotNet;
|
||||
using Obfuz.Emit;
|
||||
using System.Collections.Generic;
|
||||
using Obfuz.Utils;
|
||||
using Obfuz.Data;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
using JetBrains.Annotations;
|
||||
using System;
|
||||
using Obfuz.Emit;
|
||||
using Obfuz.Utils;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Obfuz.ObfusPasses.ExprObfus.Obfuscators
|
||||
{
|
||||
|
@ -104,12 +99,12 @@ namespace Obfuz.ObfusPasses.ExprObfus.Obfuscators
|
|||
|
||||
public override bool ObfuscateBinBitwiseOp(Instruction inst, EvalDataType op1, EvalDataType op2, EvalDataType ret, List<Instruction> outputInsts, ObfusMethodContext ctx)
|
||||
{
|
||||
return GenerateIdentityTransformForArgument(inst, op2, outputInsts, ctx) || base.ObfuscateBinBitwiseOp(inst, op1 , op2, ret, outputInsts, ctx);
|
||||
return GenerateIdentityTransformForArgument(inst, op2, outputInsts, ctx) || base.ObfuscateBinBitwiseOp(inst, op1, op2, ret, outputInsts, ctx);
|
||||
}
|
||||
|
||||
public override bool ObfuscateBitShiftOp(Instruction inst, EvalDataType op1, EvalDataType op2, EvalDataType ret, List<Instruction> outputInsts, ObfusMethodContext ctx)
|
||||
{
|
||||
return GenerateIdentityTransformForArgument(inst, op2, outputInsts, ctx) || base.ObfuscateBitShiftOp(inst, op1, op2 , ret, outputInsts, ctx);
|
||||
return GenerateIdentityTransformForArgument(inst, op2, outputInsts, ctx) || base.ObfuscateBitShiftOp(inst, op1, op2, ret, outputInsts, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
using dnlib.DotNet;
|
||||
using dnlib.DotNet.Emit;
|
||||
using Obfuz.Emit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Obfuz.ObfusPasses.ExprObfus.Obfuscators
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace Obfuz.ObfusPasses.ExprObfus.Obfuscators
|
|||
|
||||
public override bool ObfuscateBitShiftOp(Instruction inst, EvalDataType op1, EvalDataType op2, EvalDataType ret, List<Instruction> outputInsts, ObfusMethodContext ctx)
|
||||
{
|
||||
if (!base.ObfuscateBitShiftOp(inst, op1, op2, ret,outputInsts, ctx))
|
||||
if (!base.ObfuscateBitShiftOp(inst, op1, op2, ret, outputInsts, ctx))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
using dnlib.DotNet;
|
||||
using dnlib.DotNet.Emit;
|
||||
using Obfuz.Editor;
|
||||
using Obfuz.Emit;
|
||||
using Obfuz.Settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Security;
|
||||
using System.Text;
|
||||
using UnityEngine.Assertions;
|
||||
|
||||
|
@ -40,7 +37,7 @@ namespace Obfuz.ObfusPasses.Instinct
|
|||
private string GetTypeName(TypeSig type)
|
||||
{
|
||||
type = type.RemovePinnedAndModifiers();
|
||||
switch(type.ElementType)
|
||||
switch (type.ElementType)
|
||||
{
|
||||
case ElementType.Class:
|
||||
case ElementType.ValueType:
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using dnlib.DotNet;
|
||||
using dnlib.DotNet.Emit;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Obfuz.ObfusPasses
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using dnlib.DotNet;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine.Assertions;
|
||||
|
||||
namespace Obfuz.ObfusPasses.SymbolObfus.NameMakers
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using Obfuz.Editor;
|
||||
using Obfuz.Utils;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Obfuz.ObfusPasses.SymbolObfus.Policies
|
||||
{
|
||||
|
|
|
@ -3,8 +3,6 @@ using dnlib.DotNet.Emit;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Obfuz.ObfusPasses.SymbolObfus
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus
|
|||
{
|
||||
return IsVarType(t1) || IsVarType(t2);
|
||||
}
|
||||
|
||||
|
||||
switch (t1.ElementType)
|
||||
{
|
||||
case ElementType.Void:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using Obfuz.ObfusPasses;
|
||||
using Obfuz.ObfusPasses.CallObfus;
|
||||
using Obfuz.ObfusPasses.ConstEncrypt;
|
||||
using Obfuz.ObfusPasses.ControlFlowObfus;
|
||||
using Obfuz.ObfusPasses.EvalStackObfus;
|
||||
using Obfuz.ObfusPasses.ExprObfus;
|
||||
using Obfuz.ObfusPasses.FieldEncrypt;
|
||||
|
@ -186,6 +187,10 @@ namespace Obfuz
|
|||
{
|
||||
builder.AddPass(new CallObfusPass(settings.callObfusSettings.ToFacade()));
|
||||
}
|
||||
if (obfuscationPasses.HasFlag(ObfuscationPassType.ControlFlowObfus))
|
||||
{
|
||||
builder.AddPass(new ControlFlowObfusPass(settings.controlFlowObfuscationSettings.ToFacade()));
|
||||
}
|
||||
if (obfuscationPasses.HasFlag(ObfuscationPassType.SymbolObfus))
|
||||
{
|
||||
builder.AddPass(new SymbolObfusPass(settings.symbolObfusSettings.ToFacade()));
|
||||
|
|
|
@ -40,6 +40,9 @@ namespace Obfuz.Settings
|
|||
[Tooltip("expression obfuscation settings")]
|
||||
public ExprObfuscationSettings exprObfusSettings;
|
||||
|
||||
[Tooltip("control flow obfuscation settings")]
|
||||
public ControlFlowObfuscationSettings controlFlowObfuscationSettings;
|
||||
|
||||
public string ObfuzRootDir => $"Library/Obfuz";
|
||||
|
||||
public string GetObfuscatedAssemblyOutputPath(BuildTarget target)
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace Obfuz.Settings
|
|||
private SerializedProperty _fieldEncryptSettings;
|
||||
private SerializedProperty _callObfusSettings;
|
||||
private SerializedProperty _exprObfusSettings;
|
||||
private SerializedProperty _controlFlowObfusSettings;
|
||||
|
||||
public ObfuzSettingsProvider() : base("Project/Obfuz", SettingsScope.Project)
|
||||
{
|
||||
|
@ -70,6 +71,7 @@ namespace Obfuz.Settings
|
|||
_exprObfusSettings = _serializedObject.FindProperty("exprObfusSettings");
|
||||
_fieldEncryptSettings = _serializedObject.FindProperty("fieldEncryptSettings");
|
||||
_callObfusSettings = _serializedObject.FindProperty("callObfusSettings");
|
||||
_controlFlowObfusSettings = _serializedObject.FindProperty("controlFlowObfuscationSettings");
|
||||
}
|
||||
|
||||
public override void OnGUI(string searchContext)
|
||||
|
@ -94,6 +96,7 @@ namespace Obfuz.Settings
|
|||
EditorGUILayout.PropertyField(_exprObfusSettings);
|
||||
EditorGUILayout.PropertyField(_fieldEncryptSettings);
|
||||
EditorGUILayout.PropertyField(_callObfusSettings);
|
||||
EditorGUILayout.PropertyField(_controlFlowObfusSettings);
|
||||
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
using dnlib.DotNet.Emit;
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet;
|
||||
using dnlib.DotNet.Emit;
|
||||
using Obfuz.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Obfuz.Utils
|
||||
{
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
using dnlib.DotNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Obfuz.Utils
|
||||
{
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Obfuz.Utils
|
||||
{
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Obfuz
|
||||
namespace Obfuz
|
||||
{
|
||||
public static class ObfuscationInstincts
|
||||
{
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Obfuz
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue