Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

Commit

Permalink
2021.3.31.3
Browse files Browse the repository at this point in the history
  • Loading branch information
js6pak committed Apr 3, 2021
1 parent f450cae commit c938770
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 39 deletions.
37 changes: 25 additions & 12 deletions Reactor.Greenhouse/Generation/TypeContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Mono.Cecil;
using Mono.Cecil.Rocks;
using Reactor.OxygenFilter;
Expand Down Expand Up @@ -33,8 +32,6 @@ public override string ToString()
return CleanFullName;
}

private static readonly Regex CompilerGeneratedRegex = new Regex(@"^<([\w\d]+)>.__\d+$", RegexOptions.Compiled);

public void UpdateNested()
{
if (ObfuscatedType.NestedTypes.Count == CleanType.NestedTypes.Count)
Expand All @@ -49,16 +46,32 @@ public void UpdateNested()
}
}

private static string Clean(string name)
{
return name.Replace("<", "_").Replace(">", "_");
}

public MappedType ToMappedType()
{
var match = CompilerGeneratedRegex.Match(CleanType.Name);
var mappedType = new MappedType(ObfuscatedType.FullName, match.Success ? (match.Groups[1].Value + "__d") : CleanType.Name.Replace("<>", ""));
var mappedType = new MappedType(ObfuscatedType.FullName, Clean(CleanType.Name));

if (!string.IsNullOrEmpty(CleanType.Namespace))
{
mappedType.Mapped = CleanType.Namespace + "." + mappedType.Mapped;
}

if (ObfuscatedType.FullName == CleanFullName)
{
mappedType.Mapped = null;
}

if (ObfuscatedType.Fields.Count == CleanType.Fields.Count)
{
var sortedCleanFields = CleanType.Fields.OrderBy(x => x.HasConstant && x.Constant is string).ToArray();

for (var i = 0; i < CleanType.Fields.Count; i++)
{
var cleanField = CleanType.Fields[i];
var cleanField = sortedCleanFields[i];
var obfuscatedField = ObfuscatedType.Fields[i];

if (ObfuscatedType.DeclaringType != null)
Expand All @@ -76,11 +89,11 @@ public MappedType ToMappedType()
continue;
}

var fieldMatch = CompilerGeneratedRegex.Match(obfuscatedField.Name);
var clean = Clean(obfuscatedField.Name);

if (fieldMatch.Success)
if (clean != obfuscatedField.Name)
{
mappedType.Fields.Add(new MappedMember(obfuscatedField.Name, fieldMatch.Groups[1].Value));
mappedType.Fields.Add(new MappedMember(obfuscatedField.Name, clean));
continue;
}
}
Expand Down Expand Up @@ -161,11 +174,11 @@ public MappedType ToMappedType()
{
foreach (var obfuscatedMethod in ObfuscatedType.Methods)
{
var methodMatch = CompilerGeneratedRegex.Match(obfuscatedMethod.Name);
var clean = Clean(obfuscatedMethod.Name);

if (methodMatch.Success)
if (clean != obfuscatedMethod.Name)
{
mappedType.Methods.Add(new MappedMethod(obfuscatedMethod, methodMatch.Groups[1].Value));
mappedType.Methods.Add(new MappedMethod(obfuscatedMethod, clean));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Reactor.Greenhouse/Mappings
2 changes: 1 addition & 1 deletion Reactor.Greenhouse/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static async Task Main(string[] args)
ContractResolver = ShouldSerializeContractResolver.Instance,
};

var oldFile = Path.Combine("work", "Assembly-CSharp-2020.12.9s.dll");
var oldFile = Path.Combine("work", "Assembly-CSharp-2021.3.31.dll");
Console.WriteLine($"Generating mappings from {oldFile}");
using var cleanModule = ModuleDefinition.ReadModule(File.OpenRead(oldFile));

Expand Down
2 changes: 1 addition & 1 deletion Reactor.Greenhouse/Reactor.Greenhouse.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Mono.Cecil" Version="0.11.3" />
<ProjectReference Include="..\Reactor.OxygenFilter\Reactor.OxygenFilter.csproj" />
<PackageReference Include="js6pak.Il2CppDumper" Version="6.4.20" />
<PackageReference Include="Il2CppDumper" Version="6.5.3" />
</ItemGroup>
</Project>
17 changes: 8 additions & 9 deletions Reactor.Greenhouse/Setup/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ public void CheckVersion()
return; // TODO
}

var version = GameVersionParser.Parse(System.IO.Path.Combine(Path, "Among Us_Data", "globalgamemanagers"));
// TODO version patch is hardcoded to version shower, wtf!?
// var version = GameVersionParser.Parse(System.IO.Path.Combine(Path, "Among Us_Data", "globalgamemanagers"));

if (!Provider.Version.Equals(new GameVersion(version), true))
{
throw new Exception("Downloaded game has invalid version");
}
// if (!Provider.Version.Equals(new GameVersion(version), true))
// {
// throw new Exception("Downloaded game has invalid version");
// }
}

public void Dump()
Expand All @@ -71,10 +72,8 @@ public void Dump()
Path,
new Config
{
RequireAnyKey = false,
GenerateScript = false,
DumpProperty = true,
DumpAttribute = true
GenerateStruct = false,
GenerateDummyDll = true
},
Console.WriteLine
))
Expand Down
20 changes: 11 additions & 9 deletions Reactor.Greenhouse/Setup/GameVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Reactor.Greenhouse.Setup
{
public class GameVersion
{
private static readonly Regex _regex = new Regex(@"^(?<major>[0-9]+)\.(?<minor>[0-9]+)\.(?<patch>[0-9]+)(?<platform>[sia])?", RegexOptions.Compiled);
private static readonly Regex _regex = new Regex(@"^(?<year>[0-9]+)\.(?<month>[0-9]+)\.(?<day>[0-9]+)(\.(?<patch>[0-9]+))?(?<platform>[sia])?", RegexOptions.Compiled);

public static GamePlatform GamePlatformFromShorthand(string shorthand)
{
Expand All @@ -18,26 +18,28 @@ public static GamePlatform GamePlatformFromShorthand(string shorthand)
};
}

public int Major { get; }
public int Minor { get; }
public int Year { get; }
public int Month { get; }
public int Day { get; }
public int Patch { get; }
public GamePlatform? Platform { get; }

public GameVersion(string version)
{
var match = _regex.Match(version);

Major = int.Parse(match.Groups["major"].Value);
Minor = int.Parse(match.Groups["minor"].Value);
Patch = int.Parse(match.Groups["patch"].Value);
Year = int.Parse(match.Groups["year"].Value);
Month = int.Parse(match.Groups["month"].Value);
Day = int.Parse(match.Groups["day"].Value);
Patch = match.Groups["patch"].Success ? int.Parse(match.Groups["patch"].Value) : 0;

var platform = match.Groups["platform"];
Platform = platform.Success && !string.IsNullOrEmpty(platform.Value) ? GamePlatformFromShorthand(platform.Value) : null;
}

public override string ToString()
{
return $"{Major}.{Minor}.{Patch}" + Platform switch
return $"{Year}.{Month}.{Day}{(Patch == 0 ? string.Empty : $".{Patch}")}" + Platform switch
{
GamePlatform.Steam => "s",
GamePlatform.Itch => "i",
Expand All @@ -52,7 +54,7 @@ public bool Equals(GameVersion other, bool ignorePlatform = false)
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return Major == other.Major && Minor == other.Minor && Patch == other.Patch && (ignorePlatform || Platform == other.Platform);
return Year == other.Year && Month == other.Month && Day == other.Day && Patch == other.Patch && (ignorePlatform || Platform == other.Platform);
}

public override bool Equals(object obj)
Expand All @@ -62,7 +64,7 @@ public override bool Equals(object obj)

public override int GetHashCode()
{
return HashCode.Combine(Major, Minor, Patch, Platform);
return HashCode.Combine(Year, Month, Day, Patch, Platform);
}
}

Expand Down
4 changes: 3 additions & 1 deletion Reactor.Greenhouse/Setup/Provider/SteamProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public class SteamProvider : BaseProvider
{
[new GameVersion("2019.10.10s")] = 3162069540887216240,
[new GameVersion("2020.12.9s")] = 3306639722673334636,
[new GameVersion("2021.3.5s")] = 5200448423569257054
[new GameVersion("2021.3.5s")] = 5200448423569257054,
[new GameVersion("2021.3.31s")] = 9177722260012976528,
[new GameVersion("2021.3.31.3s")] = 3941730972865408291
};

public ulong Manifest { get; }
Expand Down
2 changes: 1 addition & 1 deletion Reactor.OxygenFilter.MSBuild/GenerateReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override bool Execute()

var dumperConfig = new Il2CppDumper.Config
{
GenerateScript = false,
GenerateStruct = false,
GenerateDummyDll = true
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<LangVersion>latest</LangVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

<Version>0.2.10</Version>
<Version>0.3.0</Version>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/NuclearPowered/Reactor.OxygenFilter</RepositoryUrl>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
Expand All @@ -21,8 +21,8 @@
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.8.0" />

<ProjectReference Include="..\Reactor.OxygenFilter\Reactor.OxygenFilter.csproj" />
<PackageReference Include="js6pak.Il2CppDumper" Version="6.4.20" />
<PackageReference Include="NuclearPowered.AssemblyUnhollower" Version="0.4.13" />
<PackageReference Include="Il2CppDumper" Version="6.5.4" />
<PackageReference Include="NuclearPowered.AssemblyUnhollower" Version="0.4.15" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
Expand Down
11 changes: 10 additions & 1 deletion Reactor.OxygenFilter.MSBuild/Reobfuscate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,16 @@ void ReobfuscateType(TypeReference t)

foreach (var pair in toObfuscate)
{
pair.Key.Name = pair.Value;
if (pair.Key is TypeReference typeReference)
{
var lastIndexOf = pair.Value.LastIndexOf('.');
typeReference.Namespace = lastIndexOf == -1 ? null : pair.Value.Substring(0, lastIndexOf);
typeReference.Name = pair.Value.Substring(lastIndexOf + 1);
}
else
{
pair.Key.Name = pair.Value;
}
}

foreach (var typeReference in moduleDefinition.GetTypeReferences())
Expand Down
6 changes: 6 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="BepInExLibs" value="https://pkgs.dev.azure.com/bepinex/BepInEx/_packaging/BepInExLibs/nuget/v3/index.json" />
</packageSources>
</configuration>

0 comments on commit c938770

Please sign in to comment.