obfuz/Editor/ObfusPasses/CleanUp/CleanUpInstructionPass.cs

47 lines
1.2 KiB
C#
Raw Normal View History

using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
2025-04-21 21:02:47 +08:00
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2025-05-04 19:55:10 +08:00
namespace Obfuz.ObfusPasses.CleanUp
2025-04-21 21:02:47 +08:00
{
public class CleanUpInstructionPass : ObfuscationPassBase
{
2025-05-12 22:01:35 +08:00
public override ObfuscationPassType Type => ObfuscationPassType.None;
public override void Start()
2025-05-03 20:42:08 +08:00
{
}
public override void Stop()
2025-05-03 20:42:08 +08:00
{
}
public override void Process()
2025-04-21 21:02:47 +08:00
{
var ctx = ObfuscationPassContext.Current;
2025-05-17 12:11:36 +08:00
foreach (ModuleDef mod in ctx.modulesToObfuscate)
{
2025-05-03 23:23:16 +08:00
foreach (TypeDef type in mod.GetTypes())
{
foreach (MethodDef method in type.Methods)
{
if (method.HasBody)
{
CilBody body = method.Body;
body.SimplifyBranches();
body.OptimizeMacros();
body.OptimizeBranches();
2025-04-22 10:42:58 +08:00
// TODO remove dup
}
}
}
}
2025-04-21 21:02:47 +08:00
}
}
}