diff --git a/BSIPA.sln b/BSIPA.sln
index b8a9a7b4..69ab853f 100644
--- a/BSIPA.sln
+++ b/BSIPA.sln
@@ -20,6 +20,9 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxy", "Doorstop\Proxy\Proxy.vcxproj", "{88609E16-731F-46C9-8139-6B1A7A83240D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{C79C2C3A-A7FC-40D6-A5CC-9752A661AFA9}"
+ ProjectSection(SolutionItems) = preProject
+ Refs\refs.txt = Refs\refs.txt
+ EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CollectDependencies", "CollectDependencies\CollectDependencies.csproj", "{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}"
EndProject
diff --git a/CollectDependencies/CollectDependencies.csproj b/CollectDependencies/CollectDependencies.csproj
index c15270ac..266be02a 100644
--- a/CollectDependencies/CollectDependencies.csproj
+++ b/CollectDependencies/CollectDependencies.csproj
@@ -35,15 +35,19 @@
..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.dll
+ True
..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Mdb.dll
+ True
..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Pdb.dll
+ True
..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Rocks.dll
+ True
@@ -57,10 +61,14 @@
+
+
+
+
\ No newline at end of file
diff --git a/CollectDependencies/Program.cs b/CollectDependencies/Program.cs
index 306d05a8..b38a9b7b 100644
--- a/CollectDependencies/Program.cs
+++ b/CollectDependencies/Program.cs
@@ -1,4 +1,5 @@
-using System;
+using Mono.Cecil;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -77,6 +78,32 @@ namespace CollectDependencies
files.Add(Pop());
}
+ foreach (var file in files)
+ {
+ var fparts = file.Split('?');
+ if (fparts.Length > 1 && fparts[1] == "virt")
+ {
+ var module = VirtualizedModule.Load(fparts[0]);
+ module.Virtualize(fparts[0] = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName(), Path.GetFileName(fparts[0])));
+ }
+ var modl = ModuleDefinition.ReadModule(fparts[0]);
+ foreach(var t in modl.Types)
+ {
+ foreach (var m in t.Methods)
+ {
+ if (m.Body != null)
+ {
+ m.Body.Instructions.Clear();
+ m.Body.InitLocals = false;
+ m.Body.Variables.Clear();
+ }
+ }
+ }
+ var outp = Path.Combine(fdir, Path.GetFileName(fparts[0]));
+ Console.WriteLine($"Copying {fparts[0]} to {outp}");
+ modl.Write(outp);
+ }
+
}
}
}
diff --git a/CollectDependencies/Virtualizer.cs b/CollectDependencies/Virtualizer.cs
new file mode 100644
index 00000000..324820d3
--- /dev/null
+++ b/CollectDependencies/Virtualizer.cs
@@ -0,0 +1,115 @@
+using Mono.Cecil;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace CollectDependencies
+{
+ class VirtualizedModule
+ {
+ private const string ENTRY_TYPE = "Display";
+
+ private FileInfo _File;
+ private ModuleDefinition _Module;
+
+ public static VirtualizedModule Load(string engineFile)
+ {
+ return new VirtualizedModule(engineFile);
+ }
+
+ private VirtualizedModule(string assemblyFile)
+ {
+ _File = new FileInfo(assemblyFile);
+
+ LoadModules();
+ }
+
+ private void LoadModules()
+ {
+ var resolver = new DefaultAssemblyResolver();
+ resolver.AddSearchDirectory(_File.DirectoryName);
+
+ var parameters = new ReaderParameters
+ {
+ AssemblyResolver = resolver,
+ };
+
+ _Module = ModuleDefinition.ReadModule(_File.FullName, parameters);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public void Virtualize(string targetfile)
+ {
+
+ foreach (var type in _Module.Types)
+ {
+ VirtualizeType(type);
+ }
+
+ _Module.Write(targetfile);
+ }
+
+ private void VirtualizeType(TypeDefinition type)
+ {
+ if(type.IsSealed)
+ {
+ // Unseal
+ type.IsSealed = false;
+ }
+
+ if (type.IsInterface) return;
+ if (type.IsAbstract) return;
+
+ // These two don't seem to work.
+ if (type.Name == "SceneControl" || type.Name == "ConfigUI") return;
+
+ // Take care of sub types
+ foreach (var subType in type.NestedTypes)
+ {
+ VirtualizeType(subType);
+ }
+
+ foreach (var method in type.Methods)
+ {
+ if (method.IsManaged
+ && method.IsIL
+ && !method.IsStatic
+ && !method.IsVirtual
+ && !method.IsAbstract
+ && !method.IsAddOn
+ && !method.IsConstructor
+ && !method.IsSpecialName
+ && !method.IsGenericInstance
+ && !method.HasOverrides)
+ {
+ method.IsVirtual = true;
+ method.IsPublic = true;
+ method.IsPrivate = false;
+ method.IsNewSlot = true;
+ method.IsHideBySig = true;
+ }
+ }
+
+ foreach (var field in type.Fields)
+ {
+ if (field.IsPrivate) field.IsFamily = true;
+ }
+ }
+
+ public bool IsVirtualized
+ {
+ get
+ {
+ var awakeMethods = _Module.GetTypes().SelectMany(t => t.Methods.Where(m => m.Name == "Awake"));
+ if (awakeMethods.Count() == 0) return false;
+
+ return ((float)awakeMethods.Count(m => m.IsVirtual) / awakeMethods.Count()) > 0.5f;
+ }
+ }
+ }
+}
diff --git a/IPA.Injector/IPA.Injector.csproj b/IPA.Injector/IPA.Injector.csproj
index 108c1a41..bd2ebc6f 100644
--- a/IPA.Injector/IPA.Injector.csproj
+++ b/IPA.Injector/IPA.Injector.csproj
@@ -47,7 +47,7 @@
False
- ..\..\..\..\..\..\GameLibrary\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll
+ ..\Refs\UnityEngine.CoreModule.dll
False
diff --git a/IPA.Loader/IPA.Loader.csproj b/IPA.Loader/IPA.Loader.csproj
index 758cb3ce..21041f94 100644
--- a/IPA.Loader/IPA.Loader.csproj
+++ b/IPA.Loader/IPA.Loader.csproj
@@ -47,11 +47,11 @@
- ..\..\..\..\..\..\GameLibrary\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll
+ ..\Refs\UnityEngine.CoreModule.dll
False
- ..\..\..\..\..\..\GameLibrary\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UnityWebRequestModule.dll
+ ..\Refs\UnityEngine.UnityWebRequestModule.dll
False
diff --git a/IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache b/IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache
index ac134d2c..7a5f217b 100644
--- a/IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache
+++ b/IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-de1a0105accb49be9027a1a26ea711a5ac5f69fd
+1d38dd5b9139545c6bc300c735ca121563a74d20
diff --git a/Refs/UnityEngine.CoreModule.dll b/Refs/UnityEngine.CoreModule.dll
new file mode 100644
index 00000000..06b84914
Binary files /dev/null and b/Refs/UnityEngine.CoreModule.dll differ
diff --git a/Refs/UnityEngine.UnityWebRequestModule.dll b/Refs/UnityEngine.UnityWebRequestModule.dll
new file mode 100644
index 00000000..9a23a412
Binary files /dev/null and b/Refs/UnityEngine.UnityWebRequestModule.dll differ