obfuz/Editor/ObfusPass/CleanUp/CleanUpInstructionPass.cs

44 lines
1.1 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;
namespace Obfuz
{
public class CleanUpInstructionPass : ObfuscationPassBase
{
2025-05-04 19:24:14 +08:00
public override void Start(ObfuscationPassContext ctx)
2025-05-03 20:42:08 +08:00
{
}
2025-05-04 19:24:14 +08:00
public override void Stop(ObfuscationPassContext ctx)
2025-05-03 20:42:08 +08:00
{
}
2025-05-04 19:24:14 +08:00
public override void Process(ObfuscationPassContext ctx)
2025-04-21 21:02:47 +08:00
{
2025-05-03 23:23:16 +08:00
foreach (ModuleDef mod in ctx.toObfuscatedModules)
{
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
}
}
}