obfuz/Editor/ObfusPasses/CallObfus/ConfigProxyCallPolicy.cs

48 lines
1.4 KiB
C#
Raw Normal View History

2025-04-24 11:58:22 +08:00
using dnlib.DotNet;
using System;
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.CallObfus
2025-04-24 11:58:22 +08:00
{
2025-04-29 10:04:44 +08:00
public class ConfigProxyCallPolicy : ProxyCallPolicyBase
2025-04-24 11:58:22 +08:00
{
public override bool NeedDynamicProxyCallInMethod(MethodDef method)
{
return true;
}
public override bool NeedDynamicProxyCalledMethod(IMethod method, bool callVir)
{
2025-04-28 11:37:48 +08:00
ITypeDefOrRef declaringType = method.DeclaringType;
TypeDef typeDef = declaringType.ResolveTypeDef();
// doesn't proxy call if the method is a delegate
if (typeDef != null)
{
// need configurable
if (typeDef.Module.IsCoreLibraryModule == true)
{
return false;
}
if (typeDef.IsDelegate)
return false;
}
// doesn't proxy call if the method is a constructor
if (method.Name == ".ctor")
2025-04-28 11:37:48 +08:00
{
return false;
}
// special handle
// don't proxy call for List<T>.Enumerator GetEnumerator()
if (method.Name == "GetEnumerator")
{
return false;
}
2025-04-24 11:58:22 +08:00
return true;
}
}
}