Code Clean Up

main
walon 2025-08-03 12:37:44 +08:00
parent f5c2fe94ea
commit d52a9e7016
18 changed files with 11 additions and 36 deletions

View File

@ -1,6 +1,4 @@
using System.Text; namespace Obfuz.Editor
namespace Obfuz.Editor
{ {
public static class ConstValues public static class ConstValues
{ {

View File

@ -5,7 +5,6 @@ using Obfuz.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using UnityEngine.Assertions; using UnityEngine.Assertions;

View File

@ -3,7 +3,6 @@ using dnlib.DotNet.Emit;
using Obfuz.Utils; using Obfuz.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using UnityEngine.Assertions; using UnityEngine.Assertions;

View File

@ -1,10 +1,6 @@
using Obfuz.Settings; using Obfuz.Settings;
using Obfuz.Utils; using Obfuz.Utils;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
namespace Obfuz.GarbageCodeGeneration namespace Obfuz.GarbageCodeGeneration

View File

@ -1,5 +1,4 @@
using Obfuz.Settings; using Obfuz.Utils;
using Obfuz.Utils;
namespace Obfuz.GarbageCodeGeneration namespace Obfuz.GarbageCodeGeneration
{ {

View File

@ -52,9 +52,9 @@ namespace Obfuz.ObfusPasses.CallObfus
switch (mode) switch (mode)
{ {
case ProxyMode.Dispatch: case ProxyMode.Dispatch:
return new DispatchProxyObfuscator(ctx.moduleEntityManager); return new DispatchProxyObfuscator(ctx.moduleEntityManager);
case ProxyMode.Delegate: case ProxyMode.Delegate:
return new DelegateProxyObfuscator(ctx.moduleEntityManager); return new DelegateProxyObfuscator(ctx.moduleEntityManager);
default: default:
throw new System.NotSupportedException($"Unsupported proxy mode: {mode}"); throw new System.NotSupportedException($"Unsupported proxy mode: {mode}");
} }

View File

@ -2,7 +2,6 @@
using dnlib.DotNet.Emit; using dnlib.DotNet.Emit;
using Obfuz.Data; using Obfuz.Data;
using Obfuz.Emit; using Obfuz.Emit;
using Obfuz.Settings;
using Obfuz.Utils; using Obfuz.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -64,7 +63,7 @@ namespace Obfuz.ObfusPasses.CallObfus
{ {
return typeName; return typeName;
} }
for (int i = 0; ;i++) for (int i = 0; ; i++)
{ {
typeName = $"$Obfuz$Delegate_{hashCode}_{i}"; typeName = $"$Obfuz$Delegate_{hashCode}_{i}";
if (_allocatedDelegateNames.Add(typeName)) if (_allocatedDelegateNames.Add(typeName))

View File

@ -1,8 +1,6 @@
using dnlib.DotNet; using dnlib.DotNet;
using dnlib.DotNet.Emit; using dnlib.DotNet.Emit;
using Obfuz.Data;
using Obfuz.Emit; using Obfuz.Emit;
using Obfuz.Settings;
using Obfuz.Utils; using Obfuz.Utils;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -2,7 +2,6 @@
using dnlib.DotNet.Emit; using dnlib.DotNet.Emit;
using Obfuz.Data; using Obfuz.Data;
using Obfuz.Emit; using Obfuz.Emit;
using Obfuz.Settings;
using Obfuz.Utils; using Obfuz.Utils;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,5 +1,4 @@
using dnlib.DotNet; using dnlib.DotNet;
using UnityEngine;
namespace Obfuz.ObfusPasses.ControlFlowObfus namespace Obfuz.ObfusPasses.ControlFlowObfus
{ {

View File

@ -1,5 +1,4 @@
using dnlib.DotNet; using dnlib.DotNet;
using Obfuz.Emit;
namespace Obfuz.ObfusPasses.ControlFlowObfus namespace Obfuz.ObfusPasses.ControlFlowObfus
{ {

View File

@ -328,7 +328,7 @@ namespace Obfuz.ObfusPasses.ControlFlowObfus
BlockGroup group = to.group; BlockGroup group = to.group;
group.basicBlocks.Insert(group.basicBlocks.IndexOf(to), saveLocalBasicBlock); group.basicBlocks.Insert(group.basicBlocks.IndexOf(to), saveLocalBasicBlock);
group.switchMachineCases.Add(new SwitchMachineCase { index = -1, prepareBlock = saveLocalBasicBlock, targetBlock = to}); group.switchMachineCases.Add(new SwitchMachineCase { index = -1, prepareBlock = saveLocalBasicBlock, targetBlock = to });
saveLocalBasicBlock.instructions.Add(Instruction.Create(OpCodes.Ldsfld, (FieldDef)null)); saveLocalBasicBlock.instructions.Add(Instruction.Create(OpCodes.Ldsfld, (FieldDef)null));
saveLocalBasicBlock.instructions.Add(Instruction.Create(OpCodes.Stloc, GlobalSwitchIndexLocal)); saveLocalBasicBlock.instructions.Add(Instruction.Create(OpCodes.Stloc, GlobalSwitchIndexLocal));
saveLocalBasicBlock.instructions.Add(Instruction.Create(OpCodes.Br, group.switchMachineEntryInst)); saveLocalBasicBlock.instructions.Add(Instruction.Create(OpCodes.Br, group.switchMachineEntryInst));
@ -359,7 +359,7 @@ namespace Obfuz.ObfusPasses.ControlFlowObfus
{ {
Dictionary<Instruction, BasicBlockInfo> inst2bb = BuildInstructionToBasicBlockInfoDic(); Dictionary<Instruction, BasicBlockInfo> inst2bb = BuildInstructionToBasicBlockInfoDic();
InsertSwitchMachineBasicBlockForGroup(rootGroup, inst2bb); InsertSwitchMachineBasicBlockForGroup(rootGroup, inst2bb);
} }
private void ShuffleBasicBlocks0(List<BasicBlockInfo> bbs) private void ShuffleBasicBlocks0(List<BasicBlockInfo> bbs)

View File

@ -1,6 +1,5 @@
using dnlib.DotNet; using dnlib.DotNet;
using Obfuz.Conf; using Obfuz.Conf;
using Obfuz.Utils;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml; using System.Xml;

View File

@ -1,10 +1,7 @@
using dnlib.DotNet; using dnlib.DotNet;
using dnlib.DotNet.Emit;
using Obfuz.Settings; using Obfuz.Settings;
using Obfuz.Utils; using Obfuz.Utils;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine;
namespace Obfuz.ObfusPasses.RemoveConstField namespace Obfuz.ObfusPasses.RemoveConstField
{ {

View File

@ -1,6 +1,4 @@
using System.Text; namespace Obfuz.ObfusPasses.SymbolObfus.NameMakers
namespace Obfuz.ObfusPasses.SymbolObfus.NameMakers
{ {
public class DebugNameMaker : NameMakerBase public class DebugNameMaker : NameMakerBase
{ {

View File

@ -1,14 +1,11 @@
using dnlib.DotNet; using dnlib.DotNet;
using dnlib.DotNet.Emit; using dnlib.DotNet.Emit;
using dnlib.DotNet.PolymorphicWriter.Utilities;
using NUnit.Framework;
using Obfuz.Emit; using Obfuz.Emit;
using Obfuz.Settings; using Obfuz.Settings;
using Obfuz.Utils; using Obfuz.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using UnityEngine; using UnityEngine;
using FieldAttributes = dnlib.DotNet.FieldAttributes; using FieldAttributes = dnlib.DotNet.FieldAttributes;

View File

@ -1,5 +1,4 @@
using dnlib.DotNet; using dnlib.DotNet;
using Obfuz.Data;
using Obfuz.Emit; using Obfuz.Emit;
using Obfuz.Utils; using Obfuz.Utils;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -122,7 +122,7 @@ namespace Obfuz
searchPaths.Add("Managed/UnityEngine"); searchPaths.Add("Managed/UnityEngine");
} }
var resultPaths = new List<string>(); var resultPaths = new List<string>();
foreach (var path in searchPaths) foreach (var path in searchPaths)
{ {
string candidatePath1 = Path.Combine(applicationContentsPath, path); string candidatePath1 = Path.Combine(applicationContentsPath, path);