From c7e3950c98f5e2ff71ada589a023c57fbd3124f5 Mon Sep 17 00:00:00 2001 From: js6pak Date: Sun, 7 Feb 2021 14:08:09 +0100 Subject: [PATCH] Deobfuscate custom attributes on all members --- Reactor.Greenhouse/Generation/TypeContext.cs | 1 - Reactor.OxygenFilter.MSBuild/Deobfuscate.cs | 2 ++ Reactor.OxygenFilter.MSBuild/GenerateReferences.cs | 1 + Reactor.OxygenFilter.MSBuild/LoadMappings.cs | 4 ++++ ...ctor.OxygenFilter.MSBuild.TargetFramework.props | 14 +++++++++++++- .../Reactor.OxygenFilter.MSBuild.csproj | 2 +- Reactor.OxygenFilter.MSBuild/Reobfuscate.cs | 13 ++++++++++++- 7 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Reactor.Greenhouse/Generation/TypeContext.cs b/Reactor.Greenhouse/Generation/TypeContext.cs index be750ad..eb8b1a9 100644 --- a/Reactor.Greenhouse/Generation/TypeContext.cs +++ b/Reactor.Greenhouse/Generation/TypeContext.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Text.RegularExpressions; using Mono.Cecil; diff --git a/Reactor.OxygenFilter.MSBuild/Deobfuscate.cs b/Reactor.OxygenFilter.MSBuild/Deobfuscate.cs index cdc93bc..e5cab7b 100644 --- a/Reactor.OxygenFilter.MSBuild/Deobfuscate.cs +++ b/Reactor.OxygenFilter.MSBuild/Deobfuscate.cs @@ -54,6 +54,8 @@ namespace Reactor.OxygenFilter.MSBuild continue; } + Log.LogMessage("Deobfuscating " + input); + using var stream = File.Open(input, FileMode.Open, FileAccess.Read, FileShare.Read); using var moduleDefinition = ModuleDefinition.ReadModule(stream, new ReaderParameters { AssemblyResolver = resolver }); diff --git a/Reactor.OxygenFilter.MSBuild/GenerateReferences.cs b/Reactor.OxygenFilter.MSBuild/GenerateReferences.cs index d23f2f2..b23ae98 100644 --- a/Reactor.OxygenFilter.MSBuild/GenerateReferences.cs +++ b/Reactor.OxygenFilter.MSBuild/GenerateReferences.cs @@ -41,6 +41,7 @@ namespace Reactor.OxygenFilter.MSBuild if (skip) { + Log.LogMessage("Skipping reference generation"); return true; } diff --git a/Reactor.OxygenFilter.MSBuild/LoadMappings.cs b/Reactor.OxygenFilter.MSBuild/LoadMappings.cs index f13d47f..6ffb798 100644 --- a/Reactor.OxygenFilter.MSBuild/LoadMappings.cs +++ b/Reactor.OxygenFilter.MSBuild/LoadMappings.cs @@ -20,6 +20,7 @@ namespace Reactor.OxygenFilter.MSBuild if (File.Exists(Mappings)) { + Log.LogMessage("Loading mappings from " + Mappings); Context.MappingsJson = File.ReadAllText(Mappings); return true; } @@ -34,10 +35,13 @@ namespace Reactor.OxygenFilter.MSBuild if (File.Exists(file)) { + Log.LogMessage("Loading mappings from " + file); Context.MappingsJson = File.ReadAllText(file); return true; } + Log.LogMessage("Downloading mappings from " + Mappings); + var httpClient = new HttpClient(); var json = httpClient.GetStringAsync($"https://github.com/{repo}/releases/download/{version}/{GameVersion}.json").GetAwaiter().GetResult(); diff --git a/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.TargetFramework.props b/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.TargetFramework.props index f5e6a0d..ec360fa 100644 --- a/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.TargetFramework.props +++ b/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.TargetFramework.props @@ -1,4 +1,4 @@ - + true false @@ -7,11 +7,23 @@ $(MSBuildThisFileDirectory)..\lib\$(TaskFolder)\Reactor.OxygenFilter.MSBuild.dll + + Steam + + + + + + + + diff --git a/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.csproj b/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.csproj index 89c7561..c9c9705 100644 --- a/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.csproj +++ b/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.csproj @@ -4,7 +4,7 @@ latest true - 0.2.4 + 0.2.5 git https://github.com/NuclearPowered/Reactor.OxygenFilter LGPL-3.0-or-later diff --git a/Reactor.OxygenFilter.MSBuild/Reobfuscate.cs b/Reactor.OxygenFilter.MSBuild/Reobfuscate.cs index deb672b..cb09524 100644 --- a/Reactor.OxygenFilter.MSBuild/Reobfuscate.cs +++ b/Reactor.OxygenFilter.MSBuild/Reobfuscate.cs @@ -94,7 +94,18 @@ namespace Reactor.OxygenFilter.MSBuild } } + var customAttributeProviders = new List(); + foreach (var type in moduleDefinition.GetAllTypes()) + { + customAttributeProviders.Add(type); + customAttributeProviders.AddRange(type.Events); + customAttributeProviders.AddRange(type.Fields); + customAttributeProviders.AddRange(type.Methods); + customAttributeProviders.AddRange(type.Properties); + } + + foreach (var customAttributeProvider in customAttributeProviders) { void ReobfuscateType(TypeReference t) { @@ -111,7 +122,7 @@ namespace Reactor.OxygenFilter.MSBuild } } - foreach (var customAttribute in type.CustomAttributes) + foreach (var customAttribute in customAttributeProvider.CustomAttributes) { TypeReference lastType = null;