用 Confuser Studio 混淆 DLL 后,代码有哪些变化?
在 dotPeek 中对照同一个 DLL 混淆前后的代码,看看折扣公式和提示文本发生了哪些变化。
在 dotPeek 中查看混淆前后的代码
示例文件 Demo.PriceApp.dll 中有一个计算订单金额的方法。请对照两张截图,查看原先显示计算公式和折扣提示的位置。


查看 C# 示例代码
C#
namespace ShopDemo
{
internal static class PriceCalculator
{
internal static int CalculateTotal(int unitPrice, int quantity, bool isMember)
{
int subtotal = unitPrice * quantity;
int discount = isMember ? subtotal / 5 : subtotal / 20;
int shipping = subtotal >= 50000 ? 0 : 3000;
return subtotal - discount + shipping;
}
internal static string DescribeDiscount(bool isMember)
{
string discountMessage = isMember
? "Member discount: 20%"
: "Standard discount: 5%";
return discountMessage;
}
}
}图片来源:Confuser Studio
下一步
用 Confuser Studio 的方法虚拟化保护核心计算
在公开示例中,dotPeek 在原先显示折扣公式的位置显示了虚拟机调用。可以先选择自己程序中的一个核心方法进行虚拟化,用相同输入核对计算结果,再测量重复调用时的耗时,据此决定哪些方法需要保护。
了解 Confuser Studio建议的检查顺序
- 准备尚未混淆的 Release DLL 或 EXE。
- 将选定的保护选项保存到 Studio 项目。
- 在 dotPeek 中检查核心方法和字符串。
- 在目标环境中测试功能、速度和故障诊断。