2025-04-22 08:58:00 +08:00
|
|
|
|
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;
|
|
|
|
|
|
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-04-22 08:58:00 +08:00
|
|
|
|
{
|
2025-05-03 23:23:16 +08:00
|
|
|
|
foreach (TypeDef type in mod.GetTypes())
|
2025-04-22 08:58:00 +08:00
|
|
|
|
{
|
|
|
|
|
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-22 08:58:00 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-21 21:02:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|