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;
|
|
|
|
|
|
|
|
|
|
namespace Obfuz.DynamicProxy
|
|
|
|
|
{
|
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
|
2025-04-29 10:18:42 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
2025-04-29 10:18:42 +08:00
|
|
|
|
// special handle
|
|
|
|
|
// don't proxy call for List<T>.Enumerator GetEnumerator()
|
|
|
|
|
if (method.Name == "GetEnumerator")
|
2025-04-28 17:57:10 +08:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2025-04-24 11:58:22 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|