Reobfuscate type arrays in attributes

This commit is contained in:
js6pak committed 2021-01-15 00:41:36 +01:00
1 parent 404b07697b
commit 79df790aec
2 files changed
+28 -16

No files matched your search

@@ -4,7 +4,7 @@
<LangVersion>latest</LangVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<Version>0.2.1</Version>
<Version>0.2.2</Version>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/NuclearPowered/Reactor.OxygenFilter</RepositoryUrl>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
+27 -15
View File
@@ -99,29 +99,41 @@ namespace Reactor.OxygenFilter.MSBuild
foreach (var type in moduleDefinition.GetAllTypes())
{
void ReobfuscateType(TypeReference t)
{
while (t != null)
{
var obfuscated = GetObfuscated(t.Resolve());
if (obfuscated != null)
{
toObfuscate[t] = obfuscated;
}
t = t.DeclaringType;
}
}
foreach (var customAttribute in type.CustomAttributes)
{
TypeReference lastType = null;
foreach (var argument in customAttribute.ConstructorArguments.ToList())
{
if (argument.Type.FullName == "System.Type")
if (argument.Type.FullName == "System.Type[]")
{
foreach (var nestedArgument in (CustomAttributeArgument[]) argument.Value)
{
if (nestedArgument.Type.FullName == "System.Type")
{
ReobfuscateType((TypeReference) nestedArgument.Value);
}
}
}
else if (argument.Type.FullName == "System.Type")
{
lastType = (TypeReference) argument.Value;
var t = lastType;
while (t != null)
{
var obfuscated = GetObfuscated(t.Resolve());
if (obfuscated != null)
{
toObfuscate[t] = obfuscated;
}
t = t.DeclaringType;
}
ReobfuscateType(lastType);
}
else
{