CallObfuscationSettings新增设置obfuscateCallToMethodInMscorlib
parent
905da05afc
commit
f3bde846ea
|
@ -93,10 +93,10 @@ namespace Obfuz.ObfusPasses.CallObfus
|
||||||
|
|
||||||
private bool ComputeIsInWhiteList(IMethod calledMethod)
|
private bool ComputeIsInWhiteList(IMethod calledMethod)
|
||||||
{
|
{
|
||||||
|
MethodDef calledMethodDef = calledMethod.ResolveMethodDef();
|
||||||
// mono has more strict access control, calls non-public method will raise exception.
|
// mono has more strict access control, calls non-public method will raise exception.
|
||||||
if (PlatformUtil.IsMonoBackend())
|
if (PlatformUtil.IsMonoBackend())
|
||||||
{
|
{
|
||||||
MethodDef calledMethodDef = calledMethod.ResolveMethodDef();
|
|
||||||
if (calledMethodDef != null && (!calledMethodDef.IsPublic || !IsTypeSelfAndParentPublic(calledMethodDef.DeclaringType)))
|
if (calledMethodDef != null && (!calledMethodDef.IsPublic || !IsTypeSelfAndParentPublic(calledMethodDef.DeclaringType)))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -125,6 +125,12 @@ namespace Obfuz.ObfusPasses.CallObfus
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeDef typeDef = declaringType.ResolveTypeDef();
|
TypeDef typeDef = declaringType.ResolveTypeDef();
|
||||||
|
|
||||||
|
if (!_settings.obfuscateCallToMethodInMscorlib && typeDef.Module.IsCoreLibraryModule == true)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeDef.IsDelegate || typeDef.IsEnum)
|
if (typeDef.IsDelegate || typeDef.IsEnum)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace Obfuz.Settings
|
||||||
public List<string> ruleFiles;
|
public List<string> ruleFiles;
|
||||||
public int obfuscationLevel;
|
public int obfuscationLevel;
|
||||||
public int maxProxyMethodCountPerDispatchMethod;
|
public int maxProxyMethodCountPerDispatchMethod;
|
||||||
|
public bool obfuscateCallToMethodInMscorlib;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
@ -22,6 +23,9 @@ namespace Obfuz.Settings
|
||||||
[Tooltip("The maximum number of proxy methods that can be generated per dispatch method. This helps to limit the complexity of the generated code and improve performance.")]
|
[Tooltip("The maximum number of proxy methods that can be generated per dispatch method. This helps to limit the complexity of the generated code and improve performance.")]
|
||||||
public int maxProxyMethodCountPerDispatchMethod = 100;
|
public int maxProxyMethodCountPerDispatchMethod = 100;
|
||||||
|
|
||||||
|
[Tooltip("Whether to obfuscate calls to methods in mscorlib. This can help to protect against reverse engineering, but may cause compatibility issues with some libraries.")]
|
||||||
|
public bool obfuscateCallToMethodInMscorlib;
|
||||||
|
|
||||||
[Tooltip("rule config xml files")]
|
[Tooltip("rule config xml files")]
|
||||||
public string[] ruleFiles;
|
public string[] ruleFiles;
|
||||||
|
|
||||||
|
@ -32,6 +36,7 @@ namespace Obfuz.Settings
|
||||||
ruleFiles = ruleFiles?.ToList() ?? new List<string>(),
|
ruleFiles = ruleFiles?.ToList() ?? new List<string>(),
|
||||||
obfuscationLevel = obfuscationLevel,
|
obfuscationLevel = obfuscationLevel,
|
||||||
maxProxyMethodCountPerDispatchMethod = maxProxyMethodCountPerDispatchMethod,
|
maxProxyMethodCountPerDispatchMethod = maxProxyMethodCountPerDispatchMethod,
|
||||||
|
obfuscateCallToMethodInMscorlib = obfuscateCallToMethodInMscorlib,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue