diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d4c1b67f..97f342326 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,15 +1,15 @@ name: Build MelonLoader -run-name: 0.7.0${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }} | ${{ github.event_name != 'workflow_dispatch' && (github.event.head_commit.message || format('`[PR]` {0}', github.event.pull_request.title)) || 'Manual Build' }} +run-name: 1.0.0${{ github.event_name != 'workflow_dispatch' && format('-ci.{0}', github.run_number) || '' }} | ${{ github.event_name != 'workflow_dispatch' && (github.event.head_commit.message || format('`[PR]` {0}', github.event.pull_request.title)) || 'Manual Build' }} env: - DEVVERSION: "0.7.0" + DEVVERSION: "1.0.0" on: push: - branches: [ master, alpha-development, v0.6.0-rewrite ] + branches: [ master, alpha-development, universality ] pull_request: - branches: [ master, alpha-development, v0.6.0-rewrite ] + branches: [ master, alpha-development, universality ] workflow_dispatch: jobs: diff --git a/CHANGELOG.md b/CHANGELOG.md index 39a24557a..374c2ebd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ | Versions: | | - | +| [v0.7.0](#v070) | | [v0.6.6](#v066) | | [v0.6.5](#v065) | | [v0.6.4](#v064) | @@ -38,6 +39,35 @@ --- +### v0.7.0 + +1. Updated Unity Dependencies Source to use the [New Automated Repository](https://github.com/LavaGang/MelonLoader.UnityDependencies) (Credits to [slxdy](https://github.com/slxdy) :D) +2. Fixed an issue with MelonProxy not using Executable Path for Base Directory +3. Reworked Bootstrap and Proxy to use NAOT Compilation (Credits to [slxdy](https://github.com/slxdy) :D) +4. Fixed an issue with the Il2CppAssemblyGenerator ignoring the --melonloader.agfregenerate launch option +5. Fixed an issue with Loading Plugins from MelonFolders that exist in the Mods folder too Early +6. Fixed an issue with Il2CppAssemblyGenerator using Incorrect Module Pathing to Load +7. Fixed an issue with Extended Folder Scanning not running without strict definition of Folder Names +8. Updated Cpp2IL to 2022.1.0-pre-release.19 +9. Reimplemented Cpp2IL StrippedCodeRegSupport Module +10. Fixed an issue with .NET Bundle Extraction attempting to extract to a folder of the same name as the executable +11. Fixed an issue with Compatibility Layers not loading from Base Directory +12. Updated Il2CppInterop to 1.4.6-ci.585 +13. Updated System.Configuration.ConfigurationManager, System.Drawing.Common, and System.Security.Permissions to 9.0.0 +14. Revert de-duplication to fix decoding by type hint broken in TinyJSON (Credits to [No3371](https://github.com/No3371) :D) +15. Implemented Loader Config system (Credits to [slxdy](https://github.com/slxdy) :D) +16. Changed Console Encoding to UTF8 (Credits to [slxdy](https://github.com/slxdy) :D) +17. Fixed an issue with AsmResolver not being able to read files correctly (Credits to [Atmudia](https://github.com/Atmudia) :D) +18. Made all Obsolete Members into Errors (Credits to [slxdy](https://github.com/slxdy) :D) +19. Moved SharpZipLib to BackwardsCompatibility (Credits to [slxdy](https://github.com/slxdy) :D) +20. Moved TinyJSON to BackwardsCompatibility (Credits to [slxdy](https://github.com/slxdy) :D) +21. Improved Mono Library Initialization +22. Reworked Bootstrap Proxy Exports to allow Loading Original from Local Copy +23. Implemented Pre-Scan of Melon Folders to fix Load Order +24. Updated missing deps for NetStandardPatches (Credits to [slxdy](https://github.com/slxdy) :D) + +--- + ### v0.6.6 1. Updated Il2CppInterop to 1.4.6-ci.579 diff --git a/Dependencies/CompatibilityLayers/Demeo/Demeo.csproj b/Dependencies/CompatibilityLayers/Demeo/Demeo.csproj deleted file mode 100644 index d00ce207b..000000000 --- a/Dependencies/CompatibilityLayers/Demeo/Demeo.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - MelonLoader.CompatibilityLayers - net472 - true - $(MLOutDir)/MelonLoader/Dependencies/CompatibilityLayers - true - embedded - - - - - - \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Demeo/Demeo_LobbyRequirement.cs b/Dependencies/CompatibilityLayers/Demeo/Demeo_LobbyRequirement.cs deleted file mode 100644 index ccdc98c80..000000000 --- a/Dependencies/CompatibilityLayers/Demeo/Demeo_LobbyRequirement.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace MelonLoader -{ - [AttributeUsage(AttributeTargets.Assembly)] - public class Demeo_LobbyRequirement : Attribute - { - public Demeo_LobbyRequirement() { } - } -} diff --git a/Dependencies/CompatibilityLayers/Demeo/Module.cs b/Dependencies/CompatibilityLayers/Demeo/Module.cs deleted file mode 100644 index 8bd856fde..000000000 --- a/Dependencies/CompatibilityLayers/Demeo/Module.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using MelonLoader.Modules; - -[assembly: MelonLoader.PatchShield] - -namespace MelonLoader.CompatibilityLayers -{ - internal class Demeo_Module : MelonModule - { - private Dictionary ModInformation = new Dictionary(); - private IList ModInfoList; - - private Type modInfoType; - private FieldInfo name_field; - private FieldInfo version_field; - private FieldInfo author_field; - private FieldInfo description_field; - private FieldInfo isNetworkCompatible_field; - - public override void OnInitialize() - { - MelonEvents.OnApplicationStart.Subscribe(OnPreAppStart, int.MaxValue); - MelonBase.OnMelonRegistered.Subscribe(ParseMelon, int.MaxValue); - MelonBase.OnMelonUnregistered.Subscribe(OnUnregister, int.MaxValue); - } - - private void OnPreAppStart() - { - try - { - Assembly assembly = Assembly.Load("Assembly-CSharp"); - Type moddingApi = assembly.GetType("Boardgame.Modding.ModdingAPI"); - - modInfoType = moddingApi.GetNestedType("ModInformation"); - name_field = modInfoType.GetField("name", BindingFlags.Public | BindingFlags.Instance); - version_field = modInfoType.GetField("version", BindingFlags.Public | BindingFlags.Instance); - author_field = modInfoType.GetField("author", BindingFlags.Public | BindingFlags.Instance); - description_field = modInfoType.GetField("description", BindingFlags.Public | BindingFlags.Instance); - isNetworkCompatible_field = modInfoType.GetField("isNetworkCompatible", BindingFlags.Public | BindingFlags.Instance); - - FieldInfo externalModsField = moddingApi.GetField("ExternallyInstalledMods", BindingFlags.Public | BindingFlags.Static); - if (externalModsField.GetValue(null) == null) - { - var listType = typeof(List<>); - var constructedListType = listType.MakeGenericType(modInfoType); - ModInfoList = (IList)Activator.CreateInstance(constructedListType); - externalModsField.SetValue(null, ModInfoList); - } - - foreach (var m in MelonPlugin.RegisteredMelons) - { - try - { - ParseMelon(m); - } - catch (Exception ex) - { - MelonLogger.Error($"Demeo Integration has thrown an exception: {ex}"); - } - } - - foreach (var m in MelonMod.RegisteredMelons) - { - try - { - ParseMelon(m); - } - catch (Exception ex) - { - MelonLogger.Error($"Demeo Integration has thrown an exception: {ex}"); - } - } - } - catch (Exception ex) - { - MelonLogger.Error($"Demeo Integration has thrown an exception: {ex}"); - } - } - - private void OnUnregister(MelonBase melon) - { - if (melon == null) - return; - - if (!ModInformation.ContainsKey(melon)) - return; - - try - { - object info = ModInformation[melon]; - ModInformation.Remove(melon); - ModInfoList.Remove(info); - } - catch (Exception ex) - { - MelonLogger.Error($"Demeo Integration has thrown an exception: {ex}"); - } - } - - private void ParseMelon(T melon) where T : MelonBase - { - - if (melon == null) - return; - - if (ModInformation.ContainsKey(melon)) - return; - - try - { - object info = Activator.CreateInstance(modInfoType); - - name_field.SetValue(info, melon.Info.Name); - version_field.SetValue(info, melon.Info.Version); - author_field.SetValue(info, melon.Info.Author); - description_field.SetValue(info, melon.Info.DownloadLink); - isNetworkCompatible_field.SetValue(info, MelonUtils.PullAttributeFromAssembly(melon.MelonAssembly.Assembly) == null); - - ModInformation.Add(melon, info); - ModInfoList.Add(info); - } - catch (Exception ex) - { - MelonLogger.Error($"Demeo Integration has thrown an exception: {ex}"); - } - } - } -} \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/IPA/IPA.csproj b/Dependencies/CompatibilityLayers/IPA/IPA.csproj deleted file mode 100644 index 79f99e91c..000000000 --- a/Dependencies/CompatibilityLayers/IPA/IPA.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - MelonLoader.CompatibilityLayers - net35 - true - $(MLOutDir)/MelonLoader/Dependencies/CompatibilityLayers - true - embedded - - - - - \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/IPA/IPA/IEnhancedPlugin.cs b/Dependencies/CompatibilityLayers/IPA/IPA/IEnhancedPlugin.cs deleted file mode 100644 index 2bb73efc2..000000000 --- a/Dependencies/CompatibilityLayers/IPA/IPA/IEnhancedPlugin.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace IllusionPlugin -{ - public interface IEnhancedPlugin : IPlugin - { - string[] Filter { get; } - void OnLateUpdate(); - } -} diff --git a/Dependencies/CompatibilityLayers/IPA/IPA/IPlugin.cs b/Dependencies/CompatibilityLayers/IPA/IPA/IPlugin.cs deleted file mode 100644 index df0b97c48..000000000 --- a/Dependencies/CompatibilityLayers/IPA/IPA/IPlugin.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace IllusionPlugin -{ - public interface IPlugin - { - string Name { get; } - string Version { get; } - void OnApplicationStart(); - void OnApplicationQuit(); - void OnLevelWasLoaded(int level); - void OnLevelWasInitialized(int level); - void OnUpdate(); - void OnFixedUpdate(); - } -} diff --git a/Dependencies/CompatibilityLayers/IPA/IPA/ModPrefs.cs b/Dependencies/CompatibilityLayers/IPA/IPA/ModPrefs.cs deleted file mode 100644 index 0f79ba121..000000000 --- a/Dependencies/CompatibilityLayers/IPA/IPA/ModPrefs.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using MelonLoader; - -namespace IllusionPlugin -{ - public static class ModPrefs - { - public static string GetString(string section, string name, string defaultValue = "", bool autoSave = false) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - category = MelonPreferences.CreateCategory(section); - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - entry = category.CreateEntry(name, defaultValue); - return entry.Value; - } - - public static int GetInt(string section, string name, int defaultValue = 0, bool autoSave = false) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - category = MelonPreferences.CreateCategory(section); - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - entry = category.CreateEntry(name, defaultValue); - return entry.Value; - } - - public static float GetFloat(string section, string name, float defaultValue = 0f, bool autoSave = false) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - category = MelonPreferences.CreateCategory(section); - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - entry = category.CreateEntry(name, defaultValue); - return entry.Value; - } - - public static bool GetBool(string section, string name, bool defaultValue = false, bool autoSave = false) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - category = MelonPreferences.CreateCategory(section); - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - entry = category.CreateEntry(name, defaultValue); - return entry.Value; - } - - public static bool HasKey(string section, string name) => MelonPreferences.HasEntry(section, name); - - public static void SetFloat(string section, string name, float value) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - category = MelonPreferences.CreateCategory(section); - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - entry = category.CreateEntry(name, value); - entry.Value = value; - } - - public static void SetInt(string section, string name, int value) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - category = MelonPreferences.CreateCategory(section); - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - entry = category.CreateEntry(name, value); - entry.Value = value; - } - - public static void SetString(string section, string name, string value) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - category = MelonPreferences.CreateCategory(section); - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - entry = category.CreateEntry(name, value); - entry.Value = value; - } - - public static void SetBool(string section, string name, bool value) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - category = MelonPreferences.CreateCategory(section); - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - entry = category.CreateEntry(name, value); - entry.Value = value; - } - } -} \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/IPA/IPA/PluginManager.cs b/Dependencies/CompatibilityLayers/IPA/IPA/PluginManager.cs deleted file mode 100644 index ab0f3fc42..000000000 --- a/Dependencies/CompatibilityLayers/IPA/IPA/PluginManager.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using IllusionPlugin; -using MelonLoader.Utils; - -namespace IllusionInjector -{ - public static class PluginManager - { - internal static List _Plugins = new List(); - public static IEnumerable Plugins { get => _Plugins; } - public class AppInfo - { - public static string StartupPath { get => MelonEnvironment.GameRootDirectory; } - } - } -} \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/IPA/IPAPluginWrapper.cs b/Dependencies/CompatibilityLayers/IPA/IPAPluginWrapper.cs deleted file mode 100644 index b98612372..000000000 --- a/Dependencies/CompatibilityLayers/IPA/IPAPluginWrapper.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using IllusionPlugin; -using IllusionInjector; - -namespace MelonLoader.CompatibilityLayers -{ - internal class IPAPluginWrapper : MelonMod - { - internal IPlugin pluginInstance; - public override void OnInitializeMelon() => pluginInstance.OnApplicationStart(); - public override void OnDeinitializeMelon() => pluginInstance.OnApplicationQuit(); - public override void OnSceneWasLoaded(int buildIndex, string sceneName) => pluginInstance.OnLevelWasLoaded(buildIndex); - public override void OnSceneWasInitialized(int buildIndex, string sceneName) => pluginInstance.OnLevelWasInitialized(buildIndex); - public override void OnUpdate() => pluginInstance.OnUpdate(); - public override void OnFixedUpdate() => pluginInstance.OnFixedUpdate(); - public override void OnLateUpdate() { if (pluginInstance is IEnhancedPlugin plugin) plugin.OnLateUpdate(); } - } -} \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/IPA/Module.cs b/Dependencies/CompatibilityLayers/IPA/Module.cs deleted file mode 100644 index 87cb99a13..000000000 --- a/Dependencies/CompatibilityLayers/IPA/Module.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using IllusionPlugin; -using IllusionInjector; -using MelonLoader.Modules; -using MelonLoader.Resolver; - -[assembly: MelonLoader.PatchShield] - -namespace MelonLoader.CompatibilityLayers -{ - internal class IPA_Module : MelonModule - { - public override void OnInitialize() - { - // To-Do: - // Detect if IPA is already Installed - // Point AssemblyResolveInfo to already installed IPA Assembly - // Point GetResolverFromAssembly to Dummy MelonCompatibilityLayer.Resolver - - string[] assembly_list = - { - "IllusionPlugin", - "IllusionInjector", - }; - Assembly base_assembly = typeof(IPA_Module).Assembly; - foreach (string assemblyName in assembly_list) - MelonAssemblyResolver.GetAssemblyResolveInfo(assemblyName).Override = base_assembly; - - MelonAssembly.CustomMelonResolvers += Resolve; - } - - private ResolvedMelons Resolve(Assembly asm) - { - IEnumerable pluginTypes = asm.GetValidTypes(x => - { - Type[] interfaces = x.GetInterfaces(); - return (interfaces != null) && interfaces.Any() && interfaces.Contains(typeof(IPlugin)); // To-Do: Change to Type Reflection based on Setup - }); - if ((pluginTypes == null) || !pluginTypes.Any()) - return new ResolvedMelons(null, null); - - var melons = new List(); - var rotten = new List(); - foreach (var t in pluginTypes) - { - var mel = LoadPlugin(asm, t, out RottenMelon rm); - if (mel != null) - melons.Add(mel); - else - rotten.Add(rm); - } - return new ResolvedMelons(melons.ToArray(), rotten.ToArray()); - } - - private MelonBase LoadPlugin(Assembly asm, Type pluginType, out RottenMelon rottenMelon) - { - rottenMelon = null; - IPlugin pluginInstance; - try - { pluginInstance = Activator.CreateInstance(pluginType) as IPlugin; } - catch (Exception ex) - { - rottenMelon = new RottenMelon(pluginType, "Failed to create a new instance of the IPA Plugin.", ex); - return null; - } - - MelonProcessAttribute[] processAttrs = null; - if (pluginInstance is IEnhancedPlugin enPl) - processAttrs = enPl.Filter?.Select(x => new MelonProcessAttribute(x)).ToArray(); - - string pluginName = pluginInstance.Name; - if (string.IsNullOrEmpty(pluginName)) - pluginName = pluginType.FullName; - - string plugin_version = pluginInstance.Version; - if (string.IsNullOrEmpty(plugin_version)) - plugin_version = asm.GetName().Version.ToString(); - if (string.IsNullOrEmpty(plugin_version) || plugin_version.Equals("0.0.0.0")) - plugin_version = "1.0.0.0"; - - var melon = MelonBase.CreateWrapper(pluginName, null, plugin_version, processes: processAttrs); - - melon.pluginInstance = pluginInstance; - PluginManager._Plugins.Add(pluginInstance); - return melon; - } - } -} \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Module.cs b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Module.cs deleted file mode 100644 index 80c8d1ce0..000000000 --- a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Module.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using MelonLoader.Modules; -using ModHelper; -using MelonLoader.Resolver; - -[assembly: MelonLoader.PatchShield] - -namespace MelonLoader.CompatibilityLayers -{ - internal class Muse_Dash_Mono_Module : MelonModule - { - public override void OnInitialize() - { - // To-Do: - // Detect if MuseDashModLoader is already Installed - // Point AssemblyResolveInfo to already installed MuseDashModLoader Assembly - // Inject Custom Resolver - - string[] assembly_list = - { - "ModHelper", - "ModLoader", - }; - Assembly base_assembly = typeof(Muse_Dash_Mono_Module).Assembly; - foreach (string assemblyName in assembly_list) - MelonAssemblyResolver.GetAssemblyResolveInfo(assemblyName).Override = base_assembly; - - MelonAssembly.CustomMelonResolvers += Resolve; - } - - private ResolvedMelons Resolve(Assembly asm) - { - IEnumerable modTypes = asm.GetValidTypes(x => - { - Type[] interfaces = x.GetInterfaces(); - return (interfaces != null) && interfaces.Any() && interfaces.Contains(typeof(IMod)); // To-Do: Change to Type Reflection based on Setup - }); - if ((modTypes == null) || !modTypes.Any()) - return new ResolvedMelons(null, null); - - var melons = new List(); - var rotten = new List(); - foreach (var t in modTypes) - { - var mel = LoadMod(asm, t, out RottenMelon rm); - if (mel != null) - melons.Add(mel); - else - rotten.Add(rm); - } - return new ResolvedMelons(melons.ToArray(), rotten.ToArray()); - } - - private MelonBase LoadMod(Assembly asm, Type modType, out RottenMelon rottenMelon) - { - rottenMelon = null; - - IMod modInstance; - try { modInstance = Activator.CreateInstance(modType) as IMod; } - catch (Exception ex) - { - rottenMelon = new RottenMelon(modType, "Failed to create an instance of the MMDL Mod.", ex); - return null; - } - - var modName = modInstance.Name; - - if (string.IsNullOrEmpty(modName)) - modName = modType.FullName; - - var modVersion = asm.GetName().Version.ToString(); - if (string.IsNullOrEmpty(modVersion) || modVersion.Equals("0.0.0.0")) - modVersion = "1.0.0.0"; - - var melon = MelonBase.CreateWrapper(modName, null, modVersion); - melon.modInstance = modInstance; - ModLoader.ModLoader.mods.Add(modInstance); - ModLoader.ModLoader.LoadDependency(asm); - return melon; - } - } -} \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/IMod.cs b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/IMod.cs deleted file mode 100644 index a33fe259f..000000000 --- a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/IMod.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace ModHelper -{ - public interface IMod - { - string Name { get; } - string Description { get; } - string Author { get; } - string HomePage { get; } - void DoPatching(); - } -} \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/ModLoader.cs b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/ModLoader.cs deleted file mode 100644 index fef19fbcd..000000000 --- a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/ModLoader.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using System.Reflection; -using MelonLoader; -using ModHelper; - -namespace ModLoader -{ - public class ModLoader - { - internal static List mods = new List(); - internal static Dictionary depends = new Dictionary(); - - public static void LoadDependency(Assembly assembly) - { - foreach (string dependStr in assembly.GetManifestResourceNames()) - { - string filter = $"{assembly.GetName().Name}.Depends."; - if (dependStr.StartsWith(filter) && dependStr.EndsWith(".dll")) - { - string dependName = dependStr.Remove(dependStr.LastIndexOf(".dll")).Remove(0, filter.Length); - if (depends.ContainsKey(dependName)) - { - MelonLogger.Error($"Dependency conflict: {dependName} First at: {depends[dependName].GetName().Name}"); - continue; - } - - Assembly dependAssembly; - using (var stream = assembly.GetManifestResourceStream(dependStr)) - { - byte[] buffer = new byte[stream.Length]; - stream.Read(buffer, 0, buffer.Length); - dependAssembly = Assembly.Load(buffer); - } - depends.Add(dependName, dependAssembly); - } - } - } - } -} \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/ModLogger.cs b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/ModLogger.cs deleted file mode 100644 index 5b4eacc98..000000000 --- a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/ModLogger.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Diagnostics; -using MelonLoader; - -namespace ModHelper -{ - public static class ModLogger - { - public static void Debug(object obj) - { - var frame = new StackTrace().GetFrame(1); - var className = frame.GetMethod().ReflectedType.Name; - var methodName = frame.GetMethod().Name; - AddLog(className, methodName, obj); - } - - public static void AddLog(string className, string methodName, object obj) - { - MelonLogger.Msg($"[{className}:{methodName}]: {obj}"); - } - } -} \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModWrapper.cs b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModWrapper.cs deleted file mode 100644 index aef40b5d7..000000000 --- a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModWrapper.cs +++ /dev/null @@ -1,10 +0,0 @@ -using ModHelper; - -namespace MelonLoader -{ - internal class MuseDashModWrapper : MelonMod - { - internal IMod modInstance; - public override void OnInitializeMelon() => modInstance.DoPatching(); - } -} \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Muse_Dash_Mono.csproj b/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Muse_Dash_Mono.csproj deleted file mode 100644 index 79f99e91c..000000000 --- a/Dependencies/CompatibilityLayers/Muse_Dash_Mono/Muse_Dash_Mono.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - MelonLoader.CompatibilityLayers - net35 - true - $(MLOutDir)/MelonLoader/Dependencies/CompatibilityLayers - true - embedded - - - - - \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Module.cs b/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Module.cs deleted file mode 100644 index a71f73b76..000000000 --- a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Module.cs +++ /dev/null @@ -1,71 +0,0 @@ -using MelonLoader.Modules; -using System.Collections.Generic; - -[assembly: MelonLoader.PatchShield] - -namespace MelonLoader.CompatibilityLayers -{ - internal class SLZ_Module : MelonModule - { - private static bool HasGotLoadingSceneIndex = false; - private static int LoadingSceneIndex = -9; - - private static Dictionary CompatibleGames = new Dictionary - { - ["BONELAB"] = 0, - ["BONEWORKS"] = 0 - }; - - public override void OnInitialize() - { - if (!CompatibleGames.ContainsKey(InternalUtils.UnityInformationHandler.GameName)) - return; - - MelonEvents.OnSceneWasLoaded.Subscribe(OnSceneLoad, int.MinValue); - MelonEvents.OnSceneWasInitialized.Subscribe(OnSceneInit, int.MinValue); - } - - private static void OnSceneLoad(int buildIndex, string name) - { - if (HasGotLoadingSceneIndex) - { - if (buildIndex == LoadingSceneIndex) - PreSceneEvent(); - return; - } - - if (buildIndex == 0) - return; - - HasGotLoadingSceneIndex = true; - LoadingSceneIndex = buildIndex; - PreSceneEvent(); - } - - private static void OnSceneInit(int buildIndex, string name) - { - if (!HasGotLoadingSceneIndex - || (buildIndex != LoadingSceneIndex)) - return; - - PostSceneEvent(); - MelonBase.SendMessageAll("OnLoadingScreen"); - MelonBase.SendMessageAll($"{InternalUtils.UnityInformationHandler.GameName}_OnLoadingScreen"); - } - - private static MelonEvent.MelonEventSubscriber[] SceneInitBackup; - private static void PreSceneEvent() - { - SceneInitBackup = MelonEvents.OnSceneWasInitialized.GetSubscribers(); - MelonEvents.OnSceneWasInitialized.UnsubscribeAll(); - MelonEvents.OnSceneWasInitialized.Subscribe(OnSceneInit, int.MinValue); - } - private static void PostSceneEvent() - { - MelonEvents.OnSceneWasInitialized.UnsubscribeAll(); - foreach (var sub in SceneInitBackup) - MelonEvents.OnSceneWasInitialized.Subscribe(sub.del, sub.priority, sub.unsubscribeOnFirstInvocation); - SceneInitBackup = null; - } - } -} \ No newline at end of file diff --git a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Stress_Level_Zero_Il2Cpp.csproj b/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Stress_Level_Zero_Il2Cpp.csproj deleted file mode 100644 index f30b3a643..000000000 --- a/Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Stress_Level_Zero_Il2Cpp.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - MelonLoader.CompatibilityLayers - net472 - true - $(MLOutDir)/MelonLoader/Dependencies/CompatibilityLayers - true - None - - - - - false - false - - - \ No newline at end of file diff --git a/Dependencies/Dotnet/LICENSE.TXT b/Dependencies/Dotnet/LICENSE.TXT new file mode 100644 index 000000000..984713a49 --- /dev/null +++ b/Dependencies/Dotnet/LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Dependencies/Dotnet/THIRD-PARTY-NOTICES.TXT b/Dependencies/Dotnet/THIRD-PARTY-NOTICES.TXT new file mode 100644 index 000000000..07a2b94ba --- /dev/null +++ b/Dependencies/Dotnet/THIRD-PARTY-NOTICES.TXT @@ -0,0 +1,1333 @@ +.NET Runtime uses third-party libraries or other resources that may be +distributed under licenses different than the .NET Runtime software. + +In the event that we accidentally failed to list a required notice, please +bring it to our attention. Post an issue or email us: + + dotnet@microsoft.com + +The attached notices are provided for information only. + +License notice for ASP.NET +------------------------------- + +Copyright (c) .NET Foundation. All rights reserved. +Licensed under the Apache License, Version 2.0. + +Available at +https://github.com/dotnet/aspnetcore/blob/main/LICENSE.txt + +License notice for Slicing-by-8 +------------------------------- + +http://sourceforge.net/projects/slicing-by-8/ + +Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved + + +This software program is licensed subject to the BSD License, available at +http://www.opensource.org/licenses/bsd-license.html. + + +License notice for Unicode data +------------------------------- + +https://www.unicode.org/license.html + +Copyright © 1991-2022 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +License notice for Zlib +----------------------- + +https://github.com/madler/zlib +https://zlib.net/zlib_license.html + +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.13, October 13th, 2022 + + Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +*/ + +License notice for Mono +------------------------------- + +http://www.mono-project.com/docs/about-mono/ + +Copyright (c) .NET Foundation Contributors + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the Software), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +License notice for International Organization for Standardization +----------------------------------------------------------------- + +Portions (C) International Organization for Standardization 1986: + Permission to copy in any form is granted for use with + conforming SGML systems and applications as defined in + ISO 8879, provided this notice is included in all copies. + +License notice for Intel +------------------------ + +"Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for Xamarin and Novell +------------------------------------- + +Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Copyright (c) 2011 Novell, Inc (http://www.novell.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Third party notice for W3C +-------------------------- + +"W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE +Status: This license takes effect 13 May, 2015. +This work is being provided by the copyright holders under the following license. +License +By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions. +Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications: +The full text of this NOTICE in a location viewable to users of the redistributed or derivative work. +Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software and Document Short Notice should be included. +Notice of any changes or modifications, through a copyright statement on the new code or document such as "This software or document includes material copied from or derived from [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)." +Disclaimers +THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT. +The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. Title to copyright in this work will at all times remain with copyright holders." + +License notice for Bit Twiddling Hacks +-------------------------------------- + +Bit Twiddling Hacks + +By Sean Eron Anderson +seander@cs.stanford.edu + +Individually, the code snippets here are in the public domain (unless otherwise +noted) — feel free to use them however you please. The aggregate collection and +descriptions are © 1997-2005 Sean Eron Anderson. The code and descriptions are +distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY and +without even the implied warranty of merchantability or fitness for a particular +purpose. + +License notice for Brotli +-------------------------------------- + +Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +compress_fragment.c: +Copyright (c) 2011, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +decode_fuzzer.c: +Copyright (c) 2015 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + +License notice for Json.NET +------------------------------- + +https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md + +The MIT License (MIT) + +Copyright (c) 2007 James Newton-King + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +License notice for vectorized base64 encoding / decoding +-------------------------------------------------------- + +Copyright (c) 2005-2007, Nick Galbreath +Copyright (c) 2013-2017, Alfred Klomp +Copyright (c) 2015-2017, Wojciech Mula +Copyright (c) 2016-2017, Matthieu Darbois +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for vectorized hex parsing +-------------------------------------------------------- + +Copyright (c) 2022, Geoff Langdale +Copyright (c) 2022, Wojciech Mula +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for RFC 3492 +--------------------------- + +The punycode implementation is based on the sample code in RFC 3492 + +Copyright (C) The Internet Society (2003). All Rights Reserved. + +This document and translations of it may be copied and furnished to +others, and derivative works that comment on or otherwise explain it +or assist in its implementation may be prepared, copied, published +and distributed, in whole or in part, without restriction of any +kind, provided that the above copyright notice and this paragraph are +included on all such copies and derivative works. However, this +document itself may not be modified in any way, such as by removing +the copyright notice or references to the Internet Society or other +Internet organizations, except as needed for the purpose of +developing Internet standards in which case the procedures for +copyrights defined in the Internet Standards process must be +followed, or as required to translate it into languages other than +English. + +The limited permissions granted above are perpetual and will not be +revoked by the Internet Society or its successors or assigns. + +This document and the information contained herein is provided on an +"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING +TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION +HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +Copyright(C) The Internet Society 1997. All Rights Reserved. + +This document and translations of it may be copied and furnished to others, +and derivative works that comment on or otherwise explain it or assist in +its implementation may be prepared, copied, published and distributed, in +whole or in part, without restriction of any kind, provided that the above +copyright notice and this paragraph are included on all such copies and +derivative works.However, this document itself may not be modified in any +way, such as by removing the copyright notice or references to the Internet +Society or other Internet organizations, except as needed for the purpose of +developing Internet standards in which case the procedures for copyrights +defined in the Internet Standards process must be followed, or as required +to translate it into languages other than English. + +The limited permissions granted above are perpetual and will not be revoked +by the Internet Society or its successors or assigns. + +This document and the information contained herein is provided on an "AS IS" +basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE +DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY +RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A +PARTICULAR PURPOSE. + +License notice for Algorithm from RFC 4122 - +A Universally Unique IDentifier (UUID) URN Namespace +---------------------------------------------------- + +Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. +Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & +Digital Equipment Corporation, Maynard, Mass. +Copyright (c) 1998 Microsoft. +To anyone who acknowledges that this file is provided "AS IS" +without any express or implied warranty: permission to use, copy, +modify, and distribute this file for any purpose is hereby +granted without fee, provided that the above copyright notices and +this notice appears in all source code copies, and that none of +the names of Open Software Foundation, Inc., Hewlett-Packard +Company, Microsoft, or Digital Equipment Corporation be used in +advertising or publicity pertaining to distribution of the software +without specific, written prior permission. Neither Open Software +Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital +Equipment Corporation makes any representations about the +suitability of this software for any purpose." + +License notice for The LLVM Compiler Infrastructure +--------------------------------------------------- + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +License notice for Bob Jenkins +------------------------------ + +By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this +code any way you wish, private, educational, or commercial. It's free. + +License notice for Greg Parker +------------------------------ + +Greg Parker gparker@cs.stanford.edu December 2000 +This code is in the public domain and may be copied or modified without +permission. + +License notice for libunwind based code +---------------------------------------- + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +License notice for Printing Floating-Point Numbers (Dragon4) +------------------------------------------------------------ + +/****************************************************************************** + Copyright (c) 2014 Ryan Juckett + http://www.ryanjuckett.com/ + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +******************************************************************************/ + +License notice for Printing Floating-point Numbers (Grisu3) +----------------------------------------------------------- + +Copyright 2012 the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for xxHash +------------------------- + +xxHash - Extremely Fast Hash algorithm +Header File +Copyright (C) 2012-2021 Yann Collet + +BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php) + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +You can contact the author at: + - xxHash homepage: https://www.xxhash.com + - xxHash source repository: https://github.com/Cyan4973/xxHash + +License notice for Berkeley SoftFloat Release 3e +------------------------------------------------ + +https://github.com/ucb-bar/berkeley-softfloat-3 +https://github.com/ucb-bar/berkeley-softfloat-3/blob/master/COPYING.txt + +License for Berkeley SoftFloat Release 3e + +John R. Hauser +2018 January 20 + +The following applies to the whole of SoftFloat Release 3e as well as to +each source file individually. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the +University of California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for xoshiro RNGs +-------------------------------- + +Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org) + +To the extent possible under law, the author has dedicated all copyright +and related and neighboring rights to this software to the public domain +worldwide. This software is distributed without any warranty. + +See . + +License for fastmod (https://github.com/lemire/fastmod), ibm-fpgen (https://github.com/nigeltao/parse-number-fxx-test-data) and fastrange (https://github.com/lemire/fastrange) +-------------------------------------- + + Copyright 2018 Daniel Lemire + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +License for sse4-strstr (https://github.com/WojciechMula/sse4-strstr) +-------------------------------------- + + Copyright (c) 2008-2016, Wojciech Mula + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for The C++ REST SDK +----------------------------------- + +C++ REST SDK + +The MIT License (MIT) + +Copyright (c) Microsoft Corporation + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +License notice for MessagePack-CSharp +------------------------------------- + +MessagePack for C# + +MIT License + +Copyright (c) 2017 Yoshifumi Kawai + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +License notice for lz4net +------------------------------------- + +lz4net + +Copyright (c) 2013-2017, Milosz Krajewski + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for Nerdbank.Streams +----------------------------------- + +The MIT License (MIT) + +Copyright (c) Andrew Arnott + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +License notice for RapidJSON +---------------------------- + +Tencent is pleased to support the open source community by making RapidJSON available. + +Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. + +Licensed under the MIT License (the "License"); you may not use this file except +in compliance with the License. You may obtain a copy of the License at + +http://opensource.org/licenses/MIT + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. + +License notice for DirectX Math Library +--------------------------------------- + +https://github.com/microsoft/DirectXMath/blob/master/LICENSE + + The MIT License (MIT) + +Copyright (c) 2011-2020 Microsoft Corp + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +License notice for ldap4net +--------------------------- + +The MIT License (MIT) + +Copyright (c) 2018 Alexander Chermyanin + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +License notice for vectorized sorting code +------------------------------------------ + +MIT License + +Copyright (c) 2020 Dan Shechter + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +License notice for musl +----------------------- + +musl as a whole is licensed under the following standard MIT license: + +Copyright © 2005-2020 Rich Felker, et al. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +License notice for "Faster Unsigned Division by Constants" +------------------------------ + +Reference implementations of computing and using the "magic number" approach to dividing +by constants, including codegen instructions. The unsigned division incorporates the +"round down" optimization per ridiculous_fish. + +This is free and unencumbered software. Any copyright is dedicated to the Public Domain. + + +License notice for mimalloc +----------------------------------- + +MIT License + +Copyright (c) 2019 Microsoft Corporation, Daan Leijen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +License for remote stack unwind (https://github.com/llvm/llvm-project/blob/main/lldb/source/Symbol/CompactUnwindInfo.cpp) +-------------------------------------- + +Copyright 2019 LLVM Project + +Licensed under the Apache License, Version 2.0 (the "License") with LLVM Exceptions; +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +https://llvm.org/LICENSE.txt + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +License notice for Apple header files +------------------------------------- + +Copyright (c) 1980, 1986, 1993 + The Regents of the University of California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + This product includes software developed by the University of + California, Berkeley and its contributors. +4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +License notice for JavaScript queues +------------------------------------- + +CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER. + +Statement of Purpose +The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). +Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. +For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: +the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; +moral rights retained by the original author(s) and/or performer(s); +publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; +rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; +rights protecting the extraction, dissemination, use and reuse of data in a Work; +database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and +other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. +2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. +3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. +4. Limitations and Disclaimers. +a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. +b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. +c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. +d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. + + +License notice for FastFloat algorithm +------------------------------------- +MIT License +Copyright (c) 2021 csFastFloat authors +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +License notice for MsQuic +-------------------------------------- + +Copyright (c) Microsoft Corporation. +Licensed under the MIT License. + +Available at +https://github.com/microsoft/msquic/blob/main/LICENSE + +License notice for m-ou-se/floatconv +------------------------------- + +Copyright (c) 2020 Mara Bos +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for code from The Practice of Programming +------------------------------- + +Copyright (C) 1999 Lucent Technologies + +Excerpted from 'The Practice of Programming +by Brian W. Kernighan and Rob Pike + +You may use this code for any purpose, as long as you leave the copyright notice and book citation attached. + +Notice for Euclidean Affine Functions and Applications to Calendar +Algorithms +------------------------------- + +Aspects of Date/Time processing based on algorithm described in "Euclidean Affine Functions and Applications to Calendar +Algorithms", Cassio Neri and Lorenz Schneider. https://arxiv.org/pdf/2102.06959.pdf + +License notice for amd/aocl-libm-ose +------------------------------- + +Copyright (C) 2008-2020 Advanced Micro Devices, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +License notice for fmtlib/fmt +------------------------------- + +Formatting library for C++ + +Copyright (c) 2012 - present, Victor Zverovich + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +License for Jb Evain +--------------------- + +Copyright (c) 2006 Jb Evain (jbevain@gmail.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- Optional exception to the license --- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into a machine-executable object form of such +source code, you may redistribute such embedded portions in such object form +without including the above copyright and permission notices. + + +License for MurmurHash3 +-------------------------------------- + +https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp + +MurmurHash3 was written by Austin Appleby, and is placed in the public +domain. The author hereby disclaims copyright to this source + +License for Fast CRC Computation +-------------------------------------- + +https://github.com/intel/isa-l/blob/33a2d9484595c2d6516c920ce39a694c144ddf69/crc/crc32_ieee_by4.asm +https://github.com/intel/isa-l/blob/33a2d9484595c2d6516c920ce39a694c144ddf69/crc/crc64_ecma_norm_by8.asm + +Copyright(c) 2011-2015 Intel Corporation All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License for C# Implementation of Fast CRC Computation +----------------------------------------------------- + +https://github.com/SixLabors/ImageSharp/blob/f4f689ce67ecbcc35cebddba5aacb603e6d1068a/src/ImageSharp/Formats/Png/Zlib/Crc32.cs + +Copyright (c) Six Labors. +Licensed under the Apache License, Version 2.0. + +Available at +https://github.com/SixLabors/ImageSharp/blob/f4f689ce67ecbcc35cebddba5aacb603e6d1068a/LICENSE + +License for the Teddy multi-substring searching implementation +-------------------------------------- + +https://github.com/BurntSushi/aho-corasick + +The MIT License (MIT) + +Copyright (c) 2015 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +License notice for Avx512Vbmi base64 encoding / decoding +-------------------------------------------------------- + +Copyright (c) 2015-2018, Wojciech Muła +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------- + +Aspects of base64 encoding / decoding are based on algorithm described in "Base64 encoding and decoding at almost the speed of a memory +copy", Wojciech Muła and Daniel Lemire. https://arxiv.org/pdf/1910.05109.pdf diff --git a/Dependencies/Dotnet/linux/x86_64/dotnet b/Dependencies/Dotnet/linux/x86_64/dotnet new file mode 100644 index 000000000..c023300d3 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/dotnet differ diff --git a/Dependencies/Dotnet/linux/x86_64/host/fxr/6.0.25/libhostfxr.so b/Dependencies/Dotnet/linux/x86_64/host/fxr/6.0.25/libhostfxr.so new file mode 100644 index 000000000..376bffeed Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/host/fxr/6.0.25/libhostfxr.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/.version b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/.version new file mode 100644 index 000000000..dbb688f01 --- /dev/null +++ b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/.version @@ -0,0 +1,2 @@ +492abbeef0d8a6ea902ac8f90ed339c7b1d18bf4 +6.0.25 diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.CSharp.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.CSharp.dll new file mode 100644 index 000000000..da53a8d54 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.CSharp.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.deps.json b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.deps.json new file mode 100644 index 000000000..053da3997 --- /dev/null +++ b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.deps.json @@ -0,0 +1,2896 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v6.0/linux-x64", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v6.0": {}, + ".NETCoreApp,Version=v6.0/linux-x64": { + "Microsoft.NETCore.App.Runtime.linux-x64/6.0.25": { + "runtime": { + "System.Private.CoreLib.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.VisualBasic.dll": { + "assemblyVersion": "10.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "mscorlib.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "netstandard.dll": { + "assemblyVersion": "2.1.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.AppContext.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Buffers.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.DataAnnotations.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Configuration.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Core.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Data.DataSetExtensions.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Data.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Contracts.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Debug.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Tools.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Tracing.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Drawing.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Dynamic.Runtime.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Globalization.Calendars.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Globalization.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Globalization.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.FileSystem.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.UnmanagedMemoryStream.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Numerics.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Numerics.Vectors.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Emit.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Emit.ILGeneration.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Emit.Lightweight.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Resources.Reader.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Resources.ResourceManager.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Handles.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Intrinsics.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Loader.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Json.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Xml.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Principal.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.SecureString.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ServiceModel.Web.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ServiceProcess.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encoding.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encoding.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Overlapped.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Thread.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.ThreadPool.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Timer.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Transactions.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ValueTuple.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Web.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Windows.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.Linq.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.ReaderWriter.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.Serialization.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XDocument.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XmlDocument.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XmlSerializer.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XPath.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "WindowsBase.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.CSharp.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.VisualBasic.Core.dll": { + "assemblyVersion": "11.0.0.0", + "fileVersion": "11.100.2523.51912" + }, + "Microsoft.Win32.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.Win32.Registry.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.Concurrent.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.Immutable.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.NonGeneric.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.Specialized.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.Annotations.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.EventBasedAsync.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.TypeConverter.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Console.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Data.Common.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.DiagnosticSource.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.FileVersionInfo.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Process.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.StackTrace.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.TextWriterTraceListener.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.TraceSource.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Drawing.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Formats.Asn1.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.Brotli.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.ZipFile.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.AccessControl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.DriveInfo.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.Watcher.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.IsolatedStorage.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.MemoryMappedFiles.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Pipes.AccessControl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Pipes.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.Expressions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.Parallel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.Queryable.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Memory.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Http.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Http.Json.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.HttpListener.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Mail.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.NameResolution.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.NetworkInformation.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Ping.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Quic.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Requests.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Security.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.ServicePoint.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Sockets.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebClient.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebHeaderCollection.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebProxy.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebSockets.Client.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebSockets.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ObjectModel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.DataContractSerialization.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.Uri.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.Xml.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.Xml.Linq.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.DispatchProxy.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Metadata.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.TypeExtensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Resources.Writer.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.CompilerServices.Unsafe.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.CompilerServices.VisualC.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.InteropServices.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.InteropServices.RuntimeInformation.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Numerics.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Formatters.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.AccessControl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Claims.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Algorithms.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Cng.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Csp.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Encoding.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.OpenSsl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.X509Certificates.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Principal.Windows.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encoding.CodePages.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encodings.Web.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Json.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.RegularExpressions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Channels.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.Dataflow.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.Parallel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Transactions.Local.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Web.HttpUtility.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XPath.XDocument.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + } + }, + "native": { + "createdump": { + "fileVersion": "0.0.0.0" + }, + "libclrjit.so": { + "fileVersion": "0.0.0.0" + }, + "libcoreclr.so": { + "fileVersion": "0.0.0.0" + }, + "libcoreclrtraceptprovider.so": { + "fileVersion": "0.0.0.0" + }, + "libdbgshim.so": { + "fileVersion": "0.0.0.0" + }, + "libmscordaccore.so": { + "fileVersion": "0.0.0.0" + }, + "libmscordbi.so": { + "fileVersion": "0.0.0.0" + }, + "libSystem.Globalization.Native.so": { + "fileVersion": "0.0.0.0" + }, + "libSystem.IO.Compression.Native.so": { + "fileVersion": "0.0.0.0" + }, + "libSystem.Native.so": { + "fileVersion": "0.0.0.0" + }, + "libSystem.Net.Security.Native.so": { + "fileVersion": "0.0.0.0" + }, + "libSystem.Security.Cryptography.Native.OpenSsl.so": { + "fileVersion": "0.0.0.0" + }, + "libhostpolicy.so": { + "fileVersion": "0.0.0.0" + } + } + } + } + }, + "libraries": { + "Microsoft.NETCore.App.Runtime.linux-x64/6.0.25": { + "type": "package", + "serviceable": true, + "sha512": "", + "path": "microsoft.netcore.app.runtime.linux-x64/6.0.25" + } + }, + "runtimes": { + "alpine-x64": [ + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.10-x64": [ + "alpine.3.10", + "alpine.3.9-x64", + "alpine.3.9", + "alpine.3.8-x64", + "alpine.3.8", + "alpine.3.7-x64", + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.11-x64": [ + "alpine.3.11", + "alpine.3.10-x64", + "alpine.3.10", + "alpine.3.9-x64", + "alpine.3.9", + "alpine.3.8-x64", + "alpine.3.8", + "alpine.3.7-x64", + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.12-x64": [ + "alpine.3.12", + "alpine.3.11-x64", + "alpine.3.11", + "alpine.3.10-x64", + "alpine.3.10", + "alpine.3.9-x64", + "alpine.3.9", + "alpine.3.8-x64", + "alpine.3.8", + "alpine.3.7-x64", + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.13-x64": [ + "alpine.3.13", + "alpine.3.12-x64", + "alpine.3.12", + "alpine.3.11-x64", + "alpine.3.11", + "alpine.3.10-x64", + "alpine.3.10", + "alpine.3.9-x64", + "alpine.3.9", + "alpine.3.8-x64", + "alpine.3.8", + "alpine.3.7-x64", + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.14-x64": [ + "alpine.3.14", + "alpine.3.13-x64", + "alpine.3.13", + "alpine.3.12-x64", + "alpine.3.12", + "alpine.3.11-x64", + "alpine.3.11", + "alpine.3.10-x64", + "alpine.3.10", + "alpine.3.9-x64", + "alpine.3.9", + "alpine.3.8-x64", + "alpine.3.8", + "alpine.3.7-x64", + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.15-x64": [ + "alpine.3.15", + "alpine.3.14-x64", + "alpine.3.14", + "alpine.3.13-x64", + "alpine.3.13", + "alpine.3.12-x64", + "alpine.3.12", + "alpine.3.11-x64", + "alpine.3.11", + "alpine.3.10-x64", + "alpine.3.10", + "alpine.3.9-x64", + "alpine.3.9", + "alpine.3.8-x64", + "alpine.3.8", + "alpine.3.7-x64", + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.16-x64": [ + "alpine.3.16", + "alpine.3.15-x64", + "alpine.3.15", + "alpine.3.14-x64", + "alpine.3.14", + "alpine.3.13-x64", + "alpine.3.13", + "alpine.3.12-x64", + "alpine.3.12", + "alpine.3.11-x64", + "alpine.3.11", + "alpine.3.10-x64", + "alpine.3.10", + "alpine.3.9-x64", + "alpine.3.9", + "alpine.3.8-x64", + "alpine.3.8", + "alpine.3.7-x64", + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.17-x64": [ + "alpine.3.17", + "alpine.3.16-x64", + "alpine.3.16", + "alpine.3.15-x64", + "alpine.3.15", + "alpine.3.14-x64", + "alpine.3.14", + "alpine.3.13-x64", + "alpine.3.13", + "alpine.3.12-x64", + "alpine.3.12", + "alpine.3.11-x64", + "alpine.3.11", + "alpine.3.10-x64", + "alpine.3.10", + "alpine.3.9-x64", + "alpine.3.9", + "alpine.3.8-x64", + "alpine.3.8", + "alpine.3.7-x64", + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.18-x64": [ + "alpine.3.18", + "alpine.3.17-x64", + "alpine.3.17", + "alpine.3.16-x64", + "alpine.3.16", + "alpine.3.15-x64", + "alpine.3.15", + "alpine.3.14-x64", + "alpine.3.14", + "alpine.3.13-x64", + "alpine.3.13", + "alpine.3.12-x64", + "alpine.3.12", + "alpine.3.11-x64", + "alpine.3.11", + "alpine.3.10-x64", + "alpine.3.10", + "alpine.3.9-x64", + "alpine.3.9", + "alpine.3.8-x64", + "alpine.3.8", + "alpine.3.7-x64", + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.6-x64": [ + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.7-x64": [ + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.8-x64": [ + "alpine.3.8", + "alpine.3.7-x64", + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "alpine.3.9-x64": [ + "alpine.3.9", + "alpine.3.8-x64", + "alpine.3.8", + "alpine.3.7-x64", + "alpine.3.7", + "alpine.3.6-x64", + "alpine.3.6", + "alpine-x64", + "alpine", + "linux-musl-x64", + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android-x64": [ + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.21-x64": [ + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.22-x64": [ + "android.22", + "android.21-x64", + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.23-x64": [ + "android.23", + "android.22-x64", + "android.22", + "android.21-x64", + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.24-x64": [ + "android.24", + "android.23-x64", + "android.23", + "android.22-x64", + "android.22", + "android.21-x64", + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.25-x64": [ + "android.25", + "android.24-x64", + "android.24", + "android.23-x64", + "android.23", + "android.22-x64", + "android.22", + "android.21-x64", + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.26-x64": [ + "android.26", + "android.25-x64", + "android.25", + "android.24-x64", + "android.24", + "android.23-x64", + "android.23", + "android.22-x64", + "android.22", + "android.21-x64", + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.27-x64": [ + "android.27", + "android.26-x64", + "android.26", + "android.25-x64", + "android.25", + "android.24-x64", + "android.24", + "android.23-x64", + "android.23", + "android.22-x64", + "android.22", + "android.21-x64", + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.28-x64": [ + "android.28", + "android.27-x64", + "android.27", + "android.26-x64", + "android.26", + "android.25-x64", + "android.25", + "android.24-x64", + "android.24", + "android.23-x64", + "android.23", + "android.22-x64", + "android.22", + "android.21-x64", + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.29-x64": [ + "android.29", + "android.28-x64", + "android.28", + "android.27-x64", + "android.27", + "android.26-x64", + "android.26", + "android.25-x64", + "android.25", + "android.24-x64", + "android.24", + "android.23-x64", + "android.23", + "android.22-x64", + "android.22", + "android.21-x64", + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.30-x64": [ + "android.30", + "android.29-x64", + "android.29", + "android.28-x64", + "android.28", + "android.27-x64", + "android.27", + "android.26-x64", + "android.26", + "android.25-x64", + "android.25", + "android.24-x64", + "android.24", + "android.23-x64", + "android.23", + "android.22-x64", + "android.22", + "android.21-x64", + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.31-x64": [ + "android.31", + "android.30-x64", + "android.30", + "android.29-x64", + "android.29", + "android.28-x64", + "android.28", + "android.27-x64", + "android.27", + "android.26-x64", + "android.26", + "android.25-x64", + "android.25", + "android.24-x64", + "android.24", + "android.23-x64", + "android.23", + "android.22-x64", + "android.22", + "android.21-x64", + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "android.32-x64": [ + "android.32", + "android.31-x64", + "android.31", + "android.30-x64", + "android.30", + "android.29-x64", + "android.29", + "android.28-x64", + "android.28", + "android.27-x64", + "android.27", + "android.26-x64", + "android.26", + "android.25-x64", + "android.25", + "android.24-x64", + "android.24", + "android.23-x64", + "android.23", + "android.22-x64", + "android.22", + "android.21-x64", + "android.21", + "android-x64", + "android", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "arch-x64": [ + "arch", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "centos-x64": [ + "centos", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "centos.7-x64": [ + "centos.7", + "centos-x64", + "rhel.7-x64", + "centos", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "centos.8-x64": [ + "centos.8", + "centos-x64", + "rhel.8-x64", + "centos", + "rhel.8", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "centos.9-x64": [ + "centos.9", + "centos-x64", + "rhel.9-x64", + "centos", + "rhel.9", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "debian-x64": [ + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "debian.10-x64": [ + "debian.10", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "debian.11-x64": [ + "debian.11", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "debian.12-x64": [ + "debian.12", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "debian.8-x64": [ + "debian.8", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "debian.9-x64": [ + "debian.9", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "exherbo-x64": [ + "exherbo", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora-x64": [ + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.23-x64": [ + "fedora.23", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.24-x64": [ + "fedora.24", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.25-x64": [ + "fedora.25", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.26-x64": [ + "fedora.26", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.27-x64": [ + "fedora.27", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.28-x64": [ + "fedora.28", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.29-x64": [ + "fedora.29", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.30-x64": [ + "fedora.30", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.31-x64": [ + "fedora.31", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.32-x64": [ + "fedora.32", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.33-x64": [ + "fedora.33", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.34-x64": [ + "fedora.34", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.35-x64": [ + "fedora.35", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.36-x64": [ + "fedora.36", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.37-x64": [ + "fedora.37", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.38-x64": [ + "fedora.38", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "fedora.39-x64": [ + "fedora.39", + "fedora-x64", + "fedora", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "gentoo-x64": [ + "gentoo", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linux-musl-x64": [ + "linux-musl", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linux-x64": [ + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linuxmint.17-x64": [ + "linuxmint.17", + "ubuntu.14.04-x64", + "ubuntu.14.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linuxmint.17.1-x64": [ + "linuxmint.17.1", + "linuxmint.17-x64", + "linuxmint.17", + "ubuntu.14.04-x64", + "ubuntu.14.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linuxmint.17.2-x64": [ + "linuxmint.17.2", + "linuxmint.17.1-x64", + "linuxmint.17.1", + "linuxmint.17-x64", + "linuxmint.17", + "ubuntu.14.04-x64", + "ubuntu.14.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linuxmint.17.3-x64": [ + "linuxmint.17.3", + "linuxmint.17.2-x64", + "linuxmint.17.2", + "linuxmint.17.1-x64", + "linuxmint.17.1", + "linuxmint.17-x64", + "linuxmint.17", + "ubuntu.14.04-x64", + "ubuntu.14.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linuxmint.18-x64": [ + "linuxmint.18", + "ubuntu.16.04-x64", + "ubuntu.16.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linuxmint.18.1-x64": [ + "linuxmint.18.1", + "linuxmint.18-x64", + "linuxmint.18", + "ubuntu.16.04-x64", + "ubuntu.16.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linuxmint.18.2-x64": [ + "linuxmint.18.2", + "linuxmint.18.1-x64", + "linuxmint.18.1", + "linuxmint.18-x64", + "linuxmint.18", + "ubuntu.16.04-x64", + "ubuntu.16.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linuxmint.18.3-x64": [ + "linuxmint.18.3", + "linuxmint.18.2-x64", + "linuxmint.18.2", + "linuxmint.18.1-x64", + "linuxmint.18.1", + "linuxmint.18-x64", + "linuxmint.18", + "ubuntu.16.04-x64", + "ubuntu.16.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linuxmint.19-x64": [ + "linuxmint.19", + "ubuntu.18.04-x64", + "ubuntu.18.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linuxmint.19.1-x64": [ + "linuxmint.19.1", + "linuxmint.19-x64", + "linuxmint.19", + "ubuntu.18.04-x64", + "ubuntu.18.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "linuxmint.19.2-x64": [ + "linuxmint.19.2", + "linuxmint.19.1-x64", + "linuxmint.19.1", + "linuxmint.19-x64", + "linuxmint.19", + "ubuntu.18.04-x64", + "ubuntu.18.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ol-x64": [ + "ol", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ol.7-x64": [ + "ol.7", + "ol-x64", + "rhel.7-x64", + "ol", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ol.7.0-x64": [ + "ol.7.0", + "ol.7-x64", + "rhel.7.0-x64", + "ol.7", + "rhel.7.0", + "ol-x64", + "rhel.7-x64", + "ol", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ol.7.1-x64": [ + "ol.7.1", + "ol.7.0-x64", + "rhel.7.1-x64", + "ol.7.0", + "rhel.7.1", + "ol.7-x64", + "rhel.7.0-x64", + "ol.7", + "rhel.7.0", + "ol-x64", + "rhel.7-x64", + "ol", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ol.7.2-x64": [ + "ol.7.2", + "ol.7.1-x64", + "rhel.7.2-x64", + "ol.7.1", + "rhel.7.2", + "ol.7.0-x64", + "rhel.7.1-x64", + "ol.7.0", + "rhel.7.1", + "ol.7-x64", + "rhel.7.0-x64", + "ol.7", + "rhel.7.0", + "ol-x64", + "rhel.7-x64", + "ol", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ol.7.3-x64": [ + "ol.7.3", + "ol.7.2-x64", + "rhel.7.3-x64", + "ol.7.2", + "rhel.7.3", + "ol.7.1-x64", + "rhel.7.2-x64", + "ol.7.1", + "rhel.7.2", + "ol.7.0-x64", + "rhel.7.1-x64", + "ol.7.0", + "rhel.7.1", + "ol.7-x64", + "rhel.7.0-x64", + "ol.7", + "rhel.7.0", + "ol-x64", + "rhel.7-x64", + "ol", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ol.7.4-x64": [ + "ol.7.4", + "ol.7.3-x64", + "rhel.7.4-x64", + "ol.7.3", + "rhel.7.4", + "ol.7.2-x64", + "rhel.7.3-x64", + "ol.7.2", + "rhel.7.3", + "ol.7.1-x64", + "rhel.7.2-x64", + "ol.7.1", + "rhel.7.2", + "ol.7.0-x64", + "rhel.7.1-x64", + "ol.7.0", + "rhel.7.1", + "ol.7-x64", + "rhel.7.0-x64", + "ol.7", + "rhel.7.0", + "ol-x64", + "rhel.7-x64", + "ol", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ol.7.5-x64": [ + "ol.7.5", + "ol.7.4-x64", + "rhel.7.5-x64", + "ol.7.4", + "rhel.7.5", + "ol.7.3-x64", + "rhel.7.4-x64", + "ol.7.3", + "rhel.7.4", + "ol.7.2-x64", + "rhel.7.3-x64", + "ol.7.2", + "rhel.7.3", + "ol.7.1-x64", + "rhel.7.2-x64", + "ol.7.1", + "rhel.7.2", + "ol.7.0-x64", + "rhel.7.1-x64", + "ol.7.0", + "rhel.7.1", + "ol.7-x64", + "rhel.7.0-x64", + "ol.7", + "rhel.7.0", + "ol-x64", + "rhel.7-x64", + "ol", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ol.7.6-x64": [ + "ol.7.6", + "ol.7.5-x64", + "rhel.7.6-x64", + "ol.7.5", + "rhel.7.6", + "ol.7.4-x64", + "rhel.7.5-x64", + "ol.7.4", + "rhel.7.5", + "ol.7.3-x64", + "rhel.7.4-x64", + "ol.7.3", + "rhel.7.4", + "ol.7.2-x64", + "rhel.7.3-x64", + "ol.7.2", + "rhel.7.3", + "ol.7.1-x64", + "rhel.7.2-x64", + "ol.7.1", + "rhel.7.2", + "ol.7.0-x64", + "rhel.7.1-x64", + "ol.7.0", + "rhel.7.1", + "ol.7-x64", + "rhel.7.0-x64", + "ol.7", + "rhel.7.0", + "ol-x64", + "rhel.7-x64", + "ol", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ol.8-x64": [ + "ol.8", + "ol-x64", + "rhel.8-x64", + "ol", + "rhel.8", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ol.8.0-x64": [ + "ol.8.0", + "ol.8-x64", + "rhel.8.0-x64", + "ol.8", + "rhel.8.0", + "ol-x64", + "rhel.8-x64", + "ol", + "rhel.8", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "opensuse-x64": [ + "opensuse", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "opensuse.13.2-x64": [ + "opensuse.13.2", + "opensuse-x64", + "opensuse", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "opensuse.15.0-x64": [ + "opensuse.15.0", + "opensuse-x64", + "opensuse", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "opensuse.15.1-x64": [ + "opensuse.15.1", + "opensuse-x64", + "opensuse", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "opensuse.42.1-x64": [ + "opensuse.42.1", + "opensuse-x64", + "opensuse", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "opensuse.42.2-x64": [ + "opensuse.42.2", + "opensuse-x64", + "opensuse", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "opensuse.42.3-x64": [ + "opensuse.42.3", + "opensuse-x64", + "opensuse", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel-x64": [ + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.6-x64": [ + "rhel.6", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.7-x64": [ + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.7.0-x64": [ + "rhel.7.0", + "rhel.7-x64", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.7.1-x64": [ + "rhel.7.1", + "rhel.7.0-x64", + "rhel.7.0", + "rhel.7-x64", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.7.2-x64": [ + "rhel.7.2", + "rhel.7.1-x64", + "rhel.7.1", + "rhel.7.0-x64", + "rhel.7.0", + "rhel.7-x64", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.7.3-x64": [ + "rhel.7.3", + "rhel.7.2-x64", + "rhel.7.2", + "rhel.7.1-x64", + "rhel.7.1", + "rhel.7.0-x64", + "rhel.7.0", + "rhel.7-x64", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.7.4-x64": [ + "rhel.7.4", + "rhel.7.3-x64", + "rhel.7.3", + "rhel.7.2-x64", + "rhel.7.2", + "rhel.7.1-x64", + "rhel.7.1", + "rhel.7.0-x64", + "rhel.7.0", + "rhel.7-x64", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.7.5-x64": [ + "rhel.7.5", + "rhel.7.4-x64", + "rhel.7.4", + "rhel.7.3-x64", + "rhel.7.3", + "rhel.7.2-x64", + "rhel.7.2", + "rhel.7.1-x64", + "rhel.7.1", + "rhel.7.0-x64", + "rhel.7.0", + "rhel.7-x64", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.7.6-x64": [ + "rhel.7.6", + "rhel.7.5-x64", + "rhel.7.5", + "rhel.7.4-x64", + "rhel.7.4", + "rhel.7.3-x64", + "rhel.7.3", + "rhel.7.2-x64", + "rhel.7.2", + "rhel.7.1-x64", + "rhel.7.1", + "rhel.7.0-x64", + "rhel.7.0", + "rhel.7-x64", + "rhel.7", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.8-x64": [ + "rhel.8", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.8.0-x64": [ + "rhel.8.0", + "rhel.8-x64", + "rhel.8", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.8.1-x64": [ + "rhel.8.1", + "rhel.8.0-x64", + "rhel.8.0", + "rhel.8-x64", + "rhel.8", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rhel.9-x64": [ + "rhel.9", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rocky-x64": [ + "rocky", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rocky.8-x64": [ + "rocky.8", + "rocky-x64", + "rhel.8-x64", + "rocky", + "rhel.8", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "rocky.9-x64": [ + "rocky.9", + "rocky-x64", + "rhel.9-x64", + "rocky", + "rhel.9", + "rhel-x64", + "rhel", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "sles-x64": [ + "sles", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "sles.12-x64": [ + "sles.12", + "sles-x64", + "sles", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "sles.12.1-x64": [ + "sles.12.1", + "sles.12-x64", + "sles.12", + "sles-x64", + "sles", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "sles.12.2-x64": [ + "sles.12.2", + "sles.12.1-x64", + "sles.12.1", + "sles.12-x64", + "sles.12", + "sles-x64", + "sles", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "sles.12.3-x64": [ + "sles.12.3", + "sles.12.2-x64", + "sles.12.2", + "sles.12.1-x64", + "sles.12.1", + "sles.12-x64", + "sles.12", + "sles-x64", + "sles", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "sles.12.4-x64": [ + "sles.12.4", + "sles.12.3-x64", + "sles.12.3", + "sles.12.2-x64", + "sles.12.2", + "sles.12.1-x64", + "sles.12.1", + "sles.12-x64", + "sles.12", + "sles-x64", + "sles", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "sles.15-x64": [ + "sles.15", + "sles.12.4-x64", + "sles.12.4", + "sles.12.3-x64", + "sles.12.3", + "sles.12.2-x64", + "sles.12.2", + "sles.12.1-x64", + "sles.12.1", + "sles.12-x64", + "sles.12", + "sles-x64", + "sles", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "sles.15.1-x64": [ + "sles.15.1", + "sles.15-x64", + "sles.15", + "sles.12.4-x64", + "sles.12.4", + "sles.12.3-x64", + "sles.12.3", + "sles.12.2-x64", + "sles.12.2", + "sles.12.1-x64", + "sles.12.1", + "sles.12-x64", + "sles.12", + "sles-x64", + "sles", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu-x64": [ + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.14.04-x64": [ + "ubuntu.14.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.14.10-x64": [ + "ubuntu.14.10", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.15.04-x64": [ + "ubuntu.15.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.15.10-x64": [ + "ubuntu.15.10", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.16.04-x64": [ + "ubuntu.16.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.16.10-x64": [ + "ubuntu.16.10", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.17.04-x64": [ + "ubuntu.17.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.17.10-x64": [ + "ubuntu.17.10", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.18.04-x64": [ + "ubuntu.18.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.18.10-x64": [ + "ubuntu.18.10", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.19.04-x64": [ + "ubuntu.19.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.19.10-x64": [ + "ubuntu.19.10", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.20.04-x64": [ + "ubuntu.20.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.20.10-x64": [ + "ubuntu.20.10", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.21.04-x64": [ + "ubuntu.21.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.21.10-x64": [ + "ubuntu.21.10", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.22.04-x64": [ + "ubuntu.22.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.22.10-x64": [ + "ubuntu.22.10", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.23.04-x64": [ + "ubuntu.23.04", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ], + "ubuntu.23.10-x64": [ + "ubuntu.23.10", + "ubuntu-x64", + "ubuntu", + "debian-x64", + "debian", + "linux-x64", + "linux", + "unix-x64", + "unix", + "any", + "base" + ] + } +} \ No newline at end of file diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.runtimeconfig.json b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.runtimeconfig.json new file mode 100644 index 000000000..3d37d8e97 --- /dev/null +++ b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.runtimeconfig.json @@ -0,0 +1,8 @@ +{ + "runtimeOptions": { + "tfm": "net6.0", + "configProperties": { + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false + } + } +} \ No newline at end of file diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.Core.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.Core.dll new file mode 100644 index 000000000..cd30522a8 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.Core.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.dll new file mode 100644 index 000000000..fbdadfd2e Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Primitives.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Primitives.dll new file mode 100644 index 000000000..f8538422c Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Primitives.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Registry.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Registry.dll new file mode 100644 index 000000000..79c1b1182 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Registry.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.AppContext.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.AppContext.dll new file mode 100644 index 000000000..3007ef35d Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.AppContext.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Buffers.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Buffers.dll new file mode 100644 index 000000000..bc2412b3a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Buffers.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Concurrent.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Concurrent.dll new file mode 100644 index 000000000..e507e8449 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Concurrent.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Immutable.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Immutable.dll new file mode 100644 index 000000000..b8c10233a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Immutable.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.NonGeneric.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.NonGeneric.dll new file mode 100644 index 000000000..22f61a4a6 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.NonGeneric.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Specialized.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Specialized.dll new file mode 100644 index 000000000..e8683ee01 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Specialized.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.dll new file mode 100644 index 000000000..3acc4fb3c Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Annotations.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Annotations.dll new file mode 100644 index 000000000..1ffab6d0c Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Annotations.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.DataAnnotations.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.DataAnnotations.dll new file mode 100644 index 000000000..c6492fbeb Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.DataAnnotations.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.EventBasedAsync.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.EventBasedAsync.dll new file mode 100644 index 000000000..d6b1abe49 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.EventBasedAsync.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Primitives.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Primitives.dll new file mode 100644 index 000000000..72da24352 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Primitives.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.TypeConverter.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.TypeConverter.dll new file mode 100644 index 000000000..d3d4fb4ea Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.TypeConverter.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.dll new file mode 100644 index 000000000..e1efd9b4c Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Configuration.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Configuration.dll new file mode 100644 index 000000000..8e4cfc0ce Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Configuration.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Console.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Console.dll new file mode 100644 index 000000000..82d92c870 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Console.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Core.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Core.dll new file mode 100644 index 000000000..2739938e3 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Core.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.Common.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.Common.dll new file mode 100644 index 000000000..5f38c52b3 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.Common.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.DataSetExtensions.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.DataSetExtensions.dll new file mode 100644 index 000000000..c6e1048c7 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.DataSetExtensions.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.dll new file mode 100644 index 000000000..3be9bcf26 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Contracts.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Contracts.dll new file mode 100644 index 000000000..716166a8b Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Contracts.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Debug.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Debug.dll new file mode 100644 index 000000000..a5967d06b Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Debug.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.DiagnosticSource.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.DiagnosticSource.dll new file mode 100644 index 000000000..2d5ac1c47 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.DiagnosticSource.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.FileVersionInfo.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.FileVersionInfo.dll new file mode 100644 index 000000000..2ec414c3a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.FileVersionInfo.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Process.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Process.dll new file mode 100644 index 000000000..b09232333 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Process.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.StackTrace.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.StackTrace.dll new file mode 100644 index 000000000..7f09098e9 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.StackTrace.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TextWriterTraceListener.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TextWriterTraceListener.dll new file mode 100644 index 000000000..320cfc7ae Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TextWriterTraceListener.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tools.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tools.dll new file mode 100644 index 000000000..0a3db380a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tools.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TraceSource.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TraceSource.dll new file mode 100644 index 000000000..a91679c54 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TraceSource.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tracing.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tracing.dll new file mode 100644 index 000000000..ce7eca9e6 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tracing.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.Primitives.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.Primitives.dll new file mode 100644 index 000000000..d2693ef31 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.Primitives.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.dll new file mode 100644 index 000000000..9c1e36ba2 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Dynamic.Runtime.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Dynamic.Runtime.dll new file mode 100644 index 000000000..60216621f Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Dynamic.Runtime.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Formats.Asn1.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Formats.Asn1.dll new file mode 100644 index 000000000..98f92ab95 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Formats.Asn1.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Calendars.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Calendars.dll new file mode 100644 index 000000000..a4dbf1092 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Calendars.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Extensions.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Extensions.dll new file mode 100644 index 000000000..a58cda857 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Extensions.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.dll new file mode 100644 index 000000000..ac4f221b6 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Brotli.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Brotli.dll new file mode 100644 index 000000000..30f43d4af Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Brotli.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.FileSystem.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.FileSystem.dll new file mode 100644 index 000000000..b823d9348 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.FileSystem.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.ZipFile.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.ZipFile.dll new file mode 100644 index 000000000..4cc00bdbd Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.ZipFile.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.dll new file mode 100644 index 000000000..fd99e3586 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.AccessControl.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.AccessControl.dll new file mode 100644 index 000000000..7f7143f47 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.AccessControl.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.DriveInfo.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.DriveInfo.dll new file mode 100644 index 000000000..ddc56c98e Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.DriveInfo.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Primitives.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Primitives.dll new file mode 100644 index 000000000..ea46fc4a3 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Primitives.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Watcher.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Watcher.dll new file mode 100644 index 000000000..16852830c Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Watcher.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.dll new file mode 100644 index 000000000..e698f3f18 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.IsolatedStorage.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.IsolatedStorage.dll new file mode 100644 index 000000000..ad7b163cb Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.IsolatedStorage.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.MemoryMappedFiles.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.MemoryMappedFiles.dll new file mode 100644 index 000000000..a652ebca1 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.MemoryMappedFiles.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.AccessControl.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.AccessControl.dll new file mode 100644 index 000000000..e59c2fdbc Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.AccessControl.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.dll new file mode 100644 index 000000000..d73985f5a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.UnmanagedMemoryStream.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.UnmanagedMemoryStream.dll new file mode 100644 index 000000000..5723a5c6e Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.UnmanagedMemoryStream.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.dll new file mode 100644 index 000000000..c2e4c13d9 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Expressions.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Expressions.dll new file mode 100644 index 000000000..e59b38d6c Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Expressions.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Parallel.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Parallel.dll new file mode 100644 index 000000000..0f469b755 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Parallel.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Queryable.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Queryable.dll new file mode 100644 index 000000000..9efb34149 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Queryable.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.dll new file mode 100644 index 000000000..039efacd1 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Memory.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Memory.dll new file mode 100644 index 000000000..8f02ec732 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Memory.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.Json.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.Json.dll new file mode 100644 index 000000000..7b29bd258 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.Json.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.dll new file mode 100644 index 000000000..e9e5dfc12 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.HttpListener.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.HttpListener.dll new file mode 100644 index 000000000..69b5a9405 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.HttpListener.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Mail.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Mail.dll new file mode 100644 index 000000000..0167f8007 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Mail.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NameResolution.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NameResolution.dll new file mode 100644 index 000000000..daa7c0b0d Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NameResolution.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NetworkInformation.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NetworkInformation.dll new file mode 100644 index 000000000..f48af46b0 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NetworkInformation.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Ping.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Ping.dll new file mode 100644 index 000000000..033988724 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Ping.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Primitives.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Primitives.dll new file mode 100644 index 000000000..8065600ea Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Primitives.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Quic.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Quic.dll new file mode 100644 index 000000000..0e9561c81 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Quic.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Requests.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Requests.dll new file mode 100644 index 000000000..8673d22c8 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Requests.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Security.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Security.dll new file mode 100644 index 000000000..e8b015139 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Security.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.ServicePoint.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.ServicePoint.dll new file mode 100644 index 000000000..2fba32f26 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.ServicePoint.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Sockets.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Sockets.dll new file mode 100644 index 000000000..5f1362b73 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Sockets.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebClient.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebClient.dll new file mode 100644 index 000000000..f1e694830 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebClient.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebHeaderCollection.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebHeaderCollection.dll new file mode 100644 index 000000000..fab72c514 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebHeaderCollection.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebProxy.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebProxy.dll new file mode 100644 index 000000000..8064c5806 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebProxy.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.Client.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.Client.dll new file mode 100644 index 000000000..df0aac33a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.Client.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.dll new file mode 100644 index 000000000..36b56f231 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.dll new file mode 100644 index 000000000..448c6f5a4 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.Vectors.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.Vectors.dll new file mode 100644 index 000000000..b4de58620 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.Vectors.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.dll new file mode 100644 index 000000000..7a941030a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ObjectModel.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ObjectModel.dll new file mode 100644 index 000000000..87822e1e5 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ObjectModel.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.CoreLib.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.CoreLib.dll new file mode 100644 index 000000000..4676a651b Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.CoreLib.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.DataContractSerialization.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.DataContractSerialization.dll new file mode 100644 index 000000000..77537b5fb Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.DataContractSerialization.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Uri.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Uri.dll new file mode 100644 index 000000000..a3425f726 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Uri.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.Linq.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.Linq.dll new file mode 100644 index 000000000..f67f0ac75 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.Linq.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.dll new file mode 100644 index 000000000..f972bb49f Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.DispatchProxy.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.DispatchProxy.dll new file mode 100644 index 000000000..de31d2fd1 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.DispatchProxy.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.ILGeneration.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.ILGeneration.dll new file mode 100644 index 000000000..ae8f64a83 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.ILGeneration.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.Lightweight.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.Lightweight.dll new file mode 100644 index 000000000..cfcb42647 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.Lightweight.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.dll new file mode 100644 index 000000000..22acb580a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Extensions.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Extensions.dll new file mode 100644 index 000000000..41084ab93 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Extensions.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Metadata.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Metadata.dll new file mode 100644 index 000000000..b0abfdf9c Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Metadata.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Primitives.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Primitives.dll new file mode 100644 index 000000000..648b50cc7 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Primitives.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.TypeExtensions.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.TypeExtensions.dll new file mode 100644 index 000000000..2a51e0491 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.TypeExtensions.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.dll new file mode 100644 index 000000000..c0058a31b Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Reader.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Reader.dll new file mode 100644 index 000000000..b6ca3634c Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Reader.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.ResourceManager.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.ResourceManager.dll new file mode 100644 index 000000000..abe9a8d6d Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.ResourceManager.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Writer.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Writer.dll new file mode 100644 index 000000000..069942f9b Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Writer.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.Unsafe.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.Unsafe.dll new file mode 100644 index 000000000..413cd6509 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.Unsafe.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.VisualC.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.VisualC.dll new file mode 100644 index 000000000..f8d37fb83 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.VisualC.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Extensions.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Extensions.dll new file mode 100644 index 000000000..a89ba4261 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Extensions.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Handles.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Handles.dll new file mode 100644 index 000000000..5b2095e04 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Handles.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.RuntimeInformation.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.RuntimeInformation.dll new file mode 100644 index 000000000..bec201951 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.RuntimeInformation.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.dll new file mode 100644 index 000000000..236ab2f6b Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Intrinsics.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Intrinsics.dll new file mode 100644 index 000000000..748adaf7a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Intrinsics.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Loader.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Loader.dll new file mode 100644 index 000000000..46beec379 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Loader.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Numerics.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Numerics.dll new file mode 100644 index 000000000..9a17d07ba Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Numerics.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Formatters.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Formatters.dll new file mode 100644 index 000000000..f6693a33b Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Formatters.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Json.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Json.dll new file mode 100644 index 000000000..6350e21af Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Json.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Primitives.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Primitives.dll new file mode 100644 index 000000000..a0b85367e Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Primitives.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Xml.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Xml.dll new file mode 100644 index 000000000..df4e4cd47 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Xml.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.dll new file mode 100644 index 000000000..a6ff569f9 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.dll new file mode 100644 index 000000000..180f182b9 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.AccessControl.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.AccessControl.dll new file mode 100644 index 000000000..50242fc3a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.AccessControl.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Claims.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Claims.dll new file mode 100644 index 000000000..4627e53e8 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Claims.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Algorithms.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Algorithms.dll new file mode 100644 index 000000000..9a1156a6c Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Algorithms.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Cng.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Cng.dll new file mode 100644 index 000000000..90b2962dc Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Cng.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Csp.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Csp.dll new file mode 100644 index 000000000..2b55c2f7f Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Csp.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Encoding.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Encoding.dll new file mode 100644 index 000000000..b67d39b72 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Encoding.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.OpenSsl.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.OpenSsl.dll new file mode 100644 index 000000000..16c1b958d Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.OpenSsl.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Primitives.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Primitives.dll new file mode 100644 index 000000000..f0c0d0845 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Primitives.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.X509Certificates.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.X509Certificates.dll new file mode 100644 index 000000000..95116d578 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.X509Certificates.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.Windows.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.Windows.dll new file mode 100644 index 000000000..8d975be19 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.Windows.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.dll new file mode 100644 index 000000000..0580407db Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.SecureString.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.SecureString.dll new file mode 100644 index 000000000..d9c9d8f6a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.SecureString.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.dll new file mode 100644 index 000000000..2fd2db4f7 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceModel.Web.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceModel.Web.dll new file mode 100644 index 000000000..96f15a625 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceModel.Web.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceProcess.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceProcess.dll new file mode 100644 index 000000000..187fbe741 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceProcess.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.CodePages.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.CodePages.dll new file mode 100644 index 000000000..aeee9ac22 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.CodePages.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.Extensions.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.Extensions.dll new file mode 100644 index 000000000..4a1c9a527 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.Extensions.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.dll new file mode 100644 index 000000000..007b15bc4 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encodings.Web.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encodings.Web.dll new file mode 100644 index 000000000..c96f9b1da Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encodings.Web.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Json.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Json.dll new file mode 100644 index 000000000..2fd81746e Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Json.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.RegularExpressions.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.RegularExpressions.dll new file mode 100644 index 000000000..5054ef124 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.RegularExpressions.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Channels.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Channels.dll new file mode 100644 index 000000000..8828079ad Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Channels.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Overlapped.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Overlapped.dll new file mode 100644 index 000000000..fd098004e Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Overlapped.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Dataflow.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Dataflow.dll new file mode 100644 index 000000000..6b433765a Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Dataflow.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Extensions.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Extensions.dll new file mode 100644 index 000000000..a25c84bab Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Extensions.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Parallel.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Parallel.dll new file mode 100644 index 000000000..5eb4c0d77 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Parallel.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.dll new file mode 100644 index 000000000..69c2130ef Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Thread.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Thread.dll new file mode 100644 index 000000000..cafa7d1df Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Thread.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.ThreadPool.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.ThreadPool.dll new file mode 100644 index 000000000..e29476efc Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.ThreadPool.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Timer.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Timer.dll new file mode 100644 index 000000000..62b848d81 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Timer.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.dll new file mode 100644 index 000000000..5b92a7dcc Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Transactions.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Transactions.dll new file mode 100644 index 000000000..72e0c1a91 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Transactions.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ValueTuple.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ValueTuple.dll new file mode 100644 index 000000000..77d85e2c1 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ValueTuple.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.HttpUtility.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.HttpUtility.dll new file mode 100644 index 000000000..d9e22aa84 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.HttpUtility.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.dll new file mode 100644 index 000000000..5caa0cc28 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Windows.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Windows.dll new file mode 100644 index 000000000..2e9bea0f4 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Windows.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Linq.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Linq.dll new file mode 100644 index 000000000..05a3f17e2 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Linq.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.ReaderWriter.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.ReaderWriter.dll new file mode 100644 index 000000000..c579e21a2 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.ReaderWriter.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Serialization.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Serialization.dll new file mode 100644 index 000000000..61061c1c0 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Serialization.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XDocument.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XDocument.dll new file mode 100644 index 000000000..f9a201873 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XDocument.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.XDocument.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.XDocument.dll new file mode 100644 index 000000000..c54d0a932 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.XDocument.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.dll new file mode 100644 index 000000000..44a95ecdb Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlDocument.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlDocument.dll new file mode 100644 index 000000000..a18cca47e Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlDocument.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlSerializer.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlSerializer.dll new file mode 100644 index 000000000..e1a34d84d Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlSerializer.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.dll new file mode 100644 index 000000000..1b3bab314 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.dll new file mode 100644 index 000000000..3b19f2626 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/WindowsBase.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/WindowsBase.dll new file mode 100644 index 000000000..035dd6032 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/WindowsBase.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/createdump b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/createdump new file mode 100644 index 000000000..c3fb6784e Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/createdump differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Globalization.Native.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Globalization.Native.so new file mode 100644 index 000000000..63383d59d Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Globalization.Native.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.IO.Compression.Native.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.IO.Compression.Native.so new file mode 100644 index 000000000..ae5617c5b Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.IO.Compression.Native.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Native.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Native.so new file mode 100644 index 000000000..3137d7a71 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Native.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Net.Security.Native.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Net.Security.Native.so new file mode 100644 index 000000000..22c93d8d4 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Net.Security.Native.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Security.Cryptography.Native.OpenSsl.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Security.Cryptography.Native.OpenSsl.so new file mode 100644 index 000000000..c8b3db724 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Security.Cryptography.Native.OpenSsl.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libclrjit.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libclrjit.so new file mode 100644 index 000000000..51f9fd1d6 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libclrjit.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libcoreclr.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libcoreclr.so new file mode 100644 index 000000000..a75586ebe Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libcoreclr.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libcoreclrtraceptprovider.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libcoreclrtraceptprovider.so new file mode 100644 index 000000000..b2bd87a4e Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libcoreclrtraceptprovider.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libdbgshim.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libdbgshim.so new file mode 100644 index 000000000..700afabc5 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libdbgshim.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libhostpolicy.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libhostpolicy.so new file mode 100644 index 000000000..aa30f4fdb Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libhostpolicy.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordaccore.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordaccore.so new file mode 100644 index 000000000..27d12823f Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordaccore.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordbi.so b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordbi.so new file mode 100644 index 000000000..ec27f020d Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordbi.so differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorlib.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorlib.dll new file mode 100644 index 000000000..17bbf435f Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorlib.dll differ diff --git a/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/netstandard.dll b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/netstandard.dll new file mode 100644 index 000000000..405caa073 Binary files /dev/null and b/Dependencies/Dotnet/linux/x86_64/shared/Microsoft.NETCore.App/6.0.25/netstandard.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/dotnet b/Dependencies/Dotnet/macos/x86_64/dotnet new file mode 100644 index 000000000..fa5b47d9a Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/dotnet differ diff --git a/Dependencies/Dotnet/macos/x86_64/host/fxr/6.0.25/libhostfxr.dylib b/Dependencies/Dotnet/macos/x86_64/host/fxr/6.0.25/libhostfxr.dylib new file mode 100644 index 000000000..5960e0c6d Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/host/fxr/6.0.25/libhostfxr.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/.version b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/.version new file mode 100644 index 000000000..dbb688f01 --- /dev/null +++ b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/.version @@ -0,0 +1,2 @@ +492abbeef0d8a6ea902ac8f90ed339c7b1d18bf4 +6.0.25 diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.CSharp.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.CSharp.dll new file mode 100644 index 000000000..3cb6ac81f Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.CSharp.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.deps.json b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.deps.json new file mode 100644 index 000000000..b1b947c91 --- /dev/null +++ b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.deps.json @@ -0,0 +1,914 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v6.0/osx-x64", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v6.0": {}, + ".NETCoreApp,Version=v6.0/osx-x64": { + "Microsoft.NETCore.App.Runtime.osx-x64/6.0.25": { + "runtime": { + "System.Private.CoreLib.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.VisualBasic.dll": { + "assemblyVersion": "10.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "mscorlib.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "netstandard.dll": { + "assemblyVersion": "2.1.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.AppContext.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Buffers.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.DataAnnotations.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Configuration.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Core.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Data.DataSetExtensions.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Data.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Contracts.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Debug.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Tools.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Tracing.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Drawing.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Dynamic.Runtime.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Globalization.Calendars.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Globalization.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Globalization.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.FileSystem.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.UnmanagedMemoryStream.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Numerics.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Numerics.Vectors.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Emit.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Emit.ILGeneration.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Emit.Lightweight.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Resources.Reader.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Resources.ResourceManager.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Handles.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Intrinsics.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Loader.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Json.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Xml.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Principal.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.SecureString.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ServiceModel.Web.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ServiceProcess.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encoding.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encoding.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Overlapped.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Thread.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.ThreadPool.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Timer.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Transactions.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ValueTuple.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Web.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Windows.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.Linq.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.ReaderWriter.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.Serialization.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XDocument.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XmlDocument.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XmlSerializer.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XPath.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "WindowsBase.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.CSharp.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.VisualBasic.Core.dll": { + "assemblyVersion": "11.0.0.0", + "fileVersion": "11.100.2523.51912" + }, + "Microsoft.Win32.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.Win32.Registry.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.Concurrent.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.Immutable.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.NonGeneric.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.Specialized.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.Annotations.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.EventBasedAsync.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.TypeConverter.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Console.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Data.Common.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.DiagnosticSource.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.FileVersionInfo.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Process.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.StackTrace.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.TextWriterTraceListener.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.TraceSource.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Drawing.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Formats.Asn1.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.Brotli.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.ZipFile.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.AccessControl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.DriveInfo.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.Watcher.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.IsolatedStorage.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.MemoryMappedFiles.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Pipes.AccessControl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Pipes.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.Expressions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.Parallel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.Queryable.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Memory.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Http.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Http.Json.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.HttpListener.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Mail.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.NameResolution.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.NetworkInformation.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Ping.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Quic.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Requests.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Security.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.ServicePoint.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Sockets.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebClient.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebHeaderCollection.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebProxy.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebSockets.Client.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebSockets.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ObjectModel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.DataContractSerialization.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.Uri.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.Xml.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.Xml.Linq.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.DispatchProxy.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Metadata.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.TypeExtensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Resources.Writer.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.CompilerServices.Unsafe.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.CompilerServices.VisualC.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.InteropServices.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.InteropServices.RuntimeInformation.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Numerics.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Formatters.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.AccessControl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Claims.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Algorithms.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Cng.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Csp.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Encoding.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.OpenSsl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.X509Certificates.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Principal.Windows.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encoding.CodePages.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encodings.Web.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Json.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.RegularExpressions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Channels.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.Dataflow.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.Parallel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Transactions.Local.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Web.HttpUtility.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XPath.XDocument.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + } + }, + "native": { + "createdump": { + "fileVersion": "0.0.0.0" + }, + "libclrjit.dylib": { + "fileVersion": "0.0.0.0" + }, + "libcoreclr.dylib": { + "fileVersion": "0.0.0.0" + }, + "libdbgshim.dylib": { + "fileVersion": "0.0.0.0" + }, + "libmscordaccore.dylib": { + "fileVersion": "0.0.0.0" + }, + "libmscordbi.dylib": { + "fileVersion": "0.0.0.0" + }, + "libSystem.Globalization.Native.dylib": { + "fileVersion": "0.0.0.0" + }, + "libSystem.IO.Compression.Native.dylib": { + "fileVersion": "0.0.0.0" + }, + "libSystem.Native.dylib": { + "fileVersion": "0.0.0.0" + }, + "libSystem.Net.Security.Native.dylib": { + "fileVersion": "0.0.0.0" + }, + "libSystem.Security.Cryptography.Native.Apple.dylib": { + "fileVersion": "0.0.0.0" + }, + "libSystem.Security.Cryptography.Native.OpenSsl.dylib": { + "fileVersion": "0.0.0.0" + }, + "libhostpolicy.dylib": { + "fileVersion": "0.0.0.0" + } + } + } + } + }, + "libraries": { + "Microsoft.NETCore.App.Runtime.osx-x64/6.0.25": { + "type": "package", + "serviceable": true, + "sha512": "", + "path": "microsoft.netcore.app.runtime.osx-x64/6.0.25" + } + }, + "runtimes": { + "osx-x64": [ + "osx", + "unix-x64", + "unix", + "any", + "base" + ], + "osx.10.10-x64": [ + "osx.10.10", + "osx-x64", + "osx", + "unix-x64", + "unix", + "any", + "base" + ], + "osx.10.11-x64": [ + "osx.10.11", + "osx.10.10-x64", + "osx.10.10", + "osx-x64", + "osx", + "unix-x64", + "unix", + "any", + "base" + ], + "osx.10.12-x64": [ + "osx.10.12", + "osx.10.11-x64", + "osx.10.11", + "osx.10.10-x64", + "osx.10.10", + "osx-x64", + "osx", + "unix-x64", + "unix", + "any", + "base" + ], + "osx.10.13-x64": [ + "osx.10.13", + "osx.10.12-x64", + "osx.10.12", + "osx.10.11-x64", + "osx.10.11", + "osx.10.10-x64", + "osx.10.10", + "osx-x64", + "osx", + "unix-x64", + "unix", + "any", + "base" + ], + "osx.10.14-x64": [ + "osx.10.14", + "osx.10.13-x64", + "osx.10.13", + "osx.10.12-x64", + "osx.10.12", + "osx.10.11-x64", + "osx.10.11", + "osx.10.10-x64", + "osx.10.10", + "osx-x64", + "osx", + "unix-x64", + "unix", + "any", + "base" + ], + "osx.10.15-x64": [ + "osx.10.15", + "osx.10.14-x64", + "osx.10.14", + "osx.10.13-x64", + "osx.10.13", + "osx.10.12-x64", + "osx.10.12", + "osx.10.11-x64", + "osx.10.11", + "osx.10.10-x64", + "osx.10.10", + "osx-x64", + "osx", + "unix-x64", + "unix", + "any", + "base" + ], + "osx.10.16-x64": [ + "osx.10.16", + "osx.10.15-x64", + "osx.10.15", + "osx.10.14-x64", + "osx.10.14", + "osx.10.13-x64", + "osx.10.13", + "osx.10.12-x64", + "osx.10.12", + "osx.10.11-x64", + "osx.10.11", + "osx.10.10-x64", + "osx.10.10", + "osx-x64", + "osx", + "unix-x64", + "unix", + "any", + "base" + ], + "osx.11.0-x64": [ + "osx.11.0", + "osx.10.16-x64", + "osx.10.16", + "osx.10.15-x64", + "osx.10.15", + "osx.10.14-x64", + "osx.10.14", + "osx.10.13-x64", + "osx.10.13", + "osx.10.12-x64", + "osx.10.12", + "osx.10.11-x64", + "osx.10.11", + "osx.10.10-x64", + "osx.10.10", + "osx-x64", + "osx", + "unix-x64", + "unix", + "any", + "base" + ], + "osx.12-x64": [ + "osx.12", + "osx.11.0-x64", + "osx.11.0", + "osx.10.16-x64", + "osx.10.16", + "osx.10.15-x64", + "osx.10.15", + "osx.10.14-x64", + "osx.10.14", + "osx.10.13-x64", + "osx.10.13", + "osx.10.12-x64", + "osx.10.12", + "osx.10.11-x64", + "osx.10.11", + "osx.10.10-x64", + "osx.10.10", + "osx-x64", + "osx", + "unix-x64", + "unix", + "any", + "base" + ], + "osx.13-x64": [ + "osx.13", + "osx.12-x64", + "osx.12", + "osx.11.0-x64", + "osx.11.0", + "osx.10.16-x64", + "osx.10.16", + "osx.10.15-x64", + "osx.10.15", + "osx.10.14-x64", + "osx.10.14", + "osx.10.13-x64", + "osx.10.13", + "osx.10.12-x64", + "osx.10.12", + "osx.10.11-x64", + "osx.10.11", + "osx.10.10-x64", + "osx.10.10", + "osx-x64", + "osx", + "unix-x64", + "unix", + "any", + "base" + ] + } +} \ No newline at end of file diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.runtimeconfig.json b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.runtimeconfig.json new file mode 100644 index 000000000..3d37d8e97 --- /dev/null +++ b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.runtimeconfig.json @@ -0,0 +1,8 @@ +{ + "runtimeOptions": { + "tfm": "net6.0", + "configProperties": { + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false + } + } +} \ No newline at end of file diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.Core.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.Core.dll new file mode 100644 index 000000000..586481c7a Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.Core.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.dll new file mode 100644 index 000000000..fbdadfd2e Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Primitives.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Primitives.dll new file mode 100644 index 000000000..26c45584c Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Primitives.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Registry.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Registry.dll new file mode 100644 index 000000000..f895b56bb Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Registry.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.AppContext.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.AppContext.dll new file mode 100644 index 000000000..e8f2fc539 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.AppContext.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Buffers.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Buffers.dll new file mode 100644 index 000000000..0196cc9a1 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Buffers.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Concurrent.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Concurrent.dll new file mode 100644 index 000000000..061124eb1 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Concurrent.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Immutable.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Immutable.dll new file mode 100644 index 000000000..025a68a78 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Immutable.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.NonGeneric.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.NonGeneric.dll new file mode 100644 index 000000000..8007b5bdd Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.NonGeneric.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Specialized.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Specialized.dll new file mode 100644 index 000000000..7c5ca8bd7 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Specialized.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.dll new file mode 100644 index 000000000..71add62b6 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Annotations.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Annotations.dll new file mode 100644 index 000000000..4fbccb35a Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Annotations.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.DataAnnotations.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.DataAnnotations.dll new file mode 100644 index 000000000..c6492fbeb Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.DataAnnotations.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.EventBasedAsync.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.EventBasedAsync.dll new file mode 100644 index 000000000..ee5f603ce Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.EventBasedAsync.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Primitives.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Primitives.dll new file mode 100644 index 000000000..bd546abe1 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Primitives.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.TypeConverter.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.TypeConverter.dll new file mode 100644 index 000000000..489fc0ea2 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.TypeConverter.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.dll new file mode 100644 index 000000000..71c17d134 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Configuration.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Configuration.dll new file mode 100644 index 000000000..8e4cfc0ce Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Configuration.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Console.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Console.dll new file mode 100644 index 000000000..623fb9991 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Console.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Core.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Core.dll new file mode 100644 index 000000000..2739938e3 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Core.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.Common.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.Common.dll new file mode 100644 index 000000000..750371d2c Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.Common.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.DataSetExtensions.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.DataSetExtensions.dll new file mode 100644 index 000000000..63ff514fc Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.DataSetExtensions.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.dll new file mode 100644 index 000000000..47a5fcbbd Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Contracts.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Contracts.dll new file mode 100644 index 000000000..15a6f568c Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Contracts.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Debug.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Debug.dll new file mode 100644 index 000000000..1fb8f11c0 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Debug.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.DiagnosticSource.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.DiagnosticSource.dll new file mode 100644 index 000000000..2d03381ed Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.DiagnosticSource.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.FileVersionInfo.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.FileVersionInfo.dll new file mode 100644 index 000000000..ed86f68a2 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.FileVersionInfo.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Process.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Process.dll new file mode 100644 index 000000000..94f9fa680 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Process.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.StackTrace.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.StackTrace.dll new file mode 100644 index 000000000..c1790549e Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.StackTrace.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TextWriterTraceListener.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TextWriterTraceListener.dll new file mode 100644 index 000000000..5540f63a7 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TextWriterTraceListener.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tools.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tools.dll new file mode 100644 index 000000000..a7edbfc78 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tools.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TraceSource.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TraceSource.dll new file mode 100644 index 000000000..d6b8d9d45 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TraceSource.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tracing.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tracing.dll new file mode 100644 index 000000000..f607d7037 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tracing.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.Primitives.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.Primitives.dll new file mode 100644 index 000000000..2f75ed5f4 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.Primitives.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.dll new file mode 100644 index 000000000..9c1e36ba2 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Dynamic.Runtime.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Dynamic.Runtime.dll new file mode 100644 index 000000000..4a4992548 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Dynamic.Runtime.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Formats.Asn1.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Formats.Asn1.dll new file mode 100644 index 000000000..06ae1abcf Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Formats.Asn1.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Calendars.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Calendars.dll new file mode 100644 index 000000000..6f816f714 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Calendars.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Extensions.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Extensions.dll new file mode 100644 index 000000000..261cfe64b Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Extensions.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.dll new file mode 100644 index 000000000..ec25faec4 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Brotli.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Brotli.dll new file mode 100644 index 000000000..4b1c0f4f6 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Brotli.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.FileSystem.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.FileSystem.dll new file mode 100644 index 000000000..b823d9348 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.FileSystem.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.ZipFile.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.ZipFile.dll new file mode 100644 index 000000000..faab69b9d Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.ZipFile.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.dll new file mode 100644 index 000000000..540659dc2 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.AccessControl.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.AccessControl.dll new file mode 100644 index 000000000..67bbe226e Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.AccessControl.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.DriveInfo.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.DriveInfo.dll new file mode 100644 index 000000000..60c6f8f8e Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.DriveInfo.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Primitives.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Primitives.dll new file mode 100644 index 000000000..be39551a8 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Primitives.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Watcher.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Watcher.dll new file mode 100644 index 000000000..7b6b3a605 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Watcher.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.dll new file mode 100644 index 000000000..e76eabab0 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.IsolatedStorage.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.IsolatedStorage.dll new file mode 100644 index 000000000..7eea3e0f7 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.IsolatedStorage.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.MemoryMappedFiles.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.MemoryMappedFiles.dll new file mode 100644 index 000000000..4838f5d18 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.MemoryMappedFiles.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.AccessControl.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.AccessControl.dll new file mode 100644 index 000000000..74a260177 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.AccessControl.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.dll new file mode 100644 index 000000000..a5848ee3e Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.UnmanagedMemoryStream.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.UnmanagedMemoryStream.dll new file mode 100644 index 000000000..6c034a1bc Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.UnmanagedMemoryStream.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.dll new file mode 100644 index 000000000..2e03a00b5 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Expressions.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Expressions.dll new file mode 100644 index 000000000..addf68640 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Expressions.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Parallel.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Parallel.dll new file mode 100644 index 000000000..01b506d09 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Parallel.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Queryable.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Queryable.dll new file mode 100644 index 000000000..56d3dbcb1 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Queryable.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.dll new file mode 100644 index 000000000..578cff021 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Memory.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Memory.dll new file mode 100644 index 000000000..7a34ea211 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Memory.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.Json.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.Json.dll new file mode 100644 index 000000000..133c3dfde Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.Json.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.dll new file mode 100644 index 000000000..5d884115b Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.HttpListener.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.HttpListener.dll new file mode 100644 index 000000000..47d04c8c1 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.HttpListener.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Mail.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Mail.dll new file mode 100644 index 000000000..a7cb6eaa0 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Mail.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NameResolution.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NameResolution.dll new file mode 100644 index 000000000..9f6175a51 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NameResolution.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NetworkInformation.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NetworkInformation.dll new file mode 100644 index 000000000..7a792120e Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NetworkInformation.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Ping.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Ping.dll new file mode 100644 index 000000000..964199441 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Ping.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Primitives.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Primitives.dll new file mode 100644 index 000000000..845301d5e Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Primitives.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Quic.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Quic.dll new file mode 100644 index 000000000..7d2ee02f6 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Quic.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Requests.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Requests.dll new file mode 100644 index 000000000..64febfa9c Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Requests.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Security.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Security.dll new file mode 100644 index 000000000..76ab67a87 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Security.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.ServicePoint.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.ServicePoint.dll new file mode 100644 index 000000000..89cee5fde Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.ServicePoint.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Sockets.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Sockets.dll new file mode 100644 index 000000000..65f09a835 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Sockets.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebClient.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebClient.dll new file mode 100644 index 000000000..48ca2d085 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebClient.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebHeaderCollection.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebHeaderCollection.dll new file mode 100644 index 000000000..1557fba2d Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebHeaderCollection.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebProxy.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebProxy.dll new file mode 100644 index 000000000..fcd8c8022 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebProxy.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.Client.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.Client.dll new file mode 100644 index 000000000..f5d27e98e Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.Client.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.dll new file mode 100644 index 000000000..1f5489824 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.dll new file mode 100644 index 000000000..448c6f5a4 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.Vectors.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.Vectors.dll new file mode 100644 index 000000000..f051ecf96 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.Vectors.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.dll new file mode 100644 index 000000000..7a941030a Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ObjectModel.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ObjectModel.dll new file mode 100644 index 000000000..e997c2cdb Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ObjectModel.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.CoreLib.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.CoreLib.dll new file mode 100644 index 000000000..85577fe7c Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.CoreLib.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.DataContractSerialization.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.DataContractSerialization.dll new file mode 100644 index 000000000..2177d618d Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.DataContractSerialization.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Uri.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Uri.dll new file mode 100644 index 000000000..36e028ac2 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Uri.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.Linq.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.Linq.dll new file mode 100644 index 000000000..6c0bf6c5d Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.Linq.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.dll new file mode 100644 index 000000000..765d951a2 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.DispatchProxy.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.DispatchProxy.dll new file mode 100644 index 000000000..0f47aca07 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.DispatchProxy.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.ILGeneration.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.ILGeneration.dll new file mode 100644 index 000000000..762227ea1 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.ILGeneration.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.Lightweight.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.Lightweight.dll new file mode 100644 index 000000000..109fe0927 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.Lightweight.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.dll new file mode 100644 index 000000000..e9b1e6504 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Extensions.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Extensions.dll new file mode 100644 index 000000000..e671ab60c Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Extensions.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Metadata.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Metadata.dll new file mode 100644 index 000000000..e5ef48e62 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Metadata.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Primitives.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Primitives.dll new file mode 100644 index 000000000..ebb5b5d34 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Primitives.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.TypeExtensions.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.TypeExtensions.dll new file mode 100644 index 000000000..a8f430f3d Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.TypeExtensions.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.dll new file mode 100644 index 000000000..01b5a849e Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Reader.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Reader.dll new file mode 100644 index 000000000..76bae1207 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Reader.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.ResourceManager.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.ResourceManager.dll new file mode 100644 index 000000000..47bb1e97f Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.ResourceManager.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Writer.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Writer.dll new file mode 100644 index 000000000..0300e6543 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Writer.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.Unsafe.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.Unsafe.dll new file mode 100644 index 000000000..1a98641bc Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.Unsafe.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.VisualC.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.VisualC.dll new file mode 100644 index 000000000..72d319b1a Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.VisualC.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Extensions.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Extensions.dll new file mode 100644 index 000000000..9e66d8462 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Extensions.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Handles.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Handles.dll new file mode 100644 index 000000000..614b8c091 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Handles.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.RuntimeInformation.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.RuntimeInformation.dll new file mode 100644 index 000000000..5e507a02a Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.RuntimeInformation.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.dll new file mode 100644 index 000000000..7d8154dab Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Intrinsics.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Intrinsics.dll new file mode 100644 index 000000000..4d1a86525 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Intrinsics.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Loader.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Loader.dll new file mode 100644 index 000000000..82449af46 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Loader.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Numerics.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Numerics.dll new file mode 100644 index 000000000..a9f1b6a14 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Numerics.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Formatters.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Formatters.dll new file mode 100644 index 000000000..0b4f1683a Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Formatters.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Json.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Json.dll new file mode 100644 index 000000000..2a076f9f3 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Json.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Primitives.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Primitives.dll new file mode 100644 index 000000000..50a8e481d Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Primitives.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Xml.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Xml.dll new file mode 100644 index 000000000..6c3a55179 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Xml.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.dll new file mode 100644 index 000000000..a6ff569f9 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.dll new file mode 100644 index 000000000..555054d50 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.AccessControl.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.AccessControl.dll new file mode 100644 index 000000000..4c7c4a8de Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.AccessControl.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Claims.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Claims.dll new file mode 100644 index 000000000..ae1acd649 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Claims.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Algorithms.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Algorithms.dll new file mode 100644 index 000000000..4851c9f8d Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Algorithms.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Cng.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Cng.dll new file mode 100644 index 000000000..0cb99f3a1 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Cng.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Csp.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Csp.dll new file mode 100644 index 000000000..40de61b7b Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Csp.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Encoding.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Encoding.dll new file mode 100644 index 000000000..64a430967 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Encoding.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.OpenSsl.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.OpenSsl.dll new file mode 100644 index 000000000..961333c29 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.OpenSsl.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Primitives.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Primitives.dll new file mode 100644 index 000000000..131c8e558 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Primitives.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.X509Certificates.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.X509Certificates.dll new file mode 100644 index 000000000..a3b15ce9a Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.X509Certificates.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.Windows.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.Windows.dll new file mode 100644 index 000000000..f507e0c6d Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.Windows.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.dll new file mode 100644 index 000000000..13f93f3c8 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.SecureString.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.SecureString.dll new file mode 100644 index 000000000..cda5f5bca Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.SecureString.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.dll new file mode 100644 index 000000000..2fd2db4f7 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceModel.Web.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceModel.Web.dll new file mode 100644 index 000000000..96f15a625 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceModel.Web.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceProcess.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceProcess.dll new file mode 100644 index 000000000..187fbe741 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceProcess.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.CodePages.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.CodePages.dll new file mode 100644 index 000000000..960dc7892 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.CodePages.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.Extensions.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.Extensions.dll new file mode 100644 index 000000000..0ff34d685 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.Extensions.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.dll new file mode 100644 index 000000000..9adb2bfc0 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encodings.Web.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encodings.Web.dll new file mode 100644 index 000000000..8cf583ac7 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encodings.Web.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Json.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Json.dll new file mode 100644 index 000000000..776036bd0 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Json.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.RegularExpressions.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.RegularExpressions.dll new file mode 100644 index 000000000..10d745d44 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.RegularExpressions.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Channels.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Channels.dll new file mode 100644 index 000000000..63703edf8 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Channels.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Overlapped.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Overlapped.dll new file mode 100644 index 000000000..0ac006242 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Overlapped.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Dataflow.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Dataflow.dll new file mode 100644 index 000000000..44f212b1c Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Dataflow.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Extensions.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Extensions.dll new file mode 100644 index 000000000..2e4a19dfd Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Extensions.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Parallel.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Parallel.dll new file mode 100644 index 000000000..ce787d0b5 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Parallel.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.dll new file mode 100644 index 000000000..364cbf142 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Thread.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Thread.dll new file mode 100644 index 000000000..171ed4973 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Thread.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.ThreadPool.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.ThreadPool.dll new file mode 100644 index 000000000..380ed310d Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.ThreadPool.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Timer.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Timer.dll new file mode 100644 index 000000000..79664a7fd Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Timer.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.dll new file mode 100644 index 000000000..799f1fe59 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Transactions.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Transactions.dll new file mode 100644 index 000000000..72e0c1a91 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Transactions.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ValueTuple.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ValueTuple.dll new file mode 100644 index 000000000..25a0c0e5d Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ValueTuple.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.HttpUtility.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.HttpUtility.dll new file mode 100644 index 000000000..fd1e0ae88 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.HttpUtility.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.dll new file mode 100644 index 000000000..5caa0cc28 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Windows.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Windows.dll new file mode 100644 index 000000000..2e9bea0f4 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Windows.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Linq.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Linq.dll new file mode 100644 index 000000000..05a3f17e2 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Linq.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.ReaderWriter.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.ReaderWriter.dll new file mode 100644 index 000000000..ce70c33ed Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.ReaderWriter.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Serialization.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Serialization.dll new file mode 100644 index 000000000..61061c1c0 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Serialization.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XDocument.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XDocument.dll new file mode 100644 index 000000000..f34840717 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XDocument.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.XDocument.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.XDocument.dll new file mode 100644 index 000000000..e1f970ac6 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.XDocument.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.dll new file mode 100644 index 000000000..49d40ca3c Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlDocument.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlDocument.dll new file mode 100644 index 000000000..64bff2b45 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlDocument.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlSerializer.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlSerializer.dll new file mode 100644 index 000000000..0a9608917 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlSerializer.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.dll new file mode 100644 index 000000000..2ae1a9ce1 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.dll new file mode 100644 index 000000000..151db6ed6 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/WindowsBase.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/WindowsBase.dll new file mode 100644 index 000000000..035dd6032 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/WindowsBase.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/createdump b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/createdump new file mode 100644 index 000000000..c06274751 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/createdump differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Globalization.Native.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Globalization.Native.dylib new file mode 100644 index 000000000..b06e12827 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Globalization.Native.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.IO.Compression.Native.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.IO.Compression.Native.dylib new file mode 100644 index 000000000..fa2590b04 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.IO.Compression.Native.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Native.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Native.dylib new file mode 100644 index 000000000..d87e132f9 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Native.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Net.Security.Native.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Net.Security.Native.dylib new file mode 100644 index 000000000..1c82179dd Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Net.Security.Native.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Security.Cryptography.Native.Apple.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Security.Cryptography.Native.Apple.dylib new file mode 100644 index 000000000..edbcd03ae Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Security.Cryptography.Native.Apple.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Security.Cryptography.Native.OpenSsl.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Security.Cryptography.Native.OpenSsl.dylib new file mode 100644 index 000000000..39997a778 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libSystem.Security.Cryptography.Native.OpenSsl.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libclrjit.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libclrjit.dylib new file mode 100644 index 000000000..57070a7fd Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libclrjit.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libcoreclr.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libcoreclr.dylib new file mode 100644 index 000000000..81935bc48 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libcoreclr.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libdbgshim.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libdbgshim.dylib new file mode 100644 index 000000000..d83e45e8b Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libdbgshim.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libhostpolicy.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libhostpolicy.dylib new file mode 100644 index 000000000..6900e18a9 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libhostpolicy.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordaccore.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordaccore.dylib new file mode 100644 index 000000000..848e816ca Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordaccore.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordbi.dylib b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordbi.dylib new file mode 100644 index 000000000..732de51a7 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/libmscordbi.dylib differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorlib.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorlib.dll new file mode 100644 index 000000000..a523f08cc Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorlib.dll differ diff --git a/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/netstandard.dll b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/netstandard.dll new file mode 100644 index 000000000..405caa073 Binary files /dev/null and b/Dependencies/Dotnet/macos/x86_64/shared/Microsoft.NETCore.App/6.0.25/netstandard.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/dotnet.exe b/Dependencies/Dotnet/windows/x86_64/dotnet.exe new file mode 100644 index 000000000..8a422dbc1 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/dotnet.exe differ diff --git a/Dependencies/Dotnet/windows/x86_64/host/fxr/6.0.25/hostfxr.dll b/Dependencies/Dotnet/windows/x86_64/host/fxr/6.0.25/hostfxr.dll new file mode 100644 index 000000000..87e1d4a7e Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/host/fxr/6.0.25/hostfxr.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/.version b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/.version new file mode 100644 index 000000000..dbb688f01 --- /dev/null +++ b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/.version @@ -0,0 +1,2 @@ +492abbeef0d8a6ea902ac8f90ed339c7b1d18bf4 +6.0.25 diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.CSharp.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.CSharp.dll new file mode 100644 index 000000000..e55527081 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.CSharp.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.DiaSymReader.Native.amd64.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.DiaSymReader.Native.amd64.dll new file mode 100644 index 000000000..8181b5122 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.DiaSymReader.Native.amd64.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.deps.json b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.deps.json new file mode 100644 index 000000000..bc11ff16c --- /dev/null +++ b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.deps.json @@ -0,0 +1,981 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v6.0/win-x64", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v6.0": {}, + ".NETCoreApp,Version=v6.0/win-x64": { + "Microsoft.NETCore.App.Runtime.win-x64/6.0.25": { + "runtime": { + "System.Private.CoreLib.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.VisualBasic.dll": { + "assemblyVersion": "10.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "mscorlib.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "netstandard.dll": { + "assemblyVersion": "2.1.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.AppContext.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Buffers.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.DataAnnotations.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Configuration.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Core.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Data.DataSetExtensions.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Data.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Contracts.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Debug.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Tools.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Tracing.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Drawing.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Dynamic.Runtime.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Globalization.Calendars.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Globalization.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Globalization.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.FileSystem.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Pipes.AccessControl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.UnmanagedMemoryStream.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Numerics.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Numerics.Vectors.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Emit.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Emit.ILGeneration.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Emit.Lightweight.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Resources.Reader.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Resources.ResourceManager.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Handles.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Intrinsics.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Loader.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Json.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Xml.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Principal.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.SecureString.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ServiceModel.Web.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ServiceProcess.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encoding.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encoding.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Overlapped.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.Extensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Thread.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.ThreadPool.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Timer.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Transactions.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ValueTuple.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Web.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Windows.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.Linq.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.ReaderWriter.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.Serialization.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XDocument.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XmlDocument.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XmlSerializer.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XPath.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "WindowsBase.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.CSharp.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.VisualBasic.Core.dll": { + "assemblyVersion": "11.0.0.0", + "fileVersion": "11.100.2523.51912" + }, + "Microsoft.Win32.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.Win32.Registry.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.Concurrent.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.Immutable.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.NonGeneric.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Collections.Specialized.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.Annotations.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.EventBasedAsync.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ComponentModel.TypeConverter.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Console.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Data.Common.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.DiagnosticSource.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.FileVersionInfo.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.Process.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.StackTrace.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.TextWriterTraceListener.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Diagnostics.TraceSource.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Drawing.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Formats.Asn1.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.Brotli.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Compression.ZipFile.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.AccessControl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.DriveInfo.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.FileSystem.Watcher.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.IsolatedStorage.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.MemoryMappedFiles.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.IO.Pipes.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.Expressions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.Parallel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Linq.Queryable.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Memory.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Http.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Http.Json.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.HttpListener.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Mail.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.NameResolution.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.NetworkInformation.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Ping.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Quic.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Requests.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Security.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.ServicePoint.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.Sockets.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebClient.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebHeaderCollection.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebProxy.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebSockets.Client.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Net.WebSockets.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.ObjectModel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.DataContractSerialization.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.Uri.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.Xml.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Private.Xml.Linq.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.DispatchProxy.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.Metadata.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Reflection.TypeExtensions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Resources.Writer.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.CompilerServices.Unsafe.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.CompilerServices.VisualC.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.InteropServices.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.InteropServices.RuntimeInformation.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Numerics.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Formatters.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Runtime.Serialization.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.AccessControl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Claims.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Algorithms.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Cng.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Csp.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Encoding.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.OpenSsl.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.Primitives.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Cryptography.X509Certificates.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Security.Principal.Windows.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encoding.CodePages.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Encodings.Web.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.Json.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Text.RegularExpressions.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Channels.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.Dataflow.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Threading.Tasks.Parallel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Transactions.Local.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Web.HttpUtility.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + }, + "System.Xml.XPath.XDocument.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.2523.51912" + } + }, + "native": { + "clretwrc.dll": { + "fileVersion": "6.0.2523.51912" + }, + "clrjit.dll": { + "fileVersion": "6.0.2523.51912" + }, + "coreclr.dll": { + "fileVersion": "6.0.2523.51912" + }, + "createdump.exe": { + "fileVersion": "6.0.2523.51912" + }, + "dbgshim.dll": { + "fileVersion": "6.0.2523.51912" + }, + "mscordaccore.dll": { + "fileVersion": "6.0.2523.51912" + }, + "mscordaccore_amd64_amd64_6.0.2523.51912.dll": { + "fileVersion": "6.0.2523.51912" + }, + "mscordbi.dll": { + "fileVersion": "6.0.2523.51912" + }, + "mscorrc.dll": { + "fileVersion": "6.0.2523.51912" + }, + "api-ms-win-core-console-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-console-l1-2-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-datetime-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-debug-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-errorhandling-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-fibers-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-file-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-file-l1-2-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-file-l2-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-handle-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-heap-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-interlocked-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-libraryloader-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-localization-l1-2-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-memory-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-namedpipe-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-processenvironment-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-processthreads-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-processthreads-l1-1-1.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-profile-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-rtlsupport-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-string-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-synch-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-synch-l1-2-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-sysinfo-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-timezone-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-core-util-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-conio-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-convert-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-environment-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-filesystem-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-heap-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-locale-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-math-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-multibyte-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-private-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-process-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-runtime-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-stdio-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-string-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-time-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "api-ms-win-crt-utility-l1-1-0.dll": { + "fileVersion": "10.0.22000.194" + }, + "ucrtbase.dll": { + "fileVersion": "10.0.22000.194" + }, + "msquic.dll": { + "fileVersion": "1.9.1.0" + }, + "System.IO.Compression.Native.dll": { + "fileVersion": "42.42.42.42424" + }, + "hostpolicy.dll": { + "fileVersion": "6.0.2523.51912" + }, + "Microsoft.DiaSymReader.Native.amd64.dll": { + "fileVersion": "14.29.30152.0" + } + } + } + } + }, + "libraries": { + "Microsoft.NETCore.App.Runtime.win-x64/6.0.25": { + "type": "package", + "serviceable": true, + "sha512": "", + "path": "microsoft.netcore.app.runtime.win-x64/6.0.25" + } + }, + "runtimes": { + "win-x64": [ + "win", + "any", + "base" + ], + "win-x64-aot": [ + "win-aot", + "win-x64", + "win", + "aot", + "any", + "base" + ], + "win10-x64": [ + "win10", + "win81-x64", + "win81", + "win8-x64", + "win8", + "win7-x64", + "win7", + "win-x64", + "win", + "any", + "base" + ], + "win10-x64-aot": [ + "win10-aot", + "win10-x64", + "win10", + "win81-x64-aot", + "win81-aot", + "win81-x64", + "win81", + "win8-x64-aot", + "win8-aot", + "win8-x64", + "win8", + "win7-x64-aot", + "win7-aot", + "win7-x64", + "win7", + "win-x64-aot", + "win-aot", + "win-x64", + "win", + "aot", + "any", + "base" + ], + "win7-x64": [ + "win7", + "win-x64", + "win", + "any", + "base" + ], + "win7-x64-aot": [ + "win7-aot", + "win7-x64", + "win7", + "win-x64-aot", + "win-aot", + "win-x64", + "win", + "aot", + "any", + "base" + ], + "win8-x64": [ + "win8", + "win7-x64", + "win7", + "win-x64", + "win", + "any", + "base" + ], + "win8-x64-aot": [ + "win8-aot", + "win8-x64", + "win8", + "win7-x64-aot", + "win7-aot", + "win7-x64", + "win7", + "win-x64-aot", + "win-aot", + "win-x64", + "win", + "aot", + "any", + "base" + ], + "win81-x64": [ + "win81", + "win8-x64", + "win8", + "win7-x64", + "win7", + "win-x64", + "win", + "any", + "base" + ], + "win81-x64-aot": [ + "win81-aot", + "win81-x64", + "win81", + "win8-x64-aot", + "win8-aot", + "win8-x64", + "win8", + "win7-x64-aot", + "win7-aot", + "win7-x64", + "win7", + "win-x64-aot", + "win-aot", + "win-x64", + "win", + "aot", + "any", + "base" + ] + } +} \ No newline at end of file diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.runtimeconfig.json b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.runtimeconfig.json new file mode 100644 index 000000000..3d37d8e97 --- /dev/null +++ b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.NETCore.App.runtimeconfig.json @@ -0,0 +1,8 @@ +{ + "runtimeOptions": { + "tfm": "net6.0", + "configProperties": { + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false + } + } +} \ No newline at end of file diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.Core.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.Core.dll new file mode 100644 index 000000000..40a5c65ca Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.Core.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.dll new file mode 100644 index 000000000..674a129ce Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.VisualBasic.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Primitives.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Primitives.dll new file mode 100644 index 000000000..b7491e74f Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Primitives.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Registry.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Registry.dll new file mode 100644 index 000000000..93504a69e Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/Microsoft.Win32.Registry.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.AppContext.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.AppContext.dll new file mode 100644 index 000000000..03fb3da71 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.AppContext.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Buffers.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Buffers.dll new file mode 100644 index 000000000..b7d48d596 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Buffers.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Concurrent.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Concurrent.dll new file mode 100644 index 000000000..48941a91c Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Concurrent.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Immutable.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Immutable.dll new file mode 100644 index 000000000..8d0db9512 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Immutable.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.NonGeneric.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.NonGeneric.dll new file mode 100644 index 000000000..1bc3ef67a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.NonGeneric.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Specialized.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Specialized.dll new file mode 100644 index 000000000..7b78f7447 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.Specialized.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.dll new file mode 100644 index 000000000..ecff543cc Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Collections.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Annotations.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Annotations.dll new file mode 100644 index 000000000..1a1ec48f0 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Annotations.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.DataAnnotations.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.DataAnnotations.dll new file mode 100644 index 000000000..c97c889c1 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.DataAnnotations.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.EventBasedAsync.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.EventBasedAsync.dll new file mode 100644 index 000000000..65d7b1d28 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.EventBasedAsync.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Primitives.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Primitives.dll new file mode 100644 index 000000000..1f167fcef Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.Primitives.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.TypeConverter.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.TypeConverter.dll new file mode 100644 index 000000000..7a55cda74 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.TypeConverter.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.dll new file mode 100644 index 000000000..b7a986faa Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ComponentModel.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Configuration.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Configuration.dll new file mode 100644 index 000000000..50a19b477 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Configuration.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Console.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Console.dll new file mode 100644 index 000000000..a6c8080b0 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Console.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Core.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Core.dll new file mode 100644 index 000000000..0027dcd97 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Core.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.Common.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.Common.dll new file mode 100644 index 000000000..845ee4e5a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.Common.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.DataSetExtensions.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.DataSetExtensions.dll new file mode 100644 index 000000000..2e36a6156 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.DataSetExtensions.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.dll new file mode 100644 index 000000000..045163b0c Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Data.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Contracts.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Contracts.dll new file mode 100644 index 000000000..bf672af85 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Contracts.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Debug.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Debug.dll new file mode 100644 index 000000000..3b4a3cb09 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Debug.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.DiagnosticSource.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.DiagnosticSource.dll new file mode 100644 index 000000000..46aa4946a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.DiagnosticSource.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.FileVersionInfo.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.FileVersionInfo.dll new file mode 100644 index 000000000..17bb321f6 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.FileVersionInfo.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Process.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Process.dll new file mode 100644 index 000000000..381318f7f Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Process.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.StackTrace.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.StackTrace.dll new file mode 100644 index 000000000..3f0a334ab Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.StackTrace.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TextWriterTraceListener.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TextWriterTraceListener.dll new file mode 100644 index 000000000..5a4b8789d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TextWriterTraceListener.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tools.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tools.dll new file mode 100644 index 000000000..8f6301ef3 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tools.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TraceSource.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TraceSource.dll new file mode 100644 index 000000000..ecf7b456a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.TraceSource.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tracing.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tracing.dll new file mode 100644 index 000000000..e5fe0e067 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Diagnostics.Tracing.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.Primitives.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.Primitives.dll new file mode 100644 index 000000000..ed5b21532 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.Primitives.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.dll new file mode 100644 index 000000000..53289d4d7 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Drawing.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Dynamic.Runtime.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Dynamic.Runtime.dll new file mode 100644 index 000000000..2e07b1548 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Dynamic.Runtime.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Formats.Asn1.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Formats.Asn1.dll new file mode 100644 index 000000000..8b89045de Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Formats.Asn1.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Calendars.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Calendars.dll new file mode 100644 index 000000000..d1b04a0db Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Calendars.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Extensions.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Extensions.dll new file mode 100644 index 000000000..201a3d071 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.Extensions.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.dll new file mode 100644 index 000000000..dda792b28 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Globalization.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Brotli.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Brotli.dll new file mode 100644 index 000000000..ef41315c7 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Brotli.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.FileSystem.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.FileSystem.dll new file mode 100644 index 000000000..a45ec2e9f Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.FileSystem.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Native.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Native.dll new file mode 100644 index 000000000..54961e3b2 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.Native.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.ZipFile.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.ZipFile.dll new file mode 100644 index 000000000..c95fe6e30 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.ZipFile.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.dll new file mode 100644 index 000000000..ed97c3900 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Compression.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.AccessControl.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.AccessControl.dll new file mode 100644 index 000000000..9baa7ee99 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.AccessControl.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.DriveInfo.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.DriveInfo.dll new file mode 100644 index 000000000..cbe6007dc Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.DriveInfo.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Primitives.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Primitives.dll new file mode 100644 index 000000000..342f437b0 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Primitives.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Watcher.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Watcher.dll new file mode 100644 index 000000000..e943bdcb2 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.Watcher.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.dll new file mode 100644 index 000000000..879cbb41b Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.FileSystem.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.IsolatedStorage.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.IsolatedStorage.dll new file mode 100644 index 000000000..c37032f6b Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.IsolatedStorage.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.MemoryMappedFiles.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.MemoryMappedFiles.dll new file mode 100644 index 000000000..deab12389 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.MemoryMappedFiles.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.AccessControl.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.AccessControl.dll new file mode 100644 index 000000000..3762f4d32 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.AccessControl.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.dll new file mode 100644 index 000000000..83700b944 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.Pipes.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.UnmanagedMemoryStream.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.UnmanagedMemoryStream.dll new file mode 100644 index 000000000..5464f0f42 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.UnmanagedMemoryStream.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.dll new file mode 100644 index 000000000..092888b26 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.IO.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Expressions.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Expressions.dll new file mode 100644 index 000000000..4012ebb2f Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Expressions.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Parallel.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Parallel.dll new file mode 100644 index 000000000..3a80efbe6 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Parallel.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Queryable.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Queryable.dll new file mode 100644 index 000000000..68230d514 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.Queryable.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.dll new file mode 100644 index 000000000..10b994d85 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Linq.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Memory.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Memory.dll new file mode 100644 index 000000000..91dbd9d11 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Memory.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.Json.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.Json.dll new file mode 100644 index 000000000..aacfd7f0c Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.Json.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.dll new file mode 100644 index 000000000..8959ddfa8 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Http.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.HttpListener.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.HttpListener.dll new file mode 100644 index 000000000..a819b9d13 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.HttpListener.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Mail.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Mail.dll new file mode 100644 index 000000000..7c18b886d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Mail.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NameResolution.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NameResolution.dll new file mode 100644 index 000000000..50c8f2982 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NameResolution.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NetworkInformation.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NetworkInformation.dll new file mode 100644 index 000000000..a6bf5f956 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.NetworkInformation.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Ping.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Ping.dll new file mode 100644 index 000000000..c76c7897c Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Ping.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Primitives.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Primitives.dll new file mode 100644 index 000000000..660a8c8c9 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Primitives.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Quic.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Quic.dll new file mode 100644 index 000000000..91ec659aa Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Quic.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Requests.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Requests.dll new file mode 100644 index 000000000..9bc1d9a7d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Requests.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Security.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Security.dll new file mode 100644 index 000000000..4de471b50 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Security.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.ServicePoint.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.ServicePoint.dll new file mode 100644 index 000000000..e0c2aeed6 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.ServicePoint.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Sockets.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Sockets.dll new file mode 100644 index 000000000..9c0048a07 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.Sockets.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebClient.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebClient.dll new file mode 100644 index 000000000..61c71a548 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebClient.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebHeaderCollection.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebHeaderCollection.dll new file mode 100644 index 000000000..b9864531e Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebHeaderCollection.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebProxy.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebProxy.dll new file mode 100644 index 000000000..075aa1bca Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebProxy.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.Client.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.Client.dll new file mode 100644 index 000000000..5ff371f44 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.Client.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.dll new file mode 100644 index 000000000..294e3afe6 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.WebSockets.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.dll new file mode 100644 index 000000000..b2b8de91c Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Net.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.Vectors.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.Vectors.dll new file mode 100644 index 000000000..ac588271a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.Vectors.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.dll new file mode 100644 index 000000000..1a6252d00 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Numerics.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ObjectModel.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ObjectModel.dll new file mode 100644 index 000000000..bb6c865d7 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ObjectModel.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.CoreLib.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.CoreLib.dll new file mode 100644 index 000000000..f95eaf40c Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.CoreLib.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.DataContractSerialization.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.DataContractSerialization.dll new file mode 100644 index 000000000..fca3dc203 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.DataContractSerialization.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Uri.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Uri.dll new file mode 100644 index 000000000..59d087252 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Uri.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.Linq.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.Linq.dll new file mode 100644 index 000000000..b77b941da Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.Linq.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.dll new file mode 100644 index 000000000..f06c7f9f6 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Private.Xml.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.DispatchProxy.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.DispatchProxy.dll new file mode 100644 index 000000000..318902bbb Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.DispatchProxy.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.ILGeneration.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.ILGeneration.dll new file mode 100644 index 000000000..2b835ce33 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.ILGeneration.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.Lightweight.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.Lightweight.dll new file mode 100644 index 000000000..1a4816807 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.Lightweight.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.dll new file mode 100644 index 000000000..331ab29b5 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Emit.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Extensions.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Extensions.dll new file mode 100644 index 000000000..4467c3e0c Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Extensions.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Metadata.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Metadata.dll new file mode 100644 index 000000000..3b85673dc Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Metadata.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Primitives.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Primitives.dll new file mode 100644 index 000000000..dd3052838 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.Primitives.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.TypeExtensions.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.TypeExtensions.dll new file mode 100644 index 000000000..5bf716968 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.TypeExtensions.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.dll new file mode 100644 index 000000000..f8ef2ce14 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Reflection.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Reader.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Reader.dll new file mode 100644 index 000000000..529e4354d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Reader.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.ResourceManager.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.ResourceManager.dll new file mode 100644 index 000000000..241d12701 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.ResourceManager.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Writer.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Writer.dll new file mode 100644 index 000000000..66d74df8a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Resources.Writer.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.Unsafe.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.Unsafe.dll new file mode 100644 index 000000000..1874c0d0b Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.Unsafe.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.VisualC.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.VisualC.dll new file mode 100644 index 000000000..59ba9072f Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.CompilerServices.VisualC.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Extensions.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Extensions.dll new file mode 100644 index 000000000..1e81b406d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Extensions.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Handles.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Handles.dll new file mode 100644 index 000000000..d1a620453 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Handles.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.RuntimeInformation.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.RuntimeInformation.dll new file mode 100644 index 000000000..30222733f Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.RuntimeInformation.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.dll new file mode 100644 index 000000000..4801c8aad Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.InteropServices.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Intrinsics.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Intrinsics.dll new file mode 100644 index 000000000..2d1f54584 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Intrinsics.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Loader.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Loader.dll new file mode 100644 index 000000000..3212c91b3 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Loader.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Numerics.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Numerics.dll new file mode 100644 index 000000000..298354dce Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Numerics.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Formatters.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Formatters.dll new file mode 100644 index 000000000..8b5630f4e Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Formatters.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Json.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Json.dll new file mode 100644 index 000000000..9a1b89e40 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Json.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Primitives.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Primitives.dll new file mode 100644 index 000000000..7b734ba38 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Primitives.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Xml.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Xml.dll new file mode 100644 index 000000000..e593d3345 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.Xml.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.dll new file mode 100644 index 000000000..2c0cc451a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.Serialization.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.dll new file mode 100644 index 000000000..486192eea Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Runtime.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.AccessControl.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.AccessControl.dll new file mode 100644 index 000000000..a0a6a8603 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.AccessControl.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Claims.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Claims.dll new file mode 100644 index 000000000..0d1b2575e Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Claims.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Algorithms.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Algorithms.dll new file mode 100644 index 000000000..c29984318 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Algorithms.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Cng.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Cng.dll new file mode 100644 index 000000000..829125c0b Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Cng.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Csp.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Csp.dll new file mode 100644 index 000000000..5c644ed33 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Csp.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Encoding.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Encoding.dll new file mode 100644 index 000000000..9452ec6b5 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Encoding.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.OpenSsl.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.OpenSsl.dll new file mode 100644 index 000000000..3be7bd27e Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.OpenSsl.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Primitives.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Primitives.dll new file mode 100644 index 000000000..805556d2d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.Primitives.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.X509Certificates.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.X509Certificates.dll new file mode 100644 index 000000000..43f87266e Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Cryptography.X509Certificates.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.Windows.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.Windows.dll new file mode 100644 index 000000000..eb5d96ac0 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.Windows.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.dll new file mode 100644 index 000000000..b1b585a76 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.Principal.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.SecureString.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.SecureString.dll new file mode 100644 index 000000000..52a35180c Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.SecureString.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.dll new file mode 100644 index 000000000..defb56f79 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Security.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceModel.Web.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceModel.Web.dll new file mode 100644 index 000000000..578cc7459 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceModel.Web.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceProcess.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceProcess.dll new file mode 100644 index 000000000..c4992c526 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ServiceProcess.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.CodePages.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.CodePages.dll new file mode 100644 index 000000000..b8a8a8f34 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.CodePages.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.Extensions.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.Extensions.dll new file mode 100644 index 000000000..ae280de32 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.Extensions.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.dll new file mode 100644 index 000000000..f82091349 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encoding.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encodings.Web.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encodings.Web.dll new file mode 100644 index 000000000..374899330 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Encodings.Web.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Json.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Json.dll new file mode 100644 index 000000000..dce122c65 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.Json.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.RegularExpressions.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.RegularExpressions.dll new file mode 100644 index 000000000..cc5176df4 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Text.RegularExpressions.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Channels.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Channels.dll new file mode 100644 index 000000000..b0926cf25 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Channels.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Overlapped.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Overlapped.dll new file mode 100644 index 000000000..d3c1915b4 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Overlapped.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Dataflow.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Dataflow.dll new file mode 100644 index 000000000..cb6360d23 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Dataflow.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Extensions.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Extensions.dll new file mode 100644 index 000000000..03f68038b Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Extensions.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Parallel.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Parallel.dll new file mode 100644 index 000000000..8c8c6e486 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.Parallel.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.dll new file mode 100644 index 000000000..7a8b2b677 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Tasks.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Thread.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Thread.dll new file mode 100644 index 000000000..9f02991e8 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Thread.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.ThreadPool.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.ThreadPool.dll new file mode 100644 index 000000000..082171467 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.ThreadPool.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Timer.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Timer.dll new file mode 100644 index 000000000..899ccc08d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.Timer.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.dll new file mode 100644 index 000000000..5e638a65d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Threading.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Transactions.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Transactions.dll new file mode 100644 index 000000000..ea30bd4ad Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Transactions.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ValueTuple.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ValueTuple.dll new file mode 100644 index 000000000..310b07757 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.ValueTuple.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.HttpUtility.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.HttpUtility.dll new file mode 100644 index 000000000..c78a3313a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.HttpUtility.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.dll new file mode 100644 index 000000000..c3126879d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Web.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Windows.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Windows.dll new file mode 100644 index 000000000..60b9d8ad4 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Windows.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Linq.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Linq.dll new file mode 100644 index 000000000..38db11a30 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Linq.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.ReaderWriter.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.ReaderWriter.dll new file mode 100644 index 000000000..b7ceddd31 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.ReaderWriter.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Serialization.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Serialization.dll new file mode 100644 index 000000000..e0a65ba45 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.Serialization.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XDocument.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XDocument.dll new file mode 100644 index 000000000..695b88a6b Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XDocument.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.XDocument.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.XDocument.dll new file mode 100644 index 000000000..2c49d3c34 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.XDocument.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.dll new file mode 100644 index 000000000..00a62b3fa Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XPath.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlDocument.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlDocument.dll new file mode 100644 index 000000000..9871b86a6 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlDocument.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlSerializer.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlSerializer.dll new file mode 100644 index 000000000..e3f3d95bc Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.XmlSerializer.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.dll new file mode 100644 index 000000000..0a1b7e509 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.Xml.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.dll new file mode 100644 index 000000000..32b5a15d2 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/System.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/WindowsBase.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/WindowsBase.dll new file mode 100644 index 000000000..271ffa086 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/WindowsBase.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-console-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-console-l1-1-0.dll new file mode 100644 index 000000000..726b97532 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-console-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-console-l1-2-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-console-l1-2-0.dll new file mode 100644 index 000000000..b9d1ed43e Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-console-l1-2-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-datetime-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-datetime-l1-1-0.dll new file mode 100644 index 000000000..f2ecfa7ab Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-datetime-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-debug-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-debug-l1-1-0.dll new file mode 100644 index 000000000..7bd075bcd Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-debug-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-errorhandling-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-errorhandling-l1-1-0.dll new file mode 100644 index 000000000..3bafba91c Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-errorhandling-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-fibers-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-fibers-l1-1-0.dll new file mode 100644 index 000000000..651ffe133 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-fibers-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-file-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-file-l1-1-0.dll new file mode 100644 index 000000000..12bf0b6c0 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-file-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-file-l1-2-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-file-l1-2-0.dll new file mode 100644 index 000000000..da64db36a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-file-l1-2-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-file-l2-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-file-l2-1-0.dll new file mode 100644 index 000000000..9246b9893 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-file-l2-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-handle-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-handle-l1-1-0.dll new file mode 100644 index 000000000..c96e31d98 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-handle-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-heap-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-heap-l1-1-0.dll new file mode 100644 index 000000000..baa932fd5 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-heap-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-interlocked-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-interlocked-l1-1-0.dll new file mode 100644 index 000000000..7aa063977 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-interlocked-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-libraryloader-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-libraryloader-l1-1-0.dll new file mode 100644 index 000000000..ddd5e276e Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-libraryloader-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-localization-l1-2-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-localization-l1-2-0.dll new file mode 100644 index 000000000..7b90b7c2f Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-localization-l1-2-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-memory-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-memory-l1-1-0.dll new file mode 100644 index 000000000..63e54f31b Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-memory-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-namedpipe-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-namedpipe-l1-1-0.dll new file mode 100644 index 000000000..37e956eca Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-namedpipe-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-processenvironment-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-processenvironment-l1-1-0.dll new file mode 100644 index 000000000..a2f36050a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-processenvironment-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-processthreads-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-processthreads-l1-1-0.dll new file mode 100644 index 000000000..f4d3a0339 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-processthreads-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-processthreads-l1-1-1.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-processthreads-l1-1-1.dll new file mode 100644 index 000000000..7bc40e056 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-processthreads-l1-1-1.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-profile-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-profile-l1-1-0.dll new file mode 100644 index 000000000..da2b687a1 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-profile-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-rtlsupport-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-rtlsupport-l1-1-0.dll new file mode 100644 index 000000000..ae6dce55e Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-rtlsupport-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-string-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-string-l1-1-0.dll new file mode 100644 index 000000000..32b52be78 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-string-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-synch-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-synch-l1-1-0.dll new file mode 100644 index 000000000..b88f76af0 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-synch-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-synch-l1-2-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-synch-l1-2-0.dll new file mode 100644 index 000000000..a17135afc Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-synch-l1-2-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-sysinfo-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-sysinfo-l1-1-0.dll new file mode 100644 index 000000000..527d1a12c Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-sysinfo-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-timezone-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-timezone-l1-1-0.dll new file mode 100644 index 000000000..bab2d02ff Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-timezone-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-util-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-util-l1-1-0.dll new file mode 100644 index 000000000..080a9c959 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-core-util-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-conio-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-conio-l1-1-0.dll new file mode 100644 index 000000000..2355a627e Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-conio-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-convert-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-convert-l1-1-0.dll new file mode 100644 index 000000000..ddd2b4ca1 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-convert-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-environment-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-environment-l1-1-0.dll new file mode 100644 index 000000000..e2fe9ef7a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-environment-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-filesystem-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-filesystem-l1-1-0.dll new file mode 100644 index 000000000..97ea4656b Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-filesystem-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-heap-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-heap-l1-1-0.dll new file mode 100644 index 000000000..4e3af05f8 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-heap-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-locale-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-locale-l1-1-0.dll new file mode 100644 index 000000000..5fcd98b2b Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-locale-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-math-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-math-l1-1-0.dll new file mode 100644 index 000000000..c3f2800e3 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-math-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-multibyte-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-multibyte-l1-1-0.dll new file mode 100644 index 000000000..e86ce8183 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-multibyte-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-private-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-private-l1-1-0.dll new file mode 100644 index 000000000..62c45dd04 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-private-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-process-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-process-l1-1-0.dll new file mode 100644 index 000000000..bc346dc35 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-process-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-runtime-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-runtime-l1-1-0.dll new file mode 100644 index 000000000..d0a43f824 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-runtime-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-stdio-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-stdio-l1-1-0.dll new file mode 100644 index 000000000..59e68c053 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-stdio-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-string-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-string-l1-1-0.dll new file mode 100644 index 000000000..08015e290 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-string-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-time-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-time-l1-1-0.dll new file mode 100644 index 000000000..6e3ba53c8 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-time-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-utility-l1-1-0.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-utility-l1-1-0.dll new file mode 100644 index 000000000..eaa72041d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/api-ms-win-crt-utility-l1-1-0.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/clretwrc.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/clretwrc.dll new file mode 100644 index 000000000..cab860962 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/clretwrc.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/clrjit.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/clrjit.dll new file mode 100644 index 000000000..bf65aa5be Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/clrjit.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/coreclr.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/coreclr.dll new file mode 100644 index 000000000..e529f702b Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/coreclr.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/createdump.exe b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/createdump.exe new file mode 100644 index 000000000..bf85031a7 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/createdump.exe differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/dbgshim.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/dbgshim.dll new file mode 100644 index 000000000..7e2f5609a Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/dbgshim.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/hostpolicy.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/hostpolicy.dll new file mode 100644 index 000000000..8dc018cff Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/hostpolicy.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscordaccore.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscordaccore.dll new file mode 100644 index 000000000..0ed22a59d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscordaccore.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscordaccore_amd64_amd64_6.0.2523.51912.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscordaccore_amd64_amd64_6.0.2523.51912.dll new file mode 100644 index 000000000..0ed22a59d Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscordaccore_amd64_amd64_6.0.2523.51912.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscordbi.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscordbi.dll new file mode 100644 index 000000000..3ce9d8324 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscordbi.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorlib.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorlib.dll new file mode 100644 index 000000000..94e942025 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorlib.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorrc.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorrc.dll new file mode 100644 index 000000000..013484677 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/mscorrc.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/msquic.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/msquic.dll new file mode 100644 index 000000000..07cd9e305 Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/msquic.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/netstandard.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/netstandard.dll new file mode 100644 index 000000000..92a70dfdb Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/netstandard.dll differ diff --git a/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/ucrtbase.dll b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/ucrtbase.dll new file mode 100644 index 000000000..0b410784b Binary files /dev/null and b/Dependencies/Dotnet/windows/x86_64/shared/Microsoft.NETCore.App/6.0.25/ucrtbase.dll differ diff --git a/Dependencies/GodotPCKExplorer/GodotPCKExplorer.dll b/Dependencies/GodotPCKExplorer/GodotPCKExplorer.dll new file mode 100644 index 000000000..32ee6ffdb Binary files /dev/null and b/Dependencies/GodotPCKExplorer/GodotPCKExplorer.dll differ diff --git a/Dependencies/Il2CppAssemblyGenerator/Core.cs b/Dependencies/Il2CppAssemblyGenerator/Core.cs deleted file mode 100644 index c81dfdee1..000000000 --- a/Dependencies/Il2CppAssemblyGenerator/Core.cs +++ /dev/null @@ -1,169 +0,0 @@ -using System.IO; -using System.Net.Http; -using MelonLoader.Il2CppAssemblyGenerator.Packages; -using MelonLoader.Il2CppAssemblyGenerator.Packages.Models; -using MelonLoader.Modules; -using MelonLoader.Properties; -using MelonLoader.Utils; - -namespace MelonLoader.Il2CppAssemblyGenerator -{ - internal class Core : MelonModule - { - internal static string BasePath = null; - internal static string GameAssemblyPath = null; - internal static string ManagedPath = null; - - internal static HttpClient webClient = null; - - internal static ExecutablePackage cpp2il = null; - internal static Cpp2IL_StrippedCodeRegSupport cpp2il_scrs = null; - - internal static Packages.Il2CppInterop il2cppinterop = null; - internal static UnityDependencies unitydependencies = null; - internal static DeobfuscationMap deobfuscationMap = null; - internal static DeobfuscationRegex deobfuscationRegex = null; - - internal static bool AssemblyGenerationNeeded = false; - - internal static MelonLogger.Instance Logger; - - public override void OnInitialize() - { - Logger = LoggerInstance; - - webClient = new(); - webClient.DefaultRequestHeaders.Add("User-Agent", $"{BuildInfo.Name} v{BuildInfo.Version}"); - - AssemblyGenerationNeeded = LoaderConfig.Current.UnityEngine.ForceRegeneration; - - string gameAssemblyName = "GameAssembly"; - if (MelonUtils.IsUnix) - gameAssemblyName += ".so"; - if (MelonUtils.IsWindows) - gameAssemblyName += ".dll"; - if (MelonUtils.IsMac) - gameAssemblyName += ".dylib"; - - GameAssemblyPath = Path.Combine(MelonEnvironment.GameRootDirectory, gameAssemblyName); - ManagedPath = MelonEnvironment.MelonManagedDirectory; - BasePath = MelonEnvironment.Il2CppAssemblyGeneratorDirectory; - } - - private static int Run() - { - Config.Initialize(); - - if (!LoaderConfig.Current.UnityEngine.ForceOfflineGeneration) - RemoteAPI.Contact(); - - Cpp2IL cpp2IL_netcore = new Cpp2IL(); - if (MelonUtils.IsWindows - && (cpp2IL_netcore.VersionSem < Cpp2IL.NetCoreMinVersion)) - cpp2il = new Cpp2IL_NetFramework(); - else - cpp2il = cpp2IL_netcore; - cpp2il_scrs = new Cpp2IL_StrippedCodeRegSupport(cpp2il); - - il2cppinterop = new Packages.Il2CppInterop(); - unitydependencies = new UnityDependencies(); - deobfuscationMap = new DeobfuscationMap(); - deobfuscationRegex = new DeobfuscationRegex(); - - Logger.Msg($"Using Cpp2IL Version: {(string.IsNullOrEmpty(cpp2il.Version) ? "null" : cpp2il.Version)}"); - Logger.Msg($"Using Il2CppInterop Version = {(string.IsNullOrEmpty(il2cppinterop.Version) ? "null" : il2cppinterop.Version)}"); - Logger.Msg($"Using Unity Dependencies Version = {(string.IsNullOrEmpty(unitydependencies.Version) ? "null" : unitydependencies.Version)}"); - Logger.Msg($"Using Deobfuscation Regex = {(string.IsNullOrEmpty(deobfuscationRegex.Regex) ? "null" : deobfuscationRegex.Regex)}"); - - if (!cpp2il.Setup() - || !cpp2il_scrs.Setup() - || !il2cppinterop.Setup() - || !unitydependencies.Setup() - || !deobfuscationMap.Setup()) - return 1; - - deobfuscationRegex.Setup(); - - string CurrentGameAssemblyHash; - Logger.Msg("Checking GameAssembly..."); - MelonDebug.Msg($"Last GameAssembly Hash: {Config.Values.GameAssemblyHash}"); - MelonDebug.Msg($"Current GameAssembly Hash: {CurrentGameAssemblyHash = MelonUtils.ComputeSimpleSHA512Hash(GameAssemblyPath)}"); - - if (string.IsNullOrEmpty(Config.Values.GameAssemblyHash) - || !Config.Values.GameAssemblyHash.Equals(CurrentGameAssemblyHash)) - AssemblyGenerationNeeded = true; - - if (!AssemblyGenerationNeeded) - { - Logger.Msg("Assembly is up to date. No Generation Needed."); - return 0; - } - Logger.Msg("Assembly Generation Needed!"); - - cpp2il.Cleanup(); - il2cppinterop.Cleanup(); - - if (!cpp2il.Execute()) - { - cpp2il.Cleanup(); - return 1; - } - - if (!il2cppinterop.Execute()) - { - cpp2il.Cleanup(); - il2cppinterop.Cleanup(); - return 1; - } - - OldFiles_Cleanup(); - OldFiles_LAM(); - - cpp2il.Cleanup(); - il2cppinterop.Cleanup(); - - Logger.Msg("Assembly Generation Successful!"); - deobfuscationRegex.Save(); - Config.Values.GameAssemblyHash = CurrentGameAssemblyHash; - Config.Save(); - - return 0; - } - - private static void OldFiles_Cleanup() - { - if (Config.Values.OldFiles.Count <= 0) - return; - for (int i = 0; i < Config.Values.OldFiles.Count; i++) - { - string filename = Config.Values.OldFiles[i]; - string filepath = Path.Combine(MelonEnvironment.Il2CppAssembliesDirectory, filename); - if (File.Exists(filepath)) - { - Logger.Msg("Deleting " + filename); - File.Delete(filepath); - } - } - Config.Values.OldFiles.Clear(); - } - - private static void OldFiles_LAM() - { - string[] filepathtbl = Directory.GetFiles(il2cppinterop.OutputFolder); - string il2CppAssembliesDirectory = MelonEnvironment.Il2CppAssembliesDirectory; - for (int i = 0; i < filepathtbl.Length; i++) - { - string filepath = filepathtbl[i]; - string filename = Path.GetFileName(filepath); - Logger.Msg("Moving " + filename); - Config.Values.OldFiles.Add(filename); - string newfilepath = Path.Combine(il2CppAssembliesDirectory, filename); - if (File.Exists(newfilepath)) - File.Delete(newfilepath); - Directory.CreateDirectory(il2CppAssembliesDirectory); - File.Move(filepath, newfilepath); - } - Config.Save(); - } - } -} \ No newline at end of file diff --git a/Dependencies/Il2CppAssemblyGenerator/Extensions.cs b/Dependencies/Il2CppAssemblyGenerator/Extensions.cs deleted file mode 100644 index 6eb549cc0..000000000 --- a/Dependencies/Il2CppAssemblyGenerator/Extensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.IO; -using System.Net.Http; - -namespace MelonLoader.Il2CppAssemblyGenerator; - -internal static class Extensions -{ - public static void DownloadFile(this HttpClient client, string url, string dest) - { - using var dlStream = client.GetStreamAsync(url).Result; - using var fileStream = File.Open(dest, FileMode.Create, FileAccess.Write); - dlStream.CopyTo(fileStream); - } -} \ No newline at end of file diff --git a/Dependencies/Il2CppAssemblyGenerator/FileHandler.cs b/Dependencies/Il2CppAssemblyGenerator/FileHandler.cs deleted file mode 100644 index 1066295bc..000000000 --- a/Dependencies/Il2CppAssemblyGenerator/FileHandler.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using System.IO; -using System.IO.Compression; - -namespace MelonLoader.Il2CppAssemblyGenerator -{ - internal static class FileHandler - { - internal static bool Download(string url, string destination) - { - if (string.IsNullOrEmpty(url)) - { - Core.Logger.Error($"url cannot be Null or Empty!"); - return false; - } - - if (string.IsNullOrEmpty(destination)) - { - Core.Logger.Error($"destination cannot be Null or Empty!"); - return false; - } - - if (File.Exists(destination)) - File.Delete(destination); - - Core.Logger.Msg($"Downloading {url} to {destination}"); - try { Core.webClient.DownloadFile(url, destination); } - catch (Exception ex) - { - Core.Logger.Error(ex.ToString()); - - if (File.Exists(destination)) - File.Delete(destination); - - return false; - } - - return true; - } - - internal static bool Process(string filepath, string destination, string targetName = null) - { - if (string.IsNullOrEmpty(filepath)) - { - Core.Logger.Error($"filepath cannot be Null or Empty!"); - return false; - } - - if (string.IsNullOrEmpty(destination)) - { - Core.Logger.Error($"destination cannot be Null or Empty!"); - return false; - } - - if (filepath.Equals(destination)) - return true; - - if (!File.Exists(filepath)) - { - Core.Logger.Error($"{filepath} does not Exist!"); - return false; - } - - if (Path.HasExtension(destination)) - { - if (File.Exists(destination)) - File.Delete(destination); - } - else - { - if (Directory.Exists(destination)) - { - Core.Logger.Msg($"Cleaning {destination}"); - foreach (var entry in Directory.EnumerateFileSystemEntries(destination)) - { - if (Directory.Exists(entry)) - Directory.Delete(entry, true); - else - File.Delete(entry); - } - } - else - { - Core.Logger.Msg($"Creating Directory {destination}"); - Directory.CreateDirectory(destination); - } - } - - string filename = Path.GetFileName(filepath); - if (!filename.EndsWith(".zip")) - { - Core.Logger.Msg($"Moving {filepath} to {destination}"); - - if (!string.IsNullOrEmpty(targetName)) - destination = Path.Combine(destination, targetName); - - File.Move(filepath, destination); - return true; - } - - Core.Logger.Msg($"Extracting {filepath} to {destination}"); - try { ZipFile.ExtractToDirectory(filepath, destination); } - catch (Exception ex) - { - Core.Logger.Error(ex.ToString()); - - if (File.Exists(filepath)) - File.Delete(filepath); - - if (Directory.Exists(destination)) - { - foreach (var entry in Directory.EnumerateFileSystemEntries(destination)) - { - if (Directory.Exists(entry)) - Directory.Delete(entry, true); - else - File.Delete(entry); - } - } - - return false; - } - - if (File.Exists(filepath)) - File.Delete(filepath); - - return true; - } - } -} diff --git a/Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj b/Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj deleted file mode 100644 index 61168b91a..000000000 --- a/Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - MelonLoader.Il2CppAssemblyGenerator - net6 - true - true - $(MLOutDir)/MelonLoader/Dependencies/Il2CppAssemblyGenerator - true - embedded - false - - - - - - - - - - - \ No newline at end of file diff --git a/Dependencies/Il2CppAssemblyGenerator/Packages/Cpp2IL.cs b/Dependencies/Il2CppAssemblyGenerator/Packages/Cpp2IL.cs deleted file mode 100644 index 4a5b1b347..000000000 --- a/Dependencies/Il2CppAssemblyGenerator/Packages/Cpp2IL.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using Semver; - -namespace MelonLoader.Il2CppAssemblyGenerator.Packages -{ - internal class Cpp2IL : Models.ExecutablePackage - { - internal static SemVersion NetCoreMinVersion = SemVersion.Parse("2022.1.0-pre-release.18"); - internal SemVersion VersionSem; - private string BaseFolder; - - private static string ReleaseName => - MelonUtils.IsWindows ? "Windows" : MelonUtils.IsUnix ? "Linux" : "OSX"; - - internal Cpp2IL() - { - Version = LoaderConfig.Current.UnityEngine.ForceIl2CppDumperVersion; -#if !DEBUG - if (string.IsNullOrEmpty(Version) || Version.Equals("0.0.0.0")) - Version = RemoteAPI.Info.ForceDumperVersion; -#endif - if (string.IsNullOrEmpty(Version) || Version.Equals("0.0.0.0")) - Version = $"2022.1.0-pre-release.19"; - VersionSem = SemVersion.Parse(Version); - - Name = nameof(Cpp2IL); - - var filename = Name; -#if WINDOWS - filename += ".exe"; -#endif - - BaseFolder = Path.Combine(Core.BasePath, Name); - Directory.CreateDirectory(BaseFolder); - - FilePath = - ExeFilePath = - Destination = - Path.Combine(BaseFolder, filename); - - OutputFolder = Path.Combine(BaseFolder, "cpp2il_out"); - - URL = $"https://github.com/SamboyCoding/{Name}/releases/download/{Version}/{Name}-{Version}-{ReleaseName}"; -#if WINDOWS - URL += ".exe"; -#endif - } - - internal override bool ShouldSetup() - => string.IsNullOrEmpty(Config.Values.DumperVersion) - || !Config.Values.DumperVersion.Equals(Version); - - internal override void Cleanup() { } - - internal override void Save() - => Save(ref Config.Values.DumperVersion); - - internal override bool Execute() - => Execute([ - MelonDebug.IsEnabled() ? "--verbose" : string.Empty, - - "--game-path", - "\"" + Path.GetDirectoryName(Core.GameAssemblyPath) + "\"", - - "--exe-name", - "\"" + Process.GetCurrentProcess().ProcessName + "\"", - - "--output-as", - "dummydll", - - "--use-processor", - "attributeanalyzer", - "attributeinjector", - LoaderConfig.Current.UnityEngine.EnableCpp2ILCallAnalyzer ? "callanalyzer" : string.Empty, - LoaderConfig.Current.UnityEngine.EnableCpp2ILNativeMethodDetector ? "nativemethoddetector" : string.Empty, - //"deobfmap", - //"stablenamer", - - ], false, new Dictionary() { - {"NO_COLOR", "1"}, - }); - } -} diff --git a/Dependencies/Il2CppAssemblyGenerator/Packages/Cpp2IL_NetFramework.cs b/Dependencies/Il2CppAssemblyGenerator/Packages/Cpp2IL_NetFramework.cs deleted file mode 100644 index 686b8508e..000000000 --- a/Dependencies/Il2CppAssemblyGenerator/Packages/Cpp2IL_NetFramework.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using Semver; - -namespace MelonLoader.Il2CppAssemblyGenerator.Packages -{ - internal class Cpp2IL_NetFramework : Models.ExecutablePackage - { - private static string ReleaseName => "Windows-Netframework472"; - internal Cpp2IL_NetFramework() - { - Version = LoaderConfig.Current.UnityEngine.ForceIl2CppDumperVersion; -#if !DEBUG - if (string.IsNullOrEmpty(Version) || Version.Equals("0.0.0.0")) - Version = RemoteAPI.Info.ForceDumperVersion; -#endif - if (string.IsNullOrEmpty(Version) || Version.Equals("0.0.0.0")) - Version = $"2022.1.0-pre-release.15"; - - Name = nameof(Cpp2IL); - Destination = Path.Combine(Core.BasePath, Name); - OutputFolder = Path.Combine(Destination, "cpp2il_out"); - - URL = $"https://github.com/SamboyCoding/{Name}/releases/download/{Version}/{Name}-{Version}-{ReleaseName}.zip"; - ExeFilePath = Path.Combine(Destination, $"{Name}.exe"); - FilePath = Path.Combine(Core.BasePath, $"{Name}_{Version}.zip"); - } - - internal override bool ShouldSetup() - => string.IsNullOrEmpty(Config.Values.DumperVersion) - || !Config.Values.DumperVersion.Equals(Version); - - internal override void Cleanup() { } - - internal override void Save() - => Save(ref Config.Values.DumperVersion); - - internal override bool Execute() - { - if (SemVersion.Parse(Version) <= SemVersion.Parse("2022.0.999")) - return ExecuteOld(); - return ExecuteNew(); - } - - private bool ExecuteNew() - { - if (Execute([ - MelonDebug.IsEnabled() ? "--verbose" : string.Empty, - - "--game-path", - "\"" + Path.GetDirectoryName(Core.GameAssemblyPath) + "\"", - - "--exe-name", - "\"" + Process.GetCurrentProcess().ProcessName + "\"", - - "--output-as", - "dummydll", - - "--use-processor", - "attributeanalyzer", - "attributeinjector", - LoaderConfig.Current.UnityEngine.EnableCpp2ILCallAnalyzer ? "callanalyzer" : string.Empty, - LoaderConfig.Current.UnityEngine.EnableCpp2ILNativeMethodDetector ? "nativemethoddetector" : string.Empty, - //"deobfmap", - //"stablenamer", - - ], false, new Dictionary() { - {"NO_COLOR", "1"} - })) - return true; - - return false; - } - - private bool ExecuteOld() - { - if (Execute([ - MelonDebug.IsEnabled() ? "--verbose" : string.Empty, - - "--game-path", - "\"" + Path.GetDirectoryName(Core.GameAssemblyPath) + "\"", - - "--exe-name", - "\"" + Process.GetCurrentProcess().ProcessName + "\"", - - "--skip-analysis", - "--skip-metadata-txts", - "--disable-registration-prompts" - - ], false, new Dictionary() { - {"NO_COLOR", "1"} - })) - return true; - - return false; - } - } -} \ No newline at end of file diff --git a/Dependencies/Il2CppAssemblyGenerator/Packages/DeobfuscationRegex.cs b/Dependencies/Il2CppAssemblyGenerator/Packages/DeobfuscationRegex.cs deleted file mode 100644 index 493bf4c26..000000000 --- a/Dependencies/Il2CppAssemblyGenerator/Packages/DeobfuscationRegex.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace MelonLoader.Il2CppAssemblyGenerator.Packages -{ - internal class DeobfuscationRegex - { - internal string Regex = null; - - internal DeobfuscationRegex() - { - Regex = LoaderConfig.Current.UnityEngine.ForceGeneratorRegex; - if (string.IsNullOrEmpty(Regex)) - Regex = RemoteAPI.Info.ObfuscationRegex; - } - - internal void Setup() - { - if (string.IsNullOrEmpty(Regex)) - { - if (!string.IsNullOrEmpty(Config.Values.DeobfuscationRegex)) - { - Core.AssemblyGenerationNeeded = true; - return; - } - } - else - { - if (string.IsNullOrEmpty(Config.Values.DeobfuscationRegex)) - { - Core.AssemblyGenerationNeeded = true; - return; - } - if (!Config.Values.DeobfuscationRegex.Equals(Regex)) - { - Core.AssemblyGenerationNeeded = true; - return; - } - } - } - - internal void Save() - { - Config.Values.DeobfuscationRegex = Regex; - Config.Save(); - } - } -} diff --git a/Dependencies/Il2CppAssemblyGenerator/Packages/Il2CppInterop.cs b/Dependencies/Il2CppAssemblyGenerator/Packages/Il2CppInterop.cs deleted file mode 100644 index cbb6ca484..000000000 --- a/Dependencies/Il2CppAssemblyGenerator/Packages/Il2CppInterop.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; -using Il2CppInterop.Common; -using Il2CppInterop.Generator; -using Il2CppInterop.Generator.Runners; -using Microsoft.Extensions.Logging; -using AsmResolver.DotNet; -using AsmResolver.DotNet.Serialized; - -namespace MelonLoader.Il2CppAssemblyGenerator.Packages -{ - internal class Il2CppInterop : Models.ExecutablePackage - { - internal Il2CppInterop() - { - Version = typeof(Il2CppInteropGenerator).Assembly.CustomAttributes - .Where(x => x.AttributeType.Name == "AssemblyInformationalVersionAttribute") - .Select(x => x.ConstructorArguments[0].Value.ToString()) - .FirstOrDefault(); - - Name = nameof(Il2CppInterop); - Destination = Path.Combine(Core.BasePath, Name); - OutputFolder = Path.Combine(Destination, "Il2CppAssemblies"); - } - - internal override bool ShouldSetup() - => false; - - internal override bool Execute() - { - Core.Logger.Msg("Reading dumped assemblies for interop generation..."); - - var resolver = new InteropResolver(); - var inputAssemblies = Directory.GetFiles(Core.cpp2il.OutputFolder) - .Where(f => f.EndsWith(".dll")) - .Select(f => ModuleDefinition.FromFile(f, new ModuleReaderParameters() { ModuleResolver = resolver })) - .Select(f => { resolver.Add(f); return f; }) - .Select(f => f.Assembly) - .ToList(); - - var opts = new GeneratorOptions() - { - GameAssemblyPath = Core.GameAssemblyPath, - Source = inputAssemblies, - OutputDir = OutputFolder, - UnityBaseLibsDir = Core.unitydependencies.Destination, - ObfuscatedNamesRegex = string.IsNullOrEmpty(Core.deobfuscationRegex.Regex) ? null : new Regex(Core.deobfuscationRegex.Regex), - Parallel = true, - Il2CppPrefixMode = GeneratorOptions.PrefixMode.OptOut, - }; - - //Inform cecil of the unity base libs - var trusted = (string)AppDomain.CurrentDomain.GetData("TRUSTED_PLATFORM_ASSEMBLIES"); - var allUnityDlls = string.Join(Path.PathSeparator, Directory.GetFiles(Core.unitydependencies.Destination, "*.dll", SearchOption.TopDirectoryOnly)); - // var allDumpedDlls = string.Join(Path.PathSeparator, Directory.GetFiles(Core.dumper.OutputFolder, "*.dll", SearchOption.TopDirectoryOnly)); - AppDomain.CurrentDomain.SetData("TRUSTED_PLATFORM_ASSEMBLIES", trusted + Path.PathSeparator + allUnityDlls); - - if (!string.IsNullOrEmpty(Core.deobfuscationMap.Version)) - { - Core.Logger.Msg("Loading Deobfuscation Map..."); - opts.ReadRenameMap(Core.deobfuscationMap.Destination); - } - - Core.Logger.Msg("Generating Interop Assemblies..."); - -#if !DEBUG - try -#endif - { - Il2CppInteropGenerator.Create(opts) - .AddLogger(new InteropLogger()) - .AddInteropAssemblyGenerator() - .Run(); - } -#if !DEBUG - catch (Exception e) - { - Core.Logger.Error("Error Generating Interop Assemblies!", e); - return false; - } -#endif - - Core.Logger.Msg("Cleaning up..."); - AppDomain.CurrentDomain.SetData("TRUSTED_PLATFORM_ASSEMBLIES", trusted); - //inputAssemblies.ForEach(a => a.Dispose()); - - Core.Logger.Msg("Interop Generation Complete!"); - return true; - } - } - - internal class InteropLogger : ILogger - { - public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) - { - if (logLevel is LogLevel.Debug or LogLevel.Trace) - { - MelonDebug.Msg(formatter(state, exception)); - return; - } - - Core.Logger.Msg(formatter(state, exception)); - } - - public bool IsEnabled(LogLevel logLevel) - { - return logLevel switch - { - LogLevel.Debug or LogLevel.Trace => MelonDebug.IsEnabled(), - _ => true - }; - } - - public IDisposable BeginScope(TState state) - { - throw new NotImplementedException(); - } - } - - internal class InteropResolver : INetModuleResolver - { - private readonly Dictionary _cache = new(); - - public void Dispose() - { - _cache.Clear(); - } - - internal void Add(ModuleDefinition module) - { - _cache[module.Name] = module; - } - - public ModuleDefinition Resolve(string name) - { - return _cache.GetValueOrDefault(name); - } - } -} diff --git a/Dependencies/Il2CppAssemblyGenerator/Packages/Models/PackageBase.cs b/Dependencies/Il2CppAssemblyGenerator/Packages/Models/PackageBase.cs deleted file mode 100644 index b5cbd232e..000000000 --- a/Dependencies/Il2CppAssemblyGenerator/Packages/Models/PackageBase.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.IO; - -namespace MelonLoader.Il2CppAssemblyGenerator.Packages.Models -{ - internal class PackageBase - { - internal string Name; - internal string URL; - internal string FilePath; - internal string Destination; - internal string Version; - - internal virtual bool ShouldSetup() => true; - - internal virtual bool OnProcess() - => FileHandler.Process(FilePath, Destination, MelonUtils.IsWindows ? null : Name); - - internal virtual bool Setup() - { - if (string.IsNullOrEmpty(Version) || string.IsNullOrEmpty(URL)) - return true; - - if (!ShouldSetup()) - { - Core.Logger.Msg($"{Name} is up to date."); - return true; - } - - Core.AssemblyGenerationNeeded = true; - - if (!LoaderConfig.Current.UnityEngine.ForceOfflineGeneration - && ((this is DeobfuscationMap) || !File.Exists(FilePath))) - { - Core.Logger.Msg($"Downloading {Name}..."); - if (!FileHandler.Download(URL, FilePath)) - { - ThrowInternalFailure($"Failed to Download {Name}!"); - return false; - } - } - - Core.Logger.Msg($"Processing {Name}..."); - if (!OnProcess()) - { - ThrowInternalFailure($"Failed to Process {Name}!"); - return false; - } - - Save(); - return true; - } - - internal virtual void Save() { } - internal void Save(ref string configPref) - { - configPref = Version; - Config.Save(); - } - - internal static void ThrowInternalFailure(string txt) => MelonLogger.ThrowInternalFailure(txt); - } -} diff --git a/Dependencies/Il2CppAssemblyGenerator/Packages/UnityDependencies.cs b/Dependencies/Il2CppAssemblyGenerator/Packages/UnityDependencies.cs deleted file mode 100644 index 830b0bece..000000000 --- a/Dependencies/Il2CppAssemblyGenerator/Packages/UnityDependencies.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.IO; - -namespace MelonLoader.Il2CppAssemblyGenerator.Packages -{ - internal class UnityDependencies : Models.PackageBase - { - internal UnityDependencies() - { - Name = nameof(UnityDependencies); - Version = InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(); - URL = $"https://github.com/LavaGang/MelonLoader.UnityDependencies/releases/download/{Version}/Managed.zip"; - Destination = Path.Combine(Core.BasePath, Name); - FilePath = Path.Combine(Core.BasePath, $"{Name}_{Version}.zip"); - } - - internal override bool ShouldSetup() - => string.IsNullOrEmpty(Config.Values.UnityVersion) - || !Config.Values.UnityVersion.Equals(Version); - - internal override void Save() - => Save(ref Config.Values.UnityVersion); - } -} diff --git a/Dependencies/MelonStartScreen/Core.cs b/Dependencies/MelonStartScreen/Core.cs deleted file mode 100644 index 651525d4d..000000000 --- a/Dependencies/MelonStartScreen/Core.cs +++ /dev/null @@ -1,288 +0,0 @@ -using MelonLoader.MelonStartScreen.NativeUtils; -using MelonLoader.Modules; -using MelonLoader.NativeUtils.PEParser; -using System; -using System.Diagnostics; -using System.IO; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Threading; -using Windows; -using MelonLoader.Utils; -using MelonLoader.NativeUtils; - -namespace MelonLoader.MelonStartScreen -{ - internal class Core : MelonModule - { - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr User32SetTimerDelegate(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, IntPtr lpTimerFunc); - private static NativeHook user32Hook = new(); - - private static bool nextSetTimerIsUnity = false; - private static IntPtr titleBarTimer; - - private static bool functionRunDone = false; - private static int functionRunResult = 0; - - internal static string FolderPath; - internal static string ThemesFolderPath; - - public static Core instance; - - public static MelonLogger.Instance Logger => instance.LoggerInstance; - - public override void OnInitialize() - { - instance = this; - } - - private static int LoadAndRun(LemonFunc functionToWaitForAsync) - { - // Start Screen has no signatures for Development Builds of UnityPlayer.dll - if (MelonUnityEngine.UnityDebug.isDebugBuild) - return functionToWaitForAsync(); - - Logger.Msg("Initializing..."); - - FolderPath = Path.Combine(MelonEnvironment.UserDataDirectory, "MelonStartScreen"); - if (!Directory.Exists(FolderPath)) - Directory.CreateDirectory(FolderPath); - - ThemesFolderPath = Path.Combine(FolderPath, "Themes"); - if (!Directory.Exists(ThemesFolderPath)) - Directory.CreateDirectory(ThemesFolderPath); - - UI_Theme.Load(); - if (!UI_Theme.General.Enabled) - return functionToWaitForAsync(); - - // We try to resolve all the signatures, which are available for Unity 2018.1.0+ - // If we can't find them (signatures changed or <2018.1.0), then we run the function and return. - try - { - if (!NativeSignatureResolver.Apply()) - return functionToWaitForAsync(); - - if (!ApplyUser32SetTimerPatch()) - return functionToWaitForAsync(); - - MelonDebug.Msg("Initializing Screen Renderer"); - ScreenRenderer.Init(); - MelonDebug.Msg("Screen Renderer initialized"); - - RegisterMessageCallbacks(); - - // Initial render - ScreenRenderer.Render(); - } - catch (Exception e) - { - Logger.Error(e); - ScreenRenderer.disabled = true; - return functionToWaitForAsync(); - } - - SubscribeToCoreCallbacks(); - - StartFunction(functionToWaitForAsync); - MainLoop(); - - return functionRunResult; - } - - private static void SubscribeToCoreCallbacks() - { - MelonEvents.OnApplicationLateStart.Subscribe(Finish, int.MinValue); - MelonEvents.OnApplicationStart.Subscribe(OnApplicationStart, int.MaxValue); - MelonBase.OnMelonInitializing.Subscribe(OnMelonInitializing, 100); - MelonAssembly.OnAssemblyResolving.Subscribe(OnMelonsResolving, 100); - } - - private static void RegisterMessageCallbacks() - { - MelonLogger.MsgDrawingCallbackHandler += (namesection_color, txt_color, namesection, txt) => ScreenRenderer.UpdateProgressFromLog(txt); - MelonDebug.MsgCallbackHandler += (txt_color, txt) => ScreenRenderer.UpdateProgressFromLog(txt); - } - - #region User32::SetTime Path - - private static unsafe bool ApplyUser32SetTimerPatch() - { - IntPtr original = PEUtils.GetExportedFunctionPointerForModule("USER32.dll", "SetTimer"); - MelonDebug.Msg($"User32::SetTimer original: 0x{(long)original:X}"); - - if (original == IntPtr.Zero) - { - MelonDebug.Error("Failed to find USER32.dll::SetTimer"); - return false; - } - - // We get a native function pointer to User32SetTimerDetour from our current class -#if NET6_0_OR_GREATER - delegate* unmanaged[Cdecl] detourPtr = &User32SetTimerDetour; -#else - IntPtr detourPtr = Marshal.GetFunctionPointerForDelegate((User32SetTimerDelegate)User32SetTimerDetour); - - if (detourPtr == IntPtr.Zero) - { - MelonDebug.Error("Failed to find User32SetTimerDetour"); - return false; - } -#endif - user32Hook.Target = original; - user32Hook.Detour = (IntPtr)detourPtr; - - // And we patch SetTimer to replace it by our hook - MelonDebug.Msg($"Applying USER32.dll::SetTimer Hook at 0x{original.ToInt64():X}"); - user32Hook.Attach(); - MelonDebug.Msg("Applied USER32.dll::SetTimer patch"); - - return true; - } - -#if NET6_0_OR_GREATER - [UnmanagedCallersOnly(CallConvs = new[] {typeof(CallConvCdecl)})] -#endif - private unsafe static IntPtr User32SetTimerDetour(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, IntPtr timerProc) - { - if (nextSetTimerIsUnity) - { - nextSetTimerIsUnity = false; - return IntPtr.Zero; - } - - return user32Hook.Trampoline(hWnd, nIDEvent, uElapse, timerProc); - } - - #endregion - - private static void StartFunction(LemonFunc func) - { - new Thread(() => - { - functionRunResult = func(); - functionRunDone = true; - }) - { - IsBackground = true, - Name = "MelonStartScreen Function Thread" - }.Start(); - } - - private static void MainLoop() - { - while (!functionRunDone) // WM_QUIT - { - ProcessEventsAndRender(true); - } - - if (titleBarTimer != IntPtr.Zero) - { - User32.KillTimer(IntPtr.Zero, titleBarTimer); - titleBarTimer = IntPtr.Zero; - } - } - - #region Event Processing and Rendering - - private static void ProcessEventsAndRender(bool isMainLoop = false) - { - ProcessMessages(); - - if (titleBarTimer != IntPtr.Zero) - { - User32.KillTimer(IntPtr.Zero, titleBarTimer); - titleBarTimer = IntPtr.Zero; - } - ScreenRenderer.Render(); - if (isMainLoop) - Thread.Sleep(16); // ~60fps - else - { - if (titleBarTimer != IntPtr.Zero) - { - User32.KillTimer(IntPtr.Zero, titleBarTimer); - titleBarTimer = IntPtr.Zero; - } - } - } - - private static void ProcessMessages() - { - while (true) - { - User32.PeekMessage(out Msg msg, IntPtr.Zero, 0, 0, 0); - if (msg.message == WindowMessage.QUIT) - { - Process.GetCurrentProcess().Kill(); - return; - } - else if (User32.PeekMessage(out msg, IntPtr.Zero, 0, 0, 1)) // If there a message pending - { - if (msg.message == WindowMessage.NCLBUTTONDOWN || msg.message == (WindowMessage)0x242 /* NCPOINTERDOWN */) - { - if (titleBarTimer == IntPtr.Zero) - titleBarTimer = User32.SetTimer(IntPtr.Zero, IntPtr.Zero, 10, TitleBarTimerUpdateCallback); - nextSetTimerIsUnity = true; - } - else if (msg.message == WindowMessage.PAINT) - ScreenRenderer.Render(); - - User32.TranslateMessage(ref msg); - User32.DispatchMessage(ref msg); - } - else - return; - } - } - - private static void TitleBarTimerUpdateCallback(IntPtr hWnd, uint uMsg, IntPtr nIDEvent, uint dwTime) - { - ScreenRenderer.Render(); - } - - #endregion - - #region Calls from MelonLoader - - internal static void OnMelonInitializing(MelonBase melon) - { - ScreenRenderer.UpdateProgressState(ModLoadStep.InitializeMelons); - ScreenRenderer.UpdateProgressFromMod(melon); - ProcessEventsAndRender(); - } - - internal static void OnMelonsResolving(Assembly asm) - { - ScreenRenderer.UpdateProgressState(ModLoadStep.LoadMelons); - ScreenRenderer.UpdateProgressFromModAssembly(asm); - ProcessEventsAndRender(); - } - - internal static void OnApplicationStart() - { - ScreenRenderer.UpdateProgressState(ModLoadStep.OnApplicationStart); - ProcessEventsAndRender(); - } - - internal static void DisplayModLoadIssuesIfNeeded() - { - // TODO Start a new locking thread with a display of the issues and buttons to either close the game or continue - } - - internal static void Finish() - { - ScreenRenderer.UpdateMainProgress("Starting game...", 1f); - ScreenRenderer.Render(); // Final render, to set the progress bar to 100% - - MelonEvents.OnApplicationLateStart.Unsubscribe(typeof(Core).GetMethod(nameof(Finish), BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)); - MelonEvents.OnApplicationStart.Unsubscribe(typeof(Core).GetMethod(nameof(OnApplicationStart), BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)); - MelonBase.OnMelonInitializing.Unsubscribe(typeof(Core).GetMethod(nameof(OnMelonInitializing), BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)); - MelonAssembly.OnAssemblyResolving.Unsubscribe(typeof(Core).GetMethod(nameof(OnMelonsResolving), BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)); - } - - #endregion - } -} diff --git a/Dependencies/MelonStartScreen/MelonStartScreen.csproj b/Dependencies/MelonStartScreen/MelonStartScreen.csproj deleted file mode 100644 index 605a76a07..000000000 --- a/Dependencies/MelonStartScreen/MelonStartScreen.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - MelonLoader.MelonStartScreen - net35;net6 - true - $(MLOutDir)/MelonLoader - true - true - embedded - - - - - - - - - - - - Runtime - - - \ No newline at end of file diff --git a/Dependencies/MelonStartScreen/ModLoadStep.cs b/Dependencies/MelonStartScreen/ModLoadStep.cs deleted file mode 100644 index d29ccf30f..000000000 --- a/Dependencies/MelonStartScreen/ModLoadStep.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MelonLoader.MelonStartScreen -{ - internal enum ModLoadStep - { - Generation, - LoadMelons, - InitializeMelons, - OnApplicationStart - } -} diff --git a/Dependencies/MelonStartScreen/NativeUtils/NativeFieldValueAttribute.cs b/Dependencies/MelonStartScreen/NativeUtils/NativeFieldValueAttribute.cs deleted file mode 100644 index c9a847e13..000000000 --- a/Dependencies/MelonStartScreen/NativeUtils/NativeFieldValueAttribute.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace MelonLoader.MelonStartScreen.NativeUtils -{ - [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] - class NativeFieldValueAttribute : Attribute - { - internal uint LookupIndex { get; } - internal NativeSignatureFlags Flags { get; } - internal object Value { get; } - internal string[] MinimalUnityVersions { get; } - - public NativeFieldValueAttribute(uint lookupIndex, NativeSignatureFlags flags, object value, params string[] minimalUnityVersions) - { - LookupIndex = lookupIndex; - Flags = flags; - Value = value; - MinimalUnityVersions = minimalUnityVersions; - } - } -} diff --git a/Dependencies/MelonStartScreen/NativeUtils/NativeSignatureAttribute.cs b/Dependencies/MelonStartScreen/NativeUtils/NativeSignatureAttribute.cs deleted file mode 100644 index cb048ac7b..000000000 --- a/Dependencies/MelonStartScreen/NativeUtils/NativeSignatureAttribute.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace MelonLoader.MelonStartScreen.NativeUtils -{ - [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] - internal class NativeSignatureAttribute : Attribute - { - internal uint LookupIndex { get; } - internal NativeSignatureFlags Flags { get; } - internal string Signature { get; } - internal string[] MinimalUnityVersions { get; } - - internal NativeSignatureAttribute(uint lookupIndex, NativeSignatureFlags flags, string signature, params string[] minimalUnityVersions) - { - LookupIndex = lookupIndex; - Flags = flags; - Signature = signature; - MinimalUnityVersions = minimalUnityVersions; - } - } -} diff --git a/Dependencies/MelonStartScreen/NativeUtils/NativeSignatureFlags.cs b/Dependencies/MelonStartScreen/NativeUtils/NativeSignatureFlags.cs deleted file mode 100644 index 8ec8628ae..000000000 --- a/Dependencies/MelonStartScreen/NativeUtils/NativeSignatureFlags.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace MelonLoader.MelonStartScreen.NativeUtils -{ - internal enum NativeSignatureFlags - { - None = 0, - - Il2Cpp = 1, - Mono = 2, - - //Dev = 4, - //NonDev = 8 - - X86 = 16, - X64 = 32, - //ARMEABIV7A = 64, - } -} diff --git a/Dependencies/MelonStartScreen/NativeUtils/NativeSignatureResolver.cs b/Dependencies/MelonStartScreen/NativeUtils/NativeSignatureResolver.cs deleted file mode 100644 index 94b626a6a..000000000 --- a/Dependencies/MelonStartScreen/NativeUtils/NativeSignatureResolver.cs +++ /dev/null @@ -1,161 +0,0 @@ -using System; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using MelonLoader.NativeUtils; - -namespace MelonLoader.MelonStartScreen.NativeUtils -{ - internal static class NativeSignatureResolver - { - internal static bool Apply() - { - NativeSignatureFlags currentFlags = default; - currentFlags |= MelonUtils.IsGame32Bit() ? NativeSignatureFlags.X86 : NativeSignatureFlags.X64; - currentFlags |= MelonUtils.IsGameIl2Cpp() ? NativeSignatureFlags.Il2Cpp : NativeSignatureFlags.Mono; - MelonDebug.Msg("Current Unity flags: " + (uint)currentFlags); - - string currentUnityVersion = InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(); - string moduleName = "UnityPlayer.dll"; -#if LINUX - // TODO -#elif OSX - // TODO -#elif ANDROID - // TODO -#else - if (!currentUnityVersion.StartsWith("20") || currentUnityVersion.StartsWith("2017.1")) - moduleName = "player_win.exe"; -#endif - - - IntPtr moduleAddress = IntPtr.Zero; - int moduleSize = 0; - - foreach (ProcessModule module in Process.GetCurrentProcess().Modules) - { - if (module.ModuleName == moduleName) - { - moduleAddress = module.BaseAddress; - moduleSize = module.ModuleMemorySize; - break; - } - } - - if (moduleAddress == IntPtr.Zero) - { - Core.Logger.Error($"Failed to find module \"{moduleName}\""); - return false; - } - - bool success = true; - foreach (Type type in typeof(NativeSignatureResolver).Assembly.GetTypes()) - { - foreach (FieldInfo fi in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)) - { - bool hasAttribute = false; - bool signaturefound = false; - bool optionalOnEarlyVersion = false; - IOrderedEnumerable nativeSignatureAttributes = fi.GetCustomAttributes(false) - .Where(attr => attr is NativeSignatureAttribute) - .Select(attr => (NativeSignatureAttribute)attr) - .OrderByDescending(attr => attr.LookupIndex); - foreach (NativeSignatureAttribute attribute in nativeSignatureAttributes) - { - hasAttribute = true; - if ((attribute.Flags & currentFlags) != attribute.Flags) - continue; - - if (!IsUnityVersionOverOrEqual(currentUnityVersion, attribute.MinimalUnityVersions)) - continue; - - signaturefound = true; - - if (attribute.Signature == null) - { - optionalOnEarlyVersion = true; - break; - } - - IntPtr ptr = CppUtils.Sigscan(moduleAddress, moduleSize, attribute.Signature); - if (ptr == IntPtr.Zero) - { - success = false; - Core.Logger.Error("Failed to find the signature for field " + fi.Name + " in module. Signature: " + attribute.Signature); - break; - } - - if (typeof(Delegate).IsAssignableFrom(fi.FieldType)) - fi.SetValue(null, Marshal.GetDelegateForFunctionPointer(ptr, fi.FieldType)); - else if (typeof(IntPtr).IsAssignableFrom(fi.FieldType)) - fi.SetValue(null, ptr); - else - Core.Logger.Error($"Invalid target type for field \"{fi.FieldType} {fi.Name}\""); - - MelonDebug.Msg("Signature for " + fi.Name + ": " + attribute.Signature); - break; - } - - if (hasAttribute && !signaturefound && !optionalOnEarlyVersion) - { - Core.Logger.Error("Failed to find a signature for field " + fi.Name + " for this version of Unity"); - success = false; - } - - hasAttribute = false; - signaturefound = false; - IOrderedEnumerable nativeFieldValueAttributes = fi.GetCustomAttributes(false) - .Where(attr => attr is NativeFieldValueAttribute) - .Select(attr => (NativeFieldValueAttribute)attr) - .OrderByDescending(attr => attr.LookupIndex); - foreach (NativeFieldValueAttribute attribute in nativeFieldValueAttributes) - { - hasAttribute = true; - if ((attribute.Flags & currentFlags) != attribute.Flags) - continue; - - if (!IsUnityVersionOverOrEqual(currentUnityVersion, attribute.MinimalUnityVersions)) - continue; - - signaturefound = true; - - fi.SetValue(null, attribute.Value); - - MelonDebug.Msg("Value for " + fi.Name + ": " + attribute.Value); - break; - } - - if (hasAttribute && !signaturefound) - { - Core.Logger.Error("Failed to find a value for field " + fi.Name + " for this version of Unity"); - success = false; - } - } - } - - return success; - } - - internal static bool IsUnityVersionOverOrEqual(string currentversion, string[] validversions) - { - if (validversions == null || validversions.Length == 0) - return true; - - string[] versionparts = currentversion.Split('.'); - - foreach (string validversion in validversions) - { - string[] validversionparts = validversion.Split('.'); - - if ( - int.Parse(versionparts[0]) >= int.Parse(validversionparts[0]) && - int.Parse(versionparts[1]) >= int.Parse(validversionparts[1]) && - int.Parse(versionparts[2]) >= int.Parse(validversionparts[2])) - return true; - } - - return false; - } - } -} diff --git a/Dependencies/MelonStartScreen/ProgressParser.cs b/Dependencies/MelonStartScreen/ProgressParser.cs deleted file mode 100644 index 2bbf33c72..000000000 --- a/Dependencies/MelonStartScreen/ProgressParser.cs +++ /dev/null @@ -1,364 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text.RegularExpressions; - -namespace MelonLoader.MelonStartScreen -{ - internal static class ProgressParser - { - private static float generationPercent = MelonUtils.IsGameIl2Cpp() ? 80f : 10f; - private static ModLoadStep currentStep = ModLoadStep.Generation; - private static string currentStepName = "___"; - - internal struct AverageStepDuration - { - public string message; - public float weight; - public string progresstext; - - public AverageStepDuration(string message, float weight, string progresstext) - { - this.message = message; - this.weight = weight; - this.progresstext = progresstext; - } - } - - private static readonly Dictionary stepsNames = new Dictionary() - { - { ModLoadStep.LoadMelons, "Loading Melons" }, - { ModLoadStep.InitializeMelons, "Initializing" }, - { ModLoadStep.OnApplicationStart, "Loading..." } - }; - - public static float GetProgressFromLog(string data, ref string progressText, float default_) // TODO flags (il2cpp/mono, cpp2il/il2cppdumper) - { - if (currentStep != ModLoadStep.Generation) - return default_; - - if (Regex.IsMatch(data, "Assembly is up to date")) - { - generationPercent = default_ * 100f; - return default_; - } - - float totalTime = 0; - float progressTime = 0; - foreach (var entry in averageStepDurations) - { - if (progressTime <= 0f && Regex.IsMatch(data, entry.message)) - { - progressTime = totalTime; - progressText = entry.progresstext ?? data; - } - - totalTime += entry.weight; - } - - return progressTime > 0 ? (progressTime / totalTime) * (generationPercent * 0.01f) : default_; - } - - public static float GetProgressFromMod(MelonBase melon, ref string progressText) - { - progressText = $"{currentStepName} {melon.MelonTypeName}: {melon.Info.Name} {melon.Info.Version}"; - - float generationPart = generationPercent * 0.01f; - return generationPart + (((int)currentStep - 1) * ((1 - generationPart) / 4)); - } - - public static float GetProgressFromModAssembly(Assembly asm, ref string progressText) - { - progressText = $"{currentStepName}: {Path.GetFileName(asm.Location)}"; - - float generationPart = generationPercent * 0.01f; - return generationPart + (((int)currentStep - 1) * ((1 - generationPart) / 4)); - } - - public static bool SetModState(ModLoadStep step, ref string progressText, out float generationPart) - { - generationPart = generationPercent * 0.01f; - generationPart += ((int)step - 1) * ((1 - generationPart) / 3); - - if (currentStep == step) - return false; - - currentStep = step; - if (!stepsNames.TryGetValue(step, out currentStepName)) - currentStepName = $"{step}"; - progressText = currentStepName; - - return true; - } - - internal static readonly AverageStepDuration[] averageStepDurations = new AverageStepDuration[] - { - // Il2CppAssemblyGenerator - new AverageStepDuration( - @"Contacting RemoteAPI\.\.\.", - 100f, - @"Initialization - Contacting Remote API" - ), - new AverageStepDuration( - @"Downloading Unity \S+ Dependencies\.\.\.", - 1000f, - @"Initialization - Downloading Unity Dependencies" - ), - new AverageStepDuration( - @"Extracting .* to .*UnityDpendencies", - 500f, - @"Initialization - Extracting Unity Dependencies" - ), - new AverageStepDuration( - @"Downloading Cpp2IL\.\.\.", - 500f, - @"Initialization - Downloading Cpp2IL" - ), - new AverageStepDuration( - @"Extracting .* to .*Cpp2IL", - 500f, - @"Initialization - Extracting Cpp2IL" - ), - new AverageStepDuration( - @"Downloading DeobfuscationMap\.\.\.", - 500f, - @"Initialization - Downloading DeobfuscationMap" - ), - new AverageStepDuration( - @"Checking GameAssembly\.\.\.", - 1000f, - @"Initialization - Checking GameAssembly" - ), - - - // Cpp2IL - // Slaynash: I skipped a lot of steps taking less than 100ms, but we may want to add them back for slower platforms - new AverageStepDuration( - @"Initializing metadata\.\.\.", - 2500f, - "Cpp2IL - Initializing metadata" - ), - new AverageStepDuration( - @"Searching Binary for Required Data", - 402f, - "Cpp2IL - Seaching Binary for Required Data" - ), - new AverageStepDuration( - @"Initializing Binary", - 402f, - "Cpp2IL - Initializing Binary" - ), - new AverageStepDuration( - @"Initializing Binary", - 2533f, - "Cpp2IL - Initializing Binary" - ), - new AverageStepDuration( - @"Pre-generating stubs", - 708f, - "Cpp2IL - Building Assemblies: Pre-generating stubs" - ), - new AverageStepDuration( - @"Populating mscorlib\.dll", - 340f, - "Cpp2IL - Building Assemblies: Populating assemblies" - ), - new AverageStepDuration( - @"Populating Assembly-CSharp\.dll", - 3000f, - "Cpp2IL - Building Assemblies: Populating assemblies" - ), - new AverageStepDuration( - @"Fixing up explicit overrides", - 1000f, - "Cpp2IL - Fixing up explicit overrides" - ), - new AverageStepDuration( - @"Running Scan for Known Functions", - 300f, - "Cpp2IL - Running Scan for Known Functions" - ), - new AverageStepDuration( - @"Applying type, method, and field attributes", - 5500f, - "Cpp2IL - Applying type, method, and field attributes" - ), - new AverageStepDuration( - @"Saving .* assemblies to ", - 4000f, - "Cpp2IL - Saving assemblies" - ), - - - // Il2CppInterop - new AverageStepDuration( - @"Reading assemblies\.\.\.", - 170f, - "Il2CppInterop - Reading assemblies" - ), - new AverageStepDuration( - @"Reading system assemblies\.\.\.", - 14f, - "Il2CppInterop - Reading system assemblies" - ), - new AverageStepDuration( - @"Reading unity assemblies\.\.\.", - 29f, - "Il2CppInterop - Reading unity assemblies" - ), - new AverageStepDuration( - @"Creating rewrite assemblies\.\.\.", - 20f, - "Il2CppInterop - Creating rewrite assemblies" - ), - new AverageStepDuration( - @"Computing renames\.\.\.", - 281f, - "Il2CppInterop - Computing renames" - ), - new AverageStepDuration( - @"Creating typedefs\.\.\.", - 109f, - "Il2CppInterop - Creating typedefs" - ), - new AverageStepDuration( - @"Computing struct blittability\.\.\.", - 10f, - "Il2CppInterop - Computing struct blittability" - ), - new AverageStepDuration( - @"Filling typedefs\.\.\.", - 27f, - "Il2CppInterop - Filling typedefs" - ), - new AverageStepDuration( - @"Filling generic constraints\.\.\.", - 6f, - "Il2CppInterop - Filling generic constraints" - ), - new AverageStepDuration( - @"Creating members\.\.\.", - 2256f, - "Il2CppInterop - Creating members" - ), - new AverageStepDuration( - @"Scanning method cross-references\.\.\.", - 1919f, - "Il2CppInterop - Scanning method cross-references" - ), - new AverageStepDuration( - @"Finalizing method declarations\.\.\.", - 2867f, - "Il2CppInterop - Finalizing method declarations" - ), - new AverageStepDuration( - @"Filling method parameters\.\.\.", - 510f, - "Il2CppInterop - Filling method parameters" - ), - new AverageStepDuration( - @"Creating static constructors\.\.\.", - 1237f, - "Il2CppInterop - Creating static constructors" - ), - new AverageStepDuration( - @"Creating value type fields\.\.\.", - 186f, - "Il2CppInterop - Creating value type fields" - ), - new AverageStepDuration( - @"Creating enums\.\.\.", - 69f, - "Il2CppInterop - Creating enums" - ), - new AverageStepDuration( - @"Creating IntPtr constructors\.\.\.", - 63f, - "Il2CppInterop - Creating IntPtr constructors" - ), - new AverageStepDuration( - @"Creating type getters\.\.\.", - 132f, - "Il2CppInterop - Creating type getters" - ), - /* - ( - @"Creating non-blittable struct constructors\.\.\.", - 38f, - "Il2CppInterop - Creating non-blittable struct constructors" - ), - ( - @"Creating generic method static constructors\.\.\.", - 42f, - "Il2CppInterop - Creating generic method static constructors" - ), - */ - new AverageStepDuration( - @"Creating field accessors\.\.\.", - 1642f, - "Il2CppInterop - Creating field accessors" - ), - new AverageStepDuration( - @"Filling methods\.\.\.", - 2385f, - "Il2CppInterop - Filling methods" - ), - new AverageStepDuration( - @"Generating implicit conversions\.\.\.", - 121f, - "Il2CppInterop - Generating implicit conversions" - ), - new AverageStepDuration( - @"Creating properties\.\.\.", - 102f, - "Il2CppInterop - Creating properties" - ), - new AverageStepDuration( - @"Unstripping types\.\.\.", - 44f, - "Il2CppInterop - Unstripping types" - ), - new AverageStepDuration( - @"Unstripping fields\.\.\.", - 5f, - "Il2CppInterop - Unstripping fields" - ), - new AverageStepDuration( - @"Unstripping methods\.\.\.", - 241f, - "Il2CppInterop - Unstripping methods" - ), - new AverageStepDuration( - @"Unstripping method bodies\.\.\.", - 266f, - "Il2CppInterop - Unstripping method bodies" - ), - new AverageStepDuration( - @"Generating forwarded types\.\.\.", - 4f, - "Il2CppInterop - Generating forwarded types" - ), - new AverageStepDuration( - @"Writing xref cache\.\.\.", - 1179f, - "Il2CppInterop - Writing xref cache" - ), - new AverageStepDuration( - @"Writing assemblies\.\.\.", - 2586f, - "Il2CppInterop - Writing assemblies" - ), - new AverageStepDuration( - @"Writing method pointer map\.\.\.", - 89f, - "Il2CppInterop - Writing method pointer map" - ), - // Move files - new AverageStepDuration( - @"Deleting .*\.dll", - 500f, - "Il2CppInterop - Moving files" - ), - }; - } -} diff --git a/Dependencies/MelonStartScreen/Resources/Loading_Halloween.dat b/Dependencies/MelonStartScreen/Resources/Loading_Halloween.dat deleted file mode 100644 index c7643a776..000000000 Binary files a/Dependencies/MelonStartScreen/Resources/Loading_Halloween.dat and /dev/null differ diff --git a/Dependencies/MelonStartScreen/Resources/Loading_Lemon.dat b/Dependencies/MelonStartScreen/Resources/Loading_Lemon.dat deleted file mode 100644 index 54c705dde..000000000 Binary files a/Dependencies/MelonStartScreen/Resources/Loading_Lemon.dat and /dev/null differ diff --git a/Dependencies/MelonStartScreen/Resources/Loading_Melon.dat b/Dependencies/MelonStartScreen/Resources/Loading_Melon.dat deleted file mode 100644 index 9a92310a9..000000000 Binary files a/Dependencies/MelonStartScreen/Resources/Loading_Melon.dat and /dev/null differ diff --git a/Dependencies/MelonStartScreen/Resources/Logo_Halloween.dat b/Dependencies/MelonStartScreen/Resources/Logo_Halloween.dat deleted file mode 100644 index a34ba5c48..000000000 Binary files a/Dependencies/MelonStartScreen/Resources/Logo_Halloween.dat and /dev/null differ diff --git a/Dependencies/MelonStartScreen/Resources/Logo_Lemon.dat b/Dependencies/MelonStartScreen/Resources/Logo_Lemon.dat deleted file mode 100644 index 4803417e0..000000000 Binary files a/Dependencies/MelonStartScreen/Resources/Logo_Lemon.dat and /dev/null differ diff --git a/Dependencies/MelonStartScreen/Resources/Logo_Melon.dat b/Dependencies/MelonStartScreen/Resources/Logo_Melon.dat deleted file mode 100644 index abf653010..000000000 Binary files a/Dependencies/MelonStartScreen/Resources/Logo_Melon.dat and /dev/null differ diff --git a/Dependencies/MelonStartScreen/ScreenRenderer.cs b/Dependencies/MelonStartScreen/ScreenRenderer.cs deleted file mode 100644 index fe930614b..000000000 --- a/Dependencies/MelonStartScreen/ScreenRenderer.cs +++ /dev/null @@ -1,125 +0,0 @@ -using MelonLoader.MelonStartScreen.NativeUtils; -using MelonLoader.MelonStartScreen.UI; -using System; -using System.Reflection; -using MelonUnityEngine.CoreModule; -using UnityPlayer; - -namespace MelonLoader.MelonStartScreen -{ - internal static class ScreenRenderer - { - private const float logoRatio = 1.2353f; - - private delegate void SetupPixelCorrectCoordinates(bool param_1); - -#pragma warning disable 0649 - #region m_SetupPixelCorrectCoordinates Signatures - [NativeSignature(01, NativeSignatureFlags.X86, "55 8b ec 83 ec 60 56 e8 ?? ?? ?? ?? 8b f0 8b 45 08 50 8d 4d f0 51 e8", "2017.1.0")] - [NativeSignature(02, NativeSignatureFlags.X86, "55 8b ec 83 ec 60 53 56 57 e8 ?? ?? ?? ?? ff 75 08 8b d8 8d 45 f0 50 e8", "2017.3.0", "2018.1.0")] - [NativeSignature(03, NativeSignatureFlags.X86, "55 8b ec 83 ec 60 53 56 57 e8 ?? ?? ?? ?? 8b d8 e8 ?? ?? ?? ?? ff 75 08 8d 4d f0", "2019.1.0")] - [NativeSignature(01, NativeSignatureFlags.X64, "48 89 5c 24 08 57 48 81 ec a0 00 00 00 8b d9 e8 ?? ?? ?? ?? 48 8b f8 e8", "2017.1.0")] - #endregion - private static SetupPixelCorrectCoordinates m_SetupPixelCorrectCoordinates; -#pragma warning restore 0649 - - public static bool disabled = false; - - private static uint shouldCallWFLPAGT = 0; - - internal static void Init() - { - if (disabled) - return; - - try - { - MelonDebug.Msg("Initializing UIStyleValues"); - UI_Style.Init(); - MelonDebug.Msg("UIStyleValues Initialized"); - - uint graphicsDeviceType = SystemInfo.GetGraphicsDeviceType(); - MelonDebug.Msg("Graphics Device Type: " + graphicsDeviceType); - shouldCallWFLPAGT = NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new[] { "2020.2.7", "2020.3.0", "2021.1.0" }) - && (graphicsDeviceType == /*DX11*/2 || graphicsDeviceType == /*DX12*/18) - ? graphicsDeviceType : 0; - } - catch (Exception e) - { - Core.Logger.Error("Exception while init rendering: " + e); - disabled = true; - } - } - - internal static unsafe void Render() - { - if (disabled) - return; - - try - { - m_SetupPixelCorrectCoordinates(false); - - UI_Style.Render(); - - GfxDevice.PresentFrame(); - if (shouldCallWFLPAGT != 0) - GfxDevice.WaitForLastPresentationAndGetTimestamp(shouldCallWFLPAGT); - } - catch (Exception e) - { - Core.Logger.Error("Exception while rendering: " + e); - disabled = true; - } - } - - internal static void UpdateMainProgress(string text, float progress) - { - if (UI_Style.ProgressBar == null) - return; - - UI_Style.ProgressBar.text.text = text; - UI_Style.ProgressBar.text.isDirty = true; - UI_Style.ProgressBar.progress = progress; - } - - internal static void UpdateProgressFromLog(string msg) - { - if (UI_Style.ProgressBar == null) - return; - - UI_Style.ProgressBar.progress = ProgressParser.GetProgressFromLog(msg, ref UI_Style.ProgressBar.text.text, UI_Style.ProgressBar.progress); - UI_Style.ProgressBar.text.isDirty = true; - } - - internal static void UpdateProgressFromMod(MelonBase melon) - { - if (UI_Style.ProgressBar == null) - return; - - UI_Style.ProgressBar.progress = ProgressParser.GetProgressFromMod(melon, ref UI_Style.ProgressBar.text.text); - UI_Style.ProgressBar.text.isDirty = true; - } - - internal static void UpdateProgressFromModAssembly(Assembly asm) - { - if (UI_Style.ProgressBar == null) - return; - - UI_Style.ProgressBar.progress = ProgressParser.GetProgressFromModAssembly(asm, ref UI_Style.ProgressBar.text.text); - UI_Style.ProgressBar.text.isDirty = true; - } - - internal static void UpdateProgressState(ModLoadStep step) - { - if (UI_Style.ProgressBar == null) - return; - - if (ProgressParser.SetModState(step, ref UI_Style.ProgressBar.text.text, out float generationPart)) - { - UI_Style.ProgressBar.progress = generationPart; - UI_Style.ProgressBar.text.isDirty = true; - } - } - } -} diff --git a/Dependencies/MelonStartScreen/TextMeshGenerator.cs b/Dependencies/MelonStartScreen/TextMeshGenerator.cs deleted file mode 100644 index e7db0d981..000000000 --- a/Dependencies/MelonStartScreen/TextMeshGenerator.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Linq; -using MelonUnityEngine; - -namespace MelonLoader.MelonStartScreen -{ - internal static class TextMeshGenerator - { - public static Mesh Generate(string text, TextGenerationSettings settings) - { - TextGenerator generator = new TextGenerator(); - generator.Populate(text, settings); - - Mesh mesh = new Mesh(); - UIVertexWrapper[] vertices = generator.GetVerticesArray(); - Vector3[] verticesPosition = vertices.Select(v => v.position).ToArray(); - mesh.vertices = verticesPosition; - if (GL.sRGBWrite) - mesh.colors = vertices.Select(v => { - Color color = v.color; - color.r = (float)Math.Pow(color.r, 2.2); - color.g = (float)Math.Pow(color.g, 2.2); - color.b = (float)Math.Pow(color.b, 2.2); - return color; - }).ToArray(); - else - mesh.colors = vertices.Select(v => (Color)v.color).ToArray(); - mesh.normals = vertices.Select(v => v.normal).ToArray(); - mesh.tangents = vertices.Select(v => v.tangent).ToArray(); - mesh.uv = vertices.Select(v => v.uv0).ToArray(); - - int characterCount = generator.vertexCount / 4; - int[] indices = new int[characterCount * 6]; - for (var i = 0; i < characterCount; ++i) - { - int vertIndexStart = i * 4; - int trianglesIndexStart = i * 6; - indices[trianglesIndexStart++] = vertIndexStart; - indices[trianglesIndexStart++] = vertIndexStart + 1; - indices[trianglesIndexStart++] = vertIndexStart + 2; - indices[trianglesIndexStart++] = vertIndexStart; - indices[trianglesIndexStart++] = vertIndexStart + 2; - indices[trianglesIndexStart] = vertIndexStart + 3; - } - mesh.triangles = indices; - mesh.RecalculateBounds(); - - return mesh; - } - } -} diff --git a/Dependencies/MelonStartScreen/UI/Objects/UI_AnimatedImage.cs b/Dependencies/MelonStartScreen/UI/Objects/UI_AnimatedImage.cs deleted file mode 100644 index 0131d24c0..000000000 --- a/Dependencies/MelonStartScreen/UI/Objects/UI_AnimatedImage.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using MelonUnityEngine; - -namespace MelonLoader.MelonStartScreen.UI.Objects -{ - internal class UI_AnimatedImage : UI_Image - { - private Stopwatch stopwatch = new Stopwatch(); - private float frameDelayMS = 90f; - private Texture2D[] textures; - - internal UI_AnimatedImage(UI_Theme.ImageSettings imageSettings, string filepath) : base(imageSettings, filepath) { } - internal UI_AnimatedImage(UI_Theme.ImageSettings imageSettings, byte[] filedata) : base(imageSettings, filedata) { } - internal override void LoadImage(UI_Theme.ImageSettings imageSettings, byte[] filedata) - { - config = imageSettings; - - mgGif.Decoder decoder = new mgGif.Decoder(filedata); - - var img = decoder.NextImage(); - frameDelayMS = img.Delay; - - List images = new List(); - while (img != null) - { - Texture2D newtexture = img.CreateTexture(config.Filter); - newtexture.hideFlags = HideFlags.HideAndDontSave; - newtexture.DontDestroyOnLoad(); - - images.Add(newtexture); - img = decoder.NextImage(); - } - - textures = images.ToArray(); - MainTexture = textures[0]; - AspectRatio = MainTexture.width / (float)MainTexture.height; - - AllElements.Add(this); - } - - internal override void Render() - { - if (!config.Enabled || (textures == null) || (textures.Length <= 0)) - { - if (stopwatch.IsRunning) - stopwatch.Stop(); - return; - } - - if (!stopwatch.IsRunning) - stopwatch.Start(); - - int image = (int)((float)(stopwatch.ElapsedMilliseconds / frameDelayMS) % textures.Length); - MainTexture = textures[image]; - - base.Render(); - } - - internal override void Render(int x, int y, int width, int height) - { - if (!config.Enabled) - { - if (stopwatch.IsRunning) - stopwatch.Stop(); - return; - } - - if (!stopwatch.IsRunning) - stopwatch.Start(); - - int image = (int)((float)(stopwatch.ElapsedMilliseconds / frameDelayMS) % textures.Length); - MainTexture = textures[image]; - - base.Render(x, y, width, height); - } - - internal override void Dispose() - { - if ((textures == null) || (textures.Length <= 0)) - return; - - foreach (Texture2D texture in textures) - texture.DestroyImmediate(); - - textures = null; - MainTexture = null; - } - } -} diff --git a/Dependencies/MelonStartScreen/UI/Objects/UI_Background.cs b/Dependencies/MelonStartScreen/UI/Objects/UI_Background.cs deleted file mode 100644 index 37cb565b3..000000000 --- a/Dependencies/MelonStartScreen/UI/Objects/UI_Background.cs +++ /dev/null @@ -1,48 +0,0 @@ -using MelonUnityEngine; - -namespace MelonLoader.MelonStartScreen.UI.Objects -{ - internal class UI_Background : UI_Object - { - private UI_Theme.cBackground config; - private UI_Image image; - internal Texture2D solidTexture; - - internal UI_Background(UI_Theme.cBackground backgroundSettings) - { - config = backgroundSettings; - image = UI_Utils.LoadImage(config, "Background"); - - solidTexture = UI_Utils.CreateColorTexture(config.SolidColor); - solidTexture.hideFlags = HideFlags.HideAndDontSave; - solidTexture.DontDestroyOnLoad(); - AllElements.Add(this); - } - - internal override void Render() - { - int sw = Screen.width; - int sh = Screen.height; - - if (solidTexture != null) - Graphics.DrawTexture(new Rect(0, 0, sw, sh), solidTexture); - - if (image != null) - { - if (config.StretchToScreen) - image.Render(0, 0, sw, sh); - else - image.Render(); - } - } - - internal override void Dispose() - { - if (solidTexture == null) - return; - - solidTexture.DestroyImmediate(); - solidTexture = null; - } - } -} diff --git a/Dependencies/MelonStartScreen/UI/Objects/UI_Image.cs b/Dependencies/MelonStartScreen/UI/Objects/UI_Image.cs deleted file mode 100644 index 584848022..000000000 --- a/Dependencies/MelonStartScreen/UI/Objects/UI_Image.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.IO; -using MelonUnityEngine; - -namespace MelonLoader.MelonStartScreen.UI.Objects -{ - internal class UI_Image : UI_Object - { - internal UI_Theme.ImageSettings config; - internal Texture2D MainTexture; - internal float AspectRatio; - - internal UI_Image(UI_Theme.ImageSettings imageSettings, string filepath) => LoadImage(imageSettings, File.ReadAllBytes(filepath)); - internal UI_Image(UI_Theme.ImageSettings imageSettings, byte[] filedata) => LoadImage(imageSettings, filedata); - - internal virtual void LoadImage(UI_Theme.ImageSettings imageSettings, byte[] filedata) - { - config = imageSettings; - - MainTexture = new Texture2D(2, 2); - MainTexture.filterMode = config.Filter; - - if (!ImageConversion.LoadImage(MainTexture, filedata, false)) - throw new Exception("ImageConversion.LoadImage Failed!"); - - AspectRatio = MainTexture.width / (float)MainTexture.height; - - MainTexture.hideFlags = HideFlags.HideAndDontSave; - MainTexture.DontDestroyOnLoad(); - - AllElements.Add(this); - } - - internal override void Render() - { - if (!config.Enabled) - return; - if (MainTexture == null) - return; - - int aspectHeight = config.MaintainAspectRatio ? (int)(config.Size.Item1 / AspectRatio) : config.Size.Item2; - - UI_Utils.AnchorToScreen(config.ScreenAnchor, config.Position.Item1, config.Position.Item2, out int anchor_x, out int anchor_y); - UI_Utils.AnchorToObject(config.Anchor, anchor_x, anchor_y, config.Size.Item1, -aspectHeight, out anchor_x, out anchor_y); - - Graphics.DrawTexture(new Rect(anchor_x, anchor_y, config.Size.Item1, -aspectHeight), MainTexture); - } - - internal virtual void Render(int x, int y, int width, int height) - { - if (!config.Enabled) - return; - Graphics.DrawTexture(new Rect(x, height + y, width, -height), MainTexture); - } - - internal override void Dispose() - { - if (MainTexture == null) - return; - - MainTexture.DestroyImmediate(); - MainTexture = null; - } - } -} diff --git a/Dependencies/MelonStartScreen/UI/Objects/UI_Object.cs b/Dependencies/MelonStartScreen/UI/Objects/UI_Object.cs deleted file mode 100644 index 9f165c1a0..000000000 --- a/Dependencies/MelonStartScreen/UI/Objects/UI_Object.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MelonLoader.MelonStartScreen.UI.Objects -{ - internal abstract class UI_Object : IDisposable - { - internal static List AllElements = new List(); - private bool disposedValue; - - internal virtual void Dispose() { } - internal abstract void Render(); - - protected virtual void Dispose(bool managed) - { - if (disposedValue) - return; - if (managed) - Dispose(); - disposedValue = true; - } - - void IDisposable.Dispose() - { - Dispose(managed: true); - GC.SuppressFinalize(this); - } - - internal static void DisposeOfAll() - { - if (AllElements.Count <= 0) - return; - foreach (UI_Object obj in AllElements) - obj.Dispose(); - AllElements.Clear(); - } - } -} diff --git a/Dependencies/MelonStartScreen/UI/Objects/UI_ProgressBar.cs b/Dependencies/MelonStartScreen/UI/Objects/UI_ProgressBar.cs deleted file mode 100644 index 0dded3547..000000000 --- a/Dependencies/MelonStartScreen/UI/Objects/UI_ProgressBar.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using MelonUnityEngine; - -namespace MelonLoader.MelonStartScreen.UI.Objects -{ - internal class UI_ProgressBar : UI_Object - { - private UI_Theme.cProgressBar config; - internal float progress; - internal UI_Text text; - private Texture2D innerTexture; - private Texture2D outerTexture; - - internal UI_ProgressBar(UI_Theme.cProgressBar progressBarSettings, UI_Theme.TextSettings textSettings) - { - config = progressBarSettings; - text = new UI_Text(textSettings); - - innerTexture = UI_Utils.CreateColorTexture(config.InnerColor); - innerTexture.hideFlags = HideFlags.HideAndDontSave; - innerTexture.DontDestroyOnLoad(); - - outerTexture = UI_Utils.CreateColorTexture(config.OuterColor); - outerTexture.hideFlags = HideFlags.HideAndDontSave; - outerTexture.DontDestroyOnLoad(); - - AllElements.Add(this); - } - - internal override void Render() - { - if (config.Enabled && (outerTexture != null) && (UI_Style.Background.solidTexture != null) && (innerTexture != null)) - { - UI_Utils.AnchorToScreen(config.ScreenAnchor, config.Position.Item1, config.Position.Item2, out int anchor_x, out int anchor_y); - UI_Utils.AnchorToObject(config.Anchor, anchor_x, anchor_y, config.Size.Item1, config.Size.Item2, out anchor_x, out anchor_y); - - Graphics.DrawTexture(new Rect(anchor_x, anchor_y, config.Size.Item1, config.Size.Item2), outerTexture); - Graphics.DrawTexture(new Rect(anchor_x + 6, anchor_y + 6, config.Size.Item1 - 12, config.Size.Item2 - 12), UI_Style.Background.solidTexture); - Graphics.DrawTexture(new Rect(anchor_x + 9, anchor_y + 9, (int)((config.Size.Item1 - 18) * Math.Min(1.0f, progress)), config.Size.Item2 - 18), innerTexture); - } - - text?.Render(); - } - - internal override void Dispose() - { - if (innerTexture != null) - { - innerTexture.DestroyImmediate(); - innerTexture = null; - } - - if (outerTexture != null) - { - outerTexture.DestroyImmediate(); - outerTexture = null; - } - - if (text != null) - text.Dispose(); - } - } -} diff --git a/Dependencies/MelonStartScreen/UI/Objects/UI_Text.cs b/Dependencies/MelonStartScreen/UI/Objects/UI_Text.cs deleted file mode 100644 index d926baea9..000000000 --- a/Dependencies/MelonStartScreen/UI/Objects/UI_Text.cs +++ /dev/null @@ -1,98 +0,0 @@ -using MelonLoader.Properties; -using MelonUnityEngine; - -namespace MelonLoader.MelonStartScreen.UI.Objects -{ - internal class UI_Text : UI_Object - { - private UI_Theme.TextSettings config; - private Mesh mesh; - internal bool isDirty = true; - internal string text; - internal Font font; - - internal UI_Text(UI_Theme.TextSettings textSettings) - { - config = textSettings; - text = config.Text; - - try - { - font = MelonUnityEngine.Resources.GetBuiltinResource($"{config.Font}.ttf"); - } - catch { } - - if (font == null) - font = MelonUnityEngine.Resources.GetBuiltinResource("Arial.ttf"); - - AllElements.Add(this); - } - - internal override void Render() - => Render(config.Position.Item1, config.Position.Item2); - internal void Render(int x, int y) - { - if (!config.Enabled) - return; - - UpdateMesh(); - font.material.SetPass(0); - if (mesh == null) - return; - - UI_Utils.AnchorToScreen(config.ScreenAnchor, x, y, out int anchor_x, out int anchor_y); - Graphics.DrawMeshNow(mesh, new Vector3(anchor_x, anchor_y, 0), Quaternion.identity); - } - - private void UpdateMesh() - { - if (!isDirty) - return; - if (string.IsNullOrEmpty(text)) - return; - - if (mesh != null) - { - mesh.DestroyImmediate(); - mesh = null; - } - - TextGenerationSettings settings = new TextGenerationSettings(); - settings.generationExtents = new Vector2(540, 47.5f); - settings.pivot = new Vector2(0.5f, 0.5f); - settings.verticalOverflow = VerticalWrapMode.Overflow; - settings.font = font; - settings.textAnchor = (TextAnchor)config.Anchor; - settings.color = config.TextColor; - settings.richText = config.RichText; - settings.fontSize = config.TextSize; - settings.fontStyle = config.Style; - settings.scaleFactor = config.Scale; - settings.lineSpacing = config.LineSpacing; - - string displayText = text; - displayText = displayText.Replace("", (MelonLaunchOptions.Console.Mode == MelonLaunchOptions.Console.DisplayMode.LEMON) ? "LemonLoader" : "MelonLoader"); - displayText = displayText.Replace("", BuildInfo.Version); - displayText = displayText.Replace("LemonLoader", "LemonLoader"); - displayText = displayText.Replace("MelonLoader", "MelonLoader"); - displayText = displayText.Replace("", "MelonLoader"); - - - - mesh = TextMeshGenerator.Generate(displayText, settings); - mesh.hideFlags = HideFlags.HideAndDontSave; - mesh.DontDestroyOnLoad(); - - isDirty = false; - } - - internal override void Dispose() - { - if (mesh == null) - return; - - mesh.DestroyImmediate(); - mesh = null; - } - } -} diff --git a/Dependencies/MelonStartScreen/UI/StartScreenResources.cs b/Dependencies/MelonStartScreen/UI/StartScreenResources.cs deleted file mode 100644 index 38ebcfadc..000000000 --- a/Dependencies/MelonStartScreen/UI/StartScreenResources.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.IO; -using System.Reflection; -using MelonUnityEngine; - -namespace MelonLoader.MelonStartScreen.UI -{ - internal static class StartScreenResources - { - public static byte[] HalloweenLoadingIcon => GetResource("Loading_Halloween.dat"); - public static byte[] MelonLoadingIcon => GetResource("Loading_Melon.dat"); - public static byte[] LemonLoadingIcon => GetResource("Loading_Lemon.dat"); - - //Logos - public static byte[] HalloweenLogo => GetResource("Logo_Halloween.dat"); - public static byte[] MelonLogo => GetResource("Logo_Melon.dat"); - public static byte[] LemonLogo => GetResource("Logo_Lemon.dat"); - - private static byte[] GetResource(string name) - { - using var s = Assembly.GetExecutingAssembly().GetManifestResourceStream($"MelonLoader.MelonStartScreen.Resources.{name}"); - if (s == null) - return null; -#if NET6_0_OR_GREATER - using var ms = new MemoryStream(); - s.CopyTo(ms); - return ms.ToArray(); -#else - var ret = new byte[s.Length]; - s.Read(ret, 0, ret.Length); - return ret; -#endif - } - } -} \ No newline at end of file diff --git a/Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Default.cs b/Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Default.cs deleted file mode 100644 index b4890682f..000000000 --- a/Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Default.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace MelonLoader.MelonStartScreen.UI.Themes -{ - internal class UI_Theme_Default : UI_Theme - { - internal UI_Theme_Default() => Defaults(); - - internal override byte[] GetLoadingImage() - => StartScreenResources.MelonLoadingIcon; - - internal override byte[] GetLogoImage() - => StartScreenResources.MelonLogo; - } -} diff --git a/Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Lemon.cs b/Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Lemon.cs deleted file mode 100644 index 6e0a614c5..000000000 --- a/Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Lemon.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace MelonLoader.MelonStartScreen.UI.Themes -{ - internal class UI_Theme_Lemon : UI_Theme - { - internal UI_Theme_Lemon() => Defaults(); - - internal override byte[] GetLoadingImage() - => StartScreenResources.LemonLoadingIcon; - - internal override byte[] GetLogoImage() - => StartScreenResources.LemonLogo; - } -} diff --git a/Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Pumpkin.cs b/Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Pumpkin.cs deleted file mode 100644 index 52229ce7f..000000000 --- a/Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Pumpkin.cs +++ /dev/null @@ -1,46 +0,0 @@ -using MelonUnityEngine; - -namespace MelonLoader.MelonStartScreen.UI.Themes -{ - internal class UI_Theme_Pumpkin : UI_Theme - { - internal UI_Theme_Pumpkin() - { - Background = new hBackground(); - ProgressBar = new hProgressBar(); - VersionText = new hVersionTextSettings(); - Defaults(); - } - - internal override byte[] GetLoadingImage() - => StartScreenResources.HalloweenLoadingIcon; - - internal override byte[] GetLogoImage() - => StartScreenResources.HalloweenLogo; - - internal class hBackground : cBackground - { - public hBackground() - => SolidColor = new Color(0.078f, 0f, 0.141f); - } - - internal class hProgressBar : cProgressBar - { - public hProgressBar() : base() - { - OuterColor = new Color(0.478f, 0.169f, 0.749f); - InnerColor = new Color(1f, 0.435f, 0f); - Defaults(); - } - } - - internal class hVersionTextSettings : VersionTextSettings - { - public hVersionTextSettings() - { - Text = $" v {(Is_ALPHA_PreRelease ? "ALPHA Pre-Release" : "Open-Beta")}"; - Defaults(); - } - } - } -} diff --git a/Dependencies/MelonStartScreen/UI/UI_Anchor.cs b/Dependencies/MelonStartScreen/UI/UI_Anchor.cs deleted file mode 100644 index 3a6717082..000000000 --- a/Dependencies/MelonStartScreen/UI/UI_Anchor.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace MelonLoader.MelonStartScreen.UI -{ - internal enum UI_Anchor - { - // Upper - UpperLeft, - UpperCenter, - UpperRight, - - // Middle - MiddleLeft, - MiddleCenter, - MiddleRight, - - // Lower - LowerLeft, - LowerCenter, - LowerRight - } -} diff --git a/Dependencies/MelonStartScreen/UI/UI_Style.cs b/Dependencies/MelonStartScreen/UI/UI_Style.cs deleted file mode 100644 index 3ab8ac839..000000000 --- a/Dependencies/MelonStartScreen/UI/UI_Style.cs +++ /dev/null @@ -1,41 +0,0 @@ -using MelonUnityEngine; -using System; - -namespace MelonLoader.MelonStartScreen.UI -{ - internal class UI_Style - { - internal static Objects.UI_Background Background; - internal static Objects.UI_Image LogoImage; - internal static Objects.UI_Image LoadingImage; - internal static Objects.UI_Text VersionText; - internal static Objects.UI_ProgressBar ProgressBar; - - internal static void Init() - { - Background = new Objects.UI_Background(UI_Theme.Instance.Background); - VersionText = new Objects.UI_Text(UI_Theme.Instance.VersionText); - ProgressBar = new Objects.UI_ProgressBar(UI_Theme.Instance.ProgressBar, UI_Theme.Instance.ProgressText); - - if (UI_Theme.Instance.LogoImage.ScanForCustomImage) - LogoImage = UI_Utils.LoadImage(UI_Theme.Instance.LogoImage, "Logo"); - if (LogoImage == null) - LogoImage = new Objects.UI_Image(UI_Theme.Instance.LogoImage, UI_Theme.Instance.GetLogoImage()); - - if (UI_Theme.Instance.LoadingImage.ScanForCustomImage) - LoadingImage = UI_Utils.LoadImage(UI_Theme.Instance.LoadingImage, "Loading"); - if (LoadingImage == null) - LoadingImage = new Objects.UI_AnimatedImage(UI_Theme.Instance.LoadingImage, UI_Theme.Instance.GetLoadingImage()); - } - - - internal static void Render() - { - Background.Render(); - LogoImage.Render(); - LoadingImage.Render(); - ProgressBar.Render(); - VersionText.Render(); - } - } -} \ No newline at end of file diff --git a/Dependencies/MelonStartScreen/UI/UI_Theme.cs b/Dependencies/MelonStartScreen/UI/UI_Theme.cs deleted file mode 100644 index d70733222..000000000 --- a/Dependencies/MelonStartScreen/UI/UI_Theme.cs +++ /dev/null @@ -1,283 +0,0 @@ -using System.IO; -using MelonUnityEngine; -using Tomlet; -using Tomlet.Attributes; -using Tomlet.Models; -using MelonLoader.MelonStartScreen.UI; -using System; - -namespace MelonLoader.MelonStartScreen -{ - internal abstract class UI_Theme - { - internal static UI_Theme Instance; - - private static string[] includedThemeIDs = - { - "Default", - "Random", - "Pumpkin" - }; - internal static bool IsIncludedThemeID() { foreach (var id in includedThemeIDs) if (id.Equals(ThemeID)) return true; return false; } - internal static string ThemeID = includedThemeIDs[0]; - - internal static string FilePath; - internal static string ThemePath; - internal static cGeneral General; - internal static bool IsLemon; - internal static bool IsPumpkin; - - internal cBackground Background; - internal ImageSettings LogoImage; - internal ImageSettings LoadingImage; - internal TextSettings ProgressText; - internal cProgressBar ProgressBar; - internal VersionTextSettings VersionText; - - internal void Defaults() - { - if (Background == null) - Background = CreateCat(nameof(Background), true); - if (LogoImage == null) - LogoImage = CreateCat(nameof(LogoImage), true); - if (LoadingImage == null) - LoadingImage = CreateCat(nameof(LoadingImage), true); - if (ProgressText == null) - ProgressText = CreateCat(nameof(ProgressText), true); - if (ProgressBar == null) - ProgressBar = CreateCat(nameof(ProgressBar), true); - if (VersionText == null) - VersionText = CreateCat(nameof(VersionText), true); - } - - internal static void Load() - { - TomletMain.RegisterMapper(WriteColor, ReadColor); - - FilePath = Path.Combine(Core.FolderPath, "Config.cfg"); - General = CreateCat(FilePath, nameof(General)); - - if (!string.IsNullOrEmpty(General.Theme)) - ThemeID = General.Theme - .Replace("\\", "") - .Replace("/", ""); - - if (ThemeID == "Halloween") - General.Theme = ThemeID = includedThemeIDs[0]; - - bool isIncludedID = IsIncludedThemeID(); - - if (ThemeID.Equals(includedThemeIDs[1])) - ThemePath = UI_Utils.RandomFolder(Core.ThemesFolderPath); - else - ThemePath = Path.Combine(Core.ThemesFolderPath, ThemeID); - - if (!isIncludedID && !Directory.Exists(ThemePath)) - { - Core.Logger.Error($"Failed to find Start Screen Theme: {ThemeID}"); - - isIncludedID = true; - General.Theme = ThemeID = includedThemeIDs[0]; - ThemePath = Path.Combine(Core.ThemesFolderPath, ThemeID); - } - - if (isIncludedID && !ThemeID.Equals(includedThemeIDs[1])) - { - // Lemon - IsLemon = (MelonLaunchOptions.Console.Mode == MelonLaunchOptions.Console.DisplayMode.LEMON); - if (!IsLemon) - { - // Pumpkin - IsPumpkin = ThemeID.Equals(includedThemeIDs[2]); - var nowTime = DateTime.Now; - if ((nowTime.Month == 10) - && (nowTime.Day == 31)) - IsPumpkin = true; - } - - ThemeID = "Default"; - ThemePath = Path.Combine(Core.ThemesFolderPath, ThemeID); - } - - if (!Directory.Exists(ThemePath)) - Directory.CreateDirectory(ThemePath); - - if (isIncludedID) - MelonPreferences.SaveCategory(nameof(General), false); - - string themeName = ( - IsPumpkin ? "Pumpkin" - : (IsLemon ? "Lemon" : ThemeID)); - - Core.Logger.Msg($"Using Start Screen Theme: \"{themeName}\""); - - Instance = - IsPumpkin ? new UI.Themes.UI_Theme_Pumpkin() - : (IsLemon ? new UI.Themes.UI_Theme_Lemon() - : new UI.Themes.UI_Theme_Default()); - } - - internal abstract byte[] GetLogoImage(); - internal abstract byte[] GetLoadingImage(); - - internal static T CreateCat(string name, bool shouldRemoveOld = false) where T : new() => CreateCat(Path.Combine(ThemePath, $"{name}.cfg"), name, shouldRemoveOld); - internal static T CreateCat(string filePath, string name, bool shouldRemoveOld = false) where T : new() - { - if (shouldRemoveOld) - MelonPreferences.RemoveCategoryFromFile(FilePath, name); - Preferences.MelonPreferences_ReflectiveCategory cat = MelonPreferences.CreateCategory(name, name); - cat.SetFilePath(filePath, true, false); - cat.SaveToFile(false); - cat.DestroyFileWatcher(); - return cat.GetValue(); - } - - internal class cGeneral - { - [TomlPrecedingComment("Toggles the Entire Start Screen ( true | false )")] - internal bool Enabled = true; - [TomlPrecedingComment("Current Theme of the Start Screen")] - internal string Theme = "Default"; - } - - internal class cBackground : ImageSettings - { - [TomlPrecedingComment("Solid RGBA Color of the Background")] - internal Color SolidColor = new Color(0.08f, 0.09f, 0.10f); - [TomlPrecedingComment("If it should stretch the Background to the Full Window Size")] - internal bool StretchToScreen = true; - } - - internal class ProgressTextSettings : TextSettings - { - public ProgressTextSettings() - { - Position.Item2 = 56; - Anchor = UI_Anchor.MiddleCenter; - ScreenAnchor = UI_Anchor.MiddleCenter; - } - } - - internal class cProgressBar : ElementSettings - { - public cProgressBar() => Defaults(); - public void Defaults() - { - Position.Item2 = 56; - Size.Item1 = 540; - Size.Item2 = 36; - - Anchor = UI_Anchor.MiddleCenter; - ScreenAnchor = UI_Anchor.MiddleCenter; - } - - [TomlPrecedingComment("Inner RGBA Color of the Progress Bar")] - internal Color InnerColor = new Color(1.00f, 0.23f, 0.42f); - [TomlPrecedingComment("Outer RGBA Color of the Progress Bar")] - internal Color OuterColor = new Color(0.47f, 0.97f, 0.39f); - } - - internal class VersionTextSettings : TextSettings - { - internal bool Is_ALPHA_PreRelease = false; - public VersionTextSettings() => Defaults(); - public void Defaults() - { - if (Text == null) - Text = $" v {(Is_ALPHA_PreRelease ? "ALPHA Pre-Release" : "Open-Beta")}"; - TextSize = 24; - Anchor = UI_Anchor.MiddleCenter; - ScreenAnchor = UI_Anchor.MiddleCenter; - Position.Item2 = 16; - } - } - - internal class LogoImageSettings : ImageSettings - { - public LogoImageSettings() - { - Size.Item1 = 262; - Size.Item2 = 212; - Position.Item2 = -(Size.Item2 / 2); - - Anchor = UI_Anchor.MiddleCenter; - ScreenAnchor = UI_Anchor.MiddleCenter; - } - } - - internal class LoadingImageSettings : ImageSettings - { - public LoadingImageSettings() - { - Position.Item2 = 35; - Size.Item1 = 200; - Size.Item2 = 132; - - Anchor = UI_Anchor.LowerRight; - ScreenAnchor = UI_Anchor.LowerRight; - } - } - - internal class ElementSettings - { - [TomlPrecedingComment("Toggles the Element ( true | false )")] - internal bool Enabled = true; - - [TomlPrecedingComment("Position of the Element")] - internal LemonTuple Position = new LemonTuple(); - [TomlPrecedingComment("Size of the Element")] - internal LemonTuple Size = new LemonTuple(); - - [TomlPrecedingComment("Anchor of the Text relative to Itself ( \"None\" | \"UpperLeft\" | \"UpperCenter\" | \"UpperRight\" | \"MiddleLeft\" | \"MiddleCenter\" | \"MiddleRight\" | \"LowerLeft\" | \"LowerCenter\" | \"LowerRight\" )")] - internal UI_Anchor Anchor = UI_Anchor.UpperLeft; - [TomlPrecedingComment("Anchor of the Text relative to the Screen ( \"None\" | \"UpperLeft\" | \"UpperCenter\" | \"UpperRight\" | \"MiddleLeft\" | \"MiddleCenter\" | \"MiddleRight\" | \"LowerLeft\" | \"LowerCenter\" | \"LowerRight\" )")] - internal UI_Anchor ScreenAnchor = UI_Anchor.UpperLeft; - } - - internal class TextSettings : ElementSettings - { - [TomlPrecedingComment("UnityEngine.FontStyle of the Text ( \"Normal\" | \"Bold\" | \"Italic\" | \"BoldAndItalic\" )")] - internal FontStyle Style = FontStyle.Bold; - [TomlPrecedingComment("Is this Rich Text ( true | false )")] - internal bool RichText = true; - [TomlPrecedingComment("Size of the Text")] - internal int TextSize = 16; - [TomlPrecedingComment("Scale of the Text")] - internal float Scale = 1f; - [TomlPrecedingComment("Font of the Text")] - internal string Font = "Arial"; - [TomlPrecedingComment("Scale of Line Spacing of the Text")] - internal float LineSpacing = 1f; - [TomlPrecedingComment("RGBA Color of the Text")] - internal Color TextColor = new Color(1, 1, 1); - [TomlPrecedingComment("Text to be Displayed")] - internal string Text; - } - - internal class ImageSettings : ElementSettings - { - [TomlPrecedingComment("If should Load Custom Image ( true | false )")] - internal bool ScanForCustomImage = true; - - [TomlPrecedingComment("UnityEngine.FilterMode of the Image ( \"Point\" | \"Bilinear\" | \"Trilinear\" )")] - internal FilterMode Filter = FilterMode.Bilinear; - - [TomlPrecedingComment("If the Image should attempt to Maintain it's Aspect Ratio")] - internal bool MaintainAspectRatio = false; - } - - private static Color ReadColor(TomlValue value) - { - float[] floats = MelonPreferences.Mapper.ReadArray(value); - if (floats == null || floats.Length != 4) - return default; - return new Color(floats[0] / 255f, floats[1] / 255f, floats[2] / 255f, floats[3] / 255f); - } - - private static TomlValue WriteColor(Color value) - { - float[] floats = new[] { value.r * 255, value.g * 255, value.b * 255, value.a * 255 }; - return MelonPreferences.Mapper.WriteArray(floats); - } - } -} diff --git a/Dependencies/MelonStartScreen/UI/UI_Utils.cs b/Dependencies/MelonStartScreen/UI/UI_Utils.cs deleted file mode 100644 index 40943a57f..000000000 --- a/Dependencies/MelonStartScreen/UI/UI_Utils.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System.IO; -using System.Linq; -using MelonUnityEngine; - -namespace MelonLoader.MelonStartScreen.UI -{ - internal static class UI_Utils - { - internal static Texture2D CreateColorTexture(Color color) - { - Texture2D texture = new Texture2D(2, 2); - texture.SetPixels(new Color[] { color, color, color, color }); - texture.Apply(); - return texture; - } - - internal static Objects.UI_Image LoadImage(UI_Theme.ImageSettings imageSettings, string filename) - { - string filepath = ScanForFile(UI_Theme.ThemePath, filename, new string[] { ".gif", ".png", ".jpg", ".jpeg" }); - if (string.IsNullOrEmpty(filepath)) - return null; - - string fileext = Path.GetExtension(filepath).ToLowerInvariant(); - - if (fileext.Equals(".gif")) - return new Objects.UI_AnimatedImage(imageSettings, filepath); - - if (fileext.Equals(".png") - || fileext.Equals(".jpg") - || fileext.Equals(".jpeg")) - return new Objects.UI_Image(imageSettings, filepath); - - return null; - } - - internal static string ScanForFile(string folderPath, string filename, string[] fileExts) - { - string[] files = Directory.GetFiles(folderPath); - if (files.Length <= 0) - return null; - - string filename_lower = filename.ToLowerInvariant(); - return files.FirstOrDefault((string filepath) => - { - string currentfilename = Path.GetFileNameWithoutExtension(filepath).ToLowerInvariant(); - if (!currentfilename.Equals(filename_lower)) - return false; - - string fileext = Path.GetExtension(filepath).ToLowerInvariant(); - return fileExts.Contains(fileext); - }); - } - - internal static string RandomFolder(string folderPath) - { - string[] files = Directory.GetDirectories(folderPath); - if (files.Length <= 0) - return null; - return files[MelonUtils.RandomInt(0, files.Length)]; - } - - internal static void AnchorToScreen(UI_Anchor anchor, int x, int y, out int out_x, out int out_y) - { - int sw = Screen.width; - int sh = Screen.height - 35; - - switch (anchor) - { - // Upper - case UI_Anchor.UpperLeft: - y = sh - y; - goto default; - case UI_Anchor.UpperCenter: - x = (sw / 2) + x; - y = sh - y; - goto default; - case UI_Anchor.UpperRight: - x = sw - x; - y = sh - y; - goto default; - - // Middle - case UI_Anchor.MiddleLeft: - y = (sh / 2) - y; - goto default; - case UI_Anchor.MiddleCenter: - x = (sw / 2) + x; - y = (sh / 2) - y; - goto default; - case UI_Anchor.MiddleRight: - x = sw - x; - y = (sh / 2) - y; - goto default; - - // Lower - case UI_Anchor.LowerCenter: - x = (sw / 2) + x; - goto default; - - case UI_Anchor.LowerRight: - x = sw - x; - goto default; - - // End - case UI_Anchor.LowerLeft: - default: - out_x = x; - out_y = y; - break; - } - } - - internal static void AnchorToObject(UI_Anchor anchor, int x, int y, int width, int height, out int out_x, out int out_y) - { - switch (anchor) - { - // Upper - case UI_Anchor.UpperCenter: - x -= (width / 2); - goto default; - case UI_Anchor.UpperRight: - x -= width; - goto default; - - // Middle - case UI_Anchor.MiddleLeft: - y -= (height / 2); - goto default; - case UI_Anchor.MiddleCenter: - y -= (height / 2); - x -= (width / 2); - goto default; - case UI_Anchor.MiddleRight: - y -= (height / 2); - x -= width; - goto default; - - // Lower - case UI_Anchor.LowerLeft: - y -= height; - goto default; - case UI_Anchor.LowerCenter: - y -= height; - x -= (width / 2); - goto default; - case UI_Anchor.LowerRight: - y -= height; - x -= width; - goto default; - - // End - case UI_Anchor.UpperLeft: - default: - out_x = x; - out_y = y; - break; - } - } - } -} diff --git a/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppException.cs b/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppException.cs deleted file mode 100644 index 49c1552f1..000000000 --- a/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppException.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Text; -#pragma warning disable 0649 - -namespace UnhollowerMini -{ - internal class Il2CppException : Exception - { - [ThreadStatic] private static byte[] ourMessageBytes; - - public static Func ParseMessageHook; - - public Il2CppException(IntPtr exception) : base(BuildMessage(exception)) { } - - private static unsafe string BuildMessage(IntPtr exception) - { - if (ParseMessageHook != null) return ParseMessageHook(exception); - if (ourMessageBytes == null) ourMessageBytes = new byte[65536]; - fixed (byte* message = ourMessageBytes) - UnityInternals.format_exception(exception, message, ourMessageBytes.Length); - string builtMessage = Encoding.UTF8.GetString(ourMessageBytes, 0, Array.IndexOf(ourMessageBytes, (byte)0)); - fixed (byte* message = ourMessageBytes) - UnityInternals.format_stack_trace(exception, message, ourMessageBytes.Length); - builtMessage += - "\n" + Encoding.UTF8.GetString(ourMessageBytes, 0, Array.IndexOf(ourMessageBytes, (byte)0)); - return builtMessage; - } - - public static void RaiseExceptionIfNecessary(IntPtr returnedException) - { - if (returnedException == IntPtr.Zero) return; - throw new Il2CppException(returnedException); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Byte.cs b/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Byte.cs deleted file mode 100644 index fd8c9d495..000000000 --- a/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Byte.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace Il2CppSystem -{ - [StructLayout(LayoutKind.Explicit)] - internal class Byte - { - [FieldOffset(0)] - public byte m_value; - - static Byte() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("mscorlib.dll", "System", "Byte"); - UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Int32.cs b/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Int32.cs deleted file mode 100644 index c7e2df520..000000000 --- a/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Int32.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace Il2CppSystem -{ - [StructLayout(LayoutKind.Explicit)] - internal class Int32 - { - [FieldOffset(0)] - public int m_value; - - static Int32() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("mscorlib.dll", "System", "Int32"); - UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Type.cs b/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Type.cs deleted file mode 100644 index 307428ab3..000000000 --- a/Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Type.cs +++ /dev/null @@ -1,30 +0,0 @@ -using MelonLoader; -using System; -using UnhollowerMini; - -namespace Il2CppSystem -{ - internal class Type : InternalObjectBase - { - private static readonly IntPtr m_internal_from_handle; - - static Type() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("mscorlib.dll", "System", "Type"); - - m_internal_from_handle = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "internal_from_handle", "System.Type", "System.IntPtr"); - } - - public Type(IntPtr ptr) : base(ptr) { } - - public unsafe static Type internal_from_handle(IntPtr handle) - { - void** args = stackalloc void*[1]; - args[0] = &handle; - IntPtr returnedException = default; - IntPtr intPtr = UnityInternals.runtime_invoke(Type.m_internal_from_handle, IntPtr.Zero, (void**)args, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - return (intPtr != IntPtr.Zero) ? new Type(intPtr) : null; - } - } -} diff --git a/Dependencies/MelonStartScreen/UnhollowerMini/InternalClassPointerStore.cs b/Dependencies/MelonStartScreen/UnhollowerMini/InternalClassPointerStore.cs deleted file mode 100644 index 37e0b0615..000000000 --- a/Dependencies/MelonStartScreen/UnhollowerMini/InternalClassPointerStore.cs +++ /dev/null @@ -1,27 +0,0 @@ -using MelonLoader; -using System; -using System.Runtime.CompilerServices; -#pragma warning disable 0649 - -namespace UnhollowerMini -{ - internal static class InternalClassPointerStore - { - public static IntPtr NativeClassPtr; - public static Type CreatedTypeRedirect; - - static InternalClassPointerStore() - { - var targetType = typeof(T); - - RuntimeHelpers.RunClassConstructor(targetType.TypeHandle); - - if (targetType.IsPrimitive || targetType == typeof(string)) - { - MelonDebug.Msg("Running class constructor on Il2Cpp" + targetType.FullName); - RuntimeHelpers.RunClassConstructor(typeof(InternalClassPointerStore<>).Assembly.GetType("Il2Cpp" + targetType.FullName).TypeHandle); - MelonDebug.Msg("Done running class constructor"); - } - } - } -} diff --git a/Dependencies/MelonStartScreen/UnhollowerMini/InternalObjectBase.cs b/Dependencies/MelonStartScreen/UnhollowerMini/InternalObjectBase.cs deleted file mode 100644 index 478df5a69..000000000 --- a/Dependencies/MelonStartScreen/UnhollowerMini/InternalObjectBase.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; - -namespace UnhollowerMini -{ - internal class InternalObjectBase - { - public IntPtr Pointer - { - get - { - var handleTarget = UnityInternals.gchandle_get_target(myGcHandle); - if (handleTarget == IntPtr.Zero) throw new ObjectCollectedException("Object was garbage collected"); - return handleTarget; - } - } - - protected uint myGcHandle; - - protected InternalObjectBase() { } - - public InternalObjectBase(IntPtr pointer) - { - if (pointer == IntPtr.Zero) - throw new NullReferenceException(); - - myGcHandle = UnityInternals.gchandle_new(pointer, false); - } - - ~InternalObjectBase() - { - UnityInternals.gchandle_free(myGcHandle); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnhollowerMini/InternalType.cs b/Dependencies/MelonStartScreen/UnhollowerMini/InternalType.cs deleted file mode 100644 index fa312cd03..000000000 --- a/Dependencies/MelonStartScreen/UnhollowerMini/InternalType.cs +++ /dev/null @@ -1,22 +0,0 @@ -using MelonLoader; -using System; - -namespace UnhollowerMini -{ - internal static class InternalType - { - public static Il2CppSystem.Type TypeFromPointer(IntPtr classPointer, string typeName = "") - { - if (classPointer == IntPtr.Zero) throw new ArgumentException($"{typeName} does not have a corresponding internal class pointer"); - var il2CppType = UnityInternals.class_get_type(classPointer); - if (il2CppType == IntPtr.Zero) throw new ArgumentException($"{typeName} does not have a corresponding class type pointer"); - return Il2CppSystem.Type.internal_from_handle(il2CppType); - } - - public static Il2CppSystem.Type Of() - { - var classPointer = InternalClassPointerStore.NativeClassPtr; - return TypeFromPointer(classPointer, typeof(T).Name); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnhollowerMini/ObjectCollectedException.cs b/Dependencies/MelonStartScreen/UnhollowerMini/ObjectCollectedException.cs deleted file mode 100644 index dd681b28b..000000000 --- a/Dependencies/MelonStartScreen/UnhollowerMini/ObjectCollectedException.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace UnhollowerMini -{ - internal class ObjectCollectedException : Exception - { - public ObjectCollectedException(string message) : base(message) { } - } -} diff --git a/Dependencies/MelonStartScreen/UnhollowerMini/UnityInternals.cs b/Dependencies/MelonStartScreen/UnhollowerMini/UnityInternals.cs deleted file mode 100644 index 9265239fb..000000000 --- a/Dependencies/MelonStartScreen/UnhollowerMini/UnityInternals.cs +++ /dev/null @@ -1,696 +0,0 @@ -using MelonLoader; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; - -namespace UnhollowerMini -{ - internal static unsafe class UnityInternals - { - private delegate void delegate_gfunc_mono_assembly_foreach(IntPtr assembly, IntPtr user_data); - - private static readonly IntPtr domain; - private static readonly List assemblies = new List(); - - private static readonly uint monoClassOffset = 0; - - unsafe static UnityInternals() - { - if (MelonUtils.IsGameIl2Cpp()) - { - domain = il2cpp_domain_get(); - - uint assemblyCount = 0; - IntPtr* assemblyArray = il2cpp_domain_get_assemblies(domain, ref assemblyCount); - for (int i = 0; i < assemblyCount; ++i) - assemblies.Add(new InternalAssembly(il2cpp_assembly_get_image(*(assemblyArray + i)))); - } - else - { - domain = mono_domain_get(); - - MonoClass* testclass = (MonoClass*)Marshal.AllocHGlobal(sizeof(MonoClass)); - testclass->applyZeroes(); - testclass->nested_in_0x04 = (IntPtr)0x1234; - testclass->nested_in_0x08 = (IntPtr)0x5678; - testclass->nested_in_0x0C = (IntPtr)0x9012; - long returnedName = (long)mono_class_get_name((IntPtr)testclass); - MelonDebug.Msg($"returnedName {returnedName:X}"); - Marshal.FreeHGlobal((IntPtr)testclass); - if (returnedName == 0x1234) - monoClassOffset = 0; - else if (returnedName == 0x5678) - monoClassOffset = (uint)IntPtr.Size * 1; - else if (returnedName == 0x9012) - monoClassOffset = (uint)IntPtr.Size * 2; - else - throw new Exception("Failed to find MonoClass name offset"); - - MelonDebug.Msg("monoClassOffset? " + monoClassOffset); - } - } - - private class InternalAssembly - { - public IntPtr ptr; - public string name; - - public InternalAssembly(IntPtr ptr) - { - this.ptr = ptr; - if (MelonUtils.IsGameIl2Cpp()) - { - name = Marshal.PtrToStringAnsi(il2cpp_image_get_filename(this.ptr)); - } - else - { - name = Marshal.PtrToStringAnsi(mono_image_get_filename(this.ptr)); - } - } - } - - private class InternalClass - { - public IntPtr ptr; - public string name; - public string name_space; - - public InternalClass(IntPtr ptr) - { - this.ptr = ptr; - if (MelonUtils.IsGameIl2Cpp()) - { - name = Marshal.PtrToStringAnsi(il2cpp_class_get_name(ptr)); - name_space = Marshal.PtrToStringAnsi(il2cpp_class_get_namespace(ptr)); - } - else - { - throw new NotImplementedException(); - } - } - - public InternalClass(IntPtr ptr, string name, string name_space) - { - if (MelonUtils.IsGameIl2Cpp()) - { - throw new NotImplementedException(); - } - else - { - this.ptr = ptr; - this.name = name; - this.name_space = name_space; - } - } - } - - - internal static IntPtr GetClass(string assemblyname, string name_space, string classname) - { - MelonDebug.Msg($"GetClass {assemblyname} {name_space} {classname}"); - if (MelonUtils.IsGameIl2Cpp()) - { - InternalAssembly assembly = assemblies.FirstOrDefault(a => a.name == assemblyname); - if (assembly == null) - { - throw new Exception("Unable to find assembly " + assemblyname + " in il2cpp domain"); - } - - IntPtr clazz = il2cpp_class_from_name(assembly.ptr, name_space, classname); - if (clazz == IntPtr.Zero) - { - throw new Exception("Unable to find class " + name_space + "." + classname + " in assembly " + assemblyname); - } - - MelonDebug.Msg($" > 0x{(long)clazz:X}"); - return clazz; - } - else - { - string fullname = string.IsNullOrEmpty(name_space) ? "" : (name_space + ".") + classname; - - Assembly ass = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name + ".dll" == assemblyname); - if (ass == null) - { - throw new Exception("Unable to find assembly " + assemblyname + " in mono domain"); - } - - Type t = ass.GetType(fullname); - if (t == null) - { - throw new Exception("Unable to find class " + fullname + " in assembly " + assemblyname); - } - MelonDebug.Msg($" > 0x{(long)(*(IntPtr*)t.TypeHandle.Value):X}"); - - return *(IntPtr*)t.TypeHandle.Value; - } - } - - public static IntPtr GetField(IntPtr clazz, string fieldName) - { - MelonDebug.Msg($"GetField {fieldName}"); - if (clazz == IntPtr.Zero) - return IntPtr.Zero; - - var field = MelonUtils.IsGameIl2Cpp() ? il2cpp_class_get_field_from_name(clazz, fieldName) : mono_class_get_field_from_name(clazz, fieldName); - if (field == IntPtr.Zero) - throw new Exception($"Field {fieldName} was not found on class {Marshal.PtrToStringAnsi(MelonUtils.IsGameIl2Cpp() ? il2cpp_class_get_name(clazz) : mono_class_get_name(clazz))}"); - MelonDebug.Msg($" > 0x{(long)field:X}"); - return field; - } - - internal static IntPtr GetMethod(IntPtr clazz, string name, string returntype, params string[] parameters) - { - MelonDebug.Msg($"GetMethod {returntype} {name}({string.Join(", ", parameters)})"); - if (MelonUtils.IsGameIl2Cpp()) - { - IntPtr iter = IntPtr.Zero; - IntPtr element; - while ((element = il2cpp_class_get_methods(clazz, ref iter)) != IntPtr.Zero) - { - if (Marshal.PtrToStringAnsi(il2cpp_method_get_name(element)) != name) - continue; - - if (Marshal.PtrToStringAnsi(il2cpp_type_get_name(il2cpp_method_get_return_type(element))) != returntype) - continue; - - if (parameters.Length != il2cpp_method_get_param_count(element)) - continue; - - bool hasValidParameters = true; - for (uint i = 0; i < parameters.Length; ++i) - { - if (Marshal.PtrToStringAnsi(il2cpp_type_get_name(il2cpp_method_get_param(element, i))) != parameters[i]) - { - hasValidParameters = false; - break; - } - } - - if (hasValidParameters) - { - MelonDebug.Msg($" > 0x{(long)element:X}"); - return element; - } - } - } - else - { - - IntPtr iter = IntPtr.Zero; - IntPtr element; - while ((element = mono_class_get_methods(clazz, ref iter)) != IntPtr.Zero) - { - if (Marshal.PtrToStringAnsi(mono_method_get_name(element)) != name) - continue; - - IntPtr sig = mono_method_get_signature(element, IntPtr.Zero, 0); - if (Marshal.PtrToStringAnsi(mono_type_get_name(mono_signature_get_return_type(sig))) != returntype) - continue; - if (parameters.Length != mono_signature_get_param_count(sig)) - continue; - - bool hasValidParameters = true; - IntPtr iter2 = IntPtr.Zero; - IntPtr param; - int i = 0; - while ((param = mono_signature_get_params(sig, ref iter2)) != IntPtr.Zero) - { - if (Marshal.PtrToStringAnsi(mono_type_get_name(param)) != parameters[i]) - { - hasValidParameters = false; - break; - } - ++i; - } - - if (hasValidParameters) - { - MelonDebug.Msg($" > 0x{(long)element:X}"); - return element; - } - } - } - //MelonLogger.Error($"Unable to find method {returntype} {name}({string.Join(", ", parameters)})"); - //return IntPtr.Zero; - throw new Exception($"Unable to find method {returntype} {name}({string.Join(", ", parameters)})"); - } - - public static IntPtr ObjectBaseToPtr(InternalObjectBase obj) - { - return obj?.Pointer ?? IntPtr.Zero; - } - - public static IntPtr ObjectBaseToPtrNotNull(InternalObjectBase obj) - { - return obj?.Pointer ?? throw new NullReferenceException(); - } - - public static IntPtr ManagedStringToInternal(string str) - { - if (str == null) return IntPtr.Zero; - - fixed (char* chars = str) - return MelonUtils.IsGameIl2Cpp() ? il2cpp_string_new_utf16(chars, str.Length) : mono_string_new_utf16(domain, chars, str.Length); - } - - public static IntPtr ResolveICall(string signature) - { - MelonDebug.Msg("Resolving ICall " + signature); - IntPtr icallPtr; - if (MelonUtils.IsGameIl2Cpp()) - icallPtr = il2cpp_resolve_icall(signature); - else - { - // We generate a fake MonoMethod + MonoMethodSignature + MonoClass struct to exploit the lookup code and force resolve our icall without the class/method being registered - // (Slaynash: Yes this is illegal) - MonoMethod* monoMethod = IcallToFakeMonoMethod(signature); - icallPtr = mono_lookup_internal_call((IntPtr)monoMethod); - DestroyFakeMonoMethod(monoMethod); - } - - if (icallPtr == IntPtr.Zero) - { - //MelonLogger.Error($"ICall {signature} not resolved"); - //return IntPtr.Zero; - throw new Exception($"ICall {signature} not resolved"); - } - MelonDebug.Msg($" > 0x{(long)icallPtr:X}"); - - return icallPtr; - } - - public static T ResolveICall(string signature) where T : Delegate - { - IntPtr icallPtr = ResolveICall(signature); - return icallPtr == IntPtr.Zero ? null : (T)Marshal.GetDelegateForFunctionPointer(icallPtr, typeof(T)); - } - - private static unsafe MonoMethod* IcallToFakeMonoMethod(string icallName) - { - string[] typeAndMethod = icallName.Split(new[] { "::" }, StringSplitOptions.None); - int parenthesisIndex = typeAndMethod[1].IndexOf('('); - if (parenthesisIndex >= 0) - typeAndMethod[1] = typeAndMethod[1].Substring(0, parenthesisIndex); - // We add a padding to the end of each allocated memory since our structs are supposed to be bigger than the one we have here - MonoMethod* monoMethod = (MonoMethod*)Marshal.AllocHGlobal(sizeof(MonoMethod) + 0x100); - monoMethod->applyZeroes(); - monoMethod->klass = (MonoClass*)Marshal.AllocHGlobal(sizeof(MonoClass) + 0x100); - monoMethod->klass->applyZeroes(); - monoMethod->name = (byte*)Marshal.StringToHGlobalAnsi(typeAndMethod[1]); - int lastDotIndex = typeAndMethod[0].LastIndexOf('.'); - if (lastDotIndex < 0) - { - *(IntPtr*)((long)&monoMethod->klass->nested_in_0x08 + monoClassOffset) = Marshal.StringToHGlobalAnsi(""); - *(IntPtr*)((long)&monoMethod->klass->nested_in_0x04 + monoClassOffset) = Marshal.StringToHGlobalAnsi(typeAndMethod[0]); - } - else - { - string name_space = typeAndMethod[0].Substring(0, lastDotIndex); - string name = typeAndMethod[0].Substring(lastDotIndex + 1); - *(IntPtr*)((long)&monoMethod->klass->nested_in_0x08 + monoClassOffset) = Marshal.StringToHGlobalAnsi(name_space); - *(IntPtr*)((long)&monoMethod->klass->nested_in_0x04 + monoClassOffset) = Marshal.StringToHGlobalAnsi(name); - } - - MonoMethodSignature* monoMethodSignature = (MonoMethodSignature*)Marshal.AllocHGlobal(sizeof(MonoMethodSignature)); - monoMethodSignature->ApplyZeroes(); - monoMethod->signature = monoMethodSignature; - - return monoMethod; - } - - private static unsafe void DestroyFakeMonoMethod(MonoMethod* monoMethod) - { - Marshal.FreeHGlobal((IntPtr)monoMethod->signature); - Marshal.FreeHGlobal(*(IntPtr*)((long)&monoMethod->klass->nested_in_0x04 + monoClassOffset)); - Marshal.FreeHGlobal(*(IntPtr*)((long)&monoMethod->klass->nested_in_0x08 + monoClassOffset)); - Marshal.FreeHGlobal((IntPtr)monoMethod->klass); - Marshal.FreeHGlobal((IntPtr)monoMethod->name); - Marshal.FreeHGlobal((IntPtr)monoMethod); - } - - [StructLayout(LayoutKind.Sequential)] - private struct MonoMethod - { - public ushort flags; /* method flags */ - public ushort iflags; /* method implementation flags */ - public uint token; - public MonoClass* klass; /* To what class does this method belong */ - public MonoMethodSignature* signature; - /* name is useful mostly for debugging */ - public byte* name; - - public IntPtr method_pointer; - public IntPtr invoke_pointer; - - /* this is used by the inlining algorithm */ - public ushort bitfield; - public int slot; - - internal void applyZeroes() - { - flags = 0; - iflags = 0; - token = 0; - klass = (MonoClass*)0; - signature = (MonoMethodSignature*)0; - name = (byte*)0; - method_pointer = IntPtr.Zero; - invoke_pointer = IntPtr.Zero; - bitfield = 0; - slot = 0; - } - } - - [StructLayout(LayoutKind.Sequential)] - private struct MonoMethodSignature - { - public IntPtr ret; - public ushort param_cout; - // ... - - internal void ApplyZeroes() - { - ret = (IntPtr)0; - param_cout = 0; - } - } - - [StructLayout(LayoutKind.Sequential)] - private struct MonoClass - { - /* element class for arrays and enum basetype for enums */ - public MonoClass* element_class; - /* used for subtype checks */ - public MonoClass* cast_class; - - /* for fast subtype checks */ - public MonoClass** supertypes; - public ushort idepth; - - /* array dimension */ - public byte rank; // 0x0E - - /* One of the values from MonoTypeKind */ - public byte class_kind; - - public int instance_size; // 0x10 - - public uint bitfield1; // 0x14 - - public byte min_align; // 0x18 - - public uint bitfield2; // 0x1C - - byte exception_type; - - public MonoClass* parent; // 0x24 - public MonoClass* nested_in; // 0x28 // Should always be null - - //public IntPtr cattrs; // 0x2C - - // - // Starting here (unity version from 2014+), fields will be offset by IntPtr.Size - // - - public IntPtr nested_in_0x04; // 0x2C - 0x30 - public IntPtr nested_in_0x08; // 0x30 - 0x34 - public IntPtr nested_in_0x0C; // 0x34 - 0x38 - public IntPtr nested_in_0x10; // 0x38 - 0x3C - - // ... - - internal void applyZeroes() - { - element_class = (MonoClass*)0; - cast_class = (MonoClass*)0; - supertypes = (MonoClass**)0; - idepth = 0; - rank = 0; - class_kind = 0; - instance_size = 0; - bitfield1 = 0; - min_align = 0; - bitfield2 = 0; - exception_type = 0; - parent = (MonoClass*)0; - nested_in = (MonoClass*)0; - nested_in_0x04 = (IntPtr)0; - nested_in_0x08 = (IntPtr)0; - nested_in_0x0C = (IntPtr)0; - nested_in_0x10 = (IntPtr)0; - } - } - - private struct MonoType - { - public IntPtr data; - public short attrs; - public byte type; - public byte bitflags; - - internal void applyZeroes() - { - data = (IntPtr)0; - attrs = 0; - type = 0; - bitflags = 0; - } - } - - public static IntPtr class_get_type(IntPtr klass) - { - return MelonUtils.IsGameIl2Cpp() ? il2cpp_class_get_type(klass) : mono_class_get_type(klass); - } - - public static void runtime_class_init(IntPtr klass) - { - if (klass == IntPtr.Zero) - throw new ArgumentException("Class to init is null"); - - if (MelonUtils.IsGameIl2Cpp()) il2cpp_runtime_class_init(klass); else mono_runtime_class_init(klass); - } - - public static IntPtr runtime_invoke(IntPtr method, IntPtr obj, void** param, ref IntPtr exc) => - MelonUtils.IsGameIl2Cpp() ? il2cpp_runtime_invoke(method, obj, param, ref exc) : mono_runtime_invoke(method, obj, param, ref exc); - - public static IntPtr array_new(IntPtr elementTypeInfo, ulong length) => - MelonUtils.IsGameIl2Cpp() ? il2cpp_array_new(elementTypeInfo, length) : mono_array_new(domain, elementTypeInfo, length); - - public static uint array_length(IntPtr array) => - MelonUtils.IsGameIl2Cpp() ? il2cpp_array_length(array) : *(uint*)((long)array + IntPtr.Size * 3); - - public static uint field_get_offset(IntPtr field) => - MelonUtils.IsGameIl2Cpp() ? il2cpp_field_get_offset(field) : mono_field_get_offset(field); - - public static IntPtr object_unbox(IntPtr obj) => - MelonUtils.IsGameIl2Cpp() ? il2cpp_object_unbox(obj) : mono_object_unbox(obj); - - public static IntPtr object_new(IntPtr klass) => - MelonUtils.IsGameIl2Cpp() ? il2cpp_object_new(klass) : mono_object_new(domain, klass); - - public static int class_value_size(IntPtr klass, ref uint align) => - MelonUtils.IsGameIl2Cpp() ? il2cpp_class_value_size(klass, ref align) : mono_class_value_size(klass, ref align); - - public static uint gchandle_new(IntPtr obj, bool pinned) => - MelonUtils.IsGameIl2Cpp() ? il2cpp_gchandle_new(obj, pinned) : mono_gchandle_new(obj, pinned ? 1 : 0); - public static void gchandle_free(uint gchandle) - { if (MelonUtils.IsGameIl2Cpp()) il2cpp_gchandle_free(gchandle); else mono_gchandle_free(gchandle); } - public static IntPtr gchandle_get_target(uint gchandle) => - MelonUtils.IsGameIl2Cpp() ? il2cpp_gchandle_get_target(gchandle) : mono_gchandle_get_target(gchandle); - - public static IntPtr value_box(IntPtr klass, IntPtr val) => - MelonUtils.IsGameIl2Cpp() ? il2cpp_value_box(klass, val) : mono_value_box(domain, klass, val); - - public static void format_exception(IntPtr ex, void* message, int message_size) - { - if (MelonUtils.IsGameIl2Cpp()) - il2cpp_format_exception(ex, message, message_size); - // TODO Mono mono_format_exception - } - - public static void format_stack_trace(IntPtr ex, void* output, int output_size) - { - if (MelonUtils.IsGameIl2Cpp()) - il2cpp_format_stack_trace(ex, output, output_size); - // TODO mono_format_stack_trace - } - - - // Mono Functions - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_domain_get(); - - /* - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr* mono_domain_get_assemblies(IntPtr domain, ref uint size); - */ - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern void mono_assembly_foreach(delegate_gfunc_mono_assembly_foreach func, IntPtr user_data); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_assembly_get_image(IntPtr assembly); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_image_get_filename(IntPtr image); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern uint mono_image_get_class_count(IntPtr image); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_image_get_class(IntPtr image, uint index); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_class_get_name(IntPtr klass); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_class_get_namespace(IntPtr klass); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_lookup_internal_call(IntPtr method); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - public static extern IntPtr mono_class_get_type(IntPtr klass); - - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern unsafe IntPtr mono_runtime_invoke(IntPtr method, IntPtr obj, void** param, ref IntPtr exc); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern void mono_runtime_class_init(IntPtr klass); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_array_new(IntPtr domain, IntPtr eclass, ulong n); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern uint mono_field_get_offset(IntPtr field); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_object_unbox(IntPtr obj); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_object_new(IntPtr domain, IntPtr klass); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern int mono_class_value_size(IntPtr klass, ref uint align); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern uint mono_gchandle_new(IntPtr obj, int pinned); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern void mono_gchandle_free(uint gchandle); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_gchandle_get_target(uint gchandle); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_class_get_field_from_name(IntPtr klass, [MarshalAs(UnmanagedType.LPStr)] string name); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_value_box(IntPtr domain, IntPtr klass, IntPtr data); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_class_get_methods(IntPtr klass, ref IntPtr iter); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - public static extern IntPtr mono_method_get_name(IntPtr method); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_type_get_name(IntPtr type); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_image_get_table_info(IntPtr image, int table_id); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern int mono_table_info_get_rows(IntPtr table); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern void mono_metadata_decode_row(IntPtr t, int idx, uint[] res, int res_size); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_metadata_string_heap(IntPtr meta, uint index); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_class_from_name(IntPtr image, string name_space, string name); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_domain_try_type_resolve(IntPtr domain, string name, IntPtr typebuilder_raw); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_method_get_signature(IntPtr method, IntPtr image, uint token); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_signature_get_return_type(IntPtr sig); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern uint mono_signature_get_param_count(IntPtr sig); - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_signature_get_params(IntPtr sig, ref IntPtr iter); - - [DllImport("__Internal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr mono_string_new_utf16(IntPtr domain, char* text, int len); - - - - - // IL2CPP Functions - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_domain_get(); - - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_resolve_icall([MarshalAs(UnmanagedType.LPStr)] string name); - - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern uint il2cpp_array_length(IntPtr array); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_array_new(IntPtr elementTypeInfo, ulong length); - - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_assembly_get_image(IntPtr assembly); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_class_get_field_from_name(IntPtr klass, [MarshalAs(UnmanagedType.LPStr)] string name); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_class_get_methods(IntPtr klass, ref IntPtr iter); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_class_get_name(IntPtr klass); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_class_get_namespace(IntPtr klass); - - - - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - public static extern IntPtr il2cpp_class_get_type(IntPtr klass); - - - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern int il2cpp_class_value_size(IntPtr klass, ref uint align); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr* il2cpp_domain_get_assemblies(IntPtr domain, ref uint size); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern void il2cpp_format_exception(IntPtr ex, void* message, int message_size); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern void il2cpp_format_stack_trace(IntPtr ex, void* output, int output_size); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern uint il2cpp_field_get_offset(IntPtr field); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern uint il2cpp_gchandle_new(IntPtr obj, bool pinned); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_gchandle_get_target(uint gchandle); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern void il2cpp_gchandle_free(uint gchandle); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_method_get_return_type(IntPtr method); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern uint il2cpp_method_get_param_count(IntPtr method); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_method_get_param(IntPtr method, uint index); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - public static extern IntPtr il2cpp_method_get_name(IntPtr method); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_object_new(IntPtr klass); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_object_unbox(IntPtr obj); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_value_box(IntPtr klass, IntPtr data); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern unsafe IntPtr il2cpp_runtime_invoke(IntPtr method, IntPtr obj, void** param, ref IntPtr exc); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern void il2cpp_runtime_class_init(IntPtr klass); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_string_new_utf16(char* text, int len); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_type_get_name(IntPtr type); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_image_get_filename(IntPtr image); - [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - private static extern IntPtr il2cpp_class_from_name(IntPtr image, string namespaze, string name); - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Color.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Color.cs deleted file mode 100644 index f390cb358..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Color.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - [StructLayout(LayoutKind.Explicit)] - internal struct Color - { - private static readonly IntPtr m_ToString; - - [FieldOffset(0)] - public float r; - [FieldOffset(4)] - public float g; - [FieldOffset(8)] - public float b; - [FieldOffset(12)] - public float a; - - static Color() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Color"); - UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - m_ToString = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "ToString", "System.String"); - } - - public Color(float r, float g, float b, float a = 1f) - { - this.r = r; - this.g = g; - this.b = b; - this.a = a; - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Color32.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Color32.cs deleted file mode 100644 index 39bc045c9..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Color32.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - [StructLayout(LayoutKind.Explicit)] - internal struct Color32 - { - [FieldOffset(0)] - public byte r; - [FieldOffset(1)] - public byte g; - [FieldOffset(2)] - public byte b; - [FieldOffset(3)] - public byte a; - - [FieldOffset(0)] - public int rgba; - - static Color32() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Color32"); - UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - } - - public Color32(byte r, byte g, byte b, byte a) - { - this.rgba = 0; - this.r = r; - this.g = g; - this.b = b; - this.a = a; - } - - public static implicit operator Color(Color32 c) - { - return new Color(c.r / 255f, c.g / 255f, c.b / 255f, c.a / 255f); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/FilterMode.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/FilterMode.cs deleted file mode 100644 index 05122e2f4..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/FilterMode.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace MelonUnityEngine -{ - internal enum FilterMode - { - Point, - Bilinear, - Trilinear - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/GL.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/GL.cs deleted file mode 100644 index 045bc4059..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/GL.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal sealed class GL - { - private delegate bool d_get_sRGBWrite(); - private static readonly d_get_sRGBWrite m_get_sRGBWrite; - - unsafe static GL() - { - m_get_sRGBWrite = UnityInternals.ResolveICall("UnityEngine.GL::get_sRGBWrite"); - } - - public unsafe static bool sRGBWrite - { - get => m_get_sRGBWrite(); - // set - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Graphics.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Graphics.cs deleted file mode 100644 index a01bd0ac3..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Graphics.cs +++ /dev/null @@ -1,117 +0,0 @@ -using MelonLoader; -using MelonLoader.MelonStartScreen.NativeUtils; -using System; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal class Graphics : InternalObjectBase - { - private delegate IntPtr Internal_DrawMeshNow1_InjectedDelegate(IntPtr mesh, int subsetIndex, ref Vector3 position, ref Quaternion rotation); - private delegate void Internal_DrawTextureDelegate2017(ref Internal_DrawTextureArguments_2017 args); - private delegate void Internal_DrawTextureDelegate2018(ref Internal_DrawTextureArguments_2018 args); - private delegate void Internal_DrawTextureDelegate2019(ref Internal_DrawTextureArguments_2019 args); - private delegate void Internal_DrawTextureDelegate2020(ref Internal_DrawTextureArguments_2020 args); - - private static readonly Internal_DrawTextureDelegate2017 fd_Internal_DrawTexture2017; - private static readonly Internal_DrawTextureDelegate2018 fd_Internal_DrawTexture2018; - private static readonly Internal_DrawTextureDelegate2019 fd_Internal_DrawTexture2019; - private static readonly Internal_DrawTextureDelegate2020 fd_Internal_DrawTexture2020; - private static readonly Internal_DrawMeshNow1_InjectedDelegate fd_Internal_DrawMeshNow1_Injected; - - private static readonly int m_DrawTexture_Internal_struct = -1; - - unsafe static Graphics() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Graphics"); - fd_Internal_DrawTexture2017 = UnityInternals.ResolveICall("UnityEngine.Graphics::Internal_DrawTexture"); - fd_Internal_DrawTexture2018 = UnityInternals.ResolveICall("UnityEngine.Graphics::Internal_DrawTexture"); - fd_Internal_DrawTexture2019 = UnityInternals.ResolveICall("UnityEngine.Graphics::Internal_DrawTexture"); - fd_Internal_DrawTexture2020 = UnityInternals.ResolveICall("UnityEngine.Graphics::Internal_DrawTexture"); - - if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2018.2.0", "2019.1.0" })) - fd_Internal_DrawMeshNow1_Injected = UnityInternals.ResolveICall("UnityEngine.Graphics::Internal_DrawMeshNow1_Injected"); - else - fd_Internal_DrawMeshNow1_Injected = UnityInternals.ResolveICall("UnityEngine.Graphics::INTERNAL_CALL_Internal_DrawMeshNow1"); - - if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2019.3.0", "2020.1.0" })) - m_DrawTexture_Internal_struct = 3; - else if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2018.2.0", "2019.1.0" })) - m_DrawTexture_Internal_struct = 2; - else if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2017.3.0", "2018.1.0" })) - m_DrawTexture_Internal_struct = 1; - else if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2017.2.0" })) - m_DrawTexture_Internal_struct = 0; - } - - public Graphics(IntPtr ptr) : base(ptr) { } - - public unsafe static void DrawTexture(Rect screenRect, Texture2D texture) - { - if ((texture == null) || (texture.Pointer == IntPtr.Zero)) - return; - - if (m_DrawTexture_Internal_struct == 0) - { - Internal_DrawTextureArguments_2017 args = default; - args.screenRect = screenRect; - args.sourceRect = new Rect(0, 0, 1, 1); - args.color = new Color32(128, 128, 128, 128); - args.texture = UnityInternals.ObjectBaseToPtrNotNull(texture); - fd_Internal_DrawTexture2017(ref args); - } - else if (m_DrawTexture_Internal_struct == 1) - { - Internal_DrawTextureArguments_2018 args = default; - args.screenRect = screenRect; - args.sourceRect = new Rect(0, 0, 1, 1); - args.color = new Color32(128, 128, 128, 128); - args.texture = UnityInternals.ObjectBaseToPtrNotNull(texture); - fd_Internal_DrawTexture2018(ref args); - } - else if (m_DrawTexture_Internal_struct == 2) - { - Internal_DrawTextureArguments_2019 args = default; - args.screenRect = screenRect; - args.sourceRect = new Rect(0, 0, 1, 1); - args.color = new Color(0.5f, 0.5f, 0.5f, 0.5f); - args.texture = UnityInternals.ObjectBaseToPtrNotNull(texture); - fd_Internal_DrawTexture2019(ref args); - } - else if (m_DrawTexture_Internal_struct == 3) - { - Internal_DrawTextureArguments_2020 args = default; - args.screenRect = screenRect; - args.sourceRect = new Rect(0, 0, 1, 1); - args.color = new Color(0.5f, 0.5f, 0.5f, 0.5f); - args.leftBorderColor = new Color(0, 0, 0, 1); - args.topBorderColor = new Color(0, 0, 0, 1); - args.rightBorderColor = new Color(0, 0, 0, 1); - args.bottomBorderColor = new Color(0, 0, 0, 1); - args.smoothCorners = true; - args.texture = UnityInternals.ObjectBaseToPtrNotNull(texture); - fd_Internal_DrawTexture2020(ref args); - } - } - - public static void DrawMeshNow(Mesh mesh, Vector3 position, Quaternion rotation) => - DrawMeshNow(mesh, position, rotation, -1); - - public static void DrawMeshNow(Mesh mesh, Vector3 position, Quaternion rotation, int materialIndex) - { - if (mesh == null) - throw new ArgumentNullException("mesh"); - Internal_DrawMeshNow1(mesh, materialIndex, position, rotation); - } - - private static void Internal_DrawMeshNow1(Mesh mesh, int subsetIndex, Vector3 position, Quaternion rotation) => - Internal_DrawMeshNow1_Injected(mesh, subsetIndex, ref position, ref rotation); - - private static void Internal_DrawMeshNow1_Injected(Mesh mesh, int subsetIndex, ref Vector3 position, ref Quaternion rotation) - { - if ((mesh == null) || (mesh.Pointer == IntPtr.Zero)) - return; - fd_Internal_DrawMeshNow1_Injected(UnityInternals.ObjectBaseToPtr(mesh), subsetIndex, ref position, ref rotation); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/HideFlags.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/HideFlags.cs deleted file mode 100644 index 86fa181e8..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/HideFlags.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace MelonUnityEngine -{ - internal enum HideFlags - { - None = 0, - HideInHierarchy = 1, - HideInInspector = 2, - DontSaveInEditor = 4, - NotEditable = 8, - DontSaveInBuild = 16, - DontUnloadUnusedAsset = 32, - DontSave = 52, - HideAndDontSave = 61 - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/ImageConversion.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/ImageConversion.cs deleted file mode 100644 index 50843ca85..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/ImageConversion.cs +++ /dev/null @@ -1,40 +0,0 @@ -using MelonLoader; -using System; -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal static class ImageConversion - { - private delegate bool ImageConversion_LoadImage_Delegate(IntPtr tex, IntPtr data, bool markNonReadable); - private static ImageConversion_LoadImage_Delegate ImageConversion_LoadImage; - - static ImageConversion() - { - IntPtr ptr = UnityInternals.ResolveICall("UnityEngine.ImageConversion::LoadImage(UnityEngine.Texture2D,System.Byte[],System.Boolean)"); - if (ptr != IntPtr.Zero) - ImageConversion_LoadImage = (ImageConversion_LoadImage_Delegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(ImageConversion_LoadImage_Delegate)); - else - MelonLogger.Error("Failed to resolve icall UnityEngine.ImageConversion::LoadImage(UnityEngine.Texture2D,System.Byte[],System.Boolean)"); - } - - public unsafe static bool LoadImage(Texture2D tex, byte[] data, bool markNonReadable) - { - if (ImageConversion_LoadImage == null) - { - MelonLogger.Error("Failed to run UnityEngine.ImageConversion::LoadImage(UnityEngine.Texture2D,System.Byte[],System.Boolean)"); - return false; - } - - IntPtr dataPtr = UnityInternals.array_new(InternalClassPointerStore.NativeClassPtr, (uint)data.Length); - for (var i = 0; i < data.Length; i++) - { - IntPtr arrayStartPointer = (IntPtr)((long)dataPtr + 4 * IntPtr.Size); - ((byte*)arrayStartPointer.ToPointer())[i] = data[i]; - } - - return ImageConversion_LoadImage(tex.Pointer, dataPtr, markNonReadable); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Internal_DrawTextureArguments.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Internal_DrawTextureArguments.cs deleted file mode 100644 index 6fb630c01..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Internal_DrawTextureArguments.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; - -namespace MelonUnityEngine -{ - // 2017.2.0 - [StructLayout(LayoutKind.Sequential)] - internal struct Internal_DrawTextureArguments_2017 - { - public Rect screenRect; - public Rect sourceRect; - public int leftBorder; - public int rightBorder; - public int topBorder; - public int bottomBorder; - public Color32 color; - public Vector4 borderWidths; - public float cornerRadius; - public int pass; - public IntPtr texture; - public IntPtr mat; - } - - // 2017.3.0, 2018.1.0 - [StructLayout(LayoutKind.Sequential)] - internal struct Internal_DrawTextureArguments_2018 - { - public Rect screenRect; - public Rect sourceRect; - public int leftBorder; - public int rightBorder; - public int topBorder; - public int bottomBorder; - public Color32 color; - public Vector4 borderWidths; - public Vector4 cornerRadius; // Int32 -> Vector4 - public int pass; - public IntPtr texture; - public IntPtr mat; - } - - // 2018.2.0, 2019.1.0 - [StructLayout(LayoutKind.Sequential)] - internal struct Internal_DrawTextureArguments_2019 - { - public Rect screenRect; - public Rect sourceRect; - public int leftBorder; - public int rightBorder; - public int topBorder; - public int bottomBorder; - public Color color; // Color32 -> Color - public Vector4 borderWidths; - public Vector4 cornerRadius; - public int pass; - public IntPtr texture; - public IntPtr mat; - } - - // 2019.3.0, 2020.1.0 - [StructLayout(LayoutKind.Sequential)] - internal struct Internal_DrawTextureArguments_2020 - { - public Rect screenRect; - public Rect sourceRect; - public int leftBorder; - public int rightBorder; - public int topBorder; - public int bottomBorder; - public Color leftBorderColor; // Added - public Color rightBorderColor; // Added - public Color topBorderColor; // Added - public Color bottomBorderColor; // Added - public Color color; - public Vector4 borderWidths; - public Vector4 cornerRadiuses; - public bool smoothCorners; // Added - public int pass; - public IntPtr texture; - public IntPtr mat; - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Material.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Material.cs deleted file mode 100644 index 733d8f6c0..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Material.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal class Material : UnityObject - { - private delegate bool d_SetPass(IntPtr @this, int pass); - private static readonly d_SetPass m_SetPass; - - unsafe static Material() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Material"); - UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - - //m_SetPass = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "SetPass", "System.Boolean", "System.Int32"); - m_SetPass = UnityInternals.ResolveICall("UnityEngine.Material::SetPass"); - } - - public Material(IntPtr ptr) : base(ptr) { } - - public unsafe bool SetPass(int pass) - { - return m_SetPass(UnityInternals.ObjectBaseToPtrNotNull(this), pass); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Mesh.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Mesh.cs deleted file mode 100644 index 8e1dfcdc7..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Mesh.cs +++ /dev/null @@ -1,168 +0,0 @@ -using MelonLoader; -using MelonLoader.MelonStartScreen.NativeUtils; -using System; -using UnhollowerMini; -using MelonUnityEngine.Rendering; - -namespace MelonUnityEngine -{ - internal sealed class Mesh : UnityObject - { - private delegate void SetArrayForChannelImpl_2017(IntPtr @this, int channel, int format, int dim, IntPtr values, int arraySize); - private delegate void SetArrayForChannelImpl_2019(IntPtr @this, int channel, int format, int dim, IntPtr values, int arraySize, int valuesStart, int valuesCount); - private delegate void SetArrayForChannelImpl_2020(IntPtr @this, int channel, int format, int dim, IntPtr values, int arraySize, int valuesStart, int valuesCount, int updateFlags); - - private static readonly IntPtr m_ctor; - private static readonly IntPtr m_set_triangles; - private static readonly IntPtr m_RecalculateBounds; - - private static readonly SetArrayForChannelImpl_2017 m_SetArrayForChannelImpl_2017; - private static readonly SetArrayForChannelImpl_2019 m_SetArrayForChannelImpl_2019; - private static readonly SetArrayForChannelImpl_2020 m_SetArrayForChannelImpl_2020; - private static readonly int type_SetArrayForChannelImpl = -1; - - static Mesh() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Mesh"); - UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - - m_ctor = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, ".ctor", "System.Void"); - - m_set_triangles = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "set_triangles", "System.Void", "System.Int32[]"); - m_RecalculateBounds = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "RecalculateBounds", "System.Void"); - - if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2020.1.0" })) - { - m_SetArrayForChannelImpl_2020 = UnityInternals.ResolveICall("UnityEngine.Mesh::SetArrayForChannelImpl"); - type_SetArrayForChannelImpl = 2; - } - else if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2019.3.0" })) - { - m_SetArrayForChannelImpl_2019 = UnityInternals.ResolveICall("UnityEngine.Mesh::SetArrayForChannelImpl"); - type_SetArrayForChannelImpl = 1; - } - else if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2017.1.0" })) - { - m_SetArrayForChannelImpl_2017 = UnityInternals.ResolveICall("UnityEngine.Mesh::SetArrayForChannelImpl"); - type_SetArrayForChannelImpl = 0; - } - } - - public Mesh(IntPtr ptr) : base(ptr) { } - - public unsafe Mesh() : base(UnityInternals.object_new(InternalClassPointerStore.NativeClassPtr)) - { - IntPtr returnedException = default; - UnityInternals.runtime_invoke(m_ctor, UnityInternals.ObjectBaseToPtrNotNull(this), (void**)0, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - } - - private unsafe void SetArrayForChannelImpl(int channel, IntPtr values, int channelDimensions, int valuesCount) - { - if (type_SetArrayForChannelImpl == 0) - m_SetArrayForChannelImpl_2017(UnityInternals.ObjectBaseToPtrNotNull(this), channel, 0 /* float */, channelDimensions, values, valuesCount); - else if (type_SetArrayForChannelImpl == 1) - m_SetArrayForChannelImpl_2019(UnityInternals.ObjectBaseToPtrNotNull(this), channel, 0 /* float */, channelDimensions, values, valuesCount, 0, valuesCount); - else if (type_SetArrayForChannelImpl == 2) - m_SetArrayForChannelImpl_2020(UnityInternals.ObjectBaseToPtrNotNull(this), channel, 0 /* float */, channelDimensions, values, valuesCount, 0, valuesCount, 0 /* MeshUpdateFlags.Default */); - else - throw new NotImplementedException("SetArrayForChannel isn't implemented for this version of Unity"); - } - - - public unsafe Vector3[] vertices - { - set - { - int valuesCount = value.Length; - - IntPtr valueArrayPtr = UnityInternals.array_new(InternalClassPointerStore.NativeClassPtr, (ulong)valuesCount); - for (var i = 0; i < valuesCount; i++) - ((Vector3*)((long)valueArrayPtr + 4 * IntPtr.Size))[i] = value[i]; - - SetArrayForChannelImpl(VertexAttribute.Vertex, valueArrayPtr, 3, valuesCount); - } - } - - public unsafe Vector3[] normals - { - set - { - int valuesCount = value.Length; - - IntPtr valueArrayPtr = UnityInternals.array_new(InternalClassPointerStore.NativeClassPtr, (ulong)valuesCount); - for (var i = 0; i < valuesCount; i++) - ((Vector3*)((long)valueArrayPtr + 4 * IntPtr.Size))[i] = value[i]; - - SetArrayForChannelImpl(VertexAttribute.Normal, valueArrayPtr, 3, valuesCount); - } - } - - public unsafe Vector4[] tangents - { - set - { - int valuesCount = value.Length; - - IntPtr valueArrayPtr = UnityInternals.array_new(InternalClassPointerStore.NativeClassPtr, (ulong)valuesCount); - for (var i = 0; i < valuesCount; i++) - ((Vector4*)((long)valueArrayPtr + 4 * IntPtr.Size))[i] = value[i]; - - SetArrayForChannelImpl(VertexAttribute.Tangent, valueArrayPtr, 4, valuesCount); - } - } - - public unsafe Vector2[] uv - { - set - { - int valuesCount = value.Length; - - IntPtr valueArrayPtr = UnityInternals.array_new(InternalClassPointerStore.NativeClassPtr, (ulong)valuesCount); - for (var i = 0; i < valuesCount; i++) - ((Vector2*)((long)valueArrayPtr + 4 * IntPtr.Size))[i] = value[i]; - - SetArrayForChannelImpl(VertexAttribute.TexCoord0, valueArrayPtr, 2, valuesCount); - } - } - - public unsafe Color[] colors - { - set - { - int valuesCount = value.Length; - - IntPtr valueArrayPtr = UnityInternals.array_new(InternalClassPointerStore.NativeClassPtr, (ulong)valuesCount); - for (var i = 0; i < valuesCount; i++) - ((Color*)((long)valueArrayPtr + 4 * IntPtr.Size))[i] = value[i]; - - SetArrayForChannelImpl(VertexAttribute.Color, valueArrayPtr, 4, valuesCount); - } - } - - public unsafe int[] triangles - { - set - { - UnityInternals.ObjectBaseToPtrNotNull(this); - IntPtr valueArrayPtr = UnityInternals.array_new(InternalClassPointerStore.NativeClassPtr, (ulong)value.Length); - for (var i = 0; i < value.Length; i++) - ((int*)((long)valueArrayPtr + 4 * IntPtr.Size))[i] = value[i]; - void** ptr = stackalloc void*[1]; - ptr[0] = (void*)valueArrayPtr; - IntPtr returnedException = default; - IntPtr intPtr = UnityInternals.runtime_invoke(m_set_triangles, UnityInternals.ObjectBaseToPtrNotNull(this), ptr, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - } - } - - public unsafe void RecalculateBounds() - { - UnityInternals.ObjectBaseToPtrNotNull(this); - IntPtr returnedException = default; - UnityInternals.runtime_invoke(m_RecalculateBounds, UnityInternals.ObjectBaseToPtrNotNull(this), (void**)0, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - } - - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Quaternion.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Quaternion.cs deleted file mode 100644 index ab8ffa03b..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Quaternion.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - [StructLayout(LayoutKind.Explicit)] - internal struct Quaternion - { - [FieldOffset(0)] - public float x; - [FieldOffset(4)] - public float y; - [FieldOffset(8)] - public float z; - [FieldOffset(12)] - public float w; - - static Quaternion() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Quaternion"); - } - - public static Quaternion identity => new Quaternion(); - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Rect.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Rect.cs deleted file mode 100644 index 17cf00d19..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Rect.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - [StructLayout(LayoutKind.Explicit)] - internal struct Rect - { - [FieldOffset(0)] - public float m_XMin; - [FieldOffset(4)] - public float m_YMin; - [FieldOffset(8)] - public float m_Width; - [FieldOffset(12)] - public float m_Height; - - static Rect() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Rect"); - UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - } - - public Rect(int x, int y, int width, int height) - { - m_XMin = x; - m_YMin = y; - m_Width = width; - m_Height = height; - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Resources.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Resources.cs deleted file mode 100644 index 2dadb77f3..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Resources.cs +++ /dev/null @@ -1,41 +0,0 @@ -using MelonLoader; -using System; -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal class Resources - { - private static readonly IntPtr m_GetBuiltinResource; - - static Resources() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Resources"); - //UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - - m_GetBuiltinResource = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "GetBuiltinResource", "UnityEngine.Object", "System.Type", "System.String"); - - } - - public unsafe static IntPtr GetBuiltinResource(Il2CppSystem.Type type, string path) - { - void** ptr = stackalloc void*[2]; - ptr[0] = (void*)UnityInternals.ObjectBaseToPtr(type); - ptr[1] = (void*)UnityInternals.ManagedStringToInternal(path); - IntPtr returnedException = default; - MelonDebug.Msg("Calling runtime_invoke for GetBuiltinResource"); - IntPtr objectPointer = UnityInternals.runtime_invoke(m_GetBuiltinResource, IntPtr.Zero, ptr, ref returnedException); - MelonDebug.Msg("returnedException: " + returnedException + ", objectPointer: " + objectPointer); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - return objectPointer; - } - - public static T GetBuiltinResource(string path) where T : InternalObjectBase - { - MelonDebug.Msg("GetBuiltinResource"); - IntPtr ptr = GetBuiltinResource(InternalType.Of(), path); - return ptr != IntPtr.Zero ? (T)typeof(T).GetConstructor(new[] { typeof(IntPtr) }).Invoke(new object[] { ptr }) : null; - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Screen.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Screen.cs deleted file mode 100644 index 259486606..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Screen.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal class Screen - { - private static IntPtr m_get_width; - private static IntPtr m_get_height; - - static Screen() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Screen"); - m_get_width = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "get_width", "System.Int32"); - m_get_height = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "get_height", "System.Int32"); - } - - public unsafe static int width - { - get - { - IntPtr* param = null; - IntPtr returnedException = IntPtr.Zero; - IntPtr intPtr = UnityInternals.runtime_invoke(m_get_width, IntPtr.Zero, (void**)param, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - return *(int*)UnityInternals.object_unbox(intPtr); - } - } - - public unsafe static int height - { - get - { - IntPtr* param = null; - IntPtr returnedException = IntPtr.Zero; - IntPtr intPtr = UnityInternals.runtime_invoke(m_get_height, IntPtr.Zero, (void**)param, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - return *(int*)UnityInternals.object_unbox(intPtr); - } - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/SystemInfo.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/SystemInfo.cs deleted file mode 100644 index 9f00acc27..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/SystemInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using MelonLoader; -using MelonLoader.MelonStartScreen.NativeUtils; -using UnhollowerMini; - -namespace MelonUnityEngine.CoreModule -{ - internal sealed class SystemInfo - { - private delegate uint d_GetGraphicsDeviceType(); - private static readonly d_GetGraphicsDeviceType m_GetGraphicsDeviceType; - - unsafe static SystemInfo() - { - if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2018.1.0" })) - m_GetGraphicsDeviceType = UnityInternals.ResolveICall("UnityEngine.SystemInfo::GetGraphicsDeviceType"); - else - m_GetGraphicsDeviceType = UnityInternals.ResolveICall("UnityEngine.SystemInfo::get_graphicsDeviceType"); - } - - public static uint GetGraphicsDeviceType() => - m_GetGraphicsDeviceType(); - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Texture.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Texture.cs deleted file mode 100644 index b6b681578..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Texture.cs +++ /dev/null @@ -1,45 +0,0 @@ -using MelonLoader; -using MelonLoader.MelonStartScreen.NativeUtils; -using System; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal class Texture : UnityObject - { - private delegate int GetDataWidthDelegate(IntPtr @this); - private delegate int GetDataHeightDelegate(IntPtr @this); - private delegate int set_filterModeDelegate(IntPtr @this, FilterMode filterMode); - - private static readonly GetDataWidthDelegate getDataWidth; - private static readonly GetDataHeightDelegate getDataHeight; - private static readonly set_filterModeDelegate set_filterMode_; - - static Texture() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Texture"); - - if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2018.1.0" })) - { - getDataWidth = UnityInternals.ResolveICall("UnityEngine.Texture::GetDataWidth"); - getDataHeight = UnityInternals.ResolveICall("UnityEngine.Texture::GetDataHeight"); - } - else if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2017.1.0" })) - { - getDataWidth = UnityInternals.ResolveICall("UnityEngine.Texture::Internal_GetWidth"); - getDataHeight = UnityInternals.ResolveICall("UnityEngine.Texture::Internal_GetHeight"); - } - set_filterMode_ = UnityInternals.ResolveICall("UnityEngine.Texture::set_filterMode"); - } - - public Texture(IntPtr ptr) : base(ptr) { } - - public int width => getDataWidth(UnityInternals.ObjectBaseToPtrNotNull(this)); - public int height => getDataHeight(UnityInternals.ObjectBaseToPtrNotNull(this)); - - public FilterMode filterMode - { - set => set_filterMode_(UnityInternals.ObjectBaseToPtrNotNull(this), value); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Texture2D.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Texture2D.cs deleted file mode 100644 index 277e0571d..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Texture2D.cs +++ /dev/null @@ -1,98 +0,0 @@ -using MelonLoader; -using MelonLoader.MelonStartScreen.NativeUtils; -using System; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal class Texture2D : Texture - { - private delegate void SetPixelsImplDelegate_2017(IntPtr @this, int x, int y, int w, int h, IntPtr pixel, int miplevel); - private delegate void SetPixelsImplDelegate_2018(IntPtr @this, int x, int y, int w, int h, IntPtr pixel, int miplevel, int frame); - - private static readonly IntPtr m_get_whiteTexture; - private static readonly IntPtr m_ctor; - private static readonly SetPixelsImplDelegate_2017 m_SetPixelsImpl_2017; - private static readonly SetPixelsImplDelegate_2018 m_SetPixelsImpl_2018; - private static readonly IntPtr m_Apply; - - private static readonly int type_SetPixelsImpl = -1; - - static Texture2D() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Texture2D"); - UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - - m_ctor = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, ".ctor", "System.Void", "System.Int32", "System.Int32"); - - m_get_whiteTexture = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "get_whiteTexture", "UnityEngine.Texture2D"); - - if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2018.1.0" })) { - type_SetPixelsImpl = 1; - m_SetPixelsImpl_2018 = UnityInternals.ResolveICall("UnityEngine.Texture2D::SetPixelsImpl"); - } - else if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2017.1.0" })) - { - type_SetPixelsImpl = 0; - m_SetPixelsImpl_2017 = UnityInternals.ResolveICall("UnityEngine.Texture2D::SetPixels"); - } - - m_Apply = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "Apply", "System.Void"); - } - - public Texture2D(IntPtr ptr) : base(ptr) { } - - public unsafe static Texture2D whiteTexture - { - get - { - IntPtr returnedException = IntPtr.Zero; - IntPtr intPtr = UnityInternals.runtime_invoke(m_get_whiteTexture, IntPtr.Zero, (void**)0, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - return intPtr == IntPtr.Zero ? null : new Texture2D(intPtr); - } - } - - public unsafe Texture2D(int width, int height) : base(UnityInternals.object_new(InternalClassPointerStore.NativeClassPtr)) - { - void** args = stackalloc void*[2]; - args[0] = &width; - args[1] = &height; - IntPtr returnedException = default; - UnityInternals.runtime_invoke(m_ctor, UnityInternals.ObjectBaseToPtrNotNull(this), args, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - } - - public unsafe void SetPixels(Color[] colors) - { - SetPixels(0, 0, width, height, colors, 0); - } - - public unsafe void SetPixels(int x, int y, int blockWidth, int blockHeight, Color[] colors, int miplevel = 0) - { - SetPixelsImpl(x, y, blockWidth, blockHeight, colors, miplevel, 0); - } - - public unsafe void SetPixelsImpl(int x, int y, int w, int h, Color[] pixel, int miplevel, int frame) - { - IntPtr pixelArrayPtr = UnityInternals.array_new(InternalClassPointerStore.NativeClassPtr, (uint)pixel.Length); - for (var i = 0; i < pixel.Length; i++) - { - IntPtr arrayStartPointer = (IntPtr)((long)pixelArrayPtr + 4 * IntPtr.Size); - ((Color*)arrayStartPointer.ToPointer())[i] = pixel[i]; - } - - if (type_SetPixelsImpl == 0) - m_SetPixelsImpl_2017(UnityInternals.ObjectBaseToPtrNotNull(this), x, y, w, h, pixelArrayPtr, miplevel); - else if (type_SetPixelsImpl == 1) - m_SetPixelsImpl_2018(UnityInternals.ObjectBaseToPtrNotNull(this), x, y, w, h, pixelArrayPtr, miplevel, frame); - } - - public unsafe void Apply() - { - IntPtr returnedException = default; - UnityInternals.runtime_invoke(m_Apply, UnityInternals.ObjectBaseToPtrNotNull(this), (void**)0, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/UnityDebug.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/UnityDebug.cs deleted file mode 100644 index ee4b45df9..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/UnityDebug.cs +++ /dev/null @@ -1,24 +0,0 @@ -using MelonLoader; -using System; -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal static class UnityDebug - { - private delegate bool get_isDebugBuild_Delegate(); - private static get_isDebugBuild_Delegate get_isDebugBuild_Ptr; - - static UnityDebug() - { - IntPtr ptr = UnityInternals.ResolveICall("UnityEngine.Debug::get_isDebugBuild"); - if (ptr != IntPtr.Zero) - get_isDebugBuild_Ptr = (get_isDebugBuild_Delegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(get_isDebugBuild_Delegate)); - else - MelonLogger.Error("Failed to resolve icall UnityEngine.Debug::get_isDebugBuild"); - } - - internal static bool isDebugBuild { get => get_isDebugBuild_Ptr(); } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/UnityObject.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/UnityObject.cs deleted file mode 100644 index a7fbae4dd..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/UnityObject.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal class UnityObject : InternalObjectBase - { - private delegate HideFlags get_hideFlags_Delegate(IntPtr obj); - private static get_hideFlags_Delegate m_get_hideFlags; - private delegate void set_hideFlags_Delegate(IntPtr obj, HideFlags hideFlags); - private static set_hideFlags_Delegate m_set_hideFlags; - - private static IntPtr m_DestroyImmediate; - private static IntPtr m_DontDestroyOnLoad; - unsafe static UnityObject() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Object"); - //UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - - m_DestroyImmediate = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "DestroyImmediate", "System.Void", "UnityEngine.Object"); - m_DontDestroyOnLoad = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "DontDestroyOnLoad", "System.Void", "UnityEngine.Object"); - - m_get_hideFlags = UnityInternals.ResolveICall("UnityEngine.Object::get_hideFlags(UnityEngine.Object)"); - m_set_hideFlags = UnityInternals.ResolveICall("UnityEngine.Object::set_hideFlags(UnityEngine.Object)"); - } - - public UnityObject(IntPtr ptr) : base(ptr) { } - - unsafe public HideFlags hideFlags - { - get - { - if (Pointer == IntPtr.Zero) - return HideFlags.None; - return m_get_hideFlags(Pointer); - } - set - { - if (Pointer == IntPtr.Zero) - return; - m_set_hideFlags(Pointer, value); - } - } - - unsafe public void DestroyImmediate() - { - if (Pointer == IntPtr.Zero) - return; - - void** args = stackalloc void*[1]; - args[0] = Pointer.ToPointer(); - - IntPtr returnedException = IntPtr.Zero; - UnityInternals.runtime_invoke(m_DestroyImmediate, IntPtr.Zero, args, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - } - - unsafe public void DontDestroyOnLoad() - { - if (Pointer == IntPtr.Zero) - return; - - void** args = stackalloc void*[1]; - args[0] = Pointer.ToPointer(); - - IntPtr returnedException = IntPtr.Zero; - UnityInternals.runtime_invoke(m_DontDestroyOnLoad, IntPtr.Zero, args, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector2.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector2.cs deleted file mode 100644 index 9ad85ed7f..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector2.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - [StructLayout(LayoutKind.Explicit)] - internal struct Vector2 - { - [FieldOffset(0)] - public float x; - [FieldOffset(4)] - public float y; - - static Vector2() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Vector2"); - } - - public Vector2(float x, float y) - { - this.x = x; - this.y = y; - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector3.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector3.cs deleted file mode 100644 index 1089a10f0..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector3.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - [StructLayout(LayoutKind.Explicit)] - internal struct Vector3 - { - [FieldOffset(0)] - public float x; - [FieldOffset(4)] - public float y; - [FieldOffset(8)] - public float z; - - static Vector3() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Vector3"); - } - - public static Vector3 zero => new Vector3(); - - public Vector3(float x, float y, float z) - { - this.x = x; - this.y = y; - this.z = z; - } - - public static Vector3 operator*(Vector3 a, float d) - { - return new Vector3(a.x * d, a.y * d, a.z * d); - } - - public override string ToString() - { - return $"{x} {y} {z}"; - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector4.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector4.cs deleted file mode 100644 index d0b4d911b..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector4.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - [StructLayout(LayoutKind.Explicit)] - internal struct Vector4 - { - [FieldOffset(0)] - public float x; - [FieldOffset(4)] - public float y; - [FieldOffset(8)] - public float z; - [FieldOffset(12)] - public float w; - - static Vector4() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Vector4"); - } - - public static explicit operator Vector2(Vector4 src) => new Vector2(src.x, src.y); - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/VertexAttribute.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/VertexAttribute.cs deleted file mode 100644 index e4fa48bd0..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/VertexAttribute.cs +++ /dev/null @@ -1,22 +0,0 @@ -using MelonLoader.MelonStartScreen.NativeUtils; - -namespace MelonUnityEngine.Rendering -{ - static class VertexAttribute - { - public static int Vertex = 0; - public static int Normal = 1; - - [NativeFieldValue(01, NativeSignatureFlags.None, 7, "2017.1.0")] - [NativeFieldValue(02, NativeSignatureFlags.None, 2, "2018.1.0")] - public static int Tangent = 0; - - [NativeFieldValue(01, NativeSignatureFlags.None, 2, "2017.1.0")] - [NativeFieldValue(02, NativeSignatureFlags.None, 3, "2018.1.0")] - public static int Color = 0; - - [NativeFieldValue(01, NativeSignatureFlags.None, 3, "2017.1.0")] - [NativeFieldValue(02, NativeSignatureFlags.None, 4, "2018.1.0")] - public static int TexCoord0 = 0; - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/VerticalWrapMode.cs b/Dependencies/MelonStartScreen/UnityEngine/CoreModule/VerticalWrapMode.cs deleted file mode 100644 index 20c510df6..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/CoreModule/VerticalWrapMode.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace MelonUnityEngine -{ - internal enum VerticalWrapMode - { - Truncate, - Overflow - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/Font.cs b/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/Font.cs deleted file mode 100644 index 790a07084..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/Font.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal class Font : UnityObject - { - private static IntPtr m_get_material; - - static Font() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.TextRenderingModule.dll", "UnityEngine", "Font"); - UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - - m_get_material = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "get_material", "UnityEngine.Material"); - } - - public Font(IntPtr ptr) : base(ptr) { } - - public unsafe Material material - { - get - { - UnityInternals.ObjectBaseToPtrNotNull(this); - IntPtr returnedException = default; - IntPtr intPtr = UnityInternals.runtime_invoke(Font.m_get_material, UnityInternals.ObjectBaseToPtrNotNull(this), (void**)0, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - return (intPtr != IntPtr.Zero) ? new Material(intPtr) : null; - } - // set - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/FontStyle.cs b/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/FontStyle.cs deleted file mode 100644 index d9f5764f4..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/FontStyle.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MelonUnityEngine -{ - internal enum FontStyle - { - Normal, - Bold, - Italic, - BoldAndItalic - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/TextAnchor.cs b/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/TextAnchor.cs deleted file mode 100644 index 5b997cf00..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/TextAnchor.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace MelonUnityEngine -{ - internal enum TextAnchor - { - UpperLeft, - UpperCenter, - UpperRight, - MiddleLeft, - MiddleCenter, - MiddleRight, - LowerLeft, - LowerCenter, - LowerRight - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/TextGenerationSettings.cs b/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/TextGenerationSettings.cs deleted file mode 100644 index f8983e9cd..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/TextGenerationSettings.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - internal class TextGenerationSettings : InternalObjectBase - { - private static readonly int classsize; - - private static readonly IntPtr f_font; - private static readonly IntPtr f_color; - private static readonly IntPtr f_fontSize; - private static readonly IntPtr f_lineSpacing; - private static readonly IntPtr f_richText; - private static readonly IntPtr f_scaleFactor; - private static readonly IntPtr f_fontStyle; - private static readonly IntPtr f_textAnchor; - //private static readonly IntPtr f_alignByGeometry; - //private static readonly IntPtr f_resizeTextForBestFit; - //private static readonly IntPtr f_resizeTextMinSize; - //private static readonly IntPtr f_resizeTextMaxSize; - //private static readonly IntPtr f_updateBounds; - private static readonly IntPtr f_verticalOverflow; - //private static readonly IntPtr f_horizontalOverflow; - private static readonly IntPtr f_generationExtents; - private static readonly IntPtr f_pivot; - //private static readonly IntPtr f_generateOutOfBounds; - - static TextGenerationSettings() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.TextRenderingModule.dll", "UnityEngine", "TextGenerationSettings"); - //UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - - uint align = 0; - classsize = UnityInternals.class_value_size(InternalClassPointerStore.NativeClassPtr, ref align); - - - f_font = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "font"); - f_color = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "color"); - f_fontSize = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "fontSize"); - f_lineSpacing = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "lineSpacing"); - f_richText = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "richText"); - f_scaleFactor = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "scaleFactor"); - f_fontStyle = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "fontStyle"); - f_textAnchor = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "textAnchor"); - //f_alignByGeometry = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "alignByGeometry"); - //f_resizeTextForBestFit = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "resizeTextForBestFit"); - //f_resizeTextMinSize = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "resizeTextMinSize"); - //f_resizeTextMaxSize = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "resizeTextMaxSize"); - //f_updateBounds = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "updateBounds"); - f_verticalOverflow = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "verticalOverflow"); - //f_horizontalOverflow = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "horizontalOverflow"); - f_generationExtents = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "generationExtents"); - f_pivot = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "pivot"); - //f_generateOutOfBounds = UnityInternals.GetField(InternalClassPointerStore.NativeClassPtr, "generateOutOfBounds"); - } - - public TextGenerationSettings(IntPtr ptr) : base(ptr) { } - - public unsafe TextGenerationSettings() - { - byte** data = stackalloc byte*[classsize]; - IntPtr pointer = UnityInternals.value_box(InternalClassPointerStore.NativeClassPtr, (IntPtr)data); - myGcHandle = UnityInternals.gchandle_new(pointer, false); - } - - public unsafe Font font - { - get - { - IntPtr intPtr = *(IntPtr*)((uint)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_font)); - return (intPtr != IntPtr.Zero) ? new Font(intPtr) : null; - } - set => *(IntPtr*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_font)) = UnityInternals.ObjectBaseToPtr(value); - } - - public unsafe Color color - { - get => *(Color*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_color)); - set => *(Color*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_color)) = value; - } - - public unsafe int fontSize - { - get => *(int*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_fontSize)); - set => *(int*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_fontSize)) = value; - } - - public unsafe float lineSpacing - { - get => *(float*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_lineSpacing)); - set => *(float*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_lineSpacing)) = value; - } - - public unsafe bool richText - { - get => *(bool*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_richText)); - set => *(bool*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_richText)) = value; - } - - public unsafe float scaleFactor - { - get => *(float*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_scaleFactor)); - set => *(float*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_scaleFactor)) = value; - } - - public unsafe FontStyle fontStyle - { - get => *(FontStyle*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_fontStyle)); - set => *(FontStyle*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_fontStyle)) = value; - } - - public unsafe TextAnchor textAnchor - { - get => *(TextAnchor*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_textAnchor)); - set => *(TextAnchor*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_textAnchor)) = value; - } - - public unsafe VerticalWrapMode verticalOverflow - { - get => *(VerticalWrapMode*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_verticalOverflow)); - set => *(VerticalWrapMode*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_verticalOverflow)) = value; - } - - public unsafe Vector2 generationExtents - { - get => *(Vector2*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_generationExtents)); - set => *(Vector2*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_generationExtents)) = value; - } - - public unsafe Vector2 pivot - { - get => *(Vector2*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_pivot)); - set => *(Vector2*)((ulong)UnityInternals.ObjectBaseToPtrNotNull(this) + UnityInternals.field_get_offset(f_pivot)) = value; - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/TextGenerator.cs b/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/TextGenerator.cs deleted file mode 100644 index 6cb6b2a63..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/TextGenerator.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using UnhollowerMini; - -namespace MelonUnityEngine -{ - class TextGenerator : InternalObjectBase - { - private delegate int get_vertexCountDelegate(IntPtr @this); - private delegate IntPtr GetVerticesArrayDelegate(IntPtr @this); - - private static readonly IntPtr m_ctor; - private static readonly IntPtr m_Populate; - private static readonly get_vertexCountDelegate fd_get_vertexCount; - private static readonly GetVerticesArrayDelegate fd_GetVerticesArray; - - static TextGenerator() - { - InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.TextRenderingModule.dll", "UnityEngine", "TextGenerator"); - UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); - - m_ctor = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, ".ctor", "System.Void"); - - m_Populate = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "Populate", "System.Boolean", "System.String", "UnityEngine.TextGenerationSettings"); - - fd_get_vertexCount = UnityInternals.ResolveICall("UnityEngine.TextGenerator::get_vertexCount"); - fd_GetVerticesArray = UnityInternals.ResolveICall("UnityEngine.TextGenerator::GetVerticesArray"); - } - - public TextGenerator(IntPtr ptr) : base(ptr) { } - - public unsafe TextGenerator() : this(UnityInternals.object_new(InternalClassPointerStore.NativeClassPtr)) - { - IntPtr returnedException = default; - UnityInternals.runtime_invoke(m_ctor, UnityInternals.ObjectBaseToPtrNotNull(this), (void**)0, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - } - - public unsafe bool Populate(string str, TextGenerationSettings settings) - { - void** args = stackalloc void*[2]; - args[0] = (void*)UnityInternals.ManagedStringToInternal(str); - args[1] = (void*)UnityInternals.object_unbox(UnityInternals.ObjectBaseToPtrNotNull(settings)); - IntPtr returnedException = default; - IntPtr obj = UnityInternals.runtime_invoke(m_Populate, UnityInternals.ObjectBaseToPtrNotNull(this), args, ref returnedException); - Il2CppException.RaiseExceptionIfNecessary(returnedException); - return *(bool*)UnityInternals.object_unbox(obj); - } - - public int vertexCount => fd_get_vertexCount(UnityInternals.ObjectBaseToPtrNotNull(this)); - - public unsafe UIVertexWrapper[] GetVerticesArray() - { - IntPtr intPtr = fd_GetVerticesArray(UnityInternals.ObjectBaseToPtrNotNull(this)); - if (intPtr == IntPtr.Zero) return null; - UIVertexWrapper[] arr = new UIVertexWrapper[UnityInternals.array_length(intPtr)]; - for (int i = 0; i < arr.Length; ++i) - arr[i] = new UIVertexWrapper((IntPtr)((long)intPtr + 4 * IntPtr.Size + i * UIVertexWrapper.sizeOfElement)); - // arr[i] = ( (UIVertex*)((long)intPtr + 4 * IntPtr.Size) )[i]; - // arr[i] = *( (UIVertex*)((long)intPtr + 4 * IntPtr.Size) + (i * sizeof(UIVertex))) - return arr; - } - } -} diff --git a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/UIVertex.cs b/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/UIVertex.cs deleted file mode 100644 index a7a844c3f..000000000 --- a/Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/UIVertex.cs +++ /dev/null @@ -1,108 +0,0 @@ -using MelonLoader; -using MelonLoader.MelonStartScreen.NativeUtils; -using System; -using System.Runtime.InteropServices; - -namespace MelonUnityEngine -{ - [StructLayout(LayoutKind.Sequential)] - internal struct UIVertex_2020 - { - public Vector3 position; - public Vector3 normal; - public Vector4 tangent; - public Color32 color; - public Vector4 uv0; - public Vector4 uv1; - public Vector4 uv2; - public Vector4 uv3; - } - - [StructLayout(LayoutKind.Sequential)] - internal struct UIVertex_2018 - { - public Vector3 position; - public Vector3 normal; - public Vector4 tangent; - public Color32 color; - public Vector2 uv0; - public Vector2 uv1; - public Vector2 uv2; - public Vector2 uv3; - } - - [StructLayout(LayoutKind.Sequential)] - internal struct UIVertex_2017 - { - public Vector3 position; - public Vector3 normal; - public Color32 color; - public Vector2 uv0; - public Vector2 uv1; - public Vector2 uv2; - public Vector2 uv3; - public Vector4 tangent; - } - - internal struct UIVertexWrapper - { - private static readonly int mode = -1; - public static readonly int sizeOfElement = 0; - - private IntPtr ptr; - - unsafe static UIVertexWrapper() - { - if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2020.2.0", "2021.1.0" })) - { - mode = 2; - sizeOfElement = sizeof(UIVertex_2020); - } - else if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2018.1.0" })) - { - mode = 1; - sizeOfElement = sizeof(UIVertex_2018); - } - else if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2017.2.0" })) - { - mode = 0; - sizeOfElement = sizeof(UIVertex_2017); - } - } - - public UIVertexWrapper(IntPtr ptr) - { - this.ptr = ptr; - } - - public unsafe Vector3 position => - mode == 2 ? (*(UIVertex_2020*)ptr).position : - mode == 1 ? (*(UIVertex_2018*)ptr).position : - mode == 0 ? (*(UIVertex_2017*)ptr).position : - throw new Exception("UIVertex mode not set"); - - public unsafe Vector3 normal => - mode == 2 ? (*(UIVertex_2020*)ptr).normal : - mode == 1 ? (*(UIVertex_2018*)ptr).normal : - mode == 0 ? (*(UIVertex_2017*)ptr).normal : - throw new Exception("UIVertex mode not set"); - - public unsafe Vector4 tangent => - mode == 2 ? (*(UIVertex_2020*)ptr).tangent : - mode == 1 ? (*(UIVertex_2018*)ptr).tangent : - mode == 0 ? (*(UIVertex_2017*)ptr).tangent : - throw new Exception("UIVertex mode not set"); - - public unsafe Color32 color => - mode == 2 ? (*(UIVertex_2020*)ptr).color : - mode == 1 ? (*(UIVertex_2018*)ptr).color : - mode == 0 ? (*(UIVertex_2017*)ptr).color : - throw new Exception("UIVertex mode not set"); - - public unsafe Vector2 uv0 => - mode == 2 ? (Vector2)(*(UIVertex_2020*)ptr).uv0 : - mode == 1 ? (*(UIVertex_2018*)ptr).uv0 : - mode == 0 ? (*(UIVertex_2017*)ptr).uv0 : - throw new Exception("UIVertex mode not set"); - } -} diff --git a/Dependencies/MelonStartScreen/UnityPlayer/GfxDevice.cs b/Dependencies/MelonStartScreen/UnityPlayer/GfxDevice.cs deleted file mode 100644 index e6098c8f6..000000000 --- a/Dependencies/MelonStartScreen/UnityPlayer/GfxDevice.cs +++ /dev/null @@ -1,104 +0,0 @@ -using MelonLoader; -using MelonLoader.NativeUtils; -using MelonLoader.MelonStartScreen.NativeUtils; -using System; -using System.Runtime.InteropServices; -using UnhollowerMini; - -namespace UnityPlayer -{ - internal class GfxDevice - { - private delegate void PresentFrameDelegate(); - private delegate void WaitForLastPresentationAndGetTimestampDelegate(IntPtr gfxDevice); - private delegate IntPtr GetRealGfxDeviceDelegate(); - -#pragma warning disable 0649 - #region m_PresentFrame Signatures - [NativeSignature(01, NativeSignatureFlags.X86, "e8 ?? ?? ?? ?? 85 c0 74 12 e8 ?? ?? ?? ?? 8b ?? 8b ?? 8b 42 70 ff d0 84 c0 75", "2017.1.0", "5.6.0", "2017.1.0")] - [NativeSignature(02, NativeSignatureFlags.X86, "55 8b ec 51 e8 ?? ?? ?? ?? 85 c0 74 12 e8 ?? ?? ?? ?? 8b c8 8b 10 8b 42 ?? ff d0 84 c0 75", "2018.1.0")] - [NativeSignature(03, NativeSignatureFlags.X86, "55 8b ec 51 e8 ?? ?? ?? ?? 85 c0 74 15 e8 ?? ?? ?? ?? 8b c8 8b 10 8b 82 ?? 00 00 00 ff d0", "2018.4.9", "2019.1.0")] - [NativeSignature(04, NativeSignatureFlags.X86, "55 8b ec 51 56 e8 ?? ?? ?? ?? 8b f0 8b ce e8 ?? ?? ?? ?? e8 ?? ?? ?? ?? 85 c0 74 ?? e8", "2018.4.18", "2019.3.0", "2020.1.0")] - - [NativeSignature(01, NativeSignatureFlags.X64, "48 83 ec 28 e8 ?? ?? ?? ?? 48 85 c0 74 15 e8 ?? ?? ?? ?? 48 8b c8 48 8b 10 ff 92 e0 00 00 00 84 c0", "5.6.0", "2017.1.0")] - [NativeSignature(02, NativeSignatureFlags.X64, "48 83 ec 28 e8 ?? ?? ?? ?? 48 85 c0 74 15 e8 ?? ?? ?? ?? 48 8b c8 48 8b 10 ff 92 ?? ?? 00 00 84 c0", "2018.3.0", "2019.1.0")] // We can't use this one too early, else we match multiple functions - [NativeSignature(03, NativeSignatureFlags.X64, "40 53 48 83 ec 20 e8 ?? ?? ?? ?? 48 8b c8 48 8b d8 e8 ?? ?? ?? ?? e8 ?? ?? ?? ?? 48 85 c0 74", "2018.4.18", "2019.3.0", "2020.1.0")] - #endregion - private static PresentFrameDelegate m_PresentFrame; - - #region m_D3D11WaitForLastPresentationAndGetTimestamp Signatures - [NativeSignature(00, NativeSignatureFlags.None, null, "2017.1.0")] - - [NativeSignature(01, NativeSignatureFlags.X86, "55 8b ec 83 ec 40 53 56 8b d9 57 89 5d fc e8 ?? ?? ?? ?? 6a 02 8b c8", "2020.2.7", "2020.3.0", "2021.1.0")] - [NativeSignature(02, NativeSignatureFlags.X86, "55 8b ec 83 ec 48 53 56 8b d9 57 89 5d fc e8 ?? ?? ?? ?? 6a 02 8b c8", "2021.1.5", "2021.2.0")] - [NativeSignature(03, NativeSignatureFlags.X86, "55 8b ec 83 ec 58 53 56 8b d9 57 89 5d fc e8 ?? ?? ?? ?? 6a 02 8b c8", "2022.1.0")] - [NativeSignature(04, NativeSignatureFlags.X86 | NativeSignatureFlags.Mono, null, "2020.3.9")] // TODO validate this with more advanced sigcheck - - [NativeSignature(01, NativeSignatureFlags.X64, "48 89 5c 24 10 56 48 81 ec 90 00 00 00 0f 29 b4 24 80 00 00 00 48 8b f1", "2020.2.7", "2020.3.0", "2021.1.0")] - [NativeSignature(02, NativeSignatureFlags.X64, "48 89 5c 24 10 56 48 81 ec b0 00 00 00 0f 29 b4 24 a0 00 00 00 48 8b f1", "2022.1.0")] - #endregion - private static WaitForLastPresentationAndGetTimestampDelegate m_D3D11WaitForLastPresentationAndGetTimestamp; - - #region m_D3D12WaitForLastPresentationAndGetTimestamp Signatures - [NativeSignature(00, NativeSignatureFlags.None, null, "2017.1.0")] - - [NativeSignature(01, NativeSignatureFlags.X86, "55 8b ec 83 ec 40 53 56 57 8b f9 89 7d f4 e8 ?? ?? ?? ?? 6a 02 8b c8", "2020.2.7", "2020.3.0", "2021.1.0")] - [NativeSignature(02, NativeSignatureFlags.X86, "55 8b ec 83 ec 48 56 57 8b f9 89 7d f0 e8 ?? ?? ?? ?? 6a 02 8b c8", "2020.3.9", "2021.1.5")] - [NativeSignature(03, NativeSignatureFlags.X86, "55 8b ec 83 ec 48 56 57 8b f9 89 7d f8 e8 ?? ?? ?? ?? 6a 02 8b c8", "2021.2.0")] - [NativeSignature(04, NativeSignatureFlags.X86, "55 8b ec 83 ec 58 56 57 8b f9 89 7d f8 e8 ?? ?? ?? ?? 6a 02 8b c8", "2022.1.0")] - - [NativeSignature(01, NativeSignatureFlags.X64, "48 89 5c 24 08 57 48 81 ec 90 00 00 00 0f 29 b4 24 80 00 00 00 48 8b d9", "2020.2.7", "2020.3.0", "2021.1.0")] - [NativeSignature(02, NativeSignatureFlags.X64, "48 89 5c 24 08 57 48 81 ec b0 00 00 00 0f 29 b4 24 a0 00 00 00 48 8b d9", "2022.1.0")] - #endregion - private static WaitForLastPresentationAndGetTimestampDelegate m_D3D12WaitForLastPresentationAndGetTimestamp; -#pragma warning restore 0649 - - private static GetRealGfxDeviceDelegate m_GetRealGfxDevice; - - static GfxDevice() - { - if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new[] { "2020.2.7", "2020.3.0", "2021.1.0" })) - { - // `FrameTimingManager_CUSTOM_CaptureFrameTimings()` calls `GetRealGfxDevice()` after 4 bytes. - m_GetRealGfxDevice = (GetRealGfxDeviceDelegate)Marshal.GetDelegateForFunctionPointer( - CppUtils.ResolveRelativeInstruction( - (IntPtr)((long)UnityInternals.ResolveICall("UnityEngine.FrameTimingManager::CaptureFrameTimings") + (MelonUtils.IsGame32Bit() ? 0 : 4))), - typeof(GetRealGfxDeviceDelegate)); - } - } - - public static void PresentFrame() => - m_PresentFrame(); - - public static IntPtr GetRealGfxDevice() => - m_GetRealGfxDevice(); - - internal static void WaitForLastPresentationAndGetTimestamp(uint deviceType) - { - if (m_GetRealGfxDevice == null) - throw new NotImplementedException(); - - IntPtr gfxDevice = GetRealGfxDevice(); - if (gfxDevice == IntPtr.Zero) - throw new NotImplementedException(); - - switch (deviceType) - { - case /*DX11*/ 2: - if (m_D3D11WaitForLastPresentationAndGetTimestamp == null) - throw new NotImplementedException(); - m_D3D11WaitForLastPresentationAndGetTimestamp(gfxDevice); - break; - - case /*DX12*/ 18: - if (m_D3D12WaitForLastPresentationAndGetTimestamp == null) - throw new NotImplementedException(); - m_D3D12WaitForLastPresentationAndGetTimestamp(gfxDevice); - break; - - default: - throw new NotImplementedException(); - } - } - } -} diff --git a/Dependencies/MelonStartScreen/Windows/DropFile.cs b/Dependencies/MelonStartScreen/Windows/DropFile.cs deleted file mode 100644 index 7c9b2d4bb..000000000 --- a/Dependencies/MelonStartScreen/Windows/DropFile.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Runtime.InteropServices; - -namespace Windows -{ - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - class DropFile - { - uint pFiles = 14; - public Point pt; - public bool fNC; - bool fWide = true; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 300)] // Max path size on windows is 260 - public string file = ""; - } -} diff --git a/Dependencies/MelonStartScreen/Windows/Msg.cs b/Dependencies/MelonStartScreen/Windows/Msg.cs deleted file mode 100644 index 1a17fa734..000000000 --- a/Dependencies/MelonStartScreen/Windows/Msg.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows -{ - [StructLayout(LayoutKind.Sequential)] - internal struct Msg - { - public IntPtr hwnd; - public WindowMessage message; - public IntPtr wParam; - public IntPtr lParam; - public uint time; - public Point pt; - } -} diff --git a/Dependencies/MelonStartScreen/Windows/Point.cs b/Dependencies/MelonStartScreen/Windows/Point.cs deleted file mode 100644 index 4d7c5feae..000000000 --- a/Dependencies/MelonStartScreen/Windows/Point.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Windows -{ - internal struct Point - { - public int x; - public int y; - } -} diff --git a/Dependencies/MelonStartScreen/Windows/User32.cs b/Dependencies/MelonStartScreen/Windows/User32.cs deleted file mode 100644 index 9778f4a1b..000000000 --- a/Dependencies/MelonStartScreen/Windows/User32.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Windows -{ - internal static class User32 - { - [DllImport("user32.dll")] - public static extern bool PeekMessage(out Msg lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg); - - [DllImport("user32.dll")] - public static extern bool TranslateMessage([In] ref Msg lpMsg); - - [DllImport("user32.dll")] - public static extern IntPtr DispatchMessage([In] ref Msg lpmsg); - - [DllImport("user32.dll", SetLastError = false)] - public static extern IntPtr GetMessageExtraInfo(); - - [DllImport("user32.dll", ExactSpelling = true)] - public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc); - public delegate void TimerProc(IntPtr hWnd, uint uMsg, IntPtr nIDEvent, uint dwTime); - - [DllImport("user32.dll", ExactSpelling = true)] - public static extern bool KillTimer(IntPtr hWnd, IntPtr uIDEvent); - - [DllImport("user32.dll")] - public static extern IntPtr SetClipboardData(uint uFormat, ref DropFile hMem); - } -} diff --git a/Dependencies/MelonStartScreen/Windows/WindowMessage.cs b/Dependencies/MelonStartScreen/Windows/WindowMessage.cs deleted file mode 100644 index 738ebb605..000000000 --- a/Dependencies/MelonStartScreen/Windows/WindowMessage.cs +++ /dev/null @@ -1,969 +0,0 @@ -using System; - -namespace Windows -{ - /// - /// Windows Messages - /// Defined in winuser.h from Windows SDK v6.1 - /// Documentation pulled from MSDN. - /// - internal enum WindowMessage : uint - { - /// - /// The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore. - /// - NULL = 0x0000, - /// - /// The WM_CREATE message is sent when an application requests that a window be created by calling the CreateWindowEx or CreateWindow function. (The message is sent before the function returns.) The window procedure of the new window receives this message after the window is created, but before the window becomes visible. - /// - CREATE = 0x0001, - /// - /// The WM_DESTROY message is sent when a window is being destroyed. It is sent to the window procedure of the window being destroyed after the window is removed from the screen. - /// This message is sent first to the window being destroyed and then to the child windows (if any) as they are destroyed. During the processing of the message, it can be assumed that all child windows still exist. - /// /// - DESTROY = 0x0002, - /// - /// The WM_MOVE message is sent after a window has been moved. - /// - MOVE = 0x0003, - /// - /// The WM_SIZE message is sent to a window after its size has changed. - /// - SIZE = 0x0005, - /// - /// The WM_ACTIVATE message is sent to both the window being activated and the window being deactivated. If the windows use the same input queue, the message is sent synchronously, first to the window procedure of the top-level window being deactivated, then to the window procedure of the top-level window being activated. If the windows use different input queues, the message is sent asynchronously, so the window is activated immediately. - /// - ACTIVATE = 0x0006, - /// - /// The WM_SETFOCUS message is sent to a window after it has gained the keyboard focus. - /// - SETFOCUS = 0x0007, - /// - /// The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus. - /// - KILLFOCUS = 0x0008, - /// - /// The WM_ENABLE message is sent when an application changes the enabled state of a window. It is sent to the window whose enabled state is changing. This message is sent before the EnableWindow function returns, but after the enabled state (WS_DISABLED style bit) of the window has changed. - /// - ENABLE = 0x000A, - /// - /// An application sends the WM_SETREDRAW message to a window to allow changes in that window to be redrawn or to prevent changes in that window from being redrawn. - /// - SETREDRAW = 0x000B, - /// - /// An application sends a WM_SETTEXT message to set the text of a window. - /// - SETTEXT = 0x000C, - /// - /// An application sends a WM_GETTEXT message to copy the text that corresponds to a window into a buffer provided by the caller. - /// - GETTEXT = 0x000D, - /// - /// An application sends a WM_GETTEXTLENGTH message to determine the length, in characters, of the text associated with a window. - /// - GETTEXTLENGTH = 0x000E, - /// - /// The WM_PAINT message is sent when the system or another application makes a request to paint a portion of an application's window. The message is sent when the UpdateWindow or RedrawWindow function is called, or by the DispatchMessage function when the application obtains a WM_PAINT message by using the GetMessage or PeekMessage function. - /// - PAINT = 0x000F, - /// - /// The WM_CLOSE message is sent as a signal that a window or an application should terminate. - /// - CLOSE = 0x0010, - /// - /// The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls one of the system shutdown functions. If any application returns zero, the session is not ended. The system stops sending WM_QUERYENDSESSION messages as soon as one application returns zero. - /// After processing this message, the system sends the WM_ENDSESSION message with the wParam parameter set to the results of the WM_QUERYENDSESSION message. - /// - QUERYENDSESSION = 0x0011, - /// - /// The WM_QUERYOPEN message is sent to an icon when the user requests that the window be restored to its previous size and position. - /// - QUERYOPEN = 0x0013, - /// - /// The WM_ENDSESSION message is sent to an application after the system processes the results of the WM_QUERYENDSESSION message. The WM_ENDSESSION message informs the application whether the session is ending. - /// - ENDSESSION = 0x0016, - /// - /// The WM_QUIT message indicates a request to terminate an application and is generated when the application calls the PostQuitMessage function. It causes the GetMessage function to return zero. - /// - QUIT = 0x0012, - /// - /// The WM_ERASEBKGND message is sent when the window background must be erased (for example, when a window is resized). The message is sent to prepare an invalidated portion of a window for painting. - /// - ERASEBKGND = 0x0014, - /// - /// This message is sent to all top-level windows when a change is made to a system color setting. - /// - SYSCOLORCHANGE = 0x0015, - /// - /// The WM_SHOWWINDOW message is sent to a window when the window is about to be hidden or shown. - /// - SHOWWINDOW = 0x0018, - /// - /// An application sends the WM_WININICHANGE message to all top-level windows after making a change to the WIN.INI file. The SystemParametersInfo function sends this message after an application uses the function to change a setting in WIN.INI. - /// Note The WM_WININICHANGE message is provided only for compatibility with earlier versions of the system. Applications should use the WM_SETTINGCHANGE message. - /// - WININICHANGE = 0x001A, - /// - /// An application sends the WM_WININICHANGE message to all top-level windows after making a change to the WIN.INI file. The SystemParametersInfo function sends this message after an application uses the function to change a setting in WIN.INI. - /// Note The WM_WININICHANGE message is provided only for compatibility with earlier versions of the system. Applications should use the WM_SETTINGCHANGE message. - /// - SETTINGCHANGE = WININICHANGE, - /// - /// The WM_DEVMODECHANGE message is sent to all top-level windows whenever the user changes device-mode settings. - /// - DEVMODECHANGE = 0x001B, - /// - /// The WM_ACTIVATEAPP message is sent when a window belonging to a different application than the active window is about to be activated. The message is sent to the application whose window is being activated and to the application whose window is being deactivated. - /// - ACTIVATEAPP = 0x001C, - /// - /// An application sends the WM_FONTCHANGE message to all top-level windows in the system after changing the pool of font resources. - /// - FONTCHANGE = 0x001D, - /// - /// A message that is sent whenever there is a change in the system time. - /// - TIMECHANGE = 0x001E, - /// - /// The WM_CANCELMODE message is sent to cancel certain modes, such as mouse capture. For example, the system sends this message to the active window when a dialog box or message box is displayed. Certain functions also send this message explicitly to the specified window regardless of whether it is the active window. For example, the EnableWindow function sends this message when disabling the specified window. - /// - CANCELMODE = 0x001F, - /// - /// The WM_SETCURSOR message is sent to a window if the mouse causes the cursor to move within a window and mouse input is not captured. - /// - SETCURSOR = 0x0020, - /// - /// The WM_MOUSEACTIVATE message is sent when the cursor is in an inactive window and the user presses a mouse button. The parent window receives this message only if the child window passes it to the DefWindowProc function. - /// - MOUSEACTIVATE = 0x0021, - /// - /// The WM_CHILDACTIVATE message is sent to a child window when the user clicks the window's title bar or when the window is activated, moved, or sized. - /// - CHILDACTIVATE = 0x0022, - /// - /// The WM_QUEUESYNC message is sent by a computer-based training (CBT) application to separate user-input messages from other messages sent through the WH_JOURNALPLAYBACK Hook procedure. - /// - QUEUESYNC = 0x0023, - /// - /// The WM_GETMINMAXINFO message is sent to a window when the size or position of the window is about to change. An application can use this message to override the window's default maximized size and position, or its default minimum or maximum tracking size. - /// - GETMINMAXINFO = 0x0024, - /// - /// Windows NT 3.51 and earlier: The WM_PAINTICON message is sent to a minimized window when the icon is to be painted. This message is not sent by newer versions of Microsoft Windows, except in unusual circumstances explained in the Remarks. - /// - PAINTICON = 0x0026, - /// - /// Windows NT 3.51 and earlier: The WM_ICONERASEBKGND message is sent to a minimized window when the background of the icon must be filled before painting the icon. A window receives this message only if a class icon is defined for the window; otherwise, WM_ERASEBKGND is sent. This message is not sent by newer versions of Windows. - /// - ICONERASEBKGND = 0x0027, - /// - /// The WM_NEXTDLGCTL message is sent to a dialog box procedure to set the keyboard focus to a different control in the dialog box. - /// - NEXTDLGCTL = 0x0028, - /// - /// The WM_SPOOLERSTATUS message is sent from Print Manager whenever a job is added to or removed from the Print Manager queue. - /// - SPOOLERSTATUS = 0x002A, - /// - /// The WM_DRAWITEM message is sent to the parent window of an owner-drawn button, combo box, list box, or menu when a visual aspect of the button, combo box, list box, or menu has changed. - /// - DRAWITEM = 0x002B, - /// - /// The WM_MEASUREITEM message is sent to the owner window of a combo box, list box, list view control, or menu item when the control or menu is created. - /// - MEASUREITEM = 0x002C, - /// - /// Sent to the owner of a list box or combo box when the list box or combo box is destroyed or when items are removed by the LB_DELETESTRING, LB_RESETCONTENT, CB_DELETESTRING, or CB_RESETCONTENT message. The system sends a WM_DELETEITEM message for each deleted item. The system sends the WM_DELETEITEM message for any deleted list box or combo box item with nonzero item data. - /// - DELETEITEM = 0x002D, - /// - /// Sent by a list box with the LBS_WANTKEYBOARDINPUT style to its owner in response to a WM_KEYDOWN message. - /// - VKEYTOITEM = 0x002E, - /// - /// Sent by a list box with the LBS_WANTKEYBOARDINPUT style to its owner in response to a WM_CHAR message. - /// - CHARTOITEM = 0x002F, - /// - /// An application sends a WM_SETFONT message to specify the font that a control is to use when drawing text. - /// - SETFONT = 0x0030, - /// - /// An application sends a WM_GETFONT message to a control to retrieve the font with which the control is currently drawing its text. - /// - GETFONT = 0x0031, - /// - /// An application sends a WM_SETHOTKEY message to a window to associate a hot key with the window. When the user presses the hot key, the system activates the window. - /// - SETHOTKEY = 0x0032, - /// - /// An application sends a WM_GETHOTKEY message to determine the hot key associated with a window. - /// - GETHOTKEY = 0x0033, - /// - /// The WM_QUERYDRAGICON message is sent to a minimized (iconic) window. The window is about to be dragged by the user but does not have an icon defined for its class. An application can return a handle to an icon or cursor. The system displays this cursor or icon while the user drags the icon. - /// - QUERYDRAGICON = 0x0037, - /// - /// The system sends the WM_COMPAREITEM message to determine the relative position of a new item in the sorted list of an owner-drawn combo box or list box. Whenever the application adds a new item, the system sends this message to the owner of a combo box or list box created with the CBS_SORT or LBS_SORT style. - /// - COMPAREITEM = 0x0039, - /// - /// Active Accessibility sends the WM_GETOBJECT message to obtain information about an accessible object contained in a server application. - /// Applications never send this message directly. It is sent only by Active Accessibility in response to calls to AccessibleObjectFromPoint, AccessibleObjectFromEvent, or AccessibleObjectFromWindow. However, server applications handle this message. - /// - GETOBJECT = 0x003D, - /// - /// The WM_COMPACTING message is sent to all top-level windows when the system detects more than 12.5 percent of system time over a 30- to 60-second interval is being spent compacting memory. This indicates that system memory is low. - /// - COMPACTING = 0x0041, - /// - /// WM_COMMNOTIFY is Obsolete for Win32-Based Applications - /// - [Obsolete] - COMMNOTIFY = 0x0044, - /// - /// The WM_WINDOWPOSCHANGING message is sent to a window whose size, position, or place in the Z order is about to change as a result of a call to the SetWindowPos function or another window-management function. - /// - WINDOWPOSCHANGING = 0x0046, - /// - /// The WM_WINDOWPOSCHANGED message is sent to a window whose size, position, or place in the Z order has changed as a result of a call to the SetWindowPos function or another window-management function. - /// - WINDOWPOSCHANGED = 0x0047, - /// - /// Notifies applications that the system, typically a battery-powered personal computer, is about to enter a suspended mode. - /// Use: POWERBROADCAST - /// - [Obsolete] - POWER = 0x0048, - /// - /// An application sends the WM_COPYDATA message to pass data to another application. - /// - COPYDATA = 0x004A, - /// - /// The WM_CANCELJOURNAL message is posted to an application when a user cancels the application's journaling activities. The message is posted with a NULL window handle. - /// - CANCELJOURNAL = 0x004B, - /// - /// Sent by a common control to its parent window when an event has occurred or the control requires some information. - /// - NOTIFY = 0x004E, - /// - /// The WM_INPUTLANGCHANGEREQUEST message is posted to the window with the focus when the user chooses a new input language, either with the hotkey (specified in the Keyboard control panel application) or from the indicator on the system taskbar. An application can accept the change by passing the message to the DefWindowProc function or reject the change (and prevent it from taking place) by returning immediately. - /// - INPUTLANGCHANGEREQUEST = 0x0050, - /// - /// The WM_INPUTLANGCHANGE message is sent to the topmost affected window after an application's input language has been changed. You should make any application-specific settings and pass the message to the DefWindowProc function, which passes the message to all first-level child windows. These child windows can pass the message to DefWindowProc to have it pass the message to their child windows, and so on. - /// - INPUTLANGCHANGE = 0x0051, - /// - /// Sent to an application that has initiated a training card with Microsoft Windows Help. The message informs the application when the user clicks an authorable button. An application initiates a training card by specifying the HELP_TCARD command in a call to the WinHelp function. - /// - TCARD = 0x0052, - /// - /// Indicates that the user pressed the F1 key. If a menu is active when F1 is pressed, WM_HELP is sent to the window associated with the menu; otherwise, WM_HELP is sent to the window that has the keyboard focus. If no window has the keyboard focus, WM_HELP is sent to the currently active window. - /// - HELP = 0x0053, - /// - /// The WM_USERCHANGED message is sent to all windows after the user has logged on or off. When the user logs on or off, the system updates the user-specific settings. The system sends this message immediately after updating the settings. - /// - USERCHANGED = 0x0054, - /// - /// Determines if a window accepts ANSI or Unicode structures in the WM_NOTIFY notification message. WM_NOTIFYFORMAT messages are sent from a common control to its parent window and from the parent window to the common control. - /// - NOTIFYFORMAT = 0x0055, - /// - /// The WM_CONTEXTMENU message notifies a window that the user clicked the right mouse button (right-clicked) in the window. - /// - CONTEXTMENU = 0x007B, - /// - /// The WM_STYLECHANGING message is sent to a window when the SetWindowLong function is about to change one or more of the window's styles. - /// - STYLECHANGING = 0x007C, - /// - /// The WM_STYLECHANGED message is sent to a window after the SetWindowLong function has changed one or more of the window's styles - /// - STYLECHANGED = 0x007D, - /// - /// The WM_DISPLAYCHANGE message is sent to all windows when the display resolution has changed. - /// - DISPLAYCHANGE = 0x007E, - /// - /// The WM_GETICON message is sent to a window to retrieve a handle to the large or small icon associated with a window. The system displays the large icon in the ALT+TAB dialog, and the small icon in the window caption. - /// - GETICON = 0x007F, - /// - /// An application sends the WM_SETICON message to associate a new large or small icon with a window. The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption. - /// - SETICON = 0x0080, - /// - /// The WM_NCCREATE message is sent prior to the WM_CREATE message when a window is first created. - /// - NCCREATE = 0x0081, - /// - /// The WM_NCDESTROY message informs a window that its nonclient area is being destroyed. The DestroyWindow function sends the WM_NCDESTROY message to the window following the WM_DESTROY message. WM_DESTROY is used to free the allocated memory object associated with the window. - /// The WM_NCDESTROY message is sent after the child windows have been destroyed. In contrast, WM_DESTROY is sent before the child windows are destroyed. - /// - NCDESTROY = 0x0082, - /// - /// The WM_NCCALCSIZE message is sent when the size and position of a window's client area must be calculated. By processing this message, an application can control the content of the window's client area when the size or position of the window changes. - /// - NCCALCSIZE = 0x0083, - /// - /// The WM_NCHITTEST message is sent to a window when the cursor moves, or when a mouse button is pressed or released. If the mouse is not captured, the message is sent to the window beneath the cursor. Otherwise, the message is sent to the window that has captured the mouse. - /// - NCHITTEST = 0x0084, - /// - /// The WM_NCPAINT message is sent to a window when its frame must be painted. - /// - NCPAINT = 0x0085, - /// - /// The WM_NCACTIVATE message is sent to a window when its nonclient area needs to be changed to indicate an active or inactive state. - /// - NCACTIVATE = 0x0086, - /// - /// The WM_GETDLGCODE message is sent to the window procedure associated with a control. By default, the system handles all keyboard input to the control; the system interprets certain types of keyboard input as dialog box navigation keys. To override this default behavior, the control can respond to the WM_GETDLGCODE message to indicate the types of input it wants to process itself. - /// - GETDLGCODE = 0x0087, - /// - /// The WM_SYNCPAINT message is used to synchronize painting while avoiding linking independent GUI threads. - /// - SYNCPAINT = 0x0088, - /// - /// The WM_NCMOUSEMOVE message is posted to a window when the cursor is moved within the nonclient area of the window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCMOUSEMOVE = 0x00A0, - /// - /// The WM_NCLBUTTONDOWN message is posted when the user presses the left mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCLBUTTONDOWN = 0x00A1, - /// - /// The WM_NCLBUTTONUP message is posted when the user releases the left mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCLBUTTONUP = 0x00A2, - /// - /// The WM_NCLBUTTONDBLCLK message is posted when the user double-clicks the left mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCLBUTTONDBLCLK = 0x00A3, - /// - /// The WM_NCRBUTTONDOWN message is posted when the user presses the right mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCRBUTTONDOWN = 0x00A4, - /// - /// The WM_NCRBUTTONUP message is posted when the user releases the right mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCRBUTTONUP = 0x00A5, - /// - /// The WM_NCRBUTTONDBLCLK message is posted when the user double-clicks the right mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCRBUTTONDBLCLK = 0x00A6, - /// - /// The WM_NCMBUTTONDOWN message is posted when the user presses the middle mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCMBUTTONDOWN = 0x00A7, - /// - /// The WM_NCMBUTTONUP message is posted when the user releases the middle mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCMBUTTONUP = 0x00A8, - /// - /// The WM_NCMBUTTONDBLCLK message is posted when the user double-clicks the middle mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCMBUTTONDBLCLK = 0x00A9, - /// - /// The WM_NCXBUTTONDOWN message is posted when the user presses the first or second X button while the cursor is in the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCXBUTTONDOWN = 0x00AB, - /// - /// The WM_NCXBUTTONUP message is posted when the user releases the first or second X button while the cursor is in the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCXBUTTONUP = 0x00AC, - /// - /// The WM_NCXBUTTONDBLCLK message is posted when the user double-clicks the first or second X button while the cursor is in the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted. - /// - NCXBUTTONDBLCLK = 0x00AD, - /// - /// The WM_INPUT_DEVICE_CHANGE message is sent to the window that registered to receive raw input. A window receives this message through its WindowProc function. - /// - INPUT_DEVICE_CHANGE = 0x00FE, - /// - /// The WM_INPUT message is sent to the window that is getting raw input. - /// - INPUT = 0x00FF, - /// - /// This message filters for keyboard messages. - /// - KEYFIRST = 0x0100, - /// - /// The WM_KEYDOWN message is posted to the window with the keyboard focus when a nonsystem key is pressed. A nonsystem key is a key that is pressed when the ALT key is not pressed. - /// - KEYDOWN = 0x0100, - /// - /// The WM_KEYUP message is posted to the window with the keyboard focus when a nonsystem key is released. A nonsystem key is a key that is pressed when the ALT key is not pressed, or a keyboard key that is pressed when a window has the keyboard focus. - /// - KEYUP = 0x0101, - /// - /// The WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. The WM_CHAR message contains the character code of the key that was pressed. - /// - CHAR = 0x0102, - /// - /// The WM_DEADCHAR message is posted to the window with the keyboard focus when a WM_KEYUP message is translated by the TranslateMessage function. WM_DEADCHAR specifies a character code generated by a dead key. A dead key is a key that generates a character, such as the umlaut (double-dot), that is combined with another character to form a composite character. For example, the umlaut-O character (Ö) is generated by typing the dead key for the umlaut character, and then typing the O key. - /// - DEADCHAR = 0x0103, - /// - /// The WM_SYSKEYDOWN message is posted to the window with the keyboard focus when the user presses the F10 key (which activates the menu bar) or holds down the ALT key and then presses another key. It also occurs when no window currently has the keyboard focus; in this case, the WM_SYSKEYDOWN message is sent to the active window. The window that receives the message can distinguish between these two contexts by checking the context code in the lParam parameter. - /// - SYSKEYDOWN = 0x0104, - /// - /// The WM_SYSKEYUP message is posted to the window with the keyboard focus when the user releases a key that was pressed while the ALT key was held down. It also occurs when no window currently has the keyboard focus; in this case, the WM_SYSKEYUP message is sent to the active window. The window that receives the message can distinguish between these two contexts by checking the context code in the lParam parameter. - /// - SYSKEYUP = 0x0105, - /// - /// The WM_SYSCHAR message is posted to the window with the keyboard focus when a WM_SYSKEYDOWN message is translated by the TranslateMessage function. It specifies the character code of a system character key — that is, a character key that is pressed while the ALT key is down. - /// - SYSCHAR = 0x0106, - /// - /// The WM_SYSDEADCHAR message is sent to the window with the keyboard focus when a WM_SYSKEYDOWN message is translated by the TranslateMessage function. WM_SYSDEADCHAR specifies the character code of a system dead key — that is, a dead key that is pressed while holding down the ALT key. - /// - SYSDEADCHAR = 0x0107, - /// - /// The WM_UNICHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. The WM_UNICHAR message contains the character code of the key that was pressed. - /// The WM_UNICHAR message is equivalent to WM_CHAR, but it uses Unicode Transformation Format (UTF)-32, whereas WM_CHAR uses UTF-16. It is designed to send or post Unicode characters to ANSI windows and it can can handle Unicode Supplementary Plane characters. - /// - UNICHAR = 0x0109, - /// - /// This message filters for keyboard messages. - /// - KEYLAST = 0x0108, - /// - /// Sent immediately before the IME generates the composition string as a result of a keystroke. A window receives this message through its WindowProc function. - /// - IME_STARTCOMPOSITION = 0x010D, - /// - /// Sent to an application when the IME ends composition. A window receives this message through its WindowProc function. - /// - IME_ENDCOMPOSITION = 0x010E, - /// - /// Sent to an application when the IME changes composition status as a result of a keystroke. A window receives this message through its WindowProc function. - /// - IME_COMPOSITION = 0x010F, - IME_KEYLAST = 0x010F, - /// - /// The WM_INITDIALOG message is sent to the dialog box procedure immediately before a dialog box is displayed. Dialog box procedures typically use this message to initialize controls and carry out any other initialization tasks that affect the appearance of the dialog box. - /// - INITDIALOG = 0x0110, - /// - /// The WM_COMMAND message is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated. - /// - COMMAND = 0x0111, - /// - /// A window receives this message when the user chooses a command from the Window menu, clicks the maximize button, minimize button, restore button, close button, or moves the form. You can stop the form from moving by filtering this out. - /// - SYSCOMMAND = 0x0112, - /// - /// The WM_TIMER message is posted to the installing thread's message queue when a timer expires. The message is posted by the GetMessage or PeekMessage function. - /// - TIMER = 0x0113, - /// - /// The WM_HSCROLL message is sent to a window when a scroll event occurs in the window's standard horizontal scroll bar. This message is also sent to the owner of a horizontal scroll bar control when a scroll event occurs in the control. - /// - HSCROLL = 0x0114, - /// - /// The WM_VSCROLL message is sent to a window when a scroll event occurs in the window's standard vertical scroll bar. This message is also sent to the owner of a vertical scroll bar control when a scroll event occurs in the control. - /// - VSCROLL = 0x0115, - /// - /// The WM_INITMENU message is sent when a menu is about to become active. It occurs when the user clicks an item on the menu bar or presses a menu key. This allows the application to modify the menu before it is displayed. - /// - INITMENU = 0x0116, - /// - /// The WM_INITMENUPOPUP message is sent when a drop-down menu or submenu is about to become active. This allows an application to modify the menu before it is displayed, without changing the entire menu. - /// - INITMENUPOPUP = 0x0117, - /// - /// The WM_MENUSELECT message is sent to a menu's owner window when the user selects a menu item. - /// - MENUSELECT = 0x011F, - /// - /// The WM_MENUCHAR message is sent when a menu is active and the user presses a key that does not correspond to any mnemonic or accelerator key. This message is sent to the window that owns the menu. - /// - MENUCHAR = 0x0120, - /// - /// The WM_ENTERIDLE message is sent to the owner window of a modal dialog box or menu that is entering an idle state. A modal dialog box or menu enters an idle state when no messages are waiting in its queue after it has processed one or more previous messages. - /// - ENTERIDLE = 0x0121, - /// - /// The WM_MENURBUTTONUP message is sent when the user releases the right mouse button while the cursor is on a menu item. - /// - MENURBUTTONUP = 0x0122, - /// - /// The WM_MENUDRAG message is sent to the owner of a drag-and-drop menu when the user drags a menu item. - /// - MENUDRAG = 0x0123, - /// - /// The WM_MENUGETOBJECT message is sent to the owner of a drag-and-drop menu when the mouse cursor enters a menu item or moves from the center of the item to the top or bottom of the item. - /// - MENUGETOBJECT = 0x0124, - /// - /// The WM_UNINITMENUPOPUP message is sent when a drop-down menu or submenu has been destroyed. - /// - UNINITMENUPOPUP = 0x0125, - /// - /// The WM_MENUCOMMAND message is sent when the user makes a selection from a menu. - /// - MENUCOMMAND = 0x0126, - /// - /// An application sends the WM_CHANGEUISTATE message to indicate that the user interface (UI) state should be changed. - /// - CHANGEUISTATE = 0x0127, - /// - /// An application sends the WM_UPDATEUISTATE message to change the user interface (UI) state for the specified window and all its child windows. - /// - UPDATEUISTATE = 0x0128, - /// - /// An application sends the WM_QUERYUISTATE message to retrieve the user interface (UI) state for a window. - /// - QUERYUISTATE = 0x0129, - /// - /// The WM_CTLCOLORMSGBOX message is sent to the owner window of a message box before Windows draws the message box. By responding to this message, the owner window can set the text and background colors of the message box by using the given display device context handle. - /// - CTLCOLORMSGBOX = 0x0132, - /// - /// An edit control that is not read-only or disabled sends the WM_CTLCOLOREDIT message to its parent window when the control is about to be drawn. By responding to this message, the parent window can use the specified device context handle to set the text and background colors of the edit control. - /// - CTLCOLOREDIT = 0x0133, - /// - /// Sent to the parent window of a list box before the system draws the list box. By responding to this message, the parent window can set the text and background colors of the list box by using the specified display device context handle. - /// - CTLCOLORLISTBOX = 0x0134, - /// - /// The WM_CTLCOLORBTN message is sent to the parent window of a button before drawing the button. The parent window can change the button's text and background colors. However, only owner-drawn buttons respond to the parent window processing this message. - /// - CTLCOLORBTN = 0x0135, - /// - /// The WM_CTLCOLORDLG message is sent to a dialog box before the system draws the dialog box. By responding to this message, the dialog box can set its text and background colors using the specified display device context handle. - /// - CTLCOLORDLG = 0x0136, - /// - /// The WM_CTLCOLORSCROLLBAR message is sent to the parent window of a scroll bar control when the control is about to be drawn. By responding to this message, the parent window can use the display context handle to set the background color of the scroll bar control. - /// - CTLCOLORSCROLLBAR = 0x0137, - /// - /// A static control, or an edit control that is read-only or disabled, sends the WM_CTLCOLORSTATIC message to its parent window when the control is about to be drawn. By responding to this message, the parent window can use the specified device context handle to set the text and background colors of the static control. - /// - CTLCOLORSTATIC = 0x0138, - /// - /// Use WM_MOUSEFIRST to specify the first mouse message. Use the PeekMessage() Function. - /// - MOUSEFIRST = 0x0200, - /// - /// The WM_MOUSEMOVE message is posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - MOUSEMOVE = 0x0200, - /// - /// The WM_LBUTTONDOWN message is posted when the user presses the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - LBUTTONDOWN = 0x0201, - /// - /// The WM_LBUTTONUP message is posted when the user releases the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - LBUTTONUP = 0x0202, - /// - /// The WM_LBUTTONDBLCLK message is posted when the user double-clicks the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - LBUTTONDBLCLK = 0x0203, - /// - /// The WM_RBUTTONDOWN message is posted when the user presses the right mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - RBUTTONDOWN = 0x0204, - /// - /// The WM_RBUTTONUP message is posted when the user releases the right mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - RBUTTONUP = 0x0205, - /// - /// The WM_RBUTTONDBLCLK message is posted when the user double-clicks the right mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - RBUTTONDBLCLK = 0x0206, - /// - /// The WM_MBUTTONDOWN message is posted when the user presses the middle mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - MBUTTONDOWN = 0x0207, - /// - /// The WM_MBUTTONUP message is posted when the user releases the middle mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - MBUTTONUP = 0x0208, - /// - /// The WM_MBUTTONDBLCLK message is posted when the user double-clicks the middle mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - MBUTTONDBLCLK = 0x0209, - /// - /// The WM_MOUSEWHEEL message is sent to the focus window when the mouse wheel is rotated. The DefWindowProc function propagates the message to the window's parent. There should be no internal forwarding of the message, since DefWindowProc propagates it up the parent chain until it finds a window that processes it. - /// - MOUSEWHEEL = 0x020A, - /// - /// The WM_XBUTTONDOWN message is posted when the user presses the first or second X button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - XBUTTONDOWN = 0x020B, - /// - /// The WM_XBUTTONUP message is posted when the user releases the first or second X button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - XBUTTONUP = 0x020C, - /// - /// The WM_XBUTTONDBLCLK message is posted when the user double-clicks the first or second X button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. - /// - XBUTTONDBLCLK = 0x020D, - /// - /// The WM_MOUSEHWHEEL message is sent to the focus window when the mouse's horizontal scroll wheel is tilted or rotated. The DefWindowProc function propagates the message to the window's parent. There should be no internal forwarding of the message, since DefWindowProc propagates it up the parent chain until it finds a window that processes it. - /// - MOUSEHWHEEL = 0x020E, - /// - /// Use WM_MOUSELAST to specify the last mouse message. Used with PeekMessage() Function. - /// - MOUSELAST = 0x020E, - /// - /// The WM_PARENTNOTIFY message is sent to the parent of a child window when the child window is created or destroyed, or when the user clicks a mouse button while the cursor is over the child window. When the child window is being created, the system sends WM_PARENTNOTIFY just before the CreateWindow or CreateWindowEx function that creates the window returns. When the child window is being destroyed, the system sends the message before any processing to destroy the window takes place. - /// - PARENTNOTIFY = 0x0210, - /// - /// The WM_ENTERMENULOOP message informs an application's main window procedure that a menu modal loop has been entered. - /// - ENTERMENULOOP = 0x0211, - /// - /// The WM_EXITMENULOOP message informs an application's main window procedure that a menu modal loop has been exited. - /// - EXITMENULOOP = 0x0212, - /// - /// The WM_NEXTMENU message is sent to an application when the right or left arrow key is used to switch between the menu bar and the system menu. - /// - NEXTMENU = 0x0213, - /// - /// The WM_SIZING message is sent to a window that the user is resizing. By processing this message, an application can monitor the size and position of the drag rectangle and, if needed, change its size or position. - /// - SIZING = 0x0214, - /// - /// The WM_CAPTURECHANGED message is sent to the window that is losing the mouse capture. - /// - CAPTURECHANGED = 0x0215, - /// - /// The WM_MOVING message is sent to a window that the user is moving. By processing this message, an application can monitor the position of the drag rectangle and, if needed, change its position. - /// - MOVING = 0x0216, - /// - /// Notifies applications that a power-management event has occurred. - /// - POWERBROADCAST = 0x0218, - /// - /// Notifies an application of a change to the hardware configuration of a device or the computer. - /// - DEVICECHANGE = 0x0219, - /// - /// An application sends the WM_MDICREATE message to a multiple-document interface (MDI) client window to create an MDI child window. - /// - MDICREATE = 0x0220, - /// - /// An application sends the WM_MDIDESTROY message to a multiple-document interface (MDI) client window to close an MDI child window. - /// - MDIDESTROY = 0x0221, - /// - /// An application sends the WM_MDIACTIVATE message to a multiple-document interface (MDI) client window to instruct the client window to activate a different MDI child window. - /// - MDIACTIVATE = 0x0222, - /// - /// An application sends the WM_MDIRESTORE message to a multiple-document interface (MDI) client window to restore an MDI child window from maximized or minimized size. - /// - MDIRESTORE = 0x0223, - /// - /// An application sends the WM_MDINEXT message to a multiple-document interface (MDI) client window to activate the next or previous child window. - /// - MDINEXT = 0x0224, - /// - /// An application sends the WM_MDIMAXIMIZE message to a multiple-document interface (MDI) client window to maximize an MDI child window. The system resizes the child window to make its client area fill the client window. The system places the child window's window menu icon in the rightmost position of the frame window's menu bar, and places the child window's restore icon in the leftmost position. The system also appends the title bar text of the child window to that of the frame window. - /// - MDIMAXIMIZE = 0x0225, - /// - /// An application sends the WM_MDITILE message to a multiple-document interface (MDI) client window to arrange all of its MDI child windows in a tile format. - /// - MDITILE = 0x0226, - /// - /// An application sends the WM_MDICASCADE message to a multiple-document interface (MDI) client window to arrange all its child windows in a cascade format. - /// - MDICASCADE = 0x0227, - /// - /// An application sends the WM_MDIICONARRANGE message to a multiple-document interface (MDI) client window to arrange all minimized MDI child windows. It does not affect child windows that are not minimized. - /// - MDIICONARRANGE = 0x0228, - /// - /// An application sends the WM_MDIGETACTIVE message to a multiple-document interface (MDI) client window to retrieve the handle to the active MDI child window. - /// - MDIGETACTIVE = 0x0229, - /// - /// An application sends the WM_MDISETMENU message to a multiple-document interface (MDI) client window to replace the entire menu of an MDI frame window, to replace the window menu of the frame window, or both. - /// - MDISETMENU = 0x0230, - /// - /// The WM_ENTERSIZEMOVE message is sent one time to a window after it enters the moving or sizing modal loop. The window enters the moving or sizing modal loop when the user clicks the window's title bar or sizing border, or when the window passes the WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the message specifies the SC_MOVE or SC_SIZE value. The operation is complete when DefWindowProc returns. - /// The system sends the WM_ENTERSIZEMOVE message regardless of whether the dragging of full windows is enabled. - /// - ENTERSIZEMOVE = 0x0231, - /// - /// The WM_EXITSIZEMOVE message is sent one time to a window, after it has exited the moving or sizing modal loop. The window enters the moving or sizing modal loop when the user clicks the window's title bar or sizing border, or when the window passes the WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the message specifies the SC_MOVE or SC_SIZE value. The operation is complete when DefWindowProc returns. - /// - EXITSIZEMOVE = 0x0232, - /// - /// Sent when the user drops a file on the window of an application that has registered itself as a recipient of dropped files. - /// - DROPFILES = 0x0233, - /// - /// An application sends the WM_MDIREFRESHMENU message to a multiple-document interface (MDI) client window to refresh the window menu of the MDI frame window. - /// - MDIREFRESHMENU = 0x0234, - /// - /// Sent to an application when a window is activated. A window receives this message through its WindowProc function. - /// - IME_SETCONTEXT = 0x0281, - /// - /// Sent to an application to notify it of changes to the IME window. A window receives this message through its WindowProc function. - /// - IME_NOTIFY = 0x0282, - /// - /// Sent by an application to direct the IME window to carry out the requested command. The application uses this message to control the IME window that it has created. To send this message, the application calls the SendMessage function with the following parameters. - /// - IME_CONTROL = 0x0283, - /// - /// Sent to an application when the IME window finds no space to extend the area for the composition window. A window receives this message through its WindowProc function. - /// - IME_COMPOSITIONFULL = 0x0284, - /// - /// Sent to an application when the operating system is about to change the current IME. A window receives this message through its WindowProc function. - /// - IME_SELECT = 0x0285, - /// - /// Sent to an application when the IME gets a character of the conversion result. A window receives this message through its WindowProc function. - /// - IME_CHAR = 0x0286, - /// - /// Sent to an application to provide commands and request information. A window receives this message through its WindowProc function. - /// - IME_REQUEST = 0x0288, - /// - /// Sent to an application by the IME to notify the application of a key press and to keep message order. A window receives this message through its WindowProc function. - /// - IME_KEYDOWN = 0x0290, - /// - /// Sent to an application by the IME to notify the application of a key release and to keep message order. A window receives this message through its WindowProc function. - /// - IME_KEYUP = 0x0291, - /// - /// The WM_MOUSEHOVER message is posted to a window when the cursor hovers over the client area of the window for the period of time specified in a prior call to TrackMouseEvent. - /// - MOUSEHOVER = 0x02A1, - /// - /// The WM_MOUSELEAVE message is posted to a window when the cursor leaves the client area of the window specified in a prior call to TrackMouseEvent. - /// - MOUSELEAVE = 0x02A3, - /// - /// The WM_NCMOUSEHOVER message is posted to a window when the cursor hovers over the nonclient area of the window for the period of time specified in a prior call to TrackMouseEvent. - /// - NCMOUSEHOVER = 0x02A0, - /// - /// The WM_NCMOUSELEAVE message is posted to a window when the cursor leaves the nonclient area of the window specified in a prior call to TrackMouseEvent. - /// - NCMOUSELEAVE = 0x02A2, - /// - /// The WM_WTSSESSION_CHANGE message notifies applications of changes in session state. - /// - WTSSESSION_CHANGE = 0x02B1, - TABLET_FIRST = 0x02c0, - TABLET_LAST = 0x02df, - /// - /// An application sends a WM_CUT message to an edit control or combo box to delete (cut) the current selection, if any, in the edit control and copy the deleted text to the clipboard in CF_TEXT format. - /// - CUT = 0x0300, - /// - /// An application sends the WM_COPY message to an edit control or combo box to copy the current selection to the clipboard in CF_TEXT format. - /// - COPY = 0x0301, - /// - /// An application sends a WM_PASTE message to an edit control or combo box to copy the current content of the clipboard to the edit control at the current caret position. Data is inserted only if the clipboard contains data in CF_TEXT format. - /// - PASTE = 0x0302, - /// - /// An application sends a WM_CLEAR message to an edit control or combo box to delete (clear) the current selection, if any, from the edit control. - /// - CLEAR = 0x0303, - /// - /// An application sends a WM_UNDO message to an edit control to undo the last operation. When this message is sent to an edit control, the previously deleted text is restored or the previously added text is deleted. - /// - UNDO = 0x0304, - /// - /// The WM_RENDERFORMAT message is sent to the clipboard owner if it has delayed rendering a specific clipboard format and if an application has requested data in that format. The clipboard owner must render data in the specified format and place it on the clipboard by calling the SetClipboardData function. - /// - RENDERFORMAT = 0x0305, - /// - /// The WM_RENDERALLFORMATS message is sent to the clipboard owner before it is destroyed, if the clipboard owner has delayed rendering one or more clipboard formats. For the content of the clipboard to remain available to other applications, the clipboard owner must render data in all the formats it is capable of generating, and place the data on the clipboard by calling the SetClipboardData function. - /// - RENDERALLFORMATS = 0x0306, - /// - /// The WM_DESTROYCLIPBOARD message is sent to the clipboard owner when a call to the EmptyClipboard function empties the clipboard. - /// - DESTROYCLIPBOARD = 0x0307, - /// - /// The WM_DRAWCLIPBOARD message is sent to the first window in the clipboard viewer chain when the content of the clipboard changes. This enables a clipboard viewer window to display the new content of the clipboard. - /// - DRAWCLIPBOARD = 0x0308, - /// - /// The WM_PAINTCLIPBOARD message is sent to the clipboard owner by a clipboard viewer window when the clipboard contains data in the CF_OWNERDISPLAY format and the clipboard viewer's client area needs repainting. - /// - PAINTCLIPBOARD = 0x0309, - /// - /// The WM_VSCROLLCLIPBOARD message is sent to the clipboard owner by a clipboard viewer window when the clipboard contains data in the CF_OWNERDISPLAY format and an event occurs in the clipboard viewer's vertical scroll bar. The owner should scroll the clipboard image and update the scroll bar values. - /// - VSCROLLCLIPBOARD = 0x030A, - /// - /// The WM_SIZECLIPBOARD message is sent to the clipboard owner by a clipboard viewer window when the clipboard contains data in the CF_OWNERDISPLAY format and the clipboard viewer's client area has changed size. - /// - SIZECLIPBOARD = 0x030B, - /// - /// The WM_ASKCBFORMATNAME message is sent to the clipboard owner by a clipboard viewer window to request the name of a CF_OWNERDISPLAY clipboard format. - /// - ASKCBFORMATNAME = 0x030C, - /// - /// The WM_CHANGECBCHAIN message is sent to the first window in the clipboard viewer chain when a window is being removed from the chain. - /// - CHANGECBCHAIN = 0x030D, - /// - /// The WM_HSCROLLCLIPBOARD message is sent to the clipboard owner by a clipboard viewer window. This occurs when the clipboard contains data in the CF_OWNERDISPLAY format and an event occurs in the clipboard viewer's horizontal scroll bar. The owner should scroll the clipboard image and update the scroll bar values. - /// - HSCROLLCLIPBOARD = 0x030E, - /// - /// This message informs a window that it is about to receive the keyboard focus, giving the window the opportunity to realize its logical palette when it receives the focus. - /// - QUERYNEWPALETTE = 0x030F, - /// - /// The WM_PALETTEISCHANGING message informs applications that an application is going to realize its logical palette. - /// - PALETTEISCHANGING = 0x0310, - /// - /// This message is sent by the OS to all top-level and overlapped windows after the window with the keyboard focus realizes its logical palette. - /// This message enables windows that do not have the keyboard focus to realize their logical palettes and update their client areas. - /// - PALETTECHANGED = 0x0311, - /// - /// The WM_HOTKEY message is posted when the user presses a hot key registered by the RegisterHotKey function. The message is placed at the top of the message queue associated with the thread that registered the hot key. - /// - HOTKEY = 0x0312, - /// - /// The WM_PRINT message is sent to a window to request that it draw itself in the specified device context, most commonly in a printer device context. - /// - PRINT = 0x0317, - /// - /// The WM_PRINTCLIENT message is sent to a window to request that it draw its client area in the specified device context, most commonly in a printer device context. - /// - PRINTCLIENT = 0x0318, - /// - /// The WM_APPCOMMAND message notifies a window that the user generated an application command event, for example, by clicking an application command button using the mouse or typing an application command key on the keyboard. - /// - APPCOMMAND = 0x0319, - /// - /// The WM_THEMECHANGED message is broadcast to every window following a theme change event. Examples of theme change events are the activation of a theme, the deactivation of a theme, or a transition from one theme to another. - /// - THEMECHANGED = 0x031A, - /// - /// Sent when the contents of the clipboard have changed. - /// - CLIPBOARDUPDATE = 0x031D, - /// - /// The system will send a window the WM_DWMCOMPOSITIONCHANGED message to indicate that the availability of desktop composition has changed. - /// - DWMCOMPOSITIONCHANGED = 0x031E, - /// - /// WM_DWMNCRENDERINGCHANGED is called when the non-client area rendering status of a window has changed. Only windows that have set the flag DWM_BLURBEHIND.fTransitionOnMaximized to true will get this message. - /// - DWMNCRENDERINGCHANGED = 0x031F, - /// - /// Sent to all top-level windows when the colorization color has changed. - /// - DWMCOLORIZATIONCOLORCHANGED = 0x0320, - /// - /// WM_DWMWINDOWMAXIMIZEDCHANGE will let you know when a DWM composed window is maximized. You also have to register for this message as well. You'd have other windowd go opaque when this message is sent. - /// - DWMWINDOWMAXIMIZEDCHANGE = 0x0321, - /// - /// Sent to request extended title bar information. A window receives this message through its WindowProc function. - /// - GETTITLEBARINFOEX = 0x033F, - HANDHELDFIRST = 0x0358, - HANDHELDLAST = 0x035F, - AFXFIRST = 0x0360, - AFXLAST = 0x037F, - PENWINFIRST = 0x0380, - PENWINLAST = 0x038F, - /// - /// The WM_APP constant is used by applications to help define private messages, usually of the form WM_APP+X, where X is an integer value. - /// - APP = 0x8000, - /// - /// The WM_USER constant is used by applications to help define private messages for use by private window classes, usually of the form WM_USER+X, where X is an integer value. - /// - USER = 0x0400, - - /// - /// An application sends the WM_CPL_LAUNCH message to Windows Control Panel to request that a Control Panel application be started. - /// - CPL_LAUNCH = USER + 0x1000, - /// - /// The WM_CPL_LAUNCHED message is sent when a Control Panel application, started by the WM_CPL_LAUNCH message, has closed. The WM_CPL_LAUNCHED message is sent to the window identified by the wParam parameter of the WM_CPL_LAUNCH message that started the application. - /// - CPL_LAUNCHED = USER + 0x1001, - /// - /// WM_SYSTIMER is a well-known yet still undocumented message. Windows uses WM_SYSTIMER for internal actions like scrolling. - /// - SYSTIMER = 0x118, - - /// - /// The accessibility state has changed. - /// - HSHELL_ACCESSIBILITYSTATE = 11, - /// - /// The shell should activate its main window. - /// - HSHELL_ACTIVATESHELLWINDOW = 3, - /// - /// The user completed an input event (for example, pressed an application command button on the mouse or an application command key on the keyboard), and the application did not handle the WM_APPCOMMAND message generated by that input. - /// If the Shell procedure handles the WM_COMMAND message, it should not call CallNextHookEx. See the Return Value section for more information. - /// - HSHELL_APPCOMMAND = 12, - /// - /// A window is being minimized or maximized. The system needs the coordinates of the minimized rectangle for the window. - /// - HSHELL_GETMINRECT = 5, - /// - /// Keyboard language was changed or a new keyboard layout was loaded. - /// - HSHELL_LANGUAGE = 8, - /// - /// The title of a window in the task bar has been redrawn. - /// - HSHELL_REDRAW = 6, - /// - /// The user has selected the task list. A shell application that provides a task list should return TRUE to prevent Windows from starting its task list. - /// - HSHELL_TASKMAN = 7, - /// - /// A top-level, unowned window has been created. The window exists when the system calls this hook. - /// - HSHELL_WINDOWCREATED = 1, - /// - /// A top-level, unowned window is about to be destroyed. The window still exists when the system calls this hook. - /// - HSHELL_WINDOWDESTROYED = 2, - /// - /// The activation has changed to a different top-level, unowned window. - /// - HSHELL_WINDOWACTIVATED = 4, - /// - /// A top-level window is being replaced. The window exists when the system calls this hook. - /// - HSHELL_WINDOWREPLACED = 13 - } -} diff --git a/Dependencies/MelonStartScreen/mgGif/Decoder.cs b/Dependencies/MelonStartScreen/mgGif/Decoder.cs deleted file mode 100644 index a9b34d624..000000000 --- a/Dependencies/MelonStartScreen/mgGif/Decoder.cs +++ /dev/null @@ -1,628 +0,0 @@ -using System; -using System.Text; -using MelonUnityEngine; -using MelonLoader; - -namespace mgGif -{ - internal class Decoder : IDisposable - { - public string Version; - public ushort Width; - public ushort Height; - public Color32 BackgroundColour; - - //------------------------------------------------------------------------------ - // GIF format enums - - private enum ImageFlag - { - Interlaced = 0x40, - ColourTable = 0x80, - TableSizeMask = 0x07, - BitDepthMask = 0x70, - } - - private enum Block - { - Image = 0x2C, - Extension = 0x21, - End = 0x3B - } - - private enum Extension - { - GraphicControl = 0xF9, - Comments = 0xFE, - PlainText = 0x01, - ApplicationData = 0xFF - } - - private enum Disposal - { - None = 0x00, - DoNotDispose = 0x04, - RestoreBackground = 0x08, - ReturnToPrevious = 0x0C - } - - private enum ControlFlags - { - HasTransparency = 0x01, - DisposalMask = 0x0C - } - - //------------------------------------------------------------------------------ - - private const uint NoCode = 0xFFFF; - private const ushort NoTransparency = 0xFFFF; - - // input stream to decode - private byte[] Input; - - private int D; - - // colour table - private Color32[] GlobalColourTable; - - private Color32[] LocalColourTable; - private Color32[] ActiveColourTable; - private ushort TransparentIndex; - - // current image - private Image Image = new Image(); - - private ushort ImageLeft; - private ushort ImageTop; - private ushort ImageWidth; - private ushort ImageHeight; - - private Color32[] Output; - private Color32[] PreviousImage; - - private readonly int[] Pow2 = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 }; - - //------------------------------------------------------------------------------ - // ctor - - public Decoder(byte[] data) : this() - => Load(data); - - public Decoder Load(byte[] data) - { - Input = data; - D = 0; - - GlobalColourTable = new Color32[256]; - LocalColourTable = new Color32[256]; - TransparentIndex = NoTransparency; - Output = null; - PreviousImage = null; - - Image.Delay = 0; - - return this; - } - - //------------------------------------------------------------------------------ - // reading data utility functions - - private byte ReadByte() => Input[D++]; - - private ushort ReadUInt16() => (ushort)(Input[D++] | Input[D++] << 8); - - //------------------------------------------------------------------------------ - - private void ReadHeader() - { - if (Input == null || Input.Length <= 12) - throw new Exception("Invalid data"); - - // signature - - Version = Encoding.ASCII.GetString(Input, 0, 6); - D = 6; - - if (Version != "GIF87a" && Version != "GIF89a") - { - throw new Exception("Unsupported GIF version"); - } - - // read header - - Width = ReadUInt16(); - Height = ReadUInt16(); - - Image.Width = Width; - Image.Height = Height; - - var flags = (ImageFlag)ReadByte(); - var bgIndex = ReadByte(); // background colour - - ReadByte(); // aspect ratio - - if (flags.HasFlag(ImageFlag.ColourTable)) - ReadColourTable(GlobalColourTable, flags); - - BackgroundColour = GlobalColourTable[bgIndex]; - } - - //------------------------------------------------------------------------------ - - public Image NextImage() - { - // if at start of data, read header - - if (D == 0) - ReadHeader(); - - // read blocks until we find an image block - - while (true) - { - var block = (Block)ReadByte(); - - switch (block) - { - case Block.Image: - { - // return the image if we got one - - var img = ReadImageBlock(); - - if (img != null) - return img; - } - break; - - case Block.Extension: - { - var ext = (Extension)ReadByte(); - - if (ext == Extension.GraphicControl) - ReadControlBlock(); - else - SkipBlocks(); - } - break; - - case Block.End: - { - // end block - stop! - return null; - } - - default: - { - throw new Exception("Unexpected block type"); - } - } - } - } - - //------------------------------------------------------------------------------ - - private Color32[] ReadColourTable(Color32[] colourTable, ImageFlag flags) - { - var tableSize = Pow2[(int)(flags & ImageFlag.TableSizeMask) + 1]; - - for (var i = 0; i < tableSize; i++) - { - colourTable[i] = new Color32( - Input[D++], - Input[D++], - Input[D++], - 0xFF - ); - } - - return colourTable; - } - - //------------------------------------------------------------------------------ - - private void SkipBlocks() - { - var blockSize = Input[D++]; - - while (blockSize != 0x00) - { - D += blockSize; - blockSize = Input[D++]; - } - } - - //------------------------------------------------------------------------------ - - private void ReadControlBlock() - { - // read block - - ReadByte(); // block size (0x04) - var flags = (ControlFlags)ReadByte(); // flags - Image.Delay = ReadUInt16() * 10; // delay (1/100th -> milliseconds) - var transparentColour = ReadByte(); // transparent colour - ReadByte(); // terminator (0x00) - - // has transparent colour? - - if (flags.HasFlag(ControlFlags.HasTransparency)) - TransparentIndex = transparentColour; - else - TransparentIndex = NoTransparency; - - // dispose of current image - - switch ((Disposal)(flags & ControlFlags.DisposalMask)) - { - default: - case Disposal.None: - case Disposal.DoNotDispose: - // remember current image in case we need to "return to previous" - PreviousImage = Output; - break; - - case Disposal.RestoreBackground: - // empty image - don't track - Output = new Color32[Width * Height]; - break; - - case Disposal.ReturnToPrevious: - - // return to previous image - - Output = new Color32[Width * Height]; - - if (PreviousImage != null) - Array.Copy(PreviousImage, Output, Output.Length); - - break; - } - } - - //------------------------------------------------------------------------------ - - private Image ReadImageBlock() - { - // read image block header - - ImageLeft = ReadUInt16(); - ImageTop = ReadUInt16(); - ImageWidth = ReadUInt16(); - ImageHeight = ReadUInt16(); - var flags = (ImageFlag)ReadByte(); - - // bad image if we don't have any dimensions - - if (ImageWidth == 0 || ImageHeight == 0) - return null; - - // read colour table - - if (flags.HasFlag(ImageFlag.ColourTable)) - ActiveColourTable = ReadColourTable(LocalColourTable, flags); - else - ActiveColourTable = GlobalColourTable; - - if (Output == null) - { - Output = new Color32[Width * Height]; - PreviousImage = Output; - } - - // read image data - - DecompressLZW(); - - // deinterlace - - if (flags.HasFlag(ImageFlag.Interlaced)) - Deinterlace(); - - // return image - - Image.RawImage = Output; - return Image; - } - - //------------------------------------------------------------------------------ - // decode interlaced images - - private void Deinterlace() - { - var numRows = Output.Length / Width; - var writePos = Output.Length - Width; // NB: work backwards due to Y-coord flip - var input = Output; - - Output = new Color32[Output.Length]; - - for (var row = 0; row < numRows; row++) - { - int copyRow; - - // every 8th row starting at 0 - if (row % 8 == 0) - { - copyRow = row / 8; - } - // every 8th row starting at 4 - else if ((row + 4) % 8 == 0) - { - var o = numRows / 8; - copyRow = o + (row - 4) / 8; - } - // every 4th row starting at 2 - else if ((row + 2) % 4 == 0) - { - var o = numRows / 4; - copyRow = o + (row - 2) / 4; - } - // every 2nd row starting at 1 - else // if( ( r + 1 ) % 2 == 0 ) - { - var o = numRows / 2; - copyRow = o + (row - 1) / 2; - } - - Array.Copy(input, (numRows - copyRow - 1) * Width, Output, writePos, Width); - - writePos -= Width; - } - } - - //------------------------------------------------------------------------------ - - // dispose isn't needed for the safe implementation but keep here for interface parity - - public Decoder() { } - - public void Dispose() { Dispose(true); } - - protected virtual void Dispose(bool disposing) { } - - private int[] Indices = new int[4096]; - private ushort[] Codes = new ushort[128 * 1024]; - private uint[] CurBlock = new uint[64]; - - private void DecompressLZW() - { - // output write position - - int row = (Height - ImageTop - 1) * Width; // reverse rows for unity texture coords - int col = ImageLeft; - int rightEdge = ImageLeft + ImageWidth; - - // setup codes - - int minimumCodeSize = Input[D++]; - - if (minimumCodeSize > 11) - minimumCodeSize = 11; - - var codeSize = minimumCodeSize + 1; - var nextSize = Pow2[codeSize]; - var maximumCodeSize = Pow2[minimumCodeSize]; - var clearCode = maximumCodeSize; - var endCode = maximumCodeSize + 1; - - // initialise buffers - - var codesEnd = 0; - var numCodes = maximumCodeSize + 2; - - for (ushort i = 0; i < numCodes; i++) - { - Indices[i] = codesEnd; - Codes[codesEnd++] = 1; // length - Codes[codesEnd++] = i; // code - } - - // LZW decode loop - - uint previousCode = NoCode; // last code processed - uint mask = (uint)(nextSize - 1); // mask out code bits - uint shiftRegister = 0; // shift register holds the bytes coming in from the input stream, we shift down by the number of bits - - int bitsAvailable = 0; // number of bits available to read in the shift register - int bytesAvailable = 0; // number of bytes left in current block - - int blockPos = 0; - - while (true) - { - // get next code - - uint curCode = shiftRegister & mask; - - if (bitsAvailable >= codeSize) - { - bitsAvailable -= codeSize; - shiftRegister >>= codeSize; - } - else - { - // reload shift register - - // if start of new block - - if (bytesAvailable <= 0) - { - // read blocksize - bytesAvailable = Input[D++]; - - // exit if end of stream - if (bytesAvailable == 0) - return; - - // read block - CurBlock[(bytesAvailable - 1) / 4] = 0; // zero last entry - Buffer.BlockCopy(Input, D, CurBlock, 0, bytesAvailable); - blockPos = 0; - D += bytesAvailable; - } - - // load shift register - - shiftRegister = CurBlock[blockPos++]; - int newBits = bytesAvailable >= 4 ? 32 : bytesAvailable * 8; - bytesAvailable -= 4; - - // read remaining bits - - if (bitsAvailable > 0) - { - var bitsRemaining = codeSize - bitsAvailable; - curCode |= (shiftRegister << bitsAvailable) & mask; - shiftRegister >>= bitsRemaining; - bitsAvailable = newBits - bitsRemaining; - } - else - { - curCode = shiftRegister & mask; - shiftRegister >>= codeSize; - bitsAvailable = newBits - codeSize; - } - } - - // process code - - if (curCode == clearCode) - { - // reset codes - codeSize = minimumCodeSize + 1; - nextSize = Pow2[codeSize]; - numCodes = maximumCodeSize + 2; - - // reset buffer write pos - codesEnd = numCodes * 2; - - // clear previous code - previousCode = NoCode; - mask = (uint)(nextSize - 1); - - continue; - } - else if (curCode == endCode) - { - // stop - break; - } - - bool plusOne = false; - int codePos = 0; - - if (curCode < numCodes) - { - // write existing code - codePos = Indices[curCode]; - } - else if (previousCode != NoCode) - { - // write previous code - codePos = Indices[previousCode]; - plusOne = true; - } - else - continue; - - // output colours - - var codeLength = Codes[codePos++]; - var newCode = Codes[codePos]; - - for (int i = 0; i < codeLength; i++) - { - var code = Codes[codePos++]; - - if (code != TransparentIndex && col < Width) - { - Output[row + col] = ActiveColourTable[code]; - } - - if (++col == rightEdge) - { - col = ImageLeft; - row -= Width; - - if (row < 0) - { - SkipBlocks(); - return; - } - } - } - - if (plusOne) - { - if (newCode != TransparentIndex && col < Width) - Output[row + col] = ActiveColourTable[newCode]; - - if (++col == rightEdge) - { - col = ImageLeft; - row -= Width; - - if (row < 0) - break; - } - } - - // create new code - - if (previousCode != NoCode && numCodes != Indices.Length) - { - // get previous code from buffer - - codePos = Indices[previousCode]; - codeLength = Codes[codePos++]; - - // resize buffer if required (should be rare) - - if (codesEnd + codeLength + 1 >= Codes.Length) - Array.Resize(ref Codes, Codes.Length * 2); - - // add new code - - Indices[numCodes++] = codesEnd; - Codes[codesEnd++] = (ushort)(codeLength + 1); - - // copy previous code sequence - - var stop = codesEnd + codeLength; - - while (codesEnd < stop) - Codes[codesEnd++] = Codes[codePos++]; - - // append new code - - Codes[codesEnd++] = newCode; - } - - // increase code size? - - if (numCodes >= nextSize && codeSize < 12) - { - nextSize = Pow2[++codeSize]; - mask = (uint)(nextSize - 1); - } - - // remember last code processed - previousCode = curCode; - } - - // skip any remaining blocks - SkipBlocks(); - } - - public static string Ident() - { - var v = "1.1"; - var e = BitConverter.IsLittleEndian ? "L" : "B"; - var b = "M"; - var s = "S"; - var n = "2.0"; - - return $"{v} {e}{s}{b} {n}"; - } - } -} \ No newline at end of file diff --git a/Dependencies/MelonStartScreen/mgGif/Image.cs b/Dependencies/MelonStartScreen/mgGif/Image.cs deleted file mode 100644 index 705736f44..000000000 --- a/Dependencies/MelonStartScreen/mgGif/Image.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using MelonUnityEngine; - -namespace mgGif -{ - internal class Image : ICloneable - { - public int Width; - public int Height; - public int Delay; // milliseconds - public Color32[] RawImage; - - public Image() { } - - public Image(Image img) - { - Width = img.Width; - Height = img.Height; - Delay = img.Delay; - RawImage = img.RawImage != null ? (Color32[])img.RawImage.Clone() : null; - } - - public object Clone() => new Image(this); - - public Texture2D CreateTexture(FilterMode filterMode = FilterMode.Bilinear) - { - var tex = new Texture2D(Width, Height); - tex.filterMode = filterMode; - - Color[] colors = new Color[RawImage.Length]; - for (int i = 0; i < colors.Length; i++) - colors[i] = RawImage[i]; - - tex.SetPixels(colors); - tex.Apply(); - - return tex; - } - } -} diff --git a/Dependencies/MelonStartScreen/mgGif/LICENSE.txt b/Dependencies/MelonStartScreen/mgGif/LICENSE.txt deleted file mode 100644 index 28eeb1976..000000000 --- a/Dependencies/MelonStartScreen/mgGif/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Gwaredd Mountain - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/Engine.Unity.Shared.csproj b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/Engine.Unity.Shared.csproj new file mode 100644 index 000000000..0e2de1886 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/Engine.Unity.Shared.csproj @@ -0,0 +1,20 @@ + + + MelonLoader.Engine.Unity + net35;net6 + Latest + true + $(MLOutDir)/MelonLoader/Dependencies/Engines/Unity/ + true + embedded + MelonLoader.Engine.Unity.Shared + + + + + False + + + + + \ No newline at end of file diff --git a/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonCoroutines.cs b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonCoroutines.cs new file mode 100644 index 000000000..38def65fb --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonCoroutines.cs @@ -0,0 +1,74 @@ +using System.Collections; +using System.Collections.Generic; + +namespace MelonLoader +{ + public abstract class MelonCoroutineInterop + { + public abstract object Start(IEnumerator routine); + public abstract void Stop(object coroutineToken); + } + + public static class MelonCoroutines + { + public static List QueuedCoroutines { get; private set; } = new List(); + public static MelonCoroutineInterop Interop; + + public static void ProcessQueue() + { + if (QueuedCoroutines == null) + return; + foreach (var queuedCoroutine in QueuedCoroutines) + Start(queuedCoroutine); + QueuedCoroutines.Clear(); + QueuedCoroutines = null; + } + + /// + /// Start a new coroutine.
+ /// Coroutines are called at the end of the game Update loops. + ///
+ /// The target routine + /// An object that can be passed to Stop to stop this coroutine + public static object Start(IEnumerator routine) + { + if (Interop != null) + return Interop.Start(routine); + return Queue(routine); + } + + /// + /// Start a new coroutine.
+ /// Coroutines are called at the end of the game Update loops. + ///
+ /// The target routine + /// An object that can be passed to Stop to stop this coroutine + public static object Queue(IEnumerator routine) + { + if (QueuedCoroutines == null) + return routine; + QueuedCoroutines.Add(routine); + return routine; + } + + /// + /// Stop a currently running coroutine + /// + /// The coroutine to stop + public static void Stop(object coroutineToken) + { + if (Interop != null) + Interop.Stop(coroutineToken); + Dequeue(coroutineToken as IEnumerator); + } + + public static void Dequeue(object coroutineToken) + { + if (QueuedCoroutines == null) + return; + IEnumerator routine = coroutineToken as IEnumerator; + if (QueuedCoroutines.Contains(routine)) + QueuedCoroutines.Remove(routine); + } + } +} \ No newline at end of file diff --git a/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonUnityEvents.cs b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonUnityEvents.cs new file mode 100644 index 000000000..b1afb2814 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonUnityEvents.cs @@ -0,0 +1,55 @@ +namespace MelonLoader.Engine.Unity +{ + public class MelonUnityEvents : MelonEvents + { + /// + /// Called once per frame. + /// + public readonly static MelonEvent OnUpdate = new(); + + /// + /// Called every 0.02 seconds, unless Time.fixedDeltaTime has a different Value. It is recommended to do all important Physics calculations inside this Callback. + /// + public readonly static MelonEvent OnFixedUpdate = new(); + + /// + /// Called once per frame, after . + /// + public readonly static MelonEvent OnLateUpdate = new(); + + /// + /// Called at every IMGUI event. Only use this for drawing IMGUI Elements. + /// + public readonly static MelonEvent OnGUI = new(); + + /// + /// Called when a new Scene is loaded. + /// + /// Arguments: + ///
: Build Index of the Scene.
+ ///
: Name of the Scene.
+ ///
+ ///
+ public readonly static MelonEvent OnSceneWasLoaded = new(); + + /// + /// Called once a Scene is initialized. + /// + /// Arguments: + ///
: Build Index of the Scene.
+ ///
: Name of the Scene.
+ ///
+ ///
+ public readonly static MelonEvent OnSceneWasInitialized = new(); + + /// + /// Called once a Scene unloads. + /// + /// Arguments: + ///
: Build Index of the Scene.
+ ///
: Name of the Scene.
+ ///
+ ///
+ public readonly static MelonEvent OnSceneWasUnloaded = new(); + } +} diff --git a/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonUnityMod.cs b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonUnityMod.cs new file mode 100644 index 000000000..e7d5d8650 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonUnityMod.cs @@ -0,0 +1,71 @@ +using System.Collections; + +namespace MelonLoader.Engine.Unity +{ + public class MelonUnityMod : MelonMod + { + public override void RegisterCallbacks() + { + base.RegisterCallbacks(); + + MelonUnityEvents.OnUpdate.Subscribe(OnUpdate, Priority); + MelonUnityEvents.OnLateUpdate.Subscribe(OnLateUpdate, Priority); + MelonUnityEvents.OnFixedUpdate.Subscribe(OnFixedUpdate, Priority); + MelonUnityEvents.OnGUI.Subscribe(OnGUI, Priority); + MelonUnityEvents.OnSceneWasLoaded.Subscribe(OnSceneWasLoaded, Priority); + MelonUnityEvents.OnSceneWasInitialized.Subscribe(OnSceneWasInitialized, Priority); + MelonUnityEvents.OnSceneWasUnloaded.Subscribe(OnSceneWasUnloaded, Priority); + } + + /// + /// Start a new coroutine.
+ /// Coroutines are called at the end of the game Update loops. + ///
+ /// The target routine + /// An object that can be passed to Stop to stop this coroutine + public object StartCoroutine(IEnumerator routine) + => MelonCoroutines.Start(routine); + + /// + /// Stop a currently running coroutine + /// + /// The coroutine to stop + public void StopCoroutine(object coroutineToken) + => MelonCoroutines.Stop(coroutineToken); + + /// + /// Runs once per frame. + /// + public virtual void OnUpdate() { } + + /// + /// Can run multiple times per frame. Mostly used for Physics. + /// + public virtual void OnFixedUpdate() { } + + /// + /// Runs once per frame, after . + /// + public virtual void OnLateUpdate() { } + + /// + /// Can run multiple times per frame. Mostly used for Unity's IMGUI. + /// + public virtual void OnGUI() { } + + /// + /// Runs when a new Scene is loaded. + /// + public virtual void OnSceneWasLoaded(int buildIndex, string sceneName) { } + + /// + /// Runs once a Scene is initialized. + /// + public virtual void OnSceneWasInitialized(int buildIndex, string sceneName) { } + + /// + /// Runs once a Scene unloads. + /// + public virtual void OnSceneWasUnloaded(int buildIndex, string sceneName) { } + } +} diff --git a/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonUnityPlugin.cs b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonUnityPlugin.cs new file mode 100644 index 000000000..fc0f218cd --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/MelonUnityPlugin.cs @@ -0,0 +1,53 @@ +using System.Collections; + +namespace MelonLoader.Engine.Unity +{ + public class MelonUnityPlugin : MelonPlugin + { + public override void RegisterCallbacks() + { + base.RegisterCallbacks(); + + MelonUnityEvents.OnUpdate.Subscribe(OnUpdate, Priority); + MelonUnityEvents.OnLateUpdate.Subscribe(OnLateUpdate, Priority); + MelonUnityEvents.OnFixedUpdate.Subscribe(OnFixedUpdate, Priority); + MelonUnityEvents.OnGUI.Subscribe(OnGUI, Priority); + } + + /// + /// Start a new coroutine.
+ /// Coroutines are called at the end of the game Update loops. + ///
+ /// The target routine + /// An object that can be passed to Stop to stop this coroutine + public object StartCoroutine(IEnumerator routine) + => MelonCoroutines.Start(routine); + + /// + /// Stop a currently running coroutine + /// + /// The coroutine to stop + public void StopCoroutine(object coroutineToken) + => MelonCoroutines.Stop(coroutineToken); + + /// + /// Runs once per frame. + /// + public virtual void OnUpdate() { } + + /// + /// Can run multiple times per frame. Mostly used for Physics. + /// + public virtual void OnFixedUpdate() { } + + /// + /// Runs once per frame, after . + /// + public virtual void OnLateUpdate() { } + + /// + /// Can run multiple times per frame. Mostly used for Unity's IMGUI. + /// + public virtual void OnGUI() { } + } +} diff --git a/MelonLoader/Resources/classdata.tpk b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/Resources/classdata.tpk similarity index 100% rename from MelonLoader/Resources/classdata.tpk rename to Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/Resources/classdata.tpk diff --git a/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/UnityExtensions.cs b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/UnityExtensions.cs new file mode 100644 index 000000000..9b9c634ee --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/UnityExtensions.cs @@ -0,0 +1,32 @@ +using AssetsTools.NET; +using AssetsTools.NET.Extra; + +namespace MelonLoader.Engine.Unity +{ + public static class UnityExtensions + { + #region AssetsManager + + public static ClassPackageFile LoadIncludedClassPackage(this AssetsManager assetsManager) + { + var asm = typeof(UnityExtensions).Assembly; + var names = asm.GetManifestResourceNames(); + string resourceName = null; + foreach (var name in names) + if (name.Contains("classdata")) + { + resourceName = name; + break; + } + if (string.IsNullOrEmpty(resourceName)) + return null; + + ClassPackageFile classPackage = null; + using (var stream = asm.GetManifestResourceStream(resourceName)) + classPackage = assetsManager.LoadClassPackage(stream); + return classPackage; + } + + #endregion + } +} diff --git a/MelonLoader/InternalUtils/UnityInformationHandler.cs b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/UnityInformationHandler.cs similarity index 87% rename from MelonLoader/InternalUtils/UnityInformationHandler.cs rename to Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/UnityInformationHandler.cs index 3578b5fbb..8e4b8e383 100644 --- a/MelonLoader/InternalUtils/UnityInformationHandler.cs +++ b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/UnityInformationHandler.cs @@ -7,11 +7,10 @@ using System.Text.RegularExpressions; using AssetsTools.NET; using AssetsTools.NET.Extra; -using System.Drawing; using MelonLoader.Utils; -using UnityVersion = AssetRipper.VersionUtilities.UnityVersion; +using UnityVersion = AssetRipper.Primitives.UnityVersion; -namespace MelonLoader.InternalUtils +namespace MelonLoader.Engine.Unity { public static class UnityInformationHandler { @@ -38,12 +37,10 @@ private static UnityVersion TryParse(string version) return returnval; } - internal static void Setup() + public static void Setup(string gameDataPath, string unityPlayerPath) { - string gameDataPath = MelonEnvironment.UnityGameDataDirectory; - - if (!string.IsNullOrEmpty(LoaderConfig.Current.UnityEngine.VersionOverride)) - EngineVersion = TryParse(LoaderConfig.Current.UnityEngine.VersionOverride); + //if (!string.IsNullOrEmpty(LoaderConfig.Current.UnityEngine.VersionOverride)) + // EngineVersion = TryParse(LoaderConfig.Current.UnityEngine.VersionOverride); AssetsManager assetsManager = new AssetsManager(); ReadGameInfo(assetsManager, gameDataPath); @@ -51,10 +48,10 @@ internal static void Setup() if (string.IsNullOrEmpty(GameDeveloper) || string.IsNullOrEmpty(GameName)) - ReadGameInfoFallback(); + ReadGameInfoFallback(gameDataPath); if (EngineVersion == UnityVersion.MinVersion) - EngineVersion = ReadVersionFallback(gameDataPath); + EngineVersion = ReadVersionFallback(gameDataPath, unityPlayerPath); if (string.IsNullOrEmpty(GameDeveloper)) GameDeveloper = DefaultInfo; @@ -62,14 +59,6 @@ internal static void Setup() GameName = DefaultInfo; if (string.IsNullOrEmpty(GameVersion)) GameVersion = DefaultInfo; - - MelonLogger.WriteLine(Color.Magenta); - MelonLogger.Msg($"Game Name: {GameName}"); - MelonLogger.Msg($"Game Developer: {GameDeveloper}"); - MelonLogger.Msg($"Unity Version: {EngineVersion}"); - MelonLogger.Msg($"Game Version: {GameVersion}"); - MelonLogger.WriteLine(Color.Magenta); - MelonLogger.WriteSpacer(); } private static void ReadGameInfo(AssetsManager assetsManager, string gameDataPath) @@ -123,6 +112,10 @@ private static void ReadGameInfo(AssetsManager assetsManager, string gameDataPat GameName = productName.AsString; } } + else + { + MelonLogger.Warning("Unable to find PlayerSettings in globalgamemanagers. Possible out-dated classdata.tpk present. Using fallback method."); + } } catch(Exception ex) { @@ -133,11 +126,11 @@ private static void ReadGameInfo(AssetsManager assetsManager, string gameDataPat instance.file.Close(); } - private static void ReadGameInfoFallback() + private static void ReadGameInfoFallback(string gameDataPath) { try { - string appInfoFilePath = Path.Combine(MelonEnvironment.UnityGameDataDirectory, "app.info"); + string appInfoFilePath = Path.Combine(gameDataPath, "app.info"); if (!File.Exists(appInfoFilePath)) return; @@ -159,11 +152,10 @@ private static void ReadGameInfoFallback() } } - private static UnityVersion ReadVersionFallback(string gameDataPath) + private static UnityVersion ReadVersionFallback(string gameDataPath, string unityPlayerPath) { - string unityPlayerPath = MelonEnvironment.UnityPlayerPath; if (!File.Exists(unityPlayerPath)) - unityPlayerPath = MelonEnvironment.GameExecutablePath; + unityPlayerPath = MelonEnvironment.ApplicationExecutablePath; if (Environment.OSVersion.Platform == PlatformID.Win32NT) { diff --git a/MelonLoader/InternalUtils/UnityMagicMethods.cs b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/UnityMagicMethods.cs similarity index 99% rename from MelonLoader/InternalUtils/UnityMagicMethods.cs rename to Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/UnityMagicMethods.cs index 1f485139b..da71933af 100644 --- a/MelonLoader/InternalUtils/UnityMagicMethods.cs +++ b/Dependencies/Modules/Engines/Unity/Engine.Unity.Shared/UnityMagicMethods.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Reflection; -namespace MelonLoader.InternalUtils +namespace MelonLoader.Engine.Unity { /* * A list of Unity's built-in messages / magic methods and their (optional) argument types. diff --git a/Dependencies/Modules/Engines/Unity/Engine.Unity/Engine.Unity.csproj b/Dependencies/Modules/Engines/Unity/Engine.Unity/Engine.Unity.csproj new file mode 100644 index 000000000..93dfd6689 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Engine.Unity/Engine.Unity.csproj @@ -0,0 +1,48 @@ + + + MelonLoader.Engine.Unity + net6 + Latest + false + $(MLOutDir)/MelonLoader/Dependencies/Engines/Unity/ + true + embedded + MelonLoader.Engine.Unity + + + + False + + + False + + + False + + + False + + + False + + + False + False + all + + + False + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Dependencies/Modules/Engines/Unity/Engine.Unity/UnityLoader.cs b/Dependencies/Modules/Engines/Unity/Engine.Unity/UnityLoader.cs new file mode 100644 index 000000000..7fa62b834 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Engine.Unity/UnityLoader.cs @@ -0,0 +1,265 @@ +using System.IO; +using MelonLoader.Utils; +using MelonLoader.Modules; +using MelonLoader.Runtime.Il2Cpp; +using System; +using MelonLoader.Resolver; +using System.Runtime.Loader; +using MelonLoader.Engine.Unity.Il2Cpp; +using MelonLoader.Runtime.Mono; +using System.Collections.Generic; + +namespace MelonLoader.Engine.Unity +{ + internal class UnityLoaderModule : MelonEngineModule + { + private readonly string GameDataPath = Path.Combine(MelonEnvironment.ApplicationRootDirectory, $"{MelonEnvironment.ApplicationExecutableName}_Data"); + private string UnityPlayerPath; + private string GameAssemblyPath; + private bool IsIl2Cpp; + + private string LoaderPath; + private string SupportModulePath; + + private MonoRuntimeInfo MonoInfo; + + private static readonly string[] monoFolderNames = + [ + "Mono", + "MonoBleedingEdge" + ]; + + private static readonly string[] monoLibNames = + [ + "mono", +#if WINDOWS + "mono-2.0-bdwgc", + "mono-2.0-sgen", + "mono-2.0-boehm" +#elif LINUX + "monobdwgc-2.0" +#endif + ]; + + private static readonly string[] monoPosixHelperNames = + [ + "MonoPosixHelper", + ]; + + public override bool Validate() + { + UnityPlayerPath = Path.Combine(MelonEnvironment.ApplicationRootDirectory, $"UnityPlayer{OsUtils.NativeFileExtension}"); + if (File.Exists(UnityPlayerPath)) + return true; + + if (Directory.Exists(GameDataPath)) + return File.Exists(Path.Combine(GameDataPath, "globalgamemanagers")) + || File.Exists(Path.Combine(GameDataPath, "data.unity3d")) + || File.Exists(Path.Combine(GameDataPath, "mainData")); + + return false; + } + + public override void Initialize() + { + MelonDebug.Msg("Initializing Unity Engine Module..."); + LoaderPath = Path.GetDirectoryName(typeof(UnityLoaderModule).Assembly.Location); + + UnityInformationHandler.Setup(GameDataPath, UnityPlayerPath); + + string gameAssemblyName = "GameAssembly"; + if (OsUtils.IsAndroid) + gameAssemblyName = "libil2cpp"; + gameAssemblyName += OsUtils.NativeFileExtension; + + GameAssemblyPath = Path.Combine(MelonEnvironment.ApplicationRootDirectory, gameAssemblyName); + IsIl2Cpp = File.Exists(GameAssemblyPath); + if (!IsIl2Cpp) + { + // Android only has Il2Cpp currently + if (OsUtils.IsAndroid) + { + MelonLogger.ThrowInternalFailure($"Failed to find {gameAssemblyName}!"); + return; + } + + // Attempt to find Library + MonoInfo = GetMonoRuntimeInfo(); + if (MonoInfo == null) + { + MelonLogger.ThrowInternalFailure("Failed to get Mono Runtime Info!"); + return; + } + } + + string indentifier = IsIl2Cpp ? "Il2Cpp" : (MonoInfo.IsBleedingEdge ? "MonoBleedingEdge" : "Mono"); + SupportModulePath = Path.Combine( + LoaderPath, + IsIl2Cpp ? "net6" : "net35", + $"MelonLoader.Unity.{(IsIl2Cpp ? "Il2Cpp" : "Mono")}.dll"); + + SetEngineInfo("Unity", UnityInformationHandler.EngineVersion.ToStringWithoutType(), (IsIl2Cpp ? "Il2Cpp" : (MonoInfo.IsBleedingEdge ? "MonoBleedingEdge" : "Mono"))); + SetApplicationInfo(UnityInformationHandler.GameName, UnityInformationHandler.GameDeveloper, UnityInformationHandler.GameVersion); + PrintAppInfo(); + + if (IsIl2Cpp) + { + // Initialize Il2Cpp Loader + Il2CppLoader.Initialize(this, new(GameAssemblyPath, SupportModulePath, + [ + "Internal_ActiveSceneChanged", + "UnityEngine.ISerializationCallbackReceiver.OnAfterSerialize" + ])); + } + else + { + // Android only has Il2Cpp currently + if (OsUtils.IsAndroid) + return; + + // Initialize Mono Loader + MonoInfo.SupportModulePath = SupportModulePath; + MonoLoader.Initialize(this, MonoInfo); + } + } + + public override void Stage3(string supportModulePath) + { + if (!IsIl2Cpp) + { + // Run Stage3 + base.Stage3(supportModulePath); + return; + } + + string genBasePath = Path.Combine(LoaderPath, "Il2CppAssemblyGenerator"); + if (!Directory.Exists(genBasePath)) + Directory.CreateDirectory(genBasePath); + + string genOutputPath = Path.Combine(MelonEnvironment.DependenciesDirectory, "Il2CppAssemblies"); + if (!Directory.Exists(genOutputPath)) + Directory.CreateDirectory(genOutputPath); + MelonAssemblyResolver.AddSearchDirectory(genOutputPath); + + // Apply Il2Cpp Fixes + Il2CppInteropFixes.Install(genOutputPath); + Il2CppICallInjector.Install(); + + // Generate Il2Cpp Wrapper Assemblies + try + { + if (!AssemblyGenerator.Run(genBasePath, GameAssemblyPath, genOutputPath)) + { + MelonDebug.Error("Il2Cpp Assembly Generation Failure!"); + return; + } + + foreach (var file in Directory.GetFiles(genOutputPath, "*.dll")) + { + try + { + AssemblyLoadContext.Default.LoadFromAssemblyPath(file); + } + catch { } + } + } + catch (Exception ex) + { + MelonDebug.Error(ex.ToString()); + return; + } + + // Run Stage3 after Assembly Generation + base.Stage3(supportModulePath); + } + + private MonoRuntimeInfo GetMonoRuntimeInfo() + { + // Folders the Mono folders might be located in + string[] directoriesToSearch = + [ + MelonEnvironment.ApplicationRootDirectory, + GameDataPath + ]; + + // Iterate through Variations in Mono types + (string, string, bool)? libPaths = null; + foreach (var folderName in monoFolderNames) + { + // Iterate through Variations in Mono Directory Positions + foreach (var dir in directoriesToSearch) + { + // Iterate through Variations in Mono Lib Names + string folderPath = Path.Combine(dir, folderName); + foreach (var fileName in monoLibNames) + { + libPaths = SearchFolderForMonoLib(folderPath, fileName); + if (libPaths != null) + break; + } + if (libPaths != null) + break; + } + if (libPaths != null) + break; + } + if (libPaths == null) + return null; + + // Attempt to find Posix Helper + string posixPath = null; + foreach (string fileName in monoPosixHelperNames) + { + string localFileName = fileName; + if (OsUtils.IsUnix) + localFileName = $"lib{fileName}"; + localFileName += OsUtils.NativeFileExtension; + string localFilePath = Path.Combine(libPaths.Value.Item1, localFileName); + if (File.Exists(localFilePath)) + { + posixPath = localFilePath; + break; + } + } + + bool isBleedingEdge = libPaths.Value.Item3; + return new MonoRuntimeInfo(libPaths.Value.Item2, posixPath, Path.Combine(GameDataPath, "Managed"), isBleedingEdge, null, [ + (!isBleedingEdge ? "Awake" : string.Empty), + (!isBleedingEdge ? "DoSendMouseEvents" : string.Empty), + "Internal_ActiveSceneChanged", + "UnityEngine.ISerializationCallbackReceiver.OnAfterSerialize", + ]); + } + + private (string, string, bool)? SearchFolderForMonoLib(string folderPath, string fileName) + { + bool isBleedingEdge = (fileName != monoLibNames[0]); + + if (OsUtils.IsUnix) + fileName = $"lib{fileName}"; + fileName += OsUtils.NativeFileExtension; + + string filePath = Path.Combine(folderPath, fileName); + if (File.Exists(filePath)) + return (folderPath, filePath, isBleedingEdge); + + string embedRuntimePath = Path.Combine(folderPath, "EmbedRuntime"); + if (Directory.Exists(embedRuntimePath)) + { + filePath = Path.Combine(embedRuntimePath, fileName); + if (File.Exists(filePath)) + return (embedRuntimePath, filePath, isBleedingEdge); + + string x64Path = Path.Combine(embedRuntimePath, "x86_64"); + if (Directory.Exists(x64Path)) + { + filePath = Path.Combine(x64Path, fileName); + if (File.Exists(filePath)) + return (x64Path, filePath, isBleedingEdge); + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/Dependencies/SupportModules/Il2Cpp/Libs/Il2CppSystem.dll b/Dependencies/Modules/Engines/Unity/Il2Cpp/Libs/Il2CppSystem.dll similarity index 100% rename from Dependencies/SupportModules/Il2Cpp/Libs/Il2CppSystem.dll rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Libs/Il2CppSystem.dll diff --git a/Dependencies/SupportModules/Il2Cpp/Libs/Il2Cppmscorlib.dll b/Dependencies/Modules/Engines/Unity/Il2Cpp/Libs/Il2Cppmscorlib.dll similarity index 100% rename from Dependencies/SupportModules/Il2Cpp/Libs/Il2Cppmscorlib.dll rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Libs/Il2Cppmscorlib.dll diff --git a/Dependencies/SupportModules/Il2Cpp/Libs/UnityEngine.CoreModule.dll b/Dependencies/Modules/Engines/Unity/Il2Cpp/Libs/UnityEngine.CoreModule.dll similarity index 100% rename from Dependencies/SupportModules/Il2Cpp/Libs/UnityEngine.CoreModule.dll rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Libs/UnityEngine.CoreModule.dll diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/AssemblyGenerator.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/AssemblyGenerator.cs new file mode 100644 index 000000000..6d19a95dc --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/AssemblyGenerator.cs @@ -0,0 +1,162 @@ +using System; +using System.IO; +using System.Net.Http; +using MelonLoader.Engine.Unity.Packages; +using MelonLoader.Properties; +using MelonLoader.Utils; + +namespace MelonLoader.Engine.Unity +{ + public class AssemblyGenerator + { + internal static HttpClient webClient = null; + + internal static Cpp2IL cpp2il = null; + internal static Cpp2IL_StrippedCodeRegSupport cpp2il_scrs = null; + + internal static Packages.Il2CppInterop il2cppinterop = null; + internal static UnityDependencies unitydependencies = null; + internal static DeobfuscationMap deobfuscationMap = null; + internal static DeobfuscationRegex deobfuscationRegex = null; + + internal static bool AssemblyGenerationNeeded = false; + internal static MelonLogger.Instance Logger; + + public static bool Run(string BasePath, string GameAssemblyPath, string OutputPath) + { + Environment.SetEnvironmentVariable("IL2CPP_INTEROP_DATABASES_LOCATION", OutputPath); + Logger = new("Il2Cpp.AssemblyGenerator"); + + webClient = new(); + webClient.DefaultRequestHeaders.Add("User-Agent", $"{BuildInfo.Name} v{BuildInfo.Version}"); + + //AssemblyGenerationNeeded = LoaderConfig.Current.UnityEngine.ForceRegeneration; + + Config.Initialize(BasePath); + + //if (!LoaderConfig.Current.UnityEngine.ForceOfflineGeneration) + RemoteAPI.Contact(); + + Cpp2IL cpp2IL_netcore = new Cpp2IL(BasePath); + if (OsUtils.IsWindows + && (cpp2IL_netcore.VersionSem < Cpp2IL.NetCoreMinVersion)) + cpp2il = new Cpp2IL_NetFramework(BasePath); + else + cpp2il = cpp2IL_netcore; + cpp2il_scrs = new Cpp2IL_StrippedCodeRegSupport(cpp2il, BasePath); + + il2cppinterop = new Packages.Il2CppInterop(BasePath); + unitydependencies = new UnityDependencies(BasePath); + deobfuscationMap = new DeobfuscationMap(BasePath); + deobfuscationRegex = new DeobfuscationRegex(); + + Logger.Msg($"Using Cpp2IL Version: {(string.IsNullOrEmpty(cpp2il.Version) ? "null" : cpp2il.Version)}"); + Logger.Msg($"Using Il2CppInterop Version = {(string.IsNullOrEmpty(il2cppinterop.Version) ? "null" : il2cppinterop.Version)}"); + Logger.Msg($"Using Unity Dependencies Version = {(string.IsNullOrEmpty(unitydependencies.Version) ? "null" : unitydependencies.Version)}"); + Logger.Msg($"Using Deobfuscation Regex = {(string.IsNullOrEmpty(deobfuscationRegex.Regex) ? "null" : deobfuscationRegex.Regex)}"); + + if (!cpp2il.Setup() + || !cpp2il_scrs.Setup() + || !il2cppinterop.Setup() + || !unitydependencies.Setup() + || !deobfuscationMap.Setup()) + { + webClient.Dispose(); + webClient = null; + return false; + } + + deobfuscationRegex.Setup(); + + string CurrentGameAssemblyHash; + Logger.Msg("Checking GameAssembly..."); + MelonDebug.Msg($"Last GameAssembly Hash: {Config.Values.GameAssemblyHash}"); + MelonDebug.Msg($"Current GameAssembly Hash: {CurrentGameAssemblyHash = MelonUtils.ComputeSimpleSHA512Hash(GameAssemblyPath)}"); + + if (string.IsNullOrEmpty(Config.Values.GameAssemblyHash) + || !Config.Values.GameAssemblyHash.Equals(CurrentGameAssemblyHash)) + AssemblyGenerationNeeded = true; + + if (!AssemblyGenerationNeeded) + { + Logger.Msg("Assembly is up to date. No Generation Needed."); + webClient.Dispose(); + webClient = null; + return true; + } + Logger.Msg("Assembly Generation Needed!"); + + cpp2il.Cleanup(); + il2cppinterop.Cleanup(); + + if (!cpp2il.Execute(GameAssemblyPath)) + { + cpp2il.Cleanup(); + webClient.Dispose(); + webClient = null; + return false; + } + + if (!il2cppinterop.Execute(GameAssemblyPath)) + { + cpp2il.Cleanup(); + il2cppinterop.Cleanup(); + webClient.Dispose(); + webClient = null; + return false; + } + + OldFiles_Cleanup(OutputPath); + OldFiles_LAM(OutputPath); + + cpp2il.Cleanup(); + il2cppinterop.Cleanup(); + + webClient.Dispose(); + webClient = null; + + Logger.Msg("Assembly Generation Successful!"); + deobfuscationRegex.Save(); + Config.Values.GameAssemblyHash = CurrentGameAssemblyHash; + Config.Save(); + + return true; + } + + private static void OldFiles_Cleanup(string OutputPath) + { + if (Config.Values.OldFiles.Count <= 0) + return; + for (int i = 0; i < Config.Values.OldFiles.Count; i++) + { + string filename = Config.Values.OldFiles[i]; + string filepath = Path.Combine(OutputPath, filename); + if (File.Exists(filepath)) + { + Logger.Msg("Deleting " + filename); + File.Delete(filepath); + } + } + Config.Values.OldFiles.Clear(); + } + + private static void OldFiles_LAM(string OutputPath) + { + string[] filepathtbl = Directory.GetFiles(il2cppinterop.OutputFolder); + string il2CppAssembliesDirectory = OutputPath; + for (int i = 0; i < filepathtbl.Length; i++) + { + string filepath = filepathtbl[i]; + string filename = Path.GetFileName(filepath); + Logger.Msg("Moving " + filename); + Config.Values.OldFiles.Add(filename); + string newfilepath = Path.Combine(il2CppAssembliesDirectory, filename); + if (File.Exists(newfilepath)) + File.Delete(newfilepath); + Directory.CreateDirectory(il2CppAssembliesDirectory); + File.Move(filepath, newfilepath); + } + Config.Save(); + } + } +} \ No newline at end of file diff --git a/Dependencies/Il2CppAssemblyGenerator/Config.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Config.cs similarity index 89% rename from Dependencies/Il2CppAssemblyGenerator/Config.cs rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Config.cs index 3c40f6f0c..82f3d9dbb 100644 --- a/Dependencies/Il2CppAssemblyGenerator/Config.cs +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Config.cs @@ -3,7 +3,7 @@ using System.IO; using MelonLoader.Preferences; -namespace MelonLoader.Il2CppAssemblyGenerator +namespace MelonLoader.Engine.Unity { internal class Config { @@ -11,9 +11,9 @@ internal class Config private static MelonPreferences_ReflectiveCategory Category; internal static AssemblyGeneratorConfiguration Values; - internal static void Initialize() + internal static void Initialize(string BasePath) { - FilePath = Path.Combine(Core.BasePath, "Config.cfg"); + FilePath = Path.Combine(BasePath, "Config.cfg"); Category = MelonPreferences.CreateCategory("Il2CppAssemblyGenerator"); Category.SetFilePath(FilePath, printmsg: false); diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Extensions.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Extensions.cs new file mode 100644 index 000000000..7a68581b3 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Extensions.cs @@ -0,0 +1,14 @@ +using System.IO; +using System.Net.Http; + +namespace MelonLoader.Engine.Unity; + +internal static class Extensions +{ + public static void DownloadFile(this HttpClient client, string url, string dest) + { + using var dlStream = client.GetStreamAsync(url).Result; + using var fileStream = File.Open(dest, FileMode.Create, FileAccess.Write); + dlStream.CopyTo(fileStream); + } +} \ No newline at end of file diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/FileHandler.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/FileHandler.cs new file mode 100644 index 000000000..c0b3ca211 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/FileHandler.cs @@ -0,0 +1,130 @@ +using System; +using System.IO; +using System.IO.Compression; + +namespace MelonLoader.Engine.Unity +{ + internal static class FileHandler + { + internal static bool Download(string url, string destination) + { + if (string.IsNullOrEmpty(url)) + { + AssemblyGenerator.Logger.Error($"url cannot be Null or Empty!"); + return false; + } + + if (string.IsNullOrEmpty(destination)) + { + AssemblyGenerator.Logger.Error($"destination cannot be Null or Empty!"); + return false; + } + + if (File.Exists(destination)) + File.Delete(destination); + + AssemblyGenerator.Logger.Msg($"Downloading {url} to {destination}"); + try { AssemblyGenerator.webClient.DownloadFile(url, destination); } + catch (Exception ex) + { + AssemblyGenerator.Logger.Error(ex.ToString()); + + if (File.Exists(destination)) + File.Delete(destination); + + return false; + } + + return true; + } + + internal static bool Process(string filepath, string destination, string targetName = null) + { + if (string.IsNullOrEmpty(filepath)) + { + AssemblyGenerator.Logger.Error($"filepath cannot be Null or Empty!"); + return false; + } + + if (string.IsNullOrEmpty(destination)) + { + AssemblyGenerator.Logger.Error($"destination cannot be Null or Empty!"); + return false; + } + + if (filepath.Equals(destination)) + return true; + + if (!File.Exists(filepath)) + { + AssemblyGenerator.Logger.Error($"{filepath} does not Exist!"); + return false; + } + + if (Path.HasExtension(destination)) + { + if (File.Exists(destination)) + File.Delete(destination); + } + else + { + if (Directory.Exists(destination)) + { + AssemblyGenerator.Logger.Msg($"Cleaning {destination}"); + foreach (var entry in Directory.EnumerateFileSystemEntries(destination)) + { + if (Directory.Exists(entry)) + Directory.Delete(entry, true); + else + File.Delete(entry); + } + } + else + { + AssemblyGenerator.Logger.Msg($"Creating Directory {destination}"); + Directory.CreateDirectory(destination); + } + } + + string filename = Path.GetFileName(filepath); + if (!filename.EndsWith(".zip")) + { + AssemblyGenerator.Logger.Msg($"Moving {filepath} to {destination}"); + + if (!string.IsNullOrEmpty(targetName)) + destination = Path.Combine(destination, targetName); + + File.Move(filepath, destination); + return true; + } + + AssemblyGenerator.Logger.Msg($"Extracting {filepath} to {destination}"); + try { ZipFile.ExtractToDirectory(filepath, destination); } + catch (Exception ex) + { + AssemblyGenerator.Logger.Error(ex.ToString()); + + if (File.Exists(filepath)) + File.Delete(filepath); + + if (Directory.Exists(destination)) + { + foreach (var entry in Directory.EnumerateFileSystemEntries(destination)) + { + if (Directory.Exists(entry)) + Directory.Delete(entry, true); + else + File.Delete(entry); + } + } + + return false; + } + + if (File.Exists(filepath)) + File.Delete(filepath); + + return true; + } + } +} diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Cpp2IL.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Cpp2IL.cs new file mode 100644 index 000000000..ed4785651 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Cpp2IL.cs @@ -0,0 +1,88 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using MelonLoader.Utils; +using Semver; + +namespace MelonLoader.Engine.Unity.Packages +{ + internal class Cpp2IL : Models.ExecutablePackage + { + internal static SemVersion NetCoreMinVersion = SemVersion.Parse("2022.1.0-pre-release.18"); + internal SemVersion VersionSem; + private string BaseFolder; + + private static string ReleaseName => + OsUtils.IsWindows ? "Windows" : OsUtils.IsUnix ? "Linux" : "OSX"; + + internal Cpp2IL() { } + internal Cpp2IL(string BasePath) + { + //Version = LoaderConfig.Current.UnityEngine.ForceIl2CppDumperVersion; +#if !DEBUG + if (string.IsNullOrEmpty(Version) || Version.Equals("0.0.0.0")) + Version = RemoteAPI.Info.ForceDumperVersion; +#endif + if (string.IsNullOrEmpty(Version) || Version.Equals("0.0.0.0")) + Version = $"2022.1.0-pre-release.19"; + VersionSem = SemVersion.Parse(Version); + + Name = nameof(Cpp2IL); + + var filename = Name; +#if WINDOWS + filename += ".exe"; +#endif + + BaseFolder = Path.Combine(BasePath, Name); + if (!Directory.Exists(BaseFolder)) + Directory.CreateDirectory(BaseFolder); + + FilePath = + ExeFilePath = + Destination = + Path.Combine(BaseFolder, filename); + + OutputFolder = Path.Combine(BaseFolder, "cpp2il_out"); + + URL = $"https://github.com/SamboyCoding/{Name}/releases/download/{Version}/{Name}-{Version}-{ReleaseName}"; +#if WINDOWS + URL += ".exe"; +#endif + } + + internal override bool ShouldSetup() + => string.IsNullOrEmpty(Config.Values.DumperVersion) + || !Config.Values.DumperVersion.Equals(Version); + + internal override void Cleanup() { } + + internal override void Save() + => Save(ref Config.Values.DumperVersion); + + internal virtual bool Execute(string GameAssemblyPath) + => Execute([ + MelonDebug.IsEnabled() ? "--verbose" : string.Empty, + + "--game-path", + "\"" + Path.GetDirectoryName(GameAssemblyPath) + "\"", + + "--exe-name", + "\"" + Process.GetCurrentProcess().ProcessName + "\"", + + "--output-as", + "dummydll", + + "--use-processor", + "attributeanalyzer", + "attributeinjector", + //LoaderConfig.Current.UnityEngine.EnableCpp2ILCallAnalyzer ? "callanalyzer" : string.Empty, + //LoaderConfig.Current.UnityEngine.EnableCpp2ILNativeMethodDetector ? "nativemethoddetector" : string.Empty, + //"deobfmap", + //"stablenamer", + + ], false, new Dictionary() { + {"NO_COLOR", "1"}, + }); + } +} diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Cpp2IL_NetFramework.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Cpp2IL_NetFramework.cs new file mode 100644 index 000000000..123fc1c41 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Cpp2IL_NetFramework.cs @@ -0,0 +1,101 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using Semver; + +namespace MelonLoader.Engine.Unity.Packages +{ + internal class Cpp2IL_NetFramework : Cpp2IL + { + private static string ReleaseName => "Windows-Netframework472"; + internal Cpp2IL_NetFramework(string BasePath) + { + //Version = LoaderConfig.Current.UnityEngine.ForceIl2CppDumperVersion; +#if !DEBUG + if (string.IsNullOrEmpty(Version) || Version.Equals("0.0.0.0")) + Version = RemoteAPI.Info.ForceDumperVersion; +#endif + if (string.IsNullOrEmpty(Version) || Version.Equals("0.0.0.0")) + Version = $"2022.1.0-pre-release.15"; + + Name = nameof(Cpp2IL); + Destination = Path.Combine(BasePath, Name); + if (!Directory.Exists(Destination)) + Directory.CreateDirectory(Destination); + OutputFolder = Path.Combine(Destination, "cpp2il_out"); + + URL = $"https://github.com/SamboyCoding/{Name}/releases/download/{Version}/{Name}-{Version}-{ReleaseName}.zip"; + ExeFilePath = Path.Combine(Destination, $"{Name}.exe"); + FilePath = Path.Combine(BasePath, $"{Name}_{Version}.zip"); + } + + internal override bool ShouldSetup() + => string.IsNullOrEmpty(Config.Values.DumperVersion) + || !Config.Values.DumperVersion.Equals(Version); + + internal override void Cleanup() { } + + internal override void Save() + => Save(ref Config.Values.DumperVersion); + + internal override bool Execute(string GameAssemblyPath) + { + if (SemVersion.Parse(Version) <= SemVersion.Parse("2022.0.999")) + return ExecuteOld(GameAssemblyPath); + return ExecuteNew(GameAssemblyPath); + } + + private bool ExecuteNew(string GameAssemblyPath) + { + if (Execute([ + MelonDebug.IsEnabled() ? "--verbose" : string.Empty, + + "--game-path", + "\"" + Path.GetDirectoryName(GameAssemblyPath) + "\"", + + "--exe-name", + "\"" + Process.GetCurrentProcess().ProcessName + "\"", + + "--output-as", + "dummydll", + + "--use-processor", + "attributeanalyzer", + "attributeinjector", + //LoaderConfig.Current.UnityEngine.EnableCpp2ILCallAnalyzer ? "callanalyzer" : string.Empty, + //LoaderConfig.Current.UnityEngine.EnableCpp2ILNativeMethodDetector ? "nativemethoddetector" : string.Empty, + //"deobfmap", + //"stablenamer", + + ], false, new Dictionary() { + {"NO_COLOR", "1"} + })) + return true; + + return false; + } + + private bool ExecuteOld(string GameAssemblyPath) + { + if (Execute([ + MelonDebug.IsEnabled() ? "--verbose" : string.Empty, + + "--game-path", + "\"" + Path.GetDirectoryName(GameAssemblyPath) + "\"", + + "--exe-name", + "\"" + Process.GetCurrentProcess().ProcessName + "\"", + + "--skip-analysis", + "--skip-metadata-txts", + "--disable-registration-prompts" + + ], false, new Dictionary() { + {"NO_COLOR", "1"} + })) + return true; + + return false; + } + } +} \ No newline at end of file diff --git a/Dependencies/Il2CppAssemblyGenerator/Packages/Cpp2IL_StrippedCodeRegSupport.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Cpp2IL_StrippedCodeRegSupport.cs similarity index 88% rename from Dependencies/Il2CppAssemblyGenerator/Packages/Cpp2IL_StrippedCodeRegSupport.cs rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Cpp2IL_StrippedCodeRegSupport.cs index 4492b30ba..8f4c11912 100644 --- a/Dependencies/Il2CppAssemblyGenerator/Packages/Cpp2IL_StrippedCodeRegSupport.cs +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Cpp2IL_StrippedCodeRegSupport.cs @@ -1,8 +1,8 @@ -using MelonLoader.Il2CppAssemblyGenerator.Packages.Models; +using MelonLoader.Engine.Unity.Packages.Models; using Semver; using System.IO; -namespace MelonLoader.Il2CppAssemblyGenerator.Packages +namespace MelonLoader.Engine.Unity.Packages { internal class Cpp2IL_StrippedCodeRegSupport : PackageBase { @@ -10,15 +10,17 @@ internal class Cpp2IL_StrippedCodeRegSupport : PackageBase private string _pluginsFolder; private SemVersion VersionSem; - internal Cpp2IL_StrippedCodeRegSupport(ExecutablePackage cpp2IL) + internal Cpp2IL_StrippedCodeRegSupport(ExecutablePackage cpp2IL, string BasePath) { Name = $"{cpp2IL.Name}.Plugin.StrippedCodeRegSupport"; Version = cpp2IL.Version; VersionSem = SemVersion.Parse(Version); - string folderpath = Path.Combine(Core.BasePath, cpp2IL.Name); + string folderpath = Path.Combine(BasePath, cpp2IL.Name); string fileName = $"{Name}.dll"; _pluginsFolder = Path.Combine(folderpath, "Plugins"); + if (!Directory.Exists(_pluginsFolder)) + Directory.CreateDirectory(_pluginsFolder); FilePath = Destination = @@ -41,9 +43,6 @@ internal override bool Setup() if (VersionSem < Cpp2IL.NetCoreMinVersion) return true; - if (!Directory.Exists(_pluginsFolder)) - Directory.CreateDirectory(_pluginsFolder); - return base.Setup(); } diff --git a/Dependencies/Il2CppAssemblyGenerator/Packages/DeobfuscationMap.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/DeobfuscationMap.cs similarity index 88% rename from Dependencies/Il2CppAssemblyGenerator/Packages/DeobfuscationMap.cs rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/DeobfuscationMap.cs index 9ce74b3a3..db2941a4f 100644 --- a/Dependencies/Il2CppAssemblyGenerator/Packages/DeobfuscationMap.cs +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/DeobfuscationMap.cs @@ -3,16 +3,16 @@ using System.Text; using MelonLoader.Lemons.Cryptography; -namespace MelonLoader.Il2CppAssemblyGenerator.Packages +namespace MelonLoader.Engine.Unity.Packages { internal class DeobfuscationMap : Models.PackageBase { private static LemonSHA512 lemonSHA512 = new LemonSHA512(); - internal DeobfuscationMap() + internal DeobfuscationMap(string BasePath) { Name = nameof(DeobfuscationMap); - FilePath = Path.Combine(Core.BasePath, $"{Name}.csv.gz"); + FilePath = Path.Combine(BasePath, $"{Name}.csv.gz"); Destination = FilePath; URL = RemoteAPI.Info.MappingURL; Version = RemoteAPI.Info.MappingFileSHA512; diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/DeobfuscationRegex.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/DeobfuscationRegex.cs new file mode 100644 index 000000000..3f3cc4588 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/DeobfuscationRegex.cs @@ -0,0 +1,45 @@ +namespace MelonLoader.Engine.Unity.Packages +{ + internal class DeobfuscationRegex + { + internal string Regex = null; + + internal DeobfuscationRegex() + { + //Regex = LoaderConfig.Current.UnityEngine.ForceGeneratorRegex; + if (string.IsNullOrEmpty(Regex)) + Regex = RemoteAPI.Info.ObfuscationRegex; + } + + internal void Setup() + { + if (string.IsNullOrEmpty(Regex)) + { + if (!string.IsNullOrEmpty(Config.Values.DeobfuscationRegex)) + { + AssemblyGenerator.AssemblyGenerationNeeded = true; + return; + } + } + else + { + if (string.IsNullOrEmpty(Config.Values.DeobfuscationRegex)) + { + AssemblyGenerator.AssemblyGenerationNeeded = true; + return; + } + if (!Config.Values.DeobfuscationRegex.Equals(Regex)) + { + AssemblyGenerator.AssemblyGenerationNeeded = true; + return; + } + } + } + + internal void Save() + { + Config.Values.DeobfuscationRegex = Regex; + Config.Save(); + } + } +} diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Il2CppInterop.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Il2CppInterop.cs new file mode 100644 index 000000000..8cb848a31 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Il2CppInterop.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using Il2CppInterop.Common; +using Il2CppInterop.Generator; +using Il2CppInterop.Generator.Runners; +using Microsoft.Extensions.Logging; +using AsmResolver.DotNet; +using AsmResolver.DotNet.Serialized; + +namespace MelonLoader.Engine.Unity.Packages +{ + internal class Il2CppInterop : Models.ExecutablePackage + { + internal Il2CppInterop(string BasePath) + { + Version = typeof(Il2CppInteropGenerator).Assembly.CustomAttributes + .Where(x => x.AttributeType.Name == "AssemblyInformationalVersionAttribute") + .Select(x => x.ConstructorArguments[0].Value.ToString()) + .FirstOrDefault(); + + Name = nameof(Il2CppInterop); + Destination = Path.Combine(BasePath, Name); + OutputFolder = Path.Combine(Destination, "Il2CppAssemblies"); + } + + internal override bool ShouldSetup() + => false; + + internal bool Execute(string GameAssemblyPath) + { + AssemblyGenerator.Logger.Msg("Reading dumped assemblies for interop generation..."); + + var resolver = new InteropResolver(); + var inputAssemblies = Directory.GetFiles(AssemblyGenerator.cpp2il.OutputFolder) + .Where(f => f.EndsWith(".dll")) + .Select(f => ModuleDefinition.FromFile(f, new ModuleReaderParameters() { ModuleResolver = resolver })) + .Select(f => { resolver.Add(f); return f; }) + .Select(f => f.Assembly) + .ToList(); + + var opts = new GeneratorOptions() + { + GameAssemblyPath = GameAssemblyPath, + Source = inputAssemblies, + OutputDir = OutputFolder, + UnityBaseLibsDir = AssemblyGenerator.unitydependencies.Destination, + ObfuscatedNamesRegex = string.IsNullOrEmpty(AssemblyGenerator.deobfuscationRegex.Regex) ? null : new Regex(AssemblyGenerator.deobfuscationRegex.Regex), + Parallel = true, + Il2CppPrefixMode = GeneratorOptions.PrefixMode.OptOut, + }; + + //Inform cecil of the unity base libs + var trusted = (string)AppDomain.CurrentDomain.GetData("TRUSTED_PLATFORM_ASSEMBLIES"); + var allUnityDlls = string.Join(Path.PathSeparator, Directory.GetFiles(AssemblyGenerator.unitydependencies.Destination, "*.dll", SearchOption.TopDirectoryOnly)); + // var allDumpedDlls = string.Join(Path.PathSeparator, Directory.GetFiles(AssemblyGenerator.dumper.OutputFolder, "*.dll", SearchOption.TopDirectoryOnly)); + AppDomain.CurrentDomain.SetData("TRUSTED_PLATFORM_ASSEMBLIES", trusted + Path.PathSeparator + allUnityDlls); + + if (!string.IsNullOrEmpty(AssemblyGenerator.deobfuscationMap.Version)) + { + AssemblyGenerator.Logger.Msg("Loading Deobfuscation Map..."); + opts.ReadRenameMap(AssemblyGenerator.deobfuscationMap.Destination); + } + + AssemblyGenerator.Logger.Msg("Generating Interop Assemblies..."); + +#if !DEBUG + try +#endif + { + Il2CppInteropGenerator.Create(opts) + .AddLogger(new InteropLogger()) + .AddInteropAssemblyGenerator() + .Run(); + } +#if !DEBUG + catch (Exception e) + { + AssemblyGenerator.Logger.Error("Error Generating Interop Assemblies!", e); + return false; + } +#endif + + AssemblyGenerator.Logger.Msg("Cleaning up..."); + AppDomain.CurrentDomain.SetData("TRUSTED_PLATFORM_ASSEMBLIES", trusted); + //inputAssemblies.ForEach(a => a.Dispose()); + + AssemblyGenerator.Logger.Msg("Interop Generation Complete!"); + return true; + } + } + + internal class InteropLogger : ILogger + { + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + { + if (logLevel is LogLevel.Debug or LogLevel.Trace) + { + MelonDebug.Msg(formatter(state, exception)); + return; + } + + AssemblyGenerator.Logger.Msg(formatter(state, exception)); + } + + public bool IsEnabled(LogLevel logLevel) + { + return logLevel switch + { + LogLevel.Debug or LogLevel.Trace => MelonDebug.IsEnabled(), + _ => true + }; + } + + public IDisposable BeginScope(TState state) + { + throw new NotImplementedException(); + } + } + + internal class InteropResolver : INetModuleResolver + { + private readonly Dictionary _cache = new(); + + public void Dispose() + { + _cache.Clear(); + } + + internal void Add(ModuleDefinition module) + { + _cache[module.Name] = module; + } + + public ModuleDefinition Resolve(string name) + { + return _cache.GetValueOrDefault(name); + } + } +} diff --git a/Dependencies/Il2CppAssemblyGenerator/Packages/Models/ExecutablePackage.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Models/ExecutablePackage.cs similarity index 90% rename from Dependencies/Il2CppAssemblyGenerator/Packages/Models/ExecutablePackage.cs rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Models/ExecutablePackage.cs index aaa2ad8be..00741c198 100644 --- a/Dependencies/Il2CppAssemblyGenerator/Packages/Models/ExecutablePackage.cs +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/Models/ExecutablePackage.cs @@ -7,7 +7,7 @@ using System.Text.RegularExpressions; using System.Threading; -namespace MelonLoader.Il2CppAssemblyGenerator.Packages.Models +namespace MelonLoader.Engine.Unity.Packages.Models { internal class ExecutablePackage : PackageBase { @@ -23,19 +23,18 @@ internal virtual void Cleanup() Directory.Delete(OutputFolder, true); } - internal virtual bool Execute() => true; internal bool Execute(string[] args, bool parenthesize_args = true, Dictionary environment = null) { Cleanup(); if (!File.Exists(ExeFilePath)) { - Core.Logger.Error($"{ExeFilePath} does not Exist!"); + AssemblyGenerator.Logger.Error($"{ExeFilePath} does not Exist!"); ThrowInternalFailure($"Failed to Execute {Name}!"); return false; } - Core.Logger.Msg($"Executing {Name}..."); + AssemblyGenerator.Logger.Msg($"Executing {Name}..."); try { #if LINUX @@ -70,7 +69,7 @@ internal bool Execute(string[] args, bool parenthesize_args = true, Dictionary true; + + internal virtual bool OnProcess() + => FileHandler.Process(FilePath, Destination, OsUtils.IsWindows ? null : Name); + + internal virtual bool Setup() + { + if (string.IsNullOrEmpty(Version) || string.IsNullOrEmpty(URL)) + return true; + + if (!ShouldSetup()) + { + AssemblyGenerator.Logger.Msg($"{Name} is up to date."); + return true; + } + + AssemblyGenerator.AssemblyGenerationNeeded = true; + + if (//!LoaderConfig.Current.UnityEngine.ForceOfflineGeneration && + ((this is DeobfuscationMap) || !File.Exists(FilePath))) + { + AssemblyGenerator.Logger.Msg($"Downloading {Name}..."); + if (!FileHandler.Download(URL, FilePath)) + { + ThrowInternalFailure($"Failed to Download {Name}!"); + return false; + } + } + + AssemblyGenerator.Logger.Msg($"Processing {Name}..."); + if (!OnProcess()) + { + ThrowInternalFailure($"Failed to Process {Name}!"); + return false; + } + + Save(); + return true; + } + + internal virtual void Save() { } + internal void Save(ref string configPref) + { + configPref = Version; + Config.Save(); + } + + internal static void ThrowInternalFailure(string txt) => MelonLogger.ThrowInternalFailure(txt); + } +} diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/UnityDependencies.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/UnityDependencies.cs new file mode 100644 index 000000000..c96679b3c --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Packages/UnityDependencies.cs @@ -0,0 +1,23 @@ +using System.IO; + +namespace MelonLoader.Engine.Unity.Packages +{ + internal class UnityDependencies : Models.PackageBase + { + internal UnityDependencies(string BasePath) + { + Name = nameof(UnityDependencies); + Version = UnityInformationHandler.EngineVersion.ToStringWithoutType(); + URL = $"https://github.com/LavaGang/MelonLoader.UnityDependencies/releases/download/{Version}/Managed.zip"; + Destination = Path.Combine(BasePath, Name); + FilePath = Path.Combine(BasePath, $"{Name}_{Version}.zip"); + } + + internal override bool ShouldSetup() + => string.IsNullOrEmpty(Config.Values.UnityVersion) + || !Config.Values.UnityVersion.Equals(Version); + + internal override void Save() + => Save(ref Config.Values.UnityVersion); + } +} diff --git a/Dependencies/Il2CppAssemblyGenerator/RemoteAPI.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/RemoteAPI.cs similarity index 81% rename from Dependencies/Il2CppAssemblyGenerator/RemoteAPI.cs rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/RemoteAPI.cs index f22b23b51..afced1b61 100644 --- a/Dependencies/Il2CppAssemblyGenerator/RemoteAPI.cs +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/RemoteAPI.cs @@ -4,9 +4,10 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.Text.RegularExpressions; +using MelonLoader.Properties; using Semver; -namespace MelonLoader.Il2CppAssemblyGenerator +namespace MelonLoader.Engine.Unity { internal static class RemoteAPI { @@ -33,7 +34,7 @@ internal HostInfo(string url, LemonFunc func) static RemoteAPI() { - string gamename = Regex.Replace(InternalUtils.UnityInformationHandler.GameName, "[^a-zA-Z0-9_.]+", "-", RegexOptions.Compiled).ToLowerInvariant(); + string gamename = Regex.Replace(UnityInformationHandler.GameName, "[^a-zA-Z0-9_.]+", "-", RegexOptions.Compiled).ToLowerInvariant(); HostList = new List { new HostInfo($"{DefaultHostInfo.Melon.API_URL}{gamename}", DefaultHostInfo.Melon.Contact), @@ -46,14 +47,14 @@ static RemoteAPI() internal static void Contact() { - Core.Logger.Msg("Contacting RemoteAPI..."); + AssemblyGenerator.Logger.Msg("Contacting RemoteAPI..."); ContactHosts(); - Core.Logger.Msg($"RemoteAPI.DumperVersion = {(string.IsNullOrEmpty(Info.ForceDumperVersion) ? "null" : Info.ForceDumperVersion)}"); - Core.Logger.Msg($"RemoteAPI.ObfuscationRegex = {(string.IsNullOrEmpty(Info.ObfuscationRegex) ? "null" : Info.ObfuscationRegex)}"); - Core.Logger.Msg($"RemoteAPI.MappingURL = {(string.IsNullOrEmpty(Info.MappingURL) ? "null" : Info.MappingURL)}"); - Core.Logger.Msg($"RemoteAPI.MappingFileSHA512 = {(string.IsNullOrEmpty(Info.MappingFileSHA512) ? "null" : Info.MappingFileSHA512)}"); + AssemblyGenerator.Logger.Msg($"RemoteAPI.DumperVersion = {(string.IsNullOrEmpty(Info.ForceDumperVersion) ? "null" : Info.ForceDumperVersion)}"); + AssemblyGenerator.Logger.Msg($"RemoteAPI.ObfuscationRegex = {(string.IsNullOrEmpty(Info.ObfuscationRegex) ? "null" : Info.ObfuscationRegex)}"); + AssemblyGenerator.Logger.Msg($"RemoteAPI.MappingURL = {(string.IsNullOrEmpty(Info.MappingURL) ? "null" : Info.MappingURL)}"); + AssemblyGenerator.Logger.Msg($"RemoteAPI.MappingFileSHA512 = {(string.IsNullOrEmpty(Info.MappingFileSHA512) ? "null" : Info.MappingFileSHA512)}"); } private static void ContactHosts() @@ -70,7 +71,7 @@ private static void ContactHosts() string Response = null; try { - var result = Core.webClient.GetAsync(info.URL).Result; + var result = AssemblyGenerator.webClient.GetAsync(info.URL).Result; result.EnsureSuccessStatusCode(); Response = result.Content.ReadAsStringAsync().Result; } @@ -78,17 +79,17 @@ private static void ContactHosts() { if (ex is not HttpRequestException {StatusCode: {}} hre) { - Core.Logger.Error($"Exception while Contacting RemoteAPI Host ({info.URL}): {ex}"); + AssemblyGenerator.Logger.Error($"Exception while Contacting RemoteAPI Host ({info.URL}): {ex}"); continue; } if (hre.StatusCode == System.Net.HttpStatusCode.NotFound) { - Core.Logger.Msg($"Game Not Found on RemoteAPI Host ({info.URL})"); + AssemblyGenerator.Logger.Msg($"Game Not Found on RemoteAPI Host ({info.URL})"); break; } - Core.Logger.Error($"WebException ({hre.StatusCode}) while Contacting RemoteAPI Host ({info.URL}): {ex}"); + AssemblyGenerator.Logger.Error($"WebException ({hre.StatusCode}) while Contacting RemoteAPI Host ({info.URL}): {ex}"); continue; } diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Unity.Il2Cpp.AssemblyGenerator.csproj b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Unity.Il2Cpp.AssemblyGenerator.csproj new file mode 100644 index 000000000..3a11fd251 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.AssemblyGenerator/Unity.Il2Cpp.AssemblyGenerator.csproj @@ -0,0 +1,31 @@ + + + MelonLoader.Unity.Il2Cpp + net6 + Latest + true + $(MLOutDir)/MelonLoader/Dependencies/Engines/Unity/ + true + embedded + MelonLoader.Unity.Il2Cpp.AssemblyGenerator + + + + False + all + + + False + False + all + + + + + + + + + + + \ No newline at end of file diff --git a/UnityUtilities/UnityEngine.Il2CppAssetBundleManager/Il2CppAssetBundle.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppAssetBundle.cs similarity index 97% rename from UnityUtilities/UnityEngine.Il2CppAssetBundleManager/Il2CppAssetBundle.cs rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppAssetBundle.cs index 366dfb888..3f1cf7abc 100644 --- a/UnityUtilities/UnityEngine.Il2CppAssetBundleManager/Il2CppAssetBundle.cs +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppAssetBundle.cs @@ -2,6 +2,7 @@ using Il2CppInterop.Runtime.InteropTypes.Arrays; using MelonLoader; using System; +using MelonLoader.Engine.Unity.Il2Cpp; namespace UnityEngine; @@ -93,10 +94,10 @@ public Il2CppStringArray GetAllScenePaths() public T LoadAsset(string name) where T : Object { - if (!InteropSupport.IsGeneratedAssemblyType(typeof(T))) + if (!typeof(T).IsGeneratedAssemblyType()) throw new NullReferenceException("The type must be a Generated Assembly Type."); var intptr = LoadAsset(name, Il2CppType.Of().Pointer); - return ((intptr != IntPtr.Zero) ? InteropSupport.Il2CppObjectPtrToIl2CppObject(intptr) : null); + return ((intptr != IntPtr.Zero) ? intptr.Il2CppObjectPtrToIl2CppObject() : null); } public Object Load(string name, Il2CppSystem.Type type) => LoadAsset(name, type); @@ -128,7 +129,7 @@ public IntPtr LoadAsset(string name, IntPtr typeptr) public Il2CppAssetBundleRequest LoadAssetAsync(string name) where T : Object { - if (!InteropSupport.IsGeneratedAssemblyType(typeof(T))) + if (!typeof(T).IsGeneratedAssemblyType()) throw new NullReferenceException("The type must be a Generated Assembly Type."); var intptr = LoadAssetAsync(name, Il2CppType.Of().Pointer); return ((intptr != IntPtr.Zero) ? new Il2CppAssetBundleRequest(intptr) : null); @@ -163,7 +164,7 @@ public IntPtr LoadAssetAsync(string name, IntPtr typeptr) public Il2CppReferenceArray LoadAllAssets() where T : Object { - if (!InteropSupport.IsGeneratedAssemblyType(typeof(T))) + if (!typeof(T).IsGeneratedAssemblyType()) throw new NullReferenceException("The type must be a Generated Assembly Type."); var intptr = LoadAllAssets(Il2CppType.Of().Pointer); return ((intptr != IntPtr.Zero) ? new Il2CppReferenceArray(intptr) : null); @@ -194,7 +195,7 @@ public IntPtr LoadAllAssets(IntPtr typeptr) public Il2CppReferenceArray LoadAssetWithSubAssets(string name) where T : Object { - if (!InteropSupport.IsGeneratedAssemblyType(typeof(T))) + if (!typeof(T).IsGeneratedAssemblyType()) throw new NullReferenceException("The type must be a Generated Assembly Type."); var intptr = LoadAssetWithSubAssets(name, Il2CppType.Of().Pointer); return ((intptr != IntPtr.Zero) ? new Il2CppReferenceArray(intptr) : null); @@ -224,7 +225,7 @@ public IntPtr LoadAssetWithSubAssets(string name, IntPtr typeptr) public Il2CppAssetBundleRequest LoadAssetWithSubAssetsAsync(string name) where T : Object { - if (!InteropSupport.IsGeneratedAssemblyType(typeof(T))) + if (!typeof(T).IsGeneratedAssemblyType()) throw new NullReferenceException("The type must be a Generated Assembly Type."); var intptr = LoadAssetWithSubAssetsAsync(name, Il2CppType.Of().Pointer); return ((intptr != IntPtr.Zero) ? new Il2CppAssetBundleRequest(intptr) : null); diff --git a/UnityUtilities/UnityEngine.Il2CppAssetBundleManager/Il2CppAssetBundleManager.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppAssetBundleManager.cs similarity index 100% rename from UnityUtilities/UnityEngine.Il2CppAssetBundleManager/Il2CppAssetBundleManager.cs rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppAssetBundleManager.cs diff --git a/UnityUtilities/UnityEngine.Il2CppAssetBundleManager/Il2CppAssetBundleRequest.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppAssetBundleRequest.cs similarity index 100% rename from UnityUtilities/UnityEngine.Il2CppAssetBundleManager/Il2CppAssetBundleRequest.cs rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppAssetBundleRequest.cs diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppEnumeratorWrapper.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppEnumeratorWrapper.cs new file mode 100644 index 000000000..bf696a28d --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppEnumeratorWrapper.cs @@ -0,0 +1,55 @@ +using Il2CppInterop.Runtime.Injection; +using System; +using System.Collections; + +namespace MelonLoader.Engine.Unity.Il2Cpp +{ + public class Il2CppEnumeratorWrapper : Il2CppSystem.Object /*, IEnumerator */ + { + internal unsafe static void Register() + => ClassInjector.RegisterTypeInIl2Cpp(new() + { + LogSuccess = true, + Interfaces = new Type[] { typeof(Il2CppSystem.Collections.IEnumerator) } + }); + + private readonly IEnumerator enumerator; + public Il2CppEnumeratorWrapper(IntPtr ptr) : base(ptr) { } + public Il2CppEnumeratorWrapper(IEnumerator _enumerator) : base(ClassInjector.DerivedConstructorPointer()) + { + ClassInjector.DerivedConstructorBody(this); + enumerator = _enumerator ?? throw new NullReferenceException("routine is null"); + } + + public Il2CppSystem.Object /*IEnumerator.*/Current + { + get => enumerator.Current switch + { + IEnumerator next => new Il2CppEnumeratorWrapper(next), + Il2CppSystem.Object il2cppObject => il2cppObject, + null => null, + _ => throw new NotSupportedException($"{enumerator.GetType()}: Unsupported type {enumerator.Current.GetType()}"), + }; + } + + public bool MoveNext() + { + try + { + return enumerator.MoveNext(); + } catch(Exception e) + { + var melon = MelonUtils.GetMelonFromStackTrace(new System.Diagnostics.StackTrace(e), true); + + if (melon != null) + melon.LoggerInstance.Error("Unhandled exception in coroutine. It will not continue executing.", e); + else + MelonLogger.Error("[Error: Could not identify source] Unhandled exception in coroutine. It will not continue executing.", e); + + return false; + } + } + + public void Reset() => enumerator.Reset(); + } +} diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppExtensions.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppExtensions.cs new file mode 100644 index 000000000..40343971c --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppExtensions.cs @@ -0,0 +1,81 @@ +using Il2CppInterop.Common; +using Il2CppInterop.Common.Attributes; +using Il2CppInterop.Runtime; +using Il2CppInterop.Runtime.Injection; +using Il2CppInterop.Runtime.InteropTypes; +using System; +using System.Collections; +using System.Reflection; +using UnityEngine; + +namespace MelonLoader.Engine.Unity.Il2Cpp +{ + public static class Il2CppExtensions + { + #region Coroutine + + public static Coroutine StartCoroutine(this T behaviour, IEnumerator enumerator) + where T : MonoBehaviour + => behaviour.StartCoroutine( + new Il2CppSystem.Collections.IEnumerator( + new Il2CppEnumeratorWrapper(enumerator).Pointer)); + + public static void StopCoroutine(this T behaviour, Coroutine routine) + where T : MonoBehaviour + => behaviour.StopCoroutine(routine); + + #endregion + + #region Interop + + public static int? GetIl2CppMethodCallerCount(this MethodBase method) + { + CallerCountAttribute att = method.GetCustomAttribute(); + if (att == null) + return null; + return att.Count; + } + + public static FieldInfo MethodBaseToIl2CppFieldInfo(this MethodBase method) + => Il2CppInteropUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(method); + + public static void RegisterTypeInIl2CppDomain(this Type type, bool logSuccess) + => ClassInjector.RegisterTypeInIl2Cpp(type, new() { LogSuccess = logSuccess }); + public static void RegisterTypeInIl2CppDomainWithInterfaces(this Type type, Type[] interfaces, bool logSuccess) + => ClassInjector.RegisterTypeInIl2Cpp(type, new() { LogSuccess = logSuccess, Interfaces = interfaces }); + + public static bool IsGeneratedAssemblyType(this Type type) + => type.IsInheritedFromIl2CppObjectBase() && !type.IsInjectedType(); + + public static bool IsInheritedFromIl2CppObjectBase(this Type type) + => (type != null) && type.IsSubclassOf(typeof(Il2CppObjectBase)); + + public static bool IsInjectedType(this Type type) + { + IntPtr ptr = GetClassPointerForType(type); + return ptr != IntPtr.Zero && RuntimeSpecificsStore.IsInjected(ptr); + } + + public static IntPtr GetClassPointerForType(this Type type) + { + if (type == typeof(void)) return Il2CppClassPointerStore.NativeClassPtr; + return (IntPtr)typeof(Il2CppClassPointerStore<>).MakeGenericType(type) + .GetField(nameof(Il2CppClassPointerStore.NativeClassPtr)).GetValue(null); + } + + public static T Il2CppObjectPtrToIl2CppObject(this IntPtr ptr) + { + if (ptr == IntPtr.Zero) + throw new NullReferenceException("The ptr cannot be IntPtr.Zero."); + if (!IsGeneratedAssemblyType(typeof(T))) + throw new NullReferenceException("The type must be a Generated Assembly Type."); + return (T)typeof(T).GetConstructor(BindingFlags.Public | BindingFlags.Instance, + null, + [typeof(IntPtr)], + Array.Empty()) + .Invoke([ptr]); + } + + #endregion + } +} diff --git a/UnityUtilities/UnityEngine.Il2CppImageConversionManager/Il2CppImageConversionManager.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppImageConversionManager.cs similarity index 100% rename from UnityUtilities/UnityEngine.Il2CppImageConversionManager/Il2CppImageConversionManager.cs rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Il2CppImageConversionManager.cs diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Unity.Il2Cpp.Shared.csproj b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Unity.Il2Cpp.Shared.csproj new file mode 100644 index 000000000..38baba2af --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp.Shared/Unity.Il2Cpp.Shared.csproj @@ -0,0 +1,48 @@ + + + MelonLoader.Unity.Il2Cpp + net6 + Latest + true + $(MLOutDir)/MelonLoader/Dependencies/Engines/Unity/ + true + embedded + true + MelonLoader.Unity.Il2Cpp.Shared + + + + + + + + ..\Libs\Il2Cppmscorlib.dll + false + + + ..\Libs\Il2CppSystem.dll + false + + + ..\Libs\UnityEngine.CoreModule.dll + false + + + + + False + + + False + + + + + + + + + + + + \ No newline at end of file diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppCoroutineInterop.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppCoroutineInterop.cs new file mode 100644 index 000000000..22324ea26 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppCoroutineInterop.cs @@ -0,0 +1,30 @@ +using System.Collections; +using UnityEngine; + +namespace MelonLoader.Engine.Unity.Il2Cpp +{ + internal class Il2CppCoroutineInterop : MelonCoroutineInterop + { + private Il2CppSupportComponent Component; + + internal Il2CppCoroutineInterop(Il2CppSupportComponent component) + => Component = component; + + public override object Start(IEnumerator coroutine) + { + if (Component != null) + return Component.StartCoroutine(new Il2CppSystem.Collections.IEnumerator(new Il2CppEnumeratorWrapper(coroutine).Pointer)); + + MelonCoroutines.Queue(coroutine); + return coroutine; + } + + public override void Stop(object coroutineToken) + { + if (Component != null) + Component.StopCoroutine(coroutineToken as Coroutine); + else + MelonCoroutines.Dequeue(coroutineToken); + } + } +} diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppDetourProvider.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppDetourProvider.cs new file mode 100644 index 000000000..dbf159d68 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppDetourProvider.cs @@ -0,0 +1,80 @@ +using Il2CppInterop.Runtime.Injection; +using MelonLoader.CoreClrUtils; +using MelonLoader.InternalUtils; +using System; +using System.Runtime.InteropServices; + +namespace MelonLoader.Engine.Unity.Il2Cpp +{ + internal sealed class Il2CppDetourProvider : IDetourProvider + { + public IDetour Create(nint original, TDelegate target) where TDelegate : Delegate + { + return new MelonDetour(original, target); + } + + private sealed class MelonDetour : IDetour + { + private nint _detourFrom; + private nint _originalPtr; + + private Delegate _target; + private IntPtr _targetPtr; + + /// + /// Original method + /// + public nint Target => _detourFrom; + + public nint Detour => _targetPtr; + public nint OriginalTrampoline => _originalPtr; + + public MelonDetour(nint detourFrom, Delegate target) + { + _detourFrom = detourFrom; + _target = target; + + // We have to apply immediately because we're gonna be asked for a trampoline right away + Apply(); + } + + public unsafe void Apply() + { + if (_targetPtr != IntPtr.Zero) + return; + + _targetPtr = Marshal.GetFunctionPointerForDelegate(_target); + + var addr = _detourFrom; + nint addrPtr = (nint)(&addr); + BootstrapInterop.NativeHookAttachDirect(addrPtr, _targetPtr); + NativeStackWalk.RegisterHookAddr((ulong)addrPtr, $"Il2CppInterop detour of 0x{addrPtr:X} -> 0x{_targetPtr:X}"); + + _originalPtr = addr; + } + + public unsafe void Dispose() + { + if (_targetPtr == IntPtr.Zero) + return; + + var addr = _detourFrom; + nint addrPtr = (nint)(&addr); + + BootstrapInterop.NativeHookDetach(addrPtr, _targetPtr); + NativeStackWalk.UnregisterHookAddr((ulong)addrPtr); + + _targetPtr = IntPtr.Zero; + _originalPtr = IntPtr.Zero; + } + + public T GenerateTrampoline() + where T : Delegate + { + if (_originalPtr == IntPtr.Zero) + return null; + return Marshal.GetDelegateForFunctionPointer(_originalPtr); + } + } + } +} diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppICallInjector.cs similarity index 84% rename from MelonLoader/Fixes/Il2CppICallInjector.cs rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppICallInjector.cs index 7c4e00a4f..9b08df113 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppICallInjector.cs @@ -9,20 +9,17 @@ using System.Runtime.InteropServices; using Il2CppInterop.HarmonySupport; using HarmonyLib; +using MelonLoader.Runtime.Il2Cpp; #pragma warning disable 0649 -namespace MelonLoader.Fixes +namespace MelonLoader.Engine.Unity.Il2Cpp { - internal static class Il2CppICallInjector + public static class Il2CppICallInjector { private static Dictionary _lookup = new(); - private delegate IntPtr dil2cpp_resolve_icall(IntPtr signature); - private static NativeHook il2cpp_resolve_icall_hook; - - private delegate void dil2cpp_add_internal_call(IntPtr signature, IntPtr funcPtr); - private static dil2cpp_add_internal_call il2cpp_add_internal_call; + private static MelonNativeHook il2cpp_resolve_icall_hook; private static Type _il2CppDetourMethodPatcher; private static MethodInfo _generateNativeToManagedTrampoline; @@ -30,7 +27,7 @@ internal static class Il2CppICallInjector private static bool _extendedDebug; private static MelonLogger.Instance _logger; - internal static unsafe void Install() + public static unsafe void Install() { try { @@ -44,22 +41,9 @@ internal static unsafe void Install() if (_generateNativeToManagedTrampoline == null) throw new Exception("Failed to get Il2CppDetourMethodPatcher.GenerateNativeToManagedTrampoline"); - string gameAssemblyName = "GameAssembly"; - NativeLibrary gameAssemblyLib = NativeLibrary.Load(gameAssemblyName); - if (gameAssemblyLib == null) - throw new Exception($"Failed to load {gameAssemblyName} Native Library"); - - IntPtr il2cpp_resolve_icall = gameAssemblyLib.GetExport(nameof(il2cpp_resolve_icall)); - if (il2cpp_resolve_icall == IntPtr.Zero) - throw new Exception($"Failed to get {nameof(il2cpp_resolve_icall)} Native Export"); - - il2cpp_add_internal_call = gameAssemblyLib.GetExport(nameof(il2cpp_add_internal_call)); - if (il2cpp_add_internal_call == null) - throw new Exception($"Failed to get {nameof(il2cpp_add_internal_call)} Native Export"); - MelonDebug.Msg("Patching il2cpp_resolve_icall..."); - IntPtr detourPtr = Marshal.GetFunctionPointerForDelegate((dil2cpp_resolve_icall)il2cpp_resolve_icall_Detour); - il2cpp_resolve_icall_hook = new NativeHook(il2cpp_resolve_icall, detourPtr); + IntPtr detourPtr = Marshal.GetFunctionPointerForDelegate((Il2CppLibrary.dil2cpp_resolve_icall)il2cpp_resolve_icall_Detour); + il2cpp_resolve_icall_hook = new MelonNativeHook(Marshal.GetFunctionPointerForDelegate(Il2CppLibrary.Instance.il2cpp_resolve_icall), detourPtr); il2cpp_resolve_icall_hook.Attach(); } catch (Exception e) @@ -68,7 +52,7 @@ internal static unsafe void Install() } } - internal static void Shutdown() + public static void Shutdown() { if (il2cpp_resolve_icall_hook != null) { @@ -146,7 +130,7 @@ private static IntPtr il2cpp_resolve_icall_Detour(IntPtr signature) // Add New ICall to Il2Cpp Domain _lookup[signatureStr] = pair; - il2cpp_add_internal_call(signature, pair.Item4); + Il2CppLibrary.Instance.il2cpp_add_internal_call(signature, pair.Item4); LogMsg($"Registered mono icall {signatureStr} in il2cpp domain"); // Return New Function Pointer diff --git a/MelonLoader/Fixes/Il2CppInteropFixes.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppInteropFixes.cs similarity index 98% rename from MelonLoader/Fixes/Il2CppInteropFixes.cs rename to Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppInteropFixes.cs index c94fc0351..7684193db 100644 --- a/MelonLoader/Fixes/Il2CppInteropFixes.cs +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppInteropFixes.cs @@ -21,16 +21,18 @@ #pragma warning disable CS8632 -namespace MelonLoader.Fixes +namespace MelonLoader.Engine.Unity.Il2Cpp { // fixes: https://github.com/BepInEx/Il2CppInterop/pull/103 // fixes: https://github.com/BepInEx/Il2CppInterop/issues/135 // reverts: https://github.com/BepInEx/Il2CppInterop/commit/18e58ef5db42a71d6012ab0387b107a4132101eb // fixes the rest of: https://github.com/BepInEx/Il2CppInterop/pull/134 - internal unsafe static class Il2CppInteropFixes + public unsafe static class Il2CppInteropFixes { private static MelonLogger.Instance _logger = new("Il2CppInterop"); + private static string _asmFolder; + private static Dictionary> _assemblyLookup = new(); private static Dictionary _typeLookup = new(); private static Dictionary _typeNameLookup = new(); @@ -80,8 +82,10 @@ private static void LogDebugMsg(string msg) _logger.Msg(msg); } - internal static void Install() + public static void Install(string assembliesPath) { + _asmFolder = assembliesPath; + try { Type typeType = typeof(Type); @@ -488,9 +492,9 @@ private static bool SystemTypeFromIl2CppType_Prefix(Il2CppTypeStruct* __0, ref T if (string.IsNullOrEmpty(fileNameStr)) return true; - string il2cppAssemblyPath = Path.Combine(MelonEnvironment.Il2CppAssembliesDirectory, fileNameStr); + string il2cppAssemblyPath = Path.Combine(_asmFolder, fileNameStr); if (!File.Exists(il2cppAssemblyPath)) - il2cppAssemblyPath = Path.Combine(MelonEnvironment.Il2CppAssembliesDirectory, $"Il2Cpp{fileNameStr}"); + il2cppAssemblyPath = Path.Combine(_asmFolder, $"Il2Cpp{fileNameStr}"); if (File.Exists(il2cppAssemblyPath)) { Assembly asm = Assembly.LoadFrom(il2cppAssemblyPath); diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppLogProvider.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppLogProvider.cs new file mode 100644 index 000000000..08b6ea263 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppLogProvider.cs @@ -0,0 +1,46 @@ +using Microsoft.Extensions.Logging; +using System; + +namespace MelonLoader.Engine.Unity.Il2Cpp +{ + internal class Il2CppLogProvider : ILogger + { + private MelonLogger.Instance _logger = new("Il2CppInterop"); + + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, + Func formatter) + { + string formattedTxt = formatter(state, exception); + switch (logLevel) + { + case LogLevel.Debug: + case LogLevel.Trace: + MelonDebug.Msg(formattedTxt); + break; + + case LogLevel.Error: + _logger.Error(formattedTxt); + break; + + case LogLevel.Warning: + _logger.Warning(formattedTxt); + break; + + case LogLevel.Information: + default: + _logger.Msg(formattedTxt); + break; + } + } + + public bool IsEnabled(LogLevel logLevel) + => logLevel switch + { + LogLevel.Debug or LogLevel.Trace => MelonDebug.IsEnabled(), + _ => true + }; + + public IDisposable BeginScope(TState state) + => throw new NotImplementedException(); + } +} diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppSceneHandler.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppSceneHandler.cs new file mode 100644 index 000000000..c9e8e9dbd --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppSceneHandler.cs @@ -0,0 +1,117 @@ +using System; +using UnityEngine.SceneManagement; +using System.Collections.Generic; +using UnityEngine.Events; + +namespace MelonLoader.Engine.Unity.Il2Cpp +{ + internal class Il2CppSceneHandler : IDisposable + { + private Il2CppSupportModule SupportModule; + + internal class SceneInitEvent + { + internal int buildIndex; + internal string name; + internal bool wasLoadedThisTick; + } + private Queue scenesLoaded = new Queue(); + + internal Il2CppSceneHandler(Il2CppSupportModule supportModule) + { + SupportModule = supportModule; + + try + { + SceneManager.sceneLoaded = ( + (ReferenceEquals(SceneManager.sceneLoaded, null)) + ? new Action(OnSceneLoad) + : Il2CppSystem.Delegate.Combine(SceneManager.sceneLoaded, (UnityAction)OnSceneLoad).Cast>() + ); + } + catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneLoaded override failed: {ex}"); } + + try + { + SceneManager.sceneUnloaded = ( + (ReferenceEquals(SceneManager.sceneUnloaded, null)) + ? new Action(OnSceneUnload) + : Il2CppSystem.Delegate.Combine(SceneManager.sceneUnloaded, (UnityAction)OnSceneUnload).Cast>() + ); + } + catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneUnloaded override failed: {ex}"); } + } + + ~Il2CppSceneHandler() + => Dispose(); + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2013:Do not use ReferenceEquals with value types")] + public void Dispose() + { + try + { + SceneManager.sceneLoaded = ( + (ReferenceEquals(SceneManager.sceneLoaded, null)) + ? null + : Il2CppSystem.Delegate.Remove(SceneManager.sceneLoaded, (UnityAction)OnSceneLoad).Cast>() + ); + } + catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneLoaded override failed: {ex}"); } + + try + { + SceneManager.sceneUnloaded = ( + (ReferenceEquals(SceneManager.sceneUnloaded, null)) + ? null + : Il2CppSystem.Delegate.Remove(SceneManager.sceneUnloaded, (UnityAction)OnSceneUnload).Cast>() + ); + } + catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneUnloaded override failed: {ex}"); } + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2013:Do not use ReferenceEquals with value types")] + private void OnSceneLoad(Scene scene, LoadSceneMode mode) + { + if (SupportModule.obj == null) + SupportModule.CreateGameObject(); + + if (ReferenceEquals(scene, null)) + return; + + MelonUnityEvents.OnSceneWasLoaded.Invoke(scene.buildIndex, scene.name); + scenesLoaded.Enqueue(new SceneInitEvent { buildIndex = scene.buildIndex, name = scene.name }); + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2013:Do not use ReferenceEquals with value types")] + private void OnSceneUnload(Scene scene) + { + if (ReferenceEquals(scene, null)) + return; + + MelonUnityEvents.OnSceneWasUnloaded.Invoke(scene.buildIndex, scene.name); + } + + internal void OnUpdate() + { + if (scenesLoaded.Count > 0) + { + Queue requeue = new Queue(); + SceneInitEvent evt = null; + while ((scenesLoaded.Count > 0) && ((evt = scenesLoaded.Dequeue()) != null)) + { + if (evt.wasLoadedThisTick) + { + MelonUnityEvents.OnSceneWasInitialized.Invoke(evt.buildIndex, evt.name); + } + else + { + evt.wasLoadedThisTick = true; + requeue.Enqueue(evt); + } + } + while ((requeue.Count > 0) && ((evt = requeue.Dequeue()) != null)) + scenesLoaded.Enqueue(evt); + } + } + } +} diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppSupportComponent.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppSupportComponent.cs new file mode 100644 index 000000000..8b036ee7b --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppSupportComponent.cs @@ -0,0 +1,161 @@ +using System; +using System.Reflection; +using UnityEngine; +using Il2CppInterop.Runtime; +using MelonLoader.Modules; +using Il2CppInterop.Runtime.Attributes; + +namespace MelonLoader.Engine.Unity.Il2Cpp +{ + internal class Il2CppSupportComponent : MonoBehaviour + { + private bool isQuitting; + private bool hadError; + private bool useGeneratedAssembly = true; + + private delegate bool SetAsLastSiblingDelegate(IntPtr transformptr); + private SetAsLastSiblingDelegate SetAsLastSiblingDelegateField; + private MethodInfo SetAsLastSiblingMethod; + + public Il2CppSupportComponent(IntPtr value) : base(value) { } + + [HideFromIl2Cpp] + private void LogError(string cat, Exception ex) + { + hadError = true; + useGeneratedAssembly = false; + MelonLogger.Warning($"Exception while {cat}: {ex}"); + MelonLogger.Warning("Melon Events might run before some MonoBehaviour Events"); + } + + internal void SiblingFix() + { + if (hadError) + return; + + try + { + if (useGeneratedAssembly) + { + gameObject.transform.SetAsLastSibling(); + transform.SetAsLastSibling(); + return; + } + +#if SM_Il2Cpp + SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(gameObject.transform)); + SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(transform)); +#endif + } + catch (Exception ex) + { +#if SM_Il2Cpp + if (useGeneratedAssembly) + { + useGeneratedAssembly = false; + SiblingFix(); + return; + } +#endif + + LogError("Invoking UnityEngine.Transform::SetAsLastSibling", ex); + } + } + + void Start() + { + try + { + SetAsLastSiblingMethod = typeof(Transform).GetMethod("SetAsLastSibling", BindingFlags.Public | BindingFlags.Instance); + if (SetAsLastSiblingMethod != null) + return; + + useGeneratedAssembly = false; + SetAsLastSiblingDelegateField = IL2CPP.ResolveICall("UnityEngine.Transform::SetAsLastSibling"); + if (SetAsLastSiblingDelegateField == null) + throw new Exception("Unable to find Internal Call for UnityEngine.Transform::SetAsLastSibling"); + } + catch (Exception ex) { LogError("Getting UnityEngine.Transform::SetAsLastSibling", ex); } + + if ((ModuleInterop.Support == null) || (((Il2CppSupportModule)ModuleInterop.Support).component != this)) + return; + + SiblingFix(); + + MelonUnityEvents.OnApplicationLateStart.Invoke(); + } + + void Awake() + { + if ((ModuleInterop.Support == null) || (((Il2CppSupportModule)ModuleInterop.Support).component != this)) + return; + + MelonCoroutines.ProcessQueue(); + } + + void Update() + { + if ((ModuleInterop.Support == null) || (((Il2CppSupportModule)ModuleInterop.Support).component != this)) + return; + + isQuitting = false; + SiblingFix(); + + ((Il2CppSupportModule)ModuleInterop.Support).sceneHandler.OnUpdate(); + + MelonUnityEvents.OnUpdate.Invoke(); + } + + void OnDestroy() + { + if ((ModuleInterop.Support == null) || (((Il2CppSupportModule)ModuleInterop.Support).component != this)) + return; + + if (!isQuitting) + { + ((Il2CppSupportModule)ModuleInterop.Support).CreateGameObject(); + return; + } + + OnApplicationDefiniteQuit(); + } + + void OnApplicationQuit() + { + if ((ModuleInterop.Support == null) || (((Il2CppSupportModule)ModuleInterop.Support).component != this)) + return; + + isQuitting = true; + MelonUnityEvents.OnApplicationQuit.Invoke(); + } + + void OnApplicationDefiniteQuit() + { + MelonUnityEvents.OnApplicationDefiniteQuit.Invoke(); + } + + void FixedUpdate() + { + if ((ModuleInterop.Support == null) || (((Il2CppSupportModule)ModuleInterop.Support).component != this)) + return; + + MelonUnityEvents.OnFixedUpdate.Invoke(); + } + + void LateUpdate() + { + if ((ModuleInterop.Support == null) || (((Il2CppSupportModule)ModuleInterop.Support).component != this)) + return; + + MelonUnityEvents.OnLateUpdate.Invoke(); + } + + void OnGUI() + { + if ((ModuleInterop.Support == null) || (((Il2CppSupportModule)ModuleInterop.Support).component != this)) + return; + + MelonUnityEvents.OnGUI.Invoke(); + } + } +} diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppSupportModule.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppSupportModule.cs new file mode 100644 index 000000000..50fa857e6 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppSupportModule.cs @@ -0,0 +1,124 @@ +using Il2CppInterop.Common; +using Il2CppInterop.HarmonySupport; +using Il2CppInterop.Runtime; +using Il2CppInterop.Runtime.Injection; +using Il2CppInterop.Runtime.Startup; +using MelonLoader.Modules; +using System; +using System.Reflection; +using UnityEngine; + +namespace MelonLoader.Engine.Unity.Il2Cpp +{ + internal class Il2CppSupportModule : MelonSupportModule + { + internal Il2CppSceneHandler sceneHandler; + + internal GameObject obj; + internal Il2CppSupportComponent component; + + private Assembly Il2Cppmscorlib; + private Type streamType; + + private Il2CppInteropRuntime runtime; + + public override void Initialize() + { + // Initialize Tomlet Unity Object Serialization + Il2CppTomletProvider.Initialize(); + + // Create Il2CppInterop Runtime + runtime = Il2CppInteropRuntime.Create(new() + { + DetourProvider = new Il2CppDetourProvider(), + UnityVersion = new Version( + UnityInformationHandler.EngineVersion.Major, + UnityInformationHandler.EngineVersion.Minor, + UnityInformationHandler.EngineVersion.Build) + }).AddLogger(new Il2CppLogProvider()) + .AddHarmonySupport(); + + //if (!LoaderConfig.Current.UnityEngine.DisableConsoleLogCleaner) + ConsoleCleaner(); + + // Register Custom Types + ClassInjector.RegisterTypeInIl2Cpp(); + Il2CppEnumeratorWrapper.Register(); + + // Create Scene Handler + sceneHandler = new(this); + + // Create GameObject and Component + if (component == null) + CreateGameObject(); + + // Start Il2CppInterop Runtime + runtime.Start(); + } + + internal void CreateGameObject() + { + // Create Support GameObject + obj = new GameObject(); + GameObject.DontDestroyOnLoad(obj); + obj.hideFlags = HideFlags.DontSave; + + // Create Support Component + component = obj.AddComponent(Il2CppType.Of()).TryCast(); + component.SiblingFix(); + + // Create Interop for Coroutine Management + MelonCoroutines.Interop = new Il2CppCoroutineInterop(component); + } + + private void ConsoleCleaner() + { + // Il2CppSystem.Console.SetOut(new Il2CppSystem.IO.StreamWriter(Il2CppSystem.IO.Stream.Null)); + try + { + Il2Cppmscorlib = Assembly.Load("Il2Cppmscorlib"); + if (Il2Cppmscorlib == null) + throw new Exception("Unable to Find Assembly Il2Cppmscorlib!"); + + streamType = Il2Cppmscorlib.GetType("Il2CppSystem.IO.Stream"); + if (streamType == null) + throw new Exception("Unable to Find Type Il2CppSystem.IO.Stream!"); + + PropertyInfo propertyInfo = streamType.GetProperty("Null", BindingFlags.Static | BindingFlags.Public); + if (propertyInfo == null) + throw new Exception("Unable to Find Property Il2CppSystem.IO.Stream.Null!"); + + MethodInfo nullStreamField = propertyInfo.GetGetMethod(); + if (nullStreamField == null) + throw new Exception("Unable to Find Get Method of Property Il2CppSystem.IO.Stream.Null!"); + + object nullStream = nullStreamField.Invoke(null, new object[0]); + if (nullStream == null) + throw new Exception("Unable to Get Value of Property Il2CppSystem.IO.Stream.Null!"); + + Type streamWriterType = Il2Cppmscorlib.GetType("Il2CppSystem.IO.StreamWriter"); + if (streamWriterType == null) + throw new Exception("Unable to Find Type Il2CppSystem.IO.StreamWriter!"); + + ConstructorInfo streamWriterCtor = streamWriterType.GetConstructor(new[] { streamType }); + if (streamWriterCtor == null) + throw new Exception("Unable to Find Constructor of Type Il2CppSystem.IO.StreamWriter!"); + + object nullStreamWriter = streamWriterCtor.Invoke(new[] { nullStream }); + if (nullStreamWriter == null) + throw new Exception("Unable to Invoke Constructor of Type Il2CppSystem.IO.StreamWriter!"); + + Type consoleType = Il2Cppmscorlib.GetType("Il2CppSystem.Console"); + if (consoleType == null) + throw new Exception("Unable to Find Type Il2CppSystem.Console!"); + + MethodInfo setOutMethod = consoleType.GetMethod("SetOut", BindingFlags.Static | BindingFlags.Public); + if (setOutMethod == null) + throw new Exception("Unable to Find Method Il2CppSystem.Console.SetOut!"); + + setOutMethod.Invoke(null, new[] { nullStreamWriter }); + } + catch (Exception ex) { MelonLogger.Warning($"Console Cleaner Failed: {ex}"); } + } + } +} diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppTomletProvider.cs b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppTomletProvider.cs new file mode 100644 index 000000000..8bb862694 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Il2CppTomletProvider.cs @@ -0,0 +1,103 @@ +using Tomlet; +using Tomlet.Models; +using UnityEngine; + +namespace MelonLoader.Engine.Unity.Il2Cpp +{ + internal static class Il2CppTomletProvider + { + internal static void Initialize() + { + TomletMain.RegisterMapper(WriteColor, ReadColor); + TomletMain.RegisterMapper(WriteColor32, ReadColor32); + TomletMain.RegisterMapper(WriteVector2, ReadVector2); + TomletMain.RegisterMapper(WriteVector3, ReadVector3); + TomletMain.RegisterMapper(WriteVector4, ReadVector4); + TomletMain.RegisterMapper(WriteQuaternion, ReadQuaternion); + } + + private static Color ReadColor(TomlValue value) + { + float[] floats = MelonPreferences.Mapper.ReadArray(value); + if (floats == null || floats.Length != 4) + return default; + return new Color(floats[0] / 255f, floats[1] / 255f, floats[2] / 255f, floats[3] / 255f); + } + + private static TomlValue WriteColor(Color value) + { + float[] floats = new[] { value.r * 255, value.g * 255, value.b * 255, value.a * 255}; + return MelonPreferences.Mapper.WriteArray(floats); + } + + private static Color32 ReadColor32(TomlValue value) + { + byte[] bytes = MelonPreferences.Mapper.ReadArray(value); + if (bytes == null || bytes.Length != 4) + return default; + return new Color32(bytes[0], bytes[1], bytes[2], bytes[3]); + } + + private static TomlValue WriteColor32(Color32 value) + { + byte[] bytes = new[] { value.r, value.g, value.b, value.a }; + return MelonPreferences.Mapper.WriteArray(bytes); + } + + private static Vector2 ReadVector2(TomlValue value) + { + float[] floats = MelonPreferences.Mapper.ReadArray(value); + if (floats == null || floats.Length != 2) + return default; + return new Vector2(floats[0], floats[1]); + } + + private static TomlValue WriteVector2(Vector2 value) + { + float[] floats = new[] { value.x, value.y }; + return MelonPreferences.Mapper.WriteArray(floats); + } + + private static Vector3 ReadVector3(TomlValue value) + { + float[] floats = MelonPreferences.Mapper.ReadArray(value); + if (floats == null || floats.Length != 3) + return default; + return new Vector3(floats[0], floats[1], floats[2]); + } + + private static TomlValue WriteVector3(Vector3 value) + { + float[] floats = new[] { value.x, value.y, value.z }; + return MelonPreferences.Mapper.WriteArray(floats); + } + + private static Vector4 ReadVector4(TomlValue value) + { + float[] floats = MelonPreferences.Mapper.ReadArray(value); + if (floats == null || floats.Length != 4) + return default; + return new Vector4(floats[0], floats[1], floats[2], floats[3]); + } + + private static TomlValue WriteVector4(Vector4 value) + { + float[] floats = new[] { value.x, value.y, value.z, value.w }; + return MelonPreferences.Mapper.WriteArray(floats); + } + + private static Quaternion ReadQuaternion(TomlValue value) + { + float[] floats = MelonPreferences.Mapper.ReadArray(value); + if (floats == null || floats.Length != 4) + return default; + return new Quaternion(floats[0], floats[1], floats[2], floats[3]); + } + + private static TomlValue WriteQuaternion(Quaternion value) + { + float[] floats = new[] { value.x, value.y, value.z, value.w }; + return MelonPreferences.Mapper.WriteArray(floats); + } + } +} \ No newline at end of file diff --git a/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Unity.Il2Cpp.csproj b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Unity.Il2Cpp.csproj new file mode 100644 index 000000000..388787d51 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Il2Cpp/Unity.Il2Cpp/Unity.Il2Cpp.csproj @@ -0,0 +1,54 @@ + + + MelonLoader.Unity.Il2Cpp + net6 + Latest + true + $(MLOutDir)/MelonLoader/Dependencies/Engines/Unity/ + true + embedded + MelonLoader.Unity.Il2Cpp + + + + False + + + False + + + False + + + False + + + + + ..\Libs\Il2Cppmscorlib.dll + false + + + ..\Libs\Il2CppSystem.dll + false + + + ..\Libs\UnityEngine.CoreModule.dll + false + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Dependencies/SupportModules/Mono/Libs/UnityEngine.dll b/Dependencies/Modules/Engines/Unity/Mono/Libs/UnityEngine.dll similarity index 100% rename from Dependencies/SupportModules/Mono/Libs/UnityEngine.dll rename to Dependencies/Modules/Engines/Unity/Mono/Libs/UnityEngine.dll diff --git a/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoCoroutineInterop.cs b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoCoroutineInterop.cs new file mode 100644 index 000000000..72ab897d7 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoCoroutineInterop.cs @@ -0,0 +1,29 @@ +using System.Collections; +using UnityEngine; + +namespace MelonLoader.Engine.Unity.Mono +{ + internal class MonoCoroutineInterop : MelonCoroutineInterop + { + private MonoSupportComponent Component; + + internal MonoCoroutineInterop(MonoSupportComponent component) + => Component = component; + + public override object Start(IEnumerator coroutine) + { + if (Component != null) + return Component.StartCoroutine(coroutine); + MelonCoroutines.Queue(coroutine); + return coroutine; + } + + public override void Stop(object coroutineToken) + { + if (Component != null) + Component.StopCoroutine(coroutineToken as Coroutine); + else + MelonCoroutines.Dequeue(coroutineToken as IEnumerator); + } + } +} diff --git a/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoSceneHandler.cs b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoSceneHandler.cs new file mode 100644 index 000000000..fd9cc9236 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoSceneHandler.cs @@ -0,0 +1,100 @@ +using System; +using UnityEngine.SceneManagement; +using System.Collections.Generic; + +namespace MelonLoader.Engine.Unity.Mono +{ + internal class MonoSceneHandler : IDisposable + { + private MonoSupportModule SupportModule; + + internal class SceneInitEvent + { + internal int buildIndex; + internal string name; + internal bool wasLoadedThisTick; + } + private Queue scenesLoaded = new Queue(); + + internal MonoSceneHandler(MonoSupportModule supportModule) + { + SupportModule = supportModule; + + try + { + SceneManager.sceneLoaded += OnSceneLoad; + } + catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneLoaded override failed: {ex}"); } + + try + { + SceneManager.sceneUnloaded += OnSceneUnload; + } + catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneUnloaded override failed: {ex}"); } + } + + ~MonoSceneHandler() + => Dispose(); + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2013:Do not use ReferenceEquals with value types")] + public void Dispose() + { + try + { + SceneManager.sceneLoaded -= OnSceneLoad; + } + catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneLoaded override failed: {ex}"); } + + try + { + SceneManager.sceneUnloaded -= OnSceneUnload; + } + catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneUnloaded override failed: {ex}"); } + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2013:Do not use ReferenceEquals with value types")] + private void OnSceneLoad(Scene scene, LoadSceneMode mode) + { + if (SupportModule.obj == null) + SupportModule.CreateGameObject(); + + if (ReferenceEquals(scene, null)) + return; + + MelonUnityEvents.OnSceneWasLoaded.Invoke(scene.buildIndex, scene.name); + scenesLoaded.Enqueue(new SceneInitEvent { buildIndex = scene.buildIndex, name = scene.name }); + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2013:Do not use ReferenceEquals with value types")] + private void OnSceneUnload(Scene scene) + { + if (ReferenceEquals(scene, null)) + return; + + MelonUnityEvents.OnSceneWasUnloaded.Invoke(scene.buildIndex, scene.name); + } + + internal void OnUpdate() + { + if (scenesLoaded.Count > 0) + { + Queue requeue = new Queue(); + SceneInitEvent evt = null; + while ((scenesLoaded.Count > 0) && ((evt = scenesLoaded.Dequeue()) != null)) + { + if (evt.wasLoadedThisTick) + { + MelonUnityEvents.OnSceneWasInitialized.Invoke(evt.buildIndex, evt.name); + } + else + { + evt.wasLoadedThisTick = true; + requeue.Enqueue(evt); + } + } + while ((requeue.Count > 0) && ((evt = requeue.Dequeue()) != null)) + scenesLoaded.Enqueue(evt); + } + } + } +} diff --git a/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoSupportComponent.cs b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoSupportComponent.cs new file mode 100644 index 000000000..0dc05e950 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoSupportComponent.cs @@ -0,0 +1,129 @@ +using System; +using System.Reflection; +using UnityEngine; +using MelonLoader.Modules; + +namespace MelonLoader.Engine.Unity.Mono +{ + internal class MonoSupportComponent : MonoBehaviour + { + private bool isQuitting; + private bool hadError; + + private MethodInfo SetAsLastSiblingMethod; + + private void LogError(string cat, Exception ex) + { + hadError = true; + MelonLogger.Warning($"Exception while {cat}: {ex}"); + MelonLogger.Warning("Melon Events might run before some MonoBehaviour Events"); + } + + internal void SiblingFix() + { + if (hadError) + return; + + try + { + gameObject.transform.SetAsLastSibling(); + transform.SetAsLastSibling(); + } + catch (Exception ex) + { + LogError("Invoking UnityEngine.Transform::SetAsLastSibling", ex); + } + } + + void Start() + { + try + { + SetAsLastSiblingMethod = typeof(Transform).GetMethod("SetAsLastSibling", BindingFlags.Public | BindingFlags.Instance); + if (SetAsLastSiblingMethod == null) + throw new Exception("Unable to find UnityEngine.Transform::SetAsLastSibling"); + } + catch (Exception ex) { LogError("Getting UnityEngine.Transform::SetAsLastSibling", ex); } + + if ((ModuleInterop.Support == null) || (((MonoSupportModule)ModuleInterop.Support).component != this)) + return; + + SiblingFix(); + + MelonUnityEvents.OnApplicationLateStart.Invoke(); + } + + void Awake() + { + if ((ModuleInterop.Support == null) || (((MonoSupportModule)ModuleInterop.Support).component != this)) + return; + + MelonCoroutines.ProcessQueue(); + } + + void Update() + { + if ((ModuleInterop.Support == null) || (((MonoSupportModule)ModuleInterop.Support).component != this)) + return; + + isQuitting = false; + SiblingFix(); + + ((MonoSupportModule)ModuleInterop.Support).sceneHandler.OnUpdate(); + + MelonUnityEvents.OnUpdate.Invoke(); + } + + void OnDestroy() + { + if ((ModuleInterop.Support == null) || (((MonoSupportModule)ModuleInterop.Support).component != this)) + return; + + if (!isQuitting) + { + ((MonoSupportModule)ModuleInterop.Support).CreateGameObject(); + return; + } + + OnApplicationDefiniteQuit(); + } + + void OnApplicationQuit() + { + if ((ModuleInterop.Support == null) || (((MonoSupportModule)ModuleInterop.Support).component != this)) + return; + + isQuitting = true; + MelonUnityEvents.OnApplicationQuit.Invoke(); + } + + void OnApplicationDefiniteQuit() + { + MelonUnityEvents.OnApplicationDefiniteQuit.Invoke(); + } + + void FixedUpdate() + { + if ((ModuleInterop.Support == null) || (((MonoSupportModule)ModuleInterop.Support).component != this)) + return; + + MelonUnityEvents.OnFixedUpdate.Invoke(); + } + + void LateUpdate() + { + if ((ModuleInterop.Support == null) || (((MonoSupportModule)ModuleInterop.Support).component != this)) + return; + + MelonUnityEvents.OnLateUpdate.Invoke(); + } + + void OnGUI() + { + if ((ModuleInterop.Support == null) || (((MonoSupportModule)ModuleInterop.Support).component != this)) + return; + + MelonUnityEvents.OnGUI.Invoke(); + } + } +} diff --git a/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoSupportModule.cs b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoSupportModule.cs new file mode 100644 index 000000000..dd8cb10e8 --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoSupportModule.cs @@ -0,0 +1,41 @@ +using MelonLoader.Modules; +using UnityEngine; + +namespace MelonLoader.Engine.Unity.Mono +{ + internal class MonoSupportModule : MelonSupportModule + { + internal MonoSceneHandler sceneHandler; + + internal GameObject obj; + internal MonoSupportComponent component; + + public override void Initialize() + { + // Initialize Tomlet Unity Object Serialization + MonoTomletProvider.Initialize(); + + // Create Scene Handler + sceneHandler = new(this); + + // Create GameObject and Component + if (component == null) + CreateGameObject(); + } + + internal void CreateGameObject() + { + // Create Support GameObject + obj = new GameObject(); + GameObject.DontDestroyOnLoad(obj); + obj.hideFlags = HideFlags.DontSave; + + // Create Support Component + component = (MonoSupportComponent)obj.AddComponent(typeof(MonoSupportComponent)); + component.SiblingFix(); + + // Create Interop for Coroutine Management + MelonCoroutines.Interop = new MonoCoroutineInterop(component); + } + } +} diff --git a/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoTomletProvider.cs b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoTomletProvider.cs new file mode 100644 index 000000000..8978311cd --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/MonoTomletProvider.cs @@ -0,0 +1,103 @@ +using Tomlet; +using Tomlet.Models; +using UnityEngine; + +namespace MelonLoader.Engine.Unity.Mono +{ + internal static class MonoTomletProvider + { + internal static void Initialize() + { + TomletMain.RegisterMapper(WriteColor, ReadColor); + TomletMain.RegisterMapper(WriteColor32, ReadColor32); + TomletMain.RegisterMapper(WriteVector2, ReadVector2); + TomletMain.RegisterMapper(WriteVector3, ReadVector3); + TomletMain.RegisterMapper(WriteVector4, ReadVector4); + TomletMain.RegisterMapper(WriteQuaternion, ReadQuaternion); + } + + private static Color ReadColor(TomlValue value) + { + float[] floats = MelonPreferences.Mapper.ReadArray(value); + if (floats == null || floats.Length != 4) + return default; + return new Color(floats[0] / 255f, floats[1] / 255f, floats[2] / 255f, floats[3] / 255f); + } + + private static TomlValue WriteColor(Color value) + { + float[] floats = new[] { value.r * 255, value.g * 255, value.b * 255, value.a * 255}; + return MelonPreferences.Mapper.WriteArray(floats); + } + + private static Color32 ReadColor32(TomlValue value) + { + byte[] bytes = MelonPreferences.Mapper.ReadArray(value); + if (bytes == null || bytes.Length != 4) + return default; + return new Color32(bytes[0], bytes[1], bytes[2], bytes[3]); + } + + private static TomlValue WriteColor32(Color32 value) + { + byte[] bytes = new[] { value.r, value.g, value.b, value.a }; + return MelonPreferences.Mapper.WriteArray(bytes); + } + + private static Vector2 ReadVector2(TomlValue value) + { + float[] floats = MelonPreferences.Mapper.ReadArray(value); + if (floats == null || floats.Length != 2) + return default; + return new Vector2(floats[0], floats[1]); + } + + private static TomlValue WriteVector2(Vector2 value) + { + float[] floats = new[] { value.x, value.y }; + return MelonPreferences.Mapper.WriteArray(floats); + } + + private static Vector3 ReadVector3(TomlValue value) + { + float[] floats = MelonPreferences.Mapper.ReadArray(value); + if (floats == null || floats.Length != 3) + return default; + return new Vector3(floats[0], floats[1], floats[2]); + } + + private static TomlValue WriteVector3(Vector3 value) + { + float[] floats = new[] { value.x, value.y, value.z }; + return MelonPreferences.Mapper.WriteArray(floats); + } + + private static Vector4 ReadVector4(TomlValue value) + { + float[] floats = MelonPreferences.Mapper.ReadArray(value); + if (floats == null || floats.Length != 4) + return default; + return new Vector4(floats[0], floats[1], floats[2], floats[3]); + } + + private static TomlValue WriteVector4(Vector4 value) + { + float[] floats = new[] { value.x, value.y, value.z, value.w }; + return MelonPreferences.Mapper.WriteArray(floats); + } + + private static Quaternion ReadQuaternion(TomlValue value) + { + float[] floats = MelonPreferences.Mapper.ReadArray(value); + if (floats == null || floats.Length != 4) + return default; + return new Quaternion(floats[0], floats[1], floats[2], floats[3]); + } + + private static TomlValue WriteQuaternion(Quaternion value) + { + float[] floats = new[] { value.x, value.y, value.z, value.w }; + return MelonPreferences.Mapper.WriteArray(floats); + } + } +} \ No newline at end of file diff --git a/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/Unity.Mono.csproj b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/Unity.Mono.csproj new file mode 100644 index 000000000..de52312bf --- /dev/null +++ b/Dependencies/Modules/Engines/Unity/Mono/Unity.Mono/Unity.Mono.csproj @@ -0,0 +1,29 @@ + + + MelonLoader.Unity.Mono + net35 + Latest + true + $(MLOutDir)/MelonLoader/Dependencies/Engines/Unity/ + true + embedded + MelonLoader.Unity.Mono + + + + False + + + False + + + + + ..\Libs\UnityEngine.dll + false + + + + + + \ No newline at end of file diff --git a/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp.Shared/Il2CppLibrary.cs b/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp.Shared/Il2CppLibrary.cs new file mode 100644 index 000000000..e9892be0c --- /dev/null +++ b/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp.Shared/Il2CppLibrary.cs @@ -0,0 +1,68 @@ +using System; +using System.Runtime.InteropServices; + +namespace MelonLoader.Runtime.Il2Cpp +{ + public class Il2CppLibrary + { + #region Public Members + + public static Il2CppLibrary Instance { get; private set; } + public static MelonNativeLibrary Lib { get; private set; } + + #endregion + + #region Public Methods + + public static void Load(string filePath) + { + if (Instance != null) + return; + + IntPtr libPtr = MelonNativeLibrary.LoadLib(filePath); + if (libPtr == IntPtr.Zero) + throw new Exception($"Failed to load {filePath}"); + + Lib = new(libPtr, false); + Instance = Lib.Instance; + } + + #endregion + + #region Il2Cpp Domain + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr d_il2cpp_init(IntPtr name); + public d_il2cpp_init il2cpp_init { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr d_il2cpp_domain_get(); + public d_il2cpp_domain_get il2cpp_domain_get { get; private set; } + + #endregion + + #region Il2Cpp Internal Calls + + [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] + public delegate void dil2cpp_add_internal_call(IntPtr signature, IntPtr funcPtr); + public dil2cpp_add_internal_call il2cpp_add_internal_call { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] + public delegate IntPtr dil2cpp_resolve_icall(IntPtr signature); + public dil2cpp_resolve_icall il2cpp_resolve_icall { get; private set; } + + #endregion + + #region Il2Cpp Method + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr d_il2cpp_method_get_name(IntPtr method); + public d_il2cpp_method_get_name il2cpp_method_get_name { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] + public unsafe delegate IntPtr d_il2cpp_runtime_invoke(IntPtr method, IntPtr obj, void** param, ref IntPtr exc); + public d_il2cpp_runtime_invoke il2cpp_runtime_invoke { get; private set; } + + #endregion + } +} diff --git a/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp.Shared/Runtime.Il2Cpp.Shared.csproj b/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp.Shared/Runtime.Il2Cpp.Shared.csproj new file mode 100644 index 000000000..095f33544 --- /dev/null +++ b/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp.Shared/Runtime.Il2Cpp.Shared.csproj @@ -0,0 +1,17 @@ + + + MelonLoader.Runtime.Il2Cpp + net6 + Latest + false + $(MLOutDir)/MelonLoader/Dependencies/Runtimes/Il2Cpp/ + true + embedded + MelonLoader.Runtime.Il2Cpp.Shared + + + + False + + + \ No newline at end of file diff --git a/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp/Il2CppLoader.cs b/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp/Il2CppLoader.cs new file mode 100644 index 000000000..db26a0003 --- /dev/null +++ b/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp/Il2CppLoader.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using MelonLoader.Modules; +using MelonLoader.NativeUtils; +#pragma warning disable 0649 + +namespace MelonLoader.Runtime.Il2Cpp +{ + public unsafe static class Il2CppLoader + { + #region Private Members + + private static MelonNativeDetour il2cpp_runtime_invoke_detour; + + #endregion + + #region Public Members + + public static MelonEngineModule EngineModule { get; private set; } + public static Il2CppRuntimeInfo RuntimeInfo { get; private set; } + + #endregion + + #region Loader + + public static void Initialize(MelonEngineModule engineModule, + Il2CppRuntimeInfo runtimeInfo) + { + // Apply the information + EngineModule = engineModule; + RuntimeInfo = runtimeInfo; + + // Check if it found any Il2Cpp variant library + if (RuntimeInfo == null) + { + MelonLogger.ThrowInternalFailure("Invalid Runtime Info Passed!"); + return; + } + + // Load Library + if (!LoadLibrary()) + return; + + // Check Exports + if (!CheckExports()) + return; + + // Initiate Stage2 + Stage2(); + } + + private static bool LoadLibrary() + { + // Check if there is a Posix Helper included with the Mono variant library + if (string.IsNullOrEmpty(RuntimeInfo.LibraryPath)) + return true; + + // Load Library + Il2CppLibrary.Load(RuntimeInfo.LibraryPath); + if (Il2CppLibrary.Instance == null) + { + MelonLogger.ThrowInternalFailure($"Failed to load Il2Cpp from {RuntimeInfo.LibraryPath}"); + return false; + } + + // Return Success + return true; + } + + private static bool CheckExports() + { + Dictionary listOfExports = new(); + listOfExports[nameof(Il2CppLibrary.Instance.il2cpp_method_get_name)] = Il2CppLibrary.Instance.il2cpp_method_get_name; + listOfExports[nameof(Il2CppLibrary.Instance.il2cpp_runtime_invoke)] = Il2CppLibrary.Instance.il2cpp_runtime_invoke; + + foreach (var exportPair in listOfExports) + { + if (exportPair.Value != null) + continue; + + MelonLogger.ThrowInternalFailure($"Failed to find {exportPair.Key} Export in Il2Cpp Library!"); + return false; + } + + return true; + } + + #endregion + + #region Hooks + + private static IntPtr h_il2cpp_runtime_invoke(IntPtr method, IntPtr obj, void** param, ref IntPtr exc) + { + // Get Method Name + string methodName = Il2CppLibrary.Instance.il2cpp_method_get_name(method).ToAnsiString(); + + // Check for Trigger Method + foreach (string triggerMethod in RuntimeInfo.TriggerMethods) + { + if (!methodName.Contains(triggerMethod)) + continue; + + // Detach il2cpp_runtime_invoke Detour + il2cpp_runtime_invoke_detour.Detach(); + + // Initiate Stage3 + Stage3(); + + // Return original Invoke without Trampoline + return Il2CppLibrary.Instance.il2cpp_runtime_invoke(method, obj, param, ref exc); + } + + // Return original Invoke + return il2cpp_runtime_invoke_detour.Trampoline(method, obj, param, ref exc); + } + + #endregion + + #region MelonLoader Assembly Wrapping + + private static void Stage2() + { + // Initiate Stage2 + EngineModule.Stage2(); + + // Attach il2cpp_runtime_invoke Detour + MelonDebug.Msg($"Attaching il2cpp_runtime_invoke Detour..."); + il2cpp_runtime_invoke_detour = new(Il2CppLibrary.Instance.il2cpp_runtime_invoke, h_il2cpp_runtime_invoke, false); + il2cpp_runtime_invoke_detour.Attach(); + } + + private static void Stage3() + { + // Initiate Stage3 + EngineModule.Stage3(RuntimeInfo.SupportModulePath); + } + + #endregion + } +} diff --git a/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp/Il2CppRuntimeInfo.cs b/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp/Il2CppRuntimeInfo.cs new file mode 100644 index 000000000..dced380e9 --- /dev/null +++ b/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp/Il2CppRuntimeInfo.cs @@ -0,0 +1,27 @@ +using MelonLoader.Modules; + +namespace MelonLoader.Runtime.Il2Cpp +{ + public class Il2CppRuntimeInfo : MelonRuntimeInfo + { + #region Public Members + + public string[] TriggerMethods { get; private set; } + + #endregion + + #region Constructors + + public Il2CppRuntimeInfo( + string libraryPath, + string supportModulePath, + string[] triggerMethods) + { + LibraryPath = libraryPath; + SupportModulePath = supportModulePath; + TriggerMethods = triggerMethods; + } + + #endregion + } +} diff --git a/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp/Runtime.Il2Cpp.csproj b/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp/Runtime.Il2Cpp.csproj new file mode 100644 index 000000000..a550d6308 --- /dev/null +++ b/Dependencies/Modules/Runtimes/Il2Cpp/Runtime.Il2Cpp/Runtime.Il2Cpp.csproj @@ -0,0 +1,20 @@ + + + MelonLoader.Runtime.Il2Cpp + net6 + Latest + false + $(MLOutDir)/MelonLoader/Dependencies/Runtimes/Il2Cpp/ + true + embedded + MelonLoader.Runtime.Il2Cpp + + + + False + + + False + + + \ No newline at end of file diff --git a/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoAssemblyName.cs b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoAssemblyName.cs new file mode 100644 index 000000000..83d714631 --- /dev/null +++ b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoAssemblyName.cs @@ -0,0 +1,27 @@ +using System.Runtime.InteropServices; + +namespace MelonLoader.Runtime.Mono +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct MonoAssemblyName + { + public nint Name; + + // Non-marshalled strings + public nint Culture; + public nint HashValue; + public nint PublicKey; + + public fixed byte PublicKeyToken[17]; + + public uint HashAlg; + public uint HashLength; + + public uint Flags; + public ushort Major; + public ushort Minor; + public ushort Build; + public ushort Revision; + public uint Arch; + } +} diff --git a/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoAssemblyResolver.cs b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoAssemblyResolver.cs new file mode 100644 index 000000000..6176ddf92 --- /dev/null +++ b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoAssemblyResolver.cs @@ -0,0 +1,92 @@ +using MelonLoader.Resolver; +using System; +using System.Collections.Generic; + +namespace MelonLoader.Runtime.Mono +{ + internal static class MonoAssemblyResolver + { + private static readonly List passedDelegates = new(); + + private static IntPtr mlResolve; + private static IntPtr mlLoadInfoFromAssembly; + + internal static unsafe void Initialize(string managedPath) + { + Type resolverType = typeof(MelonAssemblyResolver); + string resolverAsmLocation = resolverType.Assembly.Location; + + var asm = MonoLibrary.Instance.mono_assembly_open_full(resolverAsmLocation.ToAnsiPointer(), IntPtr.Zero, false); + var image = MonoLibrary.Instance.mono_assembly_get_image(asm); + var resolverClass = MonoLibrary.Instance.mono_class_from_name(image, resolverType.Namespace.ToAnsiPointer(), resolverType.Name.ToAnsiPointer()); + mlResolve = MonoLibrary.Instance.mono_class_get_method_from_name(resolverClass, nameof(MelonAssemblyResolver.Resolve).ToAnsiPointer(), 3); + mlLoadInfoFromAssembly = MonoLibrary.Instance.mono_class_get_method_from_name(resolverClass, nameof(MelonAssemblyResolver.LoadInfoFromAssembly).ToAnsiPointer(), 1); + + // Apply Assembly Resolver Hooks + MelonAssemblyResolver.AddSearchDirectory(managedPath); + InstallAssemblyHooks(OnAssemblyPreload, OnAssemblySearch, OnAssemblyLoad); + } + + private static void InstallAssemblyHooks(MonoLibrary.AssemblyPreloadHookFn preloadHook, + MonoLibrary.AssemblySearchHookFn searchHook, + MonoLibrary.AssemblyLoadHookFn loadHook) + { + if (preloadHook != null) + { + passedDelegates.Add(preloadHook); + MonoLibrary.Instance.mono_install_assembly_preload_hook(preloadHook, IntPtr.Zero); + } + + if (searchHook != null) + { + passedDelegates.Add(searchHook); + MonoLibrary.Instance.mono_install_assembly_search_hook(searchHook, IntPtr.Zero); + } + + if (loadHook != null) + { + passedDelegates.Add(loadHook); + MonoLibrary.Instance.mono_install_assembly_load_hook(loadHook, IntPtr.Zero); + } + } + private static unsafe void OnAssemblyLoad(IntPtr monoAssembly, IntPtr userData) + { + if (monoAssembly == IntPtr.Zero) + return; + + IntPtr domain = MonoLibrary.Instance.mono_domain_get(); + if (domain == IntPtr.Zero) + return; + + IntPtr reflectionAsm = (IntPtr)MonoLibrary.Instance.mono_assembly_get_object(domain, monoAssembly); + if (reflectionAsm == IntPtr.Zero) + return; + + MonoLibrary.Instance.TryInvokeMethod(mlLoadInfoFromAssembly, IntPtr.Zero, monoAssembly); + } + + private unsafe static IntPtr OnAssemblySearch(ref MonoAssemblyName assemblyName, IntPtr userData) + => ResolveAssembly(assemblyName, false); + private unsafe static IntPtr OnAssemblyPreload(ref MonoAssemblyName assemblyName, IntPtr assemblyPaths, IntPtr userData) + => ResolveAssembly(assemblyName, true); + + private static unsafe IntPtr ResolveAssembly(MonoAssemblyName assemblyName, bool is_preload) + { + IntPtr domain = MonoLibrary.Instance.mono_domain_get(); + if (domain == IntPtr.Zero) + return IntPtr.Zero; + + IntPtr reflectionAsm = MonoLibrary.Instance.TryInvokeMethod(mlResolve, IntPtr.Zero, + (void*)MonoLibrary.Instance.mono_string_new(domain, assemblyName.Name), + &assemblyName.Major, + &assemblyName.Minor, + &assemblyName.Build, + &assemblyName.Revision, + &is_preload); + + return (reflectionAsm == IntPtr.Zero) + ? IntPtr.Zero + : ((MonoReflectionAssembly*)reflectionAsm)->Assembly; + } + } +} \ No newline at end of file diff --git a/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoLibrary.cs b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoLibrary.cs new file mode 100644 index 000000000..4ca9e37c9 --- /dev/null +++ b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoLibrary.cs @@ -0,0 +1,207 @@ +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace MelonLoader.Runtime.Mono +{ + public class MonoLibrary + { + #region Public Members + + public static MonoLibrary Instance { get; private set; } + public static MelonNativeLibrary Lib { get; private set; } + + #endregion + + #region Public Methods + + public static void Load(string filePath) + { + if (Instance != null) + return; + + IntPtr libPtr = MelonNativeLibrary.LoadLib(filePath); + if (libPtr == IntPtr.Zero) + throw new Exception($"Failed to load {filePath}"); + + Lib = new(libPtr, false); + Instance = Lib.Instance; + } + + #endregion + + #region Mono Domain + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr d_mono_init_version(IntPtr name, IntPtr version); + public d_mono_init_version mono_init_version { get; private set; } + public d_mono_init_version mono_jit_init_version { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr d_mono_domain_get(); + public d_mono_domain_get mono_domain_get { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate void d_mono_debug_domain_create(IntPtr domain); + public d_mono_debug_domain_create mono_debug_domain_create { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr d_mono_domain_assembly_open(IntPtr domain, IntPtr filepath); + public d_mono_domain_assembly_open mono_domain_assembly_open { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] + public delegate void d_mono_domain_set_config(IntPtr domain, string configPath, IntPtr name); + public d_mono_domain_set_config mono_domain_set_config { get; private set; } + + #endregion + + #region Mono Assembly + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr d_mono_assembly_open(IntPtr filepath, IntPtr status); + public d_mono_assembly_open mono_assembly_open { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr d_mono_assembly_open_full(IntPtr filepath, IntPtr status, bool refonly); + public d_mono_assembly_open_full mono_assembly_open_full { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr d_mono_assembly_get_image(IntPtr assembly); + public d_mono_assembly_get_image mono_assembly_get_image { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate MonoReflectionAssembly* d_mono_assembly_get_object(IntPtr domain, IntPtr assembly); + public d_mono_assembly_get_object mono_assembly_get_object { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr d_mono_install_assembly_preload_hook(AssemblyPreloadHookFn func, IntPtr userData); + public d_mono_install_assembly_preload_hook mono_install_assembly_preload_hook { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr d_mono_install_assembly_search_hook(AssemblySearchHookFn func, IntPtr userData); + public d_mono_install_assembly_search_hook mono_install_assembly_search_hook { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr d_mono_install_assembly_load_hook(AssemblyLoadHookFn func, IntPtr userData); + public d_mono_install_assembly_load_hook mono_install_assembly_load_hook { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate void d_mono_domain_set(IntPtr domain, int force); + public d_mono_domain_set mono_domain_set { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr AssemblyPreloadHookFn(ref MonoAssemblyName assemblyName, IntPtr assemblyPaths, IntPtr userData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr AssemblySearchHookFn(ref MonoAssemblyName assemblyName, IntPtr userData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void AssemblyLoadHookFn(IntPtr monoAssembly, IntPtr userData); + + #endregion + + #region Mono Class + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr d_mono_class_from_name(IntPtr image, IntPtr namespaze, IntPtr name); + public d_mono_class_from_name mono_class_from_name { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr d_mono_class_get_method_from_name(IntPtr clazz, IntPtr name, int paramCount); + public d_mono_class_get_method_from_name mono_class_get_method_from_name { get; private set; } + + #endregion + + #region Mono Method + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr d_mono_method_get_name(IntPtr method); + public d_mono_method_get_name mono_method_get_name { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] + public unsafe delegate IntPtr d_mono_runtime_invoke(IntPtr method, IntPtr obj, void** param, ref IntPtr exc); + public d_mono_runtime_invoke mono_runtime_invoke { get; private set; } + + #endregion + + #region Mono String + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public unsafe delegate IntPtr d_mono_string_new(IntPtr domain, IntPtr str); + public d_mono_string_new mono_string_new { get; private set; } + + #endregion + + #region Mono Thread + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr d_mono_thread_current(); + public d_mono_thread_current mono_thread_current { get; private set; } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void d_mono_thread_set_main(IntPtr thread); + public d_mono_thread_set_main mono_thread_set_main { get; private set; } + + #endregion + + #region Utility Methods + + public unsafe IntPtr TryInvokeMethod(IntPtr method, IntPtr obj) + { + try { return InvokeMethod(method, obj, (void**)IntPtr.Zero); } + catch { } + return IntPtr.Zero; + } + + public unsafe IntPtr InvokeMethod(IntPtr method, IntPtr obj) + => InvokeMethod(method, obj, (void**)IntPtr.Zero); + + public unsafe IntPtr TryInvokeMethod(IntPtr method, IntPtr obj, params IntPtr[] parameters) + { + try { return InvokeMethod(method, obj, parameters); } + catch { } + return IntPtr.Zero; + } + + public unsafe IntPtr InvokeMethod(IntPtr method, IntPtr obj, params IntPtr[] parameters) + { + fixed (void* parameterF = ¶meters[0]) + return InvokeMethod(method, obj, (void**)parameterF); + } + + public unsafe IntPtr TryInvokeMethod(IntPtr method, IntPtr obj, params void*[] parameters) + { + try { return InvokeMethod(method, obj, parameters); } + catch { } + return IntPtr.Zero; + } + + public unsafe IntPtr InvokeMethod(IntPtr method, IntPtr obj, params void*[] parameters) + { + fixed (void** parameterF = ¶meters[0]) + return InvokeMethod(method, obj, parameterF); + } + + public unsafe IntPtr TryInvokeMethod(IntPtr method, IntPtr obj, void** param) + { + try { return InvokeMethod(method, obj, param); } + catch { } + return IntPtr.Zero; + } + + public unsafe IntPtr InvokeMethod(IntPtr method, IntPtr obj, void** param) + { + if (method == IntPtr.Zero) + return IntPtr.Zero; + + IntPtr exc = IntPtr.Zero; + IntPtr returnVal = mono_runtime_invoke(method, obj, param, ref exc); + + //TODO: Exception to String + if (exc != IntPtr.Zero) + throw new Exception("Exception occurred in Mono Method!"); + + return returnVal; + } + + #endregion + } +} \ No newline at end of file diff --git a/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoReflectionAssembly.cs b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoReflectionAssembly.cs new file mode 100644 index 000000000..c70df5c67 --- /dev/null +++ b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/MonoReflectionAssembly.cs @@ -0,0 +1,16 @@ +using System.Runtime.InteropServices; + +namespace MelonLoader.Runtime.Mono +{ + [StructLayout(LayoutKind.Sequential)] + public struct MonoReflectionAssembly + { + // MonoObject + public nint VTable; + public nint Sync; + + public nint Assembly; + + public nint Evidence; + } +} diff --git a/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/Runtime.Mono.Shared.csproj b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/Runtime.Mono.Shared.csproj new file mode 100644 index 000000000..dbd1e59fe --- /dev/null +++ b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono.Shared/Runtime.Mono.Shared.csproj @@ -0,0 +1,17 @@ + + + MelonLoader.Runtime.Mono + net35;net6 + Latest + true + $(MLOutDir)/MelonLoader/Dependencies/Runtimes/Mono/ + true + embedded + MelonLoader.Runtime.Mono.Shared + + + + False + + + \ No newline at end of file diff --git a/Dependencies/Modules/Runtimes/Mono/Runtime.Mono/MonoLoader.cs b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono/MonoLoader.cs new file mode 100644 index 000000000..6bebe9c81 --- /dev/null +++ b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono/MonoLoader.cs @@ -0,0 +1,521 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using MelonLoader.InternalUtils; +using MelonLoader.Modules; +using MelonLoader.NativeUtils; +using MelonLoader.Utils; +#pragma warning disable 0649 + +namespace MelonLoader.Runtime.Mono +{ + public unsafe static class MonoLoader + { + #region Private Members + + private static MelonNativeDetour mono_init_version_detour; + private static MelonNativeDetour mono_runtime_invoke_detour; + + private static IntPtr monoDomain; + + private static IntPtr mlAsm; + private static IntPtr mlAsmImage; + + private static IntPtr mlMonoLibraryAsm; + private static IntPtr mlMonoLibraryAsmImage; + private static IntPtr mlMonoLibraryType; + private static IntPtr mlMonoLibraryLoad; + private static IntPtr mlMonoLibraryResolverType; + private static IntPtr mlMonoLibraryResolverInit; + + private static IntPtr mlInteropType; + private static IntPtr mlStage1; + + private static IntPtr mlCoreType; + private static IntPtr mlStage2; + private static IntPtr mlStage3; + + private static IntPtr mlEnvironmentType; + private static IntPtr mlSetAppInfo; + private static IntPtr mlSetEngineInfo2; + private static IntPtr mlSetEngineInfo3; + + #endregion + + #region Public Members + + public static MelonEngineModule EngineModule { get; private set; } + public static MonoRuntimeInfo RuntimeInfo { get; private set; } + + #endregion + + #region Loader + + public static void Initialize(MelonEngineModule engineModule, + MonoRuntimeInfo runtimeInfo) + { + // Apply the information + EngineModule = engineModule; + RuntimeInfo = runtimeInfo; + + // Check if it found any Mono variant library + if (RuntimeInfo == null) + { + MelonLogger.ThrowInternalFailure("Invalid Runtime Info Passed!"); + return; + } + + // Load Posix Helper + if (!LoadPosixHelper()) + return; + + // Load Library + if (!LoadLibrary()) + return; + + // Check Exports + if (!CheckExports()) + return; + + // Get Mono Domain + monoDomain = MonoLibrary.Instance.mono_domain_get(); + + // Handle loading if Domain is already Created + if (monoDomain == IntPtr.Zero) + { + // Attach mono_init_version Detour + MelonDebug.Msg($"Attaching mono_init_version Detour..."); + if (!RuntimeInfo.IsBleedingEdge) + mono_init_version_detour = new(MonoLibrary.Instance.mono_init_version, h_mono_init_version); + else + mono_init_version_detour = new(MonoLibrary.Instance.mono_jit_init_version, h_mono_init_version); + mono_init_version_detour.Attach(); + } + } + + private static bool IsNetStandard() + { + // To-Do: Read from Mono Assembly + return false; + } + + private static bool LoadPosixHelper() + { + // Check if there is a Posix Helper included with the Mono variant library + if (string.IsNullOrEmpty(RuntimeInfo.PosixPath)) + return true; + + // Force-Load the Posix Helper before the actual Mono variant library + // Otherwise can cause crashing in some cases + MelonDebug.Msg(RuntimeInfo.PosixPath); + MelonDebug.Msg("Posix Helper found! Loading..."); + if (!MelonNativeLibrary.TryLoadLib(RuntimeInfo.PosixPath, out IntPtr _)) + { + MelonLogger.ThrowInternalFailure($"Failed to load {(RuntimeInfo.IsBleedingEdge ? "MonoBleedingEdge" : "Mono")} Posix Helper from {RuntimeInfo.PosixPath}"); + return false; + } + + // Return Success + return true; + } + + private static bool LoadLibrary() + { + // Check if there is a Posix Helper included with the Mono variant library + if (string.IsNullOrEmpty(RuntimeInfo.LibraryPath)) + return true; + + // Load Library + MonoLibrary.Load(RuntimeInfo.LibraryPath); + if (MonoLibrary.Instance == null) + { + MelonLogger.ThrowInternalFailure($"Failed to load {(RuntimeInfo.IsBleedingEdge ? "MonoBleedingEdge" : "Mono")} from {RuntimeInfo.LibraryPath}"); + return false; + } + + // Return Success + return true; + } + + private static bool CheckExports() + { + Dictionary listOfExports = new(); + + string initName = !RuntimeInfo.IsBleedingEdge + ? nameof(MonoLibrary.Instance.mono_init_version) + : nameof(MonoLibrary.Instance.mono_jit_init_version); + + Delegate initDel = !RuntimeInfo.IsBleedingEdge + ? MonoLibrary.Instance.mono_init_version + : MonoLibrary.Instance.mono_jit_init_version; + + listOfExports[initName] = initDel; + + if (RuntimeInfo.IsBleedingEdge) + listOfExports[nameof(MonoLibrary.Instance.mono_jit_init_version)] = MonoLibrary.Instance.mono_jit_init_version; + else + listOfExports[nameof(MonoLibrary.Instance.mono_init_version)] = MonoLibrary.Instance.mono_init_version; + + listOfExports[nameof(MonoLibrary.Instance.mono_domain_get)] = MonoLibrary.Instance.mono_domain_get; + listOfExports[nameof(MonoLibrary.Instance.mono_domain_set)] = MonoLibrary.Instance.mono_domain_set; + listOfExports[nameof(MonoLibrary.Instance.mono_domain_assembly_open)] = MonoLibrary.Instance.mono_domain_assembly_open; + listOfExports[nameof(MonoLibrary.Instance.mono_assembly_get_image)] = MonoLibrary.Instance.mono_assembly_get_image; + listOfExports[nameof(MonoLibrary.Instance.mono_class_from_name)] = MonoLibrary.Instance.mono_class_from_name; + listOfExports[nameof(MonoLibrary.Instance.mono_method_get_name)] = MonoLibrary.Instance.mono_method_get_name; + listOfExports[nameof(MonoLibrary.Instance.mono_runtime_invoke)] = MonoLibrary.Instance.mono_runtime_invoke; + listOfExports[nameof(MonoLibrary.Instance.mono_thread_set_main)] = MonoLibrary.Instance.mono_thread_set_main; + listOfExports[nameof(MonoLibrary.Instance.mono_string_new)] = MonoLibrary.Instance.mono_string_new; + listOfExports[nameof(MonoLibrary.Instance.mono_class_get_method_from_name)] = MonoLibrary.Instance.mono_class_get_method_from_name; + + foreach (var exportPair in listOfExports) + { + if (exportPair.Value != null) + continue; + + MelonLogger.ThrowInternalFailure($"Failed to find {exportPair.Key} Export in Mono Library!"); + return false; + } + + return true; + } + + #endregion + + #region Hooks + + private static IntPtr h_mono_init_version(IntPtr name, IntPtr version) + { + // Invoke Domain Creation + monoDomain = mono_init_version_detour.Trampoline(name, version); + + // Detach mono_init_version Detour + mono_init_version_detour.Detach(); + + if (LoaderConfig.Current.Loader.DebugMode && (MonoLibrary.Instance.mono_debug_domain_create != null)) + { + MelonDebug.Msg("Creating Mono Debug Domain"); + MonoLibrary.Instance.mono_debug_domain_create(monoDomain); + } + + MelonDebug.Msg("Setting Mono Main Thread"); + MonoLibrary.Instance.mono_thread_set_main(MonoLibrary.Instance.mono_thread_current()); + MonoLibrary.Instance.mono_domain_set(monoDomain, 1); + + if (RuntimeInfo.IsBleedingEdge && (MonoLibrary.Instance.mono_domain_set_config != null)) + { + MelonDebug.Msg("Setting Mono Config"); + MonoLibrary.Instance.mono_domain_set_config(monoDomain, MelonEnvironment.ApplicationRootDirectory, name); + } + + Stage1and2(); + + // Return Domain + return monoDomain; + } + + private static IntPtr h_mono_runtime_invoke(IntPtr method, IntPtr obj, void** param, ref IntPtr exc) + { + // Get Method Name + string methodName = MonoLibrary.Instance.mono_method_get_name(method).ToAnsiString(); + + // Check for Trigger Method + foreach (string triggerMethod in RuntimeInfo.TriggerMethods) + { + if (string.IsNullOrEmpty(triggerMethod) + || !methodName.Contains(triggerMethod)) + continue; + + // Detach mono_runtime_invoke Detour + mono_runtime_invoke_detour.Detach(); + + Stage3(); + + // Return original Invoke without Trampoline + return MonoLibrary.Instance.mono_runtime_invoke(method, obj, param, ref exc); + } + + // Return original Invoke + return mono_runtime_invoke_detour.Trampoline(method, obj, param, ref exc); + } + + #endregion + + #region MelonLoader Assembly Wrapping + + private static void Stage1and2() + { + if (!SetupAssembly()) + return; + + // Initiate Stage1 + MelonDebug.Msg("Initiating Stage1..."); + nint bootstrapHandle = BootstrapInterop._handle; + nint loadLibFunc = BootstrapInterop.NativeLoadLibInteropPtr; + nint getExportFunc = BootstrapInterop.NativeGetExportInteropPtr; + var stage1Args = stackalloc nint*[] + { + &bootstrapHandle, + &loadLibFunc, + &getExportFunc + }; + MonoLibrary.Instance.InvokeMethod(mlStage1, IntPtr.Zero, (void**)stage1Args); + + // Load MonoLibrary + MelonDebug.Msg("Loading MonoLibrary in Mono Domain..."); + MonoLibrary.Instance.InvokeMethod(mlMonoLibraryLoad, IntPtr.Zero, + MonoLibrary.Instance.mono_string_new(monoDomain, RuntimeInfo.LibraryPath.ToAnsiPointer())); + + // Patch Mono Assembly Resolver + MelonDebug.Msg("Patching Mono Assembly Resolver..."); + MonoLibrary.Instance.InvokeMethod(mlMonoLibraryResolverInit, IntPtr.Zero, + MonoLibrary.Instance.mono_string_new(monoDomain, RuntimeInfo.ManagedPath.ToAnsiPointer())); + + // Apply Engine Info + MelonDebug.Msg("Applying Engine Information..."); + nint engineNameHandle = MelonEnvironment.CurrentEngineInfo.Name.ToAnsiPointer(); + nint engineVersionHandle = MelonEnvironment.CurrentEngineInfo.Version.ToAnsiPointer(); + if (string.IsNullOrEmpty(MelonEnvironment.CurrentEngineInfo.Variant)) + { + MonoLibrary.Instance.InvokeMethod(mlSetEngineInfo2, IntPtr.Zero, + MonoLibrary.Instance.mono_string_new(monoDomain, MelonEnvironment.CurrentEngineInfo.Name.ToAnsiPointer()), + MonoLibrary.Instance.mono_string_new(monoDomain, MelonEnvironment.CurrentEngineInfo.Version.ToAnsiPointer())); + } + else + { + MonoLibrary.Instance.InvokeMethod(mlSetEngineInfo3, IntPtr.Zero, + MonoLibrary.Instance.mono_string_new(monoDomain, MelonEnvironment.CurrentEngineInfo.Name.ToAnsiPointer()), + MonoLibrary.Instance.mono_string_new(monoDomain, MelonEnvironment.CurrentEngineInfo.Version.ToAnsiPointer()), + MonoLibrary.Instance.mono_string_new(monoDomain, MelonEnvironment.CurrentEngineInfo.Variant.ToAnsiPointer())); + } + + // Apply Application Info + MelonDebug.Msg("Applying Application Information..."); + MonoLibrary.Instance.InvokeMethod(mlSetAppInfo, IntPtr.Zero, + MonoLibrary.Instance.mono_string_new(monoDomain, MelonEnvironment.CurrentApplicationInfo.Name.ToAnsiPointer()), + MonoLibrary.Instance.mono_string_new(monoDomain, MelonEnvironment.CurrentApplicationInfo.Developer.ToAnsiPointer()), + MonoLibrary.Instance.mono_string_new(monoDomain, MelonEnvironment.CurrentEngineInfo.Version.ToAnsiPointer())); + + // Initiate Stage2 + MelonDebug.Msg("Initiating Stage2..."); + MonoLibrary.Instance.InvokeMethod(mlStage2, IntPtr.Zero); + + // Attach mono_runtime_invoke Detour + MelonDebug.Msg("Attaching mono_runtime_invoke Detour..."); + mono_runtime_invoke_detour = new(MonoLibrary.Instance.mono_runtime_invoke, h_mono_runtime_invoke, false); + mono_runtime_invoke_detour.Attach(); + } + + public static void Stage3() + { + // Initiate Stage3 + MelonDebug.Msg("Initiating Stage3..."); + MonoLibrary.Instance.InvokeMethod(mlStage3, IntPtr.Zero, + MonoLibrary.Instance.mono_string_new(monoDomain, RuntimeInfo.SupportModulePath.ToAnsiPointer())); + } + + private static void LoadNetStandardPatches() + { + var corlibPath = Path.Combine(RuntimeInfo.ManagedPath, "mscorlib.dll"); + if (File.Exists(corlibPath)) + { + var corlibVersion = FileVersionInfo.GetVersionInfo(corlibPath); + if (corlibVersion.FileMajorPart <= 2) + { + MelonDebug.Msg("Loading .NET Standard 2.0 overrides"); + var overridesDir = Path.Combine(MelonEnvironment.DependenciesDirectory, "NetStandardPatches"); + if (Directory.Exists(overridesDir)) + { + foreach (var dll in Directory.EnumerateFiles(overridesDir, "*.dll")) + { + MelonDebug.Msg("Loading assembly: " + dll); + if (MonoLibrary.Instance.mono_domain_assembly_open(monoDomain, dll.ToAnsiPointer()) == IntPtr.Zero) + MelonDebug.Msg($"Assembly failed to load {dll}"); + } + } + } + } + } + + private static bool SetupAssembly() + { + LoadNetStandardPatches(); + + // Get File Path for MelonLoader.dll + string mainAssemblyLocation = typeof(MelonLogger).Assembly.Location; + string fileName = Path.GetFileName(mainAssemblyLocation); + string sharedPath = Path.Combine( + MelonEnvironment.DependenciesDirectory, + IsNetStandard() ? "netstandard2.1" : "net35", + fileName); + + Type monoLibType = typeof(MonoLibrary); + string monoLibPath = Path.Combine( + Path.GetDirectoryName(Path.GetDirectoryName(monoLibType.Assembly.Location)), + IsNetStandard() ? "netstandard2.1" : "net35", + Path.GetFileName(monoLibType.Assembly.Location)); + + // Load MelonLoader Assembly + MelonDebug.Msg($"Loading Assembly {sharedPath}..."); + mlAsm = MonoLibrary.Instance.mono_domain_assembly_open(monoDomain, sharedPath.ToAnsiPointer()); + if (mlAsm == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to load Assembly from {sharedPath}!"); + return false; + } + + // Get Assembly Image + MelonDebug.Msg("Getting Assembly Image..."); + mlAsmImage = MonoLibrary.Instance.mono_assembly_get_image(mlAsm); + if (mlAsmImage == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Assembly Image from {sharedPath}!"); + return false; + } + + // Get MelonLoader.BootstrapInterop + Type bootstrapInteropType = typeof(BootstrapInterop); + MelonDebug.Msg($"Getting Class {bootstrapInteropType.FullName}..."); + mlInteropType = MonoLibrary.Instance.mono_class_from_name(mlAsmImage, bootstrapInteropType.Namespace.ToAnsiPointer(), bootstrapInteropType.Name.ToAnsiPointer()); + if (mlInteropType == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Class {bootstrapInteropType.FullName} from {sharedPath}!"); + return false; + } + + // Get MelonLoader.BootstrapInterop::Stage1 + MelonDebug.Msg($"Getting Method Stage1 from {bootstrapInteropType.FullName}..."); + mlStage1 = MonoLibrary.Instance.mono_class_get_method_from_name(mlInteropType, "Stage1".ToAnsiPointer(), 3); + if (mlStage1 == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Method {bootstrapInteropType.FullName}::Stage1 from {sharedPath}!"); + return false; + } + + // Get MelonLoader.Core + Type coreType = bootstrapInteropType.Assembly.GetType("MelonLoader.Core"); + MelonDebug.Msg($"Getting Class {coreType.FullName}..."); + mlCoreType = MonoLibrary.Instance.mono_class_from_name(mlAsmImage, coreType.Namespace.ToAnsiPointer(), coreType.Name.ToAnsiPointer()); + if (mlCoreType == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Class {coreType.FullName} from {sharedPath}!"); + return false; + } + + // Get MelonLoader.Core::Stage2 + MelonDebug.Msg($"Getting Method Stage2 from {coreType.FullName}..."); + mlStage2 = MonoLibrary.Instance.mono_class_get_method_from_name(mlCoreType, "Stage2".ToAnsiPointer(), 0); + if (mlStage2 == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Method {coreType.FullName}::Stage2 from {sharedPath}!"); + return false; + } + + // Get MelonLoader.Core::Stage3 + MelonDebug.Msg($"Getting Method Stage3 from {coreType.FullName}..."); + mlStage3 = MonoLibrary.Instance.mono_class_get_method_from_name(mlCoreType, "Stage3".ToAnsiPointer(), 1); + if (mlStage3 == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Method {coreType.FullName}::Stage3 from {sharedPath}!"); + return false; + } + + // Get MelonLoader.Utils.MelonEnvironment + Type environmentType = typeof(MelonEnvironment); + MelonDebug.Msg($"Getting Class {environmentType.FullName}..."); + mlEnvironmentType = MonoLibrary.Instance.mono_class_from_name(mlAsmImage, environmentType.Namespace.ToAnsiPointer(), environmentType.Name.ToAnsiPointer()); + if (mlEnvironmentType == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Class {environmentType.FullName} from {sharedPath}!"); + return false; + } + + // Get MelonLoader.Utils.MelonEnvironment::SetApplicationInfo + MelonDebug.Msg($"Getting Method SetApplicationInfo from {environmentType.FullName}..."); + mlSetAppInfo = MonoLibrary.Instance.mono_class_get_method_from_name(mlEnvironmentType, "SetApplicationInfo".ToAnsiPointer(), 3); + if (mlSetAppInfo == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Method {environmentType.FullName}::SetApplicationInfo from {sharedPath}!"); + return false; + } + + // Get MelonLoader.Utils.MelonEnvironment::SetEngineInfo 2 + MelonDebug.Msg($"Getting Method SetEngineInfo 2 from {environmentType.FullName}..."); + mlSetEngineInfo2 = MonoLibrary.Instance.mono_class_get_method_from_name(mlEnvironmentType, "SetEngineInfo".ToAnsiPointer(), 2); + if (mlSetEngineInfo2 == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Method {environmentType.FullName}::SetEngineInfo 2 from {sharedPath}!"); + return false; + } + + // Get MelonLoader.Utils.MelonEnvironment::SetEngineInfo 3 + MelonDebug.Msg($"Getting Method SetEngineInfo 3 from {environmentType.FullName}..."); + mlSetEngineInfo3 = MonoLibrary.Instance.mono_class_get_method_from_name(mlEnvironmentType, "SetEngineInfo".ToAnsiPointer(), 3); + if (mlSetEngineInfo3 == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Method {environmentType.FullName}::SetEngineInfo 3 from {sharedPath}!"); + return false; + } + + // Load Mono.Shared Assembly + MelonDebug.Msg($"Loading Assembly {monoLibPath}..."); + mlMonoLibraryAsm = MonoLibrary.Instance.mono_domain_assembly_open(monoDomain, monoLibPath.ToAnsiPointer()); + if (mlMonoLibraryAsm == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to load Assembly from {monoLibPath}!"); + return false; + } + + // Get Assembly Image + MelonDebug.Msg("Getting Assembly Image..."); + mlMonoLibraryAsmImage = MonoLibrary.Instance.mono_assembly_get_image(mlMonoLibraryAsm); + if (mlMonoLibraryAsmImage == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Assembly Image from {monoLibPath}!"); + return false; + } + + // Get MonoLibrary + MelonDebug.Msg($"Getting Class {monoLibType.FullName}..."); + mlMonoLibraryType = MonoLibrary.Instance.mono_class_from_name(mlMonoLibraryAsmImage, monoLibType.Namespace.ToAnsiPointer(), monoLibType.Name.ToAnsiPointer()); + if (mlMonoLibraryType == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Class {monoLibType.FullName} from {monoLibPath}!"); + return false; + } + + // Get MonoLibrary::Load + MelonDebug.Msg($"Getting Method {nameof(MonoLibrary.Load)} from {monoLibType.FullName}..."); + mlMonoLibraryLoad = MonoLibrary.Instance.mono_class_get_method_from_name(mlMonoLibraryType, nameof(MonoLibrary.Load).ToAnsiPointer(), 1); + if (mlMonoLibraryLoad == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Method {monoLibType.FullName}::{nameof(MonoLibrary.Load)} from {monoLibPath}!"); + return false; + } + + // Get MonoAssemblyResolver + MelonDebug.Msg($"Getting Class MelonLoader.Runtime.Mono.MonoAssemblyResolver ..."); + mlMonoLibraryResolverType = MonoLibrary.Instance.mono_class_from_name(mlMonoLibraryAsmImage, "MelonLoader.Runtime.Mono".ToAnsiPointer(), "MonoAssemblyResolver".ToAnsiPointer()); + if (mlMonoLibraryResolverType == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Class MelonLoader.Runtime.Mono.MonoAssemblyResolver from {monoLibPath}!"); + return false; + } + + // Get MonoLibrary::Initialize + MelonDebug.Msg($"Getting Method Initialize from MelonLoader.Runtime.Mono.MonoAssemblyResolver..."); + mlMonoLibraryResolverInit = MonoLibrary.Instance.mono_class_get_method_from_name(mlMonoLibraryResolverType, "Initialize".ToAnsiPointer(), 1); + if (mlMonoLibraryResolverInit == IntPtr.Zero) + { + MelonLogger.ThrowInternalFailure($"Failed to get Method MelonLoader.Runtime.Mono.MonoAssemblyResolver::Initialize from {monoLibPath}!"); + return false; + } + + // Return Success + return true; + } + + #endregion + } +} diff --git a/Dependencies/Modules/Runtimes/Mono/Runtime.Mono/MonoRuntimeInfo.cs b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono/MonoRuntimeInfo.cs new file mode 100644 index 000000000..519b23cf7 --- /dev/null +++ b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono/MonoRuntimeInfo.cs @@ -0,0 +1,36 @@ +using MelonLoader.Modules; + +namespace MelonLoader.Runtime.Mono +{ + public class MonoRuntimeInfo : MelonRuntimeInfo + { + #region Public Members + + public string PosixPath { get; private set; } + public string ManagedPath { get; private set; } + public bool IsBleedingEdge { get; private set; } + public string[] TriggerMethods { get; private set; } + + #endregion + + #region Constructors + + public MonoRuntimeInfo( + string libraryPath, + string posixPath, + string managedPath, + bool isBleedingEdge, + string supportModulePath, + string[] triggerMethods) + { + LibraryPath = libraryPath; + PosixPath = posixPath; + ManagedPath = managedPath; + IsBleedingEdge = isBleedingEdge; + SupportModulePath = supportModulePath; + TriggerMethods = triggerMethods; + } + + #endregion + } +} diff --git a/Dependencies/Modules/Runtimes/Mono/Runtime.Mono/Runtime.Mono.csproj b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono/Runtime.Mono.csproj new file mode 100644 index 000000000..4cbb60d72 --- /dev/null +++ b/Dependencies/Modules/Runtimes/Mono/Runtime.Mono/Runtime.Mono.csproj @@ -0,0 +1,20 @@ + + + MelonLoader.Runtime.Mono + net6 + Latest + false + $(MLOutDir)/MelonLoader/Dependencies/Runtimes/Mono/ + true + embedded + MelonLoader.Runtime.Mono + + + + False + + + False + + + \ No newline at end of file diff --git a/BaseLibs/NetStandardPatches/System.Configuration.dll b/Dependencies/NetStandardPatches/System.Configuration.dll similarity index 100% rename from BaseLibs/NetStandardPatches/System.Configuration.dll rename to Dependencies/NetStandardPatches/System.Configuration.dll diff --git a/BaseLibs/NetStandardPatches/System.Core.dll b/Dependencies/NetStandardPatches/System.Core.dll similarity index 100% rename from BaseLibs/NetStandardPatches/System.Core.dll rename to Dependencies/NetStandardPatches/System.Core.dll diff --git a/BaseLibs/NetStandardPatches/System.Drawing.dll b/Dependencies/NetStandardPatches/System.Drawing.dll similarity index 100% rename from BaseLibs/NetStandardPatches/System.Drawing.dll rename to Dependencies/NetStandardPatches/System.Drawing.dll diff --git a/BaseLibs/NetStandardPatches/System.Xml.dll b/Dependencies/NetStandardPatches/System.Xml.dll similarity index 100% rename from BaseLibs/NetStandardPatches/System.Xml.dll rename to Dependencies/NetStandardPatches/System.Xml.dll diff --git a/BaseLibs/NetStandardPatches/System.dll b/Dependencies/NetStandardPatches/System.dll similarity index 100% rename from BaseLibs/NetStandardPatches/System.dll rename to Dependencies/NetStandardPatches/System.dll diff --git a/Dependencies/SupportModules/Component.cs b/Dependencies/SupportModules/Component.cs deleted file mode 100644 index 90f034561..000000000 --- a/Dependencies/SupportModules/Component.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.Reflection; -using UnityEngine; - -#if SM_Il2Cpp -using Il2CppInterop.Runtime; -#endif - -namespace MelonLoader.Support -{ - internal class SM_Component : MonoBehaviour - { - private bool isQuitting; - private static bool hadError; - private static bool useGeneratedAssembly = true; - - private static MethodInfo SetAsLastSiblingMethod; - -#if SM_Il2Cpp - private delegate bool SetAsLastSiblingDelegate(IntPtr transformptr); - private static SetAsLastSiblingDelegate SetAsLastSiblingDelegateField; - public SM_Component(IntPtr value) : base(value) { } -#endif - - static SM_Component() - { - try - { -#if SM_Il2Cpp - SetAsLastSiblingMethod = typeof(Transform).GetMethod("SetAsLastSibling", BindingFlags.Public | BindingFlags.Instance); - if (SetAsLastSiblingMethod != null) - return; - - useGeneratedAssembly = false; - SetAsLastSiblingDelegateField = IL2CPP.ResolveICall("UnityEngine.Transform::SetAsLastSibling"); - if (SetAsLastSiblingDelegateField == null) - throw new Exception("Unable to find Internal Call for UnityEngine.Transform::SetAsLastSibling"); -#else - SetAsLastSiblingMethod = typeof(Transform).GetMethod("SetAsLastSibling", BindingFlags.Public | BindingFlags.Instance); - if (SetAsLastSiblingMethod == null) - throw new Exception("Unable to find UnityEngine.Transform::SetAsLastSibling"); -#endif - } - catch (Exception ex) { LogError("Getting UnityEngine.Transform::SetAsLastSibling", ex); } - } - - internal static void Create() - { - if (Main.component != null) - return; - - Main.obj = new GameObject(); - DontDestroyOnLoad(Main.obj); - Main.obj.hideFlags = HideFlags.DontSave; - -#if SM_Il2Cpp - Main.component = Main.obj.AddComponent(Il2CppType.Of()).TryCast(); -#else - Main.component = (SM_Component)Main.obj.AddComponent(typeof(SM_Component)); -#endif - - Main.component.SiblingFix(); - } - - private static void LogError(string cat, Exception ex) - { - hadError = true; - useGeneratedAssembly = false; - MelonLogger.Warning($"Exception while {cat}: {ex}"); - MelonLogger.Warning("Melon Events might run before some MonoBehaviour Events"); - } - - private void SiblingFix() - { - if (hadError) - return; - - try - { - if (useGeneratedAssembly) - { - gameObject.transform.SetAsLastSibling(); - transform.SetAsLastSibling(); - return; - } - -#if SM_Il2Cpp - SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(gameObject.transform)); - SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(transform)); -#endif - } - catch (Exception ex) - { -#if SM_Il2Cpp - if (useGeneratedAssembly) - { - useGeneratedAssembly = false; - SiblingFix(); - return; - } -#endif - - LogError("Invoking UnityEngine.Transform::SetAsLastSibling", ex); - } - } - - void Start() - { - if ((Main.component != null) && (Main.component != this)) - return; - - SiblingFix(); - Main.Interface.OnApplicationLateStart(); - } - - void Awake() - { - if ((Main.component != null) && (Main.component != this)) - return; - - foreach (var queuedCoroutine in SupportModule_To.QueuedCoroutines) -#if SM_Il2Cpp - StartCoroutine(new Il2CppSystem.Collections.IEnumerator(new MonoEnumeratorWrapper(queuedCoroutine).Pointer)); -#else - StartCoroutine(queuedCoroutine); -#endif - SupportModule_To.QueuedCoroutines.Clear(); - } - - void Update() - { - if ((Main.component != null) && (Main.component != this)) - return; - - isQuitting = false; - SiblingFix(); - - SceneHandler.OnUpdate(); - Main.Interface.Update(); - } - - void OnDestroy() - { - if ((Main.component != null) && (Main.component != this)) - return; - - if (!isQuitting) - { - Create(); - return; - } - - OnApplicationDefiniteQuit(); - } - - void OnApplicationQuit() - { - if ((Main.component != null) && (Main.component != this)) - return; - - isQuitting = true; - Main.Interface.Quit(); - } - - void OnApplicationDefiniteQuit() - { - Main.Interface.DefiniteQuit(); - } - - void FixedUpdate() - { - if ((Main.component != null) && (Main.component != this)) - return; - - Main.Interface.FixedUpdate(); - } - - void LateUpdate() - { - if ((Main.component != null) && (Main.component != this)) - return; - - Main.Interface.LateUpdate(); - } - - void OnGUI() - { - if ((Main.component != null) && (Main.component != this)) - return; - - Main.Interface.OnGUI(); - } - } -} \ No newline at end of file diff --git a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj b/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj deleted file mode 100644 index 911436ae4..000000000 --- a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - MelonLoader.Support - net6 - true - $(MLOutDir)/MelonLoader/Dependencies/SupportModules - true - embedded - SM_Il2Cpp - true - https://nuget.bepinex.dev/v3/index.json - - - - Libs\Il2Cppmscorlib.dll - false - - - Libs\Il2CppSystem.dll - false - - - Libs\UnityEngine.CoreModule.dll - false - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Dependencies/SupportModules/Il2Cpp/InteropInterface.cs b/Dependencies/SupportModules/Il2Cpp/InteropInterface.cs deleted file mode 100644 index 06668b909..000000000 --- a/Dependencies/SupportModules/Il2Cpp/InteropInterface.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Il2CppInterop.Common; -using Il2CppInterop.Common.Attributes; -using Il2CppInterop.Runtime; -using Il2CppInterop.Runtime.Injection; -using Il2CppInterop.Runtime.InteropTypes; -using System; -using System.Reflection; - -namespace MelonLoader.Support -{ - internal class InteropInterface : InteropSupport.Interface - { - public IntPtr CopyMethodInfoStruct(IntPtr ptr) - => ptr; - //=> UnityVersionHandler.CopyMethodInfoStruct(ptr); - - public int? GetIl2CppMethodCallerCount(MethodBase method) - { - CallerCountAttribute att = method.GetCustomAttribute(); - if (att == null) - return null; - return att.Count; - } - - public FieldInfo MethodBaseToIl2CppFieldInfo(MethodBase method) - => Il2CppInteropUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(method); - - public void RegisterTypeInIl2CppDomain(Type type, bool logSuccess) - => ClassInjector.RegisterTypeInIl2Cpp(type, new() { LogSuccess = logSuccess }); - public void RegisterTypeInIl2CppDomainWithInterfaces(Type type, Type[] interfaces, bool logSuccess) - => ClassInjector.RegisterTypeInIl2Cpp(type, new() { LogSuccess = logSuccess, Interfaces = interfaces }); - - public bool IsInheritedFromIl2CppObjectBase(Type type) - => (type != null) && type.IsSubclassOf(typeof(Il2CppObjectBase)); - - public bool IsInjectedType(Type type) - { - IntPtr ptr = GetClassPointerForType(type); - return ptr != IntPtr.Zero && RuntimeSpecificsStore.IsInjected(ptr); - } - - public IntPtr GetClassPointerForType(Type type) - { - if (type == typeof(void)) return Il2CppClassPointerStore.NativeClassPtr; - return (IntPtr)typeof(Il2CppClassPointerStore<>).MakeGenericType(type) - .GetField(nameof(Il2CppClassPointerStore.NativeClassPtr)).GetValue(null); - } - } -} diff --git a/Dependencies/SupportModules/Il2Cpp/Main.cs b/Dependencies/SupportModules/Il2Cpp/Main.cs deleted file mode 100644 index 6e280d897..000000000 --- a/Dependencies/SupportModules/Il2Cpp/Main.cs +++ /dev/null @@ -1,236 +0,0 @@ -using Il2CppInterop.HarmonySupport; -using Il2CppInterop.Runtime.Injection; -using Il2CppInterop.Runtime.Startup; -using MelonLoader.Support.Preferences; -using System; -using System.Reflection; -using System.Runtime.InteropServices; -using MelonLoader.CoreClrUtils; -using UnityEngine; -using Il2CppInterop.Common; -using Microsoft.Extensions.Logging; -using MelonLoader.Utils; -using System.IO; -using MelonLoader.InternalUtils; - -[assembly: MelonLoader.PatchShield] - -namespace MelonLoader.Support -{ - internal static class Main - { - internal static ISupportModule_From Interface; - internal static InteropInterface Interop; - internal static GameObject obj = null; - internal static SM_Component component = null; - - private static Assembly Il2Cppmscorlib = null; - private static Type streamType = null; - - private static ISupportModule_To Initialize(ISupportModule_From interface_from) - { - Interface = interface_from; - - foreach (var file in Directory.GetFiles(MelonEnvironment.Il2CppAssembliesDirectory, "*.dll")) - { - try - { - Assembly.LoadFrom(file); - } - catch { } - } - - UnityMappers.RegisterMappers(); - - Il2CppInteropRuntime runtime = Il2CppInteropRuntime.Create(new() - { - DetourProvider = new MelonDetourProvider(), - UnityVersion = new Version( - InternalUtils.UnityInformationHandler.EngineVersion.Major, - InternalUtils.UnityInformationHandler.EngineVersion.Minor, - InternalUtils.UnityInformationHandler.EngineVersion.Build) - }).AddLogger(new InteropLogger()) - .AddHarmonySupport(); - - if (!LoaderConfig.Current.UnityEngine.DisableConsoleLogCleaner) - ConsoleCleaner(); - - SceneHandler.Init(); - - MonoEnumeratorWrapper.Register(); - - ClassInjector.RegisterTypeInIl2Cpp(); - SM_Component.Create(); - - Interop = new InteropInterface(); - Interface.SetInteropSupportInterface(Interop); - runtime.Start(); - - return new SupportModule_To(); - } - - private static void ConsoleCleaner() - { - // Il2CppSystem.Console.SetOut(new Il2CppSystem.IO.StreamWriter(Il2CppSystem.IO.Stream.Null)); - try - { - Il2Cppmscorlib = Assembly.Load("Il2Cppmscorlib"); - if (Il2Cppmscorlib == null) - throw new Exception("Unable to Find Assembly Il2Cppmscorlib!"); - - streamType = Il2Cppmscorlib.GetType("Il2CppSystem.IO.Stream"); - if (streamType == null) - throw new Exception("Unable to Find Type Il2CppSystem.IO.Stream!"); - - PropertyInfo propertyInfo = streamType.GetProperty("Null", BindingFlags.Static | BindingFlags.Public); - if (propertyInfo == null) - throw new Exception("Unable to Find Property Il2CppSystem.IO.Stream.Null!"); - - MethodInfo nullStreamField = propertyInfo.GetGetMethod(); - if (nullStreamField == null) - throw new Exception("Unable to Find Get Method of Property Il2CppSystem.IO.Stream.Null!"); - - object nullStream = nullStreamField.Invoke(null, new object[0]); - if (nullStream == null) - throw new Exception("Unable to Get Value of Property Il2CppSystem.IO.Stream.Null!"); - - Type streamWriterType = Il2Cppmscorlib.GetType("Il2CppSystem.IO.StreamWriter"); - if (streamWriterType == null) - throw new Exception("Unable to Find Type Il2CppSystem.IO.StreamWriter!"); - - ConstructorInfo streamWriterCtor = streamWriterType.GetConstructor(new[] { streamType }); - if (streamWriterCtor == null) - throw new Exception("Unable to Find Constructor of Type Il2CppSystem.IO.StreamWriter!"); - - object nullStreamWriter = streamWriterCtor.Invoke(new[] { nullStream }); - if (nullStreamWriter == null) - throw new Exception("Unable to Invoke Constructor of Type Il2CppSystem.IO.StreamWriter!"); - - Type consoleType = Il2Cppmscorlib.GetType("Il2CppSystem.Console"); - if (consoleType == null) - throw new Exception("Unable to Find Type Il2CppSystem.Console!"); - - MethodInfo setOutMethod = consoleType.GetMethod("SetOut", BindingFlags.Static | BindingFlags.Public); - if (setOutMethod == null) - throw new Exception("Unable to Find Method Il2CppSystem.Console.SetOut!"); - - setOutMethod.Invoke(null, new[] { nullStreamWriter }); - } - catch (Exception ex) { MelonLogger.Warning($"Console Cleaner Failed: {ex}"); } - } - } - - internal sealed class MelonDetourProvider : IDetourProvider - { - public IDetour Create(nint original, TDelegate target) where TDelegate : Delegate - { - return new MelonDetour(original, target); - } - - private sealed class MelonDetour : IDetour - { - private nint _detourFrom; - private nint _originalPtr; - - private Delegate _target; - private IntPtr _targetPtr; - - /// - /// Original method - /// - public nint Target => _detourFrom; - - public nint Detour => _targetPtr; - public nint OriginalTrampoline => _originalPtr; - - public MelonDetour(nint detourFrom, Delegate target) - { - _detourFrom = detourFrom; - _target = target; - - // We have to apply immediately because we're gonna be asked for a trampoline right away - Apply(); - } - - public unsafe void Apply() - { - if (_targetPtr != IntPtr.Zero) - return; - - _targetPtr = Marshal.GetFunctionPointerForDelegate(_target); - - var addr = _detourFrom; - nint addrPtr = (nint)(&addr); - BootstrapInterop.NativeHookAttachDirect(addrPtr, _targetPtr); - NativeStackWalk.RegisterHookAddr((ulong)addrPtr, $"Il2CppInterop detour of 0x{addrPtr:X} -> 0x{_targetPtr:X}"); - - _originalPtr = addr; - } - - public unsafe void Dispose() - { - if (_targetPtr == IntPtr.Zero) - return; - - var addr = _detourFrom; - nint addrPtr = (nint)(&addr); - - BootstrapInterop.NativeHookDetach(addrPtr, _targetPtr); - NativeStackWalk.UnregisterHookAddr((ulong)addrPtr); - - _targetPtr = IntPtr.Zero; - _originalPtr = IntPtr.Zero; - } - - public T GenerateTrampoline() - where T : Delegate - { - if (_originalPtr == IntPtr.Zero) - return null; - return Marshal.GetDelegateForFunctionPointer(_originalPtr); - } - } - } - - internal class InteropLogger - : Microsoft.Extensions.Logging.ILogger - { - private MelonLogger.Instance _logger = new("Il2CppInterop"); - - public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, - Func formatter) - { - string formattedTxt = formatter(state, exception); - switch (logLevel) - { - case LogLevel.Debug: - case LogLevel.Trace: - MelonDebug.Msg(formattedTxt); - break; - - case LogLevel.Error: - _logger.Error(formattedTxt); - break; - - case LogLevel.Warning: - _logger.Warning(formattedTxt); - break; - - case LogLevel.Information: - default: - _logger.Msg(formattedTxt); - break; - } - } - - public bool IsEnabled(LogLevel logLevel) - => logLevel switch - { - LogLevel.Debug or LogLevel.Trace => MelonDebug.IsEnabled(), - _ => true - }; - - public IDisposable BeginScope(TState state) - => throw new NotImplementedException(); - } -} diff --git a/Dependencies/SupportModules/Il2Cpp/MonoEnumeratorWrapper.cs b/Dependencies/SupportModules/Il2Cpp/MonoEnumeratorWrapper.cs deleted file mode 100644 index e55aecf2a..000000000 --- a/Dependencies/SupportModules/Il2Cpp/MonoEnumeratorWrapper.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Il2CppInterop.Runtime.Injection; -using System; -using System.Collections; - -namespace MelonLoader.Support -{ - public class MonoEnumeratorWrapper : Il2CppSystem.Object /*, IEnumerator */ - { - internal unsafe static void Register() - => ClassInjector.RegisterTypeInIl2Cpp(new() - { - LogSuccess = true, - Interfaces = new Type[] { typeof(Il2CppSystem.Collections.IEnumerator) } - }); - - private readonly IEnumerator enumerator; - public MonoEnumeratorWrapper(IntPtr ptr) : base(ptr) { } - public MonoEnumeratorWrapper(IEnumerator _enumerator) : base(ClassInjector.DerivedConstructorPointer()) - { - ClassInjector.DerivedConstructorBody(this); - enumerator = _enumerator ?? throw new NullReferenceException("routine is null"); - } - - public Il2CppSystem.Object /*IEnumerator.*/Current - { - get => enumerator.Current switch - { - IEnumerator next => new MonoEnumeratorWrapper(next), - Il2CppSystem.Object il2cppObject => il2cppObject, - null => null, - _ => throw new NotSupportedException($"{enumerator.GetType()}: Unsupported type {enumerator.Current.GetType()}"), - }; - } - - public bool MoveNext() - { - try - { - return enumerator.MoveNext(); - } catch(Exception e) - { - var melon = MelonUtils.GetMelonFromStackTrace(new System.Diagnostics.StackTrace(e), true); - - if (melon != null) - melon.LoggerInstance.Error("Unhandled exception in coroutine. It will not continue executing.", e); - else - MelonLogger.Error("[Error: Could not identify source] Unhandled exception in coroutine. It will not continue executing.", e); - - return false; - } - } - - public void Reset() => enumerator.Reset(); - } -} diff --git a/Dependencies/SupportModules/Mono/Main.cs b/Dependencies/SupportModules/Mono/Main.cs deleted file mode 100644 index a12bce579..000000000 --- a/Dependencies/SupportModules/Mono/Main.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Reflection; -using MelonLoader.Support.Preferences; -using UnityEngine; - -[assembly: MelonLoader.PatchShield] - -namespace MelonLoader.Support -{ - internal static class Main - { - internal static ISupportModule_From Interface = null; - internal static GameObject obj = null; - internal static SM_Component component = null; - - private static ISupportModule_To Initialize(ISupportModule_From interface_from) - { - Interface = interface_from; - UnityMappers.RegisterMappers(); - - if (IsUnity53OrLower()) - SM_Component.Create(); - else - SceneHandler.Init(); - - return new SupportModule_To(); - } - - private static bool IsUnity53OrLower() - { - try - { - Assembly unityengine = Assembly.Load("UnityEngine"); - if (unityengine == null) - return true; - Type scenemanager = unityengine.GetType("UnityEngine.SceneManagement.SceneManager"); - if (scenemanager == null) - return true; - EventInfo sceneLoaded = scenemanager.GetEvent("sceneLoaded"); - if (sceneLoaded == null) - return true; - return false; - } - catch { return true; } - } - } -} \ No newline at end of file diff --git a/Dependencies/SupportModules/Mono/Mono.csproj b/Dependencies/SupportModules/Mono/Mono.csproj deleted file mode 100644 index b623fb833..000000000 --- a/Dependencies/SupportModules/Mono/Mono.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - MelonLoader.Support - net35 - true - $(MLOutDir)/MelonLoader/Dependencies/SupportModules - true - embedded - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Dependencies/SupportModules/SceneHandler.cs b/Dependencies/SupportModules/SceneHandler.cs deleted file mode 100644 index 01c4e45f5..000000000 --- a/Dependencies/SupportModules/SceneHandler.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using UnityEngine.SceneManagement; -using System.Collections.Generic; -#if SM_Il2Cpp -using UnityEngine.Events; -#endif - -#pragma warning disable CA2013 - -namespace MelonLoader.Support -{ - internal static class SceneHandler - { - internal class SceneInitEvent - { - internal int buildIndex; - internal string name; - internal bool wasLoadedThisTick; - } - - private static Queue scenesLoaded = new Queue(); - - internal static void Init() - { - try - { -#if SM_Il2Cpp - SceneManager.sceneLoaded = ( - (ReferenceEquals(SceneManager.sceneLoaded, null)) - ? new Action(OnSceneLoad) - : Il2CppSystem.Delegate.Combine(SceneManager.sceneLoaded, (UnityAction)new Action(OnSceneLoad)).Cast>() - ); -#else - SceneManager.sceneLoaded += OnSceneLoad; -#endif - } - catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneLoaded override failed: {ex}"); } - - try - { -#if SM_Il2Cpp - SceneManager.sceneUnloaded = ( - (ReferenceEquals(SceneManager.sceneUnloaded, null)) - ? new Action(OnSceneUnload) - : Il2CppSystem.Delegate.Combine(SceneManager.sceneUnloaded, (UnityAction)new Action(OnSceneUnload)).Cast>() - ); -#else - SceneManager.sceneUnloaded += OnSceneUnload; -#endif - } - catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneUnloaded override failed: {ex}"); } - } - - private static void OnSceneLoad(Scene scene, LoadSceneMode mode) - { - if (Main.obj == null) - SM_Component.Create(); - - if (ReferenceEquals(scene, null)) - return; - - Main.Interface.OnSceneWasLoaded(scene.buildIndex, scene.name); - scenesLoaded.Enqueue(new SceneInitEvent { buildIndex = scene.buildIndex, name = scene.name }); - } - - private static void OnSceneUnload(Scene scene) - { - if (ReferenceEquals(scene, null)) - return; - - Main.Interface.OnSceneWasUnloaded(scene.buildIndex, scene.name); - } - - internal static void OnUpdate() - { - if (scenesLoaded.Count > 0) - { - Queue requeue = new Queue(); - SceneInitEvent evt = null; - while ((scenesLoaded.Count > 0) && ((evt = scenesLoaded.Dequeue()) != null)) - { - if (evt.wasLoadedThisTick) - Main.Interface.OnSceneWasInitialized(evt.buildIndex, evt.name); - else - { - evt.wasLoadedThisTick = true; - requeue.Enqueue(evt); - } - } - while ((requeue.Count > 0) && ((evt = requeue.Dequeue()) != null)) - scenesLoaded.Enqueue(evt); - } - } - } -} diff --git a/Dependencies/SupportModules/SupportModule_To.cs b/Dependencies/SupportModules/SupportModule_To.cs deleted file mode 100644 index c33a4b839..000000000 --- a/Dependencies/SupportModules/SupportModule_To.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace MelonLoader.Support -{ - internal class SupportModule_To : ISupportModule_To - { - internal static readonly List QueuedCoroutines = new List(); - public object StartCoroutine(IEnumerator coroutine) - { - if (Main.component != null) -#if SM_Il2Cpp - return Main.component.StartCoroutine(new Il2CppSystem.Collections.IEnumerator(new MonoEnumeratorWrapper(coroutine).Pointer)); -#else - return Main.component.StartCoroutine(coroutine); -#endif - QueuedCoroutines.Add(coroutine); - return coroutine; - } - public void StopCoroutine(object coroutineToken) - { - if (Main.component == null) - QueuedCoroutines.Remove(coroutineToken as IEnumerator); - else - Main.component.StopCoroutine(coroutineToken as Coroutine); - } - public void UnityDebugLog(string msg) => Debug.Log(msg); - } -} \ No newline at end of file diff --git a/Dependencies/SupportModules/UnityMappers.cs b/Dependencies/SupportModules/UnityMappers.cs deleted file mode 100644 index 9646a9866..000000000 --- a/Dependencies/SupportModules/UnityMappers.cs +++ /dev/null @@ -1,103 +0,0 @@ -using Tomlet; -using Tomlet.Models; -using UnityEngine; - -namespace MelonLoader.Support.Preferences -{ - internal static class UnityMappers - { - internal static void RegisterMappers() - { - TomletMain.RegisterMapper(WriteColor, ReadColor); - TomletMain.RegisterMapper(WriteColor32, ReadColor32); - TomletMain.RegisterMapper(WriteVector2, ReadVector2); - TomletMain.RegisterMapper(WriteVector3, ReadVector3); - TomletMain.RegisterMapper(WriteVector4, ReadVector4); - TomletMain.RegisterMapper(WriteQuaternion, ReadQuaternion); - } - - private static Color ReadColor(TomlValue value) - { - float[] floats = MelonPreferences.Mapper.ReadArray(value); - if (floats == null || floats.Length != 4) - return default; - return new Color(floats[0] / 255f, floats[1] / 255f, floats[2] / 255f, floats[3] / 255f); - } - - private static TomlValue WriteColor(Color value) - { - float[] floats = new[] { value.r * 255, value.g * 255, value.b * 255, value.a * 255}; - return MelonPreferences.Mapper.WriteArray(floats); - } - - private static Color32 ReadColor32(TomlValue value) - { - byte[] bytes = MelonPreferences.Mapper.ReadArray(value); - if (bytes == null || bytes.Length != 4) - return default; - return new Color32(bytes[0], bytes[1], bytes[2], bytes[3]); - } - - private static TomlValue WriteColor32(Color32 value) - { - byte[] bytes = new[] { value.r, value.g, value.b, value.a }; - return MelonPreferences.Mapper.WriteArray(bytes); - } - - private static Vector2 ReadVector2(TomlValue value) - { - float[] floats = MelonPreferences.Mapper.ReadArray(value); - if (floats == null || floats.Length != 2) - return default; - return new Vector2(floats[0], floats[1]); - } - - private static TomlValue WriteVector2(Vector2 value) - { - float[] floats = new[] { value.x, value.y }; - return MelonPreferences.Mapper.WriteArray(floats); - } - - private static Vector3 ReadVector3(TomlValue value) - { - float[] floats = MelonPreferences.Mapper.ReadArray(value); - if (floats == null || floats.Length != 3) - return default; - return new Vector3(floats[0], floats[1], floats[2]); - } - - private static TomlValue WriteVector3(Vector3 value) - { - float[] floats = new[] { value.x, value.y, value.z }; - return MelonPreferences.Mapper.WriteArray(floats); - } - - private static Vector4 ReadVector4(TomlValue value) - { - float[] floats = MelonPreferences.Mapper.ReadArray(value); - if (floats == null || floats.Length != 4) - return default; - return new Vector4(floats[0], floats[1], floats[2], floats[3]); - } - - private static TomlValue WriteVector4(Vector4 value) - { - float[] floats = new[] { value.x, value.y, value.z, value.w }; - return MelonPreferences.Mapper.WriteArray(floats); - } - - private static Quaternion ReadQuaternion(TomlValue value) - { - float[] floats = MelonPreferences.Mapper.ReadArray(value); - if (floats == null || floats.Length != 4) - return default; - return new Quaternion(floats[0], floats[1], floats[2], floats[3]); - } - - private static TomlValue WriteQuaternion(Quaternion value) - { - float[] floats = new[] { value.x, value.y, value.z, value.w }; - return MelonPreferences.Mapper.WriteArray(floats); - } - } -} \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index 7b6020ff5..4af3be84d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 0.7.0 - 1.4.6-ci.579 + 1.0.0 + 1.4.6-ci.602 Lava Gang discord.gg/2Wn3N2P diff --git a/MelonLoader.Bootstrap/Core.cs b/MelonLoader.Bootstrap/Core.cs index d7bb0a597..662bf0381 100644 --- a/MelonLoader.Bootstrap/Core.cs +++ b/MelonLoader.Bootstrap/Core.cs @@ -1,6 +1,4 @@ using MelonLoader.Bootstrap.Logging; -using MelonLoader.Bootstrap.RuntimeHandlers.Il2Cpp; -using MelonLoader.Bootstrap.RuntimeHandlers.Mono; using MelonLoader.Bootstrap.Utils; using System.Diagnostics.CodeAnalysis; using System.Drawing; @@ -13,8 +11,6 @@ public static class Core public static nint LibraryHandle { get; private set; } internal static InternalLogger Logger { get; private set; } = new(Color.BlueViolet, "MelonLoader.Bootstrap"); - public static string DataDir { get; private set; } = null!; - public static string GameDir { get; private set; } = null!; #if LINUX [System.Runtime.InteropServices.UnmanagedCallersOnly(EntryPoint = "Init")] @@ -25,10 +21,8 @@ public static void Init(nint moduleHandle) LibraryHandle = moduleHandle; var exePath = Environment.ProcessPath!; - GameDir = Path.GetDirectoryName(exePath)!; - - DataDir = Path.Combine(GameDir, Path.GetFileNameWithoutExtension(exePath) + "_Data"); - if (!Directory.Exists(DataDir)) + string exeName = Path.GetFileName(exePath); + if (exeName.ToLower().Contains("unitycrashhandler")) return; InitConfig(); @@ -40,8 +34,7 @@ public static void Init(nint moduleHandle) MelonDebug.Log("Starting probe for runtime"); - if (Il2CppHandler.TryInitialize() - || MonoHandler.TryInitialize()) + if (NativeHostLoader.Initialize()) { ConsoleHandler.NullHandles(); return; @@ -56,7 +49,7 @@ private static void InitConfig() var customBaseDir = ArgParser.GetValue("melonloader.basedir"); var baseDir = Directory.Exists(customBaseDir) ? Path.GetFullPath(customBaseDir) : LoaderConfig.Current.Loader.BaseDirectory; - var path = Path.Combine(baseDir, "UserData", "Loader.cfg"); + var path = Path.Combine(baseDir, "MelonLoader", "UserData", "Loader.cfg"); if (File.Exists(path)) { @@ -118,32 +111,5 @@ private static void InitConfig() if (uint.TryParse(ArgParser.GetValue("melonloader.maxlogs"), out var maxLogs)) LoaderConfig.Current.Logs.MaxLogs = maxLogs; - - var unityVersionOverride = ArgParser.GetValue("melonloader.unityversion"); - if (unityVersionOverride != null) - LoaderConfig.Current.UnityEngine.VersionOverride = unityVersionOverride; - - if (ArgParser.IsDefined("melonloader.disableunityclc")) - LoaderConfig.Current.UnityEngine.DisableConsoleLogCleaner = true; - - if (ArgParser.IsDefined("melonloader.agfregenerate")) - LoaderConfig.Current.UnityEngine.ForceRegeneration = true; - - if (ArgParser.IsDefined("melonloader.agfoffline")) - LoaderConfig.Current.UnityEngine.ForceOfflineGeneration = true; - - var forceRegex = ArgParser.GetValue("melonloader.agfregex"); - if (forceRegex != null) - LoaderConfig.Current.UnityEngine.ForceGeneratorRegex = forceRegex; - - var forceDumperVersion = ArgParser.GetValue("melonloader.agfvdumper"); - if (forceDumperVersion != null) - LoaderConfig.Current.UnityEngine.ForceIl2CppDumperVersion = forceDumperVersion; - - if (ArgParser.IsDefined("cpp2il.callanalyzer")) - LoaderConfig.Current.UnityEngine.EnableCpp2ILCallAnalyzer = true; - - if (ArgParser.IsDefined("cpp2il.nativemethoddetector")) - LoaderConfig.Current.UnityEngine.EnableCpp2ILNativeMethodDetector = true; } } diff --git a/MelonLoader.Bootstrap/Deps/LICENSE b/MelonLoader.Bootstrap/Deps/LICENSE new file mode 100644 index 000000000..f49a4e16e --- /dev/null +++ b/MelonLoader.Bootstrap/Deps/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/MelonLoader.Bootstrap/Deps/android-arm64-v8a/libdobby.a b/MelonLoader.Bootstrap/Deps/android-arm64-v8a/libdobby.a new file mode 100644 index 000000000..9e54bcbd5 Binary files /dev/null and b/MelonLoader.Bootstrap/Deps/android-arm64-v8a/libdobby.a differ diff --git a/MelonLoader.Bootstrap/Exports.cs b/MelonLoader.Bootstrap/Exports.cs index f020dec64..ad9ec75f0 100644 --- a/MelonLoader.Bootstrap/Exports.cs +++ b/MelonLoader.Bootstrap/Exports.cs @@ -1,5 +1,4 @@ using MelonLoader.Bootstrap.Logging; -using MelonLoader.Bootstrap.RuntimeHandlers.Mono; using MelonLoader.Bootstrap.Utils; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -81,24 +80,6 @@ public static unsafe void LogMelonInfo(ColorRGB* nameColor, char* name, int name MelonLogger.LogMelonInfo(*nameColor, new(name, nameLength), new(info, infoLength)); } - [UnmanagedCallersOnly(EntryPoint = "MonoInstallHooks")] - public static void MonoInstallHooks() - { - MonoHandler.InstallHooks(); - } - - [UnmanagedCallersOnly(EntryPoint = "MonoGetDomainPtr")] - public static nint MonoGetDomainPtr() - { - return MonoHandler.Domain; - } - - [UnmanagedCallersOnly(EntryPoint = "MonoGetRuntimeHandle")] - public static nint MonoGetRuntimeHandle() - { - return MonoHandler.Mono.Handle; - } - [UnmanagedCallersOnly(EntryPoint = "IsConsoleOpen")] [return: MarshalAs(UnmanagedType.U1)] public static bool IsConsoleOpen() diff --git a/MelonLoader.Bootstrap/Exports.def b/MelonLoader.Bootstrap/Exports.def index d4ca03b78..b9229ad53 100644 --- a/MelonLoader.Bootstrap/Exports.def +++ b/MelonLoader.Bootstrap/Exports.def @@ -8,9 +8,6 @@ EXPORTS LogMsg LogError LogMelonInfo - MonoInstallHooks - MonoGetDomainPtr - MonoGetRuntimeHandle IsConsoleOpen GetLoaderConfig diff --git a/MelonLoader.Bootstrap/MelonLoader.Bootstrap.csproj b/MelonLoader.Bootstrap/MelonLoader.Bootstrap.csproj index fdb3a7f0e..29b7468e2 100644 --- a/MelonLoader.Bootstrap/MelonLoader.Bootstrap.csproj +++ b/MelonLoader.Bootstrap/MelonLoader.Bootstrap.csproj @@ -31,7 +31,7 @@ - + @@ -56,7 +56,7 @@ - + diff --git a/MelonLoader.Bootstrap/NativeHostLoader.cs b/MelonLoader.Bootstrap/NativeHostLoader.cs new file mode 100644 index 000000000..c1d46419c --- /dev/null +++ b/MelonLoader.Bootstrap/NativeHostLoader.cs @@ -0,0 +1,156 @@ +using MelonLoader.Bootstrap.Utils; +using System.Runtime.InteropServices; +using System.Text; + +namespace MelonLoader.Bootstrap; + +internal static partial class NativeHostLoader +{ + private const CharSet hostfxrCharSet = +#if WINDOWS + CharSet.Unicode; +#else + CharSet.Ansi; +#endif + + private const StringMarshalling hostfxrStringMarsh = +#if WINDOWS + StringMarshalling.Utf16; +#else + StringMarshalling.Utf8; +#endif + + private delegate void InitializeFn(ref nint bootstrapHandlePtr, ref nint loadLibPtr, ref nint getExportPtr); + + public static bool Initialize() + { + var managedDir = Path.Combine(LoaderConfig.Current.Loader.BaseDirectory, "MelonLoader", "Dependencies", "net6"); + var runtimeConfigPath = Path.Combine(managedDir, "MelonLoader.runtimeconfig.json"); + var nativeHostPath = Path.Combine(managedDir, "MelonLoader.NativeHost.dll"); + + if (!File.Exists(runtimeConfigPath)) + { + Core.Logger.Error($"Runtime config not found at: '{runtimeConfigPath}'"); + return false; + } + + if (!File.Exists(nativeHostPath)) + { + Core.Logger.Error($"NativeHost not found at: '{runtimeConfigPath}'"); + return false; + } + + MelonDebug.Log("Attempting to load hostfxr"); + if (!LoadHostfxr()) + { + if (!LoadHostfxr()) + { + Core.Logger.Error("Failed to load Hostfxr"); + return false; + } + } + + MelonDebug.Log("Initializing domain"); + if (!InitializeForRuntimeConfig(runtimeConfigPath, out var context)) + { + if (!InitializeForRuntimeConfig(runtimeConfigPath, out context)) + { + Core.Logger.Error($"Failed to initialize a .NET domain"); + return false; + } + } + + MelonDebug.Log("Loading NativeHost assembly"); + var initialize = LoadAssemblyAndGetFunctionUco(context, nativeHostPath, "MelonLoader.NativeHost.NativeEntryPoint, MelonLoader.NativeHost", "NativeEntry"); + if (initialize == null) + { + Core.Logger.Error($"Failed to load assembly from: '{nativeHostPath}'"); + return false; + } + + MelonDebug.Log("Invoking NativeHost entry"); + + var bootstrapHandlePtr = Core.LibraryHandle; + + NativeLoadLibFn loadLibFuncDel = NativeFunc.NativeLoadLib; + NativeGetExportFn getExportFuncDel = NativeFunc.NativeGetExport; + + var loadLibFuncPtr = Marshal.GetFunctionPointerForDelegate(loadLibFuncDel); + var getExportFuncPtr = Marshal.GetFunctionPointerForDelegate(getExportFuncDel); + + initialize(ref bootstrapHandlePtr, ref loadLibFuncPtr, ref getExportFuncPtr); + + return true; + } + + public static bool LoadHostfxr() + { + var path = GetHostfxrPath(); + return path != null && NativeLibrary.TryLoad(path, out _); + } + + private static string? GetHostfxrPath() + { + var buffer = new StringBuilder(1024); + var bufferSize = (nint)buffer.Capacity; + var result = get_hostfxr_path(buffer, ref bufferSize, 0); + return result != 0 ? null : buffer.ToString(); + } + + public static bool InitializeForRuntimeConfig(string runtimeConfigPath, out nint context) + { + nint ctx = 0; + ConsoleHandler.NullHandles(); // Prevent it from logging its own stuff + var status = hostfxr_initialize_for_runtime_config(runtimeConfigPath, 0, ref ctx); + ConsoleHandler.ResetHandles(); + + if (status != 0) + { + context = 0; + return false; + } + + context = ctx; + return true; + } + + public static TDelegate? LoadAssemblyAndGetFunctionUco(nint context, string assemblyPath, string typeName, string methodName) where TDelegate : Delegate + { + LoadAssemblyAndGetFunctionPointerFn? loadAssemblyAndGetFunctionPointer = null; + hostfxr_get_runtime_delegate(context, HostfxrDelegateType.HdtLoadAssemblyAndGetFunctionPointer, ref loadAssemblyAndGetFunctionPointer); + if (loadAssemblyAndGetFunctionPointer == null) + return null; + + nint funcPtr = 0; + loadAssemblyAndGetFunctionPointer(assemblyPath, typeName, methodName, -1, 0, ref funcPtr); + if (funcPtr == 0) + return null; + + return Marshal.GetDelegateForFunctionPointer(funcPtr); + } + + [DllImport("*", CharSet = hostfxrCharSet)] + private static extern int get_hostfxr_path(StringBuilder buffer, ref nint bufferSize, nint parameters); + + [LibraryImport("hostfxr", StringMarshalling = hostfxrStringMarsh)] + private static partial int hostfxr_initialize_for_runtime_config(string runtimeConfigPath, nint parameters, ref nint hostContextHandle); + + [LibraryImport("hostfxr")] + private static partial int hostfxr_get_runtime_delegate(nint context, HostfxrDelegateType type, ref LoadAssemblyAndGetFunctionPointerFn? del); + + private enum HostfxrDelegateType + { + HdtComActivation, + HdtLoadInMemoryAssembly, + HdtWinrtActivation, + HdtComRegister, + HdtComUnregister, + HdtLoadAssemblyAndGetFunctionPointer, + HdtGetFunctionPointer, + HdtLoadAssembly, + HdtLoadAssemblyBytes, + }; + + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = hostfxrCharSet)] + private delegate void LoadAssemblyAndGetFunctionPointerFn(string assemblyPath, string typeName, string methodName, nint delegateTypeName, nint reserved, ref nint funcPtr); +} diff --git a/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/Dotnet.cs b/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/Dotnet.cs deleted file mode 100644 index b3bbe1010..000000000 --- a/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/Dotnet.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System.Runtime.InteropServices; -using System.Text; - -namespace MelonLoader.Bootstrap.RuntimeHandlers.Il2Cpp; - -internal static partial class Dotnet -{ - private const CharSet hostfxrCharSet = -#if WINDOWS - CharSet.Unicode; -#else - CharSet.Ansi; -#endif - private const StringMarshalling hostfxrStringMarsh = -#if WINDOWS - StringMarshalling.Utf16; -#else - StringMarshalling.Utf8; -#endif - - public static bool LoadHostfxr() - { - var path = GetHostfxrPath(); - return path != null && NativeLibrary.TryLoad(path, out _); - } - - private static string? GetHostfxrPath() - { - var buffer = new StringBuilder(1024); - var bufferSize = (nint)buffer.Capacity; - var result = get_hostfxr_path(buffer, ref bufferSize, 0); - return result != 0 ? null : buffer.ToString(); - } - - public static bool InitializeForRuntimeConfig(string runtimeConfigPath, out nint context) - { - nint ctx = 0; - ConsoleHandler.NullHandles(); // Prevent it from logging its own stuff - var status = hostfxr_initialize_for_runtime_config(runtimeConfigPath, 0, ref ctx); - ConsoleHandler.ResetHandles(); - - if (status != 0) - { - context = 0; - return false; - } - - context = ctx; - return true; - } - - public static TDelegate? LoadAssemblyAndGetFunctionUco(nint context, string assemblyPath, string typeName, string methodName) where TDelegate : Delegate - { - LoadAssemblyAndGetFunctionPointerFn? loadAssemblyAndGetFunctionPointer = null; - hostfxr_get_runtime_delegate(context, HostfxrDelegateType.HdtLoadAssemblyAndGetFunctionPointer, ref loadAssemblyAndGetFunctionPointer); - if (loadAssemblyAndGetFunctionPointer == null) - return null; - - nint funcPtr = 0; - loadAssemblyAndGetFunctionPointer(assemblyPath, typeName, methodName, -1, 0, ref funcPtr); - if (funcPtr == 0) - return null; - - return Marshal.GetDelegateForFunctionPointer(funcPtr); - } - - [DllImport("*", CharSet = hostfxrCharSet)] - private static extern int get_hostfxr_path(StringBuilder buffer, ref nint bufferSize, nint parameters); - - [LibraryImport("hostfxr", StringMarshalling = hostfxrStringMarsh)] - private static partial int hostfxr_initialize_for_runtime_config(string runtimeConfigPath, nint parameters, ref nint hostContextHandle); - - [LibraryImport("hostfxr")] - private static partial int hostfxr_get_runtime_delegate(nint context, HostfxrDelegateType type, ref LoadAssemblyAndGetFunctionPointerFn? del); - - private enum HostfxrDelegateType - { - HdtComActivation, - HdtLoadInMemoryAssembly, - HdtWinrtActivation, - HdtComRegister, - HdtComUnregister, - HdtLoadAssemblyAndGetFunctionPointer, - HdtGetFunctionPointer, - HdtLoadAssembly, - HdtLoadAssemblyBytes, - }; - - [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = hostfxrCharSet)] - private delegate void LoadAssemblyAndGetFunctionPointerFn(string assemblyPath, string typeName, string methodName, nint delegateTypeName, nint reserved, ref nint funcPtr); -} diff --git a/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/DotnetInstaller.cs b/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/DotnetInstaller.cs deleted file mode 100644 index 43ab0b54f..000000000 --- a/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/DotnetInstaller.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System.Diagnostics; - -namespace MelonLoader.Bootstrap.RuntimeHandlers.Il2Cpp; - -internal static class DotnetInstaller -{ - private readonly static string dotnetRuntimeDownload = -#if X64 - "https://aka.ms/dotnet/6.0/dotnet-runtime-win-x64.exe"; -#else - "https://aka.ms/dotnet/6.0/dotnet-runtime-win-x86.exe"; -#endif - - public static void AttemptInstall() - { -#if WINDOWS - AttemptInstallAsync().GetAwaiter().GetResult(); -#endif - } - - private static async Task AttemptInstallAsync() - { - var http = new HttpClient(); - http.DefaultRequestHeaders.Add("User-Agent", "MelonLoader"); - - Core.Logger.Msg("Downloading the .NET Runtime installer..."); - - HttpResponseMessage resp; - try - { - resp = await http.GetAsync(dotnetRuntimeDownload, HttpCompletionOption.ResponseContentRead); - } - catch - { - Core.Logger.Error("Failed to download the .NET Runtime installer. Check your internet connection."); - return; - } - - if (!resp.IsSuccessStatusCode) - { - Core.Logger.Error($"Failed to download the .NET Runtime installer. Reason: '{resp.ReasonPhrase}'"); - return; - } - - Core.Logger.Msg("Installing the .NET Runtime..."); - - var installerPath = Path.GetTempFileName() + ".exe"; - - try - { - Directory.CreateDirectory(Path.GetDirectoryName(installerPath)!); - - using var str = File.Create(installerPath); - await resp.Content.CopyToAsync(str); - } - catch - { - Core.Logger.Error($"Failed to copy the installer to path: '{installerPath}'"); - return; - } - - try - { - await Process.Start(installerPath, "/install /passive /norestart").WaitForExitAsync(); - } - catch - { - Core.Logger.Error($"Failed to start the .NET installer"); - } - - File.Delete(installerPath); - } -} diff --git a/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/Il2CppHandler.cs b/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/Il2CppHandler.cs deleted file mode 100644 index 9d6a97a0d..000000000 --- a/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/Il2CppHandler.cs +++ /dev/null @@ -1,147 +0,0 @@ -using MelonLoader.Bootstrap.Utils; -using System.Runtime.InteropServices; - -namespace MelonLoader.Bootstrap.RuntimeHandlers.Il2Cpp; - -internal static class Il2CppHandler -{ - private static Dobby.Patch? initPatch; - private static Dobby.Patch? invokePatch; - - private static Action? startFunc; // Prevent GC - - private static Il2CppLib il2cpp = null!; - - public static bool TryInitialize() - { - var il2cppLib = Il2CppLib.TryLoad(); - if (il2cppLib == null) - return false; - - il2cpp = il2cppLib; - - MelonDebug.Log("Patching il2cpp init"); - initPatch = Dobby.CreatePatch(il2cpp.InitPtr, InitDetour); - - return true; - } - - private static nint InitDetour(nint a) - { - if (initPatch == null) - return 0; - - initPatch.Destroy(); - - ConsoleHandler.ResetHandles(); - MelonDebug.Log("In init detour"); - - var domain = initPatch.Original(a); - - InitializeManaged(); - - return domain; - } - - private static unsafe void InitializeManaged() - { - var managedDir = Path.Combine(LoaderConfig.Current.Loader.BaseDirectory, "MelonLoader", "net6"); - var runtimeConfigPath = Path.Combine(managedDir, "MelonLoader.runtimeconfig.json"); - var nativeHostPath = Path.Combine(managedDir, "MelonLoader.NativeHost.dll"); - - if (!File.Exists(runtimeConfigPath)) - { - Core.Logger.Error($"Runtime config not found at: '{runtimeConfigPath}'"); - return; - } - - if (!File.Exists(nativeHostPath)) - { - Core.Logger.Error($"NativeHost not found at: '{runtimeConfigPath}'"); - return; - } - - MelonDebug.Log("Attempting to load hostfxr"); - if (!Dotnet.LoadHostfxr()) - { - DotnetInstaller.AttemptInstall(); - if (!Dotnet.LoadHostfxr()) - { - Core.Logger.Error("Failed to load Hostfxr"); - return; - } - } - - MelonDebug.Log("Initializing domain"); - if (!Dotnet.InitializeForRuntimeConfig(runtimeConfigPath, out var context)) - { - DotnetInstaller.AttemptInstall(); - if (!Dotnet.InitializeForRuntimeConfig(runtimeConfigPath, out context)) - { - Core.Logger.Error($"Failed to initialize a .NET domain"); - return; - } - } - - MelonDebug.Log("Loading NativeHost assembly"); - var initialize = Dotnet.LoadAssemblyAndGetFunctionUco(context, nativeHostPath, "MelonLoader.NativeHost.NativeEntryPoint, MelonLoader.NativeHost", "NativeEntry"); - if (initialize == null) - { - Core.Logger.Error($"Failed to load assembly from: '{nativeHostPath}'"); - return; - } - - var startFuncPtr = Core.LibraryHandle; - - MelonDebug.Log("Invoking NativeHost entry"); - initialize(ref startFuncPtr); - - if (startFuncPtr == 0 || startFuncPtr == Core.LibraryHandle) - { - Core.Logger.Error($"Managed did not return the initial function pointer"); - return; - } - - startFunc = Marshal.GetDelegateForFunctionPointer(startFuncPtr); - - MelonDebug.Log("Patching invoke"); - invokePatch = Dobby.CreatePatch(il2cpp.RuntimeInvokePtr, InvokeDetour); - } - - private static nint InvokeDetour(nint method, nint obj, nint args, nint exc) - { - if (invokePatch == null) - return 0; - - var result = invokePatch.Original(method, obj, args, exc); - - var name = il2cpp.GetMethodName(method); - if (name == null || !name.Contains("Internal_ActiveSceneChanged")) - return result; - - MelonDebug.Log("Invoke hijacked"); - invokePatch.Destroy(); - - Start(); - - return result; - } - - private static void Start() - { - startFunc?.Invoke(); - } - - private static unsafe void NativeHookAttachImpl(nint* target, nint detour) - { - *target = Dobby.HookAttach(*target, detour); - } - - private static unsafe void NativeHookDetachImpl(nint* target, nint detour) - { - Dobby.HookDetach(*target); - } - - // Requires the bootstrap handle to be passed first - private delegate void InitializeFn(ref nint startFunc); -} diff --git a/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/Il2CppLib.cs b/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/Il2CppLib.cs deleted file mode 100644 index 735a803de..000000000 --- a/MelonLoader.Bootstrap/RuntimeHandlers/Il2Cpp/Il2CppLib.cs +++ /dev/null @@ -1,47 +0,0 @@ -using MelonLoader.Bootstrap.Utils; -using System.Runtime.InteropServices; - -namespace MelonLoader.Bootstrap.RuntimeHandlers.Il2Cpp; - -internal class Il2CppLib(Il2CppLib.MethodGetNameFn methodGetName) -{ - private const string libName = // Gotta specify the file extension in lower-case, otherwise Il2CppInterop brainfarts itself -#if WINDOWS - "GameAssembly.dll"; -#elif LINUX - "GameAssembly.so"; -#endif - - public required nint Handle { get; init; } - - public required nint InitPtr { get; init; } - public required nint RuntimeInvokePtr { get; init; } - - public static Il2CppLib? TryLoad() - { - if (!NativeLibrary.TryLoad(libName, out var hRuntime) - || !NativeLibrary.TryGetExport(hRuntime, "il2cpp_init", out var initPtr) - || !NativeLibrary.TryGetExport(hRuntime, "il2cpp_runtime_invoke", out var runtimeInvokePtr) - || !NativeFunc.GetExport(hRuntime, "il2cpp_method_get_name", out var methodGetName)) - return null; - - return new(methodGetName) - { - Handle = hRuntime, - InitPtr = initPtr, - RuntimeInvokePtr = runtimeInvokePtr - }; - } - - public string? GetMethodName(nint method) - { - return method == 0 ? null : Marshal.PtrToStringAnsi(methodGetName(method)); - } - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint InitFn(nint a); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint RuntimeInvokeFn(nint method, nint obj, nint args, nint exc); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint MethodGetNameFn(nint method); -} diff --git a/MelonLoader.Bootstrap/RuntimeHandlers/Mono/MonoHandler.cs b/MelonLoader.Bootstrap/RuntimeHandlers/Mono/MonoHandler.cs deleted file mode 100644 index 3bfd9d9d9..000000000 --- a/MelonLoader.Bootstrap/RuntimeHandlers/Mono/MonoHandler.cs +++ /dev/null @@ -1,216 +0,0 @@ -using MelonLoader.Bootstrap.Utils; -using System.Diagnostics; - -namespace MelonLoader.Bootstrap.RuntimeHandlers.Mono; - -internal static class MonoHandler -{ - private static Dobby.Patch? initPatch; - private static Dobby.Patch? invokePatch; - - private static nint assemblyManagerResolve; - private static nint assemblyManagerLoadInfo; - private static nint coreStart; - - internal static nint Domain { get; private set; } - internal static MonoLib Mono { get; private set; } = null!; - - public static bool TryInitialize() - { - var monoLib = MonoLib.TryLoad(Core.GameDir); - if (monoLib == null) - monoLib = MonoLib.TryLoad(Core.DataDir); - if (monoLib == null) - return false; - - Mono = monoLib; - - MelonDebug.Log("Patching mono init"); - initPatch = Dobby.CreatePatch(Mono.JitInitVersionPtr, InitDetour); - - return true; - } - - private static nint InitDetour(nint name, nint b) - { - if (initPatch == null) - return 0; - - initPatch.Destroy(); - - ConsoleHandler.ResetHandles(); - MelonDebug.Log("In init detour"); - - Domain = initPatch.Original(name, b); - - if (LoaderConfig.Current.Loader.DebugMode && Mono.DebugDomainCreate != null) - { - MelonDebug.Log("Creating Mono Debug Domain"); - Mono.DebugDomainCreate(Domain); - } - - MelonDebug.Log("Setting Mono Main Thread"); - Mono.SetCurrentThreadAsMain(); - - if (Mono is { IsOld: false, DomainSetConfig: not null }) - { - MelonDebug.Log("Setting Mono Config"); - - Mono.DomainSetConfig(Domain, Core.GameDir, name); - } - - InitializeManaged(); - - return Domain; - } - - private static unsafe void InitializeManaged() - { - MelonDebug.Log("Initializing managed assemblies"); - - var mlPath = Path.Combine(LoaderConfig.Current.Loader.BaseDirectory, "MelonLoader", "net35", "MelonLoader.dll"); - if (!File.Exists(mlPath)) - { - Core.Logger.Error($"Mono MelonLoader assembly not found at: '{mlPath}'"); - return; - } - - var corlibPath = Path.Combine(Core.DataDir, "Managed", "mscorlib.dll"); - if (File.Exists(corlibPath)) - { - var corlibVersion = FileVersionInfo.GetVersionInfo(corlibPath); - if (corlibVersion.FileMajorPart <= 2) - { - Core.Logger.Msg("Loading .NET Standard 2.0 overrides"); - - var overridesDir = Path.Combine(LoaderConfig.Current.Loader.BaseDirectory, "MelonLoader", "Dependencies", "NetStandardPatches"); - if (Directory.Exists(overridesDir)) - { - foreach (var dll in Directory.EnumerateFiles(overridesDir, "*.dll")) - { - MelonDebug.Log("Loading assembly: " + dll); - if (Mono.DomainAssemblyOpen(Domain, dll) == 0) - MelonDebug.Log("Assembly failed to load!"); - } - } - } - } - - MelonDebug.Log("Loading ML assembly"); - var assembly = Mono.DomainAssemblyOpen(Domain, mlPath); - if (assembly == 0) - { - Core.Logger.Error($"Failed to load the Mono MelonLoader assembly"); - return; - } - - MelonDebug.Log("Adding internal calls"); - Mono.AddManagedInternalCall("MelonLoader.Utils.MonoLibrary::CastManagedAssemblyPtr", CastManagedAssemblyPtrImpl); - - var image = Mono.AssemblyGetImage(assembly); - var interopClass = Mono.ClassFromName(image, "MelonLoader.InternalUtils", "BootstrapInterop"); - - var initMethod = Mono.ClassGetMethodFromName(interopClass, "Initialize", 1); - coreStart = Mono.ClassGetMethodFromName(interopClass, "Start", 0); - - var assemblyManagerClass = Mono.ClassFromName(image, "MelonLoader.Resolver", "AssemblyManager"); - - assemblyManagerResolve = Mono.ClassGetMethodFromName(assemblyManagerClass, "Resolve", 6); - assemblyManagerLoadInfo = Mono.ClassGetMethodFromName(assemblyManagerClass, "LoadInfo", 1); - - nint ex = 0; - MelonDebug.Log("Invoking managed core init"); - - var bootstrapHandle = Core.LibraryHandle; - var initArgs = stackalloc nint*[] - { - &bootstrapHandle - }; - Mono.RuntimeInvoke(initMethod, 0, (void**)initArgs, ref ex); - if (ex != 0) - return; - - MelonDebug.Log("Patching invoke"); - invokePatch = Dobby.CreatePatch(Mono.RuntimeInvokePtr, InvokeDetour); - } - - private static unsafe nint InvokeDetour(nint method, nint obj, void** args, ref nint ex) - { - if (invokePatch == null) - return 0; - - var result = invokePatch.Original(method, obj, args, ref ex); - - var name = Mono.GetMethodName(method); - if (name == null || - ((!Mono.IsOld || (!name.Contains("Awake") && !name.Contains("DoSendMouseEvents"))) - && !name.Contains("Internal_ActiveSceneChanged") - && !name.Contains("UnityEngine.ISerializationCallbackReceiver.OnAfterSerialize"))) - return result; - - MelonDebug.Log("Invoke hijacked"); - invokePatch.Destroy(); - - Start(); - - return result; - } - - private static unsafe void Start() - { - nint ex = 0; - Mono.RuntimeInvoke(coreStart, 0, null, ref ex); - } - - private static nint CastManagedAssemblyPtrImpl(nint ptr) - { - return ptr; - } - - internal static void InstallHooks() - { - MelonDebug.Log("Installing hooks"); - - Mono.InstallAssemblyHooks(OnAssemblyPreload, OnAssemblySearch, OnAssemblyLoad); - } - - private static unsafe void OnAssemblyLoad(nint monoAssembly, nint userData) - { - if (monoAssembly == 0) - return; - - var obj = Mono.AssemblyGetObject(Domain, monoAssembly); - - nint ex = 0; - Mono.RuntimeInvoke(assemblyManagerLoadInfo, 0, (void**)&obj, ref ex); - } - - private static nint OnAssemblySearch(ref MonoLib.AssemblyName name, nint userData) - { - return ResolveAssembly(name, false); - } - - private static nint OnAssemblyPreload(ref MonoLib.AssemblyName name, nint assemblyPaths, nint userData) - { - return ResolveAssembly(name, true); - } - - private static unsafe nint ResolveAssembly(MonoLib.AssemblyName name, bool preload) - { - var args = stackalloc void*[] - { - Mono.StringNew(Domain, name.Name), - &name.Major, - &name.Minor, - &name.Build, - &name.Revision, - &preload - }; - - nint ex = 0; - var reflectionAsm = (MonoLib.ReflectionAssembly*)Mono.RuntimeInvoke(assemblyManagerResolve, 0, args, ref ex); - return reflectionAsm == null ? 0 : reflectionAsm->Assembly; - } - - private delegate nint CastManagedAssemblyPtrFn(nint ptr); -} diff --git a/MelonLoader.Bootstrap/RuntimeHandlers/Mono/MonoLib.cs b/MelonLoader.Bootstrap/RuntimeHandlers/Mono/MonoLib.cs deleted file mode 100644 index 0692bbb09..000000000 --- a/MelonLoader.Bootstrap/RuntimeHandlers/Mono/MonoLib.cs +++ /dev/null @@ -1,281 +0,0 @@ -using MelonLoader.Bootstrap.Utils; -using System.Runtime.InteropServices; - -namespace MelonLoader.Bootstrap.RuntimeHandlers.Mono; - -internal class MonoLib -{ - private static readonly string[] folderNames = - [ - "MonoBleedingEdge", - "Mono", - "MonoBleedingEdge.x64", - "MonoBleedingEdge.x86" - ]; - - private static readonly string[] libNames = - [ -#if WINDOWS - "mono.dll", - "mono-2.0-bdwgc.dll", - "mono-2.0-sgen.dll", - "mono-2.0-boehm.dll" -#elif LINUX - "libmono.so", - "libmonobdwgc-2.0.so" -#endif - ]; - - private static readonly List passedDelegates = []; - - public required nint Handle { get; init; } - public required bool IsOld { get; init; } - - public required nint JitInitVersionPtr { get; init; } - public required nint RuntimeInvokePtr { get; init; } - - public required ThreadCurrentFn ThreadCurrent { get; init; } - public required ThreadSetMainFn ThreadSetMain { get; init; } - public required RuntimeInvokeFn RuntimeInvoke { get; init; } - public required StringNewFn StringNew { get; init; } - public required AssemblyGetObjectFn AssemblyGetObject { get; init; } - public required MethodGetNameFn MethodGetName { get; init; } - public required AddInternalCallFn AddInternalCall { get; init; } - public required DomainAssemblyOpenFn DomainAssemblyOpen { get; init; } - public required AssemblyGetImageFn AssemblyGetImage { get; init; } - public required ClassFromNameFn ClassFromName { get; init; } - public required ClassGetMethodFromNameFn ClassGetMethodFromName { get; init; } - public required InstallAssemblyPreloadHookFn InstallAssemblyPreloadHook { get; init; } - public required InstallAssemblySearchHookFn InstallAssemblySearchHook { get; init; } - public required InstallAssemblyLoadHookFn InstallAssemblyLoadHook { get; init; } - - public DebugDomainCreateFn? DebugDomainCreate { get; init; } - public DomainSetConfigFn? DomainSetConfig { get; init; } - - public static MonoLib? TryLoad(string searchDir) - { - var monoPath = FindMonoPath(searchDir); - if (monoPath == null) - return null; - - if (!NativeLibrary.TryLoad(monoPath, out var hRuntime)) - return null; - - var monoName = Path.GetFileNameWithoutExtension(monoPath); -#if LINUX - if (monoName.StartsWith("lib")) - monoName = monoName[3..]; -#endif - - var isOld = monoName.Equals("mono", StringComparison.OrdinalIgnoreCase); - - MelonDebug.Log("Loading Mono exports"); - - if (!NativeLibrary.TryGetExport(hRuntime, "mono_jit_init_version", out var jitInitVersionPtr) - || !NativeLibrary.TryGetExport(hRuntime, "mono_runtime_invoke", out var runtimeInvokePtr) - || !NativeFunc.GetExport(hRuntime, "mono_thread_current", out var threadCurrent) - || !NativeFunc.GetExport(hRuntime, "mono_thread_set_main", out var threadSetMain) - || !NativeFunc.GetExport(hRuntime, "mono_string_new", out var stringNew) - || !NativeFunc.GetExport(hRuntime, "mono_assembly_get_object", out var assemblyGetObject) - || !NativeFunc.GetExport(hRuntime, "mono_method_get_name", out var methodGetName) - || !NativeFunc.GetExport(hRuntime, "mono_add_internal_call", out var addInternalCall) - || !NativeFunc.GetExport(hRuntime, "mono_domain_assembly_open", out var domainAssemblyOpen) - || !NativeFunc.GetExport(hRuntime, "mono_assembly_get_image", out var assemblyGetImage) - || !NativeFunc.GetExport(hRuntime, "mono_class_from_name", out var classFromName) - || !NativeFunc.GetExport(hRuntime, "mono_class_get_method_from_name", out var classGetMethodFromName) - || !NativeFunc.GetExport(hRuntime, "mono_install_assembly_preload_hook", out var installAssemblyPreloadHook) - || !NativeFunc.GetExport(hRuntime, "mono_install_assembly_search_hook", out var installAssemblySearchHook) - || !NativeFunc.GetExport(hRuntime, "mono_install_assembly_load_hook", out var installAssemblyLoadHook)) - return null; - - var runtimeInvoke = Marshal.GetDelegateForFunctionPointer(runtimeInvokePtr); - - var debugDomainCreate = NativeFunc.GetExport(hRuntime, "mono_debug_domain_create"); - var domainSetConfig = NativeFunc.GetExport(hRuntime, "mono_domain_set_config"); - - return new() - { - Handle = hRuntime, - IsOld = isOld, - RuntimeInvoke = runtimeInvoke, - JitInitVersionPtr = jitInitVersionPtr, - RuntimeInvokePtr = runtimeInvokePtr, - ThreadCurrent = threadCurrent, - ThreadSetMain = threadSetMain, - StringNew = stringNew, - AssemblyGetObject = assemblyGetObject, - MethodGetName = methodGetName, - AddInternalCall = addInternalCall, - DomainAssemblyOpen = domainAssemblyOpen, - AssemblyGetImage = assemblyGetImage, - ClassFromName = classFromName, - ClassGetMethodFromName = classGetMethodFromName, - InstallAssemblyPreloadHook = installAssemblyPreloadHook, - InstallAssemblySearchHook = installAssemblySearchHook, - InstallAssemblyLoadHook = installAssemblyLoadHook, - DomainSetConfig = domainSetConfig, - DebugDomainCreate = debugDomainCreate - }; - } - - private static string? FindMonoPath(string searchDir) - { - foreach (var folder in folderNames) - { - foreach (var lib in libNames) - { - var path = Path.Combine(searchDir, folder, lib); - if (File.Exists(path)) - return path; - - path = Path.Combine(searchDir, folder, "EmbedRuntime", lib); - if (File.Exists(path)) - return path; - - path = Path.Combine(searchDir, folder, lib); - if (File.Exists(path)) - return path; - - path = Path.Combine(searchDir, folder, "EmbedRuntime", lib); - if (File.Exists(path)) - return path; - - path = Path.Combine(searchDir, folder, "x86_64", lib); - if (File.Exists(path)) - return path; - } - } - - MelonDebug.Log("Probe for Mono failed"); - return null; - } - - public void SetCurrentThreadAsMain() - { - ThreadSetMain(ThreadCurrent()); - } - - public void AddManagedInternalCall(string name, TDelegate func) where TDelegate : Delegate - { - passedDelegates.Add(func); - AddInternalCall(name, Marshal.GetFunctionPointerForDelegate(func)); - } - - public string? GetMethodName(nint method) - { - if (method == 0) - return null; - - return Marshal.PtrToStringAnsi(MethodGetName(method)); - } - - public void InstallAssemblyHooks(AssemblyPreloadHookFn? preloadHook, AssemblySearchHookFn? searchHook, AssemblyLoadHookFn? loadHook) - { - if (preloadHook != null) - { - passedDelegates.Add(preloadHook); - InstallAssemblyPreloadHook(preloadHook, 0); - } - - if (searchHook != null) - { - passedDelegates.Add(searchHook); - InstallAssemblySearchHook(searchHook, 0); - } - - if (loadHook != null) - { - passedDelegates.Add(loadHook); - InstallAssemblyLoadHook(loadHook, 0); - } - } - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint DomainGetFn(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint JitInitVersionFn(nint name, nint b); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void DebugDomainCreateFn(nint domain); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint ThreadCurrentFn(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void ThreadSetMainFn(nint thread); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint AssemblyGetImageFn(nint assembly); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public unsafe delegate nint RuntimeInvokeFn(nint method, nint obj, void** args, ref nint ex); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint AssemblyGetObjectFn(nint domain, nint assembly); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint InstallAssemblyPreloadHookFn(AssemblyPreloadHookFn func, nint userData); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint InstallAssemblySearchHookFn(AssemblySearchHookFn func, nint userData); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint InstallAssemblyLoadHookFn(AssemblyLoadHookFn func, nint userData); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint MethodGetNameFn(nint method); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public unsafe delegate void* StringNewFn(nint domain, nint value); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint ObjectToStringFn(nint obj, nint ex); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Unicode)] - public delegate string StringToUtf16Fn(nint str); - [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - public delegate void AddInternalCallFn(string name, nint func); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - public delegate nint ClassFromNameFn(nint image, string nameSpace, string name); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - public delegate nint ClassGetMethodFromNameFn(nint clas, string name, int paramCount); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - public delegate nint DomainAssemblyOpenFn(nint domain, string path); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] - public delegate void DomainSetConfigFn(nint domain, string configPath, nint name); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint AssemblyPreloadHookFn(ref AssemblyName name, nint assemblyPaths, nint userData); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate nint AssemblySearchHookFn(ref AssemblyName name, nint userData); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void AssemblyLoadHookFn(nint monoAssembly, nint userData); - - [StructLayout(LayoutKind.Sequential)] - public unsafe struct AssemblyName - { - public nint Name; - - // Non-marshalled strings - public nint Culture; - public nint HashValue; - public nint PublicKey; - - public fixed byte PublicKeyToken[17]; - - public uint HashAlg; - public uint HashLength; - - public uint Flags; - public ushort Major; - public ushort Minor; - public ushort Build; - public ushort Revision; - public uint Arch; - } - - [StructLayout(LayoutKind.Sequential)] - public struct ReflectionAssembly - { - // MonoObject - public nint VTable; - public nint Sync; - - public nint Assembly; - - public nint Evidence; - } -} diff --git a/MelonLoader.Bootstrap/SharedDelegates.cs b/MelonLoader.Bootstrap/SharedDelegates.cs index c7fddb260..a8f39a184 100644 --- a/MelonLoader.Bootstrap/SharedDelegates.cs +++ b/MelonLoader.Bootstrap/SharedDelegates.cs @@ -3,6 +3,12 @@ namespace MelonLoader.Bootstrap; +[UnmanagedFunctionPointer(CallingConvention.StdCall)] +internal unsafe delegate nint NativeLoadLibFn(nint libraryPath); + +[UnmanagedFunctionPointer(CallingConvention.StdCall)] +internal unsafe delegate nint NativeGetExportFn(nint lib, nint name); + [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal unsafe delegate void NativeHookFn(nint* target, nint detour); diff --git a/MelonLoader.Bootstrap/Utils/NativeFunc.cs b/MelonLoader.Bootstrap/Utils/NativeFunc.cs index bce94361d..46cbd61aa 100644 --- a/MelonLoader.Bootstrap/Utils/NativeFunc.cs +++ b/MelonLoader.Bootstrap/Utils/NativeFunc.cs @@ -5,6 +5,36 @@ namespace MelonLoader.Bootstrap.Utils; internal static class NativeFunc { + internal static unsafe nint NativeLoadLib(nint libraryPath) + { + if (libraryPath == 0) + return 0; + + string? libraryPathStr = Marshal.PtrToStringAnsi(libraryPath); + if (string.IsNullOrEmpty(libraryPathStr)) + return 0; + + if (!NativeLibrary.TryLoad(libraryPathStr, out nint addr)) + return 0; + + return addr; + } + + internal static unsafe nint NativeGetExport(nint lib, nint name) + { + if (lib == 0) + return 0; + + string? nameStr = Marshal.PtrToStringAnsi(name); + if (string.IsNullOrEmpty(nameStr)) + return 0; + + if (!NativeLibrary.TryGetExport(lib, nameStr, out nint addr)) + return 0; + + return addr; + } + public static T? GetExport(nint hModule, string name) where T : Delegate { return !NativeLibrary.TryGetExport(hModule, name, out var export) ? null : Marshal.GetDelegateForFunctionPointer(export); diff --git a/MelonLoader.Bootstrap/linuxexports.def b/MelonLoader.Bootstrap/linuxexports.def index a836f8fac..b3f816d2e 100644 --- a/MelonLoader.Bootstrap/linuxexports.def +++ b/MelonLoader.Bootstrap/linuxexports.def @@ -7,9 +7,6 @@ V1.0 { LogMsg; LogError; LogMelonInfo; - MonoInstallHooks; - MonoGetDomainPtr; - MonoGetRuntimeHandle; IsConsoleOpen; GetLoaderConfig; local: *; diff --git a/MelonLoader.NativeHost/MelonLoader.NativeHost.csproj b/MelonLoader.NativeHost/MelonLoader.NativeHost.csproj index cf2f1e1f7..e15ff4ba9 100644 --- a/MelonLoader.NativeHost/MelonLoader.NativeHost.csproj +++ b/MelonLoader.NativeHost/MelonLoader.NativeHost.csproj @@ -4,14 +4,14 @@ net6 enable enable - $(MLOutDir)/MelonLoader + $(MLOutDir)/MelonLoader/Dependencies true True embedded - + \ No newline at end of file diff --git a/MelonLoader.NativeHost/NativeEntryPoint.cs b/MelonLoader.NativeHost/NativeEntryPoint.cs index 4e3b72c57..742c98753 100644 --- a/MelonLoader.NativeHost/NativeEntryPoint.cs +++ b/MelonLoader.NativeHost/NativeEntryPoint.cs @@ -3,51 +3,45 @@ using System.Runtime.InteropServices; using System.Runtime.Loader; using MelonLoader.InternalUtils; +using MelonLoader.Modules; namespace MelonLoader.NativeHost; internal static unsafe class NativeEntryPoint { - // Prevent GC - private static Action? startDel; - // The argument should first hold the bootstrap handle, and return the start function ptr [UnmanagedCallersOnly] - private static void NativeEntry(nint* startFunc) + private static void NativeEntry(nint* bootstrapHandlePtr, nint* loadLibFuncPtr, nint* getExportFuncPtr) { var currentAsm = typeof(NativeEntryPoint).Assembly; var asm = AssemblyLoadContext.Default.LoadFromAssemblyPath(currentAsm.Location); var type = asm.GetType("MelonLoader.NativeHost.NativeEntryPoint", true)!; var init = type.GetMethod(nameof(Initialize), BindingFlags.Static | BindingFlags.NonPublic)!; - init.Invoke(null, [ (nint)startFunc]); + init.Invoke(null, [(nint)bootstrapHandlePtr, (nint)loadLibFuncPtr, (nint)getExportFuncPtr]); } - private unsafe static void Initialize(nint* startFunc) + private unsafe static void Initialize(nint* bootstrapHandlePtr, nint* loadLibFuncPtr, nint* getExportFuncPtr) { AssemblyLoadContext.Default.Resolving += OnResolveAssembly; - - //Have to invoke through a proxy so that we don't load MelonLoader.dll before the above line - CallInit(startFunc); + CallInit(bootstrapHandlePtr, loadLibFuncPtr, getExportFuncPtr); } [MethodImpl(MethodImplOptions.NoInlining)] - private static void CallInit(nint* startFunc) + private static void CallInit(nint* bootstrapHandlePtr, nint* loadLibFuncPtr, nint* getExportFuncPtr) { - var bootstrapHandle = *startFunc; - - startDel = BootstrapInterop.Start; - *startFunc = Marshal.GetFunctionPointerForDelegate(startDel); + var bootstrapHandle = *bootstrapHandlePtr; + var loadLibFunc = *loadLibFuncPtr; + var getExportFunc = *getExportFuncPtr; - BootstrapInterop.Initialize(bootstrapHandle); + BootstrapInterop.Stage1(bootstrapHandle, loadLibFunc, getExportFunc, true); + ModuleInterop.StartEngine(); } private static Assembly? OnResolveAssembly(AssemblyLoadContext alc, AssemblyName name) { var ourDir = Path.GetDirectoryName(typeof(NativeEntryPoint).Assembly.Location)!; - var potentialDllPath = Path.Combine(ourDir, name.Name + ".dll"); - return File.Exists(potentialDllPath) ? alc.LoadFromAssemblyPath(potentialDllPath) : null; } } \ No newline at end of file diff --git a/MelonLoader.sln b/MelonLoader.sln index c436069b2..eafeec0f4 100644 --- a/MelonLoader.sln +++ b/MelonLoader.sln @@ -5,65 +5,50 @@ VisualStudioVersion = 17.4.33122.133 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MelonLoader", "MelonLoader\MelonLoader.csproj", "{F9700790-414B-431B-9F9C-1D9210FAD682}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SupportModules", "SupportModules", "{8D8A18CB-7319-4220-BED8-6B3E23E6C19F}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B2CA62DF-AD3A-47DD-8E85-B26A93C7BAE9}" + ProjectSection(SolutionItems) = preProject + .github\workflows\build.yml = .github\workflows\build.yml + .github\workflows\nuget.yml = .github\workflows\nuget.yml + README.md = README.md + EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{BE32DEBD-2C83-42F6-A1A2-941856586E57}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MelonLoader.NativeHost", "MelonLoader.NativeHost\MelonLoader.NativeHost.csproj", "{60D688E3-ECE0-43A6-9922-9D1D3B8C07CC}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CompatibilityLayers", "CompatibilityLayers", "{AB4D471C-9AB2-4A5F-93E1-8929E436C121}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MelonLoader.Bootstrap", "MelonLoader.Bootstrap\MelonLoader.Bootstrap.csproj", "{10CC7C0B-E7BC-43CC-BCE1-B0181337CCF5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Il2CppAssemblyGenerator", "Dependencies\Il2CppAssemblyGenerator\Il2CppAssemblyGenerator.csproj", "{A6452A3F-4BD6-497A-97DA-24F7DF97B234}" - ProjectSection(ProjectDependencies) = postProject - {F9700790-414B-431B-9F9C-1D9210FAD682} = {F9700790-414B-431B-9F9C-1D9210FAD682} - EndProjectSection +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engines", "Engines", "{EFD62F17-3C48-4D77-8F19-1D4BCD62CEFB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MelonStartScreen", "Dependencies\MelonStartScreen\MelonStartScreen.csproj", "{762D7545-6F6B-441A-B040-49CC31A1713B}" - ProjectSection(ProjectDependencies) = postProject - {F9700790-414B-431B-9F9C-1D9210FAD682} = {F9700790-414B-431B-9F9C-1D9210FAD682} - EndProjectSection +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Runtimes", "Runtimes", "{339D0985-0570-4C26-B09F-40E6460646EB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono", "Dependencies\SupportModules\Mono\Mono.csproj", "{542EC51D-E480-4802-B5AA-96EEC05AF19C}" - ProjectSection(ProjectDependencies) = postProject - {F9700790-414B-431B-9F9C-1D9210FAD682} = {F9700790-414B-431B-9F9C-1D9210FAD682} - EndProjectSection +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Il2Cpp", "Il2Cpp", "{D3939E0F-9232-4D4F-A0B9-48EEEED776C2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Il2Cpp", "Dependencies\SupportModules\Il2Cpp\Il2Cpp.csproj", "{4BEAF9B5-F780-414B-8F2E-59DA4A91BE50}" - ProjectSection(ProjectDependencies) = postProject - {F9700790-414B-431B-9F9C-1D9210FAD682} = {F9700790-414B-431B-9F9C-1D9210FAD682} - EndProjectSection +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.Il2Cpp.Shared", "Dependencies\Modules\Runtimes\Il2Cpp\Runtime.Il2Cpp.Shared\Runtime.Il2Cpp.Shared.csproj", "{DA2631E2-2639-4C8D-AD11-5569F980930E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IPA", "Dependencies\CompatibilityLayers\IPA\IPA.csproj", "{4FDDBEC0-9C20-456E-8906-77E9CD39C3CA}" - ProjectSection(ProjectDependencies) = postProject - {F9700790-414B-431B-9F9C-1D9210FAD682} = {F9700790-414B-431B-9F9C-1D9210FAD682} - EndProjectSection +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.Il2Cpp", "Dependencies\Modules\Runtimes\Il2Cpp\Runtime.Il2Cpp\Runtime.Il2Cpp.csproj", "{C06957F2-5402-4C96-829A-0B7847B57E95}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Muse_Dash_Mono", "Dependencies\CompatibilityLayers\Muse_Dash_Mono\Muse_Dash_Mono.csproj", "{15CFF766-420B-47EF-9E4A-E73D35A4AB44}" - ProjectSection(ProjectDependencies) = postProject - {F9700790-414B-431B-9F9C-1D9210FAD682} = {F9700790-414B-431B-9F9C-1D9210FAD682} - EndProjectSection +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Unity", "Unity", "{5939AA02-721D-4011-9B89-358446C3C818}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demeo", "Dependencies\CompatibilityLayers\Demeo\Demeo.csproj", "{3AF58371-2E0A-4256-B3A3-C100DB07E599}" - ProjectSection(ProjectDependencies) = postProject - {F9700790-414B-431B-9F9C-1D9210FAD682} = {F9700790-414B-431B-9F9C-1D9210FAD682} - EndProjectSection +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Il2Cpp", "Il2Cpp", "{1A31A1FE-5F97-4D02-B622-8D62F971EB67}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B2CA62DF-AD3A-47DD-8E85-B26A93C7BAE9}" - ProjectSection(SolutionItems) = preProject - .github\workflows\build.yml = .github\workflows\build.yml - .github\workflows\nuget.yml = .github\workflows\nuget.yml - README.md = README.md - EndProjectSection +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Unity.Shared", "Dependencies\Modules\Engines\Unity\Engine.Unity.Shared\Engine.Unity.Shared.csproj", "{47E5D0BD-04E2-4E2C-8D02-CAD79B637D93}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stress_Level_Zero_Il2Cpp", "Dependencies\CompatibilityLayers\Stress_Level_Zero_Il2Cpp\Stress_Level_Zero_Il2Cpp.csproj", "{1DB3679C-DCCA-492D-A725-75604A379C7A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Unity", "Dependencies\Modules\Engines\Unity\Engine.Unity\Engine.Unity.csproj", "{9FF4FFD8-2188-46E3-8A8A-D756B3B0AAD5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MelonLoader.NativeHost", "MelonLoader.NativeHost\MelonLoader.NativeHost.csproj", "{60D688E3-ECE0-43A6-9922-9D1D3B8C07CC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Il2Cpp", "Dependencies\Modules\Engines\Unity\Il2Cpp\Unity.Il2Cpp\Unity.Il2Cpp.csproj", "{927F019C-35EE-4942-9CAB-75AE3C043D4C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MelonLoader.Bootstrap", "MelonLoader.Bootstrap\MelonLoader.Bootstrap.csproj", "{10CC7C0B-E7BC-43CC-BCE1-B0181337CCF5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Il2Cpp.Shared", "Dependencies\Modules\Engines\Unity\Il2Cpp\Unity.Il2Cpp.Shared\Unity.Il2Cpp.Shared.csproj", "{EE6B689E-011A-4FEA-933F-325B0150AEDB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Il2Cpp.AssemblyGenerator", "Dependencies\Modules\Engines\Unity\Il2Cpp\Unity.Il2Cpp.AssemblyGenerator\Unity.Il2Cpp.AssemblyGenerator.csproj", "{51405AB6-110B-4279-8D73-177B7B74537C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mono", "Mono", "{5B41B0FE-3B90-4F82-B1B0-061E39C27EBB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mono", "Mono", "{3B132718-3D60-44B5-AAF8-BDA2E8BBEDBE}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnityUtilities", "UnityUtilities", "{F7AF6E70-6764-4A78-9E96-97D180403252}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.Mono", "Dependencies\Modules\Runtimes\Mono\Runtime.Mono\Runtime.Mono.csproj", "{CF071430-B106-4D7E-9AC5-D3E892479BD2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityEngine.Il2CppAssetBundleManager", "UnityUtilities\UnityEngine.Il2CppAssetBundleManager\UnityEngine.Il2CppAssetBundleManager.csproj", "{5C270941-AAA4-4FF4-870E-BDE170C5407C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runtime.Mono.Shared", "Dependencies\Modules\Runtimes\Mono\Runtime.Mono.Shared\Runtime.Mono.Shared.csproj", "{AF553B0E-A74D-4F1F-857C-18741FB255E8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityEngine.Il2CppImageConversionManager", "UnityUtilities\UnityEngine.Il2CppImageConversionManager\UnityEngine.Il2CppImageConversionManager.csproj", "{8D271ABF-209A-4AF9-8C62-EF92806B7DC1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Mono", "Dependencies\Modules\Engines\Unity\Mono\Unity.Mono\Unity.Mono.csproj", "{27AD78CF-2EC4-4E02-8CEA-D2533D821C33}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -75,36 +60,6 @@ Global {F9700790-414B-431B-9F9C-1D9210FAD682}.Debug|Any CPU.Build.0 = Debug|Any CPU {F9700790-414B-431B-9F9C-1D9210FAD682}.Release|Any CPU.ActiveCfg = Release|Any CPU {F9700790-414B-431B-9F9C-1D9210FAD682}.Release|Any CPU.Build.0 = Release|Any CPU - {A6452A3F-4BD6-497A-97DA-24F7DF97B234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A6452A3F-4BD6-497A-97DA-24F7DF97B234}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A6452A3F-4BD6-497A-97DA-24F7DF97B234}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A6452A3F-4BD6-497A-97DA-24F7DF97B234}.Release|Any CPU.Build.0 = Release|Any CPU - {762D7545-6F6B-441A-B040-49CC31A1713B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {762D7545-6F6B-441A-B040-49CC31A1713B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {542EC51D-E480-4802-B5AA-96EEC05AF19C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {542EC51D-E480-4802-B5AA-96EEC05AF19C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {542EC51D-E480-4802-B5AA-96EEC05AF19C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {542EC51D-E480-4802-B5AA-96EEC05AF19C}.Release|Any CPU.Build.0 = Release|Any CPU - {4BEAF9B5-F780-414B-8F2E-59DA4A91BE50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4BEAF9B5-F780-414B-8F2E-59DA4A91BE50}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4BEAF9B5-F780-414B-8F2E-59DA4A91BE50}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4BEAF9B5-F780-414B-8F2E-59DA4A91BE50}.Release|Any CPU.Build.0 = Release|Any CPU - {4FDDBEC0-9C20-456E-8906-77E9CD39C3CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4FDDBEC0-9C20-456E-8906-77E9CD39C3CA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4FDDBEC0-9C20-456E-8906-77E9CD39C3CA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4FDDBEC0-9C20-456E-8906-77E9CD39C3CA}.Release|Any CPU.Build.0 = Release|Any CPU - {15CFF766-420B-47EF-9E4A-E73D35A4AB44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {15CFF766-420B-47EF-9E4A-E73D35A4AB44}.Debug|Any CPU.Build.0 = Debug|Any CPU - {15CFF766-420B-47EF-9E4A-E73D35A4AB44}.Release|Any CPU.ActiveCfg = Release|Any CPU - {15CFF766-420B-47EF-9E4A-E73D35A4AB44}.Release|Any CPU.Build.0 = Release|Any CPU - {3AF58371-2E0A-4256-B3A3-C100DB07E599}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3AF58371-2E0A-4256-B3A3-C100DB07E599}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3AF58371-2E0A-4256-B3A3-C100DB07E599}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3AF58371-2E0A-4256-B3A3-C100DB07E599}.Release|Any CPU.Build.0 = Release|Any CPU - {1DB3679C-DCCA-492D-A725-75604A379C7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1DB3679C-DCCA-492D-A725-75604A379C7A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1DB3679C-DCCA-492D-A725-75604A379C7A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1DB3679C-DCCA-492D-A725-75604A379C7A}.Release|Any CPU.Build.0 = Release|Any CPU {60D688E3-ECE0-43A6-9922-9D1D3B8C07CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {60D688E3-ECE0-43A6-9922-9D1D3B8C07CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {60D688E3-ECE0-43A6-9922-9D1D3B8C07CC}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -113,31 +68,66 @@ Global {10CC7C0B-E7BC-43CC-BCE1-B0181337CCF5}.Debug|Any CPU.Build.0 = Debug|Any CPU {10CC7C0B-E7BC-43CC-BCE1-B0181337CCF5}.Release|Any CPU.ActiveCfg = Release|Any CPU {10CC7C0B-E7BC-43CC-BCE1-B0181337CCF5}.Release|Any CPU.Build.0 = Release|Any CPU - {5C270941-AAA4-4FF4-870E-BDE170C5407C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5C270941-AAA4-4FF4-870E-BDE170C5407C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5C270941-AAA4-4FF4-870E-BDE170C5407C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5C270941-AAA4-4FF4-870E-BDE170C5407C}.Release|Any CPU.Build.0 = Release|Any CPU - {8D271ABF-209A-4AF9-8C62-EF92806B7DC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8D271ABF-209A-4AF9-8C62-EF92806B7DC1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8D271ABF-209A-4AF9-8C62-EF92806B7DC1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8D271ABF-209A-4AF9-8C62-EF92806B7DC1}.Release|Any CPU.Build.0 = Release|Any CPU + {DA2631E2-2639-4C8D-AD11-5569F980930E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA2631E2-2639-4C8D-AD11-5569F980930E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA2631E2-2639-4C8D-AD11-5569F980930E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA2631E2-2639-4C8D-AD11-5569F980930E}.Release|Any CPU.Build.0 = Release|Any CPU + {C06957F2-5402-4C96-829A-0B7847B57E95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C06957F2-5402-4C96-829A-0B7847B57E95}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C06957F2-5402-4C96-829A-0B7847B57E95}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C06957F2-5402-4C96-829A-0B7847B57E95}.Release|Any CPU.Build.0 = Release|Any CPU + {47E5D0BD-04E2-4E2C-8D02-CAD79B637D93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47E5D0BD-04E2-4E2C-8D02-CAD79B637D93}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47E5D0BD-04E2-4E2C-8D02-CAD79B637D93}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47E5D0BD-04E2-4E2C-8D02-CAD79B637D93}.Release|Any CPU.Build.0 = Release|Any CPU + {9FF4FFD8-2188-46E3-8A8A-D756B3B0AAD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9FF4FFD8-2188-46E3-8A8A-D756B3B0AAD5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9FF4FFD8-2188-46E3-8A8A-D756B3B0AAD5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9FF4FFD8-2188-46E3-8A8A-D756B3B0AAD5}.Release|Any CPU.Build.0 = Release|Any CPU + {927F019C-35EE-4942-9CAB-75AE3C043D4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {927F019C-35EE-4942-9CAB-75AE3C043D4C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {927F019C-35EE-4942-9CAB-75AE3C043D4C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {927F019C-35EE-4942-9CAB-75AE3C043D4C}.Release|Any CPU.Build.0 = Release|Any CPU + {EE6B689E-011A-4FEA-933F-325B0150AEDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE6B689E-011A-4FEA-933F-325B0150AEDB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE6B689E-011A-4FEA-933F-325B0150AEDB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE6B689E-011A-4FEA-933F-325B0150AEDB}.Release|Any CPU.Build.0 = Release|Any CPU + {51405AB6-110B-4279-8D73-177B7B74537C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {51405AB6-110B-4279-8D73-177B7B74537C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {51405AB6-110B-4279-8D73-177B7B74537C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {51405AB6-110B-4279-8D73-177B7B74537C}.Release|Any CPU.Build.0 = Release|Any CPU + {CF071430-B106-4D7E-9AC5-D3E892479BD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF071430-B106-4D7E-9AC5-D3E892479BD2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF071430-B106-4D7E-9AC5-D3E892479BD2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF071430-B106-4D7E-9AC5-D3E892479BD2}.Release|Any CPU.Build.0 = Release|Any CPU + {AF553B0E-A74D-4F1F-857C-18741FB255E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF553B0E-A74D-4F1F-857C-18741FB255E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF553B0E-A74D-4F1F-857C-18741FB255E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF553B0E-A74D-4F1F-857C-18741FB255E8}.Release|Any CPU.Build.0 = Release|Any CPU + {27AD78CF-2EC4-4E02-8CEA-D2533D821C33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27AD78CF-2EC4-4E02-8CEA-D2533D821C33}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27AD78CF-2EC4-4E02-8CEA-D2533D821C33}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27AD78CF-2EC4-4E02-8CEA-D2533D821C33}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {8D8A18CB-7319-4220-BED8-6B3E23E6C19F} = {BE32DEBD-2C83-42F6-A1A2-941856586E57} - {AB4D471C-9AB2-4A5F-93E1-8929E436C121} = {BE32DEBD-2C83-42F6-A1A2-941856586E57} - {A6452A3F-4BD6-497A-97DA-24F7DF97B234} = {BE32DEBD-2C83-42F6-A1A2-941856586E57} - {762D7545-6F6B-441A-B040-49CC31A1713B} = {BE32DEBD-2C83-42F6-A1A2-941856586E57} - {542EC51D-E480-4802-B5AA-96EEC05AF19C} = {8D8A18CB-7319-4220-BED8-6B3E23E6C19F} - {4BEAF9B5-F780-414B-8F2E-59DA4A91BE50} = {8D8A18CB-7319-4220-BED8-6B3E23E6C19F} - {4FDDBEC0-9C20-456E-8906-77E9CD39C3CA} = {AB4D471C-9AB2-4A5F-93E1-8929E436C121} - {15CFF766-420B-47EF-9E4A-E73D35A4AB44} = {AB4D471C-9AB2-4A5F-93E1-8929E436C121} - {3AF58371-2E0A-4256-B3A3-C100DB07E599} = {AB4D471C-9AB2-4A5F-93E1-8929E436C121} - {1DB3679C-DCCA-492D-A725-75604A379C7A} = {AB4D471C-9AB2-4A5F-93E1-8929E436C121} - {5C270941-AAA4-4FF4-870E-BDE170C5407C} = {F7AF6E70-6764-4A78-9E96-97D180403252} - {8D271ABF-209A-4AF9-8C62-EF92806B7DC1} = {F7AF6E70-6764-4A78-9E96-97D180403252} + {D3939E0F-9232-4D4F-A0B9-48EEEED776C2} = {339D0985-0570-4C26-B09F-40E6460646EB} + {DA2631E2-2639-4C8D-AD11-5569F980930E} = {D3939E0F-9232-4D4F-A0B9-48EEEED776C2} + {C06957F2-5402-4C96-829A-0B7847B57E95} = {D3939E0F-9232-4D4F-A0B9-48EEEED776C2} + {5939AA02-721D-4011-9B89-358446C3C818} = {EFD62F17-3C48-4D77-8F19-1D4BCD62CEFB} + {1A31A1FE-5F97-4D02-B622-8D62F971EB67} = {5939AA02-721D-4011-9B89-358446C3C818} + {47E5D0BD-04E2-4E2C-8D02-CAD79B637D93} = {5939AA02-721D-4011-9B89-358446C3C818} + {9FF4FFD8-2188-46E3-8A8A-D756B3B0AAD5} = {5939AA02-721D-4011-9B89-358446C3C818} + {927F019C-35EE-4942-9CAB-75AE3C043D4C} = {1A31A1FE-5F97-4D02-B622-8D62F971EB67} + {EE6B689E-011A-4FEA-933F-325B0150AEDB} = {1A31A1FE-5F97-4D02-B622-8D62F971EB67} + {51405AB6-110B-4279-8D73-177B7B74537C} = {1A31A1FE-5F97-4D02-B622-8D62F971EB67} + {5B41B0FE-3B90-4F82-B1B0-061E39C27EBB} = {339D0985-0570-4C26-B09F-40E6460646EB} + {3B132718-3D60-44B5-AAF8-BDA2E8BBEDBE} = {5939AA02-721D-4011-9B89-358446C3C818} + {CF071430-B106-4D7E-9AC5-D3E892479BD2} = {5B41B0FE-3B90-4F82-B1B0-061E39C27EBB} + {AF553B0E-A74D-4F1F-857C-18741FB255E8} = {5B41B0FE-3B90-4F82-B1B0-061E39C27EBB} + {27AD78CF-2EC4-4E02-8CEA-D2533D821C33} = {3B132718-3D60-44B5-AAF8-BDA2E8BBEDBE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4AB93B1D-1C52-4A80-809D-C28770140E0A} diff --git a/MelonLoader/Attributes/MelonApplicationAttribute.cs b/MelonLoader/Attributes/MelonApplicationAttribute.cs new file mode 100644 index 000000000..c1658d4b9 --- /dev/null +++ b/MelonLoader/Attributes/MelonApplicationAttribute.cs @@ -0,0 +1,40 @@ +using System; + +namespace MelonLoader +{ + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] + public class MelonApplicationAttribute : Attribute + { + public MelonApplicationAttribute(string developer = null, string name = null) { Developer = developer; Name = name; } + + /// + /// Developer of the Game. + /// + public string Developer { get; internal set; } + + /// + /// Name of the Game. + /// + public string Name { get; internal set; } + + /// + /// If the Attribute is set as Universal or not. + /// + public bool Universal { get => (string.IsNullOrEmpty(Developer) || Developer.Equals("UNKNOWN") || string.IsNullOrEmpty(Name) || Name.Equals("UNKNOWN")); } + + /// + /// Returns true or false if the Game is compatible with this Assembly. + /// + public bool IsCompatible(string developer, string gameName) => (Universal || (!string.IsNullOrEmpty(developer) && Developer.Equals(developer) && !string.IsNullOrEmpty(gameName) && Name.Equals(gameName))); + + /// + /// Returns true or false if the Game is compatible with this Assembly. + /// + public bool IsCompatible(MelonApplicationAttribute att) => (IsCompatibleBecauseUniversal(att) || (att.Developer.Equals(Developer) && att.Name.Equals(Name))); + + /// + /// Returns true or false if the Game is compatible with this Assembly specifically because of Universal Compatibility. + /// + public bool IsCompatibleBecauseUniversal(MelonApplicationAttribute att) => ((att == null) || Universal || att.Universal); + } +} \ No newline at end of file diff --git a/MelonLoader/Attributes/MelonApplicationVersionAttribute.cs b/MelonLoader/Attributes/MelonApplicationVersionAttribute.cs new file mode 100644 index 000000000..3dfc1647f --- /dev/null +++ b/MelonLoader/Attributes/MelonApplicationVersionAttribute.cs @@ -0,0 +1,21 @@ +using System; + +namespace MelonLoader +{ + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] + public class MelonApplicationVersionAttribute : Attribute + { + public MelonApplicationVersionAttribute(string version = null) + => Version = version; + + /// + /// Version of the Game. + /// + public string Version { get; internal set; } + + /// + /// If the Attribute is set as Universal or not. + /// + public bool Universal { get => string.IsNullOrEmpty(Version); } + } +} \ No newline at end of file diff --git a/MelonLoader/Attributes/MelonAuthorColorAttribute.cs b/MelonLoader/Attributes/MelonAuthorColorAttribute.cs index 71876e833..43ca6e27a 100644 --- a/MelonLoader/Attributes/MelonAuthorColorAttribute.cs +++ b/MelonLoader/Attributes/MelonAuthorColorAttribute.cs @@ -7,16 +7,6 @@ namespace MelonLoader [AttributeUsage(AttributeTargets.Assembly)] public class MelonAuthorColorAttribute : Attribute { - /// - /// Color of the Author Log. - /// - [Obsolete("Color is obsolete. Use DrawingColor for full Color support. This will be removed in a future update.", true)] - public ConsoleColor Color - { - get => LoggerUtils.DrawingColorToConsoleColor(DrawingColor); - set => DrawingColor = LoggerUtils.ConsoleColorToDrawingColor(value); - } - /// /// Color of the Author Log. /// @@ -25,10 +15,6 @@ public ConsoleColor Color public MelonAuthorColorAttribute() => DrawingColor = MelonLogger.DefaultTextColor; - [Obsolete("ConsoleColor is obsolete, use the (int, int, int, int) constructor instead. This will be removed in a future update.", true)] - public MelonAuthorColorAttribute(ConsoleColor color) - => Color = ((color == ConsoleColor.Black) ? LoggerUtils.DrawingColorToConsoleColor(MelonLogger.DefaultMelonColor) : color); - public MelonAuthorColorAttribute(int alpha, int red, int green, int blue) => DrawingColor = System.Drawing.Color.FromArgb(alpha, red, green, blue); } diff --git a/MelonLoader/Attributes/MelonColorAttribute.cs b/MelonLoader/Attributes/MelonColorAttribute.cs index 22b83c96f..d2627b78a 100644 --- a/MelonLoader/Attributes/MelonColorAttribute.cs +++ b/MelonLoader/Attributes/MelonColorAttribute.cs @@ -7,16 +7,6 @@ namespace MelonLoader [AttributeUsage(AttributeTargets.Assembly)] public class MelonColorAttribute : Attribute { - /// - /// Color of the Melon. - /// - [Obsolete("Color is obsolete. Use DrawingColor for full Color support. This will be removed in a future update.", true)] - public ConsoleColor Color - { - get => LoggerUtils.DrawingColorToConsoleColor(DrawingColor); - set => DrawingColor = LoggerUtils.ConsoleColorToDrawingColor(value); - } - /// /// Color of the Author Log. /// @@ -25,10 +15,6 @@ public ConsoleColor Color public MelonColorAttribute() => DrawingColor = MelonLogger.DefaultTextColor; - [Obsolete("ConsoleColor is obsolete, use the (int, int, int, int) constructor instead. This will be removed in a future update.", true)] - public MelonColorAttribute(ConsoleColor color) - => Color = ((color == ConsoleColor.Black) ? LoggerUtils.DrawingColorToConsoleColor(MelonLogger.DefaultMelonColor) : color); - public MelonColorAttribute(int alpha, int red, int green, int blue) => DrawingColor = System.Drawing.Color.FromArgb(alpha, red, green, blue); } diff --git a/MelonLoader/Attributes/MelonGameAttribute.cs b/MelonLoader/Attributes/MelonGameAttribute.cs deleted file mode 100644 index 84517b5f2..000000000 --- a/MelonLoader/Attributes/MelonGameAttribute.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; - -namespace MelonLoader -{ - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public class MelonGameAttribute : Attribute - { - public MelonGameAttribute(string developer = null, string name = null) { Developer = developer; Name = name; } - - /// - /// Developer of the Game. - /// - public string Developer { get; internal set; } - - /// - /// Name of the Game. - /// - public string Name { get; internal set; } - - /// - /// If the Attribute is set as Universal or not. - /// - public bool Universal { get => (string.IsNullOrEmpty(Developer) || Developer.Equals("UNKNOWN") || string.IsNullOrEmpty(Name) || Name.Equals("UNKNOWN")); } - - /// - /// Returns true or false if the Game is compatible with this Assembly. - /// - public bool IsCompatible(string developer, string gameName) => (Universal || (!string.IsNullOrEmpty(developer) && Developer.Equals(developer) && !string.IsNullOrEmpty(gameName) && Name.Equals(gameName))); - - /// - /// Returns true or false if the Game is compatible with this Assembly. - /// - public bool IsCompatible(MelonGameAttribute att) => (IsCompatibleBecauseUniversal(att) || (att.Developer.Equals(Developer) && att.Name.Equals(Name))); - - /// - /// Returns true or false if the Game is compatible with this Assembly specifically because of Universal Compatibility. - /// - public bool IsCompatibleBecauseUniversal(MelonGameAttribute att) => ((att == null) || Universal || att.Universal); - - [Obsolete("IsCompatible(MelonModGameAttribute) is obsolete. Please use IsCompatible(MelonGameAttribute) instead. This will be removed in a future update.", true)] - public bool IsCompatible(MelonModGameAttribute att) => ((att == null) || IsCompatibleBecauseUniversal(att) || (att.Developer.Equals(Developer) && att.GameName.Equals(Name))); - [Obsolete("IsCompatible(MelonPluginGameAttribute) is obsolete. Please use IsCompatible(MelonGameAttribute) instead. This will be removed in a future update.", true)] - public bool IsCompatible(MelonPluginGameAttribute att) => ((att == null) || IsCompatibleBecauseUniversal(att) || (att.Developer.Equals(Developer) && att.GameName.Equals(Name))); - [Obsolete("IsCompatibleBecauseUniversal(MelonModGameAttribute) is obsolete. Please use IsCompatible(MelonGameAttribute) instead. This will be removed in a future update.", true)] - public bool IsCompatibleBecauseUniversal(MelonModGameAttribute att) => ((att == null) || Universal || (string.IsNullOrEmpty(att.Developer) || string.IsNullOrEmpty(att.GameName))); - [Obsolete("IsCompatibleBecauseUniversal(MelonPluginGameAttribute) is obsolete. Please use IsCompatible(MelonGameAttribute) instead. This will be removed in a future update.", true)] - public bool IsCompatibleBecauseUniversal(MelonPluginGameAttribute att) => ((att == null) || Universal || (string.IsNullOrEmpty(att.Developer) || string.IsNullOrEmpty(att.GameName))); - } -} \ No newline at end of file diff --git a/MelonLoader/Attributes/MelonGameVersionAttribute.cs b/MelonLoader/Attributes/MelonGameVersionAttribute.cs deleted file mode 100644 index f2e66653a..000000000 --- a/MelonLoader/Attributes/MelonGameVersionAttribute.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace MelonLoader -{ - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public class MelonGameVersionAttribute : Attribute - { - public MelonGameVersionAttribute(string version = null) - => Version = version; - - /// - /// Version of the Game. - /// - public string Version { get; internal set; } - - /// - /// If the Attribute is set as Universal or not. - /// - public bool Universal { get => string.IsNullOrEmpty(Version); } - } -} \ No newline at end of file diff --git a/MelonLoader/Attributes/MelonPlatformDomainAttribute.cs b/MelonLoader/Attributes/MelonPlatformDomainAttribute.cs index 9447afb14..9f1bd47be 100644 --- a/MelonLoader/Attributes/MelonPlatformDomainAttribute.cs +++ b/MelonLoader/Attributes/MelonPlatformDomainAttribute.cs @@ -12,7 +12,7 @@ public enum CompatibleDomains { UNIVERSAL, MONO, - IL2CPP + DOTNET }; // Platform Domain Compatibility of the Melon. diff --git a/MelonLoader/Attributes/RegisterTypeInIl2Cpp.cs b/MelonLoader/Attributes/RegisterTypeInIl2Cpp.cs deleted file mode 100644 index 16ecb6cae..000000000 --- a/MelonLoader/Attributes/RegisterTypeInIl2Cpp.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - -namespace MelonLoader -{ - [AttributeUsage(AttributeTargets.Class)] - public class RegisterTypeInIl2Cpp : Attribute //Naming violation? - { - internal static List registrationQueue = new List(); - internal static bool ready; - internal bool LogSuccess = true; - - public RegisterTypeInIl2Cpp() { } - public RegisterTypeInIl2Cpp(bool logSuccess) { LogSuccess = logSuccess; } - - public static void RegisterAssembly(Assembly asm) - { - if (!MelonUtils.IsGameIl2Cpp()) - return; - - if (!ready) - { - registrationQueue.Add(asm); - return; - } - - IEnumerable typeTbl = asm.GetValidTypes(); - if ((typeTbl == null) || (typeTbl.Count() <= 0)) - return; - foreach (Type type in typeTbl) - { - object[] attTbl = type.GetCustomAttributes(typeof(RegisterTypeInIl2Cpp), false); - if ((attTbl == null) || (attTbl.Length <= 0)) - continue; - RegisterTypeInIl2Cpp att = (RegisterTypeInIl2Cpp)attTbl[0]; - if (att == null) - continue; - InteropSupport.RegisterTypeInIl2CppDomain(type, att.LogSuccess); - } - } - - internal static void SetReady() - { - ready = true; - - if (registrationQueue == null) - return; - - foreach (var asm in registrationQueue) - RegisterAssembly(asm); - - registrationQueue = null; - } - } -} \ No newline at end of file diff --git a/MelonLoader/Attributes/RegisterTypeInIl2CppWithInterfaces.cs b/MelonLoader/Attributes/RegisterTypeInIl2CppWithInterfaces.cs deleted file mode 100644 index 5a1c679d9..000000000 --- a/MelonLoader/Attributes/RegisterTypeInIl2CppWithInterfaces.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - -namespace MelonLoader -{ - [AttributeUsage(AttributeTargets.Class)] - public class RegisterTypeInIl2CppWithInterfaces : Attribute //Naming violation? - { - internal static List registrationQueue = new List(); - internal static bool ready; - internal bool LogSuccess = true; - - internal Type[] Interfaces; - internal bool GetInterfacesFromType; - - public RegisterTypeInIl2CppWithInterfaces() - { - GetInterfacesFromType = true; - } - - public RegisterTypeInIl2CppWithInterfaces(bool logSuccess) - { - LogSuccess = logSuccess; - GetInterfacesFromType = true; - } - - public RegisterTypeInIl2CppWithInterfaces(params Type[] interfaces) - { - Interfaces = interfaces; - } - - public RegisterTypeInIl2CppWithInterfaces(bool logSuccess, params Type[] interfaces) - { - LogSuccess = logSuccess; - Interfaces = interfaces; - } - - public static void RegisterAssembly(Assembly asm) - { - if (!MelonUtils.IsGameIl2Cpp()) - return; - - if (!ready) - { - registrationQueue.Add(asm); - return; - } - - IEnumerable typeTbl = asm.GetValidTypes(); - if ((typeTbl == null) || (typeTbl.Count() <= 0)) - return; - - foreach (Type type in typeTbl) - { - object[] attTbl = type.GetCustomAttributes(typeof(RegisterTypeInIl2CppWithInterfaces), false); - if ((attTbl == null) || (attTbl.Length <= 0)) - continue; - - RegisterTypeInIl2CppWithInterfaces att = (RegisterTypeInIl2CppWithInterfaces)attTbl[0]; - if (att == null) - continue; - - Type[] interfaceArr = att.GetInterfacesFromType - ? type.GetInterfaces() - : att.Interfaces; - - InteropSupport.RegisterTypeInIl2CppDomainWithInterfaces(type, - interfaceArr, - att.LogSuccess); - } - } - - internal static void SetReady() - { - ready = true; - - if (registrationQueue == null) - return; - - foreach (var asm in registrationQueue) - RegisterAssembly(asm); - - registrationQueue = null; - } - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/0Harmony.cs b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/0Harmony.cs deleted file mode 100644 index ed5f6dae5..000000000 --- a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/0Harmony.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System.Runtime.CompilerServices; -#pragma warning disable 0618 - -[assembly: TypeForwardedTo(typeof(HarmonyLib.DelegateTypeFactory))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.GetterHandler<,>))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.SetterHandler<,>))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.InstantiationHandler<>))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.FastAccess))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.FastInvokeHandler))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.MethodInvoker))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.MethodType))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.ArgumentType))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyPatchType))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyReversePatchType))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.MethodDispatchType))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyAttribute))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyPatch))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyDelegate))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyReversePatch))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyPatchAll))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyPriority))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyBefore))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyAfter))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyDebug))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyEmitIL))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyWrapSafe))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyPrepare))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyCleanup))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyTargetMethod))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyTargetMethods))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyPrefix))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyPostfix))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyTranspiler))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyILManipulator))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyFinalizer))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyArgument))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.CodeInstruction))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.ExceptionBlockType))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.ExceptionBlock))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.InvalidHarmonyPatchArgumentException))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.MemberNotFoundException))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Harmony))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyException))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyGlobalSettings))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyMethod))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.HarmonyMethodExtensions))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.InlineSignature))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.PatchInfo))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Patch))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.PatchClassProcessor))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Patches))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.PatchProcessor))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Priority))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.ReversePatcher))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Transpilers))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.AccessTools))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.CodeMatch))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.CodeMatcher))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.GeneralExtensions))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.CodeInstructionExtensions))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.CollectionExtensions))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.MethodBaseExtensions))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.FileLog))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.SymbolExtensions))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Traverse<>))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Traverse))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Tools.HarmonyFileLog))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Tools.Logger))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Public.Patching.HarmonyManipulator))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Public.Patching.ManagedMethodPatcher))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Public.Patching.MethodPatcher))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Public.Patching.NativeDetourMethodPatcher))] -[assembly: TypeForwardedTo(typeof(HarmonyLib.Public.Patching.PatchManager))] diff --git a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.Mdb.cs b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.Mdb.cs deleted file mode 100644 index b14379712..000000000 --- a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.Mdb.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.MonoSymbolFileException))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.ISourceFile))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.ICompileUnit))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.IMethodDef))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.MonoSymbolFile))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.OffsetTable))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.LineNumberEntry))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.CodeBlockEntry))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.LocalVariableEntry))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.CapturedVariable))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.CapturedScope))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.ScopeVariable))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.AnonymousScopeEntry))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.CompileUnitEntry))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.SourceFileEntry))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.LineNumberTable))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.MethodEntry))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.NamespaceEntry))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.MonoSymbolWriter))] -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.SourceMethodBuilder))] -#if !NET6_0 -[assembly: TypeForwardedTo(typeof(Mono.CompilerServices.SymbolWriter.SymbolWriterImpl))] -#endif -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Mdb.MdbReaderProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Mdb.MdbReader))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Mdb.MdbWriterProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Mdb.MdbWriter))] diff --git a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.Pdb.cs b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.Pdb.cs deleted file mode 100644 index d722d62d2..000000000 --- a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.Pdb.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.NativePdbReader))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.NativePdbWriter))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.NativePdbReaderProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.PdbReaderProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.NativePdbWriterProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.PdbWriterProvider))] - -#if !NET6_0 -[assembly: TypeForwardedTo(typeof(Microsoft.Cci.ILocalScope))] -[assembly: TypeForwardedTo(typeof(Microsoft.Cci.INamespaceScope))] -[assembly: TypeForwardedTo(typeof(Microsoft.Cci.IUsedNamespace))] -[assembly: TypeForwardedTo(typeof(Microsoft.Cci.IName))] -#endif diff --git a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.Rocks.cs b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.Rocks.cs deleted file mode 100644 index f08d69583..000000000 --- a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.Rocks.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.DocCommentId))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.IILVisitor))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.ILParser))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.MethodBodyRocks))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.MethodDefinitionRocks))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.ModuleDefinitionRocks))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.ParameterReferenceRocks))] -#if !NET6_0 -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.SecurityDeclarationRocks))] -#endif -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.TypeDefinitionRocks))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.TypeReferenceRocks))] diff --git a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.cs b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.cs deleted file mode 100644 index 68e2b6322..000000000 --- a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.cs +++ /dev/null @@ -1,177 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: TypeForwardedTo(typeof(Mono.Collections.Generic.Collection<>))] -[assembly: TypeForwardedTo(typeof(Mono.Collections.Generic.ReadOnlyCollection<>))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ArrayDimension))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ArrayType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.AssemblyDefinition))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.AssemblyAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.AssemblyHashAlgorithm))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.AssemblyLinkedResource))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.AssemblyNameDefinition))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.AssemblyNameReference))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.AssemblyResolveEventHandler))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.AssemblyResolveEventArgs))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.AssemblyResolutionException))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.BaseAssemblyResolver))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.CallSite))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.CustomAttributeArgument))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.CustomAttributeNamedArgument))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ICustomAttribute))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.CustomAttribute))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.DefaultAssemblyResolver))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.EmbeddedResource))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.EventAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.EventDefinition))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.EventReference))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ExportedType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.FieldAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.FieldDefinition))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.FieldReference))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.FunctionPointerType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.GenericInstanceMethod))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.GenericInstanceType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.GenericParameter))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.GenericParameterAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IConstantProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ICustomAttributeProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IGenericInstance))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IGenericParameterProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.GenericParameterType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IMarshalInfoProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IMemberDefinition))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MetadataScopeType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IMetadataScope))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IMetadataTokenProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IMethodSignature))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IMetadataImporterProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IMetadataImporter))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IReflectionImporterProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IReflectionImporter))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.DefaultReflectionImporter))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.DefaultMetadataImporter))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.LinkedResource))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ManifestResourceAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MarshalInfo))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ArrayMarshalInfo))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.CustomMarshalInfo))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.SafeArrayMarshalInfo))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.FixedArrayMarshalInfo))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.FixedSysStringMarshalInfo))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MemberReference))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IAssemblyResolver))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IMetadataResolver))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ResolutionException))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MetadataResolver))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MethodAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MethodCallingConvention))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MethodDefinition))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MethodImplAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MethodReference))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MethodReturnType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MethodSemanticsAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MethodSpecification))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.IModifierType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.OptionalModifierType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.RequiredModifierType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ReadingMode))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ReaderParameters))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ModuleParameters))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.WriterParameters))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ModuleDefinition))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ModuleKind))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MetadataKind))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.TargetArchitecture))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ModuleAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ModuleCharacteristics))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ModuleReference))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.NativeType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ParameterAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ParameterDefinition))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ParameterReference))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.PinnedType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.PInvokeAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.PInvokeInfo))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.PointerType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.PropertyAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.PropertyDefinition))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.PropertyReference))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ByReferenceType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ResourceType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Resource))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.SecurityAction))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.ISecurityDeclarationProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.SecurityAttribute))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.SecurityDeclaration))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.SentinelType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.TargetRuntime))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.TypeAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.TypeDefinition))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.InterfaceImplementation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MetadataType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.TypeReference))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.TypeSpecification))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.TypeSystem))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.VariantType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.MetadataToken))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.TokenType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.Code))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.DocumentType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.DocumentHashAlgorithm))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.DocumentLanguage))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.DocumentLanguageVendor))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.Document))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ExceptionHandlerType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ExceptionHandler))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ILProcessor))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.Instruction))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.MethodBody))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.FlowControl))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.OpCodeType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.OperandType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.StackBehaviour))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.OpCode))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.OpCodes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.PortablePdbReaderProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.PortablePdbReader))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.EmbeddedPortablePdbReaderProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.EmbeddedPortablePdbReader))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.PortablePdbWriterProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.PortablePdbWriter))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.EmbeddedPortablePdbWriterProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.EmbeddedPortablePdbWriter))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.SequencePoint))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ImageDebugDirectory))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ImageDebugType))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ImageDebugHeader))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ImageDebugHeaderEntry))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ScopeDebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.InstructionOffset))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.VariableAttributes))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.VariableIndex))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.DebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.VariableDebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ConstantDebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ImportTargetKind))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ImportTarget))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ImportDebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ICustomDebugInformationProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.CustomDebugInformationKind))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.CustomDebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.BinaryCustomDebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.AsyncMethodBodyDebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.StateMachineScope))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.StateMachineScopeDebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.EmbeddedSourceDebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.SourceLinkDebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.MethodDebugInformation))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ISymbolReader))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ISymbolReaderProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.SymbolsNotFoundException))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.SymbolsNotMatchingException))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.DefaultSymbolReaderProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ISymbolWriter))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.ISymbolWriterProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.DefaultSymbolWriterProvider))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.VariableDefinition))] -[assembly: TypeForwardedTo(typeof(Mono.Cecil.Cil.VariableReference))] diff --git a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.RuntimeDetour.cs b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.RuntimeDetour.cs deleted file mode 100644 index 4397566e5..000000000 --- a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.RuntimeDetour.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.DetourConfig))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Detour))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Detour<>))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.DetourContext))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.DetourModManager))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.HarmonyDetourBridge))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.HookConfig))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Hook))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Hook<>))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Hook<,>))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.IDetour))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.ISortableDetour))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.ILHookConfig))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.ILHook))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.NativeDetourConfig))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.NativeDetour))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.DetourHelper))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.IDetourNativePlatform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.IDetourRuntimePlatform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.OnMethodCompiledEvent))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.NativeDetourData))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeARMPlatform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeLibcPlatform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPlatform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeWindowsPlatform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourNativeX86Platform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeMonoPlatform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeNET50Platform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeNET60Platform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCore30Platform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCorePlatform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETPlatform))] -[assembly: TypeForwardedTo(typeof(MonoMod.RuntimeDetour.HookGen.HookEndpointManager))] diff --git a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.Utils.cs b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.Utils.cs deleted file mode 100644 index dcfcac562..000000000 --- a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/MonoMod.Utils.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: TypeForwardedTo(typeof(IgnoresAccessChecksToAttribute))] -[assembly: TypeForwardedTo(typeof(MonoMod.ModInterop.ModExportNameAttribute))] -[assembly: TypeForwardedTo(typeof(MonoMod.ModInterop.ModImportNameAttribute))] -[assembly: TypeForwardedTo(typeof(MonoMod.ModInterop.ModInteropManager))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynData<>))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Extensions))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.FastReflectionDelegate))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.FastReflectionHelper))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.GenericMethodInstantiationComparer))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.GenericTypeInstantiationComparer))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.LazyDisposable))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.LazyDisposable<>))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DMDGenerator<>))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DMDCecilGenerator))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DMDEmitDynamicMethodGenerator))] -#if !NET6_0 -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DMDEmitMethodBuilderGenerator))] -#endif -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynamicMethodDefinition))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynamicMethodHelper))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynamicMethodReference))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynDll))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynDllImportAttribute))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.DynDllMapping))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Relinker))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.GCListener))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.ICallSiteGenerator))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.MMReflectionImporter))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Platform))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.PlatformHelper))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.ReflectionHelper))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.RelinkFailedException))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.RelinkTargetNotFoundException))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.WeakReferenceComparer))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Cil.CecilILGenerator))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Cil.ILGeneratorShim))] -[assembly: TypeForwardedTo(typeof(MonoMod.Utils.Cil.ILGeneratorShimExt))] -[assembly: TypeForwardedTo(typeof(MonoMod.Cil.ILContext))] -[assembly: TypeForwardedTo(typeof(MonoMod.Cil.MoveType))] -[assembly: TypeForwardedTo(typeof(MonoMod.Cil.SearchTarget))] -[assembly: TypeForwardedTo(typeof(MonoMod.Cil.ILCursor))] -[assembly: TypeForwardedTo(typeof(MonoMod.Cil.ILLabel))] -[assembly: TypeForwardedTo(typeof(MonoMod.Cil.ILPatternMatchingExt))] -[assembly: TypeForwardedTo(typeof(MonoMod.Cil.IILReferenceBag))] -[assembly: TypeForwardedTo(typeof(MonoMod.Cil.NopILReferenceBag))] -[assembly: TypeForwardedTo(typeof(MonoMod.Cil.RuntimeILReferenceBag))] diff --git a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Tomlet.cs b/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Tomlet.cs deleted file mode 100644 index b2b409e62..000000000 --- a/MelonLoader/BackwardsCompatibility/ForwardingAttributes/Tomlet.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: TypeForwardedTo(typeof(Tomlet.TomletMain))] -[assembly: TypeForwardedTo(typeof(Tomlet.TomletStringReader))] -[assembly: TypeForwardedTo(typeof(Tomlet.TomlNumberUtils))] -[assembly: TypeForwardedTo(typeof(Tomlet.TomlParser))] -[assembly: TypeForwardedTo(typeof(Tomlet.TomlSerializationMethods))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlArray))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlBoolean))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlCommentData))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlDocument))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlDouble))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlLocalDate))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlLocalDateTime))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlLocalTime))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlLong))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlOffsetDateTime))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlString))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlTable))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.TomlValue))] -[assembly: TypeForwardedTo(typeof(Tomlet.Models.ITomlValueWithDateTime))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.InvalidTomlDateTimeException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.InvalidTomlEscapeException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.InvalidTomlInlineTableException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.InvalidTomlKeyException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.InvalidTomlNumberException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.MissingIntermediateInTomlTableArraySpecException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.NewLineInTomlInlineTableException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.NoTomlKeyException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TimeOffsetOnTomlDateOrTimeException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlArraySyntaxException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlContainsDottedKeyNonTableException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlDateTimeMissingSeparatorException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlDateTimeUnnecessarySeparatorException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlDottedKeyException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlDottedKeyParserException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlDoubleDottedKeyException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlEndOfFileException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlEnumParseException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlExceptionWithLine))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlFieldTypeMismatchException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlInlineTableSeparatorException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlInstantiationException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlInternalException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlInvalidValueException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlKeyRedefinitionException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlMissingEqualsException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlMissingNewlineException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlNewlineInInlineCommentException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlNonTableArrayUsedAsTableArrayException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlNoSuchValueException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlPrimitiveToDocumentException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlStringException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlTableArrayAlreadyExistsAsNonArrayException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlTableLockedException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlTableRedefinitionException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlTripleQuotedKeyException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlTypeMismatchException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlUnescapedUnicodeControlCharException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TomlWhitespaceInKeyException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TripleQuoteInTomlMultilineLiteralException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.TripleQuoteInTomlMultilineSimpleStringException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.UnterminatedTomlKeyException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.UnterminatedTomlStringException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.UnterminatedTomlTableArrayException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Exceptions.UnterminatedTomlTableNameException))] -[assembly: TypeForwardedTo(typeof(Tomlet.Attributes.TomlDoNotInlineObjectAttribute))] -[assembly: TypeForwardedTo(typeof(Tomlet.Attributes.TomlInlineCommentAttribute))] -[assembly: TypeForwardedTo(typeof(Tomlet.Attributes.TomlPrecedingCommentAttribute))] -[assembly: TypeForwardedTo(typeof(Tomlet.Attributes.TomlPropertyAttribute))] diff --git a/MelonLoader/BackwardsCompatibility/Harmony/Attributes.cs b/MelonLoader/BackwardsCompatibility/Harmony/Attributes.cs deleted file mode 100644 index fa10a3514..000000000 --- a/MelonLoader/BackwardsCompatibility/Harmony/Attributes.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System; - -namespace Harmony -{ - [Obsolete("Harmony.MethodType is Only Here for Compatibility Reasons. Please use HarmonyLib.MethodType instead. This will be removed in a future update.", true)] - public enum MethodType - { - Normal = HarmonyLib.MethodType.Normal, - Getter = HarmonyLib.MethodType.Getter, - Setter = HarmonyLib.MethodType.Setter, - Constructor = HarmonyLib.MethodType.Constructor, - StaticConstructor = HarmonyLib.MethodType.StaticConstructor - } - - [Obsolete("Harmony.PropertyMethod is Only Here for Compatibility Reasons. Please use HarmonyLib.MethodType instead. This will be removed in a future update.", true)] - public enum PropertyMethod - { - Getter = HarmonyLib.MethodType.Getter, - Setter = HarmonyLib.MethodType.Setter - } - - [Obsolete("Harmony.ArgumentType is Only Here for Compatibility Reasons. Please use HarmonyLib.ArgumentType instead. This will be removed in a future update.", true)] - public enum ArgumentType - { - Normal = HarmonyLib.ArgumentType.Normal, - Ref = HarmonyLib.ArgumentType.Ref, - Out = HarmonyLib.ArgumentType.Out, - Pointer = HarmonyLib.ArgumentType.Pointer - } - - [Obsolete("Harmony.HarmonyPatchType is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatchType instead. This will be removed in a future update.", true)] - public enum HarmonyPatchType - { - All = HarmonyLib.HarmonyPatchType.All, - Prefix = HarmonyLib.HarmonyPatchType.Prefix, - Postfix = HarmonyLib.HarmonyPatchType.Postfix, - Transpiler = HarmonyLib.HarmonyPatchType.Transpiler - } - - [Obsolete("Harmony.HarmonyAttribute is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyAttribute instead. This will be removed in a future update.", true)] - public class HarmonyAttribute : HarmonyLib.HarmonyAttribute { } - - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Delegate | AttributeTargets.Method, AllowMultiple = true)] - public class HarmonyPatch : HarmonyLib.HarmonyPatch - { - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch() : base() { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(Type declaringType) : base(declaringType) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(Type declaringType, Type[] argumentTypes) : base(declaringType, argumentTypes) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(Type declaringType, string methodName) : base(declaringType, methodName) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(Type declaringType, string methodName, params Type[] argumentTypes) : base(declaringType, methodName, argumentTypes) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(Type declaringType, string methodName, Type[] argumentTypes, ArgumentType[] argumentVariations) : base(declaringType, methodName, argumentTypes, Array.ConvertAll(argumentVariations, x => (HarmonyLib.ArgumentType)x)) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(Type declaringType, MethodType methodType) : base(declaringType, (HarmonyLib.MethodType)methodType) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(Type declaringType, MethodType methodType, params Type[] argumentTypes) : base(declaringType, (HarmonyLib.MethodType)methodType, argumentTypes) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(Type declaringType, MethodType methodType, Type[] argumentTypes, ArgumentType[] argumentVariations) : base(declaringType, (HarmonyLib.MethodType)methodType, argumentTypes, Array.ConvertAll(argumentVariations, x => (HarmonyLib.ArgumentType)x)) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(Type declaringType, string propertyName, MethodType methodType) : base(declaringType, propertyName, (HarmonyLib.MethodType)methodType) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(string methodName) : base(methodName) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(string methodName, params Type[] argumentTypes) : base(methodName, argumentTypes) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(string methodName, Type[] argumentTypes, ArgumentType[] argumentVariations) : base(methodName, argumentTypes, Array.ConvertAll(argumentVariations, x => (HarmonyLib.ArgumentType)x)) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(string propertyName, MethodType methodType) : base(propertyName, (HarmonyLib.MethodType)methodType) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(MethodType methodType) : base((HarmonyLib.MethodType)methodType) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(MethodType methodType, params Type[] argumentTypes) : base((HarmonyLib.MethodType)methodType, argumentTypes) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(MethodType methodType, Type[] argumentTypes, ArgumentType[] argumentVariations) : base((HarmonyLib.MethodType)methodType, argumentTypes, Array.ConvertAll(argumentVariations, x => (HarmonyLib.ArgumentType)x)) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(Type[] argumentTypes) : base(argumentTypes) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(Type[] argumentTypes, ArgumentType[] argumentVariations) : base(argumentTypes, Array.ConvertAll(argumentVariations, x => (HarmonyLib.ArgumentType)x)) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(string propertyName, PropertyMethod type) : base(propertyName, (HarmonyLib.MethodType)type) { } - [Obsolete("Harmony.HarmonyPatch is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatch instead. This will be removed in a future update.", true)] - public HarmonyPatch(string assemblyQualifiedDeclaringType, string methodName, MethodType methodType, Type[] argumentTypes = null, ArgumentType[] argumentVariations = null) : base(assemblyQualifiedDeclaringType, methodName, (HarmonyLib.MethodType)methodType, argumentTypes, Array.ConvertAll(argumentVariations, x => (HarmonyLib.ArgumentType)x)) { } - } - - [Obsolete("Harmony.HarmonyPatchAll is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPatchAll instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Class)] - public class HarmonyPatchAll : HarmonyLib.HarmonyPatchAll { } - - [Obsolete("Harmony.HarmonyPriority is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPriority instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] - public class HarmonyPriority : HarmonyLib.HarmonyPriority - { - [Obsolete("Harmony.HarmonyPriority is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPriority instead. This will be removed in a future update.", true)] - public HarmonyPriority(int prioritiy) : base(prioritiy) { } - } - - [Obsolete("Harmony.HarmonyBefore is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyBefore instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] - public class HarmonyBefore : HarmonyLib.HarmonyBefore - { - [Obsolete("Harmony.HarmonyBefore is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyBefore instead. This will be removed in a future update.", true)] - public HarmonyBefore(params string[] before) : base(before) { } - } - - [Obsolete("Harmony.HarmonyAfter is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyAfter instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] - public class HarmonyAfter : HarmonyLib.HarmonyAfter - { - [Obsolete("Harmony.HarmonyAfter is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyAfter instead. This will be removed in a future update.", true)] - public HarmonyAfter(params string[] after) : base(after) { } - } - - [Obsolete("Harmony.HarmonyPrepare is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPrepare instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Method)] - public class HarmonyPrepare : HarmonyLib.HarmonyPrepare { } - - [Obsolete("Harmony.HarmonyCleanup is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyCleanup instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Method)] - public class HarmonyCleanup : HarmonyLib.HarmonyCleanup { } - - [Obsolete("Harmony.HarmonyTargetMethod is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyTargetMethod instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Method)] - public class HarmonyTargetMethod : HarmonyLib.HarmonyTargetMethod { } - - [Obsolete("Harmony.HarmonyTargetMethods is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyTargetMethods instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Method)] - public class HarmonyTargetMethods : HarmonyLib.HarmonyTargetMethods { } - - [Obsolete("Harmony.HarmonyPrefix is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPrefix instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Method)] - public class HarmonyPrefix : HarmonyLib.HarmonyPrefix { } - - [Obsolete("Harmony.HarmonyPostfix is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyPostfix instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Method)] - public class HarmonyPostfix : HarmonyLib.HarmonyPostfix { } - - [Obsolete("Harmony.HarmonyTranspiler is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyTranspiler instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Method)] - public class HarmonyTranspiler : HarmonyLib.HarmonyTranspiler { } - - [Obsolete("Harmony.HarmonyArgument is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyArgument instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] - public class HarmonyArgument : HarmonyLib.HarmonyArgument - { - [Obsolete("Harmony.HarmonyArgument is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyArgument instead. This will be removed in a future update.", true)] - public HarmonyArgument(string originalName) : base(originalName, null) { } - [Obsolete("Harmony.HarmonyArgument is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyArgument instead. This will be removed in a future update.", true)] - public HarmonyArgument(int index) : base(index, null) { } - [Obsolete("Harmony.HarmonyArgument is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyArgument instead. This will be removed in a future update.", true)] - public HarmonyArgument(string originalName, string newName) : base(originalName, newName) { } - [Obsolete("Harmony.HarmonyArgument is Only Here for Compatibility Reasons. Please use HarmonyLib.HarmonyArgument instead. This will be removed in a future update.", true)] - public HarmonyArgument(int index, string name) : base(index, name) { } - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Harmony/Extras/DelegateTypeFactory.cs b/MelonLoader/BackwardsCompatibility/Harmony/Extras/DelegateTypeFactory.cs deleted file mode 100644 index 85700343e..000000000 --- a/MelonLoader/BackwardsCompatibility/Harmony/Extras/DelegateTypeFactory.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Harmony -{ - public class DelegateTypeFactory : HarmonyLib.DelegateTypeFactory { } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Harmony/Extras/FastAccess.cs b/MelonLoader/BackwardsCompatibility/Harmony/Extras/FastAccess.cs deleted file mode 100644 index 2cf0ba01d..000000000 --- a/MelonLoader/BackwardsCompatibility/Harmony/Extras/FastAccess.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Reflection; -using System.Reflection.Emit; -using MonoMod.Utils; - -namespace Harmony -{ - public delegate object GetterHandler(object source); - public delegate void SetterHandler(object source, object value); - public delegate object InstantiationHandler(); - - public class FastAccess - { - [Obsolete("Use AccessTools.MethodDelegate>(PropertyInfo.GetGetMethod(true)). This will be removed in a future update.", true)] - public static InstantiationHandler CreateInstantiationHandler(Type type) - { - var constructorInfo = type.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[0], null); - if (constructorInfo is null) - throw new ApplicationException(string.Format("The type {0} must declare an empty constructor (the constructor may be private, internal, protected, protected internal, or public).", type)); - var dynamicMethod = new DynamicMethodDefinition($"InstantiateObject_{type.Name}", type, null); - var generator = dynamicMethod.GetILGenerator(); - generator.Emit(OpCodes.Newobj, constructorInfo); - generator.Emit(OpCodes.Ret); - return (InstantiationHandler)dynamicMethod.Generate().CreateDelegate(typeof(InstantiationHandler)); - } - - [Obsolete("Use AccessTools.MethodDelegate>(PropertyInfo.GetGetMethod(true)). This will be removed in a future update.", true)] - public static GetterHandler CreateGetterHandler(PropertyInfo propertyInfo) - { - var getMethodInfo = propertyInfo.GetGetMethod(true); - var dynamicGet = CreateGetDynamicMethod(propertyInfo.DeclaringType); - var getGenerator = dynamicGet.GetILGenerator(); - getGenerator.Emit(OpCodes.Ldarg_0); - getGenerator.Emit(OpCodes.Call, getMethodInfo); - getGenerator.Emit(OpCodes.Ret); - return (GetterHandler)dynamicGet.Generate().CreateDelegate(typeof(GetterHandler)); - } - - [Obsolete("Use AccessTools.FieldRefAccess(fieldInfo). This will be removed in a future update.", true)] - public static GetterHandler CreateGetterHandler(FieldInfo fieldInfo) - { - var dynamicGet = CreateGetDynamicMethod(fieldInfo.DeclaringType); - var getGenerator = dynamicGet.GetILGenerator(); - getGenerator.Emit(OpCodes.Ldarg_0); - getGenerator.Emit(OpCodes.Ldfld, fieldInfo); - getGenerator.Emit(OpCodes.Ret); - return (GetterHandler)dynamicGet.Generate().CreateDelegate(typeof(GetterHandler)); - } - - [Obsolete("Use AccessTools.FieldRefAccess(name) for fields and " + - "AccessTools.MethodDelegate>(AccessTools.PropertyGetter(typeof(T), name)) for properties. This will be removed in a future update.", true)] - public static GetterHandler CreateFieldGetter(Type type, params string[] names) - { - foreach (var name in names) - { - var field = type.GetField(name, AccessTools.all); - if (field is object) - return CreateGetterHandler(field); - var property = type.GetProperty(name, AccessTools.all); - if (property is object) - return CreateGetterHandler(property); - } - return null; - } - - [Obsolete("Use AccessTools.MethodDelegate>(PropertyInfo.GetSetMethod(true)). This will be removed in a future update.", true)] - public static SetterHandler CreateSetterHandler(PropertyInfo propertyInfo) - { - var setMethodInfo = propertyInfo.GetSetMethod(true); - var dynamicSet = CreateSetDynamicMethod(propertyInfo.DeclaringType); - var setGenerator = dynamicSet.GetILGenerator(); - setGenerator.Emit(OpCodes.Ldarg_0); - setGenerator.Emit(OpCodes.Ldarg_1); - setGenerator.Emit(OpCodes.Call, setMethodInfo); - setGenerator.Emit(OpCodes.Ret); - return (SetterHandler)dynamicSet.Generate().CreateDelegate(typeof(SetterHandler)); - } - - [Obsolete("Use AccessTools.FieldRefAccess(fieldInfo). This will be removed in a future update.", true)] - public static SetterHandler CreateSetterHandler(FieldInfo fieldInfo) - { - var dynamicSet = CreateSetDynamicMethod(fieldInfo.DeclaringType); - var setGenerator = dynamicSet.GetILGenerator(); - setGenerator.Emit(OpCodes.Ldarg_0); - setGenerator.Emit(OpCodes.Ldarg_1); - setGenerator.Emit(OpCodes.Stfld, fieldInfo); - setGenerator.Emit(OpCodes.Ret); - return (SetterHandler)dynamicSet.Generate().CreateDelegate(typeof(SetterHandler)); - } - - static DynamicMethodDefinition CreateGetDynamicMethod(Type type) - => new DynamicMethodDefinition($"DynamicGet_{type.Name}", typeof(object), new Type[] { typeof(object) }); - - static DynamicMethodDefinition CreateSetDynamicMethod(Type type) - => new DynamicMethodDefinition($"DynamicSet_{type.Name}", typeof(void), new Type[] { typeof(object), typeof(object) }); - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Harmony/Extras/MethodInvoker.cs b/MelonLoader/BackwardsCompatibility/Harmony/Extras/MethodInvoker.cs deleted file mode 100644 index 34e49109e..000000000 --- a/MelonLoader/BackwardsCompatibility/Harmony/Extras/MethodInvoker.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Reflection; -using System.Reflection.Emit; - -namespace Harmony -{ - public delegate object FastInvokeHandler(object target, object[] paramters); - public class MethodInvoker - { - public static FastInvokeHandler GetHandler(DynamicMethod methodInfo, Module module) => - ConvertFastInvokeHandler(HarmonyLib.MethodInvoker.GetHandler(methodInfo)); - public static FastInvokeHandler GetHandler(MethodInfo methodInfo) => - ConvertFastInvokeHandler(HarmonyLib.MethodInvoker.GetHandler(methodInfo)); - private static FastInvokeHandler ConvertFastInvokeHandler(HarmonyLib.FastInvokeHandler sourceDelegate) => - (FastInvokeHandler)Delegate.CreateDelegate(typeof(FastInvokeHandler), sourceDelegate.Target, sourceDelegate.Method); - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Harmony/HarmonyInstance.cs b/MelonLoader/BackwardsCompatibility/Harmony/HarmonyInstance.cs deleted file mode 100644 index 3c9344ceb..000000000 --- a/MelonLoader/BackwardsCompatibility/Harmony/HarmonyInstance.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Reflection; -using System.Reflection.Emit; -#pragma warning disable 0618 - -namespace Harmony -{ - [Obsolete("Harmony.HarmonyInstance is obsolete. Please use HarmonyLib.Harmony instead. This will be removed in a future update.", true)] - public class HarmonyInstance : HarmonyLib.Harmony - { - [Obsolete("Harmony.HarmonyInstance is obsolete. Please use HarmonyLib.Harmony instead. This will be removed in a future update.", true)] - public HarmonyInstance(string id) : base(id) { } - - [Obsolete("Harmony.HarmonyInstance.Create is obsolete. Please use the HarmonyLib.Harmony Constructor instead. This will be removed in a future update.", true)] - public static HarmonyInstance Create(string id) - { - if (id == null) throw new Exception("id cannot be null"); - return new HarmonyInstance(id); - } - - [Obsolete("Harmony.HarmonyInstance.Patch is obsolete. Please use HarmonyLib.Harmony.Patch instead. This will be removed in a future update.", true)] - public DynamicMethod Patch(MethodBase original, HarmonyMethod prefix = null, HarmonyMethod postfix = null, HarmonyMethod transpiler = null) - { - base.Patch(original, prefix, postfix, transpiler); - return null; - } - - public void Unpatch(MethodBase original, HarmonyPatchType type, string harmonyID = null) => Unpatch(original, (HarmonyLib.HarmonyPatchType)type, harmonyID); - } -} diff --git a/MelonLoader/BackwardsCompatibility/Harmony/HarmonyMethod.cs b/MelonLoader/BackwardsCompatibility/Harmony/HarmonyMethod.cs deleted file mode 100644 index 6c2cda45e..000000000 --- a/MelonLoader/BackwardsCompatibility/Harmony/HarmonyMethod.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - -namespace Harmony -{ - [Obsolete("Harmony.HarmonyMethod is obsolete. Please use HarmonyLib.HarmonyMethod instead. This will be removed in a future update.", true)] - public class HarmonyMethod : HarmonyLib.HarmonyMethod - { - [Obsolete("Harmony.HarmonyMethod.prioritiy is obsolete. Please use HarmonyLib.HarmonyMethod.priority instead. This will be removed in a future update.", true)] - public int prioritiy = -1; - [Obsolete("Harmony.HarmonyMethod is obsolete. Please use HarmonyLib.HarmonyMethod instead. This will be removed in a future update.", true)] - public HarmonyMethod() : base() { } - [Obsolete("Harmony.HarmonyMethod is obsolete. Please use HarmonyLib.HarmonyMethod instead. This will be removed in a future update.", true)] - public HarmonyMethod(MethodInfo method) : base(method) { } - [Obsolete("Harmony.HarmonyMethod is obsolete. Please use HarmonyLib.HarmonyMethod instead. This will be removed in a future update.", true)] - public HarmonyMethod(Type type, string name, Type[] parameters = null) : base(type, name, parameters) { } - [Obsolete("Harmony.HarmonyMethod.Merge is obsolete. Please use HarmonyLib.HarmonyMethod.Merge instead. This will be removed in a future update.", true)] - public static HarmonyMethod Merge(List attributes) => (HarmonyMethod)Merge(Array.ConvertAll(attributes.ToArray(), x => (HarmonyLib.HarmonyMethod)x).ToList()); - public override string ToString() => base.ToString(); - } - - [Obsolete("Harmony.HarmonyMethodExtensions is obsolete. Please use HarmonyLib.HarmonyMethodExtensions instead. This will be removed in a future update.", true)] - public static class HarmonyMethodExtensions - { - [Obsolete("Harmony.HarmonyMethodExtensions.CopyTo is obsolete. Please use HarmonyLib.HarmonyMethodExtensions.CopyTo instead. This will be removed in a future update.", true)] - public static void CopyTo(this HarmonyMethod from, HarmonyMethod to) => HarmonyLib.HarmonyMethodExtensions.CopyTo(from, to); - [Obsolete("Harmony.HarmonyMethodExtensions.Clone is obsolete. Please use HarmonyLib.HarmonyMethodExtensions.Clone instead. This will be removed in a future update.", true)] - public static HarmonyMethod Clone(this HarmonyMethod original) => (HarmonyMethod)HarmonyLib.HarmonyMethodExtensions.Clone(original); - [Obsolete("Harmony.HarmonyMethodExtensions.Merge is obsolete. Please use HarmonyLib.HarmonyMethodExtensions.Merge instead. This will be removed in a future update.", true)] - public static HarmonyMethod Merge(this HarmonyMethod master, HarmonyMethod detail) => (HarmonyMethod)HarmonyLib.HarmonyMethodExtensions.Merge(master, detail); - [Obsolete("Harmony.HarmonyMethodExtensions.GetHarmonyMethods(Type) is obsolete. Please use HarmonyLib.HarmonyMethodExtensions.GetFromType instead. This will be removed in a future update.", true)] - public static List GetHarmonyMethods(this Type type) => Array.ConvertAll(HarmonyLib.HarmonyMethodExtensions.GetFromType(type).ToArray(), x => (HarmonyMethod)x).ToList(); - [Obsolete("Harmony.HarmonyMethodExtensions.GetHarmonyMethods(MethodBase) is obsolete. Please use HarmonyLib.HarmonyMethodExtensions.GetFromMethod instead. This will be removed in a future update.", true)] - public static List GetHarmonyMethods(this MethodBase method) => Array.ConvertAll(HarmonyLib.HarmonyMethodExtensions.GetFromMethod(method).ToArray(), x => (HarmonyMethod)x).ToList(); - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Harmony/Patch.cs b/MelonLoader/BackwardsCompatibility/Harmony/Patch.cs deleted file mode 100644 index 04006b46e..000000000 --- a/MelonLoader/BackwardsCompatibility/Harmony/Patch.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Reflection; -using MonoMod.Utils; - -namespace Harmony -{ - [Obsolete("Harmony.PatchInfoSerialization is Only Here for Compatibility Reasons. Please use HarmonyLib.PatchInfoSerialization instead. This will be removed in a future update.", true)] - public static class PatchInfoSerialization - { - private delegate HarmonyLib.PatchInfo HarmonyLib_PatchInfoSerialization_Deserialize_Delegate(byte[] bytes); - private static HarmonyLib_PatchInfoSerialization_Deserialize_Delegate HarmonyLib_PatchInfoSerialization_Deserialize - = HarmonyLib.AccessTools.Method("HarmonyLib.PatchInfoSerialization:Deserialize").CreateDelegate(); - - private delegate int HarmonyLib_PatchInfoSerialization_PriorityComparer_Delegate(object obj, int index, int priority); - private static HarmonyLib_PatchInfoSerialization_PriorityComparer_Delegate HarmonyLib_PatchInfoSerialization_PriorityComparer - = HarmonyLib.AccessTools.Method("HarmonyLib.PatchInfoSerialization:PriorityComparer").CreateDelegate(); - - [Obsolete("Harmony.PatchInfoSerialization.Deserialize is Only Here for Compatibility Reasons. Please use HarmonyLib.PatchInfoSerialization.Deserialize instead. This will be removed in a future update.", true)] - public static PatchInfo Deserialize(byte[] bytes) => (PatchInfo)HarmonyLib_PatchInfoSerialization_Deserialize(bytes); - [Obsolete("Harmony.PatchInfoSerialization.PriorityComparer is Only Here for Compatibility Reasons. Please use HarmonyLib.PatchInfoSerialization.PriorityComparer instead. This will be removed in a future update.", true)] - public static int PriorityComparer(object obj, int index, int priority, string[] before, string[] after) => HarmonyLib_PatchInfoSerialization_PriorityComparer(obj, index, priority); - } - - [Obsolete("Harmony.PatchInfo is Only Here for Compatibility Reasons. Please use HarmonyLib.PatchInfo instead. This will be removed in a future update.", true)] - [Serializable] - public class PatchInfo : HarmonyLib.PatchInfo { } - - [Obsolete("Harmony.Patch is Only Here for Compatibility Reasons. Please use HarmonyLib.Patch instead. This will be removed in a future update.", true)] - [Serializable] - public class Patch : IComparable - { - readonly public MethodInfo patch; - private HarmonyLib.Patch patchWrapper; - [Obsolete("Harmony.Patch is Only Here for Compatibility Reasons. Please use HarmonyLib.Patch instead. This will be removed in a future update.", true)] - public Patch(MethodInfo patch, int index, string owner, int priority, string[] before, string[] after) - { - this.patch = patch; - patchWrapper = new HarmonyLib.Patch(patch, index, owner, priority, before, after, false); - } - public MethodInfo GetMethod(MethodBase original) => patchWrapper.GetMethod(original); - public override bool Equals(object obj) => patchWrapper.Equals(obj); - public int CompareTo(object obj) => patchWrapper.CompareTo(obj); - public override int GetHashCode() => patchWrapper.GetHashCode(); - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Harmony/Priority.cs b/MelonLoader/BackwardsCompatibility/Harmony/Priority.cs deleted file mode 100644 index e5f4f1dcd..000000000 --- a/MelonLoader/BackwardsCompatibility/Harmony/Priority.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; - -namespace Harmony -{ - [Obsolete("Harmony.Priority is Only Here for Compatibility Reasons. Please use HarmonyLib.Priority instead. This will be removed in a future update.", true)] - public static class Priority - { - [Obsolete("Harmony.Priority.Last is Only Here for Compatibility Reasons. Please use HarmonyLib.Priority.Last instead. This will be removed in a future update.", true)] - public const int Last = HarmonyLib.Priority.Last; - [Obsolete("Harmony.Priority.VeryLow is Only Here for Compatibility Reasons. Please use HarmonyLib.Priority.VeryLow instead. This will be removed in a future update.", true)] - public const int VeryLow = HarmonyLib.Priority.VeryLow; - [Obsolete("Harmony.Priority.Low is Only Here for Compatibility Reasons. Please use HarmonyLib.Priority.Low instead. This will be removed in a future update.", true)] - public const int Low = HarmonyLib.Priority.Low; - [Obsolete("Harmony.Priority.LowerThanNormal is Only Here for Compatibility Reasons. Please use HarmonyLib.Priority.LowerThanNormal instead. This will be removed in a future update.", true)] - public const int LowerThanNormal = HarmonyLib.Priority.LowerThanNormal; - [Obsolete("Harmony.Priority.Normal is Only Here for Compatibility Reasons. Please use HarmonyLib.Priority.Normal instead. This will be removed in a future update.", true)] - public const int Normal = HarmonyLib.Priority.Normal; - [Obsolete("Harmony.Priority.HigherThanNormal is Only Here for Compatibility Reasons. Please use HarmonyLib.Priority.HigherThanNormal instead. This will be removed in a future update.", true)] - public const int HigherThanNormal = HarmonyLib.Priority.HigherThanNormal; - [Obsolete("Harmony.Priority.High is Only Here for Compatibility Reasons. Please use HarmonyLib.Priority.High instead. This will be removed in a future update.", true)] - public const int High = HarmonyLib.Priority.High; - [Obsolete("Harmony.Priority.VeryHigh is Only Here for Compatibility Reasons. Please use HarmonyLib.Priority.VeryHigh instead. This will be removed in a future update.", true)] - public const int VeryHigh = HarmonyLib.Priority.VeryHigh; - [Obsolete("Harmony.Priority.First is Only Here for Compatibility Reasons. Please use HarmonyLib.Priority.First instead. This will be removed in a future update.", true)] - public const int First = HarmonyLib.Priority.First; - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Harmony/Tools/AccessTools.cs b/MelonLoader/BackwardsCompatibility/Harmony/Tools/AccessTools.cs deleted file mode 100644 index 5b47cea2a..000000000 --- a/MelonLoader/BackwardsCompatibility/Harmony/Tools/AccessTools.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; - -namespace Harmony -{ - [Obsolete("Harmony.AccessTools is Only Here for Compatibility Reasons. Please use HarmonyLib.AccessTools instead. This will be removed in a future update.", true)] - public static class AccessTools - { - public static BindingFlags all = HarmonyLib.AccessTools.all; - public static Type TypeByName(string name) => HarmonyLib.AccessTools.TypeByName(name); - public static T FindIncludingBaseTypes(Type type, Func action) where T : class => HarmonyLib.AccessTools.FindIncludingBaseTypes(type, action); - public static T FindIncludingInnerTypes(Type type, Func action) where T : class => HarmonyLib.AccessTools.FindIncludingInnerTypes(type, action); - public static FieldInfo Field(Type type, string name) => HarmonyLib.AccessTools.Field(type, name); - public static FieldInfo Field(Type type, int idx) => HarmonyLib.AccessTools.DeclaredField(type, idx); - public static PropertyInfo DeclaredProperty(Type type, string name) => HarmonyLib.AccessTools.DeclaredProperty(type, name); - public static PropertyInfo Property(Type type, string name) => HarmonyLib.AccessTools.Property(type, name); - public static MethodInfo DeclaredMethod(Type type, string name, Type[] parameters = null, Type[] generics = null) => HarmonyLib.AccessTools.DeclaredMethod(type, name, parameters, generics); - public static MethodInfo Method(Type type, string name, Type[] parameters = null, Type[] generics = null) => HarmonyLib.AccessTools.Method(type, name, parameters, generics); - public static MethodInfo Method(string typeColonMethodname, Type[] parameters = null, Type[] generics = null) => HarmonyLib.AccessTools.Method(typeColonMethodname, parameters, generics); - public static List GetMethodNames(Type type) => HarmonyLib.AccessTools.GetMethodNames(type); - public static List GetMethodNames(object instance) => HarmonyLib.AccessTools.GetMethodNames(instance); - public static ConstructorInfo DeclaredConstructor(Type type, Type[] parameters = null) => HarmonyLib.AccessTools.DeclaredConstructor(type, parameters); - public static ConstructorInfo Constructor(Type type, Type[] parameters = null) => HarmonyLib.AccessTools.Constructor(type, parameters); - public static List GetDeclaredConstructors(Type type) => HarmonyLib.AccessTools.GetDeclaredConstructors(type); - public static List GetDeclaredMethods(Type type) => HarmonyLib.AccessTools.GetDeclaredMethods(type); - public static List GetDeclaredProperties(Type type) => HarmonyLib.AccessTools.GetDeclaredProperties(type); - public static List GetDeclaredFields(Type type) => HarmonyLib.AccessTools.GetDeclaredFields(type); - public static Type GetReturnedType(MethodBase method) => HarmonyLib.AccessTools.GetReturnedType(method); - public static Type Inner(Type type, string name) => HarmonyLib.AccessTools.Inner(type, name); - public static Type FirstInner(Type type, Func predicate) => HarmonyLib.AccessTools.FirstInner(type, predicate); - public static MethodInfo FirstMethod(Type type, Func predicate) => HarmonyLib.AccessTools.FirstMethod(type, predicate); - public static ConstructorInfo FirstConstructor(Type type, Func predicate) => HarmonyLib.AccessTools.FirstConstructor(type, predicate); - public static PropertyInfo FirstProperty(Type type, Func predicate) => HarmonyLib.AccessTools.FirstProperty(type, predicate); - public static Type[] GetTypes(object[] parameters) => HarmonyLib.AccessTools.GetTypes(parameters); - public static List GetFieldNames(Type type) => HarmonyLib.AccessTools.GetFieldNames(type); - public static List GetFieldNames(object instance) => HarmonyLib.AccessTools.GetFieldNames(instance); - public static List GetPropertyNames(Type type) => HarmonyLib.AccessTools.GetPropertyNames(type); - public static List GetPropertyNames(object instance) => HarmonyLib.AccessTools.GetPropertyNames(instance); - public delegate ref U FieldRef(T obj); - public static FieldRef FieldRefAccess(string fieldName) => ConvertFieldRef(HarmonyLib.AccessTools.FieldRefAccess(fieldName)); - public static ref U FieldRefAccess(T instance, string fieldName) => ref FieldRefAccess(fieldName)(instance); - private static FieldRef ConvertFieldRef(HarmonyLib.AccessTools.FieldRef sourceDelegate) => - (FieldRef)Delegate.CreateDelegate(typeof(FieldRef), sourceDelegate.Target, sourceDelegate.Method); - public static void ThrowMissingMemberException(Type type, params string[] names) => HarmonyLib.AccessTools.ThrowMissingMemberException(type, names); - public static object GetDefaultValue(Type type) => HarmonyLib.AccessTools.GetDefaultValue(type); - public static object CreateInstance(Type type) => HarmonyLib.AccessTools.CreateInstance(type); - public static bool IsStruct(Type type) => HarmonyLib.AccessTools.IsStruct(type); - public static bool IsClass(Type type) => HarmonyLib.AccessTools.IsClass(type); - public static bool IsValue(Type type) => HarmonyLib.AccessTools.IsValue(type); - public static bool IsVoid(Type type) => HarmonyLib.AccessTools.IsVoid(type); - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Harmony/Tools/Extensions.cs b/MelonLoader/BackwardsCompatibility/Harmony/Tools/Extensions.cs deleted file mode 100644 index 08464e4e3..000000000 --- a/MelonLoader/BackwardsCompatibility/Harmony/Tools/Extensions.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; - -namespace Harmony -{ - [Obsolete("Harmony.GeneralExtensions is Only Here for Compatibility Reasons. Please use HarmonyLib.GeneralExtensions instead. This will be removed in a future update.", true)] - public static class GeneralExtensions - { - [Obsolete("Harmony.GeneralExtensions.Join is Only Here for Compatibility Reasons. Please use HarmonyLib.GeneralExtensions.Join instead. This will be removed in a future update.", true)] - public static string Join(this IEnumerable enumeration, Func converter = null, string delimiter = ", ") => HarmonyLib.GeneralExtensions.Join(enumeration, converter, delimiter); - [Obsolete("Harmony.GeneralExtensions.Description is Only Here for Compatibility Reasons. Please use HarmonyLib.GeneralExtensions.Description instead. This will be removed in a future update.", true)] - public static string Description(this Type[] parameters) => HarmonyLib.GeneralExtensions.Description(parameters); - [Obsolete("Harmony.GeneralExtensions.FullDescription is Only Here for Compatibility Reasons. Please use HarmonyLib.GeneralExtensions.FullDescription instead. This will be removed in a future update.", true)] - public static string FullDescription(this MethodBase method) => HarmonyLib.GeneralExtensions.FullDescription(method); - [Obsolete("Harmony.GeneralExtensions.Types is Only Here for Compatibility Reasons. Please use HarmonyLib.GeneralExtensions.Types instead. This will be removed in a future update.", true)] - public static Type[] Types(this ParameterInfo[] pinfo) => HarmonyLib.GeneralExtensions.Types(pinfo); - [Obsolete("Harmony.GeneralExtensions.GetValueSafe is Only Here for Compatibility Reasons. Please use HarmonyLib.GeneralExtensions.GetValueSafe instead. This will be removed in a future update.", true)] - public static T GetValueSafe(this Dictionary dictionary, S key) => HarmonyLib.GeneralExtensions.GetValueSafe(dictionary, key); - [Obsolete("Harmony.GeneralExtensions.GetTypedValue is Only Here for Compatibility Reasons. Please use HarmonyLib.GeneralExtensions.GetTypedValue instead. This will be removed in a future update.", true)] - public static T GetTypedValue(this Dictionary dictionary, string key) => HarmonyLib.GeneralExtensions.GetTypedValue(dictionary, key); - } - - [Obsolete("Harmony.CollectionExtensions is Only Here for Compatibility Reasons. Please use HarmonyLib.CollectionExtensions instead. This will be removed in a future update.", true)] - public static class CollectionExtensions - { - [Obsolete("Harmony.CollectionExtensions.Do is Only Here for Compatibility Reasons. Please use HarmonyLib.CollectionExtensions.Do instead. This will be removed in a future update.", true)] - public static void Do(this IEnumerable sequence, Action action) => HarmonyLib.CollectionExtensions.Do(sequence, action); - [Obsolete("Harmony.CollectionExtensions.DoIf is Only Here for Compatibility Reasons. Please use HarmonyLib.CollectionExtensions.DoIf instead. This will be removed in a future update.", true)] - public static void DoIf(this IEnumerable sequence, Func condition, Action action) => HarmonyLib.CollectionExtensions.DoIf(sequence, condition, action); - [Obsolete("Harmony.CollectionExtensions.Add is Only Here for Compatibility Reasons. Please use HarmonyLib.CollectionExtensions.Add instead. This will be removed in a future update.", true)] - public static IEnumerable Add(this IEnumerable sequence, T item) => HarmonyLib.CollectionExtensions.AddItem(sequence, item); - [Obsolete("Harmony.CollectionExtensions.AddRangeToArray is Only Here for Compatibility Reasons. Please use HarmonyLib.CollectionExtensions.AddRangeToArray instead. This will be removed in a future update.", true)] - public static T[] AddRangeToArray(this T[] sequence, T[] items) => HarmonyLib.CollectionExtensions.AddRangeToArray(sequence, items); - [Obsolete("Harmony.CollectionExtensions.AddToArray is Only Here for Compatibility Reasons. Please use HarmonyLib.CollectionExtensions.AddToArray instead. This will be removed in a future update.", true)] - public static T[] AddToArray(this T[] sequence, T item) => HarmonyLib.CollectionExtensions.AddToArray(sequence, item); - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Harmony/Tools/SymbolExtensions.cs b/MelonLoader/BackwardsCompatibility/Harmony/Tools/SymbolExtensions.cs deleted file mode 100644 index a6c677a7a..000000000 --- a/MelonLoader/BackwardsCompatibility/Harmony/Tools/SymbolExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Linq.Expressions; -using System.Reflection; - -namespace Harmony -{ - [Obsolete("Harmony.SymbolExtensions is Only Here for Compatibility Reasons. Please use HarmonyLib.SymbolExtensions instead. This will be removed in a future update.", true)] - public static class SymbolExtensions - { - [Obsolete("Harmony.SymbolExtensions.GetMethodInfo is Only Here for Compatibility Reasons. Please use HarmonyLib.SymbolExtensions.GetMethodInfo instead. This will be removed in a future update.", true)] - public static MethodInfo GetMethodInfo(Expression expression) => HarmonyLib.SymbolExtensions.GetMethodInfo(expression); - [Obsolete("Harmony.SymbolExtensions.GetMethodInfo is Only Here for Compatibility Reasons. Please use HarmonyLib.SymbolExtensions.GetMethodInfo instead. This will be removed in a future update.", true)] - public static MethodInfo GetMethodInfo(Expression> expression) => GetMethodInfo((LambdaExpression)expression); - [Obsolete("Harmony.SymbolExtensions.GetMethodInfo is Only Here for Compatibility Reasons. Please use HarmonyLib.SymbolExtensions.GetMethodInfo instead. This will be removed in a future update.", true)] - public static MethodInfo GetMethodInfo(Expression> expression) => GetMethodInfo((LambdaExpression)expression); - [Obsolete("Harmony.SymbolExtensions.GetMethodInfo is Only Here for Compatibility Reasons. Please use HarmonyLib.SymbolExtensions.GetMethodInfo instead. This will be removed in a future update.", true)] - public static MethodInfo GetMethodInfo(LambdaExpression expression) => HarmonyLib.SymbolExtensions.GetMethodInfo(expression); - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2.cs deleted file mode 100644 index 210a46249..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.BZip2 -{ - /// - /// An example class to demonstrate compression and decompression of BZip2 streams. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public static class BZip2 - { - /// - /// Decompress the input writing - /// uncompressed data to the output stream - /// - /// The readable stream containing data to decompress. - /// The output stream to receive the decompressed data. - /// Both streams are closed on completion if true. - public static void Decompress(Stream inStream, Stream outStream, bool isStreamOwner) - { - if (inStream == null) - throw new ArgumentNullException(nameof(inStream)); - - if (outStream == null) - throw new ArgumentNullException(nameof(outStream)); - - try - { - using (BZip2InputStream bzipInput = new BZip2InputStream(inStream)) - { - bzipInput.IsStreamOwner = isStreamOwner; - Core.StreamUtils.Copy(bzipInput, outStream, new byte[4096]); - } - } - finally - { - if (isStreamOwner) - { - // inStream is closed by the BZip2InputStream if stream owner - outStream.Dispose(); - } - } - } - - /// - /// Compress the input stream sending - /// result data to output stream - /// - /// The readable stream to compress. - /// The output stream to receive the compressed data. - /// Both streams are closed on completion if true. - /// Block size acts as compression level (1 to 9) with 1 giving - /// the lowest compression and 9 the highest. - public static void Compress(Stream inStream, Stream outStream, bool isStreamOwner, int level) - { - if (inStream == null) - throw new ArgumentNullException(nameof(inStream)); - - if (outStream == null) - throw new ArgumentNullException(nameof(outStream)); - - try - { - using (BZip2OutputStream bzipOutput = new BZip2OutputStream(outStream, level)) - { - bzipOutput.IsStreamOwner = isStreamOwner; - Core.StreamUtils.Copy(inStream, bzipOutput, new byte[4096]); - } - } - finally - { - if (isStreamOwner) - { - // outStream is closed by the BZip2OutputStream if stream owner - inStream.Dispose(); - } - } - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2Constants.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2Constants.cs deleted file mode 100644 index 620f1aa24..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2Constants.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.BZip2 -{ - /// - /// Defines internal values for both compression and decompression - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal static class BZip2Constants - { - /// - /// Random numbers used to randomise repetitive blocks - /// - public readonly static int[] RandomNumbers = { - 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, - 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, - 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, - 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, - 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, - 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, - 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, - 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, - 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, - 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, - 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, - 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, - 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, - 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, - 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, - 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, - 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, - 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, - 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, - 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, - 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, - 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, - 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, - 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, - 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, - 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, - 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, - 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, - 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, - 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, - 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, - 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, - 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, - 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, - 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, - 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, - 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, - 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, - 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, - 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, - 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, - 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, - 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, - 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, - 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, - 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, - 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, - 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, - 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, - 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, - 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, - 936, 638 - }; - - /// - /// When multiplied by compression parameter (1-9) gives the block size for compression - /// 9 gives the best compression but uses the most memory. - /// - public const int BaseBlockSize = 100000; - - /// - /// Backend constant - /// - public const int MaximumAlphaSize = 258; - - /// - /// Backend constant - /// - public const int MaximumCodeLength = 23; - - /// - /// Backend constant - /// - public const int RunA = 0; - - /// - /// Backend constant - /// - public const int RunB = 1; - - /// - /// Backend constant - /// - public const int GroupCount = 6; - - /// - /// Backend constant - /// - public const int GroupSize = 50; - - /// - /// Backend constant - /// - public const int NumberOfIterations = 4; - - /// - /// Backend constant - /// - public const int MaximumSelectors = (2 + (900000 / GroupSize)); - - /// - /// Backend constant - /// - public const int OvershootBytes = 20; - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2Exception.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2Exception.cs deleted file mode 100644 index 756e6e810..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2Exception.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib.BZip2 -{ - /// - /// BZip2Exception represents exceptions specific to BZip2 classes and code. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class BZip2Exception : SharpZipBaseException - { - /// - /// Initialise a new instance of . - /// - public BZip2Exception() - { - } - - /// - /// Initialise a new instance of with its message string. - /// - /// A that describes the error. - public BZip2Exception(string message) - : base(message) - { - } - - /// - /// Initialise a new instance of . - /// - /// A that describes the error. - /// The that caused this exception. - public BZip2Exception(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the BZip2Exception class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected BZip2Exception(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2InputStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2InputStream.cs deleted file mode 100644 index 30a17b2c1..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2InputStream.cs +++ /dev/null @@ -1,1054 +0,0 @@ -#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER - #define VECTORIZE_MEMORY_MOVE -#endif - -using MelonLoader.ICSharpCode.SharpZipLib.Checksum; -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.BZip2 -{ - /// - /// An input stream that decompresses files in the BZip2 format - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class BZip2InputStream : Stream - { - #region Constants - - private const int START_BLOCK_STATE = 1; - private const int RAND_PART_A_STATE = 2; - private const int RAND_PART_B_STATE = 3; - private const int RAND_PART_C_STATE = 4; - private const int NO_RAND_PART_A_STATE = 5; - private const int NO_RAND_PART_B_STATE = 6; - private const int NO_RAND_PART_C_STATE = 7; - -#if VECTORIZE_MEMORY_MOVE - private static readonly int VectorSize = System.Numerics.Vector.Count; -#endif // VECTORIZE_MEMORY_MOVE - -#endregion Constants - - #region Instance Fields - - /*-- - index of the last char in the block, so - the block size == last + 1. - --*/ - private int last; - - /*-- - index in zptr[] of original string after sorting. - --*/ - private int origPtr; - - /*-- - always: in the range 0 .. 9. - The current block size is 100000 * this number. - --*/ - private int blockSize100k; - - private bool blockRandomised; - - private int bsBuff; - private int bsLive; - private IChecksum mCrc = new BZip2Crc(); - - private bool[] inUse = new bool[256]; - private int nInUse; - - private byte[] seqToUnseq = new byte[256]; - private byte[] unseqToSeq = new byte[256]; - - private byte[] selector = new byte[BZip2Constants.MaximumSelectors]; - private byte[] selectorMtf = new byte[BZip2Constants.MaximumSelectors]; - - private int[] tt; - private byte[] ll8; - - /*-- - freq table collected to save a pass over the data - during decompression. - --*/ - private int[] unzftab = new int[256]; - - private int[][] limit = new int[BZip2Constants.GroupCount][]; - private int[][] baseArray = new int[BZip2Constants.GroupCount][]; - private int[][] perm = new int[BZip2Constants.GroupCount][]; - private int[] minLens = new int[BZip2Constants.GroupCount]; - - private readonly Stream baseStream; - private bool streamEnd; - - private int currentChar = -1; - - private int currentState = START_BLOCK_STATE; - - private int storedBlockCRC, storedCombinedCRC; - private int computedBlockCRC; - private uint computedCombinedCRC; - - private int count, chPrev, ch2; - private int tPos; - private int rNToGo; - private int rTPos; - private int i2, j2; - private byte z; - - #endregion Instance Fields - - /// - /// Construct instance for reading from stream - /// - /// Data source - public BZip2InputStream(Stream stream) - { - if (stream == null) - throw new ArgumentNullException(nameof(stream)); - // init arrays - for (int i = 0; i < BZip2Constants.GroupCount; ++i) - { - limit[i] = new int[BZip2Constants.MaximumAlphaSize]; - baseArray[i] = new int[BZip2Constants.MaximumAlphaSize]; - perm[i] = new int[BZip2Constants.MaximumAlphaSize]; - } - - baseStream = stream; - bsLive = 0; - bsBuff = 0; - Initialize(); - InitBlock(); - SetupBlock(); - } - - /// - /// Get/set flag indicating ownership of underlying stream. - /// When the flag is true will close the underlying stream also. - /// - public bool IsStreamOwner { get; set; } = true; - - #region Stream Overrides - - /// - /// Gets a value indicating if the stream supports reading - /// - public override bool CanRead - { - get - { - return baseStream.CanRead; - } - } - - /// - /// Gets a value indicating whether the current stream supports seeking. - /// - public override bool CanSeek - { - get - { - return false; - } - } - - /// - /// Gets a value indicating whether the current stream supports writing. - /// This property always returns false - /// - public override bool CanWrite - { - get - { - return false; - } - } - - /// - /// Gets the length in bytes of the stream. - /// - public override long Length - { - get - { - return baseStream.Length; - } - } - - /// - /// Gets the current position of the stream. - /// Setting the position is not supported and will throw a NotSupportException. - /// - /// Any attempt to set the position. - public override long Position - { - get - { - return baseStream.Position; - } - set - { - throw new NotSupportedException("BZip2InputStream position cannot be set"); - } - } - - /// - /// Flushes the stream. - /// - public override void Flush() - { - baseStream.Flush(); - } - - /// - /// Set the streams position. This operation is not supported and will throw a NotSupportedException - /// - /// A byte offset relative to the parameter. - /// A value of type indicating the reference point used to obtain the new position. - /// The new position of the stream. - /// Any access - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("BZip2InputStream Seek not supported"); - } - - /// - /// Sets the length of this stream to the given value. - /// This operation is not supported and will throw a NotSupportedExceptionortedException - /// - /// The new length for the stream. - /// Any access - public override void SetLength(long value) - { - throw new NotSupportedException("BZip2InputStream SetLength not supported"); - } - - /// - /// Writes a block of bytes to this stream using data from a buffer. - /// This operation is not supported and will throw a NotSupportedException - /// - /// The buffer to source data from. - /// The offset to start obtaining data from. - /// The number of bytes of data to write. - /// Any access - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotSupportedException("BZip2InputStream Write not supported"); - } - - /// - /// Writes a byte to the current position in the file stream. - /// This operation is not supported and will throw a NotSupportedException - /// - /// The value to write. - /// Any access - public override void WriteByte(byte value) - { - throw new NotSupportedException("BZip2InputStream WriteByte not supported"); - } - - /// - /// Read a sequence of bytes and advances the read position by one byte. - /// - /// Array of bytes to store values in - /// Offset in array to begin storing data - /// The maximum number of bytes to read - /// The total number of bytes read into the buffer. This might be less - /// than the number of bytes requested if that number of bytes are not - /// currently available or zero if the end of the stream is reached. - /// - public override int Read(byte[] buffer, int offset, int count) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - for (int i = 0; i < count; ++i) - { - int rb = ReadByte(); - if (rb == -1) - { - return i; - } - buffer[offset + i] = (byte)rb; - } - return count; - } - - /// - /// Closes the stream, releasing any associated resources. - /// - protected override void Dispose(bool disposing) - { - if (disposing && IsStreamOwner) - { - baseStream.Dispose(); - } - } - - /// - /// Read a byte from stream advancing position - /// - /// byte read or -1 on end of stream - public override int ReadByte() - { - if (streamEnd) - { - return -1; // ok - } - - int retChar = currentChar; - switch (currentState) - { - case RAND_PART_B_STATE: - SetupRandPartB(); - break; - - case RAND_PART_C_STATE: - SetupRandPartC(); - break; - - case NO_RAND_PART_B_STATE: - SetupNoRandPartB(); - break; - - case NO_RAND_PART_C_STATE: - SetupNoRandPartC(); - break; - - case START_BLOCK_STATE: - case NO_RAND_PART_A_STATE: - case RAND_PART_A_STATE: - break; - } - return retChar; - } - - #endregion Stream Overrides - - private void MakeMaps() - { - nInUse = 0; - for (int i = 0; i < 256; ++i) - { - if (inUse[i]) - { - seqToUnseq[nInUse] = (byte)i; - unseqToSeq[i] = (byte)nInUse; - nInUse++; - } - } - } - - private void Initialize() - { - char magic1 = BsGetUChar(); - char magic2 = BsGetUChar(); - - char magic3 = BsGetUChar(); - char magic4 = BsGetUChar(); - - if (magic1 != 'B' || magic2 != 'Z' || magic3 != 'h' || magic4 < '1' || magic4 > '9') - { - streamEnd = true; - return; - } - - SetDecompressStructureSizes(magic4 - '0'); - computedCombinedCRC = 0; - } - - private void InitBlock() - { - char magic1 = BsGetUChar(); - char magic2 = BsGetUChar(); - char magic3 = BsGetUChar(); - char magic4 = BsGetUChar(); - char magic5 = BsGetUChar(); - char magic6 = BsGetUChar(); - - if (magic1 == 0x17 && magic2 == 0x72 && magic3 == 0x45 && magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90) - { - Complete(); - return; - } - - if (magic1 != 0x31 || magic2 != 0x41 || magic3 != 0x59 || magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59) - { - BadBlockHeader(); - streamEnd = true; - return; - } - - storedBlockCRC = BsGetInt32(); - - blockRandomised = (BsR(1) == 1); - - GetAndMoveToFrontDecode(); - - mCrc.Reset(); - currentState = START_BLOCK_STATE; - } - - private void EndBlock() - { - computedBlockCRC = (int)mCrc.Value; - - // -- A bad CRC is considered a fatal error. -- - if (storedBlockCRC != computedBlockCRC) - { - CrcError(); - } - - // 1528150659 - computedCombinedCRC = ((computedCombinedCRC << 1) & 0xFFFFFFFF) | (computedCombinedCRC >> 31); - computedCombinedCRC = computedCombinedCRC ^ (uint)computedBlockCRC; - } - - private void Complete() - { - storedCombinedCRC = BsGetInt32(); - if (storedCombinedCRC != (int)computedCombinedCRC) - { - CrcError(); - } - - streamEnd = true; - } - - private void FillBuffer() - { - int thech = 0; - - try - { - thech = baseStream.ReadByte(); - } - catch (Exception) - { - CompressedStreamEOF(); - } - - if (thech == -1) - { - CompressedStreamEOF(); - } - - bsBuff = (bsBuff << 8) | (thech & 0xFF); - bsLive += 8; - } - - private int BsR(int n) - { - while (bsLive < n) - { - FillBuffer(); - } - - int v = (bsBuff >> (bsLive - n)) & ((1 << n) - 1); - bsLive -= n; - return v; - } - - private char BsGetUChar() - { - return (char)BsR(8); - } - - private int BsGetIntVS(int numBits) - { - return BsR(numBits); - } - - private int BsGetInt32() - { - int result = BsR(8); - result = (result << 8) | BsR(8); - result = (result << 8) | BsR(8); - result = (result << 8) | BsR(8); - return result; - } - - private void RecvDecodingTables() - { - char[][] len = new char[BZip2Constants.GroupCount][]; - for (int i = 0; i < BZip2Constants.GroupCount; ++i) - { - len[i] = new char[BZip2Constants.MaximumAlphaSize]; - } - - bool[] inUse16 = new bool[16]; - - //--- Receive the mapping table --- - for (int i = 0; i < 16; i++) - { - inUse16[i] = (BsR(1) == 1); - } - - for (int i = 0; i < 16; i++) - { - if (inUse16[i]) - { - for (int j = 0; j < 16; j++) - { - inUse[i * 16 + j] = (BsR(1) == 1); - } - } - else - { - for (int j = 0; j < 16; j++) - { - inUse[i * 16 + j] = false; - } - } - } - - MakeMaps(); - int alphaSize = nInUse + 2; - - //--- Now the selectors --- - int nGroups = BsR(3); - int nSelectors = BsR(15); - - for (int i = 0; i < nSelectors; i++) - { - int j = 0; - while (BsR(1) == 1) - { - j++; - } - selectorMtf[i] = (byte)j; - } - - //--- Undo the MTF values for the selectors. --- - byte[] pos = new byte[BZip2Constants.GroupCount]; - for (int v = 0; v < nGroups; v++) - { - pos[v] = (byte)v; - } - - for (int i = 0; i < nSelectors; i++) - { - int v = selectorMtf[i]; - byte tmp = pos[v]; - while (v > 0) - { - pos[v] = pos[v - 1]; - v--; - } - pos[0] = tmp; - selector[i] = tmp; - } - - //--- Now the coding tables --- - for (int t = 0; t < nGroups; t++) - { - int curr = BsR(5); - for (int i = 0; i < alphaSize; i++) - { - while (BsR(1) == 1) - { - if (BsR(1) == 0) - { - curr++; - } - else - { - curr--; - } - } - len[t][i] = (char)curr; - } - } - - //--- Create the Huffman decoding tables --- - for (int t = 0; t < nGroups; t++) - { - int minLen = 32; - int maxLen = 0; - for (int i = 0; i < alphaSize; i++) - { - maxLen = Math.Max(maxLen, len[t][i]); - minLen = Math.Min(minLen, len[t][i]); - } - HbCreateDecodeTables(limit[t], baseArray[t], perm[t], len[t], minLen, maxLen, alphaSize); - minLens[t] = minLen; - } - } - - private void GetAndMoveToFrontDecode() - { - byte[] yy = new byte[256]; - int nextSym; - - int limitLast = BZip2Constants.BaseBlockSize * blockSize100k; - origPtr = BsGetIntVS(24); - - RecvDecodingTables(); - int EOB = nInUse + 1; - int groupNo = -1; - int groupPos = 0; - - /*-- - Setting up the unzftab entries here is not strictly - necessary, but it does save having to do it later - in a separate pass, and so saves a block's worth of - cache misses. - --*/ - for (int i = 0; i <= 255; i++) - { - unzftab[i] = 0; - } - - for (int i = 0; i <= 255; i++) - { - yy[i] = (byte)i; - } - - last = -1; - - if (groupPos == 0) - { - groupNo++; - groupPos = BZip2Constants.GroupSize; - } - - groupPos--; - int zt = selector[groupNo]; - int zn = minLens[zt]; - int zvec = BsR(zn); - int zj; - - while (zvec > limit[zt][zn]) - { - if (zn > 20) - { // the longest code - throw new BZip2Exception("Bzip data error"); - } - zn++; - while (bsLive < 1) - { - FillBuffer(); - } - zj = (bsBuff >> (bsLive - 1)) & 1; - bsLive--; - zvec = (zvec << 1) | zj; - } - if (zvec - baseArray[zt][zn] < 0 || zvec - baseArray[zt][zn] >= BZip2Constants.MaximumAlphaSize) - { - throw new BZip2Exception("Bzip data error"); - } - nextSym = perm[zt][zvec - baseArray[zt][zn]]; - - while (true) - { - if (nextSym == EOB) - { - break; - } - - if (nextSym == BZip2Constants.RunA || nextSym == BZip2Constants.RunB) - { - int s = -1; - int n = 1; - do - { - if (nextSym == BZip2Constants.RunA) - { - s += (0 + 1) * n; - } - else if (nextSym == BZip2Constants.RunB) - { - s += (1 + 1) * n; - } - - n <<= 1; - - if (groupPos == 0) - { - groupNo++; - groupPos = BZip2Constants.GroupSize; - } - - groupPos--; - - zt = selector[groupNo]; - zn = minLens[zt]; - zvec = BsR(zn); - - while (zvec > limit[zt][zn]) - { - zn++; - while (bsLive < 1) - { - FillBuffer(); - } - zj = (bsBuff >> (bsLive - 1)) & 1; - bsLive--; - zvec = (zvec << 1) | zj; - } - nextSym = perm[zt][zvec - baseArray[zt][zn]]; - } while (nextSym == BZip2Constants.RunA || nextSym == BZip2Constants.RunB); - - s++; - byte ch = seqToUnseq[yy[0]]; - unzftab[ch] += s; - - while (s > 0) - { - last++; - ll8[last] = ch; - s--; - } - - if (last >= limitLast) - { - BlockOverrun(); - } - continue; - } - else - { - last++; - if (last >= limitLast) - { - BlockOverrun(); - } - - byte tmp = yy[nextSym - 1]; - unzftab[seqToUnseq[tmp]]++; - ll8[last] = seqToUnseq[tmp]; - - var j = nextSym - 1; - -#if VECTORIZE_MEMORY_MOVE - // This is vectorized memory move. Going from the back, we're taking chunks of array - // and write them at the new location shifted by one. Since chunks are VectorSize long, - // at the end we have to move "tail" (or head actually) of the array using a plain loop. - // If System.Numerics.Vector API is not available, the plain loop is used to do the whole copying. - - while(j >= VectorSize) - { - var arrayPart = new System.Numerics.Vector(yy, j - VectorSize); - arrayPart.CopyTo(yy, j - VectorSize + 1); - j -= VectorSize; - } -#endif // VECTORIZE_MEMORY_MOVE - - while(j > 0) - { - yy[j] = yy[--j]; - } - - yy[0] = tmp; - - if (groupPos == 0) - { - groupNo++; - groupPos = BZip2Constants.GroupSize; - } - - groupPos--; - zt = selector[groupNo]; - zn = minLens[zt]; - zvec = BsR(zn); - while (zvec > limit[zt][zn]) - { - zn++; - while (bsLive < 1) - { - FillBuffer(); - } - zj = (bsBuff >> (bsLive - 1)) & 1; - bsLive--; - zvec = (zvec << 1) | zj; - } - nextSym = perm[zt][zvec - baseArray[zt][zn]]; - continue; - } - } - } - - private void SetupBlock() - { - int[] cftab = new int[257]; - - cftab[0] = 0; - Array.Copy(unzftab, 0, cftab, 1, 256); - - for (int i = 1; i <= 256; i++) - { - cftab[i] += cftab[i - 1]; - } - - for (int i = 0; i <= last; i++) - { - byte ch = ll8[i]; - tt[cftab[ch]] = i; - cftab[ch]++; - } - - cftab = null; - - tPos = tt[origPtr]; - - count = 0; - i2 = 0; - ch2 = 256; /*-- not a char and not EOF --*/ - - if (blockRandomised) - { - rNToGo = 0; - rTPos = 0; - SetupRandPartA(); - } - else - { - SetupNoRandPartA(); - } - } - - private void SetupRandPartA() - { - if (i2 <= last) - { - chPrev = ch2; - ch2 = ll8[tPos]; - tPos = tt[tPos]; - if (rNToGo == 0) - { - rNToGo = BZip2Constants.RandomNumbers[rTPos]; - rTPos++; - if (rTPos == 512) - { - rTPos = 0; - } - } - rNToGo--; - ch2 ^= (int)((rNToGo == 1) ? 1 : 0); - i2++; - - currentChar = ch2; - currentState = RAND_PART_B_STATE; - mCrc.Update(ch2); - } - else - { - EndBlock(); - InitBlock(); - SetupBlock(); - } - } - - private void SetupNoRandPartA() - { - if (i2 <= last) - { - chPrev = ch2; - ch2 = ll8[tPos]; - tPos = tt[tPos]; - i2++; - - currentChar = ch2; - currentState = NO_RAND_PART_B_STATE; - mCrc.Update(ch2); - } - else - { - EndBlock(); - InitBlock(); - SetupBlock(); - } - } - - private void SetupRandPartB() - { - if (ch2 != chPrev) - { - currentState = RAND_PART_A_STATE; - count = 1; - SetupRandPartA(); - } - else - { - count++; - if (count >= 4) - { - z = ll8[tPos]; - tPos = tt[tPos]; - if (rNToGo == 0) - { - rNToGo = BZip2Constants.RandomNumbers[rTPos]; - rTPos++; - if (rTPos == 512) - { - rTPos = 0; - } - } - rNToGo--; - z ^= (byte)((rNToGo == 1) ? 1 : 0); - j2 = 0; - currentState = RAND_PART_C_STATE; - SetupRandPartC(); - } - else - { - currentState = RAND_PART_A_STATE; - SetupRandPartA(); - } - } - } - - private void SetupRandPartC() - { - if (j2 < (int)z) - { - currentChar = ch2; - mCrc.Update(ch2); - j2++; - } - else - { - currentState = RAND_PART_A_STATE; - i2++; - count = 0; - SetupRandPartA(); - } - } - - private void SetupNoRandPartB() - { - if (ch2 != chPrev) - { - currentState = NO_RAND_PART_A_STATE; - count = 1; - SetupNoRandPartA(); - } - else - { - count++; - if (count >= 4) - { - z = ll8[tPos]; - tPos = tt[tPos]; - currentState = NO_RAND_PART_C_STATE; - j2 = 0; - SetupNoRandPartC(); - } - else - { - currentState = NO_RAND_PART_A_STATE; - SetupNoRandPartA(); - } - } - } - - private void SetupNoRandPartC() - { - if (j2 < (int)z) - { - currentChar = ch2; - mCrc.Update(ch2); - j2++; - } - else - { - currentState = NO_RAND_PART_A_STATE; - i2++; - count = 0; - SetupNoRandPartA(); - } - } - - private void SetDecompressStructureSizes(int newSize100k) - { - if (!(0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k && blockSize100k <= 9)) - { - throw new BZip2Exception("Invalid block size"); - } - - blockSize100k = newSize100k; - - if (newSize100k == 0) - { - return; - } - - int n = BZip2Constants.BaseBlockSize * newSize100k; - ll8 = new byte[n]; - tt = new int[n]; - } - - private static void CompressedStreamEOF() - { - throw new EndOfStreamException("BZip2 input stream end of compressed stream"); - } - - private static void BlockOverrun() - { - throw new BZip2Exception("BZip2 input stream block overrun"); - } - - private static void BadBlockHeader() - { - throw new BZip2Exception("BZip2 input stream bad block header"); - } - - private static void CrcError() - { - throw new BZip2Exception("BZip2 input stream crc error"); - } - - private static void HbCreateDecodeTables(int[] limit, int[] baseArray, int[] perm, char[] length, int minLen, int maxLen, int alphaSize) - { - int pp = 0; - - for (int i = minLen; i <= maxLen; ++i) - { - for (int j = 0; j < alphaSize; ++j) - { - if (length[j] == i) - { - perm[pp] = j; - ++pp; - } - } - } - - for (int i = 0; i < BZip2Constants.MaximumCodeLength; i++) - { - baseArray[i] = 0; - } - - for (int i = 0; i < alphaSize; i++) - { - ++baseArray[length[i] + 1]; - } - - for (int i = 1; i < BZip2Constants.MaximumCodeLength; i++) - { - baseArray[i] += baseArray[i - 1]; - } - - for (int i = 0; i < BZip2Constants.MaximumCodeLength; i++) - { - limit[i] = 0; - } - - int vec = 0; - - for (int i = minLen; i <= maxLen; i++) - { - vec += (baseArray[i + 1] - baseArray[i]); - limit[i] = vec - 1; - vec <<= 1; - } - - for (int i = minLen + 1; i <= maxLen; i++) - { - baseArray[i] = ((limit[i - 1] + 1) << 1) - baseArray[i]; - } - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2OutputStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2OutputStream.cs deleted file mode 100644 index e71664923..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/BZip2/BZip2OutputStream.cs +++ /dev/null @@ -1,2034 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Checksum; -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.BZip2 -{ - /// - /// An output stream that compresses into the BZip2 format - /// including file header chars into another stream. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class BZip2OutputStream : Stream - { - #region Constants - - private const int SETMASK = (1 << 21); - private const int CLEARMASK = (~SETMASK); - private const int GREATER_ICOST = 15; - private const int LESSER_ICOST = 0; - private const int SMALL_THRESH = 20; - private const int DEPTH_THRESH = 10; - - /*-- - If you are ever unlucky/improbable enough - to get a stack overflow whilst sorting, - increase the following constant and try - again. In practice I have never seen the - stack go above 27 elems, so the following - limit seems very generous. - --*/ - private const int QSORT_STACK_SIZE = 1000; - - /*-- - Knuth's increments seem to work better - than Incerpi-Sedgewick here. Possibly - because the number of elems to sort is - usually small, typically <= 20. - --*/ - - private readonly int[] increments = { - 1, 4, 13, 40, 121, 364, 1093, 3280, - 9841, 29524, 88573, 265720, - 797161, 2391484 - }; - - #endregion Constants - - #region Instance Fields - - /*-- - index of the last char in the block, so - the block size == last + 1. - --*/ - private int last; - - /*-- - index in zptr[] of original string after sorting. - --*/ - private int origPtr; - - /*-- - always: in the range 0 .. 9. - The current block size is 100000 * this number. - --*/ - private int blockSize100k; - - private bool blockRandomised; - - private int bytesOut; - private int bsBuff; - private int bsLive; - private IChecksum mCrc = new BZip2Crc(); - - private bool[] inUse = new bool[256]; - private int nInUse; - - private char[] seqToUnseq = new char[256]; - private char[] unseqToSeq = new char[256]; - - private char[] selector = new char[BZip2Constants.MaximumSelectors]; - private char[] selectorMtf = new char[BZip2Constants.MaximumSelectors]; - - private byte[] block; - private int[] quadrant; - private int[] zptr; - private short[] szptr; - private int[] ftab; - - private int nMTF; - - private int[] mtfFreq = new int[BZip2Constants.MaximumAlphaSize]; - - /* - * Used when sorting. If too many long comparisons - * happen, we stop sorting, randomise the block - * slightly, and try again. - */ - private int workFactor; - private int workDone; - private int workLimit; - private bool firstAttempt; - private int nBlocksRandomised; - - private int currentChar = -1; - private int runLength; - private uint blockCRC, combinedCRC; - private int allowableBlockSize; - private readonly Stream baseStream; - private bool disposed_; - - #endregion Instance Fields - - /// - /// Construct a default output stream with maximum block size - /// - /// The stream to write BZip data onto. - public BZip2OutputStream(Stream stream) : this(stream, 9) - { - } - - /// - /// Initialise a new instance of the - /// for the specified stream, using the given blocksize. - /// - /// The stream to write compressed data to. - /// The block size to use. - /// - /// Valid block sizes are in the range 1..9, with 1 giving - /// the lowest compression and 9 the highest. - /// - public BZip2OutputStream(Stream stream, int blockSize) - { - if (stream == null) - throw new ArgumentNullException(nameof(stream)); - - baseStream = stream; - bsLive = 0; - bsBuff = 0; - bytesOut = 0; - - workFactor = 50; - if (blockSize > 9) - { - blockSize = 9; - } - - if (blockSize < 1) - { - blockSize = 1; - } - blockSize100k = blockSize; - AllocateCompressStructures(); - Initialize(); - InitBlock(); - } - - /// - /// Ensures that resources are freed and other cleanup operations - /// are performed when the garbage collector reclaims the BZip2OutputStream. - /// - ~BZip2OutputStream() - { - Dispose(false); - } - - /// - /// Gets or sets a flag indicating ownership of underlying stream. - /// When the flag is true will close the underlying stream also. - /// - /// The default value is true. - public bool IsStreamOwner { get; set; } = true; - - /// - /// Gets a value indicating whether the current stream supports reading - /// - public override bool CanRead - { - get - { - return false; - } - } - - /// - /// Gets a value indicating whether the current stream supports seeking - /// - public override bool CanSeek - { - get - { - return false; - } - } - - /// - /// Gets a value indicating whether the current stream supports writing - /// - public override bool CanWrite - { - get - { - return baseStream.CanWrite; - } - } - - /// - /// Gets the length in bytes of the stream - /// - public override long Length - { - get - { - return baseStream.Length; - } - } - - /// - /// Gets or sets the current position of this stream. - /// - public override long Position - { - get - { - return baseStream.Position; - } - set - { - throw new NotSupportedException("BZip2OutputStream position cannot be set"); - } - } - - /// - /// Sets the current position of this stream to the given value. - /// - /// The point relative to the offset from which to being seeking. - /// The reference point from which to begin seeking. - /// The new position in the stream. - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("BZip2OutputStream Seek not supported"); - } - - /// - /// Sets the length of this stream to the given value. - /// - /// The new stream length. - public override void SetLength(long value) - { - throw new NotSupportedException("BZip2OutputStream SetLength not supported"); - } - - /// - /// Read a byte from the stream advancing the position. - /// - /// The byte read cast to an int; -1 if end of stream. - public override int ReadByte() - { - throw new NotSupportedException("BZip2OutputStream ReadByte not supported"); - } - - /// - /// Read a block of bytes - /// - /// The buffer to read into. - /// The offset in the buffer to start storing data at. - /// The maximum number of bytes to read. - /// The total number of bytes read. This might be less than the number of bytes - /// requested if that number of bytes are not currently available, or zero - /// if the end of the stream is reached. - public override int Read(byte[] buffer, int offset, int count) - { - throw new NotSupportedException("BZip2OutputStream Read not supported"); - } - - /// - /// Write a block of bytes to the stream - /// - /// The buffer containing data to write. - /// The offset of the first byte to write. - /// The number of bytes to write. - public override void Write(byte[] buffer, int offset, int count) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (offset < 0) - { - throw new ArgumentOutOfRangeException(nameof(offset)); - } - - if (count < 0) - { - throw new ArgumentOutOfRangeException(nameof(count)); - } - - if (buffer.Length - offset < count) - { - throw new ArgumentException("Offset/count out of range"); - } - - for (int i = 0; i < count; ++i) - { - WriteByte(buffer[offset + i]); - } - } - - /// - /// Write a byte to the stream. - /// - /// The byte to write to the stream. - public override void WriteByte(byte value) - { - int b = (256 + value) % 256; - if (currentChar != -1) - { - if (currentChar == b) - { - runLength++; - if (runLength > 254) - { - WriteRun(); - currentChar = -1; - runLength = 0; - } - } - else - { - WriteRun(); - runLength = 1; - currentChar = b; - } - } - else - { - currentChar = b; - runLength++; - } - } - - private void MakeMaps() - { - nInUse = 0; - for (int i = 0; i < 256; i++) - { - if (inUse[i]) - { - seqToUnseq[nInUse] = (char)i; - unseqToSeq[i] = (char)nInUse; - nInUse++; - } - } - } - - /// - /// Get the number of bytes written to output. - /// - private void WriteRun() - { - if (last < allowableBlockSize) - { - inUse[currentChar] = true; - for (int i = 0; i < runLength; i++) - { - mCrc.Update(currentChar); - } - - switch (runLength) - { - case 1: - last++; - block[last + 1] = (byte)currentChar; - break; - - case 2: - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - break; - - case 3: - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - break; - - default: - inUse[runLength - 4] = true; - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)currentChar; - last++; - block[last + 1] = (byte)(runLength - 4); - break; - } - } - else - { - EndBlock(); - InitBlock(); - WriteRun(); - } - } - - /// - /// Get the number of bytes written to the output. - /// - public int BytesWritten - { - get { return bytesOut; } - } - - /// - /// Releases the unmanaged resources used by the and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - override protected void Dispose(bool disposing) - { - try - { - try - { - base.Dispose(disposing); - if (!disposed_) - { - disposed_ = true; - - if (runLength > 0) - { - WriteRun(); - } - - currentChar = -1; - EndBlock(); - EndCompression(); - Flush(); - } - } - finally - { - if (disposing) - { - if (IsStreamOwner) - { - baseStream.Dispose(); - } - } - } - } - catch - { - } - } - - /// - /// Flush output buffers - /// - public override void Flush() - { - baseStream.Flush(); - } - - private void Initialize() - { - bytesOut = 0; - nBlocksRandomised = 0; - - /*--- Write header `magic' bytes indicating file-format == huffmanised, - followed by a digit indicating blockSize100k. - ---*/ - - BsPutUChar('B'); - BsPutUChar('Z'); - - BsPutUChar('h'); - BsPutUChar('0' + blockSize100k); - - combinedCRC = 0; - } - - private void InitBlock() - { - mCrc.Reset(); - last = -1; - - for (int i = 0; i < 256; i++) - { - inUse[i] = false; - } - - /*--- 20 is just a paranoia constant ---*/ - allowableBlockSize = BZip2Constants.BaseBlockSize * blockSize100k - 20; - } - - private void EndBlock() - { - if (last < 0) - { // dont do anything for empty files, (makes empty files compatible with original Bzip) - return; - } - - blockCRC = unchecked((uint)mCrc.Value); - combinedCRC = (combinedCRC << 1) | (combinedCRC >> 31); - combinedCRC ^= blockCRC; - - /*-- sort the block and establish position of original string --*/ - DoReversibleTransformation(); - - /*-- - A 6-byte block header, the value chosen arbitrarily - as 0x314159265359 :-). A 32 bit value does not really - give a strong enough guarantee that the value will not - appear by chance in the compressed datastream. Worst-case - probability of this event, for a 900k block, is about - 2.0e-3 for 32 bits, 1.0e-5 for 40 bits and 4.0e-8 for 48 bits. - For a compressed file of size 100Gb -- about 100000 blocks -- - only a 48-bit marker will do. NB: normal compression/ - decompression do *not* rely on these statistical properties. - They are only important when trying to recover blocks from - damaged files. - --*/ - BsPutUChar(0x31); - BsPutUChar(0x41); - BsPutUChar(0x59); - BsPutUChar(0x26); - BsPutUChar(0x53); - BsPutUChar(0x59); - - /*-- Now the block's CRC, so it is in a known place. --*/ - unchecked - { - BsPutint((int)blockCRC); - } - - /*-- Now a single bit indicating randomisation. --*/ - if (blockRandomised) - { - BsW(1, 1); - nBlocksRandomised++; - } - else - { - BsW(1, 0); - } - - /*-- Finally, block's contents proper. --*/ - MoveToFrontCodeAndSend(); - } - - private void EndCompression() - { - /*-- - Now another magic 48-bit number, 0x177245385090, to - indicate the end of the last block. (sqrt(pi), if - you want to know. I did want to use e, but it contains - too much repetition -- 27 18 28 18 28 46 -- for me - to feel statistically comfortable. Call me paranoid.) - --*/ - BsPutUChar(0x17); - BsPutUChar(0x72); - BsPutUChar(0x45); - BsPutUChar(0x38); - BsPutUChar(0x50); - BsPutUChar(0x90); - - unchecked - { - BsPutint((int)combinedCRC); - } - - BsFinishedWithStream(); - } - - private void BsFinishedWithStream() - { - while (bsLive > 0) - { - int ch = (bsBuff >> 24); - baseStream.WriteByte((byte)ch); // write 8-bit - bsBuff <<= 8; - bsLive -= 8; - bytesOut++; - } - } - - private void BsW(int n, int v) - { - while (bsLive >= 8) - { - int ch = (bsBuff >> 24); - unchecked { baseStream.WriteByte((byte)ch); } // write 8-bit - bsBuff <<= 8; - bsLive -= 8; - ++bytesOut; - } - bsBuff |= (v << (32 - bsLive - n)); - bsLive += n; - } - - private void BsPutUChar(int c) - { - BsW(8, c); - } - - private void BsPutint(int u) - { - BsW(8, (u >> 24) & 0xFF); - BsW(8, (u >> 16) & 0xFF); - BsW(8, (u >> 8) & 0xFF); - BsW(8, u & 0xFF); - } - - private void BsPutIntVS(int numBits, int c) - { - BsW(numBits, c); - } - - private void SendMTFValues() - { - char[][] len = new char[BZip2Constants.GroupCount][]; - for (int i = 0; i < BZip2Constants.GroupCount; ++i) - { - len[i] = new char[BZip2Constants.MaximumAlphaSize]; - } - - int gs, ge, totc, bt, bc, iter; - int nSelectors = 0, alphaSize, minLen, maxLen, selCtr; - int nGroups; - - alphaSize = nInUse + 2; - for (int t = 0; t < BZip2Constants.GroupCount; t++) - { - for (int v = 0; v < alphaSize; v++) - { - len[t][v] = (char)GREATER_ICOST; - } - } - - /*--- Decide how many coding tables to use ---*/ - if (nMTF <= 0) - { - Panic(); - } - - if (nMTF < 200) - { - nGroups = 2; - } - else if (nMTF < 600) - { - nGroups = 3; - } - else if (nMTF < 1200) - { - nGroups = 4; - } - else if (nMTF < 2400) - { - nGroups = 5; - } - else - { - nGroups = 6; - } - - /*--- Generate an initial set of coding tables ---*/ - int nPart = nGroups; - int remF = nMTF; - gs = 0; - while (nPart > 0) - { - int tFreq = remF / nPart; - int aFreq = 0; - ge = gs - 1; - while (aFreq < tFreq && ge < alphaSize - 1) - { - ge++; - aFreq += mtfFreq[ge]; - } - - if (ge > gs && nPart != nGroups && nPart != 1 && ((nGroups - nPart) % 2 == 1)) - { - aFreq -= mtfFreq[ge]; - ge--; - } - - for (int v = 0; v < alphaSize; v++) - { - if (v >= gs && v <= ge) - { - len[nPart - 1][v] = (char)LESSER_ICOST; - } - else - { - len[nPart - 1][v] = (char)GREATER_ICOST; - } - } - - nPart--; - gs = ge + 1; - remF -= aFreq; - } - - int[][] rfreq = new int[BZip2Constants.GroupCount][]; - for (int i = 0; i < BZip2Constants.GroupCount; ++i) - { - rfreq[i] = new int[BZip2Constants.MaximumAlphaSize]; - } - - int[] fave = new int[BZip2Constants.GroupCount]; - short[] cost = new short[BZip2Constants.GroupCount]; - /*--- - Iterate up to N_ITERS times to improve the tables. - ---*/ - for (iter = 0; iter < BZip2Constants.NumberOfIterations; ++iter) - { - for (int t = 0; t < nGroups; ++t) - { - fave[t] = 0; - } - - for (int t = 0; t < nGroups; ++t) - { - for (int v = 0; v < alphaSize; ++v) - { - rfreq[t][v] = 0; - } - } - - nSelectors = 0; - totc = 0; - gs = 0; - while (true) - { - /*--- Set group start & end marks. --*/ - if (gs >= nMTF) - { - break; - } - ge = gs + BZip2Constants.GroupSize - 1; - if (ge >= nMTF) - { - ge = nMTF - 1; - } - - /*-- - Calculate the cost of this group as coded - by each of the coding tables. - --*/ - for (int t = 0; t < nGroups; t++) - { - cost[t] = 0; - } - - if (nGroups == 6) - { - short cost0, cost1, cost2, cost3, cost4, cost5; - cost0 = cost1 = cost2 = cost3 = cost4 = cost5 = 0; - for (int i = gs; i <= ge; ++i) - { - short icv = szptr[i]; - cost0 += (short)len[0][icv]; - cost1 += (short)len[1][icv]; - cost2 += (short)len[2][icv]; - cost3 += (short)len[3][icv]; - cost4 += (short)len[4][icv]; - cost5 += (short)len[5][icv]; - } - cost[0] = cost0; - cost[1] = cost1; - cost[2] = cost2; - cost[3] = cost3; - cost[4] = cost4; - cost[5] = cost5; - } - else - { - for (int i = gs; i <= ge; ++i) - { - short icv = szptr[i]; - for (int t = 0; t < nGroups; t++) - { - cost[t] += (short)len[t][icv]; - } - } - } - - /*-- - Find the coding table which is best for this group, - and record its identity in the selector table. - --*/ - bc = 999999999; - bt = -1; - for (int t = 0; t < nGroups; ++t) - { - if (cost[t] < bc) - { - bc = cost[t]; - bt = t; - } - } - totc += bc; - fave[bt]++; - selector[nSelectors] = (char)bt; - nSelectors++; - - /*-- - Increment the symbol frequencies for the selected table. - --*/ - for (int i = gs; i <= ge; ++i) - { - ++rfreq[bt][szptr[i]]; - } - - gs = ge + 1; - } - - /*-- - Recompute the tables based on the accumulated frequencies. - --*/ - for (int t = 0; t < nGroups; ++t) - { - HbMakeCodeLengths(len[t], rfreq[t], alphaSize, 20); - } - } - - rfreq = null; - fave = null; - cost = null; - - if (!(nGroups < 8)) - { - Panic(); - } - - if (!(nSelectors < 32768 && nSelectors <= (2 + (900000 / BZip2Constants.GroupSize)))) - { - Panic(); - } - - /*--- Compute MTF values for the selectors. ---*/ - char[] pos = new char[BZip2Constants.GroupCount]; - char ll_i, tmp2, tmp; - - for (int i = 0; i < nGroups; i++) - { - pos[i] = (char)i; - } - - for (int i = 0; i < nSelectors; i++) - { - ll_i = selector[i]; - int j = 0; - tmp = pos[j]; - while (ll_i != tmp) - { - j++; - tmp2 = tmp; - tmp = pos[j]; - pos[j] = tmp2; - } - pos[0] = tmp; - selectorMtf[i] = (char)j; - } - - int[][] code = new int[BZip2Constants.GroupCount][]; - - for (int i = 0; i < BZip2Constants.GroupCount; ++i) - { - code[i] = new int[BZip2Constants.MaximumAlphaSize]; - } - - /*--- Assign actual codes for the tables. --*/ - for (int t = 0; t < nGroups; t++) - { - minLen = 32; - maxLen = 0; - for (int i = 0; i < alphaSize; i++) - { - if (len[t][i] > maxLen) - { - maxLen = len[t][i]; - } - if (len[t][i] < minLen) - { - minLen = len[t][i]; - } - } - if (maxLen > 20) - { - Panic(); - } - if (minLen < 1) - { - Panic(); - } - HbAssignCodes(code[t], len[t], minLen, maxLen, alphaSize); - } - - /*--- Transmit the mapping table. ---*/ - bool[] inUse16 = new bool[16]; - for (int i = 0; i < 16; ++i) - { - inUse16[i] = false; - for (int j = 0; j < 16; ++j) - { - if (inUse[i * 16 + j]) - { - inUse16[i] = true; - } - } - } - - for (int i = 0; i < 16; ++i) - { - if (inUse16[i]) - { - BsW(1, 1); - } - else - { - BsW(1, 0); - } - } - - for (int i = 0; i < 16; ++i) - { - if (inUse16[i]) - { - for (int j = 0; j < 16; ++j) - { - if (inUse[i * 16 + j]) - { - BsW(1, 1); - } - else - { - BsW(1, 0); - } - } - } - } - - /*--- Now the selectors. ---*/ - BsW(3, nGroups); - BsW(15, nSelectors); - for (int i = 0; i < nSelectors; ++i) - { - for (int j = 0; j < selectorMtf[i]; ++j) - { - BsW(1, 1); - } - BsW(1, 0); - } - - /*--- Now the coding tables. ---*/ - for (int t = 0; t < nGroups; ++t) - { - int curr = len[t][0]; - BsW(5, curr); - for (int i = 0; i < alphaSize; ++i) - { - while (curr < len[t][i]) - { - BsW(2, 2); - curr++; /* 10 */ - } - while (curr > len[t][i]) - { - BsW(2, 3); - curr--; /* 11 */ - } - BsW(1, 0); - } - } - - /*--- And finally, the block data proper ---*/ - selCtr = 0; - gs = 0; - while (true) - { - if (gs >= nMTF) - { - break; - } - ge = gs + BZip2Constants.GroupSize - 1; - if (ge >= nMTF) - { - ge = nMTF - 1; - } - - for (int i = gs; i <= ge; i++) - { - BsW(len[selector[selCtr]][szptr[i]], code[selector[selCtr]][szptr[i]]); - } - - gs = ge + 1; - ++selCtr; - } - if (!(selCtr == nSelectors)) - { - Panic(); - } - } - - private void MoveToFrontCodeAndSend() - { - BsPutIntVS(24, origPtr); - GenerateMTFValues(); - SendMTFValues(); - } - - private void SimpleSort(int lo, int hi, int d) - { - int i, j, h, bigN, hp; - int v; - - bigN = hi - lo + 1; - if (bigN < 2) - { - return; - } - - hp = 0; - while (increments[hp] < bigN) - { - hp++; - } - hp--; - - for (; hp >= 0; hp--) - { - h = increments[hp]; - - i = lo + h; - while (true) - { - /*-- copy 1 --*/ - if (i > hi) - break; - v = zptr[i]; - j = i; - while (FullGtU(zptr[j - h] + d, v + d)) - { - zptr[j] = zptr[j - h]; - j = j - h; - if (j <= (lo + h - 1)) - break; - } - zptr[j] = v; - i++; - - /*-- copy 2 --*/ - if (i > hi) - { - break; - } - v = zptr[i]; - j = i; - while (FullGtU(zptr[j - h] + d, v + d)) - { - zptr[j] = zptr[j - h]; - j = j - h; - if (j <= (lo + h - 1)) - { - break; - } - } - zptr[j] = v; - i++; - - /*-- copy 3 --*/ - if (i > hi) - { - break; - } - v = zptr[i]; - j = i; - while (FullGtU(zptr[j - h] + d, v + d)) - { - zptr[j] = zptr[j - h]; - j = j - h; - if (j <= (lo + h - 1)) - { - break; - } - } - zptr[j] = v; - i++; - - if (workDone > workLimit && firstAttempt) - { - return; - } - } - } - } - - private void Vswap(int p1, int p2, int n) - { - int temp = 0; - while (n > 0) - { - temp = zptr[p1]; - zptr[p1] = zptr[p2]; - zptr[p2] = temp; - p1++; - p2++; - n--; - } - } - - private void QSort3(int loSt, int hiSt, int dSt) - { - int unLo, unHi, ltLo, gtHi, med, n, m; - int lo, hi, d; - - StackElement[] stack = new StackElement[QSORT_STACK_SIZE]; - - int sp = 0; - - stack[sp].ll = loSt; - stack[sp].hh = hiSt; - stack[sp].dd = dSt; - sp++; - - while (sp > 0) - { - if (sp >= QSORT_STACK_SIZE) - { - Panic(); - } - - sp--; - lo = stack[sp].ll; - hi = stack[sp].hh; - d = stack[sp].dd; - - if (hi - lo < SMALL_THRESH || d > DEPTH_THRESH) - { - SimpleSort(lo, hi, d); - if (workDone > workLimit && firstAttempt) - { - return; - } - continue; - } - - med = Med3(block[zptr[lo] + d + 1], - block[zptr[hi] + d + 1], - block[zptr[(lo + hi) >> 1] + d + 1]); - - unLo = ltLo = lo; - unHi = gtHi = hi; - - while (true) - { - while (true) - { - if (unLo > unHi) - { - break; - } - n = ((int)block[zptr[unLo] + d + 1]) - med; - if (n == 0) - { - int temp = zptr[unLo]; - zptr[unLo] = zptr[ltLo]; - zptr[ltLo] = temp; - ltLo++; - unLo++; - continue; - } - if (n > 0) - { - break; - } - unLo++; - } - - while (true) - { - if (unLo > unHi) - { - break; - } - n = ((int)block[zptr[unHi] + d + 1]) - med; - if (n == 0) - { - int temp = zptr[unHi]; - zptr[unHi] = zptr[gtHi]; - zptr[gtHi] = temp; - gtHi--; - unHi--; - continue; - } - if (n < 0) - { - break; - } - unHi--; - } - - if (unLo > unHi) - { - break; - } - - { - int temp = zptr[unLo]; - zptr[unLo] = zptr[unHi]; - zptr[unHi] = temp; - unLo++; - unHi--; - } - } - - if (gtHi < ltLo) - { - stack[sp].ll = lo; - stack[sp].hh = hi; - stack[sp].dd = d + 1; - sp++; - continue; - } - - n = ((ltLo - lo) < (unLo - ltLo)) ? (ltLo - lo) : (unLo - ltLo); - Vswap(lo, unLo - n, n); - m = ((hi - gtHi) < (gtHi - unHi)) ? (hi - gtHi) : (gtHi - unHi); - Vswap(unLo, hi - m + 1, m); - - n = lo + unLo - ltLo - 1; - m = hi - (gtHi - unHi) + 1; - - stack[sp].ll = lo; - stack[sp].hh = n; - stack[sp].dd = d; - sp++; - - stack[sp].ll = n + 1; - stack[sp].hh = m - 1; - stack[sp].dd = d + 1; - sp++; - - stack[sp].ll = m; - stack[sp].hh = hi; - stack[sp].dd = d; - sp++; - } - } - - private void MainSort() - { - int i, j, ss, sb; - int[] runningOrder = new int[256]; - int[] copy = new int[256]; - bool[] bigDone = new bool[256]; - int c1, c2; - int numQSorted; - - /*-- - In the various block-sized structures, live data runs - from 0 to last+NUM_OVERSHOOT_BYTES inclusive. First, - set up the overshoot area for block. - --*/ - - // if (verbosity >= 4) fprintf ( stderr, " sort initialise ...\n" ); - for (i = 0; i < BZip2Constants.OvershootBytes; i++) - { - block[last + i + 2] = block[(i % (last + 1)) + 1]; - } - for (i = 0; i <= last + BZip2Constants.OvershootBytes; i++) - { - quadrant[i] = 0; - } - - block[0] = (byte)(block[last + 1]); - - if (last < 4000) - { - /*-- - Use simpleSort(), since the full sorting mechanism - has quite a large constant overhead. - --*/ - for (i = 0; i <= last; i++) - { - zptr[i] = i; - } - firstAttempt = false; - workDone = workLimit = 0; - SimpleSort(0, last, 0); - } - else - { - numQSorted = 0; - for (i = 0; i <= 255; i++) - { - bigDone[i] = false; - } - for (i = 0; i <= 65536; i++) - { - ftab[i] = 0; - } - - c1 = block[0]; - for (i = 0; i <= last; i++) - { - c2 = block[i + 1]; - ftab[(c1 << 8) + c2]++; - c1 = c2; - } - - for (i = 1; i <= 65536; i++) - { - ftab[i] += ftab[i - 1]; - } - - c1 = block[1]; - for (i = 0; i < last; i++) - { - c2 = block[i + 2]; - j = (c1 << 8) + c2; - c1 = c2; - ftab[j]--; - zptr[ftab[j]] = i; - } - - j = ((block[last + 1]) << 8) + (block[1]); - ftab[j]--; - zptr[ftab[j]] = last; - - /*-- - Now ftab contains the first loc of every small bucket. - Calculate the running order, from smallest to largest - big bucket. - --*/ - - for (i = 0; i <= 255; i++) - { - runningOrder[i] = i; - } - - int vv; - int h = 1; - do - { - h = 3 * h + 1; - } while (h <= 256); - do - { - h = h / 3; - for (i = h; i <= 255; i++) - { - vv = runningOrder[i]; - j = i; - while ((ftab[((runningOrder[j - h]) + 1) << 8] - ftab[(runningOrder[j - h]) << 8]) > (ftab[((vv) + 1) << 8] - ftab[(vv) << 8])) - { - runningOrder[j] = runningOrder[j - h]; - j = j - h; - if (j <= (h - 1)) - { - break; - } - } - runningOrder[j] = vv; - } - } while (h != 1); - - /*-- - The main sorting loop. - --*/ - for (i = 0; i <= 255; i++) - { - /*-- - Process big buckets, starting with the least full. - --*/ - ss = runningOrder[i]; - - /*-- - Complete the big bucket [ss] by quicksorting - any unsorted small buckets [ss, j]. Hopefully - previous pointer-scanning phases have already - completed many of the small buckets [ss, j], so - we don't have to sort them at all. - --*/ - for (j = 0; j <= 255; j++) - { - sb = (ss << 8) + j; - if (!((ftab[sb] & SETMASK) == SETMASK)) - { - int lo = ftab[sb] & CLEARMASK; - int hi = (ftab[sb + 1] & CLEARMASK) - 1; - if (hi > lo) - { - QSort3(lo, hi, 2); - numQSorted += (hi - lo + 1); - if (workDone > workLimit && firstAttempt) - { - return; - } - } - ftab[sb] |= SETMASK; - } - } - - /*-- - The ss big bucket is now done. Record this fact, - and update the quadrant descriptors. Remember to - update quadrants in the overshoot area too, if - necessary. The "if (i < 255)" test merely skips - this updating for the last bucket processed, since - updating for the last bucket is pointless. - --*/ - bigDone[ss] = true; - - if (i < 255) - { - int bbStart = ftab[ss << 8] & CLEARMASK; - int bbSize = (ftab[(ss + 1) << 8] & CLEARMASK) - bbStart; - int shifts = 0; - - while ((bbSize >> shifts) > 65534) - { - shifts++; - } - - for (j = 0; j < bbSize; j++) - { - int a2update = zptr[bbStart + j]; - int qVal = (j >> shifts); - quadrant[a2update] = qVal; - if (a2update < BZip2Constants.OvershootBytes) - { - quadrant[a2update + last + 1] = qVal; - } - } - - if (!(((bbSize - 1) >> shifts) <= 65535)) - { - Panic(); - } - } - - /*-- - Now scan this big bucket so as to synthesise the - sorted order for small buckets [t, ss] for all t != ss. - --*/ - for (j = 0; j <= 255; j++) - { - copy[j] = ftab[(j << 8) + ss] & CLEARMASK; - } - - for (j = ftab[ss << 8] & CLEARMASK; j < (ftab[(ss + 1) << 8] & CLEARMASK); j++) - { - c1 = block[zptr[j]]; - if (!bigDone[c1]) - { - zptr[copy[c1]] = zptr[j] == 0 ? last : zptr[j] - 1; - copy[c1]++; - } - } - - for (j = 0; j <= 255; j++) - { - ftab[(j << 8) + ss] |= SETMASK; - } - } - } - } - - private void RandomiseBlock() - { - int i; - int rNToGo = 0; - int rTPos = 0; - for (i = 0; i < 256; i++) - { - inUse[i] = false; - } - - for (i = 0; i <= last; i++) - { - if (rNToGo == 0) - { - rNToGo = (int)BZip2Constants.RandomNumbers[rTPos]; - rTPos++; - if (rTPos == 512) - { - rTPos = 0; - } - } - rNToGo--; - block[i + 1] ^= (byte)((rNToGo == 1) ? 1 : 0); - // handle 16 bit signed numbers - block[i + 1] &= 0xFF; - - inUse[block[i + 1]] = true; - } - } - - private void DoReversibleTransformation() - { - workLimit = workFactor * last; - workDone = 0; - blockRandomised = false; - firstAttempt = true; - - MainSort(); - - if (workDone > workLimit && firstAttempt) - { - RandomiseBlock(); - workLimit = workDone = 0; - blockRandomised = true; - firstAttempt = false; - MainSort(); - } - - origPtr = -1; - for (int i = 0; i <= last; i++) - { - if (zptr[i] == 0) - { - origPtr = i; - break; - } - } - - if (origPtr == -1) - { - Panic(); - } - } - - private bool FullGtU(int i1, int i2) - { - int k; - byte c1, c2; - int s1, s2; - - c1 = block[i1 + 1]; - c2 = block[i2 + 1]; - if (c1 != c2) - { - return c1 > c2; - } - i1++; - i2++; - - c1 = block[i1 + 1]; - c2 = block[i2 + 1]; - if (c1 != c2) - { - return c1 > c2; - } - i1++; - i2++; - - c1 = block[i1 + 1]; - c2 = block[i2 + 1]; - if (c1 != c2) - { - return c1 > c2; - } - i1++; - i2++; - - c1 = block[i1 + 1]; - c2 = block[i2 + 1]; - if (c1 != c2) - { - return c1 > c2; - } - i1++; - i2++; - - c1 = block[i1 + 1]; - c2 = block[i2 + 1]; - if (c1 != c2) - { - return c1 > c2; - } - i1++; - i2++; - - c1 = block[i1 + 1]; - c2 = block[i2 + 1]; - if (c1 != c2) - { - return c1 > c2; - } - i1++; - i2++; - - k = last + 1; - - do - { - c1 = block[i1 + 1]; - c2 = block[i2 + 1]; - if (c1 != c2) - { - return c1 > c2; - } - s1 = quadrant[i1]; - s2 = quadrant[i2]; - if (s1 != s2) - { - return s1 > s2; - } - i1++; - i2++; - - c1 = block[i1 + 1]; - c2 = block[i2 + 1]; - if (c1 != c2) - { - return c1 > c2; - } - s1 = quadrant[i1]; - s2 = quadrant[i2]; - if (s1 != s2) - { - return s1 > s2; - } - i1++; - i2++; - - c1 = block[i1 + 1]; - c2 = block[i2 + 1]; - if (c1 != c2) - { - return c1 > c2; - } - s1 = quadrant[i1]; - s2 = quadrant[i2]; - if (s1 != s2) - { - return s1 > s2; - } - i1++; - i2++; - - c1 = block[i1 + 1]; - c2 = block[i2 + 1]; - if (c1 != c2) - { - return c1 > c2; - } - s1 = quadrant[i1]; - s2 = quadrant[i2]; - if (s1 != s2) - { - return s1 > s2; - } - i1++; - i2++; - - if (i1 > last) - { - i1 -= last; - i1--; - } - if (i2 > last) - { - i2 -= last; - i2--; - } - - k -= 4; - ++workDone; - } while (k >= 0); - - return false; - } - - private void AllocateCompressStructures() - { - int n = BZip2Constants.BaseBlockSize * blockSize100k; - block = new byte[(n + 1 + BZip2Constants.OvershootBytes)]; - quadrant = new int[(n + BZip2Constants.OvershootBytes)]; - zptr = new int[n]; - ftab = new int[65537]; - - if (block == null || quadrant == null || zptr == null || ftab == null) - { - // int totalDraw = (n + 1 + NUM_OVERSHOOT_BYTES) + (n + NUM_OVERSHOOT_BYTES) + n + 65537; - // compressOutOfMemory ( totalDraw, n ); - } - - /* - The back end needs a place to store the MTF values - whilst it calculates the coding tables. We could - put them in the zptr array. However, these values - will fit in a short, so we overlay szptr at the - start of zptr, in the hope of reducing the number - of cache misses induced by the multiple traversals - of the MTF values when calculating coding tables. - Seems to improve compression speed by about 1%. - */ - // szptr = zptr; - - szptr = new short[2 * n]; - } - - private void GenerateMTFValues() - { - char[] yy = new char[256]; - int i, j; - char tmp; - char tmp2; - int zPend; - int wr; - int EOB; - - MakeMaps(); - EOB = nInUse + 1; - - for (i = 0; i <= EOB; i++) - { - mtfFreq[i] = 0; - } - - wr = 0; - zPend = 0; - for (i = 0; i < nInUse; i++) - { - yy[i] = (char)i; - } - - for (i = 0; i <= last; i++) - { - char ll_i; - - ll_i = unseqToSeq[block[zptr[i]]]; - - j = 0; - tmp = yy[j]; - while (ll_i != tmp) - { - j++; - tmp2 = tmp; - tmp = yy[j]; - yy[j] = tmp2; - } - yy[0] = tmp; - - if (j == 0) - { - zPend++; - } - else - { - if (zPend > 0) - { - zPend--; - while (true) - { - switch (zPend % 2) - { - case 0: - szptr[wr] = (short)BZip2Constants.RunA; - wr++; - mtfFreq[BZip2Constants.RunA]++; - break; - - case 1: - szptr[wr] = (short)BZip2Constants.RunB; - wr++; - mtfFreq[BZip2Constants.RunB]++; - break; - } - if (zPend < 2) - { - break; - } - zPend = (zPend - 2) / 2; - } - zPend = 0; - } - szptr[wr] = (short)(j + 1); - wr++; - mtfFreq[j + 1]++; - } - } - - if (zPend > 0) - { - zPend--; - while (true) - { - switch (zPend % 2) - { - case 0: - szptr[wr] = (short)BZip2Constants.RunA; - wr++; - mtfFreq[BZip2Constants.RunA]++; - break; - - case 1: - szptr[wr] = (short)BZip2Constants.RunB; - wr++; - mtfFreq[BZip2Constants.RunB]++; - break; - } - if (zPend < 2) - { - break; - } - zPend = (zPend - 2) / 2; - } - } - - szptr[wr] = (short)EOB; - wr++; - mtfFreq[EOB]++; - - nMTF = wr; - } - - private static void Panic() - { - throw new BZip2Exception("BZip2 output stream panic"); - } - - private static void HbMakeCodeLengths(char[] len, int[] freq, int alphaSize, int maxLen) - { - /*-- - Nodes and heap entries run from 1. Entry 0 - for both the heap and nodes is a sentinel. - --*/ - int nNodes, nHeap, n1, n2, j, k; - bool tooLong; - - int[] heap = new int[BZip2Constants.MaximumAlphaSize + 2]; - int[] weight = new int[BZip2Constants.MaximumAlphaSize * 2]; - int[] parent = new int[BZip2Constants.MaximumAlphaSize * 2]; - - for (int i = 0; i < alphaSize; ++i) - { - weight[i + 1] = (freq[i] == 0 ? 1 : freq[i]) << 8; - } - - while (true) - { - nNodes = alphaSize; - nHeap = 0; - - heap[0] = 0; - weight[0] = 0; - parent[0] = -2; - - for (int i = 1; i <= alphaSize; ++i) - { - parent[i] = -1; - nHeap++; - heap[nHeap] = i; - int zz = nHeap; - int tmp = heap[zz]; - while (weight[tmp] < weight[heap[zz >> 1]]) - { - heap[zz] = heap[zz >> 1]; - zz >>= 1; - } - heap[zz] = tmp; - } - if (!(nHeap < (BZip2Constants.MaximumAlphaSize + 2))) - { - Panic(); - } - - while (nHeap > 1) - { - n1 = heap[1]; - heap[1] = heap[nHeap]; - nHeap--; - int zz = 1; - int yy = 0; - int tmp = heap[zz]; - while (true) - { - yy = zz << 1; - if (yy > nHeap) - { - break; - } - if (yy < nHeap && weight[heap[yy + 1]] < weight[heap[yy]]) - { - yy++; - } - if (weight[tmp] < weight[heap[yy]]) - { - break; - } - - heap[zz] = heap[yy]; - zz = yy; - } - heap[zz] = tmp; - n2 = heap[1]; - heap[1] = heap[nHeap]; - nHeap--; - - zz = 1; - yy = 0; - tmp = heap[zz]; - while (true) - { - yy = zz << 1; - if (yy > nHeap) - { - break; - } - if (yy < nHeap && weight[heap[yy + 1]] < weight[heap[yy]]) - { - yy++; - } - if (weight[tmp] < weight[heap[yy]]) - { - break; - } - heap[zz] = heap[yy]; - zz = yy; - } - heap[zz] = tmp; - nNodes++; - parent[n1] = parent[n2] = nNodes; - - weight[nNodes] = (int)((weight[n1] & 0xffffff00) + (weight[n2] & 0xffffff00)) | - (int)(1 + (((weight[n1] & 0x000000ff) > (weight[n2] & 0x000000ff)) ? (weight[n1] & 0x000000ff) : (weight[n2] & 0x000000ff))); - - parent[nNodes] = -1; - nHeap++; - heap[nHeap] = nNodes; - - zz = nHeap; - tmp = heap[zz]; - while (weight[tmp] < weight[heap[zz >> 1]]) - { - heap[zz] = heap[zz >> 1]; - zz >>= 1; - } - heap[zz] = tmp; - } - if (!(nNodes < (BZip2Constants.MaximumAlphaSize * 2))) - { - Panic(); - } - - tooLong = false; - for (int i = 1; i <= alphaSize; ++i) - { - j = 0; - k = i; - while (parent[k] >= 0) - { - k = parent[k]; - j++; - } - len[i - 1] = (char)j; - tooLong |= j > maxLen; - } - - if (!tooLong) - { - break; - } - - for (int i = 1; i < alphaSize; ++i) - { - j = weight[i] >> 8; - j = 1 + (j / 2); - weight[i] = j << 8; - } - } - } - - private static void HbAssignCodes(int[] code, char[] length, int minLen, int maxLen, int alphaSize) - { - int vec = 0; - for (int n = minLen; n <= maxLen; ++n) - { - for (int i = 0; i < alphaSize; ++i) - { - if (length[i] == n) - { - code[i] = vec; - ++vec; - } - } - vec <<= 1; - } - } - - private static byte Med3(byte a, byte b, byte c) - { - byte t; - if (a > b) - { - t = a; - a = b; - b = t; - } - if (b > c) - { - t = b; - b = c; - c = t; - } - if (a > b) - { - b = a; - } - return b; - } - - private struct StackElement - { - public int ll; - public int hh; - public int dd; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/Adler32.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/Adler32.cs deleted file mode 100644 index 54049cb08..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/Adler32.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum -{ - /// - /// Computes Adler32 checksum for a stream of data. An Adler32 - /// checksum is not as reliable as a CRC32 checksum, but a lot faster to - /// compute. - /// - /// The specification for Adler32 may be found in RFC 1950. - /// ZLIB Compressed Data Format Specification version 3.3) - /// - /// - /// From that document: - /// - /// "ADLER32 (Adler-32 checksum) - /// This contains a checksum value of the uncompressed data - /// (excluding any dictionary data) computed according to Adler-32 - /// algorithm. This algorithm is a 32-bit extension and improvement - /// of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073 - /// standard. - /// - /// Adler-32 is composed of two sums accumulated per byte: s1 is - /// the sum of all bytes, s2 is the sum of all s1 values. Both sums - /// are done modulo 65521. s1 is initialized to 1, s2 to zero. The - /// Adler-32 checksum is stored as s2*65536 + s1 in most- - /// significant-byte first (network) order." - /// - /// "8.2. The Adler-32 algorithm - /// - /// The Adler-32 algorithm is much faster than the CRC32 algorithm yet - /// still provides an extremely low probability of undetected errors. - /// - /// The modulo on unsigned long accumulators can be delayed for 5552 - /// bytes, so the modulo operation time is negligible. If the bytes - /// are a, b, c, the second sum is 3a + 2b + c + 3, and so is position - /// and order sensitive, unlike the first sum, which is just a - /// checksum. That 65521 is prime is important to avoid a possible - /// large class of two-byte errors that leave the check unchanged. - /// (The Fletcher checksum uses 255, which is not prime and which also - /// makes the Fletcher check insensitive to single byte changes 0 - - /// 255.) - /// - /// The sum s1 is initialized to 1 instead of zero to make the length - /// of the sequence part of s2, so that the length does not have to be - /// checked separately. (Any sequence of zeroes has a Fletcher - /// checksum of zero.)" - /// - /// - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public sealed class Adler32 : IChecksum - { - #region Instance Fields - - /// - /// largest prime smaller than 65536 - /// - private static readonly uint BASE = 65521; - - /// - /// The CRC data checksum so far. - /// - private uint checkValue; - - #endregion Instance Fields - - /// - /// Initialise a default instance of - /// - public Adler32() - { - Reset(); - } - - /// - /// Resets the Adler32 data checksum as if no update was ever called. - /// - public void Reset() - { - checkValue = 1; - } - - /// - /// Returns the Adler32 data checksum computed so far. - /// - public long Value - { - get - { - return checkValue; - } - } - - /// - /// Updates the checksum with the byte b. - /// - /// - /// The data value to add. The high byte of the int is ignored. - /// - public void Update(int bval) - { - // We could make a length 1 byte array and call update again, but I - // would rather not have that overhead - uint s1 = checkValue & 0xFFFF; - uint s2 = checkValue >> 16; - - s1 = (s1 + ((uint)bval & 0xFF)) % BASE; - s2 = (s1 + s2) % BASE; - - checkValue = (s2 << 16) + s1; - } - - /// - /// Updates the Adler32 data checksum with the bytes taken from - /// a block of data. - /// - /// Contains the data to update the checksum with. - public void Update(byte[] buffer) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - Update(new ArraySegment(buffer, 0, buffer.Length)); - } - - /// - /// Update Adler32 data checksum based on a portion of a block of data - /// - /// - /// The chunk of data to add - /// - public void Update(ArraySegment segment) - { - //(By Per Bothner) - uint s1 = checkValue & 0xFFFF; - uint s2 = checkValue >> 16; - var count = segment.Count; - var offset = segment.Offset; - while (count > 0) - { - // We can defer the modulo operation: - // s1 maximally grows from 65521 to 65521 + 255 * 3800 - // s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31 - int n = 3800; - if (n > count) - { - n = count; - } - count -= n; - while (--n >= 0) - { - s1 = s1 + (uint)(segment.Array[offset++] & 0xff); - s2 = s2 + s1; - } - s1 %= BASE; - s2 %= BASE; - } - checkValue = (s2 << 16) | s1; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/BZip2Crc.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/BZip2Crc.cs deleted file mode 100644 index 15f5fa588..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/BZip2Crc.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum -{ - /// - /// CRC-32 with unreversed data and reversed output - /// - /// - /// Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: - /// x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0. - /// - /// Polynomials over GF(2) are represented in binary, one bit per coefficient, - /// with the lowest powers in the most significant bit. Then adding polynomials - /// is just exclusive-or, and multiplying a polynomial by x is a right shift by - /// one. If we call the above polynomial p, and represent a byte as the - /// polynomial q, also with the lowest power in the most significant bit (so the - /// byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - /// where a mod b means the remainder after dividing a by b. - /// - /// This calculation is done using the shift-register method of multiplying and - /// taking the remainder. The register is initialized to zero, and for each - /// incoming bit, x^32 is added mod p to the register if the bit is a one (where - /// x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - /// x (which is shifting right by one and adding x^32 mod p if the bit shifted - /// out is a one). We start with the highest power (least significant bit) of - /// q and repeat for all eight bits of q. - /// - /// This implementation uses sixteen lookup tables stored in one linear array - /// to implement the slicing-by-16 algorithm, a variant of the slicing-by-8 - /// algorithm described in this Intel white paper: - /// - /// https://web.archive.org/web/20120722193753/http://download.intel.com/technology/comms/perfnet/download/slicing-by-8.pdf - /// - /// The first lookup table is simply the CRC of all possible eight bit values. - /// Each successive lookup table is derived from the original table generated - /// by Sarwate's algorithm. Slicing a 16-bit input and XORing the outputs - /// together will produce the same output as a byte-by-byte CRC loop with - /// fewer arithmetic and bit manipulation operations, at the cost of increased - /// memory consumed by the lookup tables. (Slicing-by-16 requires a 16KB table, - /// which is still small enough to fit in most processors' L1 cache.) - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public sealed class BZip2Crc : IChecksum - { - #region Instance Fields - - private const uint crcInit = 0xFFFFFFFF; - //const uint crcXor = 0x00000000; - - private static readonly uint[] crcTable = CrcUtilities.GenerateSlicingLookupTable(0x04C11DB7, isReversed: false); - - /// - /// The CRC data checksum so far. - /// - private uint checkValue; - - #endregion Instance Fields - - /// - /// Initialise a default instance of - /// - public BZip2Crc() - { - Reset(); - } - - /// - /// Resets the CRC data checksum as if no update was ever called. - /// - public void Reset() - { - checkValue = crcInit; - } - - /// - /// Returns the CRC data checksum computed so far. - /// - /// Reversed Out = true - public long Value - { - get - { - // Technically, the output should be: - //return (long)(~checkValue ^ crcXor); - // but x ^ 0 = x, so there is no point in adding - // the XOR operation - return (long)(~checkValue); - } - } - - /// - /// Updates the checksum with the int bval. - /// - /// - /// the byte is taken as the lower 8 bits of bval - /// - /// Reversed Data = false - //[MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Update(int bval) - { - checkValue = unchecked(crcTable[(byte)(((checkValue >> 24) & 0xFF) ^ bval)] ^ (checkValue << 8)); - } - - /// - /// Updates the CRC data checksum with the bytes taken from - /// a block of data. - /// - /// Contains the data to update the CRC with. - public void Update(byte[] buffer) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - Update(buffer, 0, buffer.Length); - } - - /// - /// Update CRC data checksum based on a portion of a block of data - /// - /// - /// The chunk of data to add - /// - public void Update(ArraySegment segment) - { - Update(segment.Array, segment.Offset, segment.Count); - } - - /// - /// Internal helper function for updating a block of data using slicing. - /// - /// The array containing the data to add - /// Range start for (inclusive) - /// The number of bytes to checksum starting from - private void Update(byte[] data, int offset, int count) - { - int remainder = count % CrcUtilities.SlicingDegree; - int end = offset + count - remainder; - - while (offset != end) - { - checkValue = CrcUtilities.UpdateDataForNormalPoly(data, offset, crcTable, checkValue); - offset += CrcUtilities.SlicingDegree; - } - - if (remainder != 0) - { - SlowUpdateLoop(data, offset, end + remainder); - } - } - - /// - /// A non-inlined function for updating data that doesn't fit in a 16-byte - /// block. We don't expect to enter this function most of the time, and when - /// we do we're not here for long, so disabling inlining here improves - /// performance overall. - /// - /// The array containing the data to add - /// Range start for (inclusive) - /// Range end for (exclusive) - [MethodImpl(MethodImplOptions.NoInlining)] - private void SlowUpdateLoop(byte[] data, int offset, int end) - { - while (offset != end) - { - Update(data[offset++]); - } - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/Crc32.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/Crc32.cs deleted file mode 100644 index 59d5eefc4..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/Crc32.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum -{ - /// - /// CRC-32 with reversed data and unreversed output - /// - /// - /// Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: - /// x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0. - /// - /// Polynomials over GF(2) are represented in binary, one bit per coefficient, - /// with the lowest powers in the most significant bit. Then adding polynomials - /// is just exclusive-or, and multiplying a polynomial by x is a right shift by - /// one. If we call the above polynomial p, and represent a byte as the - /// polynomial q, also with the lowest power in the most significant bit (so the - /// byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - /// where a mod b means the remainder after dividing a by b. - /// - /// This calculation is done using the shift-register method of multiplying and - /// taking the remainder. The register is initialized to zero, and for each - /// incoming bit, x^32 is added mod p to the register if the bit is a one (where - /// x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - /// x (which is shifting right by one and adding x^32 mod p if the bit shifted - /// out is a one). We start with the highest power (least significant bit) of - /// q and repeat for all eight bits of q. - /// - /// This implementation uses sixteen lookup tables stored in one linear array - /// to implement the slicing-by-16 algorithm, a variant of the slicing-by-8 - /// algorithm described in this Intel white paper: - /// - /// https://web.archive.org/web/20120722193753/http://download.intel.com/technology/comms/perfnet/download/slicing-by-8.pdf - /// - /// The first lookup table is simply the CRC of all possible eight bit values. - /// Each successive lookup table is derived from the original table generated - /// by Sarwate's algorithm. Slicing a 16-bit input and XORing the outputs - /// together will produce the same output as a byte-by-byte CRC loop with - /// fewer arithmetic and bit manipulation operations, at the cost of increased - /// memory consumed by the lookup tables. (Slicing-by-16 requires a 16KB table, - /// which is still small enough to fit in most processors' L1 cache.) - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public sealed class Crc32 : IChecksum - { - #region Instance Fields - - private static readonly uint crcInit = 0xFFFFFFFF; - private static readonly uint crcXor = 0xFFFFFFFF; - - private static readonly uint[] crcTable = CrcUtilities.GenerateSlicingLookupTable(0xEDB88320, isReversed: true); - - /// - /// The CRC data checksum so far. - /// - private uint checkValue; - - #endregion Instance Fields - - //[MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static uint ComputeCrc32(uint oldCrc, byte bval) - { - return (uint)(Crc32.crcTable[(oldCrc ^ bval) & 0xFF] ^ (oldCrc >> 8)); - } - - /// - /// Initialise a default instance of - /// - public Crc32() - { - Reset(); - } - - /// - /// Resets the CRC data checksum as if no update was ever called. - /// - public void Reset() - { - checkValue = crcInit; - } - - /// - /// Returns the CRC data checksum computed so far. - /// - /// Reversed Out = false - public long Value - { - get - { - return (long)(checkValue ^ crcXor); - } - } - - /// - /// Updates the checksum with the int bval. - /// - /// - /// the byte is taken as the lower 8 bits of bval - /// - /// Reversed Data = true - //[MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Update(int bval) - { - checkValue = unchecked(crcTable[(checkValue ^ bval) & 0xFF] ^ (checkValue >> 8)); - } - - /// - /// Updates the CRC data checksum with the bytes taken from - /// a block of data. - /// - /// Contains the data to update the CRC with. - public void Update(byte[] buffer) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - Update(buffer, 0, buffer.Length); - } - - /// - /// Update CRC data checksum based on a portion of a block of data - /// - /// - /// The chunk of data to add - /// - public void Update(ArraySegment segment) - { - Update(segment.Array, segment.Offset, segment.Count); - } - - /// - /// Internal helper function for updating a block of data using slicing. - /// - /// The array containing the data to add - /// Range start for (inclusive) - /// The number of bytes to checksum starting from - private void Update(byte[] data, int offset, int count) - { - int remainder = count % CrcUtilities.SlicingDegree; - int end = offset + count - remainder; - - while (offset != end) - { - checkValue = CrcUtilities.UpdateDataForReversedPoly(data, offset, crcTable, checkValue); - offset += CrcUtilities.SlicingDegree; - } - - if (remainder != 0) - { - SlowUpdateLoop(data, offset, end + remainder); - } - } - - /// - /// A non-inlined function for updating data that doesn't fit in a 16-byte - /// block. We don't expect to enter this function most of the time, and when - /// we do we're not here for long, so disabling inlining here improves - /// performance overall. - /// - /// The array containing the data to add - /// Range start for (inclusive) - /// Range end for (exclusive) - [MethodImpl(MethodImplOptions.NoInlining)] - private void SlowUpdateLoop(byte[] data, int offset, int end) - { - while (offset != end) - { - Update(data[offset++]); - } - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/CrcUtilities.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/CrcUtilities.cs deleted file mode 100644 index 9d0d87171..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/CrcUtilities.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum -{ - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal static class CrcUtilities - { - /// - /// The number of slicing lookup tables to generate. - /// - internal const int SlicingDegree = 16; - - /// - /// Generates multiple CRC lookup tables for a given polynomial, stored - /// in a linear array of uints. The first block (i.e. the first 256 - /// elements) is the same as the byte-by-byte CRC lookup table. - /// - /// The generating CRC polynomial - /// Whether the polynomial is in reversed bit order - /// A linear array of 256 * elements - /// - /// This table could also be generated as a rectangular array, but the - /// JIT compiler generates slower code than if we use a linear array. - /// Known issue, see: https://github.com/dotnet/runtime/issues/30275 - /// - internal static uint[] GenerateSlicingLookupTable(uint polynomial, bool isReversed) - { - var table = new uint[256 * SlicingDegree]; - uint one = isReversed ? 1 : (1U << 31); - - for (int i = 0; i < 256; i++) - { - uint res = (uint)(isReversed ? i : i << 24); - for (int j = 0; j < SlicingDegree; j++) - { - for (int k = 0; k < 8; k++) - { - if (isReversed) - { - res = (res & one) == 1 ? polynomial ^ (res >> 1) : res >> 1; - } - else - { - res = (res & one) != 0 ? polynomial ^ (res << 1) : res << 1; - } - } - - table[(256 * j) + i] = res; - } - } - - return table; - } - - /// - /// Mixes the first four bytes of input with - /// using normal ordering before calling . - /// - /// Array of data to checksum - /// Offset to start reading from - /// The table to use for slicing-by-16 lookup - /// Checksum state before this update call - /// A new unfinalized checksum value - /// - /// - /// Assumes input[offset]..input[offset + 15] are valid array indexes. - /// For performance reasons, this must be checked by the caller. - /// - //[MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static uint UpdateDataForNormalPoly(byte[] input, int offset, uint[] crcTable, uint checkValue) - { - byte x1 = (byte)((byte)(checkValue >> 24) ^ input[offset]); - byte x2 = (byte)((byte)(checkValue >> 16) ^ input[offset + 1]); - byte x3 = (byte)((byte)(checkValue >> 8) ^ input[offset + 2]); - byte x4 = (byte)((byte)checkValue ^ input[offset + 3]); - - return UpdateDataCommon(input, offset, crcTable, x1, x2, x3, x4); - } - - /// - /// Mixes the first four bytes of input with - /// using reflected ordering before calling . - /// - /// Array of data to checksum - /// Offset to start reading from - /// The table to use for slicing-by-16 lookup - /// Checksum state before this update call - /// A new unfinalized checksum value - /// - /// - /// Assumes input[offset]..input[offset + 15] are valid array indexes. - /// For performance reasons, this must be checked by the caller. - /// - //[MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static uint UpdateDataForReversedPoly(byte[] input, int offset, uint[] crcTable, uint checkValue) - { - byte x1 = (byte)((byte)checkValue ^ input[offset]); - byte x2 = (byte)((byte)(checkValue >>= 8) ^ input[offset + 1]); - byte x3 = (byte)((byte)(checkValue >>= 8) ^ input[offset + 2]); - byte x4 = (byte)((byte)(checkValue >>= 8) ^ input[offset + 3]); - - return UpdateDataCommon(input, offset, crcTable, x1, x2, x3, x4); - } - - /// - /// A shared method for updating an unfinalized CRC checksum using slicing-by-16. - /// - /// Array of data to checksum - /// Offset to start reading from - /// The table to use for slicing-by-16 lookup - /// First byte of input after mixing with the old CRC - /// Second byte of input after mixing with the old CRC - /// Third byte of input after mixing with the old CRC - /// Fourth byte of input after mixing with the old CRC - /// A new unfinalized checksum value - /// - /// - /// Even though the first four bytes of input are fed in as arguments, - /// should be the same value passed to this - /// function's caller (either or - /// ). This method will get inlined - /// into both functions, so using the same offset produces faster code. - /// - /// - /// Because most processors running C# have some kind of instruction-level - /// parallelism, the order of XOR operations can affect performance. This - /// ordering assumes that the assembly code generated by the just-in-time - /// compiler will emit a bunch of arithmetic operations for checking array - /// bounds. Then it opportunistically XORs a1 and a2 to keep the processor - /// busy while those other parts of the pipeline handle the range check - /// calculations. - /// - /// - //[MethodImpl(MethodImplOptions.AggressiveInlining)] - private static uint UpdateDataCommon(byte[] input, int offset, uint[] crcTable, byte x1, byte x2, byte x3, byte x4) - { - uint result; - uint a1 = crcTable[x1 + 3840] ^ crcTable[x2 + 3584]; - uint a2 = crcTable[x3 + 3328] ^ crcTable[x4 + 3072]; - - result = crcTable[input[offset + 4] + 2816]; - result ^= crcTable[input[offset + 5] + 2560]; - a1 ^= crcTable[input[offset + 9] + 1536]; - result ^= crcTable[input[offset + 6] + 2304]; - result ^= crcTable[input[offset + 7] + 2048]; - result ^= crcTable[input[offset + 8] + 1792]; - a2 ^= crcTable[input[offset + 13] + 512]; - result ^= crcTable[input[offset + 10] + 1280]; - result ^= crcTable[input[offset + 11] + 1024]; - result ^= crcTable[input[offset + 12] + 768]; - result ^= a1; - result ^= crcTable[input[offset + 14] + 256]; - result ^= crcTable[input[offset + 15]]; - result ^= a2; - - return result; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/IChecksum.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/IChecksum.cs deleted file mode 100644 index d9c5ffd95..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/IChecksum.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum -{ - /// - /// Interface to compute a data checksum used by checked input/output streams. - /// A data checksum can be updated by one byte or with a byte array. After each - /// update the value of the current checksum can be returned by calling - /// getValue. The complete checksum object can also be reset - /// so it can be used again with new data. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public interface IChecksum - { - /// - /// Resets the data checksum as if no update was ever called. - /// - void Reset(); - - /// - /// Returns the data checksum computed so far. - /// - long Value - { - get; - } - - /// - /// Adds one byte to the data checksum. - /// - /// - /// the data value to add. The high byte of the int is ignored. - /// - void Update(int bval); - - /// - /// Updates the data checksum with the bytes taken from the array. - /// - /// - /// buffer an array of bytes - /// - void Update(byte[] buffer); - - /// - /// Adds the byte array to the data checksum. - /// - /// - /// The chunk of data to add - /// - void Update(ArraySegment segment); - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/EmptyRefs.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/EmptyRefs.cs deleted file mode 100644 index 8f0bb3b51..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/EmptyRefs.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Core -{ - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal static class Empty - { - internal static class EmptyArray - { - public static readonly T[] Value = new T[0]; - } - public static T[] Array() => EmptyArray.Value; - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/SharpZipBaseException.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/SharpZipBaseException.cs deleted file mode 100644 index 47283237f..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/SharpZipBaseException.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib -{ - /// - /// SharpZipBaseException is the base exception class for SharpZipLib. - /// All library exceptions are derived from this. - /// - /// NOTE: Not all exceptions thrown will be derived from this class. - /// A variety of other exceptions are possible for example - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class SharpZipBaseException : Exception - { - /// - /// Initializes a new instance of the SharpZipBaseException class. - /// - public SharpZipBaseException() - { - } - - /// - /// Initializes a new instance of the SharpZipBaseException class with a specified error message. - /// - /// A message describing the exception. - public SharpZipBaseException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of the SharpZipBaseException class with a specified - /// error message and a reference to the inner exception that is the cause of this exception. - /// - /// A message describing the exception. - /// The inner exception - public SharpZipBaseException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the SharpZipBaseException class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected SharpZipBaseException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/StreamDecodingException.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/StreamDecodingException.cs deleted file mode 100644 index d5f9aa462..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/StreamDecodingException.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib -{ - /// - /// Indicates that an error occurred during decoding of a input stream due to corrupt - /// data or (unintentional) library incompatibility. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class StreamDecodingException : SharpZipBaseException - { - private const string GenericMessage = "Input stream could not be decoded"; - - /// - /// Initializes a new instance of the StreamDecodingException with a generic message - /// - public StreamDecodingException() : base(GenericMessage) { } - - /// - /// Initializes a new instance of the StreamDecodingException class with a specified error message. - /// - /// A message describing the exception. - public StreamDecodingException(string message) : base(message) { } - - /// - /// Initializes a new instance of the StreamDecodingException class with a specified - /// error message and a reference to the inner exception that is the cause of this exception. - /// - /// A message describing the exception. - /// The inner exception - public StreamDecodingException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the StreamDecodingException class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected StreamDecodingException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/StreamUnsupportedException.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/StreamUnsupportedException.cs deleted file mode 100644 index a90b01fd7..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/StreamUnsupportedException.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib -{ - /// - /// Indicates that the input stream could not decoded due to known library incompability or missing features - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class StreamUnsupportedException : StreamDecodingException - { - private const string GenericMessage = "Input stream is in a unsupported format"; - - /// - /// Initializes a new instance of the StreamUnsupportedException with a generic message - /// - public StreamUnsupportedException() : base(GenericMessage) { } - - /// - /// Initializes a new instance of the StreamUnsupportedException class with a specified error message. - /// - /// A message describing the exception. - public StreamUnsupportedException(string message) : base(message) { } - - /// - /// Initializes a new instance of the StreamUnsupportedException class with a specified - /// error message and a reference to the inner exception that is the cause of this exception. - /// - /// A message describing the exception. - /// The inner exception - public StreamUnsupportedException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the StreamUnsupportedException class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected StreamUnsupportedException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/UnexpectedEndOfStreamException.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/UnexpectedEndOfStreamException.cs deleted file mode 100644 index eb55a1c53..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/UnexpectedEndOfStreamException.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib -{ - /// - /// Indicates that the input stream could not decoded due to the stream ending before enough data had been provided - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class UnexpectedEndOfStreamException : StreamDecodingException - { - private const string GenericMessage = "Input stream ended unexpectedly"; - - /// - /// Initializes a new instance of the UnexpectedEndOfStreamException with a generic message - /// - public UnexpectedEndOfStreamException() : base(GenericMessage) { } - - /// - /// Initializes a new instance of the UnexpectedEndOfStreamException class with a specified error message. - /// - /// A message describing the exception. - public UnexpectedEndOfStreamException(string message) : base(message) { } - - /// - /// Initializes a new instance of the UnexpectedEndOfStreamException class with a specified - /// error message and a reference to the inner exception that is the cause of this exception. - /// - /// A message describing the exception. - /// The inner exception - public UnexpectedEndOfStreamException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Initializes a new instance of the UnexpectedEndOfStreamException class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected UnexpectedEndOfStreamException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/ValueOutOfRangeException.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/ValueOutOfRangeException.cs deleted file mode 100644 index efb5e88bb..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/Exceptions/ValueOutOfRangeException.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib -{ - /// - /// Indicates that a value was outside of the expected range when decoding an input stream - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class ValueOutOfRangeException : StreamDecodingException - { - /// - /// Initializes a new instance of the ValueOutOfRangeException class naming the causing variable - /// - /// Name of the variable, use: nameof() - public ValueOutOfRangeException(string nameOfValue) - : base($"{nameOfValue} out of range") { } - - /// - /// Initializes a new instance of the ValueOutOfRangeException class naming the causing variable, - /// it's current value and expected range. - /// - /// Name of the variable, use: nameof() - /// The invalid value - /// Expected maximum value - /// Expected minimum value - public ValueOutOfRangeException(string nameOfValue, long value, long maxValue, long minValue = 0) - : this(nameOfValue, value.ToString(), maxValue.ToString(), minValue.ToString()) { } - - /// - /// Initializes a new instance of the ValueOutOfRangeException class naming the causing variable, - /// it's current value and expected range. - /// - /// Name of the variable, use: nameof() - /// The invalid value - /// Expected maximum value - /// Expected minimum value - public ValueOutOfRangeException(string nameOfValue, string value, string maxValue, string minValue = "0") : - base($"{nameOfValue} out of range: {value}, should be {minValue}..{maxValue}") - { } - - private ValueOutOfRangeException() - { - } - - private ValueOutOfRangeException(string message, Exception innerException) : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the ValueOutOfRangeException class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected ValueOutOfRangeException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/FileSystemScanner.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/FileSystemScanner.cs deleted file mode 100644 index df868a808..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/FileSystemScanner.cs +++ /dev/null @@ -1,555 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Core -{ - #region EventArgs - - /// - /// Event arguments for scanning. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class ScanEventArgs : EventArgs - { - #region Constructors - - /// - /// Initialise a new instance of - /// - /// The file or directory name. - public ScanEventArgs(string name) - { - name_ = name; - } - - #endregion Constructors - - /// - /// The file or directory name for this event. - /// - public string Name - { - get { return name_; } - } - - /// - /// Get set a value indicating if scanning should continue or not. - /// - public bool ContinueRunning - { - get { return continueRunning_; } - set { continueRunning_ = value; } - } - - #region Instance Fields - - private string name_; - private bool continueRunning_ = true; - - #endregion Instance Fields - } - - /// - /// Event arguments during processing of a single file or directory. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class ProgressEventArgs : EventArgs - { - #region Constructors - - /// - /// Initialise a new instance of - /// - /// The file or directory name if known. - /// The number of bytes processed so far - /// The total number of bytes to process, 0 if not known - public ProgressEventArgs(string name, long processed, long target) - { - name_ = name; - processed_ = processed; - target_ = target; - } - - #endregion Constructors - - /// - /// The name for this event if known. - /// - public string Name - { - get { return name_; } - } - - /// - /// Get set a value indicating whether scanning should continue or not. - /// - public bool ContinueRunning - { - get { return continueRunning_; } - set { continueRunning_ = value; } - } - - /// - /// Get a percentage representing how much of the has been processed - /// - /// 0.0 to 100.0 percent; 0 if target is not known. - public float PercentComplete - { - get - { - float result; - if (target_ <= 0) - { - result = 0; - } - else - { - result = ((float)processed_ / (float)target_) * 100.0f; - } - return result; - } - } - - /// - /// The number of bytes processed so far - /// - public long Processed - { - get { return processed_; } - } - - /// - /// The number of bytes to process. - /// - /// Target may be 0 or negative if the value isnt known. - public long Target - { - get { return target_; } - } - - #region Instance Fields - - private string name_; - private long processed_; - private long target_; - private bool continueRunning_ = true; - - #endregion Instance Fields - } - - /// - /// Event arguments for directories. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class DirectoryEventArgs : ScanEventArgs - { - #region Constructors - - /// - /// Initialize an instance of . - /// - /// The name for this directory. - /// Flag value indicating if any matching files are contained in this directory. - public DirectoryEventArgs(string name, bool hasMatchingFiles) - : base(name) - { - hasMatchingFiles_ = hasMatchingFiles; - } - - #endregion Constructors - - /// - /// Get a value indicating if the directory contains any matching files or not. - /// - public bool HasMatchingFiles - { - get { return hasMatchingFiles_; } - } - - private readonly - - #region Instance Fields - - bool hasMatchingFiles_; - - #endregion Instance Fields - } - - /// - /// Arguments passed when scan failures are detected. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class ScanFailureEventArgs : EventArgs - { - #region Constructors - - /// - /// Initialise a new instance of - /// - /// The name to apply. - /// The exception to use. - public ScanFailureEventArgs(string name, Exception e) - { - name_ = name; - exception_ = e; - continueRunning_ = true; - } - - #endregion Constructors - - /// - /// The applicable name. - /// - public string Name - { - get { return name_; } - } - - /// - /// The applicable exception. - /// - public Exception Exception - { - get { return exception_; } - } - - /// - /// Get / set a value indicating whether scanning should continue. - /// - public bool ContinueRunning - { - get { return continueRunning_; } - set { continueRunning_ = value; } - } - - #region Instance Fields - - private string name_; - private Exception exception_; - private bool continueRunning_; - - #endregion Instance Fields - } - - #endregion EventArgs - - #region Delegates - - /// - /// Delegate invoked before starting to process a file. - /// - /// The source of the event - /// The event arguments. - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public delegate void ProcessFileHandler(object sender, ScanEventArgs e); - - /// - /// Delegate invoked during processing of a file or directory - /// - /// The source of the event - /// The event arguments. - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public delegate void ProgressHandler(object sender, ProgressEventArgs e); - - /// - /// Delegate invoked when a file has been completely processed. - /// - /// The source of the event - /// The event arguments. - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public delegate void CompletedFileHandler(object sender, ScanEventArgs e); - - /// - /// Delegate invoked when a directory failure is detected. - /// - /// The source of the event - /// The event arguments. - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public delegate void DirectoryFailureHandler(object sender, ScanFailureEventArgs e); - - /// - /// Delegate invoked when a file failure is detected. - /// - /// The source of the event - /// The event arguments. - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public delegate void FileFailureHandler(object sender, ScanFailureEventArgs e); - - #endregion Delegates - - /// - /// FileSystemScanner provides facilities scanning of files and directories. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class FileSystemScanner - { - #region Constructors - - /// - /// Initialise a new instance of - /// - /// The file filter to apply when scanning. - public FileSystemScanner(string filter) - { - fileFilter_ = new PathFilter(filter); - } - - /// - /// Initialise a new instance of - /// - /// The file filter to apply. - /// The directory filter to apply. - public FileSystemScanner(string fileFilter, string directoryFilter) - { - fileFilter_ = new PathFilter(fileFilter); - directoryFilter_ = new PathFilter(directoryFilter); - } - - /// - /// Initialise a new instance of - /// - /// The file filter to apply. - public FileSystemScanner(IScanFilter fileFilter) - { - fileFilter_ = fileFilter; - } - - /// - /// Initialise a new instance of - /// - /// The file filter to apply. - /// The directory filter to apply. - public FileSystemScanner(IScanFilter fileFilter, IScanFilter directoryFilter) - { - fileFilter_ = fileFilter; - directoryFilter_ = directoryFilter; - } - - #endregion Constructors - - #region Delegates - - /// - /// Delegate to invoke when a directory is processed. - /// - public event EventHandler ProcessDirectory; - - /// - /// Delegate to invoke when a file is processed. - /// - public ProcessFileHandler ProcessFile; - - /// - /// Delegate to invoke when processing for a file has finished. - /// - public CompletedFileHandler CompletedFile; - - /// - /// Delegate to invoke when a directory failure is detected. - /// - public DirectoryFailureHandler DirectoryFailure; - - /// - /// Delegate to invoke when a file failure is detected. - /// - public FileFailureHandler FileFailure; - - #endregion Delegates - - /// - /// Raise the DirectoryFailure event. - /// - /// The directory name. - /// The exception detected. - private bool OnDirectoryFailure(string directory, Exception e) - { - DirectoryFailureHandler handler = DirectoryFailure; - bool result = (handler != null); - if (result) - { - var args = new ScanFailureEventArgs(directory, e); - handler(this, args); - alive_ = args.ContinueRunning; - } - return result; - } - - /// - /// Raise the FileFailure event. - /// - /// The file name. - /// The exception detected. - private bool OnFileFailure(string file, Exception e) - { - FileFailureHandler handler = FileFailure; - - bool result = (handler != null); - - if (result) - { - var args = new ScanFailureEventArgs(file, e); - FileFailure(this, args); - alive_ = args.ContinueRunning; - } - return result; - } - - /// - /// Raise the ProcessFile event. - /// - /// The file name. - private void OnProcessFile(string file) - { - ProcessFileHandler handler = ProcessFile; - - if (handler != null) - { - var args = new ScanEventArgs(file); - handler(this, args); - alive_ = args.ContinueRunning; - } - } - - /// - /// Raise the complete file event - /// - /// The file name - private void OnCompleteFile(string file) - { - CompletedFileHandler handler = CompletedFile; - - if (handler != null) - { - var args = new ScanEventArgs(file); - handler(this, args); - alive_ = args.ContinueRunning; - } - } - - /// - /// Raise the ProcessDirectory event. - /// - /// The directory name. - /// Flag indicating if the directory has matching files. - private void OnProcessDirectory(string directory, bool hasMatchingFiles) - { - EventHandler handler = ProcessDirectory; - - if (handler != null) - { - var args = new DirectoryEventArgs(directory, hasMatchingFiles); - handler(this, args); - alive_ = args.ContinueRunning; - } - } - - /// - /// Scan a directory. - /// - /// The base directory to scan. - /// True to recurse subdirectories, false to scan a single directory. - public void Scan(string directory, bool recurse) - { - alive_ = true; - ScanDir(directory, recurse); - } - - private void ScanDir(string directory, bool recurse) - { - try - { - string[] names = System.IO.Directory.GetFiles(directory); - bool hasMatch = false; - for (int fileIndex = 0; fileIndex < names.Length; ++fileIndex) - { - if (!fileFilter_.IsMatch(names[fileIndex])) - { - names[fileIndex] = null; - } - else - { - hasMatch = true; - } - } - - OnProcessDirectory(directory, hasMatch); - - if (alive_ && hasMatch) - { - foreach (string fileName in names) - { - try - { - if (fileName != null) - { - OnProcessFile(fileName); - if (!alive_) - { - break; - } - } - } - catch (Exception e) - { - if (!OnFileFailure(fileName, e)) - { - throw; - } - } - } - } - } - catch (Exception e) - { - if (!OnDirectoryFailure(directory, e)) - { - throw; - } - } - - if (alive_ && recurse) - { - try - { - string[] names = System.IO.Directory.GetDirectories(directory); - foreach (string fulldir in names) - { - if ((directoryFilter_ == null) || (directoryFilter_.IsMatch(fulldir))) - { - ScanDir(fulldir, true); - if (!alive_) - { - break; - } - } - } - } - catch (Exception e) - { - if (!OnDirectoryFailure(directory, e)) - { - throw; - } - } - } - } - - #region Instance Fields - - /// - /// The file filter currently in use. - /// - private IScanFilter fileFilter_; - - /// - /// The directory filter currently in use. - /// - private IScanFilter directoryFilter_; - - /// - /// Flag indicating if scanning should continue running. - /// - private bool alive_; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/INameTransform.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/INameTransform.cs deleted file mode 100644 index 295f8823c..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/INameTransform.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Core -{ - /// - /// INameTransform defines how file system names are transformed for use with archives, or vice versa. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public interface INameTransform - { - /// - /// Given a file name determine the transformed value. - /// - /// The name to transform. - /// The transformed file name. - string TransformFile(string name); - - /// - /// Given a directory name determine the transformed value. - /// - /// The name to transform. - /// The transformed directory name - string TransformDirectory(string name); - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/IScanFilter.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/IScanFilter.cs deleted file mode 100644 index 1b90b48ed..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/IScanFilter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Core -{ - /// - /// Scanning filters support filtering of names. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public interface IScanFilter - { - /// - /// Test a name to see if it 'matches' the filter. - /// - /// The name to test. - /// Returns true if the name matches the filter, false if it does not match. - bool IsMatch(string name); - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/InvalidNameException.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/InvalidNameException.cs deleted file mode 100644 index 7a9a24358..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/InvalidNameException.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Core -{ - /// - /// InvalidNameException is thrown for invalid names such as directory traversal paths and names with invalid characters - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class InvalidNameException : SharpZipBaseException - { - /// - /// Initializes a new instance of the InvalidNameException class with a default error message. - /// - public InvalidNameException() : base("An invalid name was specified") - { - } - - /// - /// Initializes a new instance of the InvalidNameException class with a specified error message. - /// - /// A message describing the exception. - public InvalidNameException(string message) : base(message) - { - } - - /// - /// Initializes a new instance of the InvalidNameException class with a specified - /// error message and a reference to the inner exception that is the cause of this exception. - /// - /// A message describing the exception. - /// The inner exception - public InvalidNameException(string message, Exception innerException) : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the InvalidNameException class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected InvalidNameException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/NameFilter.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/NameFilter.cs deleted file mode 100644 index 4c11db478..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/NameFilter.cs +++ /dev/null @@ -1,285 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Core -{ - /// - /// NameFilter is a string matching class which allows for both positive and negative - /// matching. - /// A filter is a sequence of independant regular expressions separated by semi-colons ';'. - /// To include a semi-colon it may be quoted as in \;. Each expression can be prefixed by a plus '+' sign or - /// a minus '-' sign to denote the expression is intended to include or exclude names. - /// If neither a plus or minus sign is found include is the default. - /// A given name is tested for inclusion before checking exclusions. Only names matching an include spec - /// and not matching an exclude spec are deemed to match the filter. - /// An empty filter matches any name. - /// - /// The following expression includes all name ending in '.dat' with the exception of 'dummy.dat' - /// "+\.dat$;-^dummy\.dat$" - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class NameFilter : IScanFilter - { - #region Constructors - - /// - /// Construct an instance based on the filter expression passed - /// - /// The filter expression. - public NameFilter(string filter) - { - filter_ = filter; - inclusions_ = new List(); - exclusions_ = new List(); - Compile(); - } - - #endregion Constructors - - /// - /// Test a string to see if it is a valid regular expression. - /// - /// The expression to test. - /// True if expression is a valid false otherwise. - public static bool IsValidExpression(string expression) - { - bool result = true; - try - { - var exp = new Regex(expression, RegexOptions.IgnoreCase | RegexOptions.Singleline); - } - catch (ArgumentException) - { - result = false; - } - return result; - } - - /// - /// Test an expression to see if it is valid as a filter. - /// - /// The filter expression to test. - /// True if the expression is valid, false otherwise. - public static bool IsValidFilterExpression(string toTest) - { - bool result = true; - - try - { - if (toTest != null) - { - string[] items = SplitQuoted(toTest); - for (int i = 0; i < items.Length; ++i) - { - if ((items[i] != null) && (items[i].Length > 0)) - { - string toCompile; - - if (items[i][0] == '+') - { - toCompile = items[i].Substring(1, items[i].Length - 1); - } - else if (items[i][0] == '-') - { - toCompile = items[i].Substring(1, items[i].Length - 1); - } - else - { - toCompile = items[i]; - } - - var testRegex = new Regex(toCompile, RegexOptions.IgnoreCase | RegexOptions.Singleline); - } - } - } - } - catch (ArgumentException) - { - result = false; - } - - return result; - } - - /// - /// Split a string into its component pieces - /// - /// The original string - /// Returns an array of values containing the individual filter elements. - public static string[] SplitQuoted(string original) - { - char escape = '\\'; - char[] separators = { ';' }; - - var result = new List(); - - if (!string.IsNullOrEmpty(original)) - { - int endIndex = -1; - var b = new StringBuilder(); - - while (endIndex < original.Length) - { - endIndex += 1; - if (endIndex >= original.Length) - { - result.Add(b.ToString()); - } - else if (original[endIndex] == escape) - { - endIndex += 1; - if (endIndex >= original.Length) - { - throw new ArgumentException("Missing terminating escape character", nameof(original)); - } - // include escape if this is not an escaped separator - if (Array.IndexOf(separators, original[endIndex]) < 0) - b.Append(escape); - - b.Append(original[endIndex]); - } - else - { - if (Array.IndexOf(separators, original[endIndex]) >= 0) - { - result.Add(b.ToString()); - b.Length = 0; - } - else - { - b.Append(original[endIndex]); - } - } - } - } - - return result.ToArray(); - } - - /// - /// Convert this filter to its string equivalent. - /// - /// The string equivalent for this filter. - public override string ToString() - { - return filter_; - } - - /// - /// Test a value to see if it is included by the filter. - /// - /// The value to test. - /// True if the value is included, false otherwise. - public bool IsIncluded(string name) - { - bool result = false; - if (inclusions_.Count == 0) - { - result = true; - } - else - { - foreach (Regex r in inclusions_) - { - if (r.IsMatch(name)) - { - result = true; - break; - } - } - } - return result; - } - - /// - /// Test a value to see if it is excluded by the filter. - /// - /// The value to test. - /// True if the value is excluded, false otherwise. - public bool IsExcluded(string name) - { - bool result = false; - foreach (Regex r in exclusions_) - { - if (r.IsMatch(name)) - { - result = true; - break; - } - } - return result; - } - - #region IScanFilter Members - - /// - /// Test a value to see if it matches the filter. - /// - /// The value to test. - /// True if the value matches, false otherwise. - public bool IsMatch(string name) - { - return (IsIncluded(name) && !IsExcluded(name)); - } - - #endregion IScanFilter Members - - /// - /// Compile this filter. - /// - private void Compile() - { - // TODO: Check to see if combining RE's makes it faster/smaller. - // simple scheme would be to have one RE for inclusion and one for exclusion. - if (filter_ == null) - { - return; - } - - string[] items = SplitQuoted(filter_); - for (int i = 0; i < items.Length; ++i) - { - if ((items[i] != null) && (items[i].Length > 0)) - { - bool include = (items[i][0] != '-'); - string toCompile; - - if (items[i][0] == '+') - { - toCompile = items[i].Substring(1, items[i].Length - 1); - } - else if (items[i][0] == '-') - { - toCompile = items[i].Substring(1, items[i].Length - 1); - } - else - { - toCompile = items[i]; - } - - // NOTE: Regular expressions can fail to compile here for a number of reasons that cause an exception - // these are left unhandled here as the caller is responsible for ensuring all is valid. - // several functions IsValidFilterExpression and IsValidExpression are provided for such checking - if (include) - { - inclusions_.Add(new Regex(toCompile, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)); - } - else - { - exclusions_.Add(new Regex(toCompile, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)); - } - } - } - } - - #region Instance Fields - - private string filter_; - private List inclusions_; - private List exclusions_; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/PathFilter.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/PathFilter.cs deleted file mode 100644 index 6be80e407..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/PathFilter.cs +++ /dev/null @@ -1,320 +0,0 @@ -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Core -{ - /// - /// PathFilter filters directories and files using a form of regular expressions - /// by full path name. - /// See NameFilter for more detail on filtering. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class PathFilter : IScanFilter - { - #region Constructors - - /// - /// Initialise a new instance of . - /// - /// The filter expression to apply. - public PathFilter(string filter) - { - nameFilter_ = new NameFilter(filter); - } - - #endregion Constructors - - #region IScanFilter Members - - /// - /// Test a name to see if it matches the filter. - /// - /// The name to test. - /// True if the name matches, false otherwise. - /// is used to get the full path before matching. - public virtual bool IsMatch(string name) - { - bool result = false; - - if (name != null) - { - string cooked = (name.Length > 0) ? Path.GetFullPath(name) : ""; - result = nameFilter_.IsMatch(cooked); - } - return result; - } - - private readonly - - #endregion IScanFilter Members - - #region Instance Fields - - NameFilter nameFilter_; - - #endregion Instance Fields - } - - /// - /// ExtendedPathFilter filters based on name, file size, and the last write time of the file. - /// - /// Provides an example of how to customise filtering. - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class ExtendedPathFilter : PathFilter - { - #region Constructors - - /// - /// Initialise a new instance of ExtendedPathFilter. - /// - /// The filter to apply. - /// The minimum file size to include. - /// The maximum file size to include. - public ExtendedPathFilter(string filter, - long minSize, long maxSize) - : base(filter) - { - MinSize = minSize; - MaxSize = maxSize; - } - - /// - /// Initialise a new instance of ExtendedPathFilter. - /// - /// The filter to apply. - /// The minimum to include. - /// The maximum to include. - public ExtendedPathFilter(string filter, - DateTime minDate, DateTime maxDate) - : base(filter) - { - MinDate = minDate; - MaxDate = maxDate; - } - - /// - /// Initialise a new instance of ExtendedPathFilter. - /// - /// The filter to apply. - /// The minimum file size to include. - /// The maximum file size to include. - /// The minimum to include. - /// The maximum to include. - public ExtendedPathFilter(string filter, - long minSize, long maxSize, - DateTime minDate, DateTime maxDate) - : base(filter) - { - MinSize = minSize; - MaxSize = maxSize; - MinDate = minDate; - MaxDate = maxDate; - } - - #endregion Constructors - - #region IScanFilter Members - - /// - /// Test a filename to see if it matches the filter. - /// - /// The filename to test. - /// True if the filter matches, false otherwise. - /// The doesnt exist - public override bool IsMatch(string name) - { - bool result = base.IsMatch(name); - - if (result) - { - var fileInfo = new FileInfo(name); - result = - (MinSize <= fileInfo.Length) && - (MaxSize >= fileInfo.Length) && - (MinDate <= fileInfo.LastWriteTime) && - (MaxDate >= fileInfo.LastWriteTime) - ; - } - return result; - } - - #endregion IScanFilter Members - - #region Properties - - /// - /// Get/set the minimum size/length for a file that will match this filter. - /// - /// The default value is zero. - /// value is less than zero; greater than - public long MinSize - { - get { return minSize_; } - set - { - if ((value < 0) || (maxSize_ < value)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - minSize_ = value; - } - } - - /// - /// Get/set the maximum size/length for a file that will match this filter. - /// - /// The default value is - /// value is less than zero or less than - public long MaxSize - { - get { return maxSize_; } - set - { - if ((value < 0) || (minSize_ > value)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - maxSize_ = value; - } - } - - /// - /// Get/set the minimum value that will match for this filter. - /// - /// Files with a LastWrite time less than this value are excluded by the filter. - public DateTime MinDate - { - get - { - return minDate_; - } - - set - { - if (value > maxDate_) - { - throw new ArgumentOutOfRangeException(nameof(value), "Exceeds MaxDate"); - } - - minDate_ = value; - } - } - - /// - /// Get/set the maximum value that will match for this filter. - /// - /// Files with a LastWrite time greater than this value are excluded by the filter. - public DateTime MaxDate - { - get - { - return maxDate_; - } - - set - { - if (minDate_ > value) - { - throw new ArgumentOutOfRangeException(nameof(value), "Exceeds MinDate"); - } - - maxDate_ = value; - } - } - - #endregion Properties - - #region Instance Fields - - private long minSize_; - private long maxSize_ = long.MaxValue; - private DateTime minDate_ = DateTime.MinValue; - private DateTime maxDate_ = DateTime.MaxValue; - - #endregion Instance Fields - } - - /// - /// NameAndSizeFilter filters based on name and file size. - /// - /// A sample showing how filters might be extended. - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class NameAndSizeFilter : PathFilter - { - /// - /// Initialise a new instance of NameAndSizeFilter. - /// - /// The filter to apply. - /// The minimum file size to include. - /// The maximum file size to include. - public NameAndSizeFilter(string filter, long minSize, long maxSize) - : base(filter) - { - MinSize = minSize; - MaxSize = maxSize; - } - - /// - /// Test a filename to see if it matches the filter. - /// - /// The filename to test. - /// True if the filter matches, false otherwise. - public override bool IsMatch(string name) - { - bool result = base.IsMatch(name); - - if (result) - { - var fileInfo = new FileInfo(name); - long length = fileInfo.Length; - result = - (MinSize <= length) && - (MaxSize >= length); - } - return result; - } - - /// - /// Get/set the minimum size for a file that will match this filter. - /// - public long MinSize - { - get { return minSize_; } - set - { - if ((value < 0) || (maxSize_ < value)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - minSize_ = value; - } - } - - /// - /// Get/set the maximum size for a file that will match this filter. - /// - public long MaxSize - { - get { return maxSize_; } - set - { - if ((value < 0) || (minSize_ > value)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - maxSize_ = value; - } - } - - #region Instance Fields - - private long minSize_; - private long maxSize_ = long.MaxValue; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/PathUtils.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/PathUtils.cs deleted file mode 100644 index da9d6d18a..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/PathUtils.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.IO; -using System.Linq; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Core -{ - /// - /// PathUtils provides simple utilities for handling paths. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public static class PathUtils - { - /// - /// Remove any path root present in the path - /// - /// A containing path information. - /// The path with the root removed if it was present; path otherwise. - public static string DropPathRoot(string path) - { - var invalidChars = Path.GetInvalidPathChars(); - // If the first character after the root is a ':', .NET < 4.6.2 throws - var cleanRootSep = path.Length >= 3 && path[1] == ':' && path[2] == ':'; - - // Replace any invalid path characters with '_' to prevent Path.GetPathRoot from throwing. - // Only pass the first 258 (should be 260, but that still throws for some reason) characters - // as .NET < 4.6.2 throws on longer paths - var cleanPath = new string(path.Take(258) - .Select( (c, i) => invalidChars.Contains(c) || (i == 2 && cleanRootSep) ? '_' : c).ToArray()); - - var stripLength = Path.GetPathRoot(cleanPath).Length; - while (path.Length > stripLength && (path[stripLength] == '/' || path[stripLength] == '\\')) stripLength++; - return path.Substring(stripLength); - } - - /// - /// Returns a random file name in the users temporary directory, or in directory of if specified - /// - /// If specified, used as the base file name for the temporary file - /// Returns a temporary file name - public static string GetTempFileName(string original = null) - { - string fileName; - var tempPath = Path.GetTempPath(); - - do - { - fileName = original == null - ? Path.Combine(tempPath, Path.GetRandomFileName()) - : $"{original}.{Path.GetRandomFileName()}"; - } while (File.Exists(fileName)); - - return fileName; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/StreamUtils.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/StreamUtils.cs deleted file mode 100644 index ee4add299..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/StreamUtils.cs +++ /dev/null @@ -1,285 +0,0 @@ -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Core -{ - /// - /// Provides simple " utilities. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public sealed class StreamUtils - { - /// - /// Read from a ensuring all the required data is read. - /// - /// The stream to read. - /// The buffer to fill. - /// - static public void ReadFully(Stream stream, byte[] buffer) - { - ReadFully(stream, buffer, 0, buffer.Length); - } - - /// - /// Read from a " ensuring all the required data is read. - /// - /// The stream to read data from. - /// The buffer to store data in. - /// The offset at which to begin storing data. - /// The number of bytes of data to store. - /// Required parameter is null - /// and or are invalid. - /// End of stream is encountered before all the data has been read. - static public void ReadFully(Stream stream, byte[] buffer, int offset, int count) - { - if (stream == null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - // Offset can equal length when buffer and count are 0. - if ((offset < 0) || (offset > buffer.Length)) - { - throw new ArgumentOutOfRangeException(nameof(offset)); - } - - if ((count < 0) || (offset + count > buffer.Length)) - { - throw new ArgumentOutOfRangeException(nameof(count)); - } - - while (count > 0) - { - int readCount = stream.Read(buffer, offset, count); - if (readCount <= 0) - { - throw new EndOfStreamException(); - } - offset += readCount; - count -= readCount; - } - } - - /// - /// Read as much data as possible from a ", up to the requested number of bytes - /// - /// The stream to read data from. - /// The buffer to store data in. - /// The offset at which to begin storing data. - /// The number of bytes of data to store. - /// Required parameter is null - /// and or are invalid. - static public int ReadRequestedBytes(Stream stream, byte[] buffer, int offset, int count) - { - if (stream == null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - // Offset can equal length when buffer and count are 0. - if ((offset < 0) || (offset > buffer.Length)) - { - throw new ArgumentOutOfRangeException(nameof(offset)); - } - - if ((count < 0) || (offset + count > buffer.Length)) - { - throw new ArgumentOutOfRangeException(nameof(count)); - } - - int totalReadCount = 0; - while (count > 0) - { - int readCount = stream.Read(buffer, offset, count); - if (readCount <= 0) - { - break; - } - offset += readCount; - count -= readCount; - totalReadCount += readCount; - } - - return totalReadCount; - } - - /// - /// Copy the contents of one to another. - /// - /// The stream to source data from. - /// The stream to write data to. - /// The buffer to use during copying. - static public void Copy(Stream source, Stream destination, byte[] buffer) - { - if (source == null) - { - throw new ArgumentNullException(nameof(source)); - } - - if (destination == null) - { - throw new ArgumentNullException(nameof(destination)); - } - - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - // Ensure a reasonable size of buffer is used without being prohibitive. - if (buffer.Length < 128) - { - throw new ArgumentException("Buffer is too small", nameof(buffer)); - } - - bool copying = true; - - while (copying) - { - int bytesRead = source.Read(buffer, 0, buffer.Length); - if (bytesRead > 0) - { - destination.Write(buffer, 0, bytesRead); - } - else - { - destination.Flush(); - copying = false; - } - } - } - - /// - /// Copy the contents of one to another. - /// - /// The stream to source data from. - /// The stream to write data to. - /// The buffer to use during copying. - /// The progress handler delegate to use. - /// The minimum between progress updates. - /// The source for this event. - /// The name to use with the event. - /// This form is specialised for use within #Zip to support events during archive operations. - static public void Copy(Stream source, Stream destination, - byte[] buffer, ProgressHandler progressHandler, TimeSpan updateInterval, object sender, string name) - { - Copy(source, destination, buffer, progressHandler, updateInterval, sender, name, -1); - } - - /// - /// Copy the contents of one to another. - /// - /// The stream to source data from. - /// The stream to write data to. - /// The buffer to use during copying. - /// The progress handler delegate to use. - /// The minimum between progress updates. - /// The source for this event. - /// The name to use with the event. - /// A predetermined fixed target value to use with progress updates. - /// If the value is negative the target is calculated by looking at the stream. - /// This form is specialised for use within #Zip to support events during archive operations. - static public void Copy(Stream source, Stream destination, - byte[] buffer, - ProgressHandler progressHandler, TimeSpan updateInterval, - object sender, string name, long fixedTarget) - { - if (source == null) - { - throw new ArgumentNullException(nameof(source)); - } - - if (destination == null) - { - throw new ArgumentNullException(nameof(destination)); - } - - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - // Ensure a reasonable size of buffer is used without being prohibitive. - if (buffer.Length < 128) - { - throw new ArgumentException("Buffer is too small", nameof(buffer)); - } - - if (progressHandler == null) - { - throw new ArgumentNullException(nameof(progressHandler)); - } - - bool copying = true; - - DateTime marker = DateTime.Now; - long processed = 0; - long target = 0; - - if (fixedTarget >= 0) - { - target = fixedTarget; - } - else if (source.CanSeek) - { - target = source.Length - source.Position; - } - - // Always fire 0% progress.. - var args = new ProgressEventArgs(name, processed, target); - progressHandler(sender, args); - - bool progressFired = true; - - while (copying) - { - int bytesRead = source.Read(buffer, 0, buffer.Length); - if (bytesRead > 0) - { - processed += bytesRead; - progressFired = false; - destination.Write(buffer, 0, bytesRead); - } - else - { - destination.Flush(); - copying = false; - } - - if (DateTime.Now - marker > updateInterval) - { - progressFired = true; - marker = DateTime.Now; - args = new ProgressEventArgs(name, processed, target); - progressHandler(sender, args); - - copying = args.ContinueRunning; - } - } - - if (!progressFired) - { - args = new ProgressEventArgs(name, processed, target); - progressHandler(sender, args); - } - } - - /// - /// Initialise an instance of - /// - private StreamUtils() - { - // Do nothing. - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Encryption/PkzipClassic.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Encryption/PkzipClassic.cs deleted file mode 100644 index c39d1603a..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Encryption/PkzipClassic.cs +++ /dev/null @@ -1,490 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Checksum; -using System; -using System.Security.Cryptography; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Encryption -{ - /// - /// PkzipClassic embodies the classic or original encryption facilities used in Pkzip archives. - /// While it has been superceded by more recent and more powerful algorithms, its still in use and - /// is viable for preventing casual snooping - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public abstract class PkzipClassic : SymmetricAlgorithm - { - /// - /// Generates new encryption keys based on given seed - /// - /// The seed value to initialise keys with. - /// A new key value. - static public byte[] GenerateKeys(byte[] seed) - { - if (seed == null) - { - throw new ArgumentNullException(nameof(seed)); - } - - if (seed.Length == 0) - { - throw new ArgumentException("Length is zero", nameof(seed)); - } - - uint[] newKeys = { - 0x12345678, - 0x23456789, - 0x34567890 - }; - - for (int i = 0; i < seed.Length; ++i) - { - newKeys[0] = Crc32.ComputeCrc32(newKeys[0], seed[i]); - newKeys[1] = newKeys[1] + (byte)newKeys[0]; - newKeys[1] = newKeys[1] * 134775813 + 1; - newKeys[2] = Crc32.ComputeCrc32(newKeys[2], (byte)(newKeys[1] >> 24)); - } - - byte[] result = new byte[12]; - result[0] = (byte)(newKeys[0] & 0xff); - result[1] = (byte)((newKeys[0] >> 8) & 0xff); - result[2] = (byte)((newKeys[0] >> 16) & 0xff); - result[3] = (byte)((newKeys[0] >> 24) & 0xff); - result[4] = (byte)(newKeys[1] & 0xff); - result[5] = (byte)((newKeys[1] >> 8) & 0xff); - result[6] = (byte)((newKeys[1] >> 16) & 0xff); - result[7] = (byte)((newKeys[1] >> 24) & 0xff); - result[8] = (byte)(newKeys[2] & 0xff); - result[9] = (byte)((newKeys[2] >> 8) & 0xff); - result[10] = (byte)((newKeys[2] >> 16) & 0xff); - result[11] = (byte)((newKeys[2] >> 24) & 0xff); - return result; - } - } - - /// - /// PkzipClassicCryptoBase provides the low level facilities for encryption - /// and decryption using the PkzipClassic algorithm. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal class PkzipClassicCryptoBase - { - /// - /// Transform a single byte - /// - /// - /// The transformed value - /// - protected byte TransformByte() - { - uint temp = ((keys[2] & 0xFFFF) | 2); - return (byte)((temp * (temp ^ 1)) >> 8); - } - - /// - /// Set the key schedule for encryption/decryption. - /// - /// The data use to set the keys from. - protected void SetKeys(byte[] keyData) - { - if (keyData == null) - { - throw new ArgumentNullException(nameof(keyData)); - } - - if (keyData.Length != 12) - { - throw new InvalidOperationException("Key length is not valid"); - } - - keys = new uint[3]; - keys[0] = (uint)((keyData[3] << 24) | (keyData[2] << 16) | (keyData[1] << 8) | keyData[0]); - keys[1] = (uint)((keyData[7] << 24) | (keyData[6] << 16) | (keyData[5] << 8) | keyData[4]); - keys[2] = (uint)((keyData[11] << 24) | (keyData[10] << 16) | (keyData[9] << 8) | keyData[8]); - } - - /// - /// Update encryption keys - /// - protected void UpdateKeys(byte ch) - { - keys[0] = Crc32.ComputeCrc32(keys[0], ch); - keys[1] = keys[1] + (byte)keys[0]; - keys[1] = keys[1] * 134775813 + 1; - keys[2] = Crc32.ComputeCrc32(keys[2], (byte)(keys[1] >> 24)); - } - - /// - /// Reset the internal state. - /// - protected void Reset() - { - keys[0] = 0; - keys[1] = 0; - keys[2] = 0; - } - - #region Instance Fields - - private uint[] keys; - - #endregion Instance Fields - } - - /// - /// PkzipClassic CryptoTransform for encryption. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal class PkzipClassicEncryptCryptoTransform : PkzipClassicCryptoBase, ICryptoTransform - { - /// - /// Initialise a new instance of - /// - /// The key block to use. - internal PkzipClassicEncryptCryptoTransform(byte[] keyBlock) - { - SetKeys(keyBlock); - } - - #region ICryptoTransform Members - - /// - /// Transforms the specified region of the specified byte array. - /// - /// The input for which to compute the transform. - /// The offset into the byte array from which to begin using data. - /// The number of bytes in the byte array to use as data. - /// The computed transform. - public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount) - { - byte[] result = new byte[inputCount]; - TransformBlock(inputBuffer, inputOffset, inputCount, result, 0); - return result; - } - - /// - /// Transforms the specified region of the input byte array and copies - /// the resulting transform to the specified region of the output byte array. - /// - /// The input for which to compute the transform. - /// The offset into the input byte array from which to begin using data. - /// The number of bytes in the input byte array to use as data. - /// The output to which to write the transform. - /// The offset into the output byte array from which to begin writing data. - /// The number of bytes written. - public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset) - { - for (int i = inputOffset; i < inputOffset + inputCount; ++i) - { - byte oldbyte = inputBuffer[i]; - outputBuffer[outputOffset++] = (byte)(inputBuffer[i] ^ TransformByte()); - UpdateKeys(oldbyte); - } - return inputCount; - } - - /// - /// Gets a value indicating whether the current transform can be reused. - /// - public bool CanReuseTransform - { - get - { - return true; - } - } - - /// - /// Gets the size of the input data blocks in bytes. - /// - public int InputBlockSize - { - get - { - return 1; - } - } - - /// - /// Gets the size of the output data blocks in bytes. - /// - public int OutputBlockSize - { - get - { - return 1; - } - } - - /// - /// Gets a value indicating whether multiple blocks can be transformed. - /// - public bool CanTransformMultipleBlocks - { - get - { - return true; - } - } - - #endregion ICryptoTransform Members - - #region IDisposable Members - - /// - /// Cleanup internal state. - /// - public void Dispose() - { - Reset(); - } - - #endregion IDisposable Members - } - - /// - /// PkzipClassic CryptoTransform for decryption. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal class PkzipClassicDecryptCryptoTransform : PkzipClassicCryptoBase, ICryptoTransform - { - /// - /// Initialise a new instance of . - /// - /// The key block to decrypt with. - internal PkzipClassicDecryptCryptoTransform(byte[] keyBlock) - { - SetKeys(keyBlock); - } - - #region ICryptoTransform Members - - /// - /// Transforms the specified region of the specified byte array. - /// - /// The input for which to compute the transform. - /// The offset into the byte array from which to begin using data. - /// The number of bytes in the byte array to use as data. - /// The computed transform. - public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount) - { - byte[] result = new byte[inputCount]; - TransformBlock(inputBuffer, inputOffset, inputCount, result, 0); - return result; - } - - /// - /// Transforms the specified region of the input byte array and copies - /// the resulting transform to the specified region of the output byte array. - /// - /// The input for which to compute the transform. - /// The offset into the input byte array from which to begin using data. - /// The number of bytes in the input byte array to use as data. - /// The output to which to write the transform. - /// The offset into the output byte array from which to begin writing data. - /// The number of bytes written. - public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset) - { - for (int i = inputOffset; i < inputOffset + inputCount; ++i) - { - var newByte = (byte)(inputBuffer[i] ^ TransformByte()); - outputBuffer[outputOffset++] = newByte; - UpdateKeys(newByte); - } - return inputCount; - } - - /// - /// Gets a value indicating whether the current transform can be reused. - /// - public bool CanReuseTransform - { - get - { - return true; - } - } - - /// - /// Gets the size of the input data blocks in bytes. - /// - public int InputBlockSize - { - get - { - return 1; - } - } - - /// - /// Gets the size of the output data blocks in bytes. - /// - public int OutputBlockSize - { - get - { - return 1; - } - } - - /// - /// Gets a value indicating whether multiple blocks can be transformed. - /// - public bool CanTransformMultipleBlocks - { - get - { - return true; - } - } - - #endregion ICryptoTransform Members - - #region IDisposable Members - - /// - /// Cleanup internal state. - /// - public void Dispose() - { - Reset(); - } - - #endregion IDisposable Members - } - - /// - /// Defines a wrapper object to access the Pkzip algorithm. - /// This class cannot be inherited. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public sealed class PkzipClassicManaged : PkzipClassic - { - /// - /// Get / set the applicable block size in bits. - /// - /// The only valid block size is 8. - public override int BlockSize - { - get - { - return 8; - } - - set - { - if (value != 8) - { - throw new CryptographicException("Block size is invalid"); - } - } - } - - /// - /// Get an array of legal key sizes. - /// - public override KeySizes[] LegalKeySizes - { - get - { - KeySizes[] keySizes = new KeySizes[1]; - keySizes[0] = new KeySizes(12 * 8, 12 * 8, 0); - return keySizes; - } - } - - /// - /// Generate an initial vector. - /// - public override void GenerateIV() - { - // Do nothing. - } - - /// - /// Get an array of legal block sizes. - /// - public override KeySizes[] LegalBlockSizes - { - get - { - KeySizes[] keySizes = new KeySizes[1]; - keySizes[0] = new KeySizes(1 * 8, 1 * 8, 0); - return keySizes; - } - } - - /// - /// Get / set the key value applicable. - /// - public override byte[] Key - { - get - { - if (key_ == null) - { - GenerateKey(); - } - - return (byte[])key_.Clone(); - } - - set - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - - if (value.Length != 12) - { - throw new CryptographicException("Key size is illegal"); - } - - key_ = (byte[])value.Clone(); - } - } - - /// - /// Generate a new random key. - /// - public override void GenerateKey() - { - key_ = new byte[12]; - var rng = RandomNumberGenerator.Create(); - rng.GetBytes(key_); - } - - /// - /// Create an encryptor. - /// - /// The key to use for this encryptor. - /// Initialisation vector for the new encryptor. - /// Returns a new PkzipClassic encryptor - public override ICryptoTransform CreateEncryptor( - byte[] rgbKey, - byte[] rgbIV) - { - key_ = rgbKey; - return new PkzipClassicEncryptCryptoTransform(Key); - } - - /// - /// Create a decryptor. - /// - /// Keys to use for this new decryptor. - /// Initialisation vector for the new decryptor. - /// Returns a new decryptor. - public override ICryptoTransform CreateDecryptor( - byte[] rgbKey, - byte[] rgbIV) - { - key_ = rgbKey; - return new PkzipClassicDecryptCryptoTransform(Key); - } - - #region Instance Fields - - private byte[] key_; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Encryption/ZipAESStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Encryption/ZipAESStream.cs deleted file mode 100644 index d0f2fc4c9..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Encryption/ZipAESStream.cs +++ /dev/null @@ -1,233 +0,0 @@ -using System; -using System.IO; -using System.Security.Cryptography; -//using System.Threading; -//using System.Threading.Tasks; -using MelonLoader.ICSharpCode.SharpZipLib.Core; -using MelonLoader.ICSharpCode.SharpZipLib.Zip; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Encryption -{ - /// - /// Encrypts and decrypts AES ZIP - /// - /// - /// Based on information from http://www.winzip.com/aes_info.htm - /// and http://www.gladman.me.uk/cryptography_technology/fileencrypt/ - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal class ZipAESStream : CryptoStream - { - /// - /// Constructor - /// - /// The stream on which to perform the cryptographic transformation. - /// Instance of ZipAESTransform - /// Read or Write - public ZipAESStream(Stream stream, ZipAESTransform transform, CryptoStreamMode mode) - : base(stream, transform, mode) - { - _stream = stream; - _transform = transform; - _slideBuffer = new byte[1024]; - - // mode: - // CryptoStreamMode.Read means we read from "stream" and pass decrypted to our Read() method. - // Write bypasses this stream and uses the Transform directly. - if (mode != CryptoStreamMode.Read) - { - throw new Exception("ZipAESStream only for read"); - } - } - - // The final n bytes of the AES stream contain the Auth Code. - private const int AUTH_CODE_LENGTH = 10; - - // Blocksize is always 16 here, even for AES-256 which has transform.InputBlockSize of 32. - private const int CRYPTO_BLOCK_SIZE = 16; - - // total length of block + auth code - private const int BLOCK_AND_AUTH = CRYPTO_BLOCK_SIZE + AUTH_CODE_LENGTH; - - private Stream _stream; - private ZipAESTransform _transform; - private byte[] _slideBuffer; - private int _slideBufStartPos; - private int _slideBufFreePos; - - // Buffer block transforms to enable partial reads - private byte[] _transformBuffer = null;// new byte[CRYPTO_BLOCK_SIZE]; - private int _transformBufferFreePos; - private int _transformBufferStartPos; - - // Do we have some buffered data available? - private bool HasBufferedData =>_transformBuffer != null && _transformBufferStartPos < _transformBufferFreePos; - - /// - /// Reads a sequence of bytes from the current CryptoStream into buffer, - /// and advances the position within the stream by the number of bytes read. - /// - public override int Read(byte[] buffer, int offset, int count) - { - // Nothing to do - if (count == 0) - return 0; - - // If we have buffered data, read that first - int nBytes = 0; - if (HasBufferedData) - { - nBytes = ReadBufferedData(buffer, offset, count); - - // Read all requested data from the buffer - if (nBytes == count) - return nBytes; - - offset += nBytes; - count -= nBytes; - } - - // Read more data from the input, if available - if (_slideBuffer != null) - nBytes += ReadAndTransform(buffer, offset, count); - - return nBytes; - } - - /// - /* - public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) - { - var readCount = Read(buffer, offset, count); - return Task.FromResult(readCount); - } - */ - - // Read data from the underlying stream and decrypt it - private int ReadAndTransform(byte[] buffer, int offset, int count) - { - int nBytes = 0; - while (nBytes < count) - { - int bytesLeftToRead = count - nBytes; - - // Calculate buffer quantities vs read-ahead size, and check for sufficient free space - int byteCount = _slideBufFreePos - _slideBufStartPos; - - // Need to handle final block and Auth Code specially, but don't know total data length. - // Maintain a read-ahead equal to the length of (crypto block + Auth Code). - // When that runs out we can detect these final sections. - int lengthToRead = BLOCK_AND_AUTH - byteCount; - if (_slideBuffer.Length - _slideBufFreePos < lengthToRead) - { - // Shift the data to the beginning of the buffer - int iTo = 0; - for (int iFrom = _slideBufStartPos; iFrom < _slideBufFreePos; iFrom++, iTo++) - { - _slideBuffer[iTo] = _slideBuffer[iFrom]; - } - _slideBufFreePos -= _slideBufStartPos; // Note the -= - _slideBufStartPos = 0; - } - int obtained = StreamUtils.ReadRequestedBytes(_stream, _slideBuffer, _slideBufFreePos, lengthToRead); - _slideBufFreePos += obtained; - - // Recalculate how much data we now have - byteCount = _slideBufFreePos - _slideBufStartPos; - if (byteCount >= BLOCK_AND_AUTH) - { - var read = TransformAndBufferBlock(buffer, offset, bytesLeftToRead, CRYPTO_BLOCK_SIZE); - nBytes += read; - offset += read; - } - else - { - // Last round. - if (byteCount > AUTH_CODE_LENGTH) - { - // At least one byte of data plus auth code - int finalBlock = byteCount - AUTH_CODE_LENGTH; - nBytes += TransformAndBufferBlock(buffer, offset, bytesLeftToRead, finalBlock); - } - else if (byteCount < AUTH_CODE_LENGTH) - throw new ZipException("Internal error missed auth code"); // Coding bug - // Final block done. Check Auth code. - byte[] calcAuthCode = _transform.GetAuthCode(); - for (int i = 0; i < AUTH_CODE_LENGTH; i++) - { - if (calcAuthCode[i] != _slideBuffer[_slideBufStartPos + i]) - { - throw new ZipException("AES Authentication Code does not match. This is a super-CRC check on the data in the file after compression and encryption. \r\n" - + "The file may be damaged."); - } - } - - // don't need this any more, so use it as a 'complete' flag - _slideBuffer = null; - - break; // Reached the auth code - } - } - return nBytes; - } - - // read some buffered data - private int ReadBufferedData(byte[] buffer, int offset, int count) - { - int copyCount = Math.Min(count, _transformBufferFreePos - _transformBufferStartPos); - - Array.Copy(_transformBuffer, _transformBufferStartPos, buffer, offset, copyCount); - _transformBufferStartPos += copyCount; - - return copyCount; - } - - // Perform the crypto transform, and buffer the data if less than one block has been requested. - private int TransformAndBufferBlock(byte[] buffer, int offset, int count, int blockSize) - { - // If the requested data is greater than one block, transform it directly into the output - // If it's smaller, do it into a temporary buffer and copy the requested part - bool bufferRequired = (blockSize > count); - - if (bufferRequired && _transformBuffer == null) - _transformBuffer = new byte[CRYPTO_BLOCK_SIZE]; - - var targetBuffer = bufferRequired ? _transformBuffer : buffer; - var targetOffset = bufferRequired ? 0 : offset; - - // Transform the data - _transform.TransformBlock(_slideBuffer, - _slideBufStartPos, - blockSize, - targetBuffer, - targetOffset); - - _slideBufStartPos += blockSize; - - if (!bufferRequired) - { - return blockSize; - } - else - { - Array.Copy(_transformBuffer, 0, buffer, offset, count); - _transformBufferStartPos = count; - _transformBufferFreePos = blockSize; - - return count; - } - } - - /// - /// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. - /// - /// An array of bytes. This method copies count bytes from buffer to the current stream. - /// The byte offset in buffer at which to begin copying bytes to the current stream. - /// The number of bytes to be written to the current stream. - public override void Write(byte[] buffer, int offset, int count) - { - // ZipAESStream is used for reading but not for writing. Writing uses the ZipAESTransform directly. - throw new NotImplementedException(); - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Encryption/ZipAESTransform.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Encryption/ZipAESTransform.cs deleted file mode 100644 index 0fe953e76..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Encryption/ZipAESTransform.cs +++ /dev/null @@ -1,223 +0,0 @@ -using System; -using System.Security.Cryptography; -using MelonLoader.ICSharpCode.SharpZipLib.Core; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Encryption -{ - /// - /// Transforms stream using AES in CTR mode - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal class ZipAESTransform : ICryptoTransform - { - class IncrementalHash : HMACSHA1 - { - bool _finalised; - public IncrementalHash(byte[] key) : base(key) { } - public static IncrementalHash CreateHMAC(string n, byte[] key) => new IncrementalHash(key); - public void AppendData(byte[] buffer, int offset, int count) => TransformBlock(buffer, offset, count, buffer, offset); - public byte[] GetHashAndReset() - { - if (!_finalised) - { - byte[] dummy = new byte[0]; - TransformFinalBlock(dummy, 0, 0); - _finalised = true; - } - return Hash; - } - } - - static class HashAlgorithmName - { - public static string SHA1 = null; - } - - private const int PWD_VER_LENGTH = 2; - - // WinZip use iteration count of 1000 for PBKDF2 key generation - private const int KEY_ROUNDS = 1000; - - // For 128-bit AES (16 bytes) the encryption is implemented as expected. - // For 256-bit AES (32 bytes) WinZip do full 256 bit AES of the nonce to create the encryption - // block but use only the first 16 bytes of it, and discard the second half. - private const int ENCRYPT_BLOCK = 16; - - private int _blockSize; - private readonly ICryptoTransform _encryptor; - private readonly byte[] _counterNonce; - private byte[] _encryptBuffer; - private int _encrPos; - private byte[] _pwdVerifier; - private IncrementalHash _hmacsha1; - private byte[] _authCode = null; - - private bool _writeMode; - - /// - /// Constructor. - /// - /// Password string - /// Random bytes, length depends on encryption strength. - /// 128 bits = 8 bytes, 192 bits = 12 bytes, 256 bits = 16 bytes. - /// The encryption strength, in bytes eg 16 for 128 bits. - /// True when creating a zip, false when reading. For the AuthCode. - /// - public ZipAESTransform(string key, byte[] saltBytes, int blockSize, bool writeMode) - { - if (blockSize != 16 && blockSize != 32) // 24 valid for AES but not supported by Winzip - throw new Exception("Invalid blocksize " + blockSize + ". Must be 16 or 32."); - if (saltBytes.Length != blockSize / 2) - throw new Exception("Invalid salt len. Must be " + blockSize / 2 + " for blocksize " + blockSize); - // initialise the encryption buffer and buffer pos - _blockSize = blockSize; - _encryptBuffer = new byte[_blockSize]; - _encrPos = ENCRYPT_BLOCK; - - // Performs the equivalent of derive_key in Dr Brian Gladman's pwd2key.c - var pdb = new Rfc2898DeriveBytes(key, saltBytes, KEY_ROUNDS); - var rm = Aes.Create(); - rm.Mode = CipherMode.ECB; // No feedback from cipher for CTR mode - _counterNonce = new byte[_blockSize]; - byte[] key1bytes = pdb.GetBytes(_blockSize); - byte[] key2bytes = pdb.GetBytes(_blockSize); - - // Use empty IV for AES - _encryptor = rm.CreateEncryptor(key1bytes, new byte[16]); - _pwdVerifier = pdb.GetBytes(PWD_VER_LENGTH); - // - _hmacsha1 = IncrementalHash.CreateHMAC(HashAlgorithmName.SHA1, key2bytes); - _writeMode = writeMode; - } - - /// - /// Implement the ICryptoTransform method. - /// - public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset) - { - // Pass the data stream to the hash algorithm for generating the Auth Code. - // This does not change the inputBuffer. Do this before decryption for read mode. - if (!_writeMode) - { - _hmacsha1.AppendData(inputBuffer, inputOffset, inputCount); - } - // Encrypt with AES in CTR mode. Regards to Dr Brian Gladman for this. - int ix = 0; - while (ix < inputCount) - { - if (_encrPos == ENCRYPT_BLOCK) - { - /* increment encryption nonce */ - int j = 0; - while (++_counterNonce[j] == 0) - { - ++j; - } - /* encrypt the nonce to form next xor buffer */ - _encryptor.TransformBlock(_counterNonce, 0, _blockSize, _encryptBuffer, 0); - _encrPos = 0; - } - outputBuffer[ix + outputOffset] = (byte)(inputBuffer[ix + inputOffset] ^ _encryptBuffer[_encrPos++]); - // - ix++; - } - if (_writeMode) - { - // This does not change the buffer. - _hmacsha1.AppendData(outputBuffer, outputOffset, inputCount); - } - return inputCount; - } - - /// - /// Returns the 2 byte password verifier - /// - public byte[] PwdVerifier - { - get - { - return _pwdVerifier; - } - } - - /// - /// Returns the 10 byte AUTH CODE to be checked or appended immediately following the AES data stream. - /// - public byte[] GetAuthCode() - { - if (_authCode == null) - { - _authCode = _hmacsha1.GetHashAndReset(); - } - return _authCode; - } - - #region ICryptoTransform Members - - /// - /// Not implemented. - /// - public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount) - { - if(inputCount > 0) - { - throw new NotImplementedException("TransformFinalBlock is not implemented and inputCount is greater than 0"); - } - return Empty.Array(); - } - - /// - /// Gets the size of the input data blocks in bytes. - /// - public int InputBlockSize - { - get - { - return _blockSize; - } - } - - /// - /// Gets the size of the output data blocks in bytes. - /// - public int OutputBlockSize - { - get - { - return _blockSize; - } - } - - /// - /// Gets a value indicating whether multiple blocks can be transformed. - /// - public bool CanTransformMultipleBlocks - { - get - { - return true; - } - } - - /// - /// Gets a value indicating whether the current transform can be reused. - /// - public bool CanReuseTransform - { - get - { - return true; - } - } - - /// - /// Cleanup internal state. - /// - public void Dispose() - { - _encryptor.Dispose(); - } - - #endregion ICryptoTransform Members - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GZIPConstants.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GZIPConstants.cs deleted file mode 100644 index c6420fa2b..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GZIPConstants.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Text; - -namespace MelonLoader.ICSharpCode.SharpZipLib.GZip -{ - /// - /// This class contains constants used for gzip. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "kept for backwards compatibility")] - sealed public class GZipConstants - { - /// - /// First GZip identification byte - /// - public const byte ID1 = 0x1F; - - /// - /// Second GZip identification byte - /// - public const byte ID2 = 0x8B; - - /// - /// Deflate compression method - /// - public const byte CompressionMethodDeflate = 0x8; - - /// - /// Get the GZip specified encoding (CP-1252 if supported, otherwise ASCII) - /// - public static Encoding Encoding - { - get - { - try - { - return Encoding.GetEncoding(1252); - } - catch - { - return Encoding.ASCII; - } - } - } - - } - - /// - /// GZip header flags - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Flags] - public enum GZipFlags: byte - { - /// - /// Text flag hinting that the file is in ASCII - /// - FTEXT = 0x1 << 0, - - /// - /// CRC flag indicating that a CRC16 preceeds the data - /// - FHCRC = 0x1 << 1, - - /// - /// Extra flag indicating that extra fields are present - /// - FEXTRA = 0x1 << 2, - - /// - /// Filename flag indicating that the original filename is present - /// - FNAME = 0x1 << 3, - - /// - /// Flag bit mask indicating that a comment is present - /// - FCOMMENT = 0x1 << 4, - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GZip.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GZip.cs deleted file mode 100644 index 9212e2c03..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GZip.cs +++ /dev/null @@ -1,92 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression; -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.GZip -{ - /// - /// An example class to demonstrate compression and decompression of GZip streams. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public static class GZip - { - /// - /// Decompress the input writing - /// uncompressed data to the output stream - /// - /// The readable stream containing data to decompress. - /// The output stream to receive the decompressed data. - /// Both streams are closed on completion if true. - /// Input or output stream is null - public static void Decompress(Stream inStream, Stream outStream, bool isStreamOwner) - { - if (inStream == null) - throw new ArgumentNullException(nameof(inStream), "Input stream is null"); - - if (outStream == null) - throw new ArgumentNullException(nameof(outStream), "Output stream is null"); - - try - { - using (GZipInputStream gzipInput = new GZipInputStream(inStream)) - { - gzipInput.IsStreamOwner = isStreamOwner; - Core.StreamUtils.Copy(gzipInput, outStream, new byte[4096]); - } - } - finally - { - if (isStreamOwner) - { - // inStream is closed by the GZipInputStream if stream owner - outStream.Dispose(); - } - } - } - - /// - /// Compress the input stream sending - /// result data to output stream - /// - /// The readable stream to compress. - /// The output stream to receive the compressed data. - /// Both streams are closed on completion if true. - /// Deflate buffer size, minimum 512 - /// Deflate compression level, 0-9 - /// Input or output stream is null - /// Buffer Size is smaller than 512 - /// Compression level outside 0-9 - public static void Compress(Stream inStream, Stream outStream, bool isStreamOwner, int bufferSize = 512, int level = 6) - { - if (inStream == null) - throw new ArgumentNullException(nameof(inStream), "Input stream is null"); - - if (outStream == null) - throw new ArgumentNullException(nameof(outStream), "Output stream is null"); - - if (bufferSize < 512) - throw new ArgumentOutOfRangeException(nameof(bufferSize), "Deflate buffer size must be >= 512"); - - if (level < Deflater.NO_COMPRESSION || level > Deflater.BEST_COMPRESSION) - throw new ArgumentOutOfRangeException(nameof(level), "Compression level must be 0-9"); - - try - { - using (GZipOutputStream gzipOutput = new GZipOutputStream(outStream, bufferSize)) - { - gzipOutput.SetLevel(level); - gzipOutput.IsStreamOwner = isStreamOwner; - Core.StreamUtils.Copy(inStream, gzipOutput, new byte[bufferSize]); - } - } - finally - { - if (isStreamOwner) - { - // outStream is closed by the GZipOutputStream if stream owner - inStream.Dispose(); - } - } - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GZipException.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GZipException.cs deleted file mode 100644 index 8d8d55614..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GZipException.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib.GZip -{ - /// - /// GZipException represents exceptions specific to GZip classes and code. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class GZipException : SharpZipBaseException - { - /// - /// Initialise a new instance of . - /// - public GZipException() - { - } - - /// - /// Initialise a new instance of with its message string. - /// - /// A that describes the error. - public GZipException(string message) - : base(message) - { - } - - /// - /// Initialise a new instance of . - /// - /// A that describes the error. - /// The that caused this exception. - public GZipException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the GZipException class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected GZipException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GzipInputStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GzipInputStream.cs deleted file mode 100644 index 680e322d2..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GzipInputStream.cs +++ /dev/null @@ -1,362 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Checksum; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams; -using System; -using System.IO; -using System.Text; - -namespace MelonLoader.ICSharpCode.SharpZipLib.GZip -{ - /// - /// This filter stream is used to decompress a "GZIP" format stream. - /// The "GZIP" format is described baseInputStream RFC 1952. - /// - /// author of the original java version : John Leuner - /// - /// This sample shows how to unzip a gzipped file - /// - /// using System; - /// using System.IO; - /// - /// using MelonLoader.ICSharpCode.SharpZipLib.Core; - /// using MelonLoader.ICSharpCode.SharpZipLib.GZip; - /// - /// class MainClass - /// { - /// public static void Main(string[] args) - /// { - /// using (Stream inStream = new GZipInputStream(File.OpenRead(args[0]))) - /// using (FileStream outStream = File.Create(Path.GetFileNameWithoutExtension(args[0]))) { - /// byte[] buffer = new byte[4096]; - /// StreamUtils.Copy(inStream, outStream, buffer); - /// } - /// } - /// } - /// - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class GZipInputStream : InflaterInputStream - { - #region Instance Fields - - /// - /// CRC-32 value for uncompressed data - /// - protected Crc32 crc; - - /// - /// Flag to indicate if we've read the GZIP header yet for the current member (block of compressed data). - /// This is tracked per-block as the file is parsed. - /// - private bool readGZIPHeader; - - /// - /// Flag to indicate if at least one block in a stream with concatenated blocks was read successfully. - /// This allows us to exit gracefully if downstream data is not in gzip format. - /// - private bool completedLastBlock; - - private string fileName; - - #endregion Instance Fields - - #region Constructors - - /// - /// Creates a GZipInputStream with the default buffer size - /// - /// - /// The stream to read compressed data from (baseInputStream GZIP format) - /// - public GZipInputStream(Stream baseInputStream) - : this(baseInputStream, 4096) - { - } - - /// - /// Creates a GZIPInputStream with the specified buffer size - /// - /// - /// The stream to read compressed data from (baseInputStream GZIP format) - /// - /// - /// Size of the buffer to use - /// - public GZipInputStream(Stream baseInputStream, int size) - : base(baseInputStream, new Inflater(true), size) - { - } - - #endregion Constructors - - #region Stream overrides - - /// - /// Reads uncompressed data into an array of bytes - /// - /// - /// The buffer to read uncompressed data into - /// - /// - /// The offset indicating where the data should be placed - /// - /// - /// The number of uncompressed bytes to be read - /// - /// Returns the number of bytes actually read. - public override int Read(byte[] buffer, int offset, int count) - { - // A GZIP file can contain multiple blocks of compressed data, although this is quite rare. - // A compressed block could potentially be empty, so we need to loop until we reach EOF or - // we find data. - while (true) - { - // If we haven't read the header for this block, read it - if (!readGZIPHeader) - { - // Try to read header. If there is no header (0 bytes available), this is EOF. If there is - // an incomplete header, this will throw an exception. - try - { - if (!ReadHeader()) - { - return 0; - } - } - catch (Exception ex) when (completedLastBlock && (ex is GZipException || ex is EndOfStreamException)) - { - // if we completed the last block (i.e. we're in a stream that has multiple blocks concatenated - // we want to return gracefully from any header parsing exceptions since sometimes there may - // be trailing garbage on a stream - return 0; - } - } - - // Try to read compressed data - int bytesRead = base.Read(buffer, offset, count); - if (bytesRead > 0) - { - crc.Update(new ArraySegment(buffer, offset, bytesRead)); - } - - // If this is the end of stream, read the footer - if (inf.IsFinished) - { - ReadFooter(); - } - - // Attempting to read 0 bytes will never yield any bytesRead, so we return instead of looping forever - if (bytesRead > 0 || count == 0) - { - return bytesRead; - } - } - } - - /// - /// Retrieves the filename header field for the block last read - /// - /// - public string GetFilename() - { - return fileName; - } - - #endregion Stream overrides - - #region Support routines - - private bool ReadHeader() - { - // Initialize CRC for this block - crc = new Crc32(); - - // Make sure there is data in file. We can't rely on ReadLeByte() to fill the buffer, as this could be EOF, - // which is fine, but ReadLeByte() throws an exception if it doesn't find data, so we do this part ourselves. - if (inputBuffer.Available <= 0) - { - inputBuffer.Fill(); - if (inputBuffer.Available <= 0) - { - // No header, EOF. - return false; - } - } - - var headCRC = new Crc32(); - - // 1. Check the two magic bytes - - var magic = inputBuffer.ReadLeByte(); - headCRC.Update(magic); - if (magic != GZipConstants.ID1) - { - throw new GZipException("Error GZIP header, first magic byte doesn't match"); - } - - magic = inputBuffer.ReadLeByte(); - if (magic != GZipConstants.ID2) - { - throw new GZipException("Error GZIP header, second magic byte doesn't match"); - } - headCRC.Update(magic); - - // 2. Check the compression type (must be 8) - var compressionType = inputBuffer.ReadLeByte(); - - if (compressionType != GZipConstants.CompressionMethodDeflate) - { - throw new GZipException("Error GZIP header, data not in deflate format"); - } - headCRC.Update(compressionType); - - // 3. Check the flags - var flagsByte = inputBuffer.ReadLeByte(); - - headCRC.Update(flagsByte); - - // 3.1 Check the reserved bits are zero - - if ((flagsByte & 0xE0) != 0) - { - throw new GZipException("Reserved flag bits in GZIP header != 0"); - } - - var flags = (GZipFlags)flagsByte; - - // 4.-6. Skip the modification time, extra flags, and OS type - for (int i = 0; i < 6; i++) - { - headCRC.Update(inputBuffer.ReadLeByte()); - } - - // 7. Read extra field - if (flags.HasFlag(GZipFlags.FEXTRA)) - { - // XLEN is total length of extra subfields, we will skip them all - var len1 = inputBuffer.ReadLeByte(); - var len2 = inputBuffer.ReadLeByte(); - - headCRC.Update(len1); - headCRC.Update(len2); - - int extraLen = (len2 << 8) | len1; // gzip is LSB first - for (int i = 0; i < extraLen; i++) - { - headCRC.Update(inputBuffer.ReadLeByte()); - } - } - - // 8. Read file name - if (flags.HasFlag(GZipFlags.FNAME)) - { - var fname = new byte[1024]; - var fnamePos = 0; - int readByte; - while ((readByte = inputBuffer.ReadLeByte()) > 0) - { - if (fnamePos < 1024) - { - fname[fnamePos++] = (byte)readByte; - } - headCRC.Update(readByte); - } - - headCRC.Update(readByte); - - fileName = GZipConstants.Encoding.GetString(fname, 0, fnamePos); - } - else - { - fileName = null; - } - - // 9. Read comment - if (flags.HasFlag(GZipFlags.FCOMMENT)) - { - int readByte; - while ((readByte = inputBuffer.ReadLeByte()) > 0) - { - headCRC.Update(readByte); - } - - headCRC.Update(readByte); - } - - // 10. Read header CRC - if (flags.HasFlag(GZipFlags.FHCRC)) - { - int tempByte; - int crcval = inputBuffer.ReadLeByte(); - if (crcval < 0) - { - throw new EndOfStreamException("EOS reading GZIP header"); - } - - tempByte = inputBuffer.ReadLeByte(); - if (tempByte < 0) - { - throw new EndOfStreamException("EOS reading GZIP header"); - } - - crcval = (crcval << 8) | tempByte; - if (crcval != ((int)headCRC.Value & 0xffff)) - { - throw new GZipException("Header CRC value mismatch"); - } - } - - readGZIPHeader = true; - return true; - } - - private void ReadFooter() - { - byte[] footer = new byte[8]; - - // End of stream; reclaim all bytes from inf, read the final byte count, and reset the inflator - long bytesRead = inf.TotalOut & 0xffffffff; - inputBuffer.Available += inf.RemainingInput; - inf.Reset(); - - // Read footer from inputBuffer - int needed = 8; - while (needed > 0) - { - int count = inputBuffer.ReadClearTextBuffer(footer, 8 - needed, needed); - if (count <= 0) - { - throw new EndOfStreamException("EOS reading GZIP footer"); - } - needed -= count; // Jewel Jan 16 - } - - // Calculate CRC - int crcval = (footer[0] & 0xff) | ((footer[1] & 0xff) << 8) | ((footer[2] & 0xff) << 16) | (footer[3] << 24); - if (crcval != (int)crc.Value) - { - throw new GZipException("GZIP crc sum mismatch, theirs \"" + crcval + "\" and ours \"" + (int)crc.Value); - } - - // NOTE The total here is the original total modulo 2 ^ 32. - uint total = - (uint)((uint)footer[4] & 0xff) | - (uint)(((uint)footer[5] & 0xff) << 8) | - (uint)(((uint)footer[6] & 0xff) << 16) | - (uint)((uint)footer[7] << 24); - - if (bytesRead != total) - { - throw new GZipException("Number of bytes mismatch in footer"); - } - - // Mark header read as false so if another header exists, we'll continue reading through the file - readGZIPHeader = false; - - // Indicate that we succeeded on at least one block so we can exit gracefully if there is trailing garbage downstream - completedLastBlock = true; - } - - #endregion Support routines - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GzipOutputStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GzipOutputStream.cs deleted file mode 100644 index ec4689f53..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/GZip/GzipOutputStream.cs +++ /dev/null @@ -1,294 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Checksum; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams; -using System; -using System.IO; -using System.Text; - -namespace MelonLoader.ICSharpCode.SharpZipLib.GZip -{ - /// - /// This filter stream is used to compress a stream into a "GZIP" stream. - /// The "GZIP" format is described in RFC 1952. - /// - /// author of the original java version : John Leuner - /// - /// This sample shows how to gzip a file - /// - /// using System; - /// using System.IO; - /// - /// using MelonLoader.ICSharpCode.SharpZipLib.GZip; - /// using MelonLoader.ICSharpCode.SharpZipLib.Core; - /// - /// class MainClass - /// { - /// public static void Main(string[] args) - /// { - /// using (Stream s = new GZipOutputStream(File.Create(args[0] + ".gz"))) - /// using (FileStream fs = File.OpenRead(args[0])) { - /// byte[] writeData = new byte[4096]; - /// Streamutils.Copy(s, fs, writeData); - /// } - /// } - /// } - /// } - /// - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class GZipOutputStream : DeflaterOutputStream - { - private enum OutputState - { - Header, - Footer, - Finished, - Closed, - }; - - #region Instance Fields - - /// - /// CRC-32 value for uncompressed data - /// - protected Crc32 crc = new Crc32(); - - private OutputState state_ = OutputState.Header; - - private string fileName; - - private GZipFlags flags = 0; - - #endregion Instance Fields - - #region Constructors - - /// - /// Creates a GzipOutputStream with the default buffer size - /// - /// - /// The stream to read data (to be compressed) from - /// - public GZipOutputStream(Stream baseOutputStream) - : this(baseOutputStream, 4096) - { - } - - /// - /// Creates a GZipOutputStream with the specified buffer size - /// - /// - /// The stream to read data (to be compressed) from - /// - /// - /// Size of the buffer to use - /// - public GZipOutputStream(Stream baseOutputStream, int size) : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size) - { - } - - #endregion Constructors - - #region Public API - - /// - /// Sets the active compression level (0-9). The new level will be activated - /// immediately. - /// - /// The compression level to set. - /// - /// Level specified is not supported. - /// - /// - public void SetLevel(int level) - { - if (level < Deflater.NO_COMPRESSION || level > Deflater.BEST_COMPRESSION) - throw new ArgumentOutOfRangeException(nameof(level), "Compression level must be 0-9"); - - deflater_.SetLevel(level); - } - - /// - /// Get the current compression level. - /// - /// The current compression level. - public int GetLevel() - { - return deflater_.GetLevel(); - } - - /// - /// Original filename - /// - public string FileName - { - get => fileName; - set - { - fileName = CleanFilename(value); - if (string.IsNullOrEmpty(fileName)) - { - flags &= ~GZipFlags.FNAME; - } - else - { - flags |= GZipFlags.FNAME; - } - } - } - - #endregion Public API - - #region Stream overrides - - /// - /// Write given buffer to output updating crc - /// - /// Buffer to write - /// Offset of first byte in buf to write - /// Number of bytes to write - public override void Write(byte[] buffer, int offset, int count) - { - if (state_ == OutputState.Header) - { - WriteHeader(); - } - - if (state_ != OutputState.Footer) - { - throw new InvalidOperationException("Write not permitted in current state"); - } - - crc.Update(new ArraySegment(buffer, offset, count)); - base.Write(buffer, offset, count); - } - - /// - /// Writes remaining compressed output data to the output stream - /// and closes it. - /// - protected override void Dispose(bool disposing) - { - try - { - Finish(); - } - finally - { - if (state_ != OutputState.Closed) - { - state_ = OutputState.Closed; - if (IsStreamOwner) - { - baseOutputStream_.Dispose(); - } - } - } - } - - /// - /// Flushes the stream by ensuring the header is written, and then calling Flush - /// on the deflater. - /// - public override void Flush() - { - if (state_ == OutputState.Header) - { - WriteHeader(); - } - - base.Flush(); - } - - #endregion Stream overrides - - #region DeflaterOutputStream overrides - - /// - /// Finish compression and write any footer information required to stream - /// - public override void Finish() - { - // If no data has been written a header should be added. - if (state_ == OutputState.Header) - { - WriteHeader(); - } - - if (state_ == OutputState.Footer) - { - state_ = OutputState.Finished; - base.Finish(); - - var totalin = (uint)(deflater_.TotalIn & 0xffffffff); - var crcval = (uint)(crc.Value & 0xffffffff); - - byte[] gzipFooter; - - unchecked - { - gzipFooter = new byte[] { - (byte) crcval, (byte) (crcval >> 8), - (byte) (crcval >> 16), (byte) (crcval >> 24), - - (byte) totalin, (byte) (totalin >> 8), - (byte) (totalin >> 16), (byte) (totalin >> 24) - }; - } - - baseOutputStream_.Write(gzipFooter, 0, gzipFooter.Length); - } - } - - #endregion DeflaterOutputStream overrides - - #region Support Routines - - private static string CleanFilename(string path) - => path.Substring(path.LastIndexOf('/') + 1); - - private void WriteHeader() - { - if (state_ == OutputState.Header) - { - state_ = OutputState.Footer; - - var mod_time = (int)((DateTime.Now.Ticks - new DateTime(1970, 1, 1).Ticks) / 10000000L); // Ticks give back 100ns intervals - byte[] gzipHeader = { - // The two magic bytes - GZipConstants.ID1, - GZipConstants.ID2, - - // The compression type - GZipConstants.CompressionMethodDeflate, - - // The flags (not set) - (byte)flags, - - // The modification time - (byte) mod_time, (byte) (mod_time >> 8), - (byte) (mod_time >> 16), (byte) (mod_time >> 24), - - // The extra flags - 0, - - // The OS type (unknown) - 255 - }; - - baseOutputStream_.Write(gzipHeader, 0, gzipHeader.Length); - - if (flags.HasFlag(GZipFlags.FNAME)) - { - var fname = GZipConstants.Encoding.GetBytes(fileName); - baseOutputStream_.Write(fname, 0, fname.Length); - - // End filename string with a \0 - baseOutputStream_.Write(new byte[] { 0 }, 0, 1); - } - } - } - - #endregion Support Routines - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/LICENSE.txt b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/LICENSE.txt deleted file mode 100644 index f4597ac92..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/LICENSE.txt +++ /dev/null @@ -1,17 +0,0 @@ -Copyright © 2000-2018 SharpZipLib Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy of this -software and associated documentation files (the "Software"), to deal in the Software -without restriction, including without limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or -substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Lzw/LzwConstants.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Lzw/LzwConstants.cs deleted file mode 100644 index 7b4374122..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Lzw/LzwConstants.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Lzw -{ - /// - /// This class contains constants used for LZW - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "kept for backwards compatibility")] - sealed public class LzwConstants - { - /// - /// Magic number found at start of LZW header: 0x1f 0x9d - /// - public const int MAGIC = 0x1f9d; - - /// - /// Maximum number of bits per code - /// - public const int MAX_BITS = 16; - - /* 3rd header byte: - * bit 0..4 Number of compression bits - * bit 5 Extended header - * bit 6 Free - * bit 7 Block mode - */ - - /// - /// Mask for 'number of compression bits' - /// - public const int BIT_MASK = 0x1f; - - /// - /// Indicates the presence of a fourth header byte - /// - public const int EXTENDED_MASK = 0x20; - - //public const int FREE_MASK = 0x40; - - /// - /// Reserved bits - /// - public const int RESERVED_MASK = 0x60; - - /// - /// Block compression: if table is full and compression rate is dropping, - /// clear the dictionary. - /// - public const int BLOCK_MODE_MASK = 0x80; - - /// - /// LZW file header size (in bytes) - /// - public const int HDR_SIZE = 3; - - /// - /// Initial number of bits per code - /// - public const int INIT_BITS = 9; - - private LzwConstants() - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Lzw/LzwException.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Lzw/LzwException.cs deleted file mode 100644 index fba6b7dd9..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Lzw/LzwException.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Lzw -{ - /// - /// LzwException represents exceptions specific to LZW classes and code. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class LzwException : SharpZipBaseException - { - /// - /// Initialise a new instance of . - /// - public LzwException() - { - } - - /// - /// Initialise a new instance of with its message string. - /// - /// A that describes the error. - public LzwException(string message) - : base(message) - { - } - - /// - /// Initialise a new instance of . - /// - /// A that describes the error. - /// The that caused this exception. - public LzwException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the LzwException class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected LzwException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Lzw/LzwInputStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Lzw/LzwInputStream.cs deleted file mode 100644 index 09d5cbf74..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Lzw/LzwInputStream.cs +++ /dev/null @@ -1,573 +0,0 @@ -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Lzw -{ - /// - /// This filter stream is used to decompress a LZW format stream. - /// Specifically, a stream that uses the LZC compression method. - /// This file format is usually associated with the .Z file extension. - /// - /// See http://en.wikipedia.org/wiki/Compress - /// See http://wiki.wxwidgets.org/Development:_Z_File_Format - /// - /// The file header consists of 3 (or optionally 4) bytes. The first two bytes - /// contain the magic marker "0x1f 0x9d", followed by a byte of flags. - /// - /// Based on Java code by Ronald Tschalar, which in turn was based on the unlzw.c - /// code in the gzip package. - /// - /// This sample shows how to unzip a compressed file - /// - /// using System; - /// using System.IO; - /// - /// using MelonLoader.ICSharpCode.SharpZipLib.Core; - /// using MelonLoader.ICSharpCode.SharpZipLib.LZW; - /// - /// class MainClass - /// { - /// public static void Main(string[] args) - /// { - /// using (Stream inStream = new LzwInputStream(File.OpenRead(args[0]))) - /// using (FileStream outStream = File.Create(Path.GetFileNameWithoutExtension(args[0]))) { - /// byte[] buffer = new byte[4096]; - /// StreamUtils.Copy(inStream, outStream, buffer); - /// // OR - /// inStream.Read(buffer, 0, buffer.Length); - /// // now do something with the buffer - /// } - /// } - /// } - /// - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class LzwInputStream : Stream - { - /// - /// Gets or sets a flag indicating ownership of underlying stream. - /// When the flag is true will close the underlying stream also. - /// - /// The default value is true. - public bool IsStreamOwner { get; set; } = true; - - /// - /// Creates a LzwInputStream - /// - /// - /// The stream to read compressed data from (baseInputStream LZW format) - /// - public LzwInputStream(Stream baseInputStream) - { - this.baseInputStream = baseInputStream; - } - - /// - /// See - /// - /// - public override int ReadByte() - { - int b = Read(one, 0, 1); - if (b == 1) - return (one[0] & 0xff); - return -1; - } - - /// - /// Reads decompressed data into the provided buffer byte array - /// - /// - /// The array to read and decompress data into - /// - /// - /// The offset indicating where the data should be placed - /// - /// - /// The number of bytes to decompress - /// - /// The number of bytes read. Zero signals the end of stream - public override int Read(byte[] buffer, int offset, int count) - { - if (!headerParsed) - ParseHeader(); - - if (eof) - return 0; - - int start = offset; - - /* Using local copies of various variables speeds things up by as - * much as 30% in Java! Performance not tested in C#. - */ - int[] lTabPrefix = tabPrefix; - byte[] lTabSuffix = tabSuffix; - byte[] lStack = stack; - int lNBits = nBits; - int lMaxCode = maxCode; - int lMaxMaxCode = maxMaxCode; - int lBitMask = bitMask; - int lOldCode = oldCode; - byte lFinChar = finChar; - int lStackP = stackP; - int lFreeEnt = freeEnt; - byte[] lData = data; - int lBitPos = bitPos; - - // empty stack if stuff still left - int sSize = lStack.Length - lStackP; - if (sSize > 0) - { - int num = (sSize >= count) ? count : sSize; - Array.Copy(lStack, lStackP, buffer, offset, num); - offset += num; - count -= num; - lStackP += num; - } - - if (count == 0) - { - stackP = lStackP; - return offset - start; - } - - // loop, filling local buffer until enough data has been decompressed - MainLoop: - do - { - if (end < EXTRA) - { - Fill(); - } - - int bitIn = (got > 0) ? (end - end % lNBits) << 3 : - (end << 3) - (lNBits - 1); - - while (lBitPos < bitIn) - { - #region A - - // handle 1-byte reads correctly - if (count == 0) - { - nBits = lNBits; - maxCode = lMaxCode; - maxMaxCode = lMaxMaxCode; - bitMask = lBitMask; - oldCode = lOldCode; - finChar = lFinChar; - stackP = lStackP; - freeEnt = lFreeEnt; - bitPos = lBitPos; - - return offset - start; - } - - // check for code-width expansion - if (lFreeEnt > lMaxCode) - { - int nBytes = lNBits << 3; - lBitPos = (lBitPos - 1) + - nBytes - (lBitPos - 1 + nBytes) % nBytes; - - lNBits++; - lMaxCode = (lNBits == maxBits) ? lMaxMaxCode : - (1 << lNBits) - 1; - - lBitMask = (1 << lNBits) - 1; - lBitPos = ResetBuf(lBitPos); - goto MainLoop; - } - - #endregion A - - #region B - - // read next code - int pos = lBitPos >> 3; - int code = (((lData[pos] & 0xFF) | - ((lData[pos + 1] & 0xFF) << 8) | - ((lData[pos + 2] & 0xFF) << 16)) >> - (lBitPos & 0x7)) & lBitMask; - - lBitPos += lNBits; - - // handle first iteration - if (lOldCode == -1) - { - if (code >= 256) - throw new LzwException("corrupt input: " + code + " > 255"); - - lFinChar = (byte)(lOldCode = code); - buffer[offset++] = lFinChar; - count--; - continue; - } - - // handle CLEAR code - if (code == TBL_CLEAR && blockMode) - { - Array.Copy(zeros, 0, lTabPrefix, 0, zeros.Length); - lFreeEnt = TBL_FIRST - 1; - - int nBytes = lNBits << 3; - lBitPos = (lBitPos - 1) + nBytes - (lBitPos - 1 + nBytes) % nBytes; - lNBits = LzwConstants.INIT_BITS; - lMaxCode = (1 << lNBits) - 1; - lBitMask = lMaxCode; - - // Code tables reset - - lBitPos = ResetBuf(lBitPos); - goto MainLoop; - } - - #endregion B - - #region C - - // setup - int inCode = code; - lStackP = lStack.Length; - - // Handle KwK case - if (code >= lFreeEnt) - { - if (code > lFreeEnt) - { - throw new LzwException("corrupt input: code=" + code + - ", freeEnt=" + lFreeEnt); - } - - lStack[--lStackP] = lFinChar; - code = lOldCode; - } - - // Generate output characters in reverse order - while (code >= 256) - { - lStack[--lStackP] = lTabSuffix[code]; - code = lTabPrefix[code]; - } - - lFinChar = lTabSuffix[code]; - buffer[offset++] = lFinChar; - count--; - - // And put them out in forward order - sSize = lStack.Length - lStackP; - int num = (sSize >= count) ? count : sSize; - Array.Copy(lStack, lStackP, buffer, offset, num); - offset += num; - count -= num; - lStackP += num; - - #endregion C - - #region D - - // generate new entry in table - if (lFreeEnt < lMaxMaxCode) - { - lTabPrefix[lFreeEnt] = lOldCode; - lTabSuffix[lFreeEnt] = lFinChar; - lFreeEnt++; - } - - // Remember previous code - lOldCode = inCode; - - // if output buffer full, then return - if (count == 0) - { - nBits = lNBits; - maxCode = lMaxCode; - bitMask = lBitMask; - oldCode = lOldCode; - finChar = lFinChar; - stackP = lStackP; - freeEnt = lFreeEnt; - bitPos = lBitPos; - - return offset - start; - } - - #endregion D - } // while - - lBitPos = ResetBuf(lBitPos); - } while (got > 0); // do..while - - nBits = lNBits; - maxCode = lMaxCode; - bitMask = lBitMask; - oldCode = lOldCode; - finChar = lFinChar; - stackP = lStackP; - freeEnt = lFreeEnt; - bitPos = lBitPos; - - eof = true; - return offset - start; - } - - /// - /// Moves the unread data in the buffer to the beginning and resets - /// the pointers. - /// - /// - /// - private int ResetBuf(int bitPosition) - { - int pos = bitPosition >> 3; - Array.Copy(data, pos, data, 0, end - pos); - end -= pos; - return 0; - } - - private void Fill() - { - got = baseInputStream.Read(data, end, data.Length - 1 - end); - if (got > 0) - { - end += got; - } - } - - private void ParseHeader() - { - headerParsed = true; - - byte[] hdr = new byte[LzwConstants.HDR_SIZE]; - - int result = baseInputStream.Read(hdr, 0, hdr.Length); - - // Check the magic marker - if (result < 0) - throw new LzwException("Failed to read LZW header"); - - if (hdr[0] != (LzwConstants.MAGIC >> 8) || hdr[1] != (LzwConstants.MAGIC & 0xff)) - { - throw new LzwException(String.Format( - "Wrong LZW header. Magic bytes don't match. 0x{0:x2} 0x{1:x2}", - hdr[0], hdr[1])); - } - - // Check the 3rd header byte - blockMode = (hdr[2] & LzwConstants.BLOCK_MODE_MASK) > 0; - maxBits = hdr[2] & LzwConstants.BIT_MASK; - - if (maxBits > LzwConstants.MAX_BITS) - { - throw new LzwException("Stream compressed with " + maxBits + - " bits, but decompression can only handle " + - LzwConstants.MAX_BITS + " bits."); - } - - if ((hdr[2] & LzwConstants.RESERVED_MASK) > 0) - { - throw new LzwException("Unsupported bits set in the header."); - } - - // Initialize variables - maxMaxCode = 1 << maxBits; - nBits = LzwConstants.INIT_BITS; - maxCode = (1 << nBits) - 1; - bitMask = maxCode; - oldCode = -1; - finChar = 0; - freeEnt = blockMode ? TBL_FIRST : 256; - - tabPrefix = new int[1 << maxBits]; - tabSuffix = new byte[1 << maxBits]; - stack = new byte[1 << maxBits]; - stackP = stack.Length; - - for (int idx = 255; idx >= 0; idx--) - tabSuffix[idx] = (byte)idx; - } - - #region Stream Overrides - - /// - /// Gets a value indicating whether the current stream supports reading - /// - public override bool CanRead - { - get - { - return baseInputStream.CanRead; - } - } - - /// - /// Gets a value of false indicating seeking is not supported for this stream. - /// - public override bool CanSeek - { - get - { - return false; - } - } - - /// - /// Gets a value of false indicating that this stream is not writeable. - /// - public override bool CanWrite - { - get - { - return false; - } - } - - /// - /// A value representing the length of the stream in bytes. - /// - public override long Length - { - get - { - return got; - } - } - - /// - /// The current position within the stream. - /// Throws a NotSupportedException when attempting to set the position - /// - /// Attempting to set the position - public override long Position - { - get - { - return baseInputStream.Position; - } - set - { - throw new NotSupportedException("InflaterInputStream Position not supported"); - } - } - - /// - /// Flushes the baseInputStream - /// - public override void Flush() - { - baseInputStream.Flush(); - } - - /// - /// Sets the position within the current stream - /// Always throws a NotSupportedException - /// - /// The relative offset to seek to. - /// The defining where to seek from. - /// The new position in the stream. - /// Any access - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("Seek not supported"); - } - - /// - /// Set the length of the current stream - /// Always throws a NotSupportedException - /// - /// The new length value for the stream. - /// Any access - public override void SetLength(long value) - { - throw new NotSupportedException("InflaterInputStream SetLength not supported"); - } - - /// - /// Writes a sequence of bytes to stream and advances the current position - /// This method always throws a NotSupportedException - /// - /// The buffer containing data to write. - /// The offset of the first byte to write. - /// The number of bytes to write. - /// Any access - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotSupportedException("InflaterInputStream Write not supported"); - } - - /// - /// Writes one byte to the current stream and advances the current position - /// Always throws a NotSupportedException - /// - /// The byte to write. - /// Any access - public override void WriteByte(byte value) - { - throw new NotSupportedException("InflaterInputStream WriteByte not supported"); - } - - /// - /// Closes the input stream. When - /// is true the underlying stream is also closed. - /// - protected override void Dispose(bool disposing) - { - if (!isClosed) - { - isClosed = true; - if (IsStreamOwner) - { - baseInputStream.Dispose(); - } - } - } - - #endregion Stream Overrides - - #region Instance Fields - - private Stream baseInputStream; - - /// - /// Flag indicating wether this instance has been closed or not. - /// - private bool isClosed; - - private readonly byte[] one = new byte[1]; - private bool headerParsed; - - // string table stuff - private const int TBL_CLEAR = 0x100; - - private const int TBL_FIRST = TBL_CLEAR + 1; - - private int[] tabPrefix; - private byte[] tabSuffix; - private readonly int[] zeros = new int[256]; - private byte[] stack; - - // various state - private bool blockMode; - - private int nBits; - private int maxBits; - private int maxMaxCode; - private int maxCode; - private int bitMask; - private int oldCode; - private byte finChar; - private int stackP; - private int freeEnt; - - // input buffer - private readonly byte[] data = new byte[1024 * 8]; - - private int bitPos; - private int end; - private int got; - private bool eof; - private const int EXTRA = 64; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/README.md b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/README.md deleted file mode 100644 index a27570f45..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# SharpZipLib [![Build Status](https://github.com/icsharpcode/SharpZipLib/actions/workflows/build-test.yml/badge.svg?branch=master)](https://github.com/icsharpcode/SharpZipLib/actions/workflows/build-test.yml) [![NuGet Version](https://img.shields.io/nuget/v/SharpZipLib.svg)](https://www.nuget.org/packages/SharpZipLib/) - -Introduction ------------- - -SharpZipLib (\#ziplib, formerly NZipLib) is a compression library that supports Zip files using both stored and deflate compression methods, PKZIP 2.0 style and AES encryption, tar with GNU long filename extensions, GZip, zlib and raw deflate, as well as BZip2. Zip64 is supported while Deflate64 is not yet supported. It is implemented as an assembly (installable in the GAC), and thus can easily be incorporated into other projects (in any .NET language). The creator of SharpZipLib put it this way: "I've ported the zip library over to C\# because I needed gzip/zip compression and I didn't want to use libzip.dll or something like this. I want all in pure C\#." - -SharpZipLib was originally ported from the [GNU Classpath](http://www.gnu.org/software/classpath/) java.util.zip library for use with [SharpDevelop](http://www.icsharpcode.net/OpenSource/SD), which needed gzip/zip compression. bzip2 compression and tar archiving were added later due to popular demand. - -The [SharpZipLib homepage](http://icsharpcode.github.io/SharpZipLib/) has precompiled libraries available for download, [API documentation](https://icsharpcode.github.io/SharpZipLib/help/api/index.html), [release history](https://github.com/icsharpcode/SharpZipLib/wiki/Release-History), samples and more. - -License -------- - -This software is now released under the [MIT License](https://opensource.org/licenses/MIT). Please see [issue #103](https://github.com/icsharpcode/SharpZipLib/issues/103) for more information on the relicensing effort. - -Previous versions were released under the [GNU General Public License, version 2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) with an [exception](http://www.gnu.org/software/classpath/license.html) which allowed linking with non-GPL programs. - -Namespace layout ----------------- - -| Module | Namespace | -|:----------------:|:-----------------------------| -|BZip2 implementation|ICSharpCode.SharpZipLib.BZip2.\*| -|Checksum implementation|ICSharpCode.SharpZipLib.Checksum.\*| -|Core utilities / interfaces|ICSharpCode.SharpZipLib.Core.\*| -|Encryption implementation|ICSharpCode.SharpZipLib.Encryption.\*| -|GZip implementation|ICSharpCode.SharpZipLib.GZip.\*| -|LZW implementation|ICSharpCode.SharpZipLib.Lzw.\*| -|Tar implementation|ICSharpCode.SharpZipLib.Tar.\*| -|ZIP implementation|ICSharpCode.SharpZipLib.Zip.\*| -|Inflater/Deflater|ICSharpCode.SharpZipLib.Zip.Compression.\*| -|Inflater/Deflater streams|ICSharpCode.SharpZipLib.Zip.Compression.Streams.\*| - -Credits -------- - -SharpZipLib was initially developed by [Mike Krüger](http://www.icsharpcode.net/pub/relations/krueger.aspx). Past maintainers are John Reilly, David Pierson and Neil McNeight. - -And thanks to all the people that contributed features, bug fixes and issue reports. - diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/InvalidHeaderException.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/InvalidHeaderException.cs deleted file mode 100644 index 544a73c05..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/InvalidHeaderException.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Tar -{ - /// - /// This exception is used to indicate that there is a problem - /// with a TAR archive header. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class InvalidHeaderException : TarException - { - /// - /// Initialise a new instance of the InvalidHeaderException class. - /// - public InvalidHeaderException() - { - } - - /// - /// Initialises a new instance of the InvalidHeaderException class with a specified message. - /// - /// Message describing the exception cause. - public InvalidHeaderException(string message) - : base(message) - { - } - - /// - /// Initialise a new instance of InvalidHeaderException - /// - /// Message describing the problem. - /// The exception that is the cause of the current exception. - public InvalidHeaderException(string message, Exception exception) - : base(message, exception) - { - } - - /// - /// Initializes a new instance of the InvalidHeaderException class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected InvalidHeaderException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarArchive.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarArchive.cs deleted file mode 100644 index 89aa632ad..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarArchive.cs +++ /dev/null @@ -1,1029 +0,0 @@ -using System; -using System.IO; -using System.Text; -using MelonLoader.ICSharpCode.SharpZipLib.Core; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Tar -{ - /// - /// Used to advise clients of 'events' while processing archives - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public delegate void ProgressMessageHandler(TarArchive archive, TarEntry entry, string message); - - /// - /// The TarArchive class implements the concept of a - /// 'Tape Archive'. A tar archive is a series of entries, each of - /// which represents a file system object. Each entry in - /// the archive consists of a header block followed by 0 or more data blocks. - /// Directory entries consist only of the header block, and are followed by entries - /// for the directory's contents. File entries consist of a - /// header followed by the number of blocks needed to - /// contain the file's contents. All entries are written on - /// block boundaries. Blocks are 512 bytes long. - /// - /// TarArchives are instantiated in either read or write mode, - /// based upon whether they are instantiated with an InputStream - /// or an OutputStream. Once instantiated TarArchives read/write - /// mode can not be changed. - /// - /// There is currently no support for random access to tar archives. - /// However, it seems that subclassing TarArchive, and using the - /// TarBuffer.CurrentRecord and TarBuffer.CurrentBlock - /// properties, this would be rather trivial. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class TarArchive : IDisposable - { - /// - /// Client hook allowing detailed information to be reported during processing - /// - public event ProgressMessageHandler ProgressMessageEvent; - - /// - /// Raises the ProgressMessage event - /// - /// The TarEntry for this event - /// message for this event. Null is no message - protected virtual void OnProgressMessageEvent(TarEntry entry, string message) - { - ProgressMessageHandler handler = ProgressMessageEvent; - if (handler != null) - { - handler(this, entry, message); - } - } - - #region Constructors - - /// - /// Constructor for a default . - /// - protected TarArchive() - { - } - - /// - /// Initialise a TarArchive for input. - /// - /// The to use for input. - protected TarArchive(TarInputStream stream) - { - if (stream == null) - { - throw new ArgumentNullException(nameof(stream)); - } - - tarIn = stream; - } - - /// - /// Initialise a TarArchive for output. - /// - /// The to use for output. - protected TarArchive(TarOutputStream stream) - { - if (stream == null) - { - throw new ArgumentNullException(nameof(stream)); - } - - tarOut = stream; - } - - #endregion Constructors - - #region Static factory methods - - /// - /// The InputStream based constructors create a TarArchive for the - /// purposes of extracting or listing a tar archive. Thus, use - /// these constructors when you wish to extract files from or list - /// the contents of an existing tar archive. - /// - /// The stream to retrieve archive data from. - /// Returns a new suitable for reading from. - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public static TarArchive CreateInputTarArchive(Stream inputStream) - { - return CreateInputTarArchive(inputStream, null); - } - - /// - /// The InputStream based constructors create a TarArchive for the - /// purposes of extracting or listing a tar archive. Thus, use - /// these constructors when you wish to extract files from or list - /// the contents of an existing tar archive. - /// - /// The stream to retrieve archive data from. - /// The used for the Name fields, or null for ASCII only - /// Returns a new suitable for reading from. - public static TarArchive CreateInputTarArchive(Stream inputStream, Encoding nameEncoding) - { - if (inputStream == null) - { - throw new ArgumentNullException(nameof(inputStream)); - } - - var tarStream = inputStream as TarInputStream; - - TarArchive result; - if (tarStream != null) - { - result = new TarArchive(tarStream); - } - else - { - result = CreateInputTarArchive(inputStream, TarBuffer.DefaultBlockFactor, nameEncoding); - } - return result; - } - - /// - /// Create TarArchive for reading setting block factor - /// - /// A stream containing the tar archive contents - /// The blocking factor to apply - /// Returns a suitable for reading. - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public static TarArchive CreateInputTarArchive(Stream inputStream, int blockFactor) - { - return CreateInputTarArchive(inputStream, blockFactor, null); - } - - /// - /// Create TarArchive for reading setting block factor - /// - /// A stream containing the tar archive contents - /// The blocking factor to apply - /// The used for the Name fields, or null for ASCII only - /// Returns a suitable for reading. - public static TarArchive CreateInputTarArchive(Stream inputStream, int blockFactor, Encoding nameEncoding) - { - if (inputStream == null) - { - throw new ArgumentNullException(nameof(inputStream)); - } - - if (inputStream is TarInputStream) - { - throw new ArgumentException("TarInputStream not valid"); - } - - return new TarArchive(new TarInputStream(inputStream, blockFactor, nameEncoding)); - } - /// - /// Create a TarArchive for writing to, using the default blocking factor - /// - /// The to write to - /// The used for the Name fields, or null for ASCII only - /// Returns a suitable for writing. - public static TarArchive CreateOutputTarArchive(Stream outputStream, Encoding nameEncoding) - { - if (outputStream == null) - { - throw new ArgumentNullException(nameof(outputStream)); - } - - var tarStream = outputStream as TarOutputStream; - - TarArchive result; - if (tarStream != null) - { - result = new TarArchive(tarStream); - } - else - { - result = CreateOutputTarArchive(outputStream, TarBuffer.DefaultBlockFactor, nameEncoding); - } - return result; - } - /// - /// Create a TarArchive for writing to, using the default blocking factor - /// - /// The to write to - /// Returns a suitable for writing. - public static TarArchive CreateOutputTarArchive(Stream outputStream) - { - return CreateOutputTarArchive(outputStream, null); - } - - /// - /// Create a tar archive for writing. - /// - /// The stream to write to - /// The blocking factor to use for buffering. - /// Returns a suitable for writing. - public static TarArchive CreateOutputTarArchive(Stream outputStream, int blockFactor) - { - return CreateOutputTarArchive(outputStream, blockFactor, null); - } - /// - /// Create a tar archive for writing. - /// - /// The stream to write to - /// The blocking factor to use for buffering. - /// The used for the Name fields, or null for ASCII only - /// Returns a suitable for writing. - public static TarArchive CreateOutputTarArchive(Stream outputStream, int blockFactor, Encoding nameEncoding) - { - if (outputStream == null) - { - throw new ArgumentNullException(nameof(outputStream)); - } - - if (outputStream is TarOutputStream) - { - throw new ArgumentException("TarOutputStream is not valid"); - } - - return new TarArchive(new TarOutputStream(outputStream, blockFactor, nameEncoding)); - } - - #endregion Static factory methods - - /// - /// Set the flag that determines whether existing files are - /// kept, or overwritten during extraction. - /// - /// - /// If true, do not overwrite existing files. - /// - public void SetKeepOldFiles(bool keepExistingFiles) - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - keepOldFiles = keepExistingFiles; - } - - /// - /// Get/set the ascii file translation flag. If ascii file translation - /// is true, then the file is checked to see if it a binary file or not. - /// If the flag is true and the test indicates it is ascii text - /// file, it will be translated. The translation converts the local - /// operating system's concept of line ends into the UNIX line end, - /// '\n', which is the defacto standard for a TAR archive. This makes - /// text files compatible with UNIX. - /// - public bool AsciiTranslate - { - get - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - return asciiTranslate; - } - - set - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - asciiTranslate = value; - } - } - - /// - /// Set the ascii file translation flag. - /// - /// - /// If true, translate ascii text files. - /// - [Obsolete("Use the AsciiTranslate property")] - public void SetAsciiTranslation(bool translateAsciiFiles) - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - asciiTranslate = translateAsciiFiles; - } - - /// - /// PathPrefix is added to entry names as they are written if the value is not null. - /// A slash character is appended after PathPrefix - /// - public string PathPrefix - { - get - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - return pathPrefix; - } - - set - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - pathPrefix = value; - } - } - - /// - /// RootPath is removed from entry names if it is found at the - /// beginning of the name. - /// - public string RootPath - { - get - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - return rootPath; - } - - set - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - // Convert to forward slashes for matching. Trim trailing / for correct final path - rootPath = value.Replace('\\', '/').TrimEnd('/'); - } - } - - /// - /// Set user and group information that will be used to fill in the - /// tar archive's entry headers. This information is based on that available - /// for the linux operating system, which is not always available on other - /// operating systems. TarArchive allows the programmer to specify values - /// to be used in their place. - /// is set to true by this call. - /// - /// - /// The user id to use in the headers. - /// - /// - /// The user name to use in the headers. - /// - /// - /// The group id to use in the headers. - /// - /// - /// The group name to use in the headers. - /// - public void SetUserInfo(int userId, string userName, int groupId, string groupName) - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - this.userId = userId; - this.userName = userName; - this.groupId = groupId; - this.groupName = groupName; - applyUserInfoOverrides = true; - } - - /// - /// Get or set a value indicating if overrides defined by SetUserInfo should be applied. - /// - /// If overrides are not applied then the values as set in each header will be used. - public bool ApplyUserInfoOverrides - { - get - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - return applyUserInfoOverrides; - } - - set - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - applyUserInfoOverrides = value; - } - } - - /// - /// Get the archive user id. - /// See ApplyUserInfoOverrides for detail - /// on how to allow setting values on a per entry basis. - /// - /// - /// The current user id. - /// - public int UserId - { - get - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - return userId; - } - } - - /// - /// Get the archive user name. - /// See ApplyUserInfoOverrides for detail - /// on how to allow setting values on a per entry basis. - /// - /// - /// The current user name. - /// - public string UserName - { - get - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - return userName; - } - } - - /// - /// Get the archive group id. - /// See ApplyUserInfoOverrides for detail - /// on how to allow setting values on a per entry basis. - /// - /// - /// The current group id. - /// - public int GroupId - { - get - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - return groupId; - } - } - - /// - /// Get the archive group name. - /// See ApplyUserInfoOverrides for detail - /// on how to allow setting values on a per entry basis. - /// - /// - /// The current group name. - /// - public string GroupName - { - get - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - return groupName; - } - } - - /// - /// Get the archive's record size. Tar archives are composed of - /// a series of RECORDS each containing a number of BLOCKS. - /// This allowed tar archives to match the IO characteristics of - /// the physical device being used. Archives are expected - /// to be properly "blocked". - /// - /// - /// The record size this archive is using. - /// - public int RecordSize - { - get - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - if (tarIn != null) - { - return tarIn.RecordSize; - } - else if (tarOut != null) - { - return tarOut.RecordSize; - } - return TarBuffer.DefaultRecordSize; - } - } - - /// - /// Sets the IsStreamOwner property on the underlying stream. - /// Set this to false to prevent the Close of the TarArchive from closing the stream. - /// - public bool IsStreamOwner - { - set - { - if (tarIn != null) - { - tarIn.IsStreamOwner = value; - } - else - { - tarOut.IsStreamOwner = value; - } - } - } - - /// - /// Close the archive. - /// - [Obsolete("Use Close instead")] - public void CloseArchive() - { - Close(); - } - - /// - /// Perform the "list" command for the archive contents. - /// - /// NOTE That this method uses the progress event to actually list - /// the contents. If the progress display event is not set, nothing will be listed! - /// - public void ListContents() - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - while (true) - { - TarEntry entry = tarIn.GetNextEntry(); - - if (entry == null) - { - break; - } - OnProgressMessageEvent(entry, null); - } - } - - /// - /// Perform the "extract" command and extract the contents of the archive. - /// - /// - /// The destination directory into which to extract. - /// - public void ExtractContents(string destinationDirectory) - => ExtractContents(destinationDirectory, false); - - /// - /// Perform the "extract" command and extract the contents of the archive. - /// - /// - /// The destination directory into which to extract. - /// - /// Allow parent directory traversal in file paths (e.g. ../file) - public void ExtractContents(string destinationDirectory, bool allowParentTraversal) - { - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - var fullDistDir = Path.GetFullPath(destinationDirectory); - - while (true) - { - TarEntry entry = tarIn.GetNextEntry(); - - if (entry == null) - { - break; - } - - if (entry.TarHeader.TypeFlag == TarHeader.LF_LINK || entry.TarHeader.TypeFlag == TarHeader.LF_SYMLINK) - continue; - - ExtractEntry(fullDistDir, entry, allowParentTraversal); - } - } - - /// - /// Extract an entry from the archive. This method assumes that the - /// tarIn stream has been properly set with a call to GetNextEntry(). - /// - /// - /// The destination directory into which to extract. - /// - /// - /// The TarEntry returned by tarIn.GetNextEntry(). - /// - /// Allow parent directory traversal in file paths (e.g. ../file) - private void ExtractEntry(string destDir, TarEntry entry, bool allowParentTraversal) - { - OnProgressMessageEvent(entry, null); - - string name = entry.Name; - - if (Path.IsPathRooted(name)) - { - // NOTE: - // for UNC names... \\machine\share\zoom\beet.txt gives \zoom\beet.txt - name = name.Substring(Path.GetPathRoot(name).Length); - } - - name = name.Replace('/', Path.DirectorySeparatorChar); - - string destFile = Path.Combine(destDir, name); - var destFileDir = Path.GetDirectoryName(Path.GetFullPath(destFile)) ?? ""; - - if (!allowParentTraversal && !destFileDir.StartsWith(destDir, StringComparison.InvariantCultureIgnoreCase)) - { - throw new InvalidNameException("Parent traversal in paths is not allowed"); - } - - if (entry.IsDirectory) - { - EnsureDirectoryExists(destFile); - } - else - { - string parentDirectory = Path.GetDirectoryName(destFile); - EnsureDirectoryExists(parentDirectory); - - bool process = true; - var fileInfo = new FileInfo(destFile); - if (fileInfo.Exists) - { - if (keepOldFiles) - { - OnProgressMessageEvent(entry, "Destination file already exists"); - process = false; - } - else if ((fileInfo.Attributes & FileAttributes.ReadOnly) != 0) - { - OnProgressMessageEvent(entry, "Destination file already exists, and is read-only"); - process = false; - } - } - - if (process) - { - using (var outputStream = File.Create(destFile)) - { - if (this.asciiTranslate) - { - // May need to translate the file. - ExtractAndTranslateEntry(destFile, outputStream); - } - else - { - // If translation is disabled, just copy the entry across directly. - tarIn.CopyEntryContents(outputStream); - } - } - } - } - } - - // Extract a TAR entry, and perform an ASCII translation if required. - private void ExtractAndTranslateEntry(string destFile, Stream outputStream) - { - bool asciiTrans = !IsBinary(destFile); - - if (asciiTrans) - { - using (var outw = new StreamWriter(outputStream, new UTF8Encoding(false), 1024)) - { - byte[] rdbuf = new byte[32 * 1024]; - - while (true) - { - int numRead = tarIn.Read(rdbuf, 0, rdbuf.Length); - - if (numRead <= 0) - { - break; - } - - for (int off = 0, b = 0; b < numRead; ++b) - { - if (rdbuf[b] == 10) - { - string s = Encoding.ASCII.GetString(rdbuf, off, (b - off)); - outw.WriteLine(s); - off = b + 1; - } - } - } - } - } - else - { - // No translation required. - tarIn.CopyEntryContents(outputStream); - } - } - - /// - /// Write an entry to the archive. This method will call the putNextEntry - /// and then write the contents of the entry, and finally call closeEntry() - /// for entries that are files. For directories, it will call putNextEntry(), - /// and then, if the recurse flag is true, process each entry that is a - /// child of the directory. - /// - /// - /// The TarEntry representing the entry to write to the archive. - /// - /// - /// If true, process the children of directory entries. - /// - public void WriteEntry(TarEntry sourceEntry, bool recurse) - { - if (sourceEntry == null) - { - throw new ArgumentNullException(nameof(sourceEntry)); - } - - if (isDisposed) - { - throw new ObjectDisposedException("TarArchive"); - } - - try - { - if (recurse) - { - TarHeader.SetValueDefaults(sourceEntry.UserId, sourceEntry.UserName, - sourceEntry.GroupId, sourceEntry.GroupName); - } - WriteEntryCore(sourceEntry, recurse); - } - finally - { - if (recurse) - { - TarHeader.RestoreSetValues(); - } - } - } - - /// - /// Write an entry to the archive. This method will call the putNextEntry - /// and then write the contents of the entry, and finally call closeEntry() - /// for entries that are files. For directories, it will call putNextEntry(), - /// and then, if the recurse flag is true, process each entry that is a - /// child of the directory. - /// - /// - /// The TarEntry representing the entry to write to the archive. - /// - /// - /// If true, process the children of directory entries. - /// - private void WriteEntryCore(TarEntry sourceEntry, bool recurse) - { - string tempFileName = null; - string entryFilename = sourceEntry.File; - - var entry = (TarEntry)sourceEntry.Clone(); - - if (applyUserInfoOverrides) - { - entry.GroupId = groupId; - entry.GroupName = groupName; - entry.UserId = userId; - entry.UserName = userName; - } - - OnProgressMessageEvent(entry, null); - - if (asciiTranslate && !entry.IsDirectory) - { - if (!IsBinary(entryFilename)) - { - tempFileName = PathUtils.GetTempFileName(); - - using (StreamReader inStream = File.OpenText(entryFilename)) - { - using (Stream outStream = File.Create(tempFileName)) - { - while (true) - { - string line = inStream.ReadLine(); - if (line == null) - { - break; - } - byte[] data = Encoding.ASCII.GetBytes(line); - outStream.Write(data, 0, data.Length); - outStream.WriteByte((byte)'\n'); - } - - outStream.Flush(); - } - } - - entry.Size = new FileInfo(tempFileName).Length; - entryFilename = tempFileName; - } - } - - string newName = null; - - if (!String.IsNullOrEmpty(rootPath)) - { - if (entry.Name.StartsWith(rootPath, StringComparison.OrdinalIgnoreCase)) - { - newName = entry.Name.Substring(rootPath.Length + 1); - } - } - - if (pathPrefix != null) - { - newName = (newName == null) ? pathPrefix + "/" + entry.Name : pathPrefix + "/" + newName; - } - - if (newName != null) - { - entry.Name = newName; - } - - tarOut.PutNextEntry(entry); - - if (entry.IsDirectory) - { - if (recurse) - { - TarEntry[] list = entry.GetDirectoryEntries(); - for (int i = 0; i < list.Length; ++i) - { - WriteEntryCore(list[i], recurse); - } - } - } - else - { - using (Stream inputStream = File.OpenRead(entryFilename)) - { - byte[] localBuffer = new byte[32 * 1024]; - while (true) - { - int numRead = inputStream.Read(localBuffer, 0, localBuffer.Length); - - if (numRead <= 0) - { - break; - } - - tarOut.Write(localBuffer, 0, numRead); - } - } - - if (!string.IsNullOrEmpty(tempFileName)) - { - File.Delete(tempFileName); - } - - tarOut.CloseEntry(); - } - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Releases the unmanaged resources used by the FileStream and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; - /// false to release only unmanaged resources. - protected virtual void Dispose(bool disposing) - { - if (!isDisposed) - { - isDisposed = true; - if (disposing) - { - if (tarOut != null) - { - tarOut.Flush(); - tarOut.Dispose(); - } - - if (tarIn != null) - { - tarIn.Dispose(); - } - } - } - } - - /// - /// Closes the archive and releases any associated resources. - /// - public virtual void Close() - { - Dispose(true); - } - - /// - /// Ensures that resources are freed and other cleanup operations are performed - /// when the garbage collector reclaims the . - /// - ~TarArchive() - { - Dispose(false); - } - - private static void EnsureDirectoryExists(string directoryName) - { - if (!Directory.Exists(directoryName)) - { - try - { - Directory.CreateDirectory(directoryName); - } - catch (Exception e) - { - throw new TarException("Exception creating directory '" + directoryName + "', " + e.Message, e); - } - } - } - - // TODO: TarArchive - Is there a better way to test for a text file? - // It no longer reads entire files into memory but is still a weak test! - // This assumes that byte values 0-7, 14-31 or 255 are binary - // and that all non text files contain one of these values - private static bool IsBinary(string filename) - { - using (FileStream fs = File.OpenRead(filename)) - { - int sampleSize = Math.Min(4096, (int)fs.Length); - byte[] content = new byte[sampleSize]; - - int bytesRead = fs.Read(content, 0, sampleSize); - - for (int i = 0; i < bytesRead; ++i) - { - byte b = content[i]; - if ((b < 8) || ((b > 13) && (b < 32)) || (b == 255)) - { - return true; - } - } - } - return false; - } - - #region Instance Fields - - private bool keepOldFiles; - private bool asciiTranslate; - - private int userId; - private string userName = string.Empty; - private int groupId; - private string groupName = string.Empty; - - private string rootPath; - private string pathPrefix; - - private bool applyUserInfoOverrides; - - private TarInputStream tarIn; - private TarOutputStream tarOut; - private bool isDisposed; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarBuffer.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarBuffer.cs deleted file mode 100644 index 05ef797c7..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarBuffer.cs +++ /dev/null @@ -1,600 +0,0 @@ -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Tar -{ - /// - /// The TarBuffer class implements the tar archive concept - /// of a buffered input stream. This concept goes back to the - /// days of blocked tape drives and special io devices. In the - /// C# universe, the only real function that this class - /// performs is to ensure that files have the correct "record" - /// size, or other tars will complain. - ///

- /// You should never have a need to access this class directly. - /// TarBuffers are created by Tar IO Streams. - ///

- ///
- [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class TarBuffer - { - /* A quote from GNU tar man file on blocking and records - A `tar' archive file contains a series of blocks. Each block - contains `BLOCKSIZE' bytes. Although this format may be thought of as - being on magnetic tape, other media are often used. - - Each file archived is represented by a header block which describes - the file, followed by zero or more blocks which give the contents of - the file. At the end of the archive file there may be a block filled - with binary zeros as an end-of-file marker. A reasonable system should - write a block of zeros at the end, but must not assume that such a - block exists when reading an archive. - - The blocks may be "blocked" for physical I/O operations. Each - record of N blocks is written with a single 'write ()' - operation. On magnetic tapes, the result of such a write is a single - record. When writing an archive, the last record of blocks should be - written at the full size, with blocks after the zero block containing - all zeros. When reading an archive, a reasonable system should - properly handle an archive whose last record is shorter than the rest, - or which contains garbage records after a zero block. - */ - - #region Constants - - /// - /// The size of a block in a tar archive in bytes. - /// - /// This is 512 bytes. - public const int BlockSize = 512; - - /// - /// The number of blocks in a default record. - /// - /// - /// The default value is 20 blocks per record. - /// - public const int DefaultBlockFactor = 20; - - /// - /// The size in bytes of a default record. - /// - /// - /// The default size is 10KB. - /// - public const int DefaultRecordSize = BlockSize * DefaultBlockFactor; - - #endregion Constants - - /// - /// Get the record size for this buffer - /// - /// The record size in bytes. - /// This is equal to the multiplied by the - public int RecordSize - { - get - { - return recordSize; - } - } - - /// - /// Get the TAR Buffer's record size. - /// - /// The record size in bytes. - /// This is equal to the multiplied by the - [Obsolete("Use RecordSize property instead")] - public int GetRecordSize() - { - return recordSize; - } - - /// - /// Get the Blocking factor for the buffer - /// - /// This is the number of blocks in each record. - public int BlockFactor - { - get - { - return blockFactor; - } - } - - /// - /// Get the TAR Buffer's block factor - /// - /// The block factor; the number of blocks per record. - [Obsolete("Use BlockFactor property instead")] - public int GetBlockFactor() - { - return blockFactor; - } - - /// - /// Construct a default TarBuffer - /// - protected TarBuffer() - { - } - - /// - /// Create TarBuffer for reading with default BlockFactor - /// - /// Stream to buffer - /// A new suitable for input. - public static TarBuffer CreateInputTarBuffer(Stream inputStream) - { - if (inputStream == null) - { - throw new ArgumentNullException(nameof(inputStream)); - } - - return CreateInputTarBuffer(inputStream, DefaultBlockFactor); - } - - /// - /// Construct TarBuffer for reading inputStream setting BlockFactor - /// - /// Stream to buffer - /// Blocking factor to apply - /// A new suitable for input. - public static TarBuffer CreateInputTarBuffer(Stream inputStream, int blockFactor) - { - if (inputStream == null) - { - throw new ArgumentNullException(nameof(inputStream)); - } - - if (blockFactor <= 0) - { - throw new ArgumentOutOfRangeException(nameof(blockFactor), "Factor cannot be negative"); - } - - var tarBuffer = new TarBuffer(); - tarBuffer.inputStream = inputStream; - tarBuffer.outputStream = null; - tarBuffer.Initialize(blockFactor); - - return tarBuffer; - } - - /// - /// Construct TarBuffer for writing with default BlockFactor - /// - /// output stream for buffer - /// A new suitable for output. - public static TarBuffer CreateOutputTarBuffer(Stream outputStream) - { - if (outputStream == null) - { - throw new ArgumentNullException(nameof(outputStream)); - } - - return CreateOutputTarBuffer(outputStream, DefaultBlockFactor); - } - - /// - /// Construct TarBuffer for writing Tar output to streams. - /// - /// Output stream to write to. - /// Blocking factor to apply - /// A new suitable for output. - public static TarBuffer CreateOutputTarBuffer(Stream outputStream, int blockFactor) - { - if (outputStream == null) - { - throw new ArgumentNullException(nameof(outputStream)); - } - - if (blockFactor <= 0) - { - throw new ArgumentOutOfRangeException(nameof(blockFactor), "Factor cannot be negative"); - } - - var tarBuffer = new TarBuffer(); - tarBuffer.inputStream = null; - tarBuffer.outputStream = outputStream; - tarBuffer.Initialize(blockFactor); - - return tarBuffer; - } - - /// - /// Initialization common to all constructors. - /// - private void Initialize(int archiveBlockFactor) - { - blockFactor = archiveBlockFactor; - recordSize = archiveBlockFactor * BlockSize; - recordBuffer = new byte[RecordSize]; - - if (inputStream != null) - { - currentRecordIndex = -1; - currentBlockIndex = BlockFactor; - } - else - { - currentRecordIndex = 0; - currentBlockIndex = 0; - } - } - - /// - /// Determine if an archive block indicates End of Archive. End of - /// archive is indicated by a block that consists entirely of null bytes. - /// All remaining blocks for the record should also be null's - /// However some older tars only do a couple of null blocks (Old GNU tar for one) - /// and also partial records - /// - /// The data block to check. - /// Returns true if the block is an EOF block; false otherwise. - [Obsolete("Use IsEndOfArchiveBlock instead")] - public bool IsEOFBlock(byte[] block) - { - if (block == null) - { - throw new ArgumentNullException(nameof(block)); - } - - if (block.Length != BlockSize) - { - throw new ArgumentException("block length is invalid"); - } - - for (int i = 0; i < BlockSize; ++i) - { - if (block[i] != 0) - { - return false; - } - } - - return true; - } - - /// - /// Determine if an archive block indicates the End of an Archive has been reached. - /// End of archive is indicated by a block that consists entirely of null bytes. - /// All remaining blocks for the record should also be null's - /// However some older tars only do a couple of null blocks (Old GNU tar for one) - /// and also partial records - /// - /// The data block to check. - /// Returns true if the block is an EOF block; false otherwise. - public static bool IsEndOfArchiveBlock(byte[] block) - { - if (block == null) - { - throw new ArgumentNullException(nameof(block)); - } - - if (block.Length != BlockSize) - { - throw new ArgumentException("block length is invalid"); - } - - for (int i = 0; i < BlockSize; ++i) - { - if (block[i] != 0) - { - return false; - } - } - - return true; - } - - /// - /// Skip over a block on the input stream. - /// - public void SkipBlock() - { - if (inputStream == null) - { - throw new TarException("no input stream defined"); - } - - if (currentBlockIndex >= BlockFactor) - { - if (!ReadRecord()) - { - throw new TarException("Failed to read a record"); - } - } - - currentBlockIndex++; - } - - /// - /// Read a block from the input stream. - /// - /// - /// The block of data read. - /// - public byte[] ReadBlock() - { - if (inputStream == null) - { - throw new TarException("TarBuffer.ReadBlock - no input stream defined"); - } - - if (currentBlockIndex >= BlockFactor) - { - if (!ReadRecord()) - { - throw new TarException("Failed to read a record"); - } - } - - byte[] result = new byte[BlockSize]; - - Array.Copy(recordBuffer, (currentBlockIndex * BlockSize), result, 0, BlockSize); - currentBlockIndex++; - return result; - } - - /// - /// Read a record from data stream. - /// - /// - /// false if End-Of-File, else true. - /// - private bool ReadRecord() - { - if (inputStream == null) - { - throw new TarException("no input stream defined"); - } - - currentBlockIndex = 0; - - int offset = 0; - int bytesNeeded = RecordSize; - - while (bytesNeeded > 0) - { - long numBytes = inputStream.Read(recordBuffer, offset, bytesNeeded); - - // - // NOTE - // We have found EOF, and the record is not full! - // - // This is a broken archive. It does not follow the standard - // blocking algorithm. However, because we are generous, and - // it requires little effort, we will simply ignore the error - // and continue as if the entire record were read. This does - // not appear to break anything upstream. We used to return - // false in this case. - // - // Thanks to 'Yohann.Roussel@alcatel.fr' for this fix. - // - if (numBytes <= 0) - { - break; - } - - offset += (int)numBytes; - bytesNeeded -= (int)numBytes; - } - - currentRecordIndex++; - return true; - } - - /// - /// Get the current block number, within the current record, zero based. - /// - /// Block numbers are zero based values - /// - public int CurrentBlock - { - get { return currentBlockIndex; } - } - - /// - /// Gets or sets a flag indicating ownership of underlying stream. - /// When the flag is true will close the underlying stream also. - /// - /// The default value is true. - public bool IsStreamOwner { get; set; } = true; - - /// - /// Get the current block number, within the current record, zero based. - /// - /// - /// The current zero based block number. - /// - /// - /// The absolute block number = (record number * block factor) + block number. - /// - [Obsolete("Use CurrentBlock property instead")] - public int GetCurrentBlockNum() - { - return currentBlockIndex; - } - - /// - /// Get the current record number. - /// - /// - /// The current zero based record number. - /// - public int CurrentRecord - { - get { return currentRecordIndex; } - } - - /// - /// Get the current record number. - /// - /// - /// The current zero based record number. - /// - [Obsolete("Use CurrentRecord property instead")] - public int GetCurrentRecordNum() - { - return currentRecordIndex; - } - - /// - /// Write a block of data to the archive. - /// - /// - /// The data to write to the archive. - /// - public void WriteBlock(byte[] block) - { - if (block == null) - { - throw new ArgumentNullException(nameof(block)); - } - - if (outputStream == null) - { - throw new TarException("TarBuffer.WriteBlock - no output stream defined"); - } - - if (block.Length != BlockSize) - { - string errorText = string.Format("TarBuffer.WriteBlock - block to write has length '{0}' which is not the block size of '{1}'", - block.Length, BlockSize); - throw new TarException(errorText); - } - - if (currentBlockIndex >= BlockFactor) - { - WriteRecord(); - } - - Array.Copy(block, 0, recordBuffer, (currentBlockIndex * BlockSize), BlockSize); - currentBlockIndex++; - } - - /// - /// Write an archive record to the archive, where the record may be - /// inside of a larger array buffer. The buffer must be "offset plus - /// record size" long. - /// - /// - /// The buffer containing the record data to write. - /// - /// - /// The offset of the record data within buffer. - /// - public void WriteBlock(byte[] buffer, int offset) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (outputStream == null) - { - throw new TarException("TarBuffer.WriteBlock - no output stream defined"); - } - - if ((offset < 0) || (offset >= buffer.Length)) - { - throw new ArgumentOutOfRangeException(nameof(offset)); - } - - if ((offset + BlockSize) > buffer.Length) - { - string errorText = string.Format("TarBuffer.WriteBlock - record has length '{0}' with offset '{1}' which is less than the record size of '{2}'", - buffer.Length, offset, recordSize); - throw new TarException(errorText); - } - - if (currentBlockIndex >= BlockFactor) - { - WriteRecord(); - } - - Array.Copy(buffer, offset, recordBuffer, (currentBlockIndex * BlockSize), BlockSize); - - currentBlockIndex++; - } - - /// - /// Write a TarBuffer record to the archive. - /// - private void WriteRecord() - { - if (outputStream == null) - { - throw new TarException("TarBuffer.WriteRecord no output stream defined"); - } - - outputStream.Write(recordBuffer, 0, RecordSize); - outputStream.Flush(); - - currentBlockIndex = 0; - currentRecordIndex++; - } - - /// - /// WriteFinalRecord writes the current record buffer to output any unwritten data is present. - /// - /// Any trailing bytes are set to zero which is by definition correct behaviour - /// for the end of a tar stream. - private void WriteFinalRecord() - { - if (outputStream == null) - { - throw new TarException("TarBuffer.WriteFinalRecord no output stream defined"); - } - - if (currentBlockIndex > 0) - { - int dataBytes = currentBlockIndex * BlockSize; - Array.Clear(recordBuffer, dataBytes, RecordSize - dataBytes); - WriteRecord(); - } - - outputStream.Flush(); - } - - /// - /// Close the TarBuffer. If this is an output buffer, also flush the - /// current block before closing. - /// - public void Close() - { - if (outputStream != null) - { - WriteFinalRecord(); - - if (IsStreamOwner) - { - outputStream.Dispose(); - } - outputStream = null; - } - else if (inputStream != null) - { - if (IsStreamOwner) - { - inputStream.Dispose(); - } - inputStream = null; - } - } - - #region Instance Fields - - private Stream inputStream; - private Stream outputStream; - - private byte[] recordBuffer; - private int currentBlockIndex; - private int currentRecordIndex; - - private int recordSize = DefaultRecordSize; - private int blockFactor = DefaultBlockFactor; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarEntry.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarEntry.cs deleted file mode 100644 index 3d4eb786f..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarEntry.cs +++ /dev/null @@ -1,599 +0,0 @@ -using System; -using System.IO; -using System.Text; -using MelonLoader.ICSharpCode.SharpZipLib.Core; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Tar -{ - /// - /// This class represents an entry in a Tar archive. It consists - /// of the entry's header, as well as the entry's File. Entries - /// can be instantiated in one of three ways, depending on how - /// they are to be used. - ///

- /// TarEntries that are created from the header bytes read from - /// an archive are instantiated with the TarEntry( byte[] ) - /// constructor. These entries will be used when extracting from - /// or listing the contents of an archive. These entries have their - /// header filled in using the header bytes. They also set the File - /// to null, since they reference an archive entry not a file.

- ///

- /// TarEntries that are created from files that are to be written - /// into an archive are instantiated with the CreateEntryFromFile(string) - /// pseudo constructor. These entries have their header filled in using - /// the File's information. They also keep a reference to the File - /// for convenience when writing entries.

- ///

- /// Finally, TarEntries can be constructed from nothing but a name. - /// This allows the programmer to construct the entry by hand, for - /// instance when only an InputStream is available for writing to - /// the archive, and the header information is constructed from - /// other information. In this case the header fields are set to - /// defaults and the File is set to null.

- /// - ///
- [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class TarEntry - { - #region Constructors - - /// - /// Initialise a default instance of . - /// - private TarEntry() - { - header = new TarHeader(); - } - - /// - /// Construct an entry from an archive's header bytes. File is set - /// to null. - /// - /// - /// The header bytes from a tar archive entry. - /// - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public TarEntry(byte[] headerBuffer) : this(headerBuffer, null) - { - } - - /// - /// Construct an entry from an archive's header bytes. File is set - /// to null. - /// - /// - /// The header bytes from a tar archive entry. - /// - /// - /// The used for the Name fields, or null for ASCII only - /// - public TarEntry(byte[] headerBuffer, Encoding nameEncoding) - { - header = new TarHeader(); - header.ParseBuffer(headerBuffer, nameEncoding); - } - - /// - /// Construct a TarEntry using the header provided - /// - /// Header details for entry - public TarEntry(TarHeader header) - { - if (header == null) - { - throw new ArgumentNullException(nameof(header)); - } - - this.header = (TarHeader)header.Clone(); - } - - #endregion Constructors - - #region ICloneable Members - - /// - /// Clone this tar entry. - /// - /// Returns a clone of this entry. - public object Clone() - { - var entry = new TarEntry(); - entry.file = file; - entry.header = (TarHeader)header.Clone(); - entry.Name = Name; - return entry; - } - - #endregion ICloneable Members - - /// - /// Construct an entry with only a name. - /// This allows the programmer to construct the entry's header "by hand". - /// - /// The name to use for the entry - /// Returns the newly created - public static TarEntry CreateTarEntry(string name) - { - var entry = new TarEntry(); - TarEntry.NameTarHeader(entry.header, name); - return entry; - } - - /// - /// Construct an entry for a file. File is set to file, and the - /// header is constructed from information from the file. - /// - /// The file name that the entry represents. - /// Returns the newly created - public static TarEntry CreateEntryFromFile(string fileName) - { - var entry = new TarEntry(); - entry.GetFileTarHeader(entry.header, fileName); - return entry; - } - - /// - /// Determine if the two entries are equal. Equality is determined - /// by the header names being equal. - /// - /// The to compare with the current Object. - /// - /// True if the entries are equal; false if not. - /// - public override bool Equals(object obj) - { - var localEntry = obj as TarEntry; - - if (localEntry != null) - { - return Name.Equals(localEntry.Name); - } - return false; - } - - /// - /// Derive a Hash value for the current - /// - /// A Hash code for the current - public override int GetHashCode() - { - return Name.GetHashCode(); - } - - /// - /// Determine if the given entry is a descendant of this entry. - /// Descendancy is determined by the name of the descendant - /// starting with this entry's name. - /// - /// - /// Entry to be checked as a descendent of this. - /// - /// - /// True if entry is a descendant of this. - /// - public bool IsDescendent(TarEntry toTest) - { - if (toTest == null) - { - throw new ArgumentNullException(nameof(toTest)); - } - - return toTest.Name.StartsWith(Name, StringComparison.Ordinal); - } - - /// - /// Get this entry's header. - /// - /// - /// This entry's TarHeader. - /// - public TarHeader TarHeader - { - get - { - return header; - } - } - - /// - /// Get/Set this entry's name. - /// - public string Name - { - get - { - return header.Name; - } - set - { - header.Name = value; - } - } - - /// - /// Get/set this entry's user id. - /// - public int UserId - { - get - { - return header.UserId; - } - set - { - header.UserId = value; - } - } - - /// - /// Get/set this entry's group id. - /// - public int GroupId - { - get - { - return header.GroupId; - } - set - { - header.GroupId = value; - } - } - - /// - /// Get/set this entry's user name. - /// - public string UserName - { - get - { - return header.UserName; - } - set - { - header.UserName = value; - } - } - - /// - /// Get/set this entry's group name. - /// - public string GroupName - { - get - { - return header.GroupName; - } - set - { - header.GroupName = value; - } - } - - /// - /// Convenience method to set this entry's group and user ids. - /// - /// - /// This entry's new user id. - /// - /// - /// This entry's new group id. - /// - public void SetIds(int userId, int groupId) - { - UserId = userId; - GroupId = groupId; - } - - /// - /// Convenience method to set this entry's group and user names. - /// - /// - /// This entry's new user name. - /// - /// - /// This entry's new group name. - /// - public void SetNames(string userName, string groupName) - { - UserName = userName; - GroupName = groupName; - } - - /// - /// Get/Set the modification time for this entry - /// - public DateTime ModTime - { - get - { - return header.ModTime; - } - set - { - header.ModTime = value; - } - } - - /// - /// Get this entry's file. - /// - /// - /// This entry's file. - /// - public string File - { - get - { - return file; - } - } - - /// - /// Get/set this entry's recorded file size. - /// - public long Size - { - get - { - return header.Size; - } - set - { - header.Size = value; - } - } - - /// - /// Return true if this entry represents a directory, false otherwise - /// - /// - /// True if this entry is a directory. - /// - public bool IsDirectory - { - get - { - if (file != null) - { - return Directory.Exists(file); - } - - if (header != null) - { - if ((header.TypeFlag == TarHeader.LF_DIR) || Name.EndsWith("/", StringComparison.Ordinal)) - { - return true; - } - } - return false; - } - } - - /// - /// Fill in a TarHeader with information from a File. - /// - /// - /// The TarHeader to fill in. - /// - /// - /// The file from which to get the header information. - /// - public void GetFileTarHeader(TarHeader header, string file) - { - if (header == null) - { - throw new ArgumentNullException(nameof(header)); - } - - if (file == null) - { - throw new ArgumentNullException(nameof(file)); - } - - this.file = file; - - // bugfix from torhovl from #D forum: - string name = file; - - // 23-Jan-2004 GnuTar allows device names in path where the name is not local to the current directory - if (name.IndexOf(Directory.GetCurrentDirectory(), StringComparison.Ordinal) == 0) - { - name = name.Substring(Directory.GetCurrentDirectory().Length); - } - - /* - if (Path.DirectorySeparatorChar == '\\') - { - // check if the OS is Windows - // Strip off drive letters! - if (name.Length > 2) - { - char ch1 = name[0]; - char ch2 = name[1]; - - if (ch2 == ':' && Char.IsLetter(ch1)) - { - name = name.Substring(2); - } - } - } - */ - - name = name.Replace(Path.DirectorySeparatorChar, '/'); - - // No absolute pathnames - // Windows (and Posix?) paths can start with UNC style "\\NetworkDrive\", - // so we loop on starting /'s. - while (name.StartsWith("/", StringComparison.Ordinal)) - { - name = name.Substring(1); - } - - header.LinkName = String.Empty; - header.Name = name; - - if (Directory.Exists(file)) - { - header.Mode = 1003; // Magic number for security access for a UNIX filesystem - header.TypeFlag = TarHeader.LF_DIR; - if ((header.Name.Length == 0) || header.Name[header.Name.Length - 1] != '/') - { - header.Name = header.Name + "/"; - } - - header.Size = 0; - } - else - { - header.Mode = 33216; // Magic number for security access for a UNIX filesystem - header.TypeFlag = TarHeader.LF_NORMAL; - header.Size = new FileInfo(file.Replace('/', Path.DirectorySeparatorChar)).Length; - } - - header.ModTime = System.IO.File.GetLastWriteTime(file.Replace('/', Path.DirectorySeparatorChar)).ToUniversalTime(); - header.DevMajor = 0; - header.DevMinor = 0; - } - - /// - /// Get entries for all files present in this entries directory. - /// If this entry doesnt represent a directory zero entries are returned. - /// - /// - /// An array of TarEntry's for this entry's children. - /// - public TarEntry[] GetDirectoryEntries() - { - if ((file == null) || !Directory.Exists(file)) - { - return Empty.Array(); - } - - string[] list = Directory.GetFileSystemEntries(file); - TarEntry[] result = new TarEntry[list.Length]; - - for (int i = 0; i < list.Length; ++i) - { - result[i] = TarEntry.CreateEntryFromFile(list[i]); - } - - return result; - } - - /// - /// Write an entry's header information to a header buffer. - /// - /// - /// The tar entry header buffer to fill in. - /// - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public void WriteEntryHeader(byte[] outBuffer) - { - WriteEntryHeader(outBuffer, null); - } - - /// - /// Write an entry's header information to a header buffer. - /// - /// - /// The tar entry header buffer to fill in. - /// - /// - /// The used for the Name fields, or null for ASCII only - /// - public void WriteEntryHeader(byte[] outBuffer, Encoding nameEncoding) - { - header.WriteHeader(outBuffer, nameEncoding); - } - - /// - /// Convenience method that will modify an entry's name directly - /// in place in an entry header buffer byte array. - /// - /// - /// The buffer containing the entry header to modify. - /// - /// - /// The new name to place into the header buffer. - /// - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - static public void AdjustEntryName(byte[] buffer, string newName) - { - AdjustEntryName(buffer, newName, null); - } - - /// - /// Convenience method that will modify an entry's name directly - /// in place in an entry header buffer byte array. - /// - /// - /// The buffer containing the entry header to modify. - /// - /// - /// The new name to place into the header buffer. - /// - /// - /// The used for the Name fields, or null for ASCII only - /// - static public void AdjustEntryName(byte[] buffer, string newName, Encoding nameEncoding) - { - TarHeader.GetNameBytes(newName, buffer, 0, TarHeader.NAMELEN, nameEncoding); - } - - /// - /// Fill in a TarHeader given only the entry's name. - /// - /// - /// The TarHeader to fill in. - /// - /// - /// The tar entry name. - /// - static public void NameTarHeader(TarHeader header, string name) - { - if (header == null) - { - throw new ArgumentNullException(nameof(header)); - } - - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - bool isDir = name.EndsWith("/", StringComparison.Ordinal); - - header.Name = name; - header.Mode = isDir ? 1003 : 33216; - header.UserId = 0; - header.GroupId = 0; - header.Size = 0; - - header.ModTime = DateTime.UtcNow; - - header.TypeFlag = isDir ? TarHeader.LF_DIR : TarHeader.LF_NORMAL; - - header.LinkName = String.Empty; - header.UserName = String.Empty; - header.GroupName = String.Empty; - - header.DevMajor = 0; - header.DevMinor = 0; - } - - #region Instance Fields - - /// - /// The name of the file this entry represents or null if the entry is not based on a file. - /// - private string file; - - /// - /// The entry's header information. - /// - private TarHeader header; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarException.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarException.cs deleted file mode 100644 index 28d4014c0..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarException.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Tar -{ - /// - /// TarException represents exceptions specific to Tar classes and code. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class TarException : SharpZipBaseException - { - /// - /// Initialise a new instance of . - /// - public TarException() - { - } - - /// - /// Initialise a new instance of with its message string. - /// - /// A that describes the error. - public TarException(string message) - : base(message) - { - } - - /// - /// Initialise a new instance of . - /// - /// A that describes the error. - /// The that caused this exception. - public TarException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the TarException class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected TarException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarExtendedHeaderReader.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarExtendedHeaderReader.cs deleted file mode 100644 index a5570a1f4..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarExtendedHeaderReader.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Tar -{ - /// - /// Reads the extended header of a Tar stream - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class TarExtendedHeaderReader - { - private const byte LENGTH = 0; - private const byte KEY = 1; - private const byte VALUE = 2; - private const byte END = 3; - - private readonly Dictionary headers = new Dictionary(); - - private string[] headerParts = new string[3]; - - private int bbIndex; - private byte[] byteBuffer; - private char[] charBuffer; - - private readonly StringBuilder sb = new StringBuilder(); - private readonly Decoder decoder = Encoding.UTF8.GetDecoder(); - - private int state = LENGTH; - - private static readonly byte[] StateNext = new[] { (byte)' ', (byte)'=', (byte)'\n' }; - - /// - /// Creates a new . - /// - public TarExtendedHeaderReader() - { - ResetBuffers(); - } - - /// - /// Read bytes from - /// - /// - /// - public void Read(byte[] buffer, int length) - { - for (int i = 0; i < length; i++) - { - byte next = buffer[i]; - - if (next == StateNext[state]) - { - Flush(); - headerParts[state] = sb.ToString(); - sb.Remove(0, sb.Length); - - if (++state == END) - { - headers.Add(headerParts[KEY], headerParts[VALUE]); - headerParts = new string[3]; - state = LENGTH; - } - } - else - { - byteBuffer[bbIndex++] = next; - if (bbIndex == 4) - Flush(); - } - } - } - - private void Flush() - { - decoder.Convert(byteBuffer, 0, bbIndex, charBuffer, 0, 4, false, out int bytesUsed, out int charsUsed, out bool completed); - - sb.Append(charBuffer, 0, charsUsed); - ResetBuffers(); - } - - private void ResetBuffers() - { - charBuffer = new char[4]; - byteBuffer = new byte[4]; - bbIndex = 0; - } - - /// - /// Returns the parsed headers as key-value strings - /// - public Dictionary Headers - { - get - { - // TODO: Check for invalid state? -NM 2018-07-01 - return headers; - } - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarHeader.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarHeader.cs deleted file mode 100644 index 5837152e4..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarHeader.cs +++ /dev/null @@ -1,1311 +0,0 @@ -using System; -using System.Text; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Tar -{ - /// - /// This class encapsulates the Tar Entry Header used in Tar Archives. - /// The class also holds a number of tar constants, used mostly in headers. - /// - /// - /// The tar format and its POSIX successor PAX have a long history which makes for compatability - /// issues when creating and reading files. - /// - /// This is further complicated by a large number of programs with variations on formats - /// One common issue is the handling of names longer than 100 characters. - /// GNU style long names are currently supported. - /// - /// This is the ustar (Posix 1003.1) header. - /// - /// struct header - /// { - /// char t_name[100]; // 0 Filename - /// char t_mode[8]; // 100 Permissions - /// char t_uid[8]; // 108 Numerical User ID - /// char t_gid[8]; // 116 Numerical Group ID - /// char t_size[12]; // 124 Filesize - /// char t_mtime[12]; // 136 st_mtime - /// char t_chksum[8]; // 148 Checksum - /// char t_typeflag; // 156 Type of File - /// char t_linkname[100]; // 157 Target of Links - /// char t_magic[6]; // 257 "ustar" or other... - /// char t_version[2]; // 263 Version fixed to 00 - /// char t_uname[32]; // 265 User Name - /// char t_gname[32]; // 297 Group Name - /// char t_devmajor[8]; // 329 Major for devices - /// char t_devminor[8]; // 337 Minor for devices - /// char t_prefix[155]; // 345 Prefix for t_name - /// char t_mfill[12]; // 500 Filler up to 512 - /// }; - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class TarHeader - { - #region Constants - - /// - /// The length of the name field in a header buffer. - /// - public const int NAMELEN = 100; - - /// - /// The length of the mode field in a header buffer. - /// - public const int MODELEN = 8; - - /// - /// The length of the user id field in a header buffer. - /// - public const int UIDLEN = 8; - - /// - /// The length of the group id field in a header buffer. - /// - public const int GIDLEN = 8; - - /// - /// The length of the checksum field in a header buffer. - /// - public const int CHKSUMLEN = 8; - - /// - /// Offset of checksum in a header buffer. - /// - public const int CHKSUMOFS = 148; - - /// - /// The length of the size field in a header buffer. - /// - public const int SIZELEN = 12; - - /// - /// The length of the magic field in a header buffer. - /// - public const int MAGICLEN = 6; - - /// - /// The length of the version field in a header buffer. - /// - public const int VERSIONLEN = 2; - - /// - /// The length of the modification time field in a header buffer. - /// - public const int MODTIMELEN = 12; - - /// - /// The length of the user name field in a header buffer. - /// - public const int UNAMELEN = 32; - - /// - /// The length of the group name field in a header buffer. - /// - public const int GNAMELEN = 32; - - /// - /// The length of the devices field in a header buffer. - /// - public const int DEVLEN = 8; - - /// - /// The length of the name prefix field in a header buffer. - /// - public const int PREFIXLEN = 155; - - // - // LF_ constants represent the "type" of an entry - // - - /// - /// The "old way" of indicating a normal file. - /// - public const byte LF_OLDNORM = 0; - - /// - /// Normal file type. - /// - public const byte LF_NORMAL = (byte)'0'; - - /// - /// Link file type. - /// - public const byte LF_LINK = (byte)'1'; - - /// - /// Symbolic link file type. - /// - public const byte LF_SYMLINK = (byte)'2'; - - /// - /// Character device file type. - /// - public const byte LF_CHR = (byte)'3'; - - /// - /// Block device file type. - /// - public const byte LF_BLK = (byte)'4'; - - /// - /// Directory file type. - /// - public const byte LF_DIR = (byte)'5'; - - /// - /// FIFO (pipe) file type. - /// - public const byte LF_FIFO = (byte)'6'; - - /// - /// Contiguous file type. - /// - public const byte LF_CONTIG = (byte)'7'; - - /// - /// Posix.1 2001 global extended header - /// - public const byte LF_GHDR = (byte)'g'; - - /// - /// Posix.1 2001 extended header - /// - public const byte LF_XHDR = (byte)'x'; - - // POSIX allows for upper case ascii type as extensions - - /// - /// Solaris access control list file type - /// - public const byte LF_ACL = (byte)'A'; - - /// - /// GNU dir dump file type - /// This is a dir entry that contains the names of files that were in the - /// dir at the time the dump was made - /// - public const byte LF_GNU_DUMPDIR = (byte)'D'; - - /// - /// Solaris Extended Attribute File - /// - public const byte LF_EXTATTR = (byte)'E'; - - /// - /// Inode (metadata only) no file content - /// - public const byte LF_META = (byte)'I'; - - /// - /// Identifies the next file on the tape as having a long link name - /// - public const byte LF_GNU_LONGLINK = (byte)'K'; - - /// - /// Identifies the next file on the tape as having a long name - /// - public const byte LF_GNU_LONGNAME = (byte)'L'; - - /// - /// Continuation of a file that began on another volume - /// - public const byte LF_GNU_MULTIVOL = (byte)'M'; - - /// - /// For storing filenames that dont fit in the main header (old GNU) - /// - public const byte LF_GNU_NAMES = (byte)'N'; - - /// - /// GNU Sparse file - /// - public const byte LF_GNU_SPARSE = (byte)'S'; - - /// - /// GNU Tape/volume header ignore on extraction - /// - public const byte LF_GNU_VOLHDR = (byte)'V'; - - /// - /// The magic tag representing a POSIX tar archive. (would be written with a trailing NULL) - /// - public const string TMAGIC = "ustar"; - - /// - /// The magic tag representing an old GNU tar archive where version is included in magic and overwrites it - /// - public const string GNU_TMAGIC = "ustar "; - - private const long timeConversionFactor = 10000000L; // 1 tick == 100 nanoseconds - private static readonly DateTime dateTime1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0); - - #endregion Constants - - #region Constructors - - /// - /// Initialise a default TarHeader instance - /// - public TarHeader() - { - Magic = TMAGIC; - Version = " "; - - Name = ""; - LinkName = ""; - - UserId = defaultUserId; - GroupId = defaultGroupId; - UserName = defaultUser; - GroupName = defaultGroupName; - Size = 0; - } - - #endregion Constructors - - #region Properties - - /// - /// Get/set the name for this tar entry. - /// - /// Thrown when attempting to set the property to null. - public string Name - { - get { return name; } - set - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - name = value; - } - } - - /// - /// Get the name of this entry. - /// - /// The entry's name. - [Obsolete("Use the Name property instead", true)] - public string GetName() - { - return name; - } - - /// - /// Get/set the entry's Unix style permission mode. - /// - public int Mode - { - get { return mode; } - set { mode = value; } - } - - /// - /// The entry's user id. - /// - /// - /// This is only directly relevant to unix systems. - /// The default is zero. - /// - public int UserId - { - get { return userId; } - set { userId = value; } - } - - /// - /// Get/set the entry's group id. - /// - /// - /// This is only directly relevant to linux/unix systems. - /// The default value is zero. - /// - public int GroupId - { - get { return groupId; } - set { groupId = value; } - } - - /// - /// Get/set the entry's size. - /// - /// Thrown when setting the size to less than zero. - public long Size - { - get { return size; } - set - { - if (value < 0) - { - throw new ArgumentOutOfRangeException(nameof(value), "Cannot be less than zero"); - } - size = value; - } - } - - /// - /// Get/set the entry's modification time. - /// - /// - /// The modification time is only accurate to within a second. - /// - /// Thrown when setting the date time to less than 1/1/1970. - public DateTime ModTime - { - get { return modTime; } - set - { - if (value < dateTime1970) - { - throw new ArgumentOutOfRangeException(nameof(value), "ModTime cannot be before Jan 1st 1970"); - } - modTime = new DateTime(value.Year, value.Month, value.Day, value.Hour, value.Minute, value.Second); - } - } - - /// - /// Get the entry's checksum. This is only valid/updated after writing or reading an entry. - /// - public int Checksum - { - get { return checksum; } - } - - /// - /// Get value of true if the header checksum is valid, false otherwise. - /// - public bool IsChecksumValid - { - get { return isChecksumValid; } - } - - /// - /// Get/set the entry's type flag. - /// - public byte TypeFlag - { - get { return typeFlag; } - set { typeFlag = value; } - } - - /// - /// The entry's link name. - /// - /// Thrown when attempting to set LinkName to null. - public string LinkName - { - get { return linkName; } - set - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - linkName = value; - } - } - - /// - /// Get/set the entry's magic tag. - /// - /// Thrown when attempting to set Magic to null. - public string Magic - { - get { return magic; } - set - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - magic = value; - } - } - - /// - /// The entry's version. - /// - /// Thrown when attempting to set Version to null. - public string Version - { - get - { - return version; - } - - set - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - version = value; - } - } - - /// - /// The entry's user name. - /// - public string UserName - { - get { return userName; } - set - { - if (value != null) - { - userName = value.Substring(0, Math.Min(UNAMELEN, value.Length)); - } - else - { - string currentUser = "user"; - if (currentUser.Length > UNAMELEN) - { - currentUser = currentUser.Substring(0, UNAMELEN); - } - userName = currentUser; - } - } - } - - /// - /// Get/set the entry's group name. - /// - /// - /// This is only directly relevant to unix systems. - /// - public string GroupName - { - get { return groupName; } - set - { - if (value == null) - { - groupName = "None"; - } - else - { - groupName = value; - } - } - } - - /// - /// Get/set the entry's major device number. - /// - public int DevMajor - { - get { return devMajor; } - set { devMajor = value; } - } - - /// - /// Get/set the entry's minor device number. - /// - public int DevMinor - { - get { return devMinor; } - set { devMinor = value; } - } - - #endregion Properties - - #region ICloneable Members - - /// - /// Create a new that is a copy of the current instance. - /// - /// A new that is a copy of the current instance. - public object Clone() - { - return this.MemberwiseClone(); - } - - #endregion ICloneable Members - - /// - /// Parse TarHeader information from a header buffer. - /// - /// - /// The tar entry header buffer to get information from. - /// - /// - /// The used for the Name field, or null for ASCII only - /// - public void ParseBuffer(byte[] header, Encoding nameEncoding) - { - if (header == null) - { - throw new ArgumentNullException(nameof(header)); - } - - int offset = 0; - - name = ParseName(header, offset, NAMELEN, nameEncoding).ToString(); - offset += NAMELEN; - - mode = (int)ParseOctal(header, offset, MODELEN); - offset += MODELEN; - - UserId = (int)ParseOctal(header, offset, UIDLEN); - offset += UIDLEN; - - GroupId = (int)ParseOctal(header, offset, GIDLEN); - offset += GIDLEN; - - Size = ParseBinaryOrOctal(header, offset, SIZELEN); - offset += SIZELEN; - - ModTime = GetDateTimeFromCTime(ParseOctal(header, offset, MODTIMELEN)); - offset += MODTIMELEN; - - checksum = (int)ParseOctal(header, offset, CHKSUMLEN); - offset += CHKSUMLEN; - - TypeFlag = header[offset++]; - - LinkName = ParseName(header, offset, NAMELEN, nameEncoding).ToString(); - offset += NAMELEN; - - Magic = ParseName(header, offset, MAGICLEN, nameEncoding).ToString(); - offset += MAGICLEN; - - if (Magic == "ustar") - { - Version = ParseName(header, offset, VERSIONLEN, nameEncoding).ToString(); - offset += VERSIONLEN; - - UserName = ParseName(header, offset, UNAMELEN, nameEncoding).ToString(); - offset += UNAMELEN; - - GroupName = ParseName(header, offset, GNAMELEN, nameEncoding).ToString(); - offset += GNAMELEN; - - DevMajor = (int)ParseOctal(header, offset, DEVLEN); - offset += DEVLEN; - - DevMinor = (int)ParseOctal(header, offset, DEVLEN); - offset += DEVLEN; - - string prefix = ParseName(header, offset, PREFIXLEN, nameEncoding).ToString(); - if (!string.IsNullOrEmpty(prefix)) Name = prefix + '/' + Name; - } - - isChecksumValid = Checksum == TarHeader.MakeCheckSum(header); - } - - /// - /// Parse TarHeader information from a header buffer. - /// - /// - /// The tar entry header buffer to get information from. - /// - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public void ParseBuffer(byte[] header) - { - ParseBuffer(header, null); - } - - /// - /// 'Write' header information to buffer provided, updating the check sum. - /// - /// output buffer for header information - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public void WriteHeader(byte[] outBuffer) - { - WriteHeader(outBuffer, null); - } - - /// - /// 'Write' header information to buffer provided, updating the check sum. - /// - /// output buffer for header information - /// The used for the Name field, or null for ASCII only - public void WriteHeader(byte[] outBuffer, Encoding nameEncoding) - { - if (outBuffer == null) - { - throw new ArgumentNullException(nameof(outBuffer)); - } - - int offset = 0; - - offset = GetNameBytes(Name, outBuffer, offset, NAMELEN, nameEncoding); - offset = GetOctalBytes(mode, outBuffer, offset, MODELEN); - offset = GetOctalBytes(UserId, outBuffer, offset, UIDLEN); - offset = GetOctalBytes(GroupId, outBuffer, offset, GIDLEN); - - offset = GetBinaryOrOctalBytes(Size, outBuffer, offset, SIZELEN); - offset = GetOctalBytes(GetCTime(ModTime), outBuffer, offset, MODTIMELEN); - - int csOffset = offset; - for (int c = 0; c < CHKSUMLEN; ++c) - { - outBuffer[offset++] = (byte)' '; - } - - outBuffer[offset++] = TypeFlag; - - offset = GetNameBytes(LinkName, outBuffer, offset, NAMELEN, nameEncoding); - offset = GetAsciiBytes(Magic, 0, outBuffer, offset, MAGICLEN, nameEncoding); - offset = GetNameBytes(Version, outBuffer, offset, VERSIONLEN, nameEncoding); - offset = GetNameBytes(UserName, outBuffer, offset, UNAMELEN, nameEncoding); - offset = GetNameBytes(GroupName, outBuffer, offset, GNAMELEN, nameEncoding); - - if ((TypeFlag == LF_CHR) || (TypeFlag == LF_BLK)) - { - offset = GetOctalBytes(DevMajor, outBuffer, offset, DEVLEN); - offset = GetOctalBytes(DevMinor, outBuffer, offset, DEVLEN); - } - - for (; offset < outBuffer.Length;) - { - outBuffer[offset++] = 0; - } - - checksum = ComputeCheckSum(outBuffer); - - GetCheckSumOctalBytes(checksum, outBuffer, csOffset, CHKSUMLEN); - isChecksumValid = true; - } - - /// - /// Get a hash code for the current object. - /// - /// A hash code for the current object. - public override int GetHashCode() - { - return Name.GetHashCode(); - } - - /// - /// Determines if this instance is equal to the specified object. - /// - /// The object to compare with. - /// true if the objects are equal, false otherwise. - public override bool Equals(object obj) - { - var localHeader = obj as TarHeader; - - bool result; - if (localHeader != null) - { - result = (name == localHeader.name) - && (mode == localHeader.mode) - && (UserId == localHeader.UserId) - && (GroupId == localHeader.GroupId) - && (Size == localHeader.Size) - && (ModTime == localHeader.ModTime) - && (Checksum == localHeader.Checksum) - && (TypeFlag == localHeader.TypeFlag) - && (LinkName == localHeader.LinkName) - && (Magic == localHeader.Magic) - && (Version == localHeader.Version) - && (UserName == localHeader.UserName) - && (GroupName == localHeader.GroupName) - && (DevMajor == localHeader.DevMajor) - && (DevMinor == localHeader.DevMinor); - } - else - { - result = false; - } - return result; - } - - /// - /// Set defaults for values used when constructing a TarHeader instance. - /// - /// Value to apply as a default for userId. - /// Value to apply as a default for userName. - /// Value to apply as a default for groupId. - /// Value to apply as a default for groupName. - static internal void SetValueDefaults(int userId, string userName, int groupId, string groupName) - { - defaultUserId = userIdAsSet = userId; - defaultUser = userNameAsSet = userName; - defaultGroupId = groupIdAsSet = groupId; - defaultGroupName = groupNameAsSet = groupName; - } - - static internal void RestoreSetValues() - { - defaultUserId = userIdAsSet; - defaultUser = userNameAsSet; - defaultGroupId = groupIdAsSet; - defaultGroupName = groupNameAsSet; - } - - // Return value that may be stored in octal or binary. Length must exceed 8. - // - static private long ParseBinaryOrOctal(byte[] header, int offset, int length) - { - if (header[offset] >= 0x80) - { - // File sizes over 8GB are stored in 8 right-justified bytes of binary indicated by setting the high-order bit of the leftmost byte of a numeric field. - long result = 0; - for (int pos = length - 8; pos < length; pos++) - { - result = result << 8 | header[offset + pos]; - } - return result; - } - return ParseOctal(header, offset, length); - } - - /// - /// Parse an octal string from a header buffer. - /// - /// The header buffer from which to parse. - /// The offset into the buffer from which to parse. - /// The number of header bytes to parse. - /// The long equivalent of the octal string. - static public long ParseOctal(byte[] header, int offset, int length) - { - if (header == null) - { - throw new ArgumentNullException(nameof(header)); - } - - long result = 0; - bool stillPadding = true; - - int end = offset + length; - for (int i = offset; i < end; ++i) - { - if (header[i] == 0) - { - break; - } - - if (header[i] == (byte)' ' || header[i] == '0') - { - if (stillPadding) - { - continue; - } - - if (header[i] == (byte)' ') - { - break; - } - } - - stillPadding = false; - - result = (result << 3) + (header[i] - '0'); - } - - return result; - } - - /// - /// Parse a name from a header buffer. - /// - /// - /// The header buffer from which to parse. - /// - /// - /// The offset into the buffer from which to parse. - /// - /// - /// The number of header bytes to parse. - /// - /// - /// The name parsed. - /// - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - static public StringBuilder ParseName(byte[] header, int offset, int length) - { - return ParseName(header, offset, length, null); - } - - /// - /// Parse a name from a header buffer. - /// - /// - /// The header buffer from which to parse. - /// - /// - /// The offset into the buffer from which to parse. - /// - /// - /// The number of header bytes to parse. - /// - /// - /// name encoding, or null for ASCII only - /// - /// - /// The name parsed. - /// - static public StringBuilder ParseName(byte[] header, int offset, int length, Encoding encoding) - { - if (header == null) - { - throw new ArgumentNullException(nameof(header)); - } - - if (offset < 0) - { - throw new ArgumentOutOfRangeException(nameof(offset), "Cannot be less than zero"); - } - - if (length < 0) - { - throw new ArgumentOutOfRangeException(nameof(length), "Cannot be less than zero"); - } - - if (offset + length > header.Length) - { - throw new ArgumentException("Exceeds header size", nameof(length)); - } - - var result = new StringBuilder(length); - - int count = 0; - if(encoding == null) - { - for (int i = offset; i < offset + length; ++i) - { - if (header[i] == 0) - { - break; - } - result.Append((char)header[i]); - } - } - else - { - for(int i = offset; i < offset + length; ++i, ++count) - { - if(header[i] == 0) - { - break; - } - } - result.Append(encoding.GetString(header, offset, count)); - } - - return result; - } - - /// - /// Add name to the buffer as a collection of bytes - /// - /// The name to add - /// The offset of the first character - /// The buffer to add to - /// The index of the first byte to add - /// The number of characters/bytes to add - /// The next free index in the - public static int GetNameBytes(StringBuilder name, int nameOffset, byte[] buffer, int bufferOffset, int length) - { - return GetNameBytes(name.ToString(), nameOffset, buffer, bufferOffset, length, null); - } - - /// - /// Add name to the buffer as a collection of bytes - /// - /// The name to add - /// The offset of the first character - /// The buffer to add to - /// The index of the first byte to add - /// The number of characters/bytes to add - /// The next free index in the - public static int GetNameBytes(string name, int nameOffset, byte[] buffer, int bufferOffset, int length) - { - return GetNameBytes(name, nameOffset, buffer, bufferOffset, length, null); - } - - /// - /// Add name to the buffer as a collection of bytes - /// - /// The name to add - /// The offset of the first character - /// The buffer to add to - /// The index of the first byte to add - /// The number of characters/bytes to add - /// name encoding, or null for ASCII only - /// The next free index in the - public static int GetNameBytes(string name, int nameOffset, byte[] buffer, int bufferOffset, int length, Encoding encoding) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - int i; - if(encoding != null) - { - // it can be more sufficient if using Span or unsafe - var nameArray = name.ToCharArray(nameOffset, Math.Min(name.Length - nameOffset, length)); - // it can be more sufficient if using Span(or unsafe?) and ArrayPool for temporary buffer - var bytes = encoding.GetBytes(nameArray, 0, nameArray.Length); - i = Math.Min(bytes.Length, length); - Array.Copy(bytes, 0, buffer, bufferOffset, i); - } - else - { - for (i = 0; i < length && nameOffset + i < name.Length; ++i) - { - buffer[bufferOffset + i] = (byte)name[nameOffset + i]; - } - } - - for (; i < length; ++i) - { - buffer[bufferOffset + i] = 0; - } - return bufferOffset + length; - } - /// - /// Add an entry name to the buffer - /// - /// - /// The name to add - /// - /// - /// The buffer to add to - /// - /// - /// The offset into the buffer from which to start adding - /// - /// - /// The number of header bytes to add - /// - /// - /// The index of the next free byte in the buffer - /// - /// TODO: what should be default behavior?(omit upper byte or UTF8?) - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public static int GetNameBytes(StringBuilder name, byte[] buffer, int offset, int length) - { - return GetNameBytes(name, buffer, offset, length, null); - } - - /// - /// Add an entry name to the buffer - /// - /// - /// The name to add - /// - /// - /// The buffer to add to - /// - /// - /// The offset into the buffer from which to start adding - /// - /// - /// The number of header bytes to add - /// - /// - /// - /// - /// The index of the next free byte in the buffer - /// - public static int GetNameBytes(StringBuilder name, byte[] buffer, int offset, int length, Encoding encoding) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - return GetNameBytes(name.ToString(), 0, buffer, offset, length, encoding); - } - - /// - /// Add an entry name to the buffer - /// - /// The name to add - /// The buffer to add to - /// The offset into the buffer from which to start adding - /// The number of header bytes to add - /// The index of the next free byte in the buffer - /// TODO: what should be default behavior?(omit upper byte or UTF8?) - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public static int GetNameBytes(string name, byte[] buffer, int offset, int length) - { - return GetNameBytes(name, buffer, offset, length, null); - } - - /// - /// Add an entry name to the buffer - /// - /// The name to add - /// The buffer to add to - /// The offset into the buffer from which to start adding - /// The number of header bytes to add - /// - /// The index of the next free byte in the buffer - public static int GetNameBytes(string name, byte[] buffer, int offset, int length, Encoding encoding) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - return GetNameBytes(name, 0, buffer, offset, length, encoding); - } - /// - /// Add a string to a buffer as a collection of ascii bytes. - /// - /// The string to add - /// The offset of the first character to add. - /// The buffer to add to. - /// The offset to start adding at. - /// The number of ascii characters to add. - /// The next free index in the buffer. - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public static int GetAsciiBytes(string toAdd, int nameOffset, byte[] buffer, int bufferOffset, int length) - { - return GetAsciiBytes(toAdd, nameOffset, buffer, bufferOffset, length, null); - } - - /// - /// Add a string to a buffer as a collection of ascii bytes. - /// - /// The string to add - /// The offset of the first character to add. - /// The buffer to add to. - /// The offset to start adding at. - /// The number of ascii characters to add. - /// String encoding, or null for ASCII only - /// The next free index in the buffer. - public static int GetAsciiBytes(string toAdd, int nameOffset, byte[] buffer, int bufferOffset, int length, Encoding encoding) - { - if (toAdd == null) - { - throw new ArgumentNullException(nameof(toAdd)); - } - - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - int i; - if(encoding == null) - { - for (i = 0; i < length && nameOffset + i < toAdd.Length; ++i) - { - buffer[bufferOffset + i] = (byte)toAdd[nameOffset + i]; - } - } - else - { - // It can be more sufficient if using unsafe code or Span(ToCharArray can be omitted) - var chars = toAdd.ToCharArray(); - // It can be more sufficient if using Span(or unsafe?) and ArrayPool for temporary buffer - var bytes = encoding.GetBytes(chars, nameOffset, Math.Min(toAdd.Length - nameOffset, length)); - i = Math.Min(bytes.Length, length); - Array.Copy(bytes, 0, buffer, bufferOffset, i); - } - // If length is beyond the toAdd string length (which is OK by the prev loop condition), eg if a field has fixed length and the string is shorter, make sure all of the extra chars are written as NULLs, so that the reader func would ignore them and get back the original string - for (; i < length; ++i) - buffer[bufferOffset + i] = 0; - return bufferOffset + length; - } - - /// - /// Put an octal representation of a value into a buffer - /// - /// - /// the value to be converted to octal - /// - /// - /// buffer to store the octal string - /// - /// - /// The offset into the buffer where the value starts - /// - /// - /// The length of the octal string to create - /// - /// - /// The offset of the character next byte after the octal string - /// - public static int GetOctalBytes(long value, byte[] buffer, int offset, int length) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - int localIndex = length - 1; - - // Either a space or null is valid here. We use NULL as per GNUTar - buffer[offset + localIndex] = 0; - --localIndex; - - if (value > 0) - { - for (long v = value; (localIndex >= 0) && (v > 0); --localIndex) - { - buffer[offset + localIndex] = (byte)((byte)'0' + (byte)(v & 7)); - v >>= 3; - } - } - - for (; localIndex >= 0; --localIndex) - { - buffer[offset + localIndex] = (byte)'0'; - } - - return offset + length; - } - - /// - /// Put an octal or binary representation of a value into a buffer - /// - /// Value to be convert to octal - /// The buffer to update - /// The offset into the buffer to store the value - /// The length of the octal string. Must be 12. - /// Index of next byte - private static int GetBinaryOrOctalBytes(long value, byte[] buffer, int offset, int length) - { - if (value > 0x1FFFFFFFF) - { // Octal 77777777777 (11 digits) - // Put value as binary, right-justified into the buffer. Set high order bit of left-most byte. - for (int pos = length - 1; pos > 0; pos--) - { - buffer[offset + pos] = (byte)value; - value = value >> 8; - } - buffer[offset] = 0x80; - return offset + length; - } - return GetOctalBytes(value, buffer, offset, length); - } - - /// - /// Add the checksum integer to header buffer. - /// - /// - /// The header buffer to set the checksum for - /// The offset into the buffer for the checksum - /// The number of header bytes to update. - /// It's formatted differently from the other fields: it has 6 digits, a - /// null, then a space -- rather than digits, a space, then a null. - /// The final space is already there, from checksumming - /// - /// The modified buffer offset - private static void GetCheckSumOctalBytes(long value, byte[] buffer, int offset, int length) - { - GetOctalBytes(value, buffer, offset, length - 1); - } - - /// - /// Compute the checksum for a tar entry header. - /// The checksum field must be all spaces prior to this happening - /// - /// The tar entry's header buffer. - /// The computed checksum. - private static int ComputeCheckSum(byte[] buffer) - { - int sum = 0; - for (int i = 0; i < buffer.Length; ++i) - { - sum += buffer[i]; - } - return sum; - } - - /// - /// Make a checksum for a tar entry ignoring the checksum contents. - /// - /// The tar entry's header buffer. - /// The checksum for the buffer - private static int MakeCheckSum(byte[] buffer) - { - int sum = 0; - for (int i = 0; i < CHKSUMOFS; ++i) - { - sum += buffer[i]; - } - - for (int i = 0; i < CHKSUMLEN; ++i) - { - sum += (byte)' '; - } - - for (int i = CHKSUMOFS + CHKSUMLEN; i < buffer.Length; ++i) - { - sum += buffer[i]; - } - return sum; - } - - private static int GetCTime(DateTime dateTime) - { - return unchecked((int)((dateTime.Ticks - dateTime1970.Ticks) / timeConversionFactor)); - } - - private static DateTime GetDateTimeFromCTime(long ticks) - { - DateTime result; - - try - { - result = new DateTime(dateTime1970.Ticks + ticks * timeConversionFactor); - } - catch (ArgumentOutOfRangeException) - { - result = dateTime1970; - } - return result; - } - - #region Instance Fields - - private string name; - private int mode; - private int userId; - private int groupId; - private long size; - private DateTime modTime; - private int checksum; - private bool isChecksumValid; - private byte typeFlag; - private string linkName; - private string magic; - private string version; - private string userName; - private string groupName; - private int devMajor; - private int devMinor; - - #endregion Instance Fields - - #region Class Fields - - // Values used during recursive operations. - static internal int userIdAsSet; - - static internal int groupIdAsSet; - static internal string userNameAsSet; - static internal string groupNameAsSet = "None"; - - static internal int defaultUserId; - static internal int defaultGroupId; - static internal string defaultGroupName = "None"; - static internal string defaultUser; - - #endregion Class Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarInputStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarInputStream.cs deleted file mode 100644 index 7fbe33f34..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarInputStream.cs +++ /dev/null @@ -1,772 +0,0 @@ -using System; -using System.IO; -using System.Text; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Tar -{ - /// - /// The TarInputStream reads a UNIX tar archive as an InputStream. - /// methods are provided to position at each successive entry in - /// the archive, and the read each entry as a normal input stream - /// using read(). - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class TarInputStream : Stream - { - #region Constructors - - /// - /// Construct a TarInputStream with default block factor - /// - /// stream to source data from - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public TarInputStream(Stream inputStream) - : this(inputStream, TarBuffer.DefaultBlockFactor, null) - { - } - /// - /// Construct a TarInputStream with default block factor - /// - /// stream to source data from - /// The used for the Name fields, or null for ASCII only - public TarInputStream(Stream inputStream, Encoding nameEncoding) - : this(inputStream, TarBuffer.DefaultBlockFactor, nameEncoding) - { - } - - /// - /// Construct a TarInputStream with user specified block factor - /// - /// stream to source data from - /// block factor to apply to archive - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public TarInputStream(Stream inputStream, int blockFactor) - { - this.inputStream = inputStream; - tarBuffer = TarBuffer.CreateInputTarBuffer(inputStream, blockFactor); - encoding = null; - } - - /// - /// Construct a TarInputStream with user specified block factor - /// - /// stream to source data from - /// block factor to apply to archive - /// The used for the Name fields, or null for ASCII only - public TarInputStream(Stream inputStream, int blockFactor, Encoding nameEncoding) - { - this.inputStream = inputStream; - tarBuffer = TarBuffer.CreateInputTarBuffer(inputStream, blockFactor); - encoding = nameEncoding; - } - - #endregion Constructors - - /// - /// Gets or sets a flag indicating ownership of underlying stream. - /// When the flag is true will close the underlying stream also. - /// - /// The default value is true. - public bool IsStreamOwner - { - get { return tarBuffer.IsStreamOwner; } - set { tarBuffer.IsStreamOwner = value; } - } - - #region Stream Overrides - - /// - /// Gets a value indicating whether the current stream supports reading - /// - public override bool CanRead - { - get - { - return inputStream.CanRead; - } - } - - /// - /// Gets a value indicating whether the current stream supports seeking - /// This property always returns false. - /// - public override bool CanSeek - { - get - { - return false; - } - } - - /// - /// Gets a value indicating if the stream supports writing. - /// This property always returns false. - /// - public override bool CanWrite - { - get - { - return false; - } - } - - /// - /// The length in bytes of the stream - /// - public override long Length - { - get - { - return inputStream.Length; - } - } - - /// - /// Gets or sets the position within the stream. - /// Setting the Position is not supported and throws a NotSupportedExceptionNotSupportedException - /// - /// Any attempt to set position - public override long Position - { - get - { - return inputStream.Position; - } - set - { - throw new NotSupportedException("TarInputStream Seek not supported"); - } - } - - /// - /// Flushes the baseInputStream - /// - public override void Flush() - { - inputStream.Flush(); - } - - /// - /// Set the streams position. This operation is not supported and will throw a NotSupportedException - /// - /// The offset relative to the origin to seek to. - /// The to start seeking from. - /// The new position in the stream. - /// Any access - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("TarInputStream Seek not supported"); - } - - /// - /// Sets the length of the stream - /// This operation is not supported and will throw a NotSupportedException - /// - /// The new stream length. - /// Any access - public override void SetLength(long value) - { - throw new NotSupportedException("TarInputStream SetLength not supported"); - } - - /// - /// Writes a block of bytes to this stream using data from a buffer. - /// This operation is not supported and will throw a NotSupportedException - /// - /// The buffer containing bytes to write. - /// The offset in the buffer of the frist byte to write. - /// The number of bytes to write. - /// Any access - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotSupportedException("TarInputStream Write not supported"); - } - - /// - /// Writes a byte to the current position in the file stream. - /// This operation is not supported and will throw a NotSupportedException - /// - /// The byte value to write. - /// Any access - public override void WriteByte(byte value) - { - throw new NotSupportedException("TarInputStream WriteByte not supported"); - } - - /// - /// Reads a byte from the current tar archive entry. - /// - /// A byte cast to an int; -1 if the at the end of the stream. - public override int ReadByte() - { - byte[] oneByteBuffer = new byte[1]; - int num = Read(oneByteBuffer, 0, 1); - if (num <= 0) - { - // return -1 to indicate that no byte was read. - return -1; - } - return oneByteBuffer[0]; - } - - /// - /// Reads bytes from the current tar archive entry. - /// - /// This method is aware of the boundaries of the current - /// entry in the archive and will deal with them appropriately - /// - /// - /// The buffer into which to place bytes read. - /// - /// - /// The offset at which to place bytes read. - /// - /// - /// The number of bytes to read. - /// - /// - /// The number of bytes read, or 0 at end of stream/EOF. - /// - public override int Read(byte[] buffer, int offset, int count) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - int totalRead = 0; - - if (entryOffset >= entrySize) - { - return 0; - } - - long numToRead = count; - - if ((numToRead + entryOffset) > entrySize) - { - numToRead = entrySize - entryOffset; - } - - if (readBuffer != null) - { - int sz = (numToRead > readBuffer.Length) ? readBuffer.Length : (int)numToRead; - - Array.Copy(readBuffer, 0, buffer, offset, sz); - - if (sz >= readBuffer.Length) - { - readBuffer = null; - } - else - { - int newLen = readBuffer.Length - sz; - byte[] newBuf = new byte[newLen]; - Array.Copy(readBuffer, sz, newBuf, 0, newLen); - readBuffer = newBuf; - } - - totalRead += sz; - numToRead -= sz; - offset += sz; - } - - while (numToRead > 0) - { - byte[] rec = tarBuffer.ReadBlock(); - if (rec == null) - { - // Unexpected EOF! - throw new TarException("unexpected EOF with " + numToRead + " bytes unread"); - } - - var sz = (int)numToRead; - int recLen = rec.Length; - - if (recLen > sz) - { - Array.Copy(rec, 0, buffer, offset, sz); - readBuffer = new byte[recLen - sz]; - Array.Copy(rec, sz, readBuffer, 0, recLen - sz); - } - else - { - sz = recLen; - Array.Copy(rec, 0, buffer, offset, recLen); - } - - totalRead += sz; - numToRead -= sz; - offset += sz; - } - - entryOffset += totalRead; - - return totalRead; - } - - /// - /// Closes this stream. Calls the TarBuffer's close() method. - /// The underlying stream is closed by the TarBuffer. - /// - protected override void Dispose(bool disposing) - { - if (disposing) - { - tarBuffer.Close(); - } - } - - #endregion Stream Overrides - - /// - /// Set the entry factory for this instance. - /// - /// The factory for creating new entries - public void SetEntryFactory(IEntryFactory factory) - { - entryFactory = factory; - } - - /// - /// Get the record size being used by this stream's TarBuffer. - /// - public int RecordSize - { - get { return tarBuffer.RecordSize; } - } - - /// - /// Get the record size being used by this stream's TarBuffer. - /// - /// - /// TarBuffer record size. - /// - [Obsolete("Use RecordSize property instead")] - public int GetRecordSize() - { - return tarBuffer.RecordSize; - } - - /// - /// Get the available data that can be read from the current - /// entry in the archive. This does not indicate how much data - /// is left in the entire archive, only in the current entry. - /// This value is determined from the entry's size header field - /// and the amount of data already read from the current entry. - /// - /// - /// The number of available bytes for the current entry. - /// - public long Available - { - get - { - return entrySize - entryOffset; - } - } - - /// - /// Skip bytes in the input buffer. This skips bytes in the - /// current entry's data, not the entire archive, and will - /// stop at the end of the current entry's data if the number - /// to skip extends beyond that point. - /// - /// - /// The number of bytes to skip. - /// - public void Skip(long skipCount) - { - // TODO: REVIEW efficiency of TarInputStream.Skip - // This is horribly inefficient, but it ensures that we - // properly skip over bytes via the TarBuffer... - // - byte[] skipBuf = new byte[8 * 1024]; - - for (long num = skipCount; num > 0;) - { - int toRead = num > skipBuf.Length ? skipBuf.Length : (int)num; - int numRead = Read(skipBuf, 0, toRead); - - if (numRead == -1) - { - break; - } - - num -= numRead; - } - } - - /// - /// Return a value of true if marking is supported; false otherwise. - /// - /// Currently marking is not supported, the return value is always false. - public bool IsMarkSupported - { - get - { - return false; - } - } - - /// - /// Since we do not support marking just yet, we do nothing. - /// - /// - /// The limit to mark. - /// - public void Mark(int markLimit) - { - } - - /// - /// Since we do not support marking just yet, we do nothing. - /// - public void Reset() - { - } - - /// - /// Get the next entry in this tar archive. This will skip - /// over any remaining data in the current entry, if there - /// is one, and place the input stream at the header of the - /// next entry, and read the header and instantiate a new - /// TarEntry from the header bytes and return that entry. - /// If there are no more entries in the archive, null will - /// be returned to indicate that the end of the archive has - /// been reached. - /// - /// - /// The next TarEntry in the archive, or null. - /// - public TarEntry GetNextEntry() - { - if (hasHitEOF) - { - return null; - } - - if (currentEntry != null) - { - SkipToNextEntry(); - } - - byte[] headerBuf = tarBuffer.ReadBlock(); - - if (headerBuf == null) - { - hasHitEOF = true; - } - else if (TarBuffer.IsEndOfArchiveBlock(headerBuf)) - { - hasHitEOF = true; - - // Read the second zero-filled block - tarBuffer.ReadBlock(); - } - else - { - hasHitEOF = false; - } - - if (hasHitEOF) - { - currentEntry = null; - } - else - { - try - { - var header = new TarHeader(); - header.ParseBuffer(headerBuf, encoding); - if (!header.IsChecksumValid) - { - throw new TarException("Header checksum is invalid"); - } - this.entryOffset = 0; - this.entrySize = header.Size; - - StringBuilder longName = null; - - if (header.TypeFlag == TarHeader.LF_GNU_LONGNAME) - { - byte[] nameBuffer = new byte[TarBuffer.BlockSize]; - long numToRead = this.entrySize; - - longName = new StringBuilder(); - - while (numToRead > 0) - { - int numRead = this.Read(nameBuffer, 0, (numToRead > nameBuffer.Length ? nameBuffer.Length : (int)numToRead)); - - if (numRead == -1) - { - throw new InvalidHeaderException("Failed to read long name entry"); - } - - longName.Append(TarHeader.ParseName(nameBuffer, 0, numRead, encoding).ToString()); - numToRead -= numRead; - } - - SkipToNextEntry(); - headerBuf = this.tarBuffer.ReadBlock(); - } - else if (header.TypeFlag == TarHeader.LF_GHDR) - { // POSIX global extended header - // Ignore things we dont understand completely for now - SkipToNextEntry(); - headerBuf = this.tarBuffer.ReadBlock(); - } - else if (header.TypeFlag == TarHeader.LF_XHDR) - { // POSIX extended header - byte[] nameBuffer = new byte[TarBuffer.BlockSize]; - long numToRead = this.entrySize; - - var xhr = new TarExtendedHeaderReader(); - - while (numToRead > 0) - { - int numRead = this.Read(nameBuffer, 0, (numToRead > nameBuffer.Length ? nameBuffer.Length : (int)numToRead)); - - if (numRead == -1) - { - throw new InvalidHeaderException("Failed to read long name entry"); - } - - xhr.Read(nameBuffer, numRead); - numToRead -= numRead; - } - - if (xhr.Headers.TryGetValue("path", out string name)) - { - longName = new StringBuilder(name); - } - - SkipToNextEntry(); - headerBuf = this.tarBuffer.ReadBlock(); - } - else if (header.TypeFlag == TarHeader.LF_GNU_VOLHDR) - { - // TODO: could show volume name when verbose - SkipToNextEntry(); - headerBuf = this.tarBuffer.ReadBlock(); - } - else if (header.TypeFlag != TarHeader.LF_NORMAL && - header.TypeFlag != TarHeader.LF_OLDNORM && - header.TypeFlag != TarHeader.LF_LINK && - header.TypeFlag != TarHeader.LF_SYMLINK && - header.TypeFlag != TarHeader.LF_DIR) - { - // Ignore things we dont understand completely for now - SkipToNextEntry(); - headerBuf = tarBuffer.ReadBlock(); - } - - if (entryFactory == null) - { - currentEntry = new TarEntry(headerBuf, encoding); - if (longName != null) - { - currentEntry.Name = longName.ToString(); - } - } - else - { - currentEntry = entryFactory.CreateEntry(headerBuf); - } - - // Magic was checked here for 'ustar' but there are multiple valid possibilities - // so this is not done anymore. - - entryOffset = 0; - - // TODO: Review How do we resolve this discrepancy?! - entrySize = this.currentEntry.Size; - } - catch (InvalidHeaderException ex) - { - entrySize = 0; - entryOffset = 0; - currentEntry = null; - string errorText = string.Format("Bad header in record {0} block {1} {2}", - tarBuffer.CurrentRecord, tarBuffer.CurrentBlock, ex.Message); - throw new InvalidHeaderException(errorText); - } - } - return currentEntry; - } - - /// - /// Copies the contents of the current tar archive entry directly into - /// an output stream. - /// - /// - /// The OutputStream into which to write the entry's data. - /// - public void CopyEntryContents(Stream outputStream) - { - byte[] tempBuffer = new byte[32 * 1024]; - - while (true) - { - int numRead = Read(tempBuffer, 0, tempBuffer.Length); - if (numRead <= 0) - { - break; - } - outputStream.Write(tempBuffer, 0, numRead); - } - } - - private void SkipToNextEntry() - { - long numToSkip = entrySize - entryOffset; - - if (numToSkip > 0) - { - Skip(numToSkip); - } - - readBuffer = null; - } - - /// - /// This interface is provided, along with the method , to allow - /// the programmer to have their own subclass instantiated for the - /// entries return from . - /// - public interface IEntryFactory - { - // This interface does not considering name encoding. - // How this interface should be? - /// - /// Create an entry based on name alone - /// - /// - /// Name of the new EntryPointNotFoundException to create - /// - /// created TarEntry or descendant class - TarEntry CreateEntry(string name); - - /// - /// Create an instance based on an actual file - /// - /// - /// Name of file to represent in the entry - /// - /// - /// Created TarEntry or descendant class - /// - TarEntry CreateEntryFromFile(string fileName); - - /// - /// Create a tar entry based on the header information passed - /// - /// - /// Buffer containing header information to create an entry from. - /// - /// - /// Created TarEntry or descendant class - /// - TarEntry CreateEntry(byte[] headerBuffer); - } - - /// - /// Standard entry factory class creating instances of the class TarEntry - /// - public class EntryFactoryAdapter : IEntryFactory - { - Encoding nameEncoding; - /// - /// Construct standard entry factory class with ASCII name encoding - /// - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public EntryFactoryAdapter() - { - } - /// - /// Construct standard entry factory with name encoding - /// - /// The used for the Name fields, or null for ASCII only - public EntryFactoryAdapter(Encoding nameEncoding) - { - this.nameEncoding = nameEncoding; - } - /// - /// Create a based on named - /// - /// The name to use for the entry - /// A new - public TarEntry CreateEntry(string name) - { - return TarEntry.CreateTarEntry(name); - } - - /// - /// Create a tar entry with details obtained from file - /// - /// The name of the file to retrieve details from. - /// A new - public TarEntry CreateEntryFromFile(string fileName) - { - return TarEntry.CreateEntryFromFile(fileName); - } - - /// - /// Create an entry based on details in header - /// - /// The buffer containing entry details. - /// A new - public TarEntry CreateEntry(byte[] headerBuffer) - { - return new TarEntry(headerBuffer, nameEncoding); - } - } - - #region Instance Fields - - /// - /// Flag set when last block has been read - /// - protected bool hasHitEOF; - - /// - /// Size of this entry as recorded in header - /// - protected long entrySize; - - /// - /// Number of bytes read for this entry so far - /// - protected long entryOffset; - - /// - /// Buffer used with calls to Read() - /// - protected byte[] readBuffer; - - /// - /// Working buffer - /// - protected TarBuffer tarBuffer; - - /// - /// Current entry being read - /// - private TarEntry currentEntry; - - /// - /// Factory used to create TarEntry or descendant class instance - /// - protected IEntryFactory entryFactory; - - /// - /// Stream used as the source of input data. - /// - private readonly Stream inputStream; - - private readonly Encoding encoding; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarOutputStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarOutputStream.cs deleted file mode 100644 index 14d981a6f..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarOutputStream.cs +++ /dev/null @@ -1,523 +0,0 @@ -using System; -using System.IO; -using System.Text; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Tar -{ - /// - /// The TarOutputStream writes a UNIX tar archive as an OutputStream. - /// Methods are provided to put entries, and then write their contents - /// by writing to this stream using write(). - /// - /// public - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class TarOutputStream : Stream - { - #region Constructors - - /// - /// Construct TarOutputStream using default block factor - /// - /// stream to write to - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public TarOutputStream(Stream outputStream) - : this(outputStream, TarBuffer.DefaultBlockFactor) - { - } - - /// - /// Construct TarOutputStream using default block factor - /// - /// stream to write to - /// The used for the Name fields, or null for ASCII only - public TarOutputStream(Stream outputStream, Encoding nameEncoding) - : this(outputStream, TarBuffer.DefaultBlockFactor, nameEncoding) - { - } - - /// - /// Construct TarOutputStream with user specified block factor - /// - /// stream to write to - /// blocking factor - [Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")] - public TarOutputStream(Stream outputStream, int blockFactor) - { - if (outputStream == null) - { - throw new ArgumentNullException(nameof(outputStream)); - } - - this.outputStream = outputStream; - buffer = TarBuffer.CreateOutputTarBuffer(outputStream, blockFactor); - - assemblyBuffer = new byte[TarBuffer.BlockSize]; - blockBuffer = new byte[TarBuffer.BlockSize]; - } - - /// - /// Construct TarOutputStream with user specified block factor - /// - /// stream to write to - /// blocking factor - /// The used for the Name fields, or null for ASCII only - public TarOutputStream(Stream outputStream, int blockFactor, Encoding nameEncoding) - { - if (outputStream == null) - { - throw new ArgumentNullException(nameof(outputStream)); - } - - this.outputStream = outputStream; - buffer = TarBuffer.CreateOutputTarBuffer(outputStream, blockFactor); - - assemblyBuffer = new byte[TarBuffer.BlockSize]; - blockBuffer = new byte[TarBuffer.BlockSize]; - - this.nameEncoding = nameEncoding; - } - - #endregion Constructors - - /// - /// Gets or sets a flag indicating ownership of underlying stream. - /// When the flag is true will close the underlying stream also. - /// - /// The default value is true. - public bool IsStreamOwner - { - get { return buffer.IsStreamOwner; } - set { buffer.IsStreamOwner = value; } - } - - /// - /// true if the stream supports reading; otherwise, false. - /// - public override bool CanRead - { - get - { - return outputStream.CanRead; - } - } - - /// - /// true if the stream supports seeking; otherwise, false. - /// - public override bool CanSeek - { - get - { - return outputStream.CanSeek; - } - } - - /// - /// true if stream supports writing; otherwise, false. - /// - public override bool CanWrite - { - get - { - return outputStream.CanWrite; - } - } - - /// - /// length of stream in bytes - /// - public override long Length - { - get - { - return outputStream.Length; - } - } - - /// - /// gets or sets the position within the current stream. - /// - public override long Position - { - get - { - return outputStream.Position; - } - set - { - outputStream.Position = value; - } - } - - /// - /// set the position within the current stream - /// - /// The offset relative to the to seek to - /// The to seek from. - /// The new position in the stream. - public override long Seek(long offset, SeekOrigin origin) - { - return outputStream.Seek(offset, origin); - } - - /// - /// Set the length of the current stream - /// - /// The new stream length. - public override void SetLength(long value) - { - outputStream.SetLength(value); - } - - /// - /// Read a byte from the stream and advance the position within the stream - /// by one byte or returns -1 if at the end of the stream. - /// - /// The byte value or -1 if at end of stream - public override int ReadByte() - { - return outputStream.ReadByte(); - } - - /// - /// read bytes from the current stream and advance the position within the - /// stream by the number of bytes read. - /// - /// The buffer to store read bytes in. - /// The index into the buffer to being storing bytes at. - /// The desired number of bytes to read. - /// The total number of bytes read, or zero if at the end of the stream. - /// The number of bytes may be less than the count - /// requested if data is not available. - public override int Read(byte[] buffer, int offset, int count) - { - return outputStream.Read(buffer, offset, count); - } - - /// - /// All buffered data is written to destination - /// - public override void Flush() - { - outputStream.Flush(); - } - - /// - /// Ends the TAR archive without closing the underlying OutputStream. - /// The result is that the EOF block of nulls is written. - /// - public void Finish() - { - if (IsEntryOpen) - { - CloseEntry(); - } - WriteEofBlock(); - } - - /// - /// Ends the TAR archive and closes the underlying OutputStream. - /// - /// This means that Finish() is called followed by calling the - /// TarBuffer's Close(). - protected override void Dispose(bool disposing) - { - if (!isClosed) - { - isClosed = true; - Finish(); - buffer.Close(); - } - } - - /// - /// Get the record size being used by this stream's TarBuffer. - /// - public int RecordSize - { - get { return buffer.RecordSize; } - } - - /// - /// Get the record size being used by this stream's TarBuffer. - /// - /// - /// The TarBuffer record size. - /// - [Obsolete("Use RecordSize property instead")] - public int GetRecordSize() - { - return buffer.RecordSize; - } - - /// - /// Get a value indicating whether an entry is open, requiring more data to be written. - /// - private bool IsEntryOpen - { - get { return (currBytes < currSize); } - } - - /// - /// Put an entry on the output stream. This writes the entry's - /// header and positions the output stream for writing - /// the contents of the entry. Once this method is called, the - /// stream is ready for calls to write() to write the entry's - /// contents. Once the contents are written, closeEntry() - /// MUST be called to ensure that all buffered data - /// is completely written to the output stream. - /// - /// - /// The TarEntry to be written to the archive. - /// - public void PutNextEntry(TarEntry entry) - { - if (entry == null) - { - throw new ArgumentNullException(nameof(entry)); - } - - var namelen = nameEncoding != null ? nameEncoding.GetByteCount(entry.TarHeader.Name) : entry.TarHeader.Name.Length; - - if (namelen > TarHeader.NAMELEN) - { - var longHeader = new TarHeader(); - longHeader.TypeFlag = TarHeader.LF_GNU_LONGNAME; - longHeader.Name = longHeader.Name + "././@LongLink"; - longHeader.Mode = 420;//644 by default - longHeader.UserId = entry.UserId; - longHeader.GroupId = entry.GroupId; - longHeader.GroupName = entry.GroupName; - longHeader.UserName = entry.UserName; - longHeader.LinkName = ""; - longHeader.Size = namelen + 1; // Plus one to avoid dropping last char - - longHeader.WriteHeader(blockBuffer, nameEncoding); - buffer.WriteBlock(blockBuffer); // Add special long filename header block - - int nameCharIndex = 0; - - while (nameCharIndex < namelen + 1 /* we've allocated one for the null char, now we must make sure it gets written out */) - { - Array.Clear(blockBuffer, 0, blockBuffer.Length); - TarHeader.GetAsciiBytes(entry.TarHeader.Name, nameCharIndex, this.blockBuffer, 0, TarBuffer.BlockSize, nameEncoding); // This func handles OK the extra char out of string length - nameCharIndex += TarBuffer.BlockSize; - buffer.WriteBlock(blockBuffer); - } - } - - entry.WriteEntryHeader(blockBuffer, nameEncoding); - buffer.WriteBlock(blockBuffer); - - currBytes = 0; - - currSize = entry.IsDirectory ? 0 : entry.Size; - } - - /// - /// Close an entry. This method MUST be called for all file - /// entries that contain data. The reason is that we must - /// buffer data written to the stream in order to satisfy - /// the buffer's block based writes. Thus, there may be - /// data fragments still being assembled that must be written - /// to the output stream before this entry is closed and the - /// next entry written. - /// - public void CloseEntry() - { - if (assemblyBufferLength > 0) - { - Array.Clear(assemblyBuffer, assemblyBufferLength, assemblyBuffer.Length - assemblyBufferLength); - - buffer.WriteBlock(assemblyBuffer); - - currBytes += assemblyBufferLength; - assemblyBufferLength = 0; - } - - if (currBytes < currSize) - { - string errorText = string.Format( - "Entry closed at '{0}' before the '{1}' bytes specified in the header were written", - currBytes, currSize); - throw new TarException(errorText); - } - } - - /// - /// Writes a byte to the current tar archive entry. - /// This method simply calls Write(byte[], int, int). - /// - /// - /// The byte to be written. - /// - public override void WriteByte(byte value) - { - Write(new byte[] { value }, 0, 1); - } - - /// - /// Writes bytes to the current tar archive entry. This method - /// is aware of the current entry and will throw an exception if - /// you attempt to write bytes past the length specified for the - /// current entry. The method is also (painfully) aware of the - /// record buffering required by TarBuffer, and manages buffers - /// that are not a multiple of recordsize in length, including - /// assembling records from small buffers. - /// - /// - /// The buffer to write to the archive. - /// - /// - /// The offset in the buffer from which to get bytes. - /// - /// - /// The number of bytes to write. - /// - public override void Write(byte[] buffer, int offset, int count) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (offset < 0) - { - throw new ArgumentOutOfRangeException(nameof(offset), "Cannot be negative"); - } - - if (buffer.Length - offset < count) - { - throw new ArgumentException("offset and count combination is invalid"); - } - - if (count < 0) - { - throw new ArgumentOutOfRangeException(nameof(count), "Cannot be negative"); - } - - if ((currBytes + count) > currSize) - { - string errorText = string.Format("request to write '{0}' bytes exceeds size in header of '{1}' bytes", - count, this.currSize); - throw new ArgumentOutOfRangeException(nameof(count), errorText); - } - - // - // We have to deal with assembly!!! - // The programmer can be writing little 32 byte chunks for all - // we know, and we must assemble complete blocks for writing. - // TODO REVIEW Maybe this should be in TarBuffer? Could that help to - // eliminate some of the buffer copying. - // - if (assemblyBufferLength > 0) - { - if ((assemblyBufferLength + count) >= blockBuffer.Length) - { - int aLen = blockBuffer.Length - assemblyBufferLength; - - Array.Copy(assemblyBuffer, 0, blockBuffer, 0, assemblyBufferLength); - Array.Copy(buffer, offset, blockBuffer, assemblyBufferLength, aLen); - - this.buffer.WriteBlock(blockBuffer); - - currBytes += blockBuffer.Length; - - offset += aLen; - count -= aLen; - - assemblyBufferLength = 0; - } - else - { - Array.Copy(buffer, offset, assemblyBuffer, assemblyBufferLength, count); - offset += count; - assemblyBufferLength += count; - count -= count; - } - } - - // - // When we get here we have EITHER: - // o An empty "assembly" buffer. - // o No bytes to write (count == 0) - // - while (count > 0) - { - if (count < blockBuffer.Length) - { - Array.Copy(buffer, offset, assemblyBuffer, assemblyBufferLength, count); - assemblyBufferLength += count; - break; - } - - this.buffer.WriteBlock(buffer, offset); - - int bufferLength = blockBuffer.Length; - currBytes += bufferLength; - count -= bufferLength; - offset += bufferLength; - } - } - - /// - /// Write an EOF (end of archive) block to the tar archive. - /// The end of the archive is indicated by two blocks consisting entirely of zero bytes. - /// - private void WriteEofBlock() - { - Array.Clear(blockBuffer, 0, blockBuffer.Length); - buffer.WriteBlock(blockBuffer); - buffer.WriteBlock(blockBuffer); - } - - #region Instance Fields - - /// - /// bytes written for this entry so far - /// - private long currBytes; - - /// - /// current 'Assembly' buffer length - /// - private int assemblyBufferLength; - - /// - /// Flag indicating whether this instance has been closed or not. - /// - private bool isClosed; - - /// - /// Size for the current entry - /// - protected long currSize; - - /// - /// single block working buffer - /// - protected byte[] blockBuffer; - - /// - /// 'Assembly' buffer used to assemble data before writing - /// - protected byte[] assemblyBuffer; - - /// - /// TarBuffer used to provide correct blocking factor - /// - protected TarBuffer buffer; - - /// - /// the destination stream for the archive contents - /// - protected Stream outputStream; - - /// - /// name encoding - /// - protected Encoding nameEncoding; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Deflater.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Deflater.cs deleted file mode 100644 index 9584e4fd6..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Deflater.cs +++ /dev/null @@ -1,605 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression -{ - /// - /// This is the Deflater class. The deflater class compresses input - /// with the deflate algorithm described in RFC 1951. It has several - /// compression levels and three different strategies described below. - /// - /// This class is not thread safe. This is inherent in the API, due - /// to the split of deflate and setInput. - /// - /// author of the original java version : Jochen Hoenicke - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class Deflater - { - #region Deflater Documentation - - /* - * The Deflater can do the following state transitions: - * - * (1) -> INIT_STATE ----> INIT_FINISHING_STATE ---. - * / | (2) (5) | - * / v (5) | - * (3)| SETDICT_STATE ---> SETDICT_FINISHING_STATE |(3) - * \ | (3) | ,--------' - * | | | (3) / - * v v (5) v v - * (1) -> BUSY_STATE ----> FINISHING_STATE - * | (6) - * v - * FINISHED_STATE - * \_____________________________________/ - * | (7) - * v - * CLOSED_STATE - * - * (1) If we should produce a header we start in INIT_STATE, otherwise - * we start in BUSY_STATE. - * (2) A dictionary may be set only when we are in INIT_STATE, then - * we change the state as indicated. - * (3) Whether a dictionary is set or not, on the first call of deflate - * we change to BUSY_STATE. - * (4) -- intentionally left blank -- :) - * (5) FINISHING_STATE is entered, when flush() is called to indicate that - * there is no more INPUT. There are also states indicating, that - * the header wasn't written yet. - * (6) FINISHED_STATE is entered, when everything has been flushed to the - * internal pending output buffer. - * (7) At any time (7) - * - */ - - #endregion Deflater Documentation - - #region Public Constants - - /// - /// The best and slowest compression level. This tries to find very - /// long and distant string repetitions. - /// - public const int BEST_COMPRESSION = 9; - - /// - /// The worst but fastest compression level. - /// - public const int BEST_SPEED = 1; - - /// - /// The default compression level. - /// - public const int DEFAULT_COMPRESSION = -1; - - /// - /// This level won't compress at all but output uncompressed blocks. - /// - public const int NO_COMPRESSION = 0; - - /// - /// The compression method. This is the only method supported so far. - /// There is no need to use this constant at all. - /// - public const int DEFLATED = 8; - - #endregion Public Constants - - #region Public Enum - - /// - /// Compression Level as an enum for safer use - /// - public enum CompressionLevel - { - /// - /// The best and slowest compression level. This tries to find very - /// long and distant string repetitions. - /// - BEST_COMPRESSION = Deflater.BEST_COMPRESSION, - - /// - /// The worst but fastest compression level. - /// - BEST_SPEED = Deflater.BEST_SPEED, - - /// - /// The default compression level. - /// - DEFAULT_COMPRESSION = Deflater.DEFAULT_COMPRESSION, - - /// - /// This level won't compress at all but output uncompressed blocks. - /// - NO_COMPRESSION = Deflater.NO_COMPRESSION, - - /// - /// The compression method. This is the only method supported so far. - /// There is no need to use this constant at all. - /// - DEFLATED = Deflater.DEFLATED - } - - #endregion Public Enum - - #region Local Constants - - private const int IS_SETDICT = 0x01; - private const int IS_FLUSHING = 0x04; - private const int IS_FINISHING = 0x08; - - private const int INIT_STATE = 0x00; - private const int SETDICT_STATE = 0x01; - - // private static int INIT_FINISHING_STATE = 0x08; - // private static int SETDICT_FINISHING_STATE = 0x09; - private const int BUSY_STATE = 0x10; - - private const int FLUSHING_STATE = 0x14; - private const int FINISHING_STATE = 0x1c; - private const int FINISHED_STATE = 0x1e; - private const int CLOSED_STATE = 0x7f; - - #endregion Local Constants - - #region Constructors - - /// - /// Creates a new deflater with default compression level. - /// - public Deflater() : this(DEFAULT_COMPRESSION, false) - { - } - - /// - /// Creates a new deflater with given compression level. - /// - /// - /// the compression level, a value between NO_COMPRESSION - /// and BEST_COMPRESSION, or DEFAULT_COMPRESSION. - /// - /// if lvl is out of range. - public Deflater(int level) : this(level, false) - { - } - - /// - /// Creates a new deflater with given compression level. - /// - /// - /// the compression level, a value between NO_COMPRESSION - /// and BEST_COMPRESSION. - /// - /// - /// true, if we should suppress the Zlib/RFC1950 header at the - /// beginning and the adler checksum at the end of the output. This is - /// useful for the GZIP/PKZIP formats. - /// - /// if lvl is out of range. - public Deflater(int level, bool noZlibHeaderOrFooter) - { - if (level == DEFAULT_COMPRESSION) - { - level = 6; - } - else if (level < NO_COMPRESSION || level > BEST_COMPRESSION) - { - throw new ArgumentOutOfRangeException(nameof(level)); - } - - pending = new DeflaterPending(); - engine = new DeflaterEngine(pending, noZlibHeaderOrFooter); - this.noZlibHeaderOrFooter = noZlibHeaderOrFooter; - SetStrategy(DeflateStrategy.Default); - SetLevel(level); - Reset(); - } - - #endregion Constructors - - /// - /// Resets the deflater. The deflater acts afterwards as if it was - /// just created with the same compression level and strategy as it - /// had before. - /// - public void Reset() - { - state = (noZlibHeaderOrFooter ? BUSY_STATE : INIT_STATE); - totalOut = 0; - pending.Reset(); - engine.Reset(); - } - - /// - /// Gets the current adler checksum of the data that was processed so far. - /// - public int Adler - { - get - { - return engine.Adler; - } - } - - /// - /// Gets the number of input bytes processed so far. - /// - public long TotalIn - { - get - { - return engine.TotalIn; - } - } - - /// - /// Gets the number of output bytes so far. - /// - public long TotalOut - { - get - { - return totalOut; - } - } - - /// - /// Flushes the current input block. Further calls to deflate() will - /// produce enough output to inflate everything in the current input - /// block. This is not part of Sun's JDK so I have made it package - /// private. It is used by DeflaterOutputStream to implement - /// flush(). - /// - public void Flush() - { - state |= IS_FLUSHING; - } - - /// - /// Finishes the deflater with the current input block. It is an error - /// to give more input after this method was called. This method must - /// be called to force all bytes to be flushed. - /// - public void Finish() - { - state |= (IS_FLUSHING | IS_FINISHING); - } - - /// - /// Returns true if the stream was finished and no more output bytes - /// are available. - /// - public bool IsFinished - { - get - { - return (state == FINISHED_STATE) && pending.IsFlushed; - } - } - - /// - /// Returns true, if the input buffer is empty. - /// You should then call setInput(). - /// NOTE: This method can also return true when the stream - /// was finished. - /// - public bool IsNeedingInput - { - get - { - return engine.NeedsInput(); - } - } - - /// - /// Sets the data which should be compressed next. This should be only - /// called when needsInput indicates that more input is needed. - /// If you call setInput when needsInput() returns false, the - /// previous input that is still pending will be thrown away. - /// The given byte array should not be changed, before needsInput() returns - /// true again. - /// This call is equivalent to setInput(input, 0, input.length). - /// - /// - /// the buffer containing the input data. - /// - /// - /// if the buffer was finished() or ended(). - /// - public void SetInput(byte[] input) - { - SetInput(input, 0, input.Length); - } - - /// - /// Sets the data which should be compressed next. This should be - /// only called when needsInput indicates that more input is needed. - /// The given byte array should not be changed, before needsInput() returns - /// true again. - /// - /// - /// the buffer containing the input data. - /// - /// - /// the start of the data. - /// - /// - /// the number of data bytes of input. - /// - /// - /// if the buffer was Finish()ed or if previous input is still pending. - /// - public void SetInput(byte[] input, int offset, int count) - { - if ((state & IS_FINISHING) != 0) - { - throw new InvalidOperationException("Finish() already called"); - } - engine.SetInput(input, offset, count); - } - - /// - /// Sets the compression level. There is no guarantee of the exact - /// position of the change, but if you call this when needsInput is - /// true the change of compression level will occur somewhere near - /// before the end of the so far given input. - /// - /// - /// the new compression level. - /// - public void SetLevel(int level) - { - if (level == DEFAULT_COMPRESSION) - { - level = 6; - } - else if (level < NO_COMPRESSION || level > BEST_COMPRESSION) - { - throw new ArgumentOutOfRangeException(nameof(level)); - } - - if (this.level != level) - { - this.level = level; - engine.SetLevel(level); - } - } - - /// - /// Get current compression level - /// - /// Returns the current compression level - public int GetLevel() - { - return level; - } - - /// - /// Sets the compression strategy. Strategy is one of - /// DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED. For the exact - /// position where the strategy is changed, the same as for - /// SetLevel() applies. - /// - /// - /// The new compression strategy. - /// - public void SetStrategy(DeflateStrategy strategy) - { - engine.Strategy = strategy; - } - - /// - /// Deflates the current input block with to the given array. - /// - /// - /// The buffer where compressed data is stored - /// - /// - /// The number of compressed bytes added to the output, or 0 if either - /// IsNeedingInput() or IsFinished returns true or length is zero. - /// - public int Deflate(byte[] output) - { - return Deflate(output, 0, output.Length); - } - - /// - /// Deflates the current input block to the given array. - /// - /// - /// Buffer to store the compressed data. - /// - /// - /// Offset into the output array. - /// - /// - /// The maximum number of bytes that may be stored. - /// - /// - /// The number of compressed bytes added to the output, or 0 if either - /// needsInput() or finished() returns true or length is zero. - /// - /// - /// If Finish() was previously called. - /// - /// - /// If offset or length don't match the array length. - /// - public int Deflate(byte[] output, int offset, int length) - { - int origLength = length; - - if (state == CLOSED_STATE) - { - throw new InvalidOperationException("Deflater closed"); - } - - if (state < BUSY_STATE) - { - // output header - int header = (DEFLATED + - ((DeflaterConstants.MAX_WBITS - 8) << 4)) << 8; - int level_flags = (level - 1) >> 1; - if (level_flags < 0 || level_flags > 3) - { - level_flags = 3; - } - header |= level_flags << 6; - if ((state & IS_SETDICT) != 0) - { - // Dictionary was set - header |= DeflaterConstants.PRESET_DICT; - } - header += 31 - (header % 31); - - pending.WriteShortMSB(header); - if ((state & IS_SETDICT) != 0) - { - int chksum = engine.Adler; - engine.ResetAdler(); - pending.WriteShortMSB(chksum >> 16); - pending.WriteShortMSB(chksum & 0xffff); - } - - state = BUSY_STATE | (state & (IS_FLUSHING | IS_FINISHING)); - } - - for (; ; ) - { - int count = pending.Flush(output, offset, length); - offset += count; - totalOut += count; - length -= count; - - if (length == 0 || state == FINISHED_STATE) - { - break; - } - - if (!engine.Deflate((state & IS_FLUSHING) != 0, (state & IS_FINISHING) != 0)) - { - switch (state) - { - case BUSY_STATE: - // We need more input now - return origLength - length; - - case FLUSHING_STATE: - if (level != NO_COMPRESSION) - { - /* We have to supply some lookahead. 8 bit lookahead - * is needed by the zlib inflater, and we must fill - * the next byte, so that all bits are flushed. - */ - int neededbits = 8 + ((-pending.BitCount) & 7); - while (neededbits > 0) - { - /* write a static tree block consisting solely of - * an EOF: - */ - pending.WriteBits(2, 10); - neededbits -= 10; - } - } - state = BUSY_STATE; - break; - - case FINISHING_STATE: - pending.AlignToByte(); - - // Compressed data is complete. Write footer information if required. - if (!noZlibHeaderOrFooter) - { - int adler = engine.Adler; - pending.WriteShortMSB(adler >> 16); - pending.WriteShortMSB(adler & 0xffff); - } - state = FINISHED_STATE; - break; - } - } - } - return origLength - length; - } - - /// - /// Sets the dictionary which should be used in the deflate process. - /// This call is equivalent to setDictionary(dict, 0, dict.Length). - /// - /// - /// the dictionary. - /// - /// - /// if SetInput () or Deflate () were already called or another dictionary was already set. - /// - public void SetDictionary(byte[] dictionary) - { - SetDictionary(dictionary, 0, dictionary.Length); - } - - /// - /// Sets the dictionary which should be used in the deflate process. - /// The dictionary is a byte array containing strings that are - /// likely to occur in the data which should be compressed. The - /// dictionary is not stored in the compressed output, only a - /// checksum. To decompress the output you need to supply the same - /// dictionary again. - /// - /// - /// The dictionary data - /// - /// - /// The index where dictionary information commences. - /// - /// - /// The number of bytes in the dictionary. - /// - /// - /// If SetInput () or Deflate() were already called or another dictionary was already set. - /// - public void SetDictionary(byte[] dictionary, int index, int count) - { - if (state != INIT_STATE) - { - throw new InvalidOperationException(); - } - - state = SETDICT_STATE; - engine.SetDictionary(dictionary, index, count); - } - - #region Instance Fields - - /// - /// Compression level. - /// - private int level; - - /// - /// If true no Zlib/RFC1950 headers or footers are generated - /// - private bool noZlibHeaderOrFooter; - - /// - /// The current state. - /// - private int state; - - /// - /// The total bytes of output written. - /// - private long totalOut; - - /// - /// The pending output. - /// - private DeflaterPending pending; - - /// - /// The deflater engine. - /// - private DeflaterEngine engine; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterConstants.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterConstants.cs deleted file mode 100644 index d693c32b1..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterConstants.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression -{ - /// - /// This class contains constants used for deflation. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "kept for backwards compatibility")] - public static class DeflaterConstants - { - /// - /// Set to true to enable debugging - /// - public const bool DEBUGGING = false; - - /// - /// Written to Zip file to identify a stored block - /// - public const int STORED_BLOCK = 0; - - /// - /// Identifies static tree in Zip file - /// - public const int STATIC_TREES = 1; - - /// - /// Identifies dynamic tree in Zip file - /// - public const int DYN_TREES = 2; - - /// - /// Header flag indicating a preset dictionary for deflation - /// - public const int PRESET_DICT = 0x20; - - /// - /// Sets internal buffer sizes for Huffman encoding - /// - public const int DEFAULT_MEM_LEVEL = 8; - - /// - /// Internal compression engine constant - /// - public const int MAX_MATCH = 258; - - /// - /// Internal compression engine constant - /// - public const int MIN_MATCH = 3; - - /// - /// Internal compression engine constant - /// - public const int MAX_WBITS = 15; - - /// - /// Internal compression engine constant - /// - public const int WSIZE = 1 << MAX_WBITS; - - /// - /// Internal compression engine constant - /// - public const int WMASK = WSIZE - 1; - - /// - /// Internal compression engine constant - /// - public const int HASH_BITS = DEFAULT_MEM_LEVEL + 7; - - /// - /// Internal compression engine constant - /// - public const int HASH_SIZE = 1 << HASH_BITS; - - /// - /// Internal compression engine constant - /// - public const int HASH_MASK = HASH_SIZE - 1; - - /// - /// Internal compression engine constant - /// - public const int HASH_SHIFT = (HASH_BITS + MIN_MATCH - 1) / MIN_MATCH; - - /// - /// Internal compression engine constant - /// - public const int MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1; - - /// - /// Internal compression engine constant - /// - public const int MAX_DIST = WSIZE - MIN_LOOKAHEAD; - - /// - /// Internal compression engine constant - /// - public const int PENDING_BUF_SIZE = 1 << (DEFAULT_MEM_LEVEL + 8); - - /// - /// Internal compression engine constant - /// - public static int MAX_BLOCK_SIZE = Math.Min(65535, PENDING_BUF_SIZE - 5); - - /// - /// Internal compression engine constant - /// - public const int DEFLATE_STORED = 0; - - /// - /// Internal compression engine constant - /// - public const int DEFLATE_FAST = 1; - - /// - /// Internal compression engine constant - /// - public const int DEFLATE_SLOW = 2; - - /// - /// Internal compression engine constant - /// - public static int[] GOOD_LENGTH = { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 }; - - /// - /// Internal compression engine constant - /// - public static int[] MAX_LAZY = { 0, 4, 5, 6, 4, 16, 16, 32, 128, 258 }; - - /// - /// Internal compression engine constant - /// - public static int[] NICE_LENGTH = { 0, 8, 16, 32, 16, 32, 128, 128, 258, 258 }; - - /// - /// Internal compression engine constant - /// - public static int[] MAX_CHAIN = { 0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096 }; - - /// - /// Internal compression engine constant - /// - public static int[] COMPR_FUNC = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 }; - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterEngine.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterEngine.cs deleted file mode 100644 index 3177e0d1c..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterEngine.cs +++ /dev/null @@ -1,948 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Checksum; -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression -{ - /// - /// Strategies for deflater - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public enum DeflateStrategy - { - /// - /// The default strategy - /// - Default = 0, - - /// - /// This strategy will only allow longer string repetitions. It is - /// useful for random data with a small character set. - /// - Filtered = 1, - - /// - /// This strategy will not look for string repetitions at all. It - /// only encodes with Huffman trees (which means, that more common - /// characters get a smaller encoding. - /// - HuffmanOnly = 2 - } - - // DEFLATE ALGORITHM: - // - // The uncompressed stream is inserted into the window array. When - // the window array is full the first half is thrown away and the - // second half is copied to the beginning. - // - // The head array is a hash table. Three characters build a hash value - // and they the value points to the corresponding index in window of - // the last string with this hash. The prev array implements a - // linked list of matches with the same hash: prev[index & WMASK] points - // to the previous index with the same hash. - // - - /// - /// Low level compression engine for deflate algorithm which uses a 32K sliding window - /// with secondary compression from Huffman/Shannon-Fano codes. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class DeflaterEngine - { - #region Constants - - private const int TooFar = 4096; - - #endregion Constants - - #region Constructors - - /// - /// Construct instance with pending buffer - /// Adler calculation will be performed - /// - /// - /// Pending buffer to use - /// - public DeflaterEngine(DeflaterPending pending) - : this (pending, false) - { - } - - - - /// - /// Construct instance with pending buffer - /// - /// - /// Pending buffer to use - /// - /// - /// If no adler calculation should be performed - /// - public DeflaterEngine(DeflaterPending pending, bool noAdlerCalculation) - { - this.pending = pending; - huffman = new DeflaterHuffman(pending); - if (!noAdlerCalculation) - adler = new Adler32(); - - window = new byte[2 * DeflaterConstants.WSIZE]; - head = new short[DeflaterConstants.HASH_SIZE]; - prev = new short[DeflaterConstants.WSIZE]; - - // We start at index 1, to avoid an implementation deficiency, that - // we cannot build a repeat pattern at index 0. - blockStart = strstart = 1; - } - - #endregion Constructors - - /// - /// Deflate drives actual compression of data - /// - /// True to flush input buffers - /// Finish deflation with the current input. - /// Returns true if progress has been made. - public bool Deflate(bool flush, bool finish) - { - bool progress; - do - { - FillWindow(); - bool canFlush = flush && (inputOff == inputEnd); - -#if DebugDeflation - if (DeflaterConstants.DEBUGGING) { - Console.WriteLine("window: [" + blockStart + "," + strstart + "," - + lookahead + "], " + compressionFunction + "," + canFlush); - } -#endif - switch (compressionFunction) - { - case DeflaterConstants.DEFLATE_STORED: - progress = DeflateStored(canFlush, finish); - break; - - case DeflaterConstants.DEFLATE_FAST: - progress = DeflateFast(canFlush, finish); - break; - - case DeflaterConstants.DEFLATE_SLOW: - progress = DeflateSlow(canFlush, finish); - break; - - default: - throw new InvalidOperationException("unknown compressionFunction"); - } - } while (pending.IsFlushed && progress); // repeat while we have no pending output and progress was made - return progress; - } - - /// - /// Sets input data to be deflated. Should only be called when NeedsInput() - /// returns true - /// - /// The buffer containing input data. - /// The offset of the first byte of data. - /// The number of bytes of data to use as input. - public void SetInput(byte[] buffer, int offset, int count) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (offset < 0) - { - throw new ArgumentOutOfRangeException(nameof(offset)); - } - - if (count < 0) - { - throw new ArgumentOutOfRangeException(nameof(count)); - } - - if (inputOff < inputEnd) - { - throw new InvalidOperationException("Old input was not completely processed"); - } - - int end = offset + count; - - /* We want to throw an ArrayIndexOutOfBoundsException early. The - * check is very tricky: it also handles integer wrap around. - */ - if ((offset > end) || (end > buffer.Length)) - { - throw new ArgumentOutOfRangeException(nameof(count)); - } - - inputBuf = buffer; - inputOff = offset; - inputEnd = end; - } - - /// - /// Determines if more input is needed. - /// - /// Return true if input is needed via SetInput - public bool NeedsInput() - { - return (inputEnd == inputOff); - } - - /// - /// Set compression dictionary - /// - /// The buffer containing the dictionary data - /// The offset in the buffer for the first byte of data - /// The length of the dictionary data. - public void SetDictionary(byte[] buffer, int offset, int length) - { -#if DebugDeflation - if (DeflaterConstants.DEBUGGING && (strstart != 1) ) - { - throw new InvalidOperationException("strstart not 1"); - } -#endif - adler?.Update(new ArraySegment(buffer, offset, length)); - if (length < DeflaterConstants.MIN_MATCH) - { - return; - } - - if (length > DeflaterConstants.MAX_DIST) - { - offset += length - DeflaterConstants.MAX_DIST; - length = DeflaterConstants.MAX_DIST; - } - - System.Array.Copy(buffer, offset, window, strstart, length); - - UpdateHash(); - --length; - while (--length > 0) - { - InsertString(); - strstart++; - } - strstart += 2; - blockStart = strstart; - } - - /// - /// Reset internal state - /// - public void Reset() - { - huffman.Reset(); - adler?.Reset(); - blockStart = strstart = 1; - lookahead = 0; - totalIn = 0; - prevAvailable = false; - matchLen = DeflaterConstants.MIN_MATCH - 1; - - for (int i = 0; i < DeflaterConstants.HASH_SIZE; i++) - { - head[i] = 0; - } - - for (int i = 0; i < DeflaterConstants.WSIZE; i++) - { - prev[i] = 0; - } - } - - /// - /// Reset Adler checksum - /// - public void ResetAdler() - { - adler?.Reset(); - } - - /// - /// Get current value of Adler checksum - /// - public int Adler - { - get - { - return (adler != null) ? unchecked((int)adler.Value) : 0; - } - } - - /// - /// Total data processed - /// - public long TotalIn - { - get - { - return totalIn; - } - } - - /// - /// Get/set the deflate strategy - /// - public DeflateStrategy Strategy - { - get - { - return strategy; - } - set - { - strategy = value; - } - } - - /// - /// Set the deflate level (0-9) - /// - /// The value to set the level to. - public void SetLevel(int level) - { - if ((level < 0) || (level > 9)) - { - throw new ArgumentOutOfRangeException(nameof(level)); - } - - goodLength = DeflaterConstants.GOOD_LENGTH[level]; - max_lazy = DeflaterConstants.MAX_LAZY[level]; - niceLength = DeflaterConstants.NICE_LENGTH[level]; - max_chain = DeflaterConstants.MAX_CHAIN[level]; - - if (DeflaterConstants.COMPR_FUNC[level] != compressionFunction) - { -#if DebugDeflation - if (DeflaterConstants.DEBUGGING) { - Console.WriteLine("Change from " + compressionFunction + " to " - + DeflaterConstants.COMPR_FUNC[level]); - } -#endif - switch (compressionFunction) - { - case DeflaterConstants.DEFLATE_STORED: - if (strstart > blockStart) - { - huffman.FlushStoredBlock(window, blockStart, - strstart - blockStart, false); - blockStart = strstart; - } - UpdateHash(); - break; - - case DeflaterConstants.DEFLATE_FAST: - if (strstart > blockStart) - { - huffman.FlushBlock(window, blockStart, strstart - blockStart, - false); - blockStart = strstart; - } - break; - - case DeflaterConstants.DEFLATE_SLOW: - if (prevAvailable) - { - huffman.TallyLit(window[strstart - 1] & 0xff); - } - if (strstart > blockStart) - { - huffman.FlushBlock(window, blockStart, strstart - blockStart, false); - blockStart = strstart; - } - prevAvailable = false; - matchLen = DeflaterConstants.MIN_MATCH - 1; - break; - } - compressionFunction = DeflaterConstants.COMPR_FUNC[level]; - } - } - - /// - /// Fill the window - /// - public void FillWindow() - { - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (strstart >= DeflaterConstants.WSIZE + DeflaterConstants.MAX_DIST) - { - SlideWindow(); - } - - /* If there is not enough lookahead, but still some input left, - * read in the input - */ - if (lookahead < DeflaterConstants.MIN_LOOKAHEAD && inputOff < inputEnd) - { - int more = 2 * DeflaterConstants.WSIZE - lookahead - strstart; - - if (more > inputEnd - inputOff) - { - more = inputEnd - inputOff; - } - - System.Array.Copy(inputBuf, inputOff, window, strstart + lookahead, more); - adler?.Update(new ArraySegment(inputBuf, inputOff, more)); - - inputOff += more; - totalIn += more; - lookahead += more; - } - - if (lookahead >= DeflaterConstants.MIN_MATCH) - { - UpdateHash(); - } - } - - private void UpdateHash() - { - /* - if (DEBUGGING) { - Console.WriteLine("updateHash: "+strstart); - } - */ - ins_h = (window[strstart] << DeflaterConstants.HASH_SHIFT) ^ window[strstart + 1]; - } - - /// - /// Inserts the current string in the head hash and returns the previous - /// value for this hash. - /// - /// The previous hash value - private int InsertString() - { - short match; - int hash = ((ins_h << DeflaterConstants.HASH_SHIFT) ^ window[strstart + (DeflaterConstants.MIN_MATCH - 1)]) & DeflaterConstants.HASH_MASK; - -#if DebugDeflation - if (DeflaterConstants.DEBUGGING) - { - if (hash != (((window[strstart] << (2*HASH_SHIFT)) ^ - (window[strstart + 1] << HASH_SHIFT) ^ - (window[strstart + 2])) & HASH_MASK)) { - throw new SharpZipBaseException("hash inconsistent: " + hash + "/" - +window[strstart] + "," - +window[strstart + 1] + "," - +window[strstart + 2] + "," + HASH_SHIFT); - } - } -#endif - prev[strstart & DeflaterConstants.WMASK] = match = head[hash]; - head[hash] = unchecked((short)strstart); - ins_h = hash; - return match & 0xffff; - } - - private void SlideWindow() - { - Array.Copy(window, DeflaterConstants.WSIZE, window, 0, DeflaterConstants.WSIZE); - matchStart -= DeflaterConstants.WSIZE; - strstart -= DeflaterConstants.WSIZE; - blockStart -= DeflaterConstants.WSIZE; - - // Slide the hash table (could be avoided with 32 bit values - // at the expense of memory usage). - for (int i = 0; i < DeflaterConstants.HASH_SIZE; ++i) - { - int m = head[i] & 0xffff; - head[i] = (short)(m >= DeflaterConstants.WSIZE ? (m - DeflaterConstants.WSIZE) : 0); - } - - // Slide the prev table. - for (int i = 0; i < DeflaterConstants.WSIZE; i++) - { - int m = prev[i] & 0xffff; - prev[i] = (short)(m >= DeflaterConstants.WSIZE ? (m - DeflaterConstants.WSIZE) : 0); - } - } - - /// - /// Find the best (longest) string in the window matching the - /// string starting at strstart. - /// - /// Preconditions: - /// - /// strstart + DeflaterConstants.MAX_MATCH <= window.length. - /// - /// - /// True if a match greater than the minimum length is found - private bool FindLongestMatch(int curMatch) - { - int match; - int scan = strstart; - // scanMax is the highest position that we can look at - int scanMax = scan + Math.Min(DeflaterConstants.MAX_MATCH, lookahead) - 1; - int limit = Math.Max(scan - DeflaterConstants.MAX_DIST, 0); - - byte[] window = this.window; - short[] prev = this.prev; - int chainLength = this.max_chain; - int niceLength = Math.Min(this.niceLength, lookahead); - - matchLen = Math.Max(matchLen, DeflaterConstants.MIN_MATCH - 1); - - if (scan + matchLen > scanMax) return false; - - byte scan_end1 = window[scan + matchLen - 1]; - byte scan_end = window[scan + matchLen]; - - // Do not waste too much time if we already have a good match: - if (matchLen >= this.goodLength) chainLength >>= 2; - - do - { - match = curMatch; - scan = strstart; - - if (window[match + matchLen] != scan_end - || window[match + matchLen - 1] != scan_end1 - || window[match] != window[scan] - || window[++match] != window[++scan]) - { - continue; - } - - // scan is set to strstart+1 and the comparison passed, so - // scanMax - scan is the maximum number of bytes we can compare. - // below we compare 8 bytes at a time, so first we compare - // (scanMax - scan) % 8 bytes, so the remainder is a multiple of 8 - - switch ((scanMax - scan) % 8) - { - case 1: - if (window[++scan] == window[++match]) break; - break; - - case 2: - if (window[++scan] == window[++match] - && window[++scan] == window[++match]) break; - break; - - case 3: - if (window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match]) break; - break; - - case 4: - if (window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match]) break; - break; - - case 5: - if (window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match]) break; - break; - - case 6: - if (window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match]) break; - break; - - case 7: - if (window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match]) break; - break; - } - - if (window[scan] == window[match]) - { - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart + 258 unless lookahead is - * exhausted first. - */ - do - { - if (scan == scanMax) - { - ++scan; // advance to first position not matched - ++match; - - break; - } - } - while (window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match] - && window[++scan] == window[++match]); - } - - if (scan - strstart > matchLen) - { -#if DebugDeflation - if (DeflaterConstants.DEBUGGING && (ins_h == 0) ) - Console.Error.WriteLine("Found match: " + curMatch + "-" + (scan - strstart)); -#endif - - matchStart = curMatch; - matchLen = scan - strstart; - - if (matchLen >= niceLength) - break; - - scan_end1 = window[scan - 1]; - scan_end = window[scan]; - } - } while ((curMatch = (prev[curMatch & DeflaterConstants.WMASK] & 0xffff)) > limit && 0 != --chainLength); - - return matchLen >= DeflaterConstants.MIN_MATCH; - } - - private bool DeflateStored(bool flush, bool finish) - { - if (!flush && (lookahead == 0)) - { - return false; - } - - strstart += lookahead; - lookahead = 0; - - int storedLength = strstart - blockStart; - - if ((storedLength >= DeflaterConstants.MAX_BLOCK_SIZE) || // Block is full - (blockStart < DeflaterConstants.WSIZE && storedLength >= DeflaterConstants.MAX_DIST) || // Block may move out of window - flush) - { - bool lastBlock = finish; - if (storedLength > DeflaterConstants.MAX_BLOCK_SIZE) - { - storedLength = DeflaterConstants.MAX_BLOCK_SIZE; - lastBlock = false; - } - -#if DebugDeflation - if (DeflaterConstants.DEBUGGING) - { - Console.WriteLine("storedBlock[" + storedLength + "," + lastBlock + "]"); - } -#endif - - huffman.FlushStoredBlock(window, blockStart, storedLength, lastBlock); - blockStart += storedLength; - return !(lastBlock || storedLength == 0); - } - return true; - } - - private bool DeflateFast(bool flush, bool finish) - { - if (lookahead < DeflaterConstants.MIN_LOOKAHEAD && !flush) - { - return false; - } - - while (lookahead >= DeflaterConstants.MIN_LOOKAHEAD || flush) - { - if (lookahead == 0) - { - // We are flushing everything - huffman.FlushBlock(window, blockStart, strstart - blockStart, finish); - blockStart = strstart; - return false; - } - - if (strstart > 2 * DeflaterConstants.WSIZE - DeflaterConstants.MIN_LOOKAHEAD) - { - /* slide window, as FindLongestMatch needs this. - * This should only happen when flushing and the window - * is almost full. - */ - SlideWindow(); - } - - int hashHead; - if (lookahead >= DeflaterConstants.MIN_MATCH && - (hashHead = InsertString()) != 0 && - strategy != DeflateStrategy.HuffmanOnly && - strstart - hashHead <= DeflaterConstants.MAX_DIST && - FindLongestMatch(hashHead)) - { - // longestMatch sets matchStart and matchLen -#if DebugDeflation - if (DeflaterConstants.DEBUGGING) - { - for (int i = 0 ; i < matchLen; i++) { - if (window[strstart + i] != window[matchStart + i]) { - throw new SharpZipBaseException("Match failure"); - } - } - } -#endif - - bool full = huffman.TallyDist(strstart - matchStart, matchLen); - - lookahead -= matchLen; - if (matchLen <= max_lazy && lookahead >= DeflaterConstants.MIN_MATCH) - { - while (--matchLen > 0) - { - ++strstart; - InsertString(); - } - ++strstart; - } - else - { - strstart += matchLen; - if (lookahead >= DeflaterConstants.MIN_MATCH - 1) - { - UpdateHash(); - } - } - matchLen = DeflaterConstants.MIN_MATCH - 1; - if (!full) - { - continue; - } - } - else - { - // No match found - huffman.TallyLit(window[strstart] & 0xff); - ++strstart; - --lookahead; - } - - if (huffman.IsFull()) - { - bool lastBlock = finish && (lookahead == 0); - huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock); - blockStart = strstart; - return !lastBlock; - } - } - return true; - } - - private bool DeflateSlow(bool flush, bool finish) - { - if (lookahead < DeflaterConstants.MIN_LOOKAHEAD && !flush) - { - return false; - } - - while (lookahead >= DeflaterConstants.MIN_LOOKAHEAD || flush) - { - if (lookahead == 0) - { - if (prevAvailable) - { - huffman.TallyLit(window[strstart - 1] & 0xff); - } - prevAvailable = false; - - // We are flushing everything -#if DebugDeflation - if (DeflaterConstants.DEBUGGING && !flush) - { - throw new SharpZipBaseException("Not flushing, but no lookahead"); - } -#endif - huffman.FlushBlock(window, blockStart, strstart - blockStart, - finish); - blockStart = strstart; - return false; - } - - if (strstart >= 2 * DeflaterConstants.WSIZE - DeflaterConstants.MIN_LOOKAHEAD) - { - /* slide window, as FindLongestMatch needs this. - * This should only happen when flushing and the window - * is almost full. - */ - SlideWindow(); - } - - int prevMatch = matchStart; - int prevLen = matchLen; - if (lookahead >= DeflaterConstants.MIN_MATCH) - { - int hashHead = InsertString(); - - if (strategy != DeflateStrategy.HuffmanOnly && - hashHead != 0 && - strstart - hashHead <= DeflaterConstants.MAX_DIST && - FindLongestMatch(hashHead)) - { - // longestMatch sets matchStart and matchLen - - // Discard match if too small and too far away - if (matchLen <= 5 && (strategy == DeflateStrategy.Filtered || (matchLen == DeflaterConstants.MIN_MATCH && strstart - matchStart > TooFar))) - { - matchLen = DeflaterConstants.MIN_MATCH - 1; - } - } - } - - // previous match was better - if ((prevLen >= DeflaterConstants.MIN_MATCH) && (matchLen <= prevLen)) - { -#if DebugDeflation - if (DeflaterConstants.DEBUGGING) - { - for (int i = 0 ; i < matchLen; i++) { - if (window[strstart-1+i] != window[prevMatch + i]) - throw new SharpZipBaseException(); - } - } -#endif - huffman.TallyDist(strstart - 1 - prevMatch, prevLen); - prevLen -= 2; - do - { - strstart++; - lookahead--; - if (lookahead >= DeflaterConstants.MIN_MATCH) - { - InsertString(); - } - } while (--prevLen > 0); - - strstart++; - lookahead--; - prevAvailable = false; - matchLen = DeflaterConstants.MIN_MATCH - 1; - } - else - { - if (prevAvailable) - { - huffman.TallyLit(window[strstart - 1] & 0xff); - } - prevAvailable = true; - strstart++; - lookahead--; - } - - if (huffman.IsFull()) - { - int len = strstart - blockStart; - if (prevAvailable) - { - len--; - } - bool lastBlock = (finish && (lookahead == 0) && !prevAvailable); - huffman.FlushBlock(window, blockStart, len, lastBlock); - blockStart += len; - return !lastBlock; - } - } - return true; - } - - #region Instance Fields - - // Hash index of string to be inserted - private int ins_h; - - /// - /// Hashtable, hashing three characters to an index for window, so - /// that window[index]..window[index+2] have this hash code. - /// Note that the array should really be unsigned short, so you need - /// to and the values with 0xffff. - /// - private short[] head; - - /// - /// prev[index & WMASK] points to the previous index that has the - /// same hash code as the string starting at index. This way - /// entries with the same hash code are in a linked list. - /// Note that the array should really be unsigned short, so you need - /// to and the values with 0xffff. - /// - private short[] prev; - - private int matchStart; - - // Length of best match - private int matchLen; - - // Set if previous match exists - private bool prevAvailable; - - private int blockStart; - - /// - /// Points to the current character in the window. - /// - private int strstart; - - /// - /// lookahead is the number of characters starting at strstart in - /// window that are valid. - /// So window[strstart] until window[strstart+lookahead-1] are valid - /// characters. - /// - private int lookahead; - - /// - /// This array contains the part of the uncompressed stream that - /// is of relevance. The current character is indexed by strstart. - /// - private byte[] window; - - private DeflateStrategy strategy; - private int max_chain, max_lazy, niceLength, goodLength; - - /// - /// The current compression function. - /// - private int compressionFunction; - - /// - /// The input data for compression. - /// - private byte[] inputBuf; - - /// - /// The total bytes of input read. - /// - private long totalIn; - - /// - /// The offset into inputBuf, where input data starts. - /// - private int inputOff; - - /// - /// The end offset of the input data. - /// - private int inputEnd; - - private DeflaterPending pending; - private DeflaterHuffman huffman; - - /// - /// The adler checksum - /// - private Adler32 adler; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterHuffman.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterHuffman.cs deleted file mode 100644 index f03aeedc6..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterHuffman.cs +++ /dev/null @@ -1,960 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression -{ - /// - /// This is the DeflaterHuffman class. - /// - /// This class is not thread safe. This is inherent in the API, due - /// to the split of Deflate and SetInput. - /// - /// author of the original java version : Jochen Hoenicke - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class DeflaterHuffman - { - private const int BUFSIZE = 1 << (DeflaterConstants.DEFAULT_MEM_LEVEL + 6); - private const int LITERAL_NUM = 286; - - // Number of distance codes - private const int DIST_NUM = 30; - - // Number of codes used to transfer bit lengths - private const int BITLEN_NUM = 19; - - // repeat previous bit length 3-6 times (2 bits of repeat count) - private const int REP_3_6 = 16; - - // repeat a zero length 3-10 times (3 bits of repeat count) - private const int REP_3_10 = 17; - - // repeat a zero length 11-138 times (7 bits of repeat count) - private const int REP_11_138 = 18; - - private const int EOF_SYMBOL = 256; - - // The lengths of the bit length codes are sent in order of decreasing - // probability, to avoid transmitting the lengths for unused bit length codes. - private static readonly int[] BL_ORDER = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; - - private static readonly byte[] bit4Reverse = { - 0, - 8, - 4, - 12, - 2, - 10, - 6, - 14, - 1, - 9, - 5, - 13, - 3, - 11, - 7, - 15 - }; - - private static short[] staticLCodes; - private static byte[] staticLLength; - private static short[] staticDCodes; - private static byte[] staticDLength; - - private class Tree - { - #region Instance Fields - - public short[] freqs; - - public byte[] length; - - public int minNumCodes; - - public int numCodes; - - private short[] codes; - private readonly int[] bl_counts; - private readonly int maxLength; - private DeflaterHuffman dh; - - #endregion Instance Fields - - #region Constructors - - public Tree(DeflaterHuffman dh, int elems, int minCodes, int maxLength) - { - this.dh = dh; - this.minNumCodes = minCodes; - this.maxLength = maxLength; - freqs = new short[elems]; - bl_counts = new int[maxLength]; - } - - #endregion Constructors - - /// - /// Resets the internal state of the tree - /// - public void Reset() - { - for (int i = 0; i < freqs.Length; i++) - { - freqs[i] = 0; - } - codes = null; - length = null; - } - - public void WriteSymbol(int code) - { - // if (DeflaterConstants.DEBUGGING) { - // freqs[code]--; - // // Console.Write("writeSymbol("+freqs.length+","+code+"): "); - // } - dh.pending.WriteBits(codes[code] & 0xffff, length[code]); - } - - /// - /// Check that all frequencies are zero - /// - /// - /// At least one frequency is non-zero - /// - public void CheckEmpty() - { - bool empty = true; - for (int i = 0; i < freqs.Length; i++) - { - empty &= freqs[i] == 0; - } - - if (!empty) - { - throw new SharpZipBaseException("!Empty"); - } - } - - /// - /// Set static codes and length - /// - /// new codes - /// length for new codes - public void SetStaticCodes(short[] staticCodes, byte[] staticLengths) - { - codes = staticCodes; - length = staticLengths; - } - - /// - /// Build dynamic codes and lengths - /// - public void BuildCodes() - { - int numSymbols = freqs.Length; - int[] nextCode = new int[maxLength]; - int code = 0; - - codes = new short[freqs.Length]; - - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("buildCodes: "+freqs.Length); - // } - - for (int bits = 0; bits < maxLength; bits++) - { - nextCode[bits] = code; - code += bl_counts[bits] << (15 - bits); - - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("bits: " + ( bits + 1) + " count: " + bl_counts[bits] - // +" nextCode: "+code); - // } - } - -#if DebugDeflation - if ( DeflaterConstants.DEBUGGING && (code != 65536) ) - { - throw new SharpZipBaseException("Inconsistent bl_counts!"); - } -#endif - for (int i = 0; i < numCodes; i++) - { - int bits = length[i]; - if (bits > 0) - { - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("codes["+i+"] = rev(" + nextCode[bits-1]+"), - // +bits); - // } - - codes[i] = BitReverse(nextCode[bits - 1]); - nextCode[bits - 1] += 1 << (16 - bits); - } - } - } - - public void BuildTree() - { - int numSymbols = freqs.Length; - - /* heap is a priority queue, sorted by frequency, least frequent - * nodes first. The heap is a binary tree, with the property, that - * the parent node is smaller than both child nodes. This assures - * that the smallest node is the first parent. - * - * The binary tree is encoded in an array: 0 is root node and - * the nodes 2*n+1, 2*n+2 are the child nodes of node n. - */ - int[] heap = new int[numSymbols]; - int heapLen = 0; - int maxCode = 0; - for (int n = 0; n < numSymbols; n++) - { - int freq = freqs[n]; - if (freq != 0) - { - // Insert n into heap - int pos = heapLen++; - int ppos; - while (pos > 0 && freqs[heap[ppos = (pos - 1) / 2]] > freq) - { - heap[pos] = heap[ppos]; - pos = ppos; - } - heap[pos] = n; - - maxCode = n; - } - } - - /* We could encode a single literal with 0 bits but then we - * don't see the literals. Therefore we force at least two - * literals to avoid this case. We don't care about order in - * this case, both literals get a 1 bit code. - */ - while (heapLen < 2) - { - int node = maxCode < 2 ? ++maxCode : 0; - heap[heapLen++] = node; - } - - numCodes = Math.Max(maxCode + 1, minNumCodes); - - int numLeafs = heapLen; - int[] childs = new int[4 * heapLen - 2]; - int[] values = new int[2 * heapLen - 1]; - int numNodes = numLeafs; - for (int i = 0; i < heapLen; i++) - { - int node = heap[i]; - childs[2 * i] = node; - childs[2 * i + 1] = -1; - values[i] = freqs[node] << 8; - heap[i] = i; - } - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - do - { - int first = heap[0]; - int last = heap[--heapLen]; - - // Propagate the hole to the leafs of the heap - int ppos = 0; - int path = 1; - - while (path < heapLen) - { - if (path + 1 < heapLen && values[heap[path]] > values[heap[path + 1]]) - { - path++; - } - - heap[ppos] = heap[path]; - ppos = path; - path = path * 2 + 1; - } - - /* Now propagate the last element down along path. Normally - * it shouldn't go too deep. - */ - int lastVal = values[last]; - while ((path = ppos) > 0 && values[heap[ppos = (path - 1) / 2]] > lastVal) - { - heap[path] = heap[ppos]; - } - heap[path] = last; - - int second = heap[0]; - - // Create a new node father of first and second - last = numNodes++; - childs[2 * last] = first; - childs[2 * last + 1] = second; - int mindepth = Math.Min(values[first] & 0xff, values[second] & 0xff); - values[last] = lastVal = values[first] + values[second] - mindepth + 1; - - // Again, propagate the hole to the leafs - ppos = 0; - path = 1; - - while (path < heapLen) - { - if (path + 1 < heapLen && values[heap[path]] > values[heap[path + 1]]) - { - path++; - } - - heap[ppos] = heap[path]; - ppos = path; - path = ppos * 2 + 1; - } - - // Now propagate the new element down along path - while ((path = ppos) > 0 && values[heap[ppos = (path - 1) / 2]] > lastVal) - { - heap[path] = heap[ppos]; - } - heap[path] = last; - } while (heapLen > 1); - - if (heap[0] != childs.Length / 2 - 1) - { - throw new SharpZipBaseException("Heap invariant violated"); - } - - BuildLength(childs); - } - - /// - /// Get encoded length - /// - /// Encoded length, the sum of frequencies * lengths - public int GetEncodedLength() - { - int len = 0; - for (int i = 0; i < freqs.Length; i++) - { - len += freqs[i] * length[i]; - } - return len; - } - - /// - /// Scan a literal or distance tree to determine the frequencies of the codes - /// in the bit length tree. - /// - public void CalcBLFreq(Tree blTree) - { - int max_count; /* max repeat count */ - int min_count; /* min repeat count */ - int count; /* repeat count of the current code */ - int curlen = -1; /* length of current code */ - - int i = 0; - while (i < numCodes) - { - count = 1; - int nextlen = length[i]; - if (nextlen == 0) - { - max_count = 138; - min_count = 3; - } - else - { - max_count = 6; - min_count = 3; - if (curlen != nextlen) - { - blTree.freqs[nextlen]++; - count = 0; - } - } - curlen = nextlen; - i++; - - while (i < numCodes && curlen == length[i]) - { - i++; - if (++count >= max_count) - { - break; - } - } - - if (count < min_count) - { - blTree.freqs[curlen] += (short)count; - } - else if (curlen != 0) - { - blTree.freqs[REP_3_6]++; - } - else if (count <= 10) - { - blTree.freqs[REP_3_10]++; - } - else - { - blTree.freqs[REP_11_138]++; - } - } - } - - /// - /// Write tree values - /// - /// Tree to write - public void WriteTree(Tree blTree) - { - int max_count; // max repeat count - int min_count; // min repeat count - int count; // repeat count of the current code - int curlen = -1; // length of current code - - int i = 0; - while (i < numCodes) - { - count = 1; - int nextlen = length[i]; - if (nextlen == 0) - { - max_count = 138; - min_count = 3; - } - else - { - max_count = 6; - min_count = 3; - if (curlen != nextlen) - { - blTree.WriteSymbol(nextlen); - count = 0; - } - } - curlen = nextlen; - i++; - - while (i < numCodes && curlen == length[i]) - { - i++; - if (++count >= max_count) - { - break; - } - } - - if (count < min_count) - { - while (count-- > 0) - { - blTree.WriteSymbol(curlen); - } - } - else if (curlen != 0) - { - blTree.WriteSymbol(REP_3_6); - dh.pending.WriteBits(count - 3, 2); - } - else if (count <= 10) - { - blTree.WriteSymbol(REP_3_10); - dh.pending.WriteBits(count - 3, 3); - } - else - { - blTree.WriteSymbol(REP_11_138); - dh.pending.WriteBits(count - 11, 7); - } - } - } - - private void BuildLength(int[] childs) - { - this.length = new byte[freqs.Length]; - int numNodes = childs.Length / 2; - int numLeafs = (numNodes + 1) / 2; - int overflow = 0; - - for (int i = 0; i < maxLength; i++) - { - bl_counts[i] = 0; - } - - // First calculate optimal bit lengths - int[] lengths = new int[numNodes]; - lengths[numNodes - 1] = 0; - - for (int i = numNodes - 1; i >= 0; i--) - { - if (childs[2 * i + 1] != -1) - { - int bitLength = lengths[i] + 1; - if (bitLength > maxLength) - { - bitLength = maxLength; - overflow++; - } - lengths[childs[2 * i]] = lengths[childs[2 * i + 1]] = bitLength; - } - else - { - // A leaf node - int bitLength = lengths[i]; - bl_counts[bitLength - 1]++; - this.length[childs[2 * i]] = (byte)lengths[i]; - } - } - - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("Tree "+freqs.Length+" lengths:"); - // for (int i=0; i < numLeafs; i++) { - // //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]] - // + " len: "+length[childs[2*i]]); - // } - // } - - if (overflow == 0) - { - return; - } - - int incrBitLen = maxLength - 1; - do - { - // Find the first bit length which could increase: - while (bl_counts[--incrBitLen] == 0) - { - } - - // Move this node one down and remove a corresponding - // number of overflow nodes. - do - { - bl_counts[incrBitLen]--; - bl_counts[++incrBitLen]++; - overflow -= 1 << (maxLength - 1 - incrBitLen); - } while (overflow > 0 && incrBitLen < maxLength - 1); - } while (overflow > 0); - - /* We may have overshot above. Move some nodes from maxLength to - * maxLength-1 in that case. - */ - bl_counts[maxLength - 1] += overflow; - bl_counts[maxLength - 2] -= overflow; - - /* Now recompute all bit lengths, scanning in increasing - * frequency. It is simpler to reconstruct all lengths instead of - * fixing only the wrong ones. This idea is taken from 'ar' - * written by Haruhiko Okumura. - * - * The nodes were inserted with decreasing frequency into the childs - * array. - */ - int nodePtr = 2 * numLeafs; - for (int bits = maxLength; bits != 0; bits--) - { - int n = bl_counts[bits - 1]; - while (n > 0) - { - int childPtr = 2 * childs[nodePtr++]; - if (childs[childPtr + 1] == -1) - { - // We found another leaf - length[childs[childPtr]] = (byte)bits; - n--; - } - } - } - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("*** After overflow elimination. ***"); - // for (int i=0; i < numLeafs; i++) { - // //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]] - // + " len: "+length[childs[2*i]]); - // } - // } - } - } - - #region Instance Fields - - /// - /// Pending buffer to use - /// - public DeflaterPending pending; - - private Tree literalTree; - private Tree distTree; - private Tree blTree; - - // Buffer for distances - private short[] d_buf; - - private byte[] l_buf; - private int last_lit; - private int extra_bits; - - #endregion Instance Fields - - static DeflaterHuffman() - { - // See RFC 1951 3.2.6 - // Literal codes - staticLCodes = new short[LITERAL_NUM]; - staticLLength = new byte[LITERAL_NUM]; - - int i = 0; - while (i < 144) - { - staticLCodes[i] = BitReverse((0x030 + i) << 8); - staticLLength[i++] = 8; - } - - while (i < 256) - { - staticLCodes[i] = BitReverse((0x190 - 144 + i) << 7); - staticLLength[i++] = 9; - } - - while (i < 280) - { - staticLCodes[i] = BitReverse((0x000 - 256 + i) << 9); - staticLLength[i++] = 7; - } - - while (i < LITERAL_NUM) - { - staticLCodes[i] = BitReverse((0x0c0 - 280 + i) << 8); - staticLLength[i++] = 8; - } - - // Distance codes - staticDCodes = new short[DIST_NUM]; - staticDLength = new byte[DIST_NUM]; - for (i = 0; i < DIST_NUM; i++) - { - staticDCodes[i] = BitReverse(i << 11); - staticDLength[i] = 5; - } - } - - /// - /// Construct instance with pending buffer - /// - /// Pending buffer to use - public DeflaterHuffman(DeflaterPending pending) - { - this.pending = pending; - - literalTree = new Tree(this, LITERAL_NUM, 257, 15); - distTree = new Tree(this, DIST_NUM, 1, 15); - blTree = new Tree(this, BITLEN_NUM, 4, 7); - - d_buf = new short[BUFSIZE]; - l_buf = new byte[BUFSIZE]; - } - - /// - /// Reset internal state - /// - public void Reset() - { - last_lit = 0; - extra_bits = 0; - literalTree.Reset(); - distTree.Reset(); - blTree.Reset(); - } - - /// - /// Write all trees to pending buffer - /// - /// The number/rank of treecodes to send. - public void SendAllTrees(int blTreeCodes) - { - blTree.BuildCodes(); - literalTree.BuildCodes(); - distTree.BuildCodes(); - pending.WriteBits(literalTree.numCodes - 257, 5); - pending.WriteBits(distTree.numCodes - 1, 5); - pending.WriteBits(blTreeCodes - 4, 4); - for (int rank = 0; rank < blTreeCodes; rank++) - { - pending.WriteBits(blTree.length[BL_ORDER[rank]], 3); - } - literalTree.WriteTree(blTree); - distTree.WriteTree(blTree); - -#if DebugDeflation - if (DeflaterConstants.DEBUGGING) { - blTree.CheckEmpty(); - } -#endif - } - - /// - /// Compress current buffer writing data to pending buffer - /// - public void CompressBlock() - { - for (int i = 0; i < last_lit; i++) - { - int litlen = l_buf[i] & 0xff; - int dist = d_buf[i]; - if (dist-- != 0) - { - // if (DeflaterConstants.DEBUGGING) { - // Console.Write("["+(dist+1)+","+(litlen+3)+"]: "); - // } - - int lc = Lcode(litlen); - literalTree.WriteSymbol(lc); - - int bits = (lc - 261) / 4; - if (bits > 0 && bits <= 5) - { - pending.WriteBits(litlen & ((1 << bits) - 1), bits); - } - - int dc = Dcode(dist); - distTree.WriteSymbol(dc); - - bits = dc / 2 - 1; - if (bits > 0) - { - pending.WriteBits(dist & ((1 << bits) - 1), bits); - } - } - else - { - // if (DeflaterConstants.DEBUGGING) { - // if (litlen > 32 && litlen < 127) { - // Console.Write("("+(char)litlen+"): "); - // } else { - // Console.Write("{"+litlen+"}: "); - // } - // } - literalTree.WriteSymbol(litlen); - } - } - -#if DebugDeflation - if (DeflaterConstants.DEBUGGING) { - Console.Write("EOF: "); - } -#endif - literalTree.WriteSymbol(EOF_SYMBOL); - -#if DebugDeflation - if (DeflaterConstants.DEBUGGING) { - literalTree.CheckEmpty(); - distTree.CheckEmpty(); - } -#endif - } - - /// - /// Flush block to output with no compression - /// - /// Data to write - /// Index of first byte to write - /// Count of bytes to write - /// True if this is the last block - public void FlushStoredBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock) - { -#if DebugDeflation - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("Flushing stored block "+ storedLength); - // } -#endif - pending.WriteBits((DeflaterConstants.STORED_BLOCK << 1) + (lastBlock ? 1 : 0), 3); - pending.AlignToByte(); - pending.WriteShort(storedLength); - pending.WriteShort(~storedLength); - pending.WriteBlock(stored, storedOffset, storedLength); - Reset(); - } - - /// - /// Flush block to output with compression - /// - /// Data to flush - /// Index of first byte to flush - /// Count of bytes to flush - /// True if this is the last block - public void FlushBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock) - { - literalTree.freqs[EOF_SYMBOL]++; - - // Build trees - literalTree.BuildTree(); - distTree.BuildTree(); - - // Calculate bitlen frequency - literalTree.CalcBLFreq(blTree); - distTree.CalcBLFreq(blTree); - - // Build bitlen tree - blTree.BuildTree(); - - int blTreeCodes = 4; - for (int i = 18; i > blTreeCodes; i--) - { - if (blTree.length[BL_ORDER[i]] > 0) - { - blTreeCodes = i + 1; - } - } - int opt_len = 14 + blTreeCodes * 3 + blTree.GetEncodedLength() + - literalTree.GetEncodedLength() + distTree.GetEncodedLength() + - extra_bits; - - int static_len = extra_bits; - for (int i = 0; i < LITERAL_NUM; i++) - { - static_len += literalTree.freqs[i] * staticLLength[i]; - } - for (int i = 0; i < DIST_NUM; i++) - { - static_len += distTree.freqs[i] * staticDLength[i]; - } - if (opt_len >= static_len) - { - // Force static trees - opt_len = static_len; - } - - if (storedOffset >= 0 && storedLength + 4 < opt_len >> 3) - { - // Store Block - - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("Storing, since " + storedLength + " < " + opt_len - // + " <= " + static_len); - // } - FlushStoredBlock(stored, storedOffset, storedLength, lastBlock); - } - else if (opt_len == static_len) - { - // Encode with static tree - pending.WriteBits((DeflaterConstants.STATIC_TREES << 1) + (lastBlock ? 1 : 0), 3); - literalTree.SetStaticCodes(staticLCodes, staticLLength); - distTree.SetStaticCodes(staticDCodes, staticDLength); - CompressBlock(); - Reset(); - } - else - { - // Encode with dynamic tree - pending.WriteBits((DeflaterConstants.DYN_TREES << 1) + (lastBlock ? 1 : 0), 3); - SendAllTrees(blTreeCodes); - CompressBlock(); - Reset(); - } - } - - /// - /// Get value indicating if internal buffer is full - /// - /// true if buffer is full - public bool IsFull() - { - return last_lit >= BUFSIZE; - } - - /// - /// Add literal to buffer - /// - /// Literal value to add to buffer. - /// Value indicating internal buffer is full - public bool TallyLit(int literal) - { - // if (DeflaterConstants.DEBUGGING) { - // if (lit > 32 && lit < 127) { - // //Console.WriteLine("("+(char)lit+")"); - // } else { - // //Console.WriteLine("{"+lit+"}"); - // } - // } - d_buf[last_lit] = 0; - l_buf[last_lit++] = (byte)literal; - literalTree.freqs[literal]++; - return IsFull(); - } - - /// - /// Add distance code and length to literal and distance trees - /// - /// Distance code - /// Length - /// Value indicating if internal buffer is full - public bool TallyDist(int distance, int length) - { - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("[" + distance + "," + length + "]"); - // } - - d_buf[last_lit] = (short)distance; - l_buf[last_lit++] = (byte)(length - 3); - - int lc = Lcode(length - 3); - literalTree.freqs[lc]++; - if (lc >= 265 && lc < 285) - { - extra_bits += (lc - 261) / 4; - } - - int dc = Dcode(distance - 1); - distTree.freqs[dc]++; - if (dc >= 4) - { - extra_bits += dc / 2 - 1; - } - return IsFull(); - } - - /// - /// Reverse the bits of a 16 bit value. - /// - /// Value to reverse bits - /// Value with bits reversed - public static short BitReverse(int toReverse) - { - return (short)(bit4Reverse[toReverse & 0xF] << 12 | - bit4Reverse[(toReverse >> 4) & 0xF] << 8 | - bit4Reverse[(toReverse >> 8) & 0xF] << 4 | - bit4Reverse[toReverse >> 12]); - } - - private static int Lcode(int length) - { - if (length == 255) - { - return 285; - } - - int code = 257; - while (length >= 8) - { - code += 4; - length >>= 1; - } - return code + length; - } - - private static int Dcode(int distance) - { - int code = 0; - while (distance >= 4) - { - code += 2; - distance >>= 1; - } - return code + distance; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterPending.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterPending.cs deleted file mode 100644 index c0eafdc3b..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterPending.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression -{ - /// - /// This class stores the pending output of the Deflater. - /// - /// author of the original java version : Jochen Hoenicke - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class DeflaterPending : PendingBuffer - { - /// - /// Construct instance with default buffer size - /// - public DeflaterPending() : base(DeflaterConstants.PENDING_BUF_SIZE) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Inflater.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Inflater.cs deleted file mode 100644 index 2e25e0c80..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Inflater.cs +++ /dev/null @@ -1,888 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Checksum; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams; -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression -{ - /// - /// Inflater is used to decompress data that has been compressed according - /// to the "deflate" standard described in rfc1951. - /// - /// By default Zlib (rfc1950) headers and footers are expected in the input. - /// You can use constructor public Inflater(bool noHeader) passing true - /// if there is no Zlib header information - /// - /// The usage is as following. First you have to set some input with - /// SetInput(), then Inflate() it. If inflate doesn't - /// inflate any bytes there may be three reasons: - ///
    - ///
  • IsNeedingInput() returns true because the input buffer is empty. - /// You have to provide more input with SetInput(). - /// NOTE: IsNeedingInput() also returns true when, the stream is finished. - ///
  • - ///
  • IsNeedingDictionary() returns true, you have to provide a preset - /// dictionary with SetDictionary().
  • - ///
  • IsFinished returns true, the inflater has finished.
  • - ///
- /// Once the first output byte is produced, a dictionary will not be - /// needed at a later stage. - /// - /// author of the original java version : John Leuner, Jochen Hoenicke - ///
- [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class Inflater - { - #region Constants/Readonly - - /// - /// Copy lengths for literal codes 257..285 - /// - private static readonly int[] CPLENS = { - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 - }; - - /// - /// Extra bits for literal codes 257..285 - /// - private static readonly int[] CPLEXT = { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, - 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 - }; - - /// - /// Copy offsets for distance codes 0..29 - /// - private static readonly int[] CPDIST = { - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577 - }; - - /// - /// Extra bits for distance codes - /// - private static readonly int[] CPDEXT = { - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, - 12, 12, 13, 13 - }; - - /// - /// These are the possible states for an inflater - /// - private const int DECODE_HEADER = 0; - - private const int DECODE_DICT = 1; - private const int DECODE_BLOCKS = 2; - private const int DECODE_STORED_LEN1 = 3; - private const int DECODE_STORED_LEN2 = 4; - private const int DECODE_STORED = 5; - private const int DECODE_DYN_HEADER = 6; - private const int DECODE_HUFFMAN = 7; - private const int DECODE_HUFFMAN_LENBITS = 8; - private const int DECODE_HUFFMAN_DIST = 9; - private const int DECODE_HUFFMAN_DISTBITS = 10; - private const int DECODE_CHKSUM = 11; - private const int FINISHED = 12; - - #endregion Constants/Readonly - - #region Instance Fields - - /// - /// This variable contains the current state. - /// - private int mode; - - /// - /// The adler checksum of the dictionary or of the decompressed - /// stream, as it is written in the header resp. footer of the - /// compressed stream. - /// Only valid if mode is DECODE_DICT or DECODE_CHKSUM. - /// - private int readAdler; - - /// - /// The number of bits needed to complete the current state. This - /// is valid, if mode is DECODE_DICT, DECODE_CHKSUM, - /// DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS. - /// - private int neededBits; - - private int repLength; - private int repDist; - private int uncomprLen; - - /// - /// True, if the last block flag was set in the last block of the - /// inflated stream. This means that the stream ends after the - /// current block. - /// - private bool isLastBlock; - - /// - /// The total number of inflated bytes. - /// - private long totalOut; - - /// - /// The total number of bytes set with setInput(). This is not the - /// value returned by the TotalIn property, since this also includes the - /// unprocessed input. - /// - private long totalIn; - - /// - /// This variable stores the noHeader flag that was given to the constructor. - /// True means, that the inflated stream doesn't contain a Zlib header or - /// footer. - /// - private bool noHeader; - - private readonly StreamManipulator input; - private OutputWindow outputWindow; - private InflaterDynHeader dynHeader; - private InflaterHuffmanTree litlenTree, distTree; - private Adler32 adler; - - #endregion Instance Fields - - #region Constructors - - /// - /// Creates a new inflater or RFC1951 decompressor - /// RFC1950/Zlib headers and footers will be expected in the input data - /// - public Inflater() : this(false) - { - } - - /// - /// Creates a new inflater. - /// - /// - /// True if no RFC1950/Zlib header and footer fields are expected in the input data - /// - /// This is used for GZIPed/Zipped input. - /// - /// For compatibility with - /// Sun JDK you should provide one byte of input more than needed in - /// this case. - /// - public Inflater(bool noHeader) - { - this.noHeader = noHeader; - if (!noHeader) - this.adler = new Adler32(); - input = new StreamManipulator(); - outputWindow = new OutputWindow(); - mode = noHeader ? DECODE_BLOCKS : DECODE_HEADER; - } - - #endregion Constructors - - /// - /// Resets the inflater so that a new stream can be decompressed. All - /// pending input and output will be discarded. - /// - public void Reset() - { - mode = noHeader ? DECODE_BLOCKS : DECODE_HEADER; - totalIn = 0; - totalOut = 0; - input.Reset(); - outputWindow.Reset(); - dynHeader = null; - litlenTree = null; - distTree = null; - isLastBlock = false; - adler?.Reset(); - } - - /// - /// Decodes a zlib/RFC1950 header. - /// - /// - /// False if more input is needed. - /// - /// - /// The header is invalid. - /// - private bool DecodeHeader() - { - int header = input.PeekBits(16); - if (header < 0) - { - return false; - } - input.DropBits(16); - - // The header is written in "wrong" byte order - header = ((header << 8) | (header >> 8)) & 0xffff; - if (header % 31 != 0) - { - throw new SharpZipBaseException("Header checksum illegal"); - } - - if ((header & 0x0f00) != (Deflater.DEFLATED << 8)) - { - throw new SharpZipBaseException("Compression Method unknown"); - } - - /* Maximum size of the backwards window in bits. - * We currently ignore this, but we could use it to make the - * inflater window more space efficient. On the other hand the - * full window (15 bits) is needed most times, anyway. - int max_wbits = ((header & 0x7000) >> 12) + 8; - */ - - if ((header & 0x0020) == 0) - { // Dictionary flag? - mode = DECODE_BLOCKS; - } - else - { - mode = DECODE_DICT; - neededBits = 32; - } - return true; - } - - /// - /// Decodes the dictionary checksum after the deflate header. - /// - /// - /// False if more input is needed. - /// - private bool DecodeDict() - { - while (neededBits > 0) - { - int dictByte = input.PeekBits(8); - if (dictByte < 0) - { - return false; - } - input.DropBits(8); - readAdler = (readAdler << 8) | dictByte; - neededBits -= 8; - } - return false; - } - - /// - /// Decodes the huffman encoded symbols in the input stream. - /// - /// - /// false if more input is needed, true if output window is - /// full or the current block ends. - /// - /// - /// if deflated stream is invalid. - /// - private bool DecodeHuffman() - { - int free = outputWindow.GetFreeSpace(); - while (free >= 258) - { - int symbol; - switch (mode) - { - case DECODE_HUFFMAN: - // This is the inner loop so it is optimized a bit - while (((symbol = litlenTree.GetSymbol(input)) & ~0xff) == 0) - { - outputWindow.Write(symbol); - if (--free < 258) - { - return true; - } - } - - if (symbol < 257) - { - if (symbol < 0) - { - return false; - } - else - { - // symbol == 256: end of block - distTree = null; - litlenTree = null; - mode = DECODE_BLOCKS; - return true; - } - } - - try - { - repLength = CPLENS[symbol - 257]; - neededBits = CPLEXT[symbol - 257]; - } - catch (Exception) - { - throw new SharpZipBaseException("Illegal rep length code"); - } - goto case DECODE_HUFFMAN_LENBITS; // fall through - - case DECODE_HUFFMAN_LENBITS: - if (neededBits > 0) - { - mode = DECODE_HUFFMAN_LENBITS; - int i = input.PeekBits(neededBits); - if (i < 0) - { - return false; - } - input.DropBits(neededBits); - repLength += i; - } - mode = DECODE_HUFFMAN_DIST; - goto case DECODE_HUFFMAN_DIST; // fall through - - case DECODE_HUFFMAN_DIST: - symbol = distTree.GetSymbol(input); - if (symbol < 0) - { - return false; - } - - try - { - repDist = CPDIST[symbol]; - neededBits = CPDEXT[symbol]; - } - catch (Exception) - { - throw new SharpZipBaseException("Illegal rep dist code"); - } - - goto case DECODE_HUFFMAN_DISTBITS; // fall through - - case DECODE_HUFFMAN_DISTBITS: - if (neededBits > 0) - { - mode = DECODE_HUFFMAN_DISTBITS; - int i = input.PeekBits(neededBits); - if (i < 0) - { - return false; - } - input.DropBits(neededBits); - repDist += i; - } - - outputWindow.Repeat(repLength, repDist); - free -= repLength; - mode = DECODE_HUFFMAN; - break; - - default: - throw new SharpZipBaseException("Inflater unknown mode"); - } - } - return true; - } - - /// - /// Decodes the adler checksum after the deflate stream. - /// - /// - /// false if more input is needed. - /// - /// - /// If checksum doesn't match. - /// - private bool DecodeChksum() - { - while (neededBits > 0) - { - int chkByte = input.PeekBits(8); - if (chkByte < 0) - { - return false; - } - input.DropBits(8); - readAdler = (readAdler << 8) | chkByte; - neededBits -= 8; - } - - if ((int)adler?.Value != readAdler) - { - throw new SharpZipBaseException("Adler chksum doesn't match: " + (int)adler?.Value + " vs. " + readAdler); - } - - mode = FINISHED; - return false; - } - - /// - /// Decodes the deflated stream. - /// - /// - /// false if more input is needed, or if finished. - /// - /// - /// if deflated stream is invalid. - /// - private bool Decode() - { - switch (mode) - { - case DECODE_HEADER: - return DecodeHeader(); - - case DECODE_DICT: - return DecodeDict(); - - case DECODE_CHKSUM: - return DecodeChksum(); - - case DECODE_BLOCKS: - if (isLastBlock) - { - if (noHeader) - { - mode = FINISHED; - return false; - } - else - { - input.SkipToByteBoundary(); - neededBits = 32; - mode = DECODE_CHKSUM; - return true; - } - } - - int type = input.PeekBits(3); - if (type < 0) - { - return false; - } - input.DropBits(3); - - isLastBlock |= (type & 1) != 0; - switch (type >> 1) - { - case DeflaterConstants.STORED_BLOCK: - input.SkipToByteBoundary(); - mode = DECODE_STORED_LEN1; - break; - - case DeflaterConstants.STATIC_TREES: - litlenTree = InflaterHuffmanTree.defLitLenTree; - distTree = InflaterHuffmanTree.defDistTree; - mode = DECODE_HUFFMAN; - break; - - case DeflaterConstants.DYN_TREES: - dynHeader = new InflaterDynHeader(input); - mode = DECODE_DYN_HEADER; - break; - - default: - throw new SharpZipBaseException("Unknown block type " + type); - } - return true; - - case DECODE_STORED_LEN1: - { - if ((uncomprLen = input.PeekBits(16)) < 0) - { - return false; - } - input.DropBits(16); - mode = DECODE_STORED_LEN2; - } - goto case DECODE_STORED_LEN2; // fall through - - case DECODE_STORED_LEN2: - { - int nlen = input.PeekBits(16); - if (nlen < 0) - { - return false; - } - input.DropBits(16); - if (nlen != (uncomprLen ^ 0xffff)) - { - throw new SharpZipBaseException("broken uncompressed block"); - } - mode = DECODE_STORED; - } - goto case DECODE_STORED; // fall through - - case DECODE_STORED: - { - int more = outputWindow.CopyStored(input, uncomprLen); - uncomprLen -= more; - if (uncomprLen == 0) - { - mode = DECODE_BLOCKS; - return true; - } - return !input.IsNeedingInput; - } - - case DECODE_DYN_HEADER: - if (!dynHeader.AttemptRead()) - { - return false; - } - - litlenTree = dynHeader.LiteralLengthTree; - distTree = dynHeader.DistanceTree; - mode = DECODE_HUFFMAN; - goto case DECODE_HUFFMAN; // fall through - - case DECODE_HUFFMAN: - case DECODE_HUFFMAN_LENBITS: - case DECODE_HUFFMAN_DIST: - case DECODE_HUFFMAN_DISTBITS: - return DecodeHuffman(); - - case FINISHED: - return false; - - default: - throw new SharpZipBaseException("Inflater.Decode unknown mode"); - } - } - - /// - /// Sets the preset dictionary. This should only be called, if - /// needsDictionary() returns true and it should set the same - /// dictionary, that was used for deflating. The getAdler() - /// function returns the checksum of the dictionary needed. - /// - /// - /// The dictionary. - /// - public void SetDictionary(byte[] buffer) - { - SetDictionary(buffer, 0, buffer.Length); - } - - /// - /// Sets the preset dictionary. This should only be called, if - /// needsDictionary() returns true and it should set the same - /// dictionary, that was used for deflating. The getAdler() - /// function returns the checksum of the dictionary needed. - /// - /// - /// The dictionary. - /// - /// - /// The index into buffer where the dictionary starts. - /// - /// - /// The number of bytes in the dictionary. - /// - /// - /// No dictionary is needed. - /// - /// - /// The adler checksum for the buffer is invalid - /// - public void SetDictionary(byte[] buffer, int index, int count) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (index < 0) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - - if (count < 0) - { - throw new ArgumentOutOfRangeException(nameof(count)); - } - - if (!IsNeedingDictionary) - { - throw new InvalidOperationException("Dictionary is not needed"); - } - - adler?.Update(new ArraySegment(buffer, index, count)); - - if (adler != null && (int)adler.Value != readAdler) - { - throw new SharpZipBaseException("Wrong adler checksum"); - } - adler?.Reset(); - outputWindow.CopyDict(buffer, index, count); - mode = DECODE_BLOCKS; - } - - /// - /// Sets the input. This should only be called, if needsInput() - /// returns true. - /// - /// - /// the input. - /// - public void SetInput(byte[] buffer) - { - SetInput(buffer, 0, buffer.Length); - } - - /// - /// Sets the input. This should only be called, if needsInput() - /// returns true. - /// - /// - /// The source of input data - /// - /// - /// The index into buffer where the input starts. - /// - /// - /// The number of bytes of input to use. - /// - /// - /// No input is needed. - /// - /// - /// The index and/or count are wrong. - /// - public void SetInput(byte[] buffer, int index, int count) - { - input.SetInput(buffer, index, count); - totalIn += (long)count; - } - - /// - /// Inflates the compressed stream to the output buffer. If this - /// returns 0, you should check, whether IsNeedingDictionary(), - /// IsNeedingInput() or IsFinished() returns true, to determine why no - /// further output is produced. - /// - /// - /// the output buffer. - /// - /// - /// The number of bytes written to the buffer, 0 if no further - /// output can be produced. - /// - /// - /// if buffer has length 0. - /// - /// - /// if deflated stream is invalid. - /// - public int Inflate(byte[] buffer) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - return Inflate(buffer, 0, buffer.Length); - } - - /// - /// Inflates the compressed stream to the output buffer. If this - /// returns 0, you should check, whether needsDictionary(), - /// needsInput() or finished() returns true, to determine why no - /// further output is produced. - /// - /// - /// the output buffer. - /// - /// - /// the offset in buffer where storing starts. - /// - /// - /// the maximum number of bytes to output. - /// - /// - /// the number of bytes written to the buffer, 0 if no further output can be produced. - /// - /// - /// if count is less than 0. - /// - /// - /// if the index and / or count are wrong. - /// - /// - /// if deflated stream is invalid. - /// - public int Inflate(byte[] buffer, int offset, int count) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (count < 0) - { - throw new ArgumentOutOfRangeException(nameof(count), "count cannot be negative"); - } - - if (offset < 0) - { - throw new ArgumentOutOfRangeException(nameof(offset), "offset cannot be negative"); - } - - if (offset + count > buffer.Length) - { - throw new ArgumentException("count exceeds buffer bounds"); - } - - // Special case: count may be zero - if (count == 0) - { - if (!IsFinished) - { // -jr- 08-Nov-2003 INFLATE_BUG fix.. - Decode(); - } - return 0; - } - - int bytesCopied = 0; - - do - { - if (mode != DECODE_CHKSUM) - { - /* Don't give away any output, if we are waiting for the - * checksum in the input stream. - * - * With this trick we have always: - * IsNeedingInput() and not IsFinished() - * implies more output can be produced. - */ - int more = outputWindow.CopyOutput(buffer, offset, count); - if (more > 0) - { - adler?.Update(new ArraySegment(buffer, offset, more)); - offset += more; - bytesCopied += more; - totalOut += (long)more; - count -= more; - if (count == 0) - { - return bytesCopied; - } - } - } - } while (Decode() || ((outputWindow.GetAvailable() > 0) && (mode != DECODE_CHKSUM))); - return bytesCopied; - } - - /// - /// Returns true, if the input buffer is empty. - /// You should then call setInput(). - /// NOTE: This method also returns true when the stream is finished. - /// - public bool IsNeedingInput - { - get - { - return input.IsNeedingInput; - } - } - - /// - /// Returns true, if a preset dictionary is needed to inflate the input. - /// - public bool IsNeedingDictionary - { - get - { - return mode == DECODE_DICT && neededBits == 0; - } - } - - /// - /// Returns true, if the inflater has finished. This means, that no - /// input is needed and no output can be produced. - /// - public bool IsFinished - { - get - { - return mode == FINISHED && outputWindow.GetAvailable() == 0; - } - } - - /// - /// Gets the adler checksum. This is either the checksum of all - /// uncompressed bytes returned by inflate(), or if needsDictionary() - /// returns true (and thus no output was yet produced) this is the - /// adler checksum of the expected dictionary. - /// - /// - /// the adler checksum. - /// - public int Adler - { - get - { - if (IsNeedingDictionary) - { - return readAdler; - } - else if (adler != null) - { - return (int)adler.Value; - } - else - { - return 0; - } - } - } - - /// - /// Gets the total number of output bytes returned by Inflate(). - /// - /// - /// the total number of output bytes. - /// - public long TotalOut - { - get - { - return totalOut; - } - } - - /// - /// Gets the total number of processed compressed input bytes. - /// - /// - /// The total number of bytes of processed input bytes. - /// - public long TotalIn - { - get - { - return totalIn - (long)RemainingInput; - } - } - - /// - /// Gets the number of unprocessed input bytes. Useful, if the end of the - /// stream is reached and you want to further process the bytes after - /// the deflate stream. - /// - /// - /// The number of bytes of the input which have not been processed. - /// - public int RemainingInput - { - // TODO: This should be a long? - get - { - return input.AvailableBytes; - } - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/InflaterDynHeader.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/InflaterDynHeader.cs deleted file mode 100644 index f1d9fe3bf..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/InflaterDynHeader.cs +++ /dev/null @@ -1,153 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression -{ - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal class InflaterDynHeader - { - #region Constants - - // maximum number of literal/length codes - private const int LITLEN_MAX = 286; - - // maximum number of distance codes - private const int DIST_MAX = 30; - - // maximum data code lengths to read - private const int CODELEN_MAX = LITLEN_MAX + DIST_MAX; - - // maximum meta code length codes to read - private const int META_MAX = 19; - - private static readonly int[] MetaCodeLengthIndex = - { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; - - #endregion Constants - - /// - /// Continue decoding header from until more bits are needed or decoding has been completed - /// - /// Returns whether decoding could be completed - public bool AttemptRead() - => !state.MoveNext() || state.Current; - - public InflaterDynHeader(StreamManipulator input) - { - this.input = input; - stateMachine = CreateStateMachine(); - state = stateMachine.GetEnumerator(); - } - - private IEnumerable CreateStateMachine() - { - // Read initial code length counts from header - while (!input.TryGetBits(5, ref litLenCodeCount, 257)) yield return false; - while (!input.TryGetBits(5, ref distanceCodeCount, 1)) yield return false; - while (!input.TryGetBits(4, ref metaCodeCount, 4)) yield return false; - var dataCodeCount = litLenCodeCount + distanceCodeCount; - - if (litLenCodeCount > LITLEN_MAX) throw new ValueOutOfRangeException(nameof(litLenCodeCount)); - if (distanceCodeCount > DIST_MAX) throw new ValueOutOfRangeException(nameof(distanceCodeCount)); - if (metaCodeCount > META_MAX) throw new ValueOutOfRangeException(nameof(metaCodeCount)); - - // Load code lengths for the meta tree from the header bits - for (int i = 0; i < metaCodeCount; i++) - { - while (!input.TryGetBits(3, ref codeLengths, MetaCodeLengthIndex[i])) yield return false; - } - - var metaCodeTree = new InflaterHuffmanTree(codeLengths); - - // Decompress the meta tree symbols into the data table code lengths - int index = 0; - while (index < dataCodeCount) - { - byte codeLength; - int symbol; - - while ((symbol = metaCodeTree.GetSymbol(input)) < 0) yield return false; - - if (symbol < 16) - { - // append literal code length - codeLengths[index++] = (byte)symbol; - } - else - { - int repeatCount = 0; - - if (symbol == 16) // Repeat last code length 3..6 times - { - if (index == 0) - throw new StreamDecodingException("Cannot repeat previous code length when no other code length has been read"); - - codeLength = codeLengths[index - 1]; - - // 2 bits + 3, [3..6] - while (!input.TryGetBits(2, ref repeatCount, 3)) yield return false; - } - else if (symbol == 17) // Repeat zero 3..10 times - { - codeLength = 0; - - // 3 bits + 3, [3..10] - while (!input.TryGetBits(3, ref repeatCount, 3)) yield return false; - } - else // (symbol == 18), Repeat zero 11..138 times - { - codeLength = 0; - - // 7 bits + 11, [11..138] - while (!input.TryGetBits(7, ref repeatCount, 11)) yield return false; - } - - if (index + repeatCount > dataCodeCount) - throw new StreamDecodingException("Cannot repeat code lengths past total number of data code lengths"); - - while (repeatCount-- > 0) - codeLengths[index++] = codeLength; - } - } - - if (codeLengths[256] == 0) - throw new StreamDecodingException("Inflater dynamic header end-of-block code missing"); - - litLenTree = new InflaterHuffmanTree(new LemonArraySegment(codeLengths, 0, litLenCodeCount)); - distTree = new InflaterHuffmanTree(new LemonArraySegment(codeLengths, litLenCodeCount, distanceCodeCount)); - - yield return true; - } - - /// - /// Get literal/length huffman tree, must not be used before has returned true - /// - /// If hader has not been successfully read by the state machine - public InflaterHuffmanTree LiteralLengthTree - => litLenTree ?? throw new StreamDecodingException("Header properties were accessed before header had been successfully read"); - - /// - /// Get distance huffman tree, must not be used before has returned true - /// - /// If hader has not been successfully read by the state machine - public InflaterHuffmanTree DistanceTree - => distTree ?? throw new StreamDecodingException("Header properties were accessed before header had been successfully read"); - - #region Instance Fields - - private readonly StreamManipulator input; - private readonly IEnumerator state; - private readonly IEnumerable stateMachine; - - private byte[] codeLengths = new byte[CODELEN_MAX]; - - private InflaterHuffmanTree litLenTree; - private InflaterHuffmanTree distTree; - - private int litLenCodeCount, distanceCodeCount, metaCodeCount; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/InflaterHuffmanTree.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/InflaterHuffmanTree.cs deleted file mode 100644 index 508f40796..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/InflaterHuffmanTree.cs +++ /dev/null @@ -1,238 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams; -using System; -using System.Collections.Generic; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression -{ - /// - /// Huffman tree used for inflation - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class InflaterHuffmanTree - { - #region Constants - - private const int MAX_BITLEN = 15; - - #endregion Constants - - #region Instance Fields - - private short[] tree; - - #endregion Instance Fields - - /// - /// Literal length tree - /// - public static InflaterHuffmanTree defLitLenTree; - - /// - /// Distance tree - /// - public static InflaterHuffmanTree defDistTree; - - static InflaterHuffmanTree() - { - try - { - byte[] codeLengths = new byte[288]; - int i = 0; - while (i < 144) - { - codeLengths[i++] = 8; - } - while (i < 256) - { - codeLengths[i++] = 9; - } - while (i < 280) - { - codeLengths[i++] = 7; - } - while (i < 288) - { - codeLengths[i++] = 8; - } - defLitLenTree = new InflaterHuffmanTree(codeLengths); - - codeLengths = new byte[32]; - i = 0; - while (i < 32) - { - codeLengths[i++] = 5; - } - defDistTree = new InflaterHuffmanTree(codeLengths); - } - catch (Exception) - { - throw new SharpZipBaseException("InflaterHuffmanTree: static tree length illegal"); - } - } - - #region Constructors - - /// - /// Constructs a Huffman tree from the array of code lengths. - /// - /// - /// the array of code lengths - /// - public InflaterHuffmanTree(IList codeLengths) - { - BuildTree(codeLengths); - } - - #endregion Constructors - - private void BuildTree(IList codeLengths) - { - int[] blCount = new int[MAX_BITLEN + 1]; - int[] nextCode = new int[MAX_BITLEN + 1]; - - for (int i = 0; i < codeLengths.Count; i++) - { - int bits = codeLengths[i]; - if (bits > 0) - { - blCount[bits]++; - } - } - - int code = 0; - int treeSize = 512; - for (int bits = 1; bits <= MAX_BITLEN; bits++) - { - nextCode[bits] = code; - code += blCount[bits] << (16 - bits); - if (bits >= 10) - { - /* We need an extra table for bit lengths >= 10. */ - int start = nextCode[bits] & 0x1ff80; - int end = code & 0x1ff80; - treeSize += (end - start) >> (16 - bits); - } - } - - /* -jr comment this out! doesnt work for dynamic trees and pkzip 2.04g - if (code != 65536) - { - throw new SharpZipBaseException("Code lengths don't add up properly."); - } - */ - /* Now create and fill the extra tables from longest to shortest - * bit len. This way the sub trees will be aligned. - */ - tree = new short[treeSize]; - int treePtr = 512; - for (int bits = MAX_BITLEN; bits >= 10; bits--) - { - int end = code & 0x1ff80; - code -= blCount[bits] << (16 - bits); - int start = code & 0x1ff80; - for (int i = start; i < end; i += 1 << 7) - { - tree[DeflaterHuffman.BitReverse(i)] = (short)((-treePtr << 4) | bits); - treePtr += 1 << (bits - 9); - } - } - - for (int i = 0; i < codeLengths.Count; i++) - { - int bits = codeLengths[i]; - if (bits == 0) - { - continue; - } - code = nextCode[bits]; - int revcode = DeflaterHuffman.BitReverse(code); - if (bits <= 9) - { - do - { - tree[revcode] = (short)((i << 4) | bits); - revcode += 1 << bits; - } while (revcode < 512); - } - else - { - int subTree = tree[revcode & 511]; - int treeLen = 1 << (subTree & 15); - subTree = -(subTree >> 4); - do - { - tree[subTree | (revcode >> 9)] = (short)((i << 4) | bits); - revcode += 1 << bits; - } while (revcode < treeLen); - } - nextCode[bits] = code + (1 << (16 - bits)); - } - } - - /// - /// Reads the next symbol from input. The symbol is encoded using the - /// huffman tree. - /// - /// - /// input the input source. - /// - /// - /// the next symbol, or -1 if not enough input is available. - /// - public int GetSymbol(StreamManipulator input) - { - int lookahead, symbol; - if ((lookahead = input.PeekBits(9)) >= 0) - { - symbol = tree[lookahead]; - int bitlen = symbol & 15; - - if (symbol >= 0) - { - if(bitlen == 0){ - throw new SharpZipBaseException("Encountered invalid codelength 0"); - } - input.DropBits(bitlen); - return symbol >> 4; - } - int subtree = -(symbol >> 4); - if ((lookahead = input.PeekBits(bitlen)) >= 0) - { - symbol = tree[subtree | (lookahead >> 9)]; - input.DropBits(symbol & 15); - return symbol >> 4; - } - else - { - int bits = input.AvailableBits; - lookahead = input.PeekBits(bits); - symbol = tree[subtree | (lookahead >> 9)]; - if ((symbol & 15) <= bits) - { - input.DropBits(symbol & 15); - return symbol >> 4; - } - else - { - return -1; - } - } - } - else // Less than 9 bits - { - int bits = input.AvailableBits; - lookahead = input.PeekBits(bits); - symbol = tree[lookahead]; - if (symbol >= 0 && (symbol & 15) <= bits) - { - input.DropBits(symbol & 15); - return symbol >> 4; - } - else - { - return -1; - } - } - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/PendingBuffer.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/PendingBuffer.cs deleted file mode 100644 index 9fe464b66..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/PendingBuffer.cs +++ /dev/null @@ -1,271 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression -{ - /// - /// This class is general purpose class for writing data to a buffer. - /// - /// It allows you to write bits as well as bytes - /// Based on DeflaterPending.java - /// - /// author of the original java version : Jochen Hoenicke - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class PendingBuffer - { - #region Instance Fields - - /// - /// Internal work buffer - /// - private readonly byte[] buffer; - - private int start; - private int end; - - private uint bits; - private int bitCount; - - #endregion Instance Fields - - #region Constructors - - /// - /// construct instance using default buffer size of 4096 - /// - public PendingBuffer() : this(4096) - { - } - - /// - /// construct instance using specified buffer size - /// - /// - /// size to use for internal buffer - /// - public PendingBuffer(int bufferSize) - { - buffer = new byte[bufferSize]; - } - - #endregion Constructors - - /// - /// Clear internal state/buffers - /// - public void Reset() - { - start = end = bitCount = 0; - } - - /// - /// Write a byte to buffer - /// - /// - /// The value to write - /// - public void WriteByte(int value) - { -#if DebugDeflation - if (DeflaterConstants.DEBUGGING && (start != 0) ) - { - throw new SharpZipBaseException("Debug check: start != 0"); - } -#endif - buffer[end++] = unchecked((byte)value); - } - - /// - /// Write a short value to buffer LSB first - /// - /// - /// The value to write. - /// - public void WriteShort(int value) - { -#if DebugDeflation - if (DeflaterConstants.DEBUGGING && (start != 0) ) - { - throw new SharpZipBaseException("Debug check: start != 0"); - } -#endif - buffer[end++] = unchecked((byte)value); - buffer[end++] = unchecked((byte)(value >> 8)); - } - - /// - /// write an integer LSB first - /// - /// The value to write. - public void WriteInt(int value) - { -#if DebugDeflation - if (DeflaterConstants.DEBUGGING && (start != 0) ) - { - throw new SharpZipBaseException("Debug check: start != 0"); - } -#endif - buffer[end++] = unchecked((byte)value); - buffer[end++] = unchecked((byte)(value >> 8)); - buffer[end++] = unchecked((byte)(value >> 16)); - buffer[end++] = unchecked((byte)(value >> 24)); - } - - /// - /// Write a block of data to buffer - /// - /// data to write - /// offset of first byte to write - /// number of bytes to write - public void WriteBlock(byte[] block, int offset, int length) - { -#if DebugDeflation - if (DeflaterConstants.DEBUGGING && (start != 0) ) - { - throw new SharpZipBaseException("Debug check: start != 0"); - } -#endif - System.Array.Copy(block, offset, buffer, end, length); - end += length; - } - - /// - /// The number of bits written to the buffer - /// - public int BitCount - { - get - { - return bitCount; - } - } - - /// - /// Align internal buffer on a byte boundary - /// - public void AlignToByte() - { -#if DebugDeflation - if (DeflaterConstants.DEBUGGING && (start != 0) ) - { - throw new SharpZipBaseException("Debug check: start != 0"); - } -#endif - if (bitCount > 0) - { - buffer[end++] = unchecked((byte)bits); - if (bitCount > 8) - { - buffer[end++] = unchecked((byte)(bits >> 8)); - } - } - bits = 0; - bitCount = 0; - } - - /// - /// Write bits to internal buffer - /// - /// source of bits - /// number of bits to write - public void WriteBits(int b, int count) - { -#if DebugDeflation - if (DeflaterConstants.DEBUGGING && (start != 0) ) - { - throw new SharpZipBaseException("Debug check: start != 0"); - } - - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("writeBits("+b+","+count+")"); - // } -#endif - bits |= (uint)(b << bitCount); - bitCount += count; - if (bitCount >= 16) - { - buffer[end++] = unchecked((byte)bits); - buffer[end++] = unchecked((byte)(bits >> 8)); - bits >>= 16; - bitCount -= 16; - } - } - - /// - /// Write a short value to internal buffer most significant byte first - /// - /// value to write - public void WriteShortMSB(int s) - { -#if DebugDeflation - if (DeflaterConstants.DEBUGGING && (start != 0) ) - { - throw new SharpZipBaseException("Debug check: start != 0"); - } -#endif - buffer[end++] = unchecked((byte)(s >> 8)); - buffer[end++] = unchecked((byte)s); - } - - /// - /// Indicates if buffer has been flushed - /// - public bool IsFlushed - { - get - { - return end == 0; - } - } - - /// - /// Flushes the pending buffer into the given output array. If the - /// output array is to small, only a partial flush is done. - /// - /// The output array. - /// The offset into output array. - /// The maximum number of bytes to store. - /// The number of bytes flushed. - public int Flush(byte[] output, int offset, int length) - { - if (bitCount >= 8) - { - buffer[end++] = unchecked((byte)bits); - bits >>= 8; - bitCount -= 8; - } - - if (length > end - start) - { - length = end - start; - System.Array.Copy(buffer, start, output, offset, length); - start = 0; - end = 0; - } - else - { - System.Array.Copy(buffer, start, output, offset, length); - start += length; - } - return length; - } - - /// - /// Convert internal buffer to byte array. - /// Buffer is empty on completion - /// - /// - /// The internal buffer contents converted to a byte array. - /// - public byte[] ToByteArray() - { - AlignToByte(); - - byte[] result = new byte[end - start]; - System.Array.Copy(buffer, start, result, 0, result.Length); - start = 0; - end = 0; - return result; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/DeflaterOutputStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/DeflaterOutputStream.cs deleted file mode 100644 index 0a0f46844..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/DeflaterOutputStream.cs +++ /dev/null @@ -1,439 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Encryption; -using System; -using System.IO; -using System.Security.Cryptography; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - /// - /// A special stream deflating or compressing the bytes that are - /// written to it. It uses a Deflater to perform actual deflating.
- /// Authors of the original java version : Tom Tromey, Jochen Hoenicke - ///
- [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class DeflaterOutputStream : Stream - { - #region Constructors - - /// - /// Creates a new DeflaterOutputStream with a default Deflater and default buffer size. - /// - /// - /// the output stream where deflated output should be written. - /// - public DeflaterOutputStream(Stream baseOutputStream) - : this(baseOutputStream, new Deflater(), 512) - { - } - - /// - /// Creates a new DeflaterOutputStream with the given Deflater and - /// default buffer size. - /// - /// - /// the output stream where deflated output should be written. - /// - /// - /// the underlying deflater. - /// - public DeflaterOutputStream(Stream baseOutputStream, Deflater deflater) - : this(baseOutputStream, deflater, 512) - { - } - - /// - /// Creates a new DeflaterOutputStream with the given Deflater and - /// buffer size. - /// - /// - /// The output stream where deflated output is written. - /// - /// - /// The underlying deflater to use - /// - /// - /// The buffer size in bytes to use when deflating (minimum value 512) - /// - /// - /// bufsize is less than or equal to zero. - /// - /// - /// baseOutputStream does not support writing - /// - /// - /// deflater instance is null - /// - public DeflaterOutputStream(Stream baseOutputStream, Deflater deflater, int bufferSize) - { - if (baseOutputStream == null) - { - throw new ArgumentNullException(nameof(baseOutputStream)); - } - - if (baseOutputStream.CanWrite == false) - { - throw new ArgumentException("Must support writing", nameof(baseOutputStream)); - } - - if (bufferSize < 512) - { - throw new ArgumentOutOfRangeException(nameof(bufferSize)); - } - - baseOutputStream_ = baseOutputStream; - buffer_ = new byte[bufferSize]; - deflater_ = deflater ?? throw new ArgumentNullException(nameof(deflater)); - } - - #endregion Constructors - - #region Public API - - /// - /// Finishes the stream by calling finish() on the deflater. - /// - /// - /// Not all input is deflated - /// - public virtual void Finish() - { - deflater_.Finish(); - while (!deflater_.IsFinished) - { - int len = deflater_.Deflate(buffer_, 0, buffer_.Length); - if (len <= 0) - { - break; - } - - if (cryptoTransform_ != null) - { - EncryptBlock(buffer_, 0, len); - } - - baseOutputStream_.Write(buffer_, 0, len); - } - - if (!deflater_.IsFinished) - { - throw new SharpZipBaseException("Can't deflate all input?"); - } - - baseOutputStream_.Flush(); - - if (cryptoTransform_ != null) - { - if (cryptoTransform_ is ZipAESTransform) - { - AESAuthCode = ((ZipAESTransform)cryptoTransform_).GetAuthCode(); - } - cryptoTransform_.Dispose(); - cryptoTransform_ = null; - } - } - - /// - /// Gets or sets a flag indicating ownership of underlying stream. - /// When the flag is true will close the underlying stream also. - /// - /// The default value is true. - public bool IsStreamOwner { get; set; } = true; - - /// - /// Allows client to determine if an entry can be patched after its added - /// - public bool CanPatchEntries - { - get - { - return baseOutputStream_.CanSeek; - } - } - - #endregion Public API - - #region Encryption - - /// - /// The CryptoTransform currently being used to encrypt the compressed data. - /// - protected ICryptoTransform cryptoTransform_; - - /// - /// Returns the 10 byte AUTH CODE to be appended immediately following the AES data stream. - /// - protected byte[] AESAuthCode; - - /// - /// Encrypt a block of data - /// - /// - /// Data to encrypt. NOTE the original contents of the buffer are lost - /// - /// - /// Offset of first byte in buffer to encrypt - /// - /// - /// Number of bytes in buffer to encrypt - /// - protected void EncryptBlock(byte[] buffer, int offset, int length) - { - cryptoTransform_.TransformBlock(buffer, 0, length, buffer, 0); - } - - #endregion Encryption - - #region Deflation Support - - /// - /// Deflates everything in the input buffers. This will call - /// def.deflate() until all bytes from the input buffers - /// are processed. - /// - protected void Deflate() - { - Deflate(false); - } - - private void Deflate(bool flushing) - { - while (flushing || !deflater_.IsNeedingInput) - { - int deflateCount = deflater_.Deflate(buffer_, 0, buffer_.Length); - - if (deflateCount <= 0) - { - break; - } - if (cryptoTransform_ != null) - { - EncryptBlock(buffer_, 0, deflateCount); - } - - baseOutputStream_.Write(buffer_, 0, deflateCount); - } - - if (!deflater_.IsNeedingInput) - { - throw new SharpZipBaseException("DeflaterOutputStream can't deflate all input?"); - } - } - - #endregion Deflation Support - - #region Stream Overrides - - /// - /// Gets value indicating stream can be read from - /// - public override bool CanRead - { - get - { - return false; - } - } - - /// - /// Gets a value indicating if seeking is supported for this stream - /// This property always returns false - /// - public override bool CanSeek - { - get - { - return false; - } - } - - /// - /// Get value indicating if this stream supports writing - /// - public override bool CanWrite - { - get - { - return baseOutputStream_.CanWrite; - } - } - - /// - /// Get current length of stream - /// - public override long Length - { - get - { - return baseOutputStream_.Length; - } - } - - /// - /// Gets the current position within the stream. - /// - /// Any attempt to set position - public override long Position - { - get - { - return baseOutputStream_.Position; - } - set - { - throw new NotSupportedException("Position property not supported"); - } - } - - /// - /// Sets the current position of this stream to the given value. Not supported by this class! - /// - /// The offset relative to the to seek. - /// The to seek from. - /// The new position in the stream. - /// Any access - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("DeflaterOutputStream Seek not supported"); - } - - /// - /// Sets the length of this stream to the given value. Not supported by this class! - /// - /// The new stream length. - /// Any access - public override void SetLength(long value) - { - throw new NotSupportedException("DeflaterOutputStream SetLength not supported"); - } - - /// - /// Read a byte from stream advancing position by one - /// - /// The byte read cast to an int. THe value is -1 if at the end of the stream. - /// Any access - public override int ReadByte() - { - throw new NotSupportedException("DeflaterOutputStream ReadByte not supported"); - } - - /// - /// Read a block of bytes from stream - /// - /// The buffer to store read data in. - /// The offset to start storing at. - /// The maximum number of bytes to read. - /// The actual number of bytes read. Zero if end of stream is detected. - /// Any access - public override int Read(byte[] buffer, int offset, int count) - { - throw new NotSupportedException("DeflaterOutputStream Read not supported"); - } - - /// - /// Flushes the stream by calling Flush on the deflater and then - /// on the underlying stream. This ensures that all bytes are flushed. - /// - public override void Flush() - { - deflater_.Flush(); - Deflate(true); - baseOutputStream_.Flush(); - } - - /// - /// Calls and closes the underlying - /// stream when is true. - /// - protected override void Dispose(bool disposing) - { - if (!isClosed_) - { - isClosed_ = true; - - try - { - Finish(); - if (cryptoTransform_ != null) - { - GetAuthCodeIfAES(); - cryptoTransform_.Dispose(); - cryptoTransform_ = null; - } - } - finally - { - if (IsStreamOwner) - { - baseOutputStream_.Dispose(); - } - } - } - } - - /// - /// Get the Auth code for AES encrypted entries - /// - protected void GetAuthCodeIfAES() - { - if (cryptoTransform_ is ZipAESTransform) - { - AESAuthCode = ((ZipAESTransform)cryptoTransform_).GetAuthCode(); - } - } - - /// - /// Writes a single byte to the compressed output stream. - /// - /// - /// The byte value. - /// - public override void WriteByte(byte value) - { - byte[] b = new byte[1]; - b[0] = value; - Write(b, 0, 1); - } - - /// - /// Writes bytes from an array to the compressed stream. - /// - /// - /// The byte array - /// - /// - /// The offset into the byte array where to start. - /// - /// - /// The number of bytes to write. - /// - public override void Write(byte[] buffer, int offset, int count) - { - deflater_.SetInput(buffer, offset, count); - Deflate(); - } - - #endregion Stream Overrides - - #region Instance Fields - - /// - /// This buffer is used temporarily to retrieve the bytes from the - /// deflater and write them to the underlying output stream. - /// - private byte[] buffer_; - - /// - /// The deflater which is used to deflate the stream. - /// - protected Deflater deflater_; - - /// - /// Base stream the deflater depends on. - /// - protected Stream baseOutputStream_; - - private bool isClosed_; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs deleted file mode 100644 index cce24827c..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs +++ /dev/null @@ -1,715 +0,0 @@ -using System; -using System.IO; -using System.Security.Cryptography; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - /// - /// An input buffer customised for use by - /// - /// - /// The buffer supports decryption of incoming data. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class InflaterInputBuffer - { - #region Constructors - - /// - /// Initialise a new instance of with a default buffer size - /// - /// The stream to buffer. - public InflaterInputBuffer(Stream stream) : this(stream, 4096) - { - } - - /// - /// Initialise a new instance of - /// - /// The stream to buffer. - /// The size to use for the buffer - /// A minimum buffer size of 1KB is permitted. Lower sizes are treated as 1KB. - public InflaterInputBuffer(Stream stream, int bufferSize) - { - inputStream = stream; - if (bufferSize < 1024) - { - bufferSize = 1024; - } - rawData = new byte[bufferSize]; - clearText = rawData; - } - - #endregion Constructors - - /// - /// Get the length of bytes in the - /// - public int RawLength - { - get - { - return rawLength; - } - } - - /// - /// Get the contents of the raw data buffer. - /// - /// This may contain encrypted data. - public byte[] RawData - { - get - { - return rawData; - } - } - - /// - /// Get the number of useable bytes in - /// - public int ClearTextLength - { - get - { - return clearTextLength; - } - } - - /// - /// Get the contents of the clear text buffer. - /// - public byte[] ClearText - { - get - { - return clearText; - } - } - - /// - /// Get/set the number of bytes available - /// - public int Available - { - get { return available; } - set { available = value; } - } - - /// - /// Call passing the current clear text buffer contents. - /// - /// The inflater to set input for. - public void SetInflaterInput(Inflater inflater) - { - if (available > 0) - { - inflater.SetInput(clearText, clearTextLength - available, available); - available = 0; - } - } - - /// - /// Fill the buffer from the underlying input stream. - /// - public void Fill() - { - rawLength = 0; - int toRead = rawData.Length; - - while (toRead > 0 && inputStream.CanRead) - { - int count = inputStream.Read(rawData, rawLength, toRead); - if (count <= 0) - { - break; - } - rawLength += count; - toRead -= count; - } - - if (cryptoTransform != null) - { - clearTextLength = cryptoTransform.TransformBlock(rawData, 0, rawLength, clearText, 0); - } - else - { - clearTextLength = rawLength; - } - - available = clearTextLength; - } - - /// - /// Read a buffer directly from the input stream - /// - /// The buffer to fill - /// Returns the number of bytes read. - public int ReadRawBuffer(byte[] buffer) - { - return ReadRawBuffer(buffer, 0, buffer.Length); - } - - /// - /// Read a buffer directly from the input stream - /// - /// The buffer to read into - /// The offset to start reading data into. - /// The number of bytes to read. - /// Returns the number of bytes read. - public int ReadRawBuffer(byte[] outBuffer, int offset, int length) - { - if (length < 0) - { - throw new ArgumentOutOfRangeException(nameof(length)); - } - - int currentOffset = offset; - int currentLength = length; - - while (currentLength > 0) - { - if (available <= 0) - { - Fill(); - if (available <= 0) - { - return 0; - } - } - int toCopy = Math.Min(currentLength, available); - System.Array.Copy(rawData, rawLength - (int)available, outBuffer, currentOffset, toCopy); - currentOffset += toCopy; - currentLength -= toCopy; - available -= toCopy; - } - return length; - } - - /// - /// Read clear text data from the input stream. - /// - /// The buffer to add data to. - /// The offset to start adding data at. - /// The number of bytes to read. - /// Returns the number of bytes actually read. - public int ReadClearTextBuffer(byte[] outBuffer, int offset, int length) - { - if (length < 0) - { - throw new ArgumentOutOfRangeException(nameof(length)); - } - - int currentOffset = offset; - int currentLength = length; - - while (currentLength > 0) - { - if (available <= 0) - { - Fill(); - if (available <= 0) - { - return 0; - } - } - - int toCopy = Math.Min(currentLength, available); - Array.Copy(clearText, clearTextLength - (int)available, outBuffer, currentOffset, toCopy); - currentOffset += toCopy; - currentLength -= toCopy; - available -= toCopy; - } - return length; - } - - /// - /// Read a from the input stream. - /// - /// Returns the byte read. - public byte ReadLeByte() - { - if (available <= 0) - { - Fill(); - if (available <= 0) - { - throw new ZipException("EOF in header"); - } - } - byte result = rawData[rawLength - available]; - available -= 1; - return result; - } - - /// - /// Read an in little endian byte order. - /// - /// The short value read case to an int. - public int ReadLeShort() - { - return ReadLeByte() | (ReadLeByte() << 8); - } - - /// - /// Read an in little endian byte order. - /// - /// The int value read. - public int ReadLeInt() - { - return ReadLeShort() | (ReadLeShort() << 16); - } - - /// - /// Read a in little endian byte order. - /// - /// The long value read. - public long ReadLeLong() - { - return (uint)ReadLeInt() | ((long)ReadLeInt() << 32); - } - - /// - /// Get/set the to apply to any data. - /// - /// Set this value to null to have no transform applied. - public ICryptoTransform CryptoTransform - { - set - { - cryptoTransform = value; - if (cryptoTransform != null) - { - if (rawData == clearText) - { - if (internalClearText == null) - { - internalClearText = new byte[rawData.Length]; - } - clearText = internalClearText; - } - clearTextLength = rawLength; - if (available > 0) - { - cryptoTransform.TransformBlock(rawData, rawLength - available, available, clearText, rawLength - available); - } - } - else - { - clearText = rawData; - clearTextLength = rawLength; - } - } - } - - #region Instance Fields - - private int rawLength; - private byte[] rawData; - - private int clearTextLength; - private byte[] clearText; - private byte[] internalClearText; - - private int available; - - private ICryptoTransform cryptoTransform; - private Stream inputStream; - - #endregion Instance Fields - } - - /// - /// This filter stream is used to decompress data compressed using the "deflate" - /// format. The "deflate" format is described in RFC 1951. - /// - /// This stream may form the basis for other decompression filters, such - /// as the GZipInputStream. - /// - /// Author of the original java version : John Leuner. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class InflaterInputStream : Stream - { - #region Constructors - - /// - /// Create an InflaterInputStream with the default decompressor - /// and a default buffer size of 4KB. - /// - /// - /// The InputStream to read bytes from - /// - public InflaterInputStream(Stream baseInputStream) - : this(baseInputStream, new Inflater(), 4096) - { - } - - /// - /// Create an InflaterInputStream with the specified decompressor - /// and a default buffer size of 4KB. - /// - /// - /// The source of input data - /// - /// - /// The decompressor used to decompress data read from baseInputStream - /// - public InflaterInputStream(Stream baseInputStream, Inflater inf) - : this(baseInputStream, inf, 4096) - { - } - - /// - /// Create an InflaterInputStream with the specified decompressor - /// and the specified buffer size. - /// - /// - /// The InputStream to read bytes from - /// - /// - /// The decompressor to use - /// - /// - /// Size of the buffer to use - /// - public InflaterInputStream(Stream baseInputStream, Inflater inflater, int bufferSize) - { - if (baseInputStream == null) - { - throw new ArgumentNullException(nameof(baseInputStream)); - } - - if (inflater == null) - { - throw new ArgumentNullException(nameof(inflater)); - } - - if (bufferSize <= 0) - { - throw new ArgumentOutOfRangeException(nameof(bufferSize)); - } - - this.baseInputStream = baseInputStream; - this.inf = inflater; - - inputBuffer = new InflaterInputBuffer(baseInputStream, bufferSize); - } - - #endregion Constructors - - /// - /// Gets or sets a flag indicating ownership of underlying stream. - /// When the flag is true will close the underlying stream also. - /// - /// The default value is true. - public bool IsStreamOwner { get; set; } = true; - - /// - /// Skip specified number of bytes of uncompressed data - /// - /// - /// Number of bytes to skip - /// - /// - /// The number of bytes skipped, zero if the end of - /// stream has been reached - /// - /// - /// The number of bytes to skip is less than or equal to zero. - /// - public long Skip(long count) - { - if (count <= 0) - { - throw new ArgumentOutOfRangeException(nameof(count)); - } - - // v0.80 Skip by seeking if underlying stream supports it... - if (baseInputStream.CanSeek) - { - baseInputStream.Seek(count, SeekOrigin.Current); - return count; - } - else - { - int length = 2048; - if (count < length) - { - length = (int)count; - } - - byte[] tmp = new byte[length]; - int readCount = 1; - long toSkip = count; - - while ((toSkip > 0) && (readCount > 0)) - { - if (toSkip < length) - { - length = (int)toSkip; - } - - readCount = baseInputStream.Read(tmp, 0, length); - toSkip -= readCount; - } - - return count - toSkip; - } - } - - /// - /// Clear any cryptographic state. - /// - protected void StopDecrypting() - { - inputBuffer.CryptoTransform = null; - } - - /// - /// Returns 0 once the end of the stream (EOF) has been reached. - /// Otherwise returns 1. - /// - public virtual int Available - { - get - { - return inf.IsFinished ? 0 : 1; - } - } - - /// - /// Fills the buffer with more data to decompress. - /// - /// - /// Stream ends early - /// - protected void Fill() - { - // Protect against redundant calls - if (inputBuffer.Available <= 0) - { - inputBuffer.Fill(); - if (inputBuffer.Available <= 0) - { - throw new SharpZipBaseException("Unexpected EOF"); - } - } - inputBuffer.SetInflaterInput(inf); - } - - #region Stream Overrides - - /// - /// Gets a value indicating whether the current stream supports reading - /// - public override bool CanRead - { - get - { - return baseInputStream.CanRead; - } - } - - /// - /// Gets a value of false indicating seeking is not supported for this stream. - /// - public override bool CanSeek - { - get - { - return false; - } - } - - /// - /// Gets a value of false indicating that this stream is not writeable. - /// - public override bool CanWrite - { - get - { - return false; - } - } - - /// - /// A value representing the length of the stream in bytes. - /// - public override long Length - { - get - { - //return inputBuffer.RawLength; - throw new NotSupportedException("InflaterInputStream Length is not supported"); - } - } - - /// - /// The current position within the stream. - /// Throws a NotSupportedException when attempting to set the position - /// - /// Attempting to set the position - public override long Position - { - get - { - return baseInputStream.Position; - } - set - { - throw new NotSupportedException("InflaterInputStream Position not supported"); - } - } - - /// - /// Flushes the baseInputStream - /// - public override void Flush() - { - baseInputStream.Flush(); - } - - /// - /// Sets the position within the current stream - /// Always throws a NotSupportedException - /// - /// The relative offset to seek to. - /// The defining where to seek from. - /// The new position in the stream. - /// Any access - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("Seek not supported"); - } - - /// - /// Set the length of the current stream - /// Always throws a NotSupportedException - /// - /// The new length value for the stream. - /// Any access - public override void SetLength(long value) - { - throw new NotSupportedException("InflaterInputStream SetLength not supported"); - } - - /// - /// Writes a sequence of bytes to stream and advances the current position - /// This method always throws a NotSupportedException - /// - /// The buffer containing data to write. - /// The offset of the first byte to write. - /// The number of bytes to write. - /// Any access - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotSupportedException("InflaterInputStream Write not supported"); - } - - /// - /// Writes one byte to the current stream and advances the current position - /// Always throws a NotSupportedException - /// - /// The byte to write. - /// Any access - public override void WriteByte(byte value) - { - throw new NotSupportedException("InflaterInputStream WriteByte not supported"); - } - - /// - /// Closes the input stream. When - /// is true the underlying stream is also closed. - /// - protected override void Dispose(bool disposing) - { - if (!isClosed) - { - isClosed = true; - if (IsStreamOwner) - { - baseInputStream.Dispose(); - } - } - } - - /// - /// Reads decompressed data into the provided buffer byte array - /// - /// - /// The array to read and decompress data into - /// - /// - /// The offset indicating where the data should be placed - /// - /// - /// The number of bytes to decompress - /// - /// The number of bytes read. Zero signals the end of stream - /// - /// Inflater needs a dictionary - /// - public override int Read(byte[] buffer, int offset, int count) - { - if (inf.IsNeedingDictionary) - { - throw new SharpZipBaseException("Need a dictionary"); - } - - int remainingBytes = count; - while (true) - { - int bytesRead = inf.Inflate(buffer, offset, remainingBytes); - offset += bytesRead; - remainingBytes -= bytesRead; - - if (remainingBytes == 0 || inf.IsFinished) - { - break; - } - - if (inf.IsNeedingInput) - { - Fill(); - } - else if (bytesRead == 0) - { - throw new ZipException("Invalid input data"); - } - } - return count - remainingBytes; - } - - #endregion Stream Overrides - - #region Instance Fields - - /// - /// Decompressor for this stream - /// - protected Inflater inf; - - /// - /// Input buffer for this stream. - /// - protected InflaterInputBuffer inputBuffer; - - /// - /// Base stream the inflater reads from. - /// - private Stream baseInputStream; - - /// - /// The compressed size - /// - protected long csize; - - /// - /// Flag indicating whether this instance has been closed or not. - /// - private bool isClosed; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/OutputWindow.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/OutputWindow.cs deleted file mode 100644 index 150416399..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/OutputWindow.cs +++ /dev/null @@ -1,221 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - /// - /// Contains the output from the Inflation process. - /// We need to have a window so that we can refer backwards into the output stream - /// to repeat stuff.
- /// Author of the original java version : John Leuner - ///
- [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class OutputWindow - { - #region Constants - - private const int WindowSize = 1 << 15; - private const int WindowMask = WindowSize - 1; - - #endregion Constants - - #region Instance Fields - - private byte[] window = new byte[WindowSize]; //The window is 2^15 bytes - private int windowEnd; - private int windowFilled; - - #endregion Instance Fields - - /// - /// Write a byte to this output window - /// - /// value to write - /// - /// if window is full - /// - public void Write(int value) - { - if (windowFilled++ == WindowSize) - { - throw new InvalidOperationException("Window full"); - } - window[windowEnd++] = (byte)value; - windowEnd &= WindowMask; - } - - private void SlowRepeat(int repStart, int length, int distance) - { - while (length-- > 0) - { - window[windowEnd++] = window[repStart++]; - windowEnd &= WindowMask; - repStart &= WindowMask; - } - } - - /// - /// Append a byte pattern already in the window itself - /// - /// length of pattern to copy - /// distance from end of window pattern occurs - /// - /// If the repeated data overflows the window - /// - public void Repeat(int length, int distance) - { - if ((windowFilled += length) > WindowSize) - { - throw new InvalidOperationException("Window full"); - } - - int repStart = (windowEnd - distance) & WindowMask; - int border = WindowSize - length; - if ((repStart <= border) && (windowEnd < border)) - { - if (length <= distance) - { - System.Array.Copy(window, repStart, window, windowEnd, length); - windowEnd += length; - } - else - { - // We have to copy manually, since the repeat pattern overlaps. - while (length-- > 0) - { - window[windowEnd++] = window[repStart++]; - } - } - } - else - { - SlowRepeat(repStart, length, distance); - } - } - - /// - /// Copy from input manipulator to internal window - /// - /// source of data - /// length of data to copy - /// the number of bytes copied - public int CopyStored(StreamManipulator input, int length) - { - length = Math.Min(Math.Min(length, WindowSize - windowFilled), input.AvailableBytes); - int copied; - - int tailLen = WindowSize - windowEnd; - if (length > tailLen) - { - copied = input.CopyBytes(window, windowEnd, tailLen); - if (copied == tailLen) - { - copied += input.CopyBytes(window, 0, length - tailLen); - } - } - else - { - copied = input.CopyBytes(window, windowEnd, length); - } - - windowEnd = (windowEnd + copied) & WindowMask; - windowFilled += copied; - return copied; - } - - /// - /// Copy dictionary to window - /// - /// source dictionary - /// offset of start in source dictionary - /// length of dictionary - /// - /// If window isnt empty - /// - public void CopyDict(byte[] dictionary, int offset, int length) - { - if (dictionary == null) - { - throw new ArgumentNullException(nameof(dictionary)); - } - - if (windowFilled > 0) - { - throw new InvalidOperationException(); - } - - if (length > WindowSize) - { - offset += length - WindowSize; - length = WindowSize; - } - System.Array.Copy(dictionary, offset, window, 0, length); - windowEnd = length & WindowMask; - } - - /// - /// Get remaining unfilled space in window - /// - /// Number of bytes left in window - public int GetFreeSpace() - { - return WindowSize - windowFilled; - } - - /// - /// Get bytes available for output in window - /// - /// Number of bytes filled - public int GetAvailable() - { - return windowFilled; - } - - /// - /// Copy contents of window to output - /// - /// buffer to copy to - /// offset to start at - /// number of bytes to count - /// The number of bytes copied - /// - /// If a window underflow occurs - /// - public int CopyOutput(byte[] output, int offset, int len) - { - int copyEnd = windowEnd; - if (len > windowFilled) - { - len = windowFilled; - } - else - { - copyEnd = (windowEnd - windowFilled + len) & WindowMask; - } - - int copied = len; - int tailLen = len - copyEnd; - - if (tailLen > 0) - { - System.Array.Copy(window, WindowSize - tailLen, output, offset, tailLen); - offset += tailLen; - len = copyEnd; - } - System.Array.Copy(window, copyEnd - len, output, offset, len); - windowFilled -= copied; - if (windowFilled < 0) - { - throw new InvalidOperationException(); - } - return copied; - } - - /// - /// Reset by clearing window so GetAvailable returns 0 - /// - public void Reset() - { - windowFilled = windowEnd = 0; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/StreamManipulator.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/StreamManipulator.cs deleted file mode 100644 index e5a14c532..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/Streams/StreamManipulator.cs +++ /dev/null @@ -1,299 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - /// - /// This class allows us to retrieve a specified number of bits from - /// the input buffer, as well as copy big byte blocks. - /// - /// It uses an int buffer to store up to 31 bits for direct - /// manipulation. This guarantees that we can get at least 16 bits, - /// but we only need at most 15, so this is all safe. - /// - /// There are some optimizations in this class, for example, you must - /// never peek more than 8 bits more than needed, and you must first - /// peek bits before you may drop them. This is not a general purpose - /// class but optimized for the behaviour of the Inflater. - /// - /// authors of the original java version : John Leuner, Jochen Hoenicke - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class StreamManipulator - { - /// - /// Get the next sequence of bits but don't increase input pointer. bitCount must be - /// less or equal 16 and if this call succeeds, you must drop - /// at least n - 8 bits in the next call. - /// - /// The number of bits to peek. - /// - /// the value of the bits, or -1 if not enough bits available. */ - /// - public int PeekBits(int bitCount) - { - if (bitsInBuffer_ < bitCount) - { - if (windowStart_ == windowEnd_) - { - return -1; // ok - } - buffer_ |= (uint)((window_[windowStart_++] & 0xff | - (window_[windowStart_++] & 0xff) << 8) << bitsInBuffer_); - bitsInBuffer_ += 16; - } - return (int)(buffer_ & ((1 << bitCount) - 1)); - } - - /// - /// Tries to grab the next bits from the input and - /// sets to the value, adding . - /// - /// true if enough bits could be read, otherwise false - public bool TryGetBits(int bitCount, ref int output, int outputOffset = 0) - { - var bits = PeekBits(bitCount); - if (bits < 0) - { - return false; - } - output = bits + outputOffset; - DropBits(bitCount); - return true; - } - - /// - /// Tries to grab the next bits from the input and - /// sets of to the value. - /// - /// true if enough bits could be read, otherwise false - public bool TryGetBits(int bitCount, ref byte[] array, int index) - { - var bits = PeekBits(bitCount); - if (bits < 0) - { - return false; - } - array[index] = (byte)bits; - DropBits(bitCount); - return true; - } - - /// - /// Drops the next n bits from the input. You should have called PeekBits - /// with a bigger or equal n before, to make sure that enough bits are in - /// the bit buffer. - /// - /// The number of bits to drop. - public void DropBits(int bitCount) - { - buffer_ >>= bitCount; - bitsInBuffer_ -= bitCount; - } - - /// - /// Gets the next n bits and increases input pointer. This is equivalent - /// to followed by , except for correct error handling. - /// - /// The number of bits to retrieve. - /// - /// the value of the bits, or -1 if not enough bits available. - /// - public int GetBits(int bitCount) - { - int bits = PeekBits(bitCount); - if (bits >= 0) - { - DropBits(bitCount); - } - return bits; - } - - /// - /// Gets the number of bits available in the bit buffer. This must be - /// only called when a previous PeekBits() returned -1. - /// - /// - /// the number of bits available. - /// - public int AvailableBits - { - get - { - return bitsInBuffer_; - } - } - - /// - /// Gets the number of bytes available. - /// - /// - /// The number of bytes available. - /// - public int AvailableBytes - { - get - { - return windowEnd_ - windowStart_ + (bitsInBuffer_ >> 3); - } - } - - /// - /// Skips to the next byte boundary. - /// - public void SkipToByteBoundary() - { - buffer_ >>= (bitsInBuffer_ & 7); - bitsInBuffer_ &= ~7; - } - - /// - /// Returns true when SetInput can be called - /// - public bool IsNeedingInput - { - get - { - return windowStart_ == windowEnd_; - } - } - - /// - /// Copies bytes from input buffer to output buffer starting - /// at output[offset]. You have to make sure, that the buffer is - /// byte aligned. If not enough bytes are available, copies fewer - /// bytes. - /// - /// - /// The buffer to copy bytes to. - /// - /// - /// The offset in the buffer at which copying starts - /// - /// - /// The length to copy, 0 is allowed. - /// - /// - /// The number of bytes copied, 0 if no bytes were available. - /// - /// - /// Length is less than zero - /// - /// - /// Bit buffer isnt byte aligned - /// - public int CopyBytes(byte[] output, int offset, int length) - { - if (length < 0) - { - throw new ArgumentOutOfRangeException(nameof(length)); - } - - if ((bitsInBuffer_ & 7) != 0) - { - // bits_in_buffer may only be 0 or a multiple of 8 - throw new InvalidOperationException("Bit buffer is not byte aligned!"); - } - - int count = 0; - while ((bitsInBuffer_ > 0) && (length > 0)) - { - output[offset++] = (byte)buffer_; - buffer_ >>= 8; - bitsInBuffer_ -= 8; - length--; - count++; - } - - if (length == 0) - { - return count; - } - - int avail = windowEnd_ - windowStart_; - if (length > avail) - { - length = avail; - } - System.Array.Copy(window_, windowStart_, output, offset, length); - windowStart_ += length; - - if (((windowStart_ - windowEnd_) & 1) != 0) - { - // We always want an even number of bytes in input, see peekBits - buffer_ = (uint)(window_[windowStart_++] & 0xff); - bitsInBuffer_ = 8; - } - return count + length; - } - - /// - /// Resets state and empties internal buffers - /// - public void Reset() - { - buffer_ = 0; - windowStart_ = windowEnd_ = bitsInBuffer_ = 0; - } - - /// - /// Add more input for consumption. - /// Only call when IsNeedingInput returns true - /// - /// data to be input - /// offset of first byte of input - /// number of bytes of input to add. - public void SetInput(byte[] buffer, int offset, int count) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (offset < 0) - { - throw new ArgumentOutOfRangeException(nameof(offset), "Cannot be negative"); - } - - if (count < 0) - { - throw new ArgumentOutOfRangeException(nameof(count), "Cannot be negative"); - } - - if (windowStart_ < windowEnd_) - { - throw new InvalidOperationException("Old input was not completely processed"); - } - - int end = offset + count; - - // We want to throw an ArrayIndexOutOfBoundsException early. - // Note the check also handles integer wrap around. - if ((offset > end) || (end > buffer.Length)) - { - throw new ArgumentOutOfRangeException(nameof(count)); - } - - if ((count & 1) != 0) - { - // We always want an even number of bytes in input, see PeekBits - buffer_ |= (uint)((buffer[offset++] & 0xff) << bitsInBuffer_); - bitsInBuffer_ += 8; - } - - window_ = buffer; - windowStart_ = offset; - windowEnd_ = end; - } - - #region Instance Fields - - private byte[] window_; - private int windowStart_; - private int windowEnd_; - - private uint buffer_; - private int bitsInBuffer_; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/FastZip.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/FastZip.cs deleted file mode 100644 index ce01ed35d..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/FastZip.cs +++ /dev/null @@ -1,975 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Core; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression; -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// FastZipEvents supports all events applicable to FastZip operations. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class FastZipEvents - { - /// - /// Delegate to invoke when processing directories. - /// - public event EventHandler ProcessDirectory; - - /// - /// Delegate to invoke when processing files. - /// - public ProcessFileHandler ProcessFile; - - /// - /// Delegate to invoke during processing of files. - /// - public ProgressHandler Progress; - - /// - /// Delegate to invoke when processing for a file has been completed. - /// - public CompletedFileHandler CompletedFile; - - /// - /// Delegate to invoke when processing directory failures. - /// - public DirectoryFailureHandler DirectoryFailure; - - /// - /// Delegate to invoke when processing file failures. - /// - public FileFailureHandler FileFailure; - - /// - /// Raise the directory failure event. - /// - /// The directory causing the failure. - /// The exception for this event. - /// A boolean indicating if execution should continue or not. - public bool OnDirectoryFailure(string directory, Exception e) - { - bool result = false; - DirectoryFailureHandler handler = DirectoryFailure; - - if (handler != null) - { - var args = new ScanFailureEventArgs(directory, e); - handler(this, args); - result = args.ContinueRunning; - } - return result; - } - - /// - /// Fires the file failure handler delegate. - /// - /// The file causing the failure. - /// The exception for this failure. - /// A boolean indicating if execution should continue or not. - public bool OnFileFailure(string file, Exception e) - { - FileFailureHandler handler = FileFailure; - bool result = (handler != null); - - if (result) - { - var args = new ScanFailureEventArgs(file, e); - handler(this, args); - result = args.ContinueRunning; - } - return result; - } - - /// - /// Fires the ProcessFile delegate. - /// - /// The file being processed. - /// A boolean indicating if execution should continue or not. - public bool OnProcessFile(string file) - { - bool result = true; - ProcessFileHandler handler = ProcessFile; - - if (handler != null) - { - var args = new ScanEventArgs(file); - handler(this, args); - result = args.ContinueRunning; - } - return result; - } - - /// - /// Fires the delegate - /// - /// The file whose processing has been completed. - /// A boolean indicating if execution should continue or not. - public bool OnCompletedFile(string file) - { - bool result = true; - CompletedFileHandler handler = CompletedFile; - if (handler != null) - { - var args = new ScanEventArgs(file); - handler(this, args); - result = args.ContinueRunning; - } - return result; - } - - /// - /// Fires the process directory delegate. - /// - /// The directory being processed. - /// Flag indicating if the directory has matching files as determined by the current filter. - /// A of true if the operation should continue; false otherwise. - public bool OnProcessDirectory(string directory, bool hasMatchingFiles) - { - bool result = true; - EventHandler handler = ProcessDirectory; - if (handler != null) - { - var args = new DirectoryEventArgs(directory, hasMatchingFiles); - handler(this, args); - result = args.ContinueRunning; - } - return result; - } - - /// - /// The minimum timespan between events. - /// - /// The minimum period of time between events. - /// - /// The default interval is three seconds. - public TimeSpan ProgressInterval - { - get { return progressInterval_; } - set { progressInterval_ = value; } - } - - #region Instance Fields - - private TimeSpan progressInterval_ = TimeSpan.FromSeconds(3); - - #endregion Instance Fields - } - - /// - /// FastZip provides facilities for creating and extracting zip files. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class FastZip - { - #region Enumerations - - /// - /// Defines the desired handling when overwriting files during extraction. - /// - public enum Overwrite - { - /// - /// Prompt the user to confirm overwriting - /// - Prompt, - - /// - /// Never overwrite files. - /// - Never, - - /// - /// Always overwrite files. - /// - Always - } - - #endregion Enumerations - - #region Constructors - - /// - /// Initialise a default instance of . - /// - public FastZip() - { - } - - /// - /// Initialise a new instance of using the specified - /// - /// The time setting to use when creating or extracting Zip entries. - /// Using TimeSetting.LastAccessTime[Utc] when - /// creating an archive will set the file time to the moment of reading. - /// - public FastZip(ZipEntryFactory.TimeSetting timeSetting) - { - entryFactory_ = new ZipEntryFactory(timeSetting); - restoreDateTimeOnExtract_ = true; - } - - /// - /// Initialise a new instance of using the specified - /// - /// The time to set all values for created or extracted Zip Entries. - public FastZip(DateTime time) - { - entryFactory_ = new ZipEntryFactory(time); - restoreDateTimeOnExtract_ = true; - } - - /// - /// Initialise a new instance of - /// - /// The events to use during operations. - public FastZip(FastZipEvents events) - { - events_ = events; - } - - #endregion Constructors - - #region Properties - - /// - /// Get/set a value indicating whether empty directories should be created. - /// - public bool CreateEmptyDirectories - { - get { return createEmptyDirectories_; } - set { createEmptyDirectories_ = value; } - } - - /// - /// Get / set the password value. - /// - public string Password - { - get { return password_; } - set { password_ = value; } - } - - /// - /// Get / set the method of encrypting entries. - /// - /// - /// Only applies when is set. - /// Defaults to ZipCrypto for backwards compatibility purposes. - /// - public ZipEncryptionMethod EntryEncryptionMethod { get; set; } = ZipEncryptionMethod.ZipCrypto; - - /// - /// Get or set the active when creating Zip files. - /// - /// - public INameTransform NameTransform - { - get { return entryFactory_.NameTransform; } - set - { - entryFactory_.NameTransform = value; - } - } - - /// - /// Get or set the active when creating Zip files. - /// - public IEntryFactory EntryFactory - { - get { return entryFactory_; } - set - { - if (value == null) - { - entryFactory_ = new ZipEntryFactory(); - } - else - { - entryFactory_ = value; - } - } - } - - /// - /// Gets or sets the setting for Zip64 handling when writing. - /// - /// - /// The default value is dynamic which is not backwards compatible with old - /// programs and can cause problems with XP's built in compression which cant - /// read Zip64 archives. However it does avoid the situation were a large file - /// is added and cannot be completed correctly. - /// NOTE: Setting the size for entries before they are added is the best solution! - /// By default the EntryFactory used by FastZip will set the file size. - /// - public UseZip64 UseZip64 - { - get { return useZip64_; } - set { useZip64_ = value; } - } - - /// - /// Get/set a value indicating whether file dates and times should - /// be restored when extracting files from an archive. - /// - /// The default value is false. - public bool RestoreDateTimeOnExtract - { - get - { - return restoreDateTimeOnExtract_; - } - set - { - restoreDateTimeOnExtract_ = value; - } - } - - /// - /// Get/set a value indicating whether file attributes should - /// be restored during extract operations - /// - public bool RestoreAttributesOnExtract - { - get { return restoreAttributesOnExtract_; } - set { restoreAttributesOnExtract_ = value; } - } - - /// - /// Get/set the Compression Level that will be used - /// when creating the zip - /// - public Deflater.CompressionLevel CompressionLevel - { - get { return compressionLevel_; } - set { compressionLevel_ = value; } - } - - #endregion Properties - - #region Delegates - - /// - /// Delegate called when confirming overwriting of files. - /// - public delegate bool ConfirmOverwriteDelegate(string fileName); - - #endregion Delegates - - #region CreateZip - - /// - /// Create a zip file. - /// - /// The name of the zip file to create. - /// The directory to source files from. - /// True to recurse directories, false for no recursion. - /// The file filter to apply. - /// The directory filter to apply. - public void CreateZip(string zipFileName, string sourceDirectory, - bool recurse, string fileFilter, string directoryFilter) - { - CreateZip(File.Create(zipFileName), sourceDirectory, recurse, fileFilter, directoryFilter); - } - - /// - /// Create a zip file/archive. - /// - /// The name of the zip file to create. - /// The directory to obtain files and directories from. - /// True to recurse directories, false for no recursion. - /// The file filter to apply. - public void CreateZip(string zipFileName, string sourceDirectory, bool recurse, string fileFilter) - { - CreateZip(File.Create(zipFileName), sourceDirectory, recurse, fileFilter, null); - } - - /// - /// Create a zip archive sending output to the passed. - /// - /// The stream to write archive data to. - /// The directory to source files from. - /// True to recurse directories, false for no recursion. - /// The file filter to apply. - /// The directory filter to apply. - /// The is closed after creation. - public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse, string fileFilter, string directoryFilter) - { - CreateZip(outputStream, sourceDirectory, recurse, fileFilter, directoryFilter, false); - } - - /// - /// Create a zip archive sending output to the passed. - /// - /// The stream to write archive data to. - /// The directory to source files from. - /// True to recurse directories, false for no recursion. - /// The file filter to apply. - /// The directory filter to apply. - /// true to leave open after the zip has been created, false to dispose it. - public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse, string fileFilter, string directoryFilter, bool leaveOpen) - { - var scanner = new FileSystemScanner(fileFilter, directoryFilter); - CreateZip(outputStream, sourceDirectory, recurse, scanner, leaveOpen); - } - - /// - /// Create a zip file. - /// - /// The name of the zip file to create. - /// The directory to source files from. - /// True to recurse directories, false for no recursion. - /// The file filter to apply. - /// The directory filter to apply. - public void CreateZip(string zipFileName, string sourceDirectory, - bool recurse, IScanFilter fileFilter, IScanFilter directoryFilter) - { - CreateZip(File.Create(zipFileName), sourceDirectory, recurse, fileFilter, directoryFilter, false); - } - - /// - /// Create a zip archive sending output to the passed. - /// - /// The stream to write archive data to. - /// The directory to source files from. - /// True to recurse directories, false for no recursion. - /// The file filter to apply. - /// The directory filter to apply. - /// true to leave open after the zip has been created, false to dispose it. - public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse, IScanFilter fileFilter, IScanFilter directoryFilter, bool leaveOpen = false) - { - var scanner = new FileSystemScanner(fileFilter, directoryFilter); - CreateZip(outputStream, sourceDirectory, recurse, scanner, leaveOpen); - } - - /// - /// Create a zip archive sending output to the passed. - /// - /// The stream to write archive data to. - /// The directory to source files from. - /// True to recurse directories, false for no recursion. - /// For performing the actual file system scan - /// true to leave open after the zip has been created, false to dispose it. - /// The is closed after creation. - private void CreateZip(Stream outputStream, string sourceDirectory, bool recurse, FileSystemScanner scanner, bool leaveOpen) - { - NameTransform = new ZipNameTransform(sourceDirectory); - sourceDirectory_ = sourceDirectory; - - using (outputStream_ = new ZipOutputStream(outputStream)) - { - outputStream_.SetLevel((int)CompressionLevel); - outputStream_.IsStreamOwner = !leaveOpen; - outputStream_.NameTransform = null; // all required transforms handled by us - - if (false == string.IsNullOrEmpty(password_) && EntryEncryptionMethod != ZipEncryptionMethod.None) - { - outputStream_.Password = password_; - } - - outputStream_.UseZip64 = UseZip64; - scanner.ProcessFile += ProcessFile; - if (this.CreateEmptyDirectories) - { - scanner.ProcessDirectory += ProcessDirectory; - } - - if (events_ != null) - { - if (events_.FileFailure != null) - { - scanner.FileFailure += events_.FileFailure; - } - - if (events_.DirectoryFailure != null) - { - scanner.DirectoryFailure += events_.DirectoryFailure; - } - } - - scanner.Scan(sourceDirectory, recurse); - } - } - - #endregion CreateZip - - #region ExtractZip - - /// - /// Extract the contents of a zip file. - /// - /// The zip file to extract from. - /// The directory to save extracted information in. - /// A filter to apply to files. - public void ExtractZip(string zipFileName, string targetDirectory, string fileFilter) - { - ExtractZip(zipFileName, targetDirectory, Overwrite.Always, null, fileFilter, null, restoreDateTimeOnExtract_); - } - - /// - /// Extract the contents of a zip file. - /// - /// The zip file to extract from. - /// The directory to save extracted information in. - /// The style of overwriting to apply. - /// A delegate to invoke when confirming overwriting. - /// A filter to apply to files. - /// A filter to apply to directories. - /// Flag indicating whether to restore the date and time for extracted files. - /// Allow parent directory traversal in file paths (e.g. ../file) - public void ExtractZip(string zipFileName, string targetDirectory, - Overwrite overwrite, ConfirmOverwriteDelegate confirmDelegate, - string fileFilter, string directoryFilter, bool restoreDateTime, bool allowParentTraversal = false) - { - Stream inputStream = File.Open(zipFileName, FileMode.Open, FileAccess.Read, FileShare.Read); - ExtractZip(inputStream, targetDirectory, overwrite, confirmDelegate, fileFilter, directoryFilter, restoreDateTime, true, allowParentTraversal); - } - - /// - /// Extract the contents of a zip file held in a stream. - /// - /// The seekable input stream containing the zip to extract from. - /// The directory to save extracted information in. - /// The style of overwriting to apply. - /// A delegate to invoke when confirming overwriting. - /// A filter to apply to files. - /// A filter to apply to directories. - /// Flag indicating whether to restore the date and time for extracted files. - /// Flag indicating whether the inputStream will be closed by this method. - /// Allow parent directory traversal in file paths (e.g. ../file) - public void ExtractZip(Stream inputStream, string targetDirectory, - Overwrite overwrite, ConfirmOverwriteDelegate confirmDelegate, - string fileFilter, string directoryFilter, bool restoreDateTime, - bool isStreamOwner, bool allowParentTraversal = false) - { - if ((overwrite == Overwrite.Prompt) && (confirmDelegate == null)) - { - throw new ArgumentNullException(nameof(confirmDelegate)); - } - - continueRunning_ = true; - overwrite_ = overwrite; - confirmDelegate_ = confirmDelegate; - extractNameTransform_ = new WindowsNameTransform(targetDirectory, allowParentTraversal); - - fileFilter_ = new NameFilter(fileFilter); - directoryFilter_ = new NameFilter(directoryFilter); - restoreDateTimeOnExtract_ = restoreDateTime; - - using (zipFile_ = new ZipFile(inputStream, !isStreamOwner)) - { - if (password_ != null) - { - zipFile_.Password = password_; - } - - System.Collections.IEnumerator enumerator = zipFile_.GetEnumerator(); - while (continueRunning_ && enumerator.MoveNext()) - { - var entry = (ZipEntry)enumerator.Current; - if (entry.IsFile) - { - // TODO Path.GetDirectory can fail here on invalid characters. - if (directoryFilter_.IsMatch(Path.GetDirectoryName(entry.Name)) && fileFilter_.IsMatch(entry.Name)) - { - ExtractEntry(entry); - } - } - else if (entry.IsDirectory) - { - if (directoryFilter_.IsMatch(entry.Name) && CreateEmptyDirectories) - { - ExtractEntry(entry); - } - } - else - { - // Do nothing for volume labels etc... - } - } - } - } - - #endregion ExtractZip - - #region Internal Processing - - private void ProcessDirectory(object sender, DirectoryEventArgs e) - { - if (!e.HasMatchingFiles && CreateEmptyDirectories) - { - if (events_ != null) - { - events_.OnProcessDirectory(e.Name, e.HasMatchingFiles); - } - - if (e.ContinueRunning) - { - if (e.Name != sourceDirectory_) - { - ZipEntry entry = entryFactory_.MakeDirectoryEntry(e.Name); - outputStream_.PutNextEntry(entry); - } - } - } - } - - private void ProcessFile(object sender, ScanEventArgs e) - { - if ((events_ != null) && (events_.ProcessFile != null)) - { - events_.ProcessFile(sender, e); - } - - if (e.ContinueRunning) - { - try - { - // The open below is equivalent to OpenRead which guarantees that if opened the - // file will not be changed by subsequent openers, but precludes opening in some cases - // were it could succeed. ie the open may fail as its already open for writing and the share mode should reflect that. - using (FileStream stream = File.Open(e.Name, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - ZipEntry entry = entryFactory_.MakeFileEntry(e.Name); - - // Set up AES encryption for the entry if required. - ConfigureEntryEncryption(entry); - - outputStream_.PutNextEntry(entry); - AddFileContents(e.Name, stream); - } - } - catch (Exception ex) - { - if (events_ != null) - { - continueRunning_ = events_.OnFileFailure(e.Name, ex); - } - else - { - continueRunning_ = false; - throw; - } - } - } - } - - // Set up the encryption method to use for the specific entry. - private void ConfigureEntryEncryption(ZipEntry entry) - { - // Only alter the entries options if AES isn't already enabled for it - // (it might have been set up by the entry factory, and if so we let that take precedence) - if (!string.IsNullOrEmpty(Password) && entry.AESEncryptionStrength == 0) - { - switch (EntryEncryptionMethod) - { - case ZipEncryptionMethod.AES128: - entry.AESKeySize = 128; - break; - - case ZipEncryptionMethod.AES256: - entry.AESKeySize = 256; - break; - } - } - } - - private void AddFileContents(string name, Stream stream) - { - if (stream == null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (buffer_ == null) - { - buffer_ = new byte[4096]; - } - - if ((events_ != null) && (events_.Progress != null)) - { - StreamUtils.Copy(stream, outputStream_, buffer_, - events_.Progress, events_.ProgressInterval, this, name); - } - else - { - StreamUtils.Copy(stream, outputStream_, buffer_); - } - - if (events_ != null) - { - continueRunning_ = events_.OnCompletedFile(name); - } - } - - private void ExtractFileEntry(ZipEntry entry, string targetName) - { - bool proceed = true; - if (overwrite_ != Overwrite.Always) - { - if (File.Exists(targetName)) - { - if ((overwrite_ == Overwrite.Prompt) && (confirmDelegate_ != null)) - { - proceed = confirmDelegate_(targetName); - } - else - { - proceed = false; - } - } - } - - if (proceed) - { - if (events_ != null) - { - continueRunning_ = events_.OnProcessFile(entry.Name); - } - - if (continueRunning_) - { - try - { - using (FileStream outputStream = File.Create(targetName)) - { - if (buffer_ == null) - { - buffer_ = new byte[4096]; - } - - using (var inputStream = zipFile_.GetInputStream(entry)) - { - if ((events_ != null) && (events_.Progress != null)) - { - StreamUtils.Copy(inputStream, outputStream, buffer_, - events_.Progress, events_.ProgressInterval, this, entry.Name, entry.Size); - } - else - { - StreamUtils.Copy(inputStream, outputStream, buffer_); - } - } - - if (events_ != null) - { - continueRunning_ = events_.OnCompletedFile(entry.Name); - } - } - - if (restoreDateTimeOnExtract_) - { - switch (entryFactory_.Setting) - { - case ZipEntryFactory.TimeSetting.CreateTime: - File.SetCreationTime(targetName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.CreateTimeUtc: - File.SetCreationTimeUtc(targetName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.LastAccessTime: - File.SetLastAccessTime(targetName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.LastAccessTimeUtc: - File.SetLastAccessTimeUtc(targetName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.LastWriteTime: - File.SetLastWriteTime(targetName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.LastWriteTimeUtc: - File.SetLastWriteTimeUtc(targetName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.Fixed: - File.SetLastWriteTime(targetName, entryFactory_.FixedDateTime); - break; - - default: - throw new ZipException("Unhandled time setting in ExtractFileEntry"); - } - } - - if (RestoreAttributesOnExtract && entry.IsDOSEntry && (entry.ExternalFileAttributes != -1)) - { - var fileAttributes = (FileAttributes)entry.ExternalFileAttributes; - // TODO: FastZip - Setting of other file attributes on extraction is a little trickier. - fileAttributes &= (FileAttributes.Archive | FileAttributes.Normal | FileAttributes.ReadOnly | FileAttributes.Hidden); - File.SetAttributes(targetName, fileAttributes); - } - } - catch (Exception ex) - { - if (events_ != null) - { - continueRunning_ = events_.OnFileFailure(targetName, ex); - } - else - { - continueRunning_ = false; - throw; - } - } - } - } - } - - private void ExtractEntry(ZipEntry entry) - { - bool doExtraction = entry.IsCompressionMethodSupported(); - string targetName = entry.Name; - - if (doExtraction) - { - if (entry.IsFile) - { - targetName = extractNameTransform_.TransformFile(targetName); - } - else if (entry.IsDirectory) - { - targetName = extractNameTransform_.TransformDirectory(targetName); - } - - doExtraction = !(string.IsNullOrEmpty(targetName)); - } - - // TODO: Fire delegate/throw exception were compression method not supported, or name is invalid? - - string dirName = string.Empty; - - if (doExtraction) - { - if (entry.IsDirectory) - { - dirName = targetName; - } - else - { - dirName = Path.GetDirectoryName(Path.GetFullPath(targetName)); - } - } - - if (doExtraction && !Directory.Exists(dirName)) - { - if (!entry.IsDirectory || CreateEmptyDirectories) - { - try - { - continueRunning_ = events_?.OnProcessDirectory(dirName, true) ?? true; - if (continueRunning_) - { - Directory.CreateDirectory(dirName); - if (entry.IsDirectory && restoreDateTimeOnExtract_) - { - switch (entryFactory_.Setting) - { - case ZipEntryFactory.TimeSetting.CreateTime: - Directory.SetCreationTime(dirName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.CreateTimeUtc: - Directory.SetCreationTimeUtc(dirName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.LastAccessTime: - Directory.SetLastAccessTime(dirName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.LastAccessTimeUtc: - Directory.SetLastAccessTimeUtc(dirName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.LastWriteTime: - Directory.SetLastWriteTime(dirName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.LastWriteTimeUtc: - Directory.SetLastWriteTimeUtc(dirName, entry.DateTime); - break; - - case ZipEntryFactory.TimeSetting.Fixed: - Directory.SetLastWriteTime(dirName, entryFactory_.FixedDateTime); - break; - - default: - throw new ZipException("Unhandled time setting in ExtractEntry"); - } - } - } - else - { - doExtraction = false; - } - } - catch (Exception ex) - { - doExtraction = false; - if (events_ != null) - { - if (entry.IsDirectory) - { - continueRunning_ = events_.OnDirectoryFailure(targetName, ex); - } - else - { - continueRunning_ = events_.OnFileFailure(targetName, ex); - } - } - else - { - continueRunning_ = false; - throw; - } - } - } - } - - if (doExtraction && entry.IsFile) - { - ExtractFileEntry(entry, targetName); - } - } - - private static int MakeExternalAttributes(FileInfo info) - { - return (int)info.Attributes; - } - - private static bool NameIsValid(string name) - { - return !string.IsNullOrEmpty(name) && - (name.IndexOfAny(Path.GetInvalidPathChars()) < 0); - } - - #endregion Internal Processing - - #region Instance Fields - - private bool continueRunning_; - private byte[] buffer_; - private ZipOutputStream outputStream_; - private ZipFile zipFile_; - private string sourceDirectory_; - private NameFilter fileFilter_; - private NameFilter directoryFilter_; - private Overwrite overwrite_; - private ConfirmOverwriteDelegate confirmDelegate_; - - private bool restoreDateTimeOnExtract_; - private bool restoreAttributesOnExtract_; - private bool createEmptyDirectories_; - private FastZipEvents events_; - private IEntryFactory entryFactory_ = new ZipEntryFactory(); - private INameTransform extractNameTransform_; - private UseZip64 useZip64_ = UseZip64.Dynamic; - private Deflater.CompressionLevel compressionLevel_ = Deflater.CompressionLevel.DEFAULT_COMPRESSION; - - private string password_; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/IEntryFactory.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/IEntryFactory.cs deleted file mode 100644 index ba330c716..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/IEntryFactory.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using MelonLoader.ICSharpCode.SharpZipLib.Core; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// Defines factory methods for creating new values. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public interface IEntryFactory - { - /// - /// Create a for a file given its name - /// - /// The name of the file to create an entry for. - /// Returns a file entry based on the passed. - ZipEntry MakeFileEntry(string fileName); - - /// - /// Create a for a file given its name - /// - /// The name of the file to create an entry for. - /// If true get details from the file system if the file exists. - /// Returns a file entry based on the passed. - ZipEntry MakeFileEntry(string fileName, bool useFileSystem); - - /// - /// Create a for a file given its actual name and optional override name - /// - /// The name of the file to create an entry for. - /// An alternative name to be used for the new entry. Null if not applicable. - /// If true get details from the file system if the file exists. - /// Returns a file entry based on the passed. - ZipEntry MakeFileEntry(string fileName, string entryName, bool useFileSystem); - - /// - /// Create a for a directory given its name - /// - /// The name of the directory to create an entry for. - /// Returns a directory entry based on the passed. - ZipEntry MakeDirectoryEntry(string directoryName); - - /// - /// Create a for a directory given its name - /// - /// The name of the directory to create an entry for. - /// If true get details from the file system for this directory if it exists. - /// Returns a directory entry based on the passed. - ZipEntry MakeDirectoryEntry(string directoryName, bool useFileSystem); - - /// - /// Get/set the applicable. - /// - INameTransform NameTransform { get; set; } - - /// - /// Get the in use. - /// - ZipEntryFactory.TimeSetting Setting { get; } - - /// - /// Get the value to use when is set to , - /// or if not specified, the value of when the class was the initialized - /// - DateTime FixedDateTime { get; } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/WindowsNameTransform.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/WindowsNameTransform.cs deleted file mode 100644 index 24ca065c8..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/WindowsNameTransform.cs +++ /dev/null @@ -1,267 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Core; -using System; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// WindowsNameTransform transforms names to windows compatible ones. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class WindowsNameTransform : INameTransform - { - /// - /// The maximum windows path name permitted. - /// - /// This may not valid for all windows systems - CE?, etc but I cant find the equivalent in the CLR. - private const int MaxPath = 260; - - private string _baseDirectory; - private bool _trimIncomingPaths; - private char _replacementChar = '_'; - private bool _allowParentTraversal; - - /// - /// In this case we need Windows' invalid path characters. - /// Path.GetInvalidPathChars() only returns a subset invalid on all platforms. - /// - private static readonly char[] InvalidEntryChars = new char[] { - '"', '<', '>', '|', '\0', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', - '\u0006', '\a', '\b', '\t', '\n', '\v', '\f', '\r', '\u000e', '\u000f', - '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', - '\u0017', '\u0018', '\u0019', '\u001a', '\u001b', '\u001c', '\u001d', - '\u001e', '\u001f', - // extra characters for masks, etc. - '*', '?', ':' - }; - - /// - /// Initialises a new instance of - /// - /// - /// Allow parent directory traversal in file paths (e.g. ../file) - public WindowsNameTransform(string baseDirectory, bool allowParentTraversal = false) - { - BaseDirectory = baseDirectory ?? throw new ArgumentNullException(nameof(baseDirectory), "Directory name is invalid"); - AllowParentTraversal = allowParentTraversal; - } - - /// - /// Initialise a default instance of - /// - public WindowsNameTransform() - { - // Do nothing. - } - - /// - /// Gets or sets a value containing the target directory to prefix values with. - /// - public string BaseDirectory - { - get { return _baseDirectory; } - set - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - - _baseDirectory = Path.GetFullPath(value); - } - } - - /// - /// Allow parent directory traversal in file paths (e.g. ../file) - /// - public bool AllowParentTraversal - { - get => _allowParentTraversal; - set => _allowParentTraversal = value; - } - - /// - /// Gets or sets a value indicating whether paths on incoming values should be removed. - /// - public bool TrimIncomingPaths - { - get { return _trimIncomingPaths; } - set { _trimIncomingPaths = value; } - } - - /// - /// Transform a Zip directory name to a windows directory name. - /// - /// The directory name to transform. - /// The transformed name. - public string TransformDirectory(string name) - { - name = TransformFile(name); - if (name.Length > 0) - { - while (name.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) - { - name = name.Remove(name.Length - 1, 1); - } - } - else - { - throw new InvalidNameException("Cannot have an empty directory name"); - } - return name; - } - - /// - /// Transform a Zip format file name to a windows style one. - /// - /// The file name to transform. - /// The transformed name. - public string TransformFile(string name) - { - if (name != null) - { - name = MakeValidName(name, _replacementChar); - - if (_trimIncomingPaths) - { - name = Path.GetFileName(name); - } - - // This may exceed windows length restrictions. - // Combine will throw a PathTooLongException in that case. - if (_baseDirectory != null) - { - name = Path.Combine(_baseDirectory, name); - - // Ensure base directory ends with directory separator ('/' or '\' depending on OS) - var pathBase = Path.GetFullPath(_baseDirectory); - if (pathBase[pathBase.Length - 1] != Path.DirectorySeparatorChar) - { - pathBase += Path.DirectorySeparatorChar; - } - - if (!_allowParentTraversal && !Path.GetFullPath(name).StartsWith(pathBase, StringComparison.InvariantCultureIgnoreCase)) - { - throw new InvalidNameException("Parent traversal in paths is not allowed"); - } - } - } - else - { - name = string.Empty; - } - return name; - } - - /// - /// Test a name to see if it is a valid name for a windows filename as extracted from a Zip archive. - /// - /// The name to test. - /// Returns true if the name is a valid zip name; false otherwise. - /// The filename isnt a true windows path in some fundamental ways like no absolute paths, no rooted paths etc. - public static bool IsValidName(string name) - { - bool result = - (name != null) && - (name.Length <= MaxPath) && - (string.Compare(name, MakeValidName(name, '_'), StringComparison.Ordinal) == 0) - ; - - return result; - } - - /// - /// Force a name to be valid by replacing invalid characters with a fixed value - /// - /// The name to make valid - /// The replacement character to use for any invalid characters. - /// Returns a valid name - public static string MakeValidName(string name, char replacement) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - name = PathUtils.DropPathRoot(name.Replace("/", Path.DirectorySeparatorChar.ToString())); - - // Drop any leading slashes. - while ((name.Length > 0) && (name[0] == Path.DirectorySeparatorChar)) - { - name = name.Remove(0, 1); - } - - // Drop any trailing slashes. - while ((name.Length > 0) && (name[name.Length - 1] == Path.DirectorySeparatorChar)) - { - name = name.Remove(name.Length - 1, 1); - } - - // Convert consecutive \\ characters to \ - int index = name.IndexOf(string.Format("{0}{0}", Path.DirectorySeparatorChar), StringComparison.Ordinal); - while (index >= 0) - { - name = name.Remove(index, 1); - index = name.IndexOf(string.Format("{0}{0}", Path.DirectorySeparatorChar), StringComparison.Ordinal); - } - - // Convert any invalid characters using the replacement one. - index = name.IndexOfAny(InvalidEntryChars); - if (index >= 0) - { - var builder = new StringBuilder(name); - - while (index >= 0) - { - builder[index] = replacement; - - if (index >= name.Length) - { - index = -1; - } - else - { - index = name.IndexOfAny(InvalidEntryChars, index + 1); - } - } - name = builder.ToString(); - } - - // Check for names greater than MaxPath characters. - // TODO: Were is CLR version of MaxPath defined? Can't find it in Environment. - if (name.Length > MaxPath) - { - throw new PathTooLongException(); - } - - return name; - } - - /// - /// Gets or set the character to replace invalid characters during transformations. - /// - public char Replacement - { - get { return _replacementChar; } - set - { - for (int i = 0; i < InvalidEntryChars.Length; ++i) - { - if (InvalidEntryChars[i] == value) - { - throw new ArgumentException("invalid path character"); - } - } - - if ((value == Path.DirectorySeparatorChar) || (value == Path.AltDirectorySeparatorChar)) - { - throw new ArgumentException("invalid replacement character"); - } - - _replacementChar = value; - } - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipConstants.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipConstants.cs deleted file mode 100644 index 8940a588f..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipConstants.cs +++ /dev/null @@ -1,523 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - #region Enumerations - - /// - /// Determines how entries are tested to see if they should use Zip64 extensions or not. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public enum UseZip64 - { - /// - /// Zip64 will not be forced on entries during processing. - /// - /// An entry can have this overridden if required - Off, - - /// - /// Zip64 should always be used. - /// - On, - - /// - /// #ZipLib will determine use based on entry values when added to archive. - /// - Dynamic, - } - - /// - /// The kind of compression used for an entry in an archive - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public enum CompressionMethod - { - /// - /// A direct copy of the file contents is held in the archive - /// - Stored = 0, - - /// - /// Common Zip compression method using a sliding dictionary - /// of up to 32KB and secondary compression from Huffman/Shannon-Fano trees - /// - Deflated = 8, - - /// - /// An extension to deflate with a 64KB window. Not supported by #Zip currently - /// - Deflate64 = 9, - - /// - /// BZip2 compression. Not supported by #Zip. - /// - BZip2 = 12, - - /// - /// LZMA compression. Not supported by #Zip. - /// - LZMA = 14, - - /// - /// PPMd compression. Not supported by #Zip. - /// - PPMd = 98, - - /// - /// WinZip special for AES encryption, Now supported by #Zip. - /// - WinZipAES = 99, - } - - /// - /// Identifies the encryption algorithm used for an entry - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public enum EncryptionAlgorithm - { - /// - /// No encryption has been used. - /// - None = 0, - - /// - /// Encrypted using PKZIP 2.0 or 'classic' encryption. - /// - PkzipClassic = 1, - - /// - /// DES encryption has been used. - /// - Des = 0x6601, - - /// - /// RC2 encryption has been used for encryption. - /// - RC2 = 0x6602, - - /// - /// Triple DES encryption with 168 bit keys has been used for this entry. - /// - TripleDes168 = 0x6603, - - /// - /// Triple DES with 112 bit keys has been used for this entry. - /// - TripleDes112 = 0x6609, - - /// - /// AES 128 has been used for encryption. - /// - Aes128 = 0x660e, - - /// - /// AES 192 has been used for encryption. - /// - Aes192 = 0x660f, - - /// - /// AES 256 has been used for encryption. - /// - Aes256 = 0x6610, - - /// - /// RC2 corrected has been used for encryption. - /// - RC2Corrected = 0x6702, - - /// - /// Blowfish has been used for encryption. - /// - Blowfish = 0x6720, - - /// - /// Twofish has been used for encryption. - /// - Twofish = 0x6721, - - /// - /// RC4 has been used for encryption. - /// - RC4 = 0x6801, - - /// - /// An unknown algorithm has been used for encryption. - /// - Unknown = 0xffff - } - - /// - /// Defines the contents of the general bit flags field for an archive entry. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Flags] - public enum GeneralBitFlags - { - /// - /// Bit 0 if set indicates that the file is encrypted - /// - Encrypted = 0x0001, - - /// - /// Bits 1 and 2 - Two bits defining the compression method (only for Method 6 Imploding and 8,9 Deflating) - /// - Method = 0x0006, - - /// - /// Bit 3 if set indicates a trailing data descriptor is appended to the entry data - /// - Descriptor = 0x0008, - - /// - /// Bit 4 is reserved for use with method 8 for enhanced deflation - /// - ReservedPKware4 = 0x0010, - - /// - /// Bit 5 if set indicates the file contains Pkzip compressed patched data. - /// Requires version 2.7 or greater. - /// - Patched = 0x0020, - - /// - /// Bit 6 if set indicates strong encryption has been used for this entry. - /// - StrongEncryption = 0x0040, - - /// - /// Bit 7 is currently unused - /// - Unused7 = 0x0080, - - /// - /// Bit 8 is currently unused - /// - Unused8 = 0x0100, - - /// - /// Bit 9 is currently unused - /// - Unused9 = 0x0200, - - /// - /// Bit 10 is currently unused - /// - Unused10 = 0x0400, - - /// - /// Bit 11 if set indicates the filename and - /// comment fields for this file must be encoded using UTF-8. - /// - UnicodeText = 0x0800, - - /// - /// Bit 12 is documented as being reserved by PKware for enhanced compression. - /// - EnhancedCompress = 0x1000, - - /// - /// Bit 13 if set indicates that values in the local header are masked to hide - /// their actual values, and the central directory is encrypted. - /// - /// - /// Used when encrypting the central directory contents. - /// - HeaderMasked = 0x2000, - - /// - /// Bit 14 is documented as being reserved for use by PKware - /// - ReservedPkware14 = 0x4000, - - /// - /// Bit 15 is documented as being reserved for use by PKware - /// - ReservedPkware15 = 0x8000 - } - - #endregion Enumerations - - /// - /// This class contains constants used for Zip format files - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "kept for backwards compatibility")] - public static class ZipConstants - { - #region Versions - - /// - /// The version made by field for entries in the central header when created by this library - /// - /// - /// This is also the Zip version for the library when comparing against the version required to extract - /// for an entry. See . - /// - public const int VersionMadeBy = 51; // was 45 before AES - - /// - /// The version made by field for entries in the central header when created by this library - /// - /// - /// This is also the Zip version for the library when comparing against the version required to extract - /// for an entry. See ZipInputStream.CanDecompressEntry. - /// - [Obsolete("Use VersionMadeBy instead")] - public const int VERSION_MADE_BY = 51; - - /// - /// The minimum version required to support strong encryption - /// - public const int VersionStrongEncryption = 50; - - /// - /// The minimum version required to support strong encryption - /// - [Obsolete("Use VersionStrongEncryption instead")] - public const int VERSION_STRONG_ENCRYPTION = 50; - - /// - /// Version indicating AES encryption - /// - public const int VERSION_AES = 51; - - /// - /// The version required for Zip64 extensions (4.5 or higher) - /// - public const int VersionZip64 = 45; - - /// - /// The version required for BZip2 compression (4.6 or higher) - /// - public const int VersionBZip2 = 46; - - #endregion Versions - - #region Header Sizes - - /// - /// Size of local entry header (excluding variable length fields at end) - /// - public const int LocalHeaderBaseSize = 30; - - /// - /// Size of local entry header (excluding variable length fields at end) - /// - [Obsolete("Use LocalHeaderBaseSize instead")] - public const int LOCHDR = 30; - - /// - /// Size of Zip64 data descriptor - /// - public const int Zip64DataDescriptorSize = 24; - - /// - /// Size of data descriptor - /// - public const int DataDescriptorSize = 16; - - /// - /// Size of data descriptor - /// - [Obsolete("Use DataDescriptorSize instead")] - public const int EXTHDR = 16; - - /// - /// Size of central header entry (excluding variable fields) - /// - public const int CentralHeaderBaseSize = 46; - - /// - /// Size of central header entry - /// - [Obsolete("Use CentralHeaderBaseSize instead")] - public const int CENHDR = 46; - - /// - /// Size of end of central record (excluding variable fields) - /// - public const int EndOfCentralRecordBaseSize = 22; - - /// - /// Size of end of central record (excluding variable fields) - /// - [Obsolete("Use EndOfCentralRecordBaseSize instead")] - public const int ENDHDR = 22; - - /// - /// Size of 'classic' cryptographic header stored before any entry data - /// - public const int CryptoHeaderSize = 12; - - /// - /// Size of cryptographic header stored before entry data - /// - [Obsolete("Use CryptoHeaderSize instead")] - public const int CRYPTO_HEADER_SIZE = 12; - - /// - /// The size of the Zip64 central directory locator. - /// - public const int Zip64EndOfCentralDirectoryLocatorSize = 20; - - #endregion Header Sizes - - #region Header Signatures - - /// - /// Signature for local entry header - /// - public const int LocalHeaderSignature = 'P' | ('K' << 8) | (3 << 16) | (4 << 24); - - /// - /// Signature for local entry header - /// - [Obsolete("Use LocalHeaderSignature instead")] - public const int LOCSIG = 'P' | ('K' << 8) | (3 << 16) | (4 << 24); - - /// - /// Signature for spanning entry - /// - public const int SpanningSignature = 'P' | ('K' << 8) | (7 << 16) | (8 << 24); - - /// - /// Signature for spanning entry - /// - [Obsolete("Use SpanningSignature instead")] - public const int SPANNINGSIG = 'P' | ('K' << 8) | (7 << 16) | (8 << 24); - - /// - /// Signature for temporary spanning entry - /// - public const int SpanningTempSignature = 'P' | ('K' << 8) | ('0' << 16) | ('0' << 24); - - /// - /// Signature for temporary spanning entry - /// - [Obsolete("Use SpanningTempSignature instead")] - public const int SPANTEMPSIG = 'P' | ('K' << 8) | ('0' << 16) | ('0' << 24); - - /// - /// Signature for data descriptor - /// - /// - /// This is only used where the length, Crc, or compressed size isnt known when the - /// entry is created and the output stream doesnt support seeking. - /// The local entry cannot be 'patched' with the correct values in this case - /// so the values are recorded after the data prefixed by this header, as well as in the central directory. - /// - public const int DataDescriptorSignature = 'P' | ('K' << 8) | (7 << 16) | (8 << 24); - - /// - /// Signature for data descriptor - /// - /// - /// This is only used where the length, Crc, or compressed size isnt known when the - /// entry is created and the output stream doesnt support seeking. - /// The local entry cannot be 'patched' with the correct values in this case - /// so the values are recorded after the data prefixed by this header, as well as in the central directory. - /// - [Obsolete("Use DataDescriptorSignature instead")] - public const int EXTSIG = 'P' | ('K' << 8) | (7 << 16) | (8 << 24); - - /// - /// Signature for central header - /// - [Obsolete("Use CentralHeaderSignature instead")] - public const int CENSIG = 'P' | ('K' << 8) | (1 << 16) | (2 << 24); - - /// - /// Signature for central header - /// - public const int CentralHeaderSignature = 'P' | ('K' << 8) | (1 << 16) | (2 << 24); - - /// - /// Signature for Zip64 central file header - /// - public const int Zip64CentralFileHeaderSignature = 'P' | ('K' << 8) | (6 << 16) | (6 << 24); - - /// - /// Signature for Zip64 central file header - /// - [Obsolete("Use Zip64CentralFileHeaderSignature instead")] - public const int CENSIG64 = 'P' | ('K' << 8) | (6 << 16) | (6 << 24); - - /// - /// Signature for Zip64 central directory locator - /// - public const int Zip64CentralDirLocatorSignature = 'P' | ('K' << 8) | (6 << 16) | (7 << 24); - - /// - /// Signature for archive extra data signature (were headers are encrypted). - /// - public const int ArchiveExtraDataSignature = 'P' | ('K' << 8) | (6 << 16) | (7 << 24); - - /// - /// Central header digital signature - /// - public const int CentralHeaderDigitalSignature = 'P' | ('K' << 8) | (5 << 16) | (5 << 24); - - /// - /// Central header digital signature - /// - [Obsolete("Use CentralHeaderDigitalSignaure instead")] - public const int CENDIGITALSIG = 'P' | ('K' << 8) | (5 << 16) | (5 << 24); - - /// - /// End of central directory record signature - /// - public const int EndOfCentralDirectorySignature = 'P' | ('K' << 8) | (5 << 16) | (6 << 24); - - /// - /// End of central directory record signature - /// - [Obsolete("Use EndOfCentralDirectorySignature instead")] - public const int ENDSIG = 'P' | ('K' << 8) | (5 << 16) | (6 << 24); - - #endregion Header Signatures - - /// - /// Default encoding used for string conversion. 0 gives the default system OEM code page. - /// Using the default code page isnt the full solution necessarily - /// there are many variable factors, codepage 850 is often a good choice for - /// European users, however be careful about compatability. - /// - [Obsolete("Use ZipStrings instead")] - public static int DefaultCodePage - { - get => ZipStrings.CodePage; - set => ZipStrings.CodePage = value; - } - - /// Deprecated wrapper for - [Obsolete("Use ZipStrings.ConvertToString instead")] - public static string ConvertToString(byte[] data, int count) - => ZipStrings.ConvertToString(data, count); - - /// Deprecated wrapper for - [Obsolete("Use ZipStrings.ConvertToString instead")] - public static string ConvertToString(byte[] data) - => ZipStrings.ConvertToString(data); - - /// Deprecated wrapper for - [Obsolete("Use ZipStrings.ConvertToStringExt instead")] - public static string ConvertToStringExt(int flags, byte[] data, int count) - => ZipStrings.ConvertToStringExt(flags, data, count); - - /// Deprecated wrapper for - [Obsolete("Use ZipStrings.ConvertToStringExt instead")] - public static string ConvertToStringExt(int flags, byte[] data) - => ZipStrings.ConvertToStringExt(flags, data); - - /// Deprecated wrapper for - [Obsolete("Use ZipStrings.ConvertToArray instead")] - public static byte[] ConvertToArray(string str) - => ZipStrings.ConvertToArray(str); - - /// Deprecated wrapper for - [Obsolete("Use ZipStrings.ConvertToArray instead")] - public static byte[] ConvertToArray(int flags, string str) - => ZipStrings.ConvertToArray(flags, str); - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEncryptionMethod.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEncryptionMethod.cs deleted file mode 100644 index c71c00808..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEncryptionMethod.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// The method of encrypting entries when creating zip archives. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public enum ZipEncryptionMethod - { - /// - /// No encryption will be used. - /// - None, - - /// - /// Encrypt entries with ZipCrypto. - /// - ZipCrypto, - - /// - /// Encrypt entries with AES 128. - /// - AES128, - - /// - /// Encrypt entries with AES 256. - /// - AES256 - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEntry.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEntry.cs deleted file mode 100644 index dab47bc43..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEntry.cs +++ /dev/null @@ -1,1157 +0,0 @@ -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// Defines known values for the property. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public enum HostSystemID - { - /// - /// Host system = MSDOS - /// - Msdos = 0, - - /// - /// Host system = Amiga - /// - Amiga = 1, - - /// - /// Host system = Open VMS - /// - OpenVms = 2, - - /// - /// Host system = Unix - /// - Unix = 3, - - /// - /// Host system = VMCms - /// - VMCms = 4, - - /// - /// Host system = Atari ST - /// - AtariST = 5, - - /// - /// Host system = OS2 - /// - OS2 = 6, - - /// - /// Host system = Macintosh - /// - Macintosh = 7, - - /// - /// Host system = ZSystem - /// - ZSystem = 8, - - /// - /// Host system = Cpm - /// - Cpm = 9, - - /// - /// Host system = Windows NT - /// - WindowsNT = 10, - - /// - /// Host system = MVS - /// - MVS = 11, - - /// - /// Host system = VSE - /// - Vse = 12, - - /// - /// Host system = Acorn RISC - /// - AcornRisc = 13, - - /// - /// Host system = VFAT - /// - Vfat = 14, - - /// - /// Host system = Alternate MVS - /// - AlternateMvs = 15, - - /// - /// Host system = BEOS - /// - BeOS = 16, - - /// - /// Host system = Tandem - /// - Tandem = 17, - - /// - /// Host system = OS400 - /// - OS400 = 18, - - /// - /// Host system = OSX - /// - OSX = 19, - - /// - /// Host system = WinZIP AES - /// - WinZipAES = 99, - } - - /// - /// This class represents an entry in a zip archive. This can be a file - /// or a directory - /// ZipFile and ZipInputStream will give you instances of this class as - /// information about the members in an archive. ZipOutputStream - /// uses an instance of this class when creating an entry in a Zip file. - ///
- ///
Author of the original java version : Jochen Hoenicke - ///
- [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class ZipEntry - { - [Flags] - private enum Known : byte - { - None = 0, - Size = 0x01, - CompressedSize = 0x02, - Crc = 0x04, - Time = 0x08, - ExternalAttributes = 0x10, - } - - #region Constructors - - /// - /// Creates a zip entry with the given name. - /// - /// - /// The name for this entry. Can include directory components. - /// The convention for names is 'unix' style paths with relative names only. - /// There are with no device names and path elements are separated by '/' characters. - /// - /// - /// The name passed is null - /// - public ZipEntry(string name) - : this(name, 0, ZipConstants.VersionMadeBy, CompressionMethod.Deflated) - { - } - - /// - /// Creates a zip entry with the given name and version required to extract - /// - /// - /// The name for this entry. Can include directory components. - /// The convention for names is 'unix' style paths with no device names and - /// path elements separated by '/' characters. This is not enforced see CleanName - /// on how to ensure names are valid if this is desired. - /// - /// - /// The minimum 'feature version' required this entry - /// - /// - /// The name passed is null - /// - internal ZipEntry(string name, int versionRequiredToExtract) - : this(name, versionRequiredToExtract, ZipConstants.VersionMadeBy, - CompressionMethod.Deflated) - { - } - - /// - /// Initializes an entry with the given name and made by information - /// - /// Name for this entry - /// Version and HostSystem Information - /// Minimum required zip feature version required to extract this entry - /// Compression method for this entry. - /// - /// The name passed is null - /// - /// - /// versionRequiredToExtract should be 0 (auto-calculate) or > 10 - /// - /// - /// This constructor is used by the ZipFile class when reading from the central header - /// It is not generally useful, use the constructor specifying the name only. - /// - internal ZipEntry(string name, int versionRequiredToExtract, int madeByInfo, - CompressionMethod method) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - if (name.Length > 0xffff) - { - throw new ArgumentException("Name is too long", nameof(name)); - } - - if ((versionRequiredToExtract != 0) && (versionRequiredToExtract < 10)) - { - throw new ArgumentOutOfRangeException(nameof(versionRequiredToExtract)); - } - - this.DateTime = DateTime.Now; - this.name = name; - this.versionMadeBy = (ushort)madeByInfo; - this.versionToExtract = (ushort)versionRequiredToExtract; - this.method = method; - - IsUnicodeText = ZipStrings.UseUnicode; - } - - /// - /// Creates a deep copy of the given zip entry. - /// - /// - /// The entry to copy. - /// - [Obsolete("Use Clone instead")] - public ZipEntry(ZipEntry entry) - { - if (entry == null) - { - throw new ArgumentNullException(nameof(entry)); - } - - known = entry.known; - name = entry.name; - size = entry.size; - compressedSize = entry.compressedSize; - crc = entry.crc; - dateTime = entry.DateTime; - method = entry.method; - comment = entry.comment; - versionToExtract = entry.versionToExtract; - versionMadeBy = entry.versionMadeBy; - externalFileAttributes = entry.externalFileAttributes; - flags = entry.flags; - - zipFileIndex = entry.zipFileIndex; - offset = entry.offset; - - forceZip64_ = entry.forceZip64_; - - if (entry.extra != null) - { - extra = new byte[entry.extra.Length]; - Array.Copy(entry.extra, 0, extra, 0, entry.extra.Length); - } - } - - #endregion Constructors - - /// - /// Get a value indicating whether the entry has a CRC value available. - /// - public bool HasCrc => (known & Known.Crc) != 0; - - /// - /// Get/Set flag indicating if entry is encrypted. - /// A simple helper routine to aid interpretation of flags - /// - /// This is an assistant that interprets the flags property. - public bool IsCrypted - { - get => this.HasFlag(GeneralBitFlags.Encrypted); - set => this.SetFlag(GeneralBitFlags.Encrypted, value); - } - - /// - /// Get / set a flag indicating whether entry name and comment text are - /// encoded in unicode UTF8. - /// - /// This is an assistant that interprets the flags property. - public bool IsUnicodeText - { - get => this.HasFlag(GeneralBitFlags.UnicodeText); - set => this.SetFlag(GeneralBitFlags.UnicodeText, value); - } - - /// - /// Value used during password checking for PKZIP 2.0 / 'classic' encryption. - /// - internal byte CryptoCheckValue - { - get => cryptoCheckValue_; - set => cryptoCheckValue_ = value; - } - - /// - /// Get/Set general purpose bit flag for entry - /// - /// - /// General purpose bit flag
- ///
- /// Bit 0: If set, indicates the file is encrypted
- /// Bit 1-2 Only used for compression type 6 Imploding, and 8, 9 deflating
- /// Imploding:
- /// Bit 1 if set indicates an 8K sliding dictionary was used. If clear a 4k dictionary was used
- /// Bit 2 if set indicates 3 Shannon-Fanno trees were used to encode the sliding dictionary, 2 otherwise
- ///
- /// Deflating:
- /// Bit 2 Bit 1
- /// 0 0 Normal compression was used
- /// 0 1 Maximum compression was used
- /// 1 0 Fast compression was used
- /// 1 1 Super fast compression was used
- ///
- /// Bit 3: If set, the fields crc-32, compressed size - /// and uncompressed size are were not able to be written during zip file creation - /// The correct values are held in a data descriptor immediately following the compressed data.
- /// Bit 4: Reserved for use by PKZIP for enhanced deflating
- /// Bit 5: If set indicates the file contains compressed patch data
- /// Bit 6: If set indicates strong encryption was used.
- /// Bit 7-10: Unused or reserved
- /// Bit 11: If set the name and comments for this entry are in unicode.
- /// Bit 12-15: Unused or reserved
- ///
- /// - /// - public int Flags - { - get => flags; - set => flags = value; - } - - /// - /// Get/Set index of this entry in Zip file - /// - /// This is only valid when the entry is part of a - public long ZipFileIndex - { - get => zipFileIndex; - set => zipFileIndex = value; - } - - /// - /// Get/set offset for use in central header - /// - public long Offset - { - get => offset; - set => offset = value; - } - - /// - /// Get/Set external file attributes as an integer. - /// The values of this are operating system dependent see - /// HostSystem for details - /// - public int ExternalFileAttributes - { - get => (known & Known.ExternalAttributes) == 0 ? -1 : externalFileAttributes; - - set - { - externalFileAttributes = value; - known |= Known.ExternalAttributes; - } - } - - /// - /// Get the version made by for this entry or zero if unknown. - /// The value / 10 indicates the major version number, and - /// the value mod 10 is the minor version number - /// - public int VersionMadeBy => versionMadeBy & 0xff; - - /// - /// Get a value indicating this entry is for a DOS/Windows system. - /// - public bool IsDOSEntry - => (HostSystem == (int)HostSystemID.Msdos) - || (HostSystem == (int)HostSystemID.WindowsNT); - - /// - /// Test the external attributes for this to - /// see if the external attributes are Dos based (including WINNT and variants) - /// and match the values - /// - /// The attributes to test. - /// Returns true if the external attributes are known to be DOS/Windows - /// based and have the same attributes set as the value passed. - private bool HasDosAttributes(int attributes) - { - bool result = false; - if ((known & Known.ExternalAttributes) != 0) - { - result |= (((HostSystem == (int)HostSystemID.Msdos) || - (HostSystem == (int)HostSystemID.WindowsNT)) && - (ExternalFileAttributes & attributes) == attributes); - } - return result; - } - - /// - /// Gets the compatibility information for the external file attribute - /// If the external file attributes are compatible with MS-DOS and can be read - /// by PKZIP for DOS version 2.04g then this value will be zero. Otherwise the value - /// will be non-zero and identify the host system on which the attributes are compatible. - /// - /// - /// - /// The values for this as defined in the Zip File format and by others are shown below. The values are somewhat - /// misleading in some cases as they are not all used as shown. You should consult the relevant documentation - /// to obtain up to date and correct information. The modified appnote by the infozip group is - /// particularly helpful as it documents a lot of peculiarities. The document is however a little dated. - /// - /// 0 - MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems) - /// 1 - Amiga - /// 2 - OpenVMS - /// 3 - Unix - /// 4 - VM/CMS - /// 5 - Atari ST - /// 6 - OS/2 HPFS - /// 7 - Macintosh - /// 8 - Z-System - /// 9 - CP/M - /// 10 - Windows NTFS - /// 11 - MVS (OS/390 - Z/OS) - /// 12 - VSE - /// 13 - Acorn Risc - /// 14 - VFAT - /// 15 - Alternate MVS - /// 16 - BeOS - /// 17 - Tandem - /// 18 - OS/400 - /// 19 - OS/X (Darwin) - /// 99 - WinZip AES - /// remainder - unused - /// - /// - public int HostSystem - { - get => (versionMadeBy >> 8) & 0xff; - - set - { - versionMadeBy &= 0x00ff; - versionMadeBy |= (ushort)((value & 0xff) << 8); - } - } - - /// - /// Get minimum Zip feature version required to extract this entry - /// - /// - /// Minimum features are defined as:
- /// 1.0 - Default value
- /// 1.1 - File is a volume label
- /// 2.0 - File is a folder/directory
- /// 2.0 - File is compressed using Deflate compression
- /// 2.0 - File is encrypted using traditional encryption
- /// 2.1 - File is compressed using Deflate64
- /// 2.5 - File is compressed using PKWARE DCL Implode
- /// 2.7 - File is a patch data set
- /// 4.5 - File uses Zip64 format extensions
- /// 4.6 - File is compressed using BZIP2 compression
- /// 5.0 - File is encrypted using DES
- /// 5.0 - File is encrypted using 3DES
- /// 5.0 - File is encrypted using original RC2 encryption
- /// 5.0 - File is encrypted using RC4 encryption
- /// 5.1 - File is encrypted using AES encryption
- /// 5.1 - File is encrypted using corrected RC2 encryption
- /// 5.1 - File is encrypted using corrected RC2-64 encryption
- /// 6.1 - File is encrypted using non-OAEP key wrapping
- /// 6.2 - Central directory encryption (not confirmed yet)
- /// 6.3 - File is compressed using LZMA
- /// 6.3 - File is compressed using PPMD+
- /// 6.3 - File is encrypted using Blowfish
- /// 6.3 - File is encrypted using Twofish
- ///
- /// - public int Version - { - get - { - // Return recorded version if known. - if (versionToExtract != 0) - // Only lower order byte. High order is O/S file system. - return versionToExtract & 0x00ff; - - if (AESKeySize > 0) - // Ver 5.1 = AES - return ZipConstants.VERSION_AES; - - if (CompressionMethod.BZip2 == method) - return ZipConstants.VersionBZip2; - - if (CentralHeaderRequiresZip64) - return ZipConstants.VersionZip64; - - if (CompressionMethod.Deflated == method || IsDirectory || IsCrypted) - return 20; - - if (HasDosAttributes(0x08)) - return 11; - - return 10; - } - } - - /// - /// Get a value indicating whether this entry can be decompressed by the library. - /// - /// This is based on the and - /// whether the compression method is supported. - public bool CanDecompress - => Version <= ZipConstants.VersionMadeBy - && (Version == 10 || Version == 11 || Version == 20 || Version == 45 || Version == 46 || Version == 51) - && IsCompressionMethodSupported(); - - /// - /// Force this entry to be recorded using Zip64 extensions. - /// - public void ForceZip64() => forceZip64_ = true; - - /// - /// Get a value indicating whether Zip64 extensions were forced. - /// - /// A value of true if Zip64 extensions have been forced on; false if not. - public bool IsZip64Forced() => forceZip64_; - - /// - /// Gets a value indicating if the entry requires Zip64 extensions - /// to store the full entry values. - /// - /// A value of true if a local header requires Zip64 extensions; false if not. - public bool LocalHeaderRequiresZip64 - { - get - { - bool result = forceZip64_; - - if (!result) - { - ulong trueCompressedSize = compressedSize; - - if ((versionToExtract == 0) && IsCrypted) - { - trueCompressedSize += (ulong)this.EncryptionOverheadSize; - } - - // TODO: A better estimation of the true limit based on compression overhead should be used - // to determine when an entry should use Zip64. - result = - ((this.size >= uint.MaxValue) || (trueCompressedSize >= uint.MaxValue)) && - ((versionToExtract == 0) || (versionToExtract >= ZipConstants.VersionZip64)); - } - - return result; - } - } - - /// - /// Get a value indicating whether the central directory entry requires Zip64 extensions to be stored. - /// - public bool CentralHeaderRequiresZip64 - => LocalHeaderRequiresZip64 || (offset >= uint.MaxValue); - - /// - /// Get/Set DosTime value. - /// - /// - /// The MS-DOS date format can only represent dates between 1/1/1980 and 12/31/2107. - /// - public long DosTime - { - get - { - if ((known & Known.Time) == 0) - { - return 0; - } - - var year = (uint)DateTime.Year; - var month = (uint)DateTime.Month; - var day = (uint)DateTime.Day; - var hour = (uint)DateTime.Hour; - var minute = (uint)DateTime.Minute; - var second = (uint)DateTime.Second; - - if (year < 1980) - { - year = 1980; - month = 1; - day = 1; - hour = 0; - minute = 0; - second = 0; - } - else if (year > 2107) - { - year = 2107; - month = 12; - day = 31; - hour = 23; - minute = 59; - second = 59; - } - - return ((year - 1980) & 0x7f) << 25 | - (month << 21) | - (day << 16) | - (hour << 11) | - (minute << 5) | - (second >> 1); - } - - set - { - unchecked - { - var dosTime = (uint)value; - uint sec = Math.Min(59, 2 * (dosTime & 0x1f)); - uint min = Math.Min(59, (dosTime >> 5) & 0x3f); - uint hrs = Math.Min(23, (dosTime >> 11) & 0x1f); - uint mon = Math.Max(1, Math.Min(12, ((uint)(value >> 21) & 0xf))); - uint year = ((dosTime >> 25) & 0x7f) + 1980; - int day = Math.Max(1, Math.Min(DateTime.DaysInMonth((int)year, (int)mon), (int)((value >> 16) & 0x1f))); - DateTime = new DateTime((int)year, (int)mon, day, (int)hrs, (int)min, (int)sec, DateTimeKind.Unspecified); - } - } - } - - /// - /// Gets/Sets the time of last modification of the entry. - /// - /// - /// The property is updated to match this as far as possible. - /// - public DateTime DateTime - { - get => dateTime; - - set - { - dateTime = value; - known |= Known.Time; - } - } - - /// - /// Returns the entry name. - /// - /// - /// The unix naming convention is followed. - /// Path components in the entry should always separated by forward slashes ('/'). - /// Dos device names like C: should also be removed. - /// See the class, or - /// - public string Name - { - get => name; - internal set => name = value; - } - - /// - /// Gets/Sets the size of the uncompressed data. - /// - /// - /// The size or -1 if unknown. - /// - /// Setting the size before adding an entry to an archive can help - /// avoid compatibility problems with some archivers which don't understand Zip64 extensions. - public long Size - { - get => (known & Known.Size) != 0 ? (long)size : -1L; - set - { - size = (ulong)value; - known |= Known.Size; - } - } - - /// - /// Gets/Sets the size of the compressed data. - /// - /// - /// The compressed entry size or -1 if unknown. - /// - public long CompressedSize - { - get => (known & Known.CompressedSize) != 0 ? (long)compressedSize : -1L; - set - { - compressedSize = (ulong)value; - known |= Known.CompressedSize; - } - } - - /// - /// Gets/Sets the crc of the uncompressed data. - /// - /// - /// Crc is not in the range 0..0xffffffffL - /// - /// - /// The crc value or -1 if unknown. - /// - public long Crc - { - get => (known & Known.Crc) != 0 ? crc & 0xffffffffL : -1L; - set - { - if ((crc & 0xffffffff00000000L) != 0) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - this.crc = (uint)value; - this.known |= Known.Crc; - } - } - - /// - /// Gets/Sets the compression method. - /// - /// - /// The compression method for this entry - /// - public CompressionMethod CompressionMethod - { - get => method; - set => method = value; - } - - /// - /// Gets the compression method for outputting to the local or central header. - /// Returns same value as CompressionMethod except when AES encrypting, which - /// places 99 in the method and places the real method in the extra data. - /// - internal CompressionMethod CompressionMethodForHeader - => (AESKeySize > 0) ? CompressionMethod.WinZipAES : method; - - /// - /// Gets/Sets the extra data. - /// - /// - /// Extra data is longer than 64KB (0xffff) bytes. - /// - /// - /// Extra data or null if not set. - /// - public byte[] ExtraData - { - // TODO: This is slightly safer but less efficient. Think about whether it should change. - // return (byte[]) extra.Clone(); - get => extra; - - set - { - if (value == null) - { - extra = null; - } - else - { - if (value.Length > 0xffff) - { - throw new System.ArgumentOutOfRangeException(nameof(value)); - } - - extra = new byte[value.Length]; - Array.Copy(value, 0, extra, 0, value.Length); - } - } - } - - /// - /// For AES encrypted files returns or sets the number of bits of encryption (128, 192 or 256). - /// When setting, only 0 (off), 128 or 256 is supported. - /// - public int AESKeySize - { - get - { - // the strength (1 or 3) is in the entry header - switch (_aesEncryptionStrength) - { - case 0: - return 0; // Not AES - case 1: - return 128; - - case 2: - return 192; // Not used by WinZip - case 3: - return 256; - - default: - throw new ZipException("Invalid AESEncryptionStrength " + _aesEncryptionStrength); - } - } - set - { - switch (value) - { - case 0: - _aesEncryptionStrength = 0; - break; - - case 128: - _aesEncryptionStrength = 1; - break; - - case 256: - _aesEncryptionStrength = 3; - break; - - default: - throw new ZipException("AESKeySize must be 0, 128 or 256: " + value); - } - } - } - - /// - /// AES Encryption strength for storage in extra data in entry header. - /// 1 is 128 bit, 2 is 192 bit, 3 is 256 bit. - /// - internal byte AESEncryptionStrength => (byte)_aesEncryptionStrength; - - /// - /// Returns the length of the salt, in bytes - /// - /// Key size -> Salt length: 128 bits = 8 bytes, 192 bits = 12 bytes, 256 bits = 16 bytes. - internal int AESSaltLen => AESKeySize / 16; - - /// - /// Number of extra bytes required to hold the AES Header fields (Salt, Pwd verify, AuthCode) - /// - /// File format: - /// Bytes | Content - /// ---------+--------------------------- - /// Variable | Salt value - /// 2 | Password verification value - /// Variable | Encrypted file data - /// 10 | Authentication code - internal int AESOverheadSize => 12 + AESSaltLen; - - /// - /// Number of extra bytes required to hold the encryption header fields. - /// - internal int EncryptionOverheadSize => - !IsCrypted - // Entry is not encrypted - no overhead - ? 0 - : _aesEncryptionStrength == 0 - // Entry is encrypted using ZipCrypto - ? ZipConstants.CryptoHeaderSize - // Entry is encrypted using AES - : AESOverheadSize; - - /// - /// Process extra data fields updating the entry based on the contents. - /// - /// True if the extra data fields should be handled - /// for a local header, rather than for a central header. - /// - internal void ProcessExtraData(bool localHeader) - { - var extraData = new ZipExtraData(this.extra); - - if (extraData.Find(0x0001)) - { - // Version required to extract is ignored here as some archivers dont set it correctly - // in theory it should be version 45 or higher - - // The recorded size will change but remember that this is zip64. - forceZip64_ = true; - - if (extraData.ValueLength < 4) - { - throw new ZipException("Extra data extended Zip64 information length is invalid"); - } - - // (localHeader ||) was deleted, because actually there is no specific difference with reading sizes between local header & central directory - // https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT - // ... - // 4.4 Explanation of fields - // ... - // 4.4.8 compressed size: (4 bytes) - // 4.4.9 uncompressed size: (4 bytes) - // - // The size of the file compressed (4.4.8) and uncompressed, - // (4.4.9) respectively. When a decryption header is present it - // will be placed in front of the file data and the value of the - // compressed file size will include the bytes of the decryption - // header. If bit 3 of the general purpose bit flag is set, - // these fields are set to zero in the local header and the - // correct values are put in the data descriptor and - // in the central directory. If an archive is in ZIP64 format - // and the value in this field is 0xFFFFFFFF, the size will be - // in the corresponding 8 byte ZIP64 extended information - // extra field. When encrypting the central directory, if the - // local header is not in ZIP64 format and general purpose bit - // flag 13 is set indicating masking, the value stored for the - // uncompressed size in the Local Header will be zero. - // - // Otherwise there is problem with minizip implementation - if (size == uint.MaxValue) - { - size = (ulong)extraData.ReadLong(); - } - - if (compressedSize == uint.MaxValue) - { - compressedSize = (ulong)extraData.ReadLong(); - } - - if (!localHeader && (offset == uint.MaxValue)) - { - offset = extraData.ReadLong(); - } - - // Disk number on which file starts is ignored - } - else - { - if ( - ((versionToExtract & 0xff) >= ZipConstants.VersionZip64) && - ((size == uint.MaxValue) || (compressedSize == uint.MaxValue)) - ) - { - throw new ZipException("Zip64 Extended information required but is missing."); - } - } - - DateTime = GetDateTime(extraData) ?? DateTime; - if (method == CompressionMethod.WinZipAES) - { - ProcessAESExtraData(extraData); - } - } - - private static DateTime? GetDateTime(ZipExtraData extraData) - { - // Check for NT timestamp - // NOTE: Disable by default to match behavior of InfoZIP -#if RESPECT_NT_TIMESTAMP - NTTaggedData ntData = extraData.GetData(); - if (ntData != null) - return ntData.LastModificationTime; -#endif - - // Check for Unix timestamp - ExtendedUnixData unixData = extraData.GetData(); - if (unixData != null && unixData.Include.HasFlag(ExtendedUnixData.Flags.ModificationTime)) - return unixData.ModificationTime; - - return null; - } - - // For AES the method in the entry is 99, and the real compression method is in the extradata - private void ProcessAESExtraData(ZipExtraData extraData) - { - if (extraData.Find(0x9901)) - { - // Set version for Zipfile.CreateAndInitDecryptionStream - versionToExtract = ZipConstants.VERSION_AES; // Ver 5.1 = AES see "Version" getter - - // - // Unpack AES extra data field see http://www.winzip.com/aes_info.htm - int length = extraData.ValueLength; // Data size currently 7 - if (length < 7) - throw new ZipException("AES Extra Data Length " + length + " invalid."); - int ver = extraData.ReadShort(); // Version number (1=AE-1 2=AE-2) - int vendorId = extraData.ReadShort(); // 2-character vendor ID 0x4541 = "AE" - int encrStrength = extraData.ReadByte(); // encryption strength 1 = 128 2 = 192 3 = 256 - int actualCompress = extraData.ReadShort(); // The actual compression method used to compress the file - _aesVer = ver; - _aesEncryptionStrength = encrStrength; - method = (CompressionMethod)actualCompress; - } - else - throw new ZipException("AES Extra Data missing"); - } - - /// - /// Gets/Sets the entry comment. - /// - /// - /// If comment is longer than 0xffff. - /// - /// - /// The comment or null if not set. - /// - /// - /// A comment is only available for entries when read via the class. - /// The class doesn't have the comment data available. - /// - public string Comment - { - get => comment; - set - { - // This test is strictly incorrect as the length is in characters - // while the storage limit is in bytes. - // While the test is partially correct in that a comment of this length or greater - // is definitely invalid, shorter comments may also have an invalid length - // where there are multi-byte characters - // The full test is not possible here however as the code page to apply conversions with - // isn't available. - if ((value != null) && (value.Length > 0xffff)) - { - throw new ArgumentOutOfRangeException(nameof(value), "cannot exceed 65535"); - } - - comment = value; - } - } - - /// - /// Gets a value indicating if the entry is a directory. - /// however. - /// - /// - /// A directory is determined by an entry name with a trailing slash '/'. - /// The external file attributes can also indicate an entry is for a directory. - /// Currently only dos/windows attributes are tested in this manner. - /// The trailing slash convention should always be followed. - /// - public bool IsDirectory - => name.Length > 0 - && (name[name.Length - 1] == '/' || name[name.Length - 1] == '\\') || HasDosAttributes(16); - - /// - /// Get a value of true if the entry appears to be a file; false otherwise - /// - /// - /// This only takes account of DOS/Windows attributes. Other operating systems are ignored. - /// For linux and others the result may be incorrect. - /// - public bool IsFile => !IsDirectory && !HasDosAttributes(8); - - /// - /// Test entry to see if data can be extracted. - /// - /// Returns true if data can be extracted for this entry; false otherwise. - public bool IsCompressionMethodSupported() => IsCompressionMethodSupported(CompressionMethod); - - #region ICloneable Members - - /// - /// Creates a copy of this zip entry. - /// - /// An that is a copy of the current instance. - public object Clone() - { - var result = (ZipEntry)this.MemberwiseClone(); - - // Ensure extra data is unique if it exists. - if (extra != null) - { - result.extra = new byte[extra.Length]; - Array.Copy(extra, 0, result.extra, 0, extra.Length); - } - - return result; - } - - #endregion ICloneable Members - - /// - /// Gets a string representation of this ZipEntry. - /// - /// A readable textual representation of this - public override string ToString() => name; - - /// - /// Test a compression method to see if this library - /// supports extracting data compressed with that method - /// - /// The compression method to test. - /// Returns true if the compression method is supported; false otherwise - public static bool IsCompressionMethodSupported(CompressionMethod method) - => method == CompressionMethod.Deflated - || method == CompressionMethod.Stored - || method == CompressionMethod.BZip2; - - /// - /// Cleans a name making it conform to Zip file conventions. - /// Devices names ('c:\') and UNC share names ('\\server\share') are removed - /// and forward slashes ('\') are converted to back slashes ('/'). - /// Names are made relative by trimming leading slashes which is compatible - /// with the ZIP naming convention. - /// - /// The name to clean - /// The 'cleaned' name. - /// - /// The Zip name transform class is more flexible. - /// - public static string CleanName(string name) - { - if (name == null) - { - return string.Empty; - } - - if (Path.IsPathRooted(name)) - { - // NOTE: - // for UNC names... \\machine\share\zoom\beet.txt gives \zoom\beet.txt - name = name.Substring(Path.GetPathRoot(name).Length); - } - - name = name.Replace(@"\", "/"); - - while ((name.Length > 0) && (name[0] == '/')) - { - name = name.Remove(0, 1); - } - return name; - } - - #region Instance Fields - - private Known known; - private int externalFileAttributes = -1; // contains external attributes (O/S dependant) - - private ushort versionMadeBy; // Contains host system and version information - // only relevant for central header entries - - private string name; - private ulong size; - private ulong compressedSize; - private ushort versionToExtract; // Version required to extract (library handles <= 2.0) - private uint crc; - private DateTime dateTime; - - private CompressionMethod method = CompressionMethod.Deflated; - private byte[] extra; - private string comment; - - private int flags; // general purpose bit flags - - private long zipFileIndex = -1; // used by ZipFile - private long offset; // used by ZipFile and ZipOutputStream - - private bool forceZip64_; - private byte cryptoCheckValue_; - private int _aesVer; // Version number (2 = AE-2 ?). Assigned but not used. - private int _aesEncryptionStrength; // Encryption strength 1 = 128 2 = 192 3 = 256 - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEntryExtensions.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEntryExtensions.cs deleted file mode 100644 index 1fad80f81..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEntryExtensions.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// General ZipEntry helper extensions - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public static class ZipEntryExtensions - { - /// - /// Efficiently check if a flag is set without enum un-/boxing - /// - /// - /// - /// Returns whether the flag was set - public static bool HasFlag(this ZipEntry entry, GeneralBitFlags flag) - => (entry.Flags & (int) flag) != 0; - - /// - /// Efficiently set a flag without enum un-/boxing - /// - /// - /// - /// Whether the passed flag should be set (1) or cleared (0) - public static void SetFlag(this ZipEntry entry, GeneralBitFlags flag, bool enabled = true) - => entry.Flags = enabled - ? entry.Flags | (int) flag - : entry.Flags & ~(int) flag; - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEntryFactory.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEntryFactory.cs deleted file mode 100644 index fb3ea946d..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEntryFactory.cs +++ /dev/null @@ -1,376 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Core; -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// Basic implementation of - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class ZipEntryFactory : IEntryFactory - { - #region Enumerations - - /// - /// Defines the possible values to be used for the . - /// - public enum TimeSetting - { - /// - /// Use the recorded LastWriteTime value for the file. - /// - LastWriteTime, - - /// - /// Use the recorded LastWriteTimeUtc value for the file - /// - LastWriteTimeUtc, - - /// - /// Use the recorded CreateTime value for the file. - /// - CreateTime, - - /// - /// Use the recorded CreateTimeUtc value for the file. - /// - CreateTimeUtc, - - /// - /// Use the recorded LastAccessTime value for the file. - /// - LastAccessTime, - - /// - /// Use the recorded LastAccessTimeUtc value for the file. - /// - LastAccessTimeUtc, - - /// - /// Use a fixed value. - /// - /// The actual value used can be - /// specified via the constructor or - /// using the with the setting set - /// to which will use the when this class was constructed. - /// The property can also be used to set this value. - Fixed, - } - - #endregion Enumerations - - #region Constructors - - /// - /// Initialise a new instance of the class. - /// - /// A default , and the LastWriteTime for files is used. - public ZipEntryFactory() - { - nameTransform_ = new ZipNameTransform(); - isUnicodeText_ = ZipStrings.UseUnicode; - } - - /// - /// Initialise a new instance of using the specified - /// - /// The time setting to use when creating Zip entries. - public ZipEntryFactory(TimeSetting timeSetting) : this() - { - timeSetting_ = timeSetting; - } - - /// - /// Initialise a new instance of using the specified - /// - /// The time to set all values to. - public ZipEntryFactory(DateTime time) : this() - { - timeSetting_ = TimeSetting.Fixed; - FixedDateTime = time; - } - - #endregion Constructors - - #region Properties - - /// - /// Get / set the to be used when creating new values. - /// - /// - /// Setting this property to null will cause a default name transform to be used. - /// - public INameTransform NameTransform - { - get { return nameTransform_; } - set - { - if (value == null) - { - nameTransform_ = new ZipNameTransform(); - } - else - { - nameTransform_ = value; - } - } - } - - /// - /// Get / set the in use. - /// - public TimeSetting Setting - { - get { return timeSetting_; } - set { timeSetting_ = value; } - } - - /// - /// Get / set the value to use when is set to - /// - public DateTime FixedDateTime - { - get { return fixedDateTime_; } - set - { - if (value.Year < 1970) - { - throw new ArgumentException("Value is too old to be valid", nameof(value)); - } - fixedDateTime_ = value; - } - } - - /// - /// A bitmask defining the attributes to be retrieved from the actual file. - /// - /// The default is to get all possible attributes from the actual file. - public int GetAttributes - { - get { return getAttributes_; } - set { getAttributes_ = value; } - } - - /// - /// A bitmask defining which attributes are to be set on. - /// - /// By default no attributes are set on. - public int SetAttributes - { - get { return setAttributes_; } - set { setAttributes_ = value; } - } - - /// - /// Get set a value indicating whether unidoce text should be set on. - /// - public bool IsUnicodeText - { - get { return isUnicodeText_; } - set { isUnicodeText_ = value; } - } - - #endregion Properties - - #region IEntryFactory Members - - /// - /// Make a new for a file. - /// - /// The name of the file to create a new entry for. - /// Returns a new based on the . - public ZipEntry MakeFileEntry(string fileName) - { - return MakeFileEntry(fileName, null, true); - } - - /// - /// Make a new for a file. - /// - /// The name of the file to create a new entry for. - /// If true entry detail is retrieved from the file system if the file exists. - /// Returns a new based on the . - public ZipEntry MakeFileEntry(string fileName, bool useFileSystem) - { - return MakeFileEntry(fileName, null, useFileSystem); - } - - /// - /// Make a new from a name. - /// - /// The name of the file to create a new entry for. - /// An alternative name to be used for the new entry. Null if not applicable. - /// If true entry detail is retrieved from the file system if the file exists. - /// Returns a new based on the . - public ZipEntry MakeFileEntry(string fileName, string entryName, bool useFileSystem) - { - var result = new ZipEntry(nameTransform_.TransformFile(!string.IsNullOrEmpty(entryName) ? entryName : fileName)); - result.IsUnicodeText = isUnicodeText_; - - int externalAttributes = 0; - bool useAttributes = (setAttributes_ != 0); - - FileInfo fi = null; - if (useFileSystem) - { - fi = new FileInfo(fileName); - } - - if ((fi != null) && fi.Exists) - { - switch (timeSetting_) - { - case TimeSetting.CreateTime: - result.DateTime = fi.CreationTime; - break; - - case TimeSetting.CreateTimeUtc: - result.DateTime = fi.CreationTimeUtc; - break; - - case TimeSetting.LastAccessTime: - result.DateTime = fi.LastAccessTime; - break; - - case TimeSetting.LastAccessTimeUtc: - result.DateTime = fi.LastAccessTimeUtc; - break; - - case TimeSetting.LastWriteTime: - result.DateTime = fi.LastWriteTime; - break; - - case TimeSetting.LastWriteTimeUtc: - result.DateTime = fi.LastWriteTimeUtc; - break; - - case TimeSetting.Fixed: - result.DateTime = fixedDateTime_; - break; - - default: - throw new ZipException("Unhandled time setting in MakeFileEntry"); - } - - result.Size = fi.Length; - - useAttributes = true; - externalAttributes = ((int)fi.Attributes & getAttributes_); - } - else - { - if (timeSetting_ == TimeSetting.Fixed) - { - result.DateTime = fixedDateTime_; - } - } - - if (useAttributes) - { - externalAttributes |= setAttributes_; - result.ExternalFileAttributes = externalAttributes; - } - - return result; - } - - /// - /// Make a new for a directory. - /// - /// The raw untransformed name for the new directory - /// Returns a new representing a directory. - public ZipEntry MakeDirectoryEntry(string directoryName) - { - return MakeDirectoryEntry(directoryName, true); - } - - /// - /// Make a new for a directory. - /// - /// The raw untransformed name for the new directory - /// If true entry detail is retrieved from the file system if the file exists. - /// Returns a new representing a directory. - public ZipEntry MakeDirectoryEntry(string directoryName, bool useFileSystem) - { - var result = new ZipEntry(nameTransform_.TransformDirectory(directoryName)); - result.IsUnicodeText = isUnicodeText_; - result.Size = 0; - - int externalAttributes = 0; - - DirectoryInfo di = null; - - if (useFileSystem) - { - di = new DirectoryInfo(directoryName); - } - - if ((di != null) && di.Exists) - { - switch (timeSetting_) - { - case TimeSetting.CreateTime: - result.DateTime = di.CreationTime; - break; - - case TimeSetting.CreateTimeUtc: - result.DateTime = di.CreationTimeUtc; - break; - - case TimeSetting.LastAccessTime: - result.DateTime = di.LastAccessTime; - break; - - case TimeSetting.LastAccessTimeUtc: - result.DateTime = di.LastAccessTimeUtc; - break; - - case TimeSetting.LastWriteTime: - result.DateTime = di.LastWriteTime; - break; - - case TimeSetting.LastWriteTimeUtc: - result.DateTime = di.LastWriteTimeUtc; - break; - - case TimeSetting.Fixed: - result.DateTime = fixedDateTime_; - break; - - default: - throw new ZipException("Unhandled time setting in MakeDirectoryEntry"); - } - - externalAttributes = ((int)di.Attributes & getAttributes_); - } - else - { - if (timeSetting_ == TimeSetting.Fixed) - { - result.DateTime = fixedDateTime_; - } - } - - // Always set directory attribute on. - externalAttributes |= (setAttributes_ | 16); - result.ExternalFileAttributes = externalAttributes; - - return result; - } - - #endregion IEntryFactory Members - - #region Instance Fields - - private INameTransform nameTransform_; - private DateTime fixedDateTime_ = DateTime.Now; - private TimeSetting timeSetting_ = TimeSetting.LastWriteTime; - private bool isUnicodeText_; - - private int getAttributes_ = -1; - private int setAttributes_; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipException.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipException.cs deleted file mode 100644 index 25ff7b7bc..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipException.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// ZipException represents exceptions specific to Zip classes and code. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - [Serializable] - public class ZipException : SharpZipBaseException - { - /// - /// Initialise a new instance of . - /// - public ZipException() - { - } - - /// - /// Initialise a new instance of with its message string. - /// - /// A that describes the error. - public ZipException(string message) - : base(message) - { - } - - /// - /// Initialise a new instance of . - /// - /// A that describes the error. - /// The that caused this exception. - public ZipException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Initializes a new instance of the ZipException class with serialized data. - /// - /// - /// The System.Runtime.Serialization.SerializationInfo that holds the serialized - /// object data about the exception being thrown. - /// - /// - /// The System.Runtime.Serialization.StreamingContext that contains contextual information - /// about the source or destination. - /// - protected ZipException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipExtraData.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipExtraData.cs deleted file mode 100644 index d81a02c0f..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipExtraData.cs +++ /dev/null @@ -1,986 +0,0 @@ -using System; -using System.IO; -using MelonLoader.ICSharpCode.SharpZipLib.Core; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - // TODO: Sort out whether tagged data is useful and what a good implementation might look like. - // Its just a sketch of an idea at the moment. - - /// - /// ExtraData tagged value interface. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public interface ITaggedData - { - /// - /// Get the ID for this tagged data value. - /// - short TagID { get; } - - /// - /// Set the contents of this instance from the data passed. - /// - /// The data to extract contents from. - /// The offset to begin extracting data from. - /// The number of bytes to extract. - void SetData(byte[] data, int offset, int count); - - /// - /// Get the data representing this instance. - /// - /// Returns the data for this instance. - byte[] GetData(); - } - - /// - /// A raw binary tagged value - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class RawTaggedData : ITaggedData - { - /// - /// Initialise a new instance. - /// - /// The tag ID. - public RawTaggedData(short tag) - { - _tag = tag; - } - - #region ITaggedData Members - - /// - /// Get the ID for this tagged data value. - /// - public short TagID - { - get { return _tag; } - set { _tag = value; } - } - - /// - /// Set the data from the raw values provided. - /// - /// The raw data to extract values from. - /// The index to start extracting values from. - /// The number of bytes available. - public void SetData(byte[] data, int offset, int count) - { - if (data == null) - { - throw new ArgumentNullException(nameof(data)); - } - - _data = new byte[count]; - Array.Copy(data, offset, _data, 0, count); - } - - /// - /// Get the binary data representing this instance. - /// - /// The raw binary data representing this instance. - public byte[] GetData() - { - return _data; - } - - #endregion ITaggedData Members - - /// - /// Get /set the binary data representing this instance. - /// - /// The raw binary data representing this instance. - public byte[] Data - { - get { return _data; } - set { _data = value; } - } - - #region Instance Fields - - /// - /// The tag ID for this instance. - /// - private short _tag; - - private byte[] _data; - - #endregion Instance Fields - } - - /// - /// Class representing extended unix date time values. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class ExtendedUnixData : ITaggedData - { - /// - /// Flags indicate which values are included in this instance. - /// - [Flags] - public enum Flags : byte - { - /// - /// The modification time is included - /// - ModificationTime = 0x01, - - /// - /// The access time is included - /// - AccessTime = 0x02, - - /// - /// The create time is included. - /// - CreateTime = 0x04, - } - - #region ITaggedData Members - - /// - /// Get the ID - /// - public short TagID - { - get { return 0x5455; } - } - - /// - /// Set the data from the raw values provided. - /// - /// The raw data to extract values from. - /// The index to start extracting values from. - /// The number of bytes available. - public void SetData(byte[] data, int index, int count) - { - using (MemoryStream ms = new MemoryStream(data, index, count, false)) - using (ZipHelperStream helperStream = new ZipHelperStream(ms)) - { - // bit 0 if set, modification time is present - // bit 1 if set, access time is present - // bit 2 if set, creation time is present - - _flags = (Flags)helperStream.ReadByte(); - if (((_flags & Flags.ModificationTime) != 0)) - { - int iTime = helperStream.ReadLEInt(); - - _modificationTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc) + - new TimeSpan(0, 0, 0, iTime, 0); - - // Central-header version is truncated after modification time - if (count <= 5) return; - } - - if ((_flags & Flags.AccessTime) != 0) - { - int iTime = helperStream.ReadLEInt(); - - _lastAccessTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc) + - new TimeSpan(0, 0, 0, iTime, 0); - } - - if ((_flags & Flags.CreateTime) != 0) - { - int iTime = helperStream.ReadLEInt(); - - _createTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc) + - new TimeSpan(0, 0, 0, iTime, 0); - } - } - } - - /// - /// Get the binary data representing this instance. - /// - /// The raw binary data representing this instance. - public byte[] GetData() - { - using (MemoryStream ms = new MemoryStream()) - using (ZipHelperStream helperStream = new ZipHelperStream(ms)) - { - helperStream.IsStreamOwner = false; - helperStream.WriteByte((byte)_flags); // Flags - if ((_flags & Flags.ModificationTime) != 0) - { - TimeSpan span = _modificationTime - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); - var seconds = (int)span.TotalSeconds; - helperStream.WriteLEInt(seconds); - } - if ((_flags & Flags.AccessTime) != 0) - { - TimeSpan span = _lastAccessTime - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); - var seconds = (int)span.TotalSeconds; - helperStream.WriteLEInt(seconds); - } - if ((_flags & Flags.CreateTime) != 0) - { - TimeSpan span = _createTime - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); - var seconds = (int)span.TotalSeconds; - helperStream.WriteLEInt(seconds); - } - return ms.ToArray(); - } - } - - #endregion ITaggedData Members - - /// - /// Test a value to see if is valid and can be represented here. - /// - /// The value to test. - /// Returns true if the value is valid and can be represented; false if not. - /// The standard Unix time is a signed integer data type, directly encoding the Unix time number, - /// which is the number of seconds since 1970-01-01. - /// Being 32 bits means the values here cover a range of about 136 years. - /// The minimum representable time is 1901-12-13 20:45:52, - /// and the maximum representable time is 2038-01-19 03:14:07. - /// - public static bool IsValidValue(DateTime value) - { - return ((value >= new DateTime(1901, 12, 13, 20, 45, 52)) || - (value <= new DateTime(2038, 1, 19, 03, 14, 07))); - } - - /// - /// Get /set the Modification Time - /// - /// - /// - public DateTime ModificationTime - { - get { return _modificationTime; } - set - { - if (!IsValidValue(value)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - _flags |= Flags.ModificationTime; - _modificationTime = value; - } - } - - /// - /// Get / set the Access Time - /// - /// - /// - public DateTime AccessTime - { - get { return _lastAccessTime; } - set - { - if (!IsValidValue(value)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - _flags |= Flags.AccessTime; - _lastAccessTime = value; - } - } - - /// - /// Get / Set the Create Time - /// - /// - /// - public DateTime CreateTime - { - get { return _createTime; } - set - { - if (!IsValidValue(value)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - _flags |= Flags.CreateTime; - _createTime = value; - } - } - - /// - /// Get/set the values to include. - /// - public Flags Include - { - get { return _flags; } - set { _flags = value; } - } - - #region Instance Fields - - private Flags _flags; - private DateTime _modificationTime = new DateTime(1970, 1, 1); - private DateTime _lastAccessTime = new DateTime(1970, 1, 1); - private DateTime _createTime = new DateTime(1970, 1, 1); - - #endregion Instance Fields - } - - /// - /// Class handling NT date time values. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class NTTaggedData : ITaggedData - { - /// - /// Get the ID for this tagged data value. - /// - public short TagID - { - get { return 10; } - } - - /// - /// Set the data from the raw values provided. - /// - /// The raw data to extract values from. - /// The index to start extracting values from. - /// The number of bytes available. - public void SetData(byte[] data, int index, int count) - { - using (MemoryStream ms = new MemoryStream(data, index, count, false)) - using (ZipHelperStream helperStream = new ZipHelperStream(ms)) - { - helperStream.ReadLEInt(); // Reserved - while (helperStream.Position < helperStream.Length) - { - int ntfsTag = helperStream.ReadLEShort(); - int ntfsLength = helperStream.ReadLEShort(); - if (ntfsTag == 1) - { - if (ntfsLength >= 24) - { - long lastModificationTicks = helperStream.ReadLELong(); - _lastModificationTime = DateTime.FromFileTimeUtc(lastModificationTicks); - - long lastAccessTicks = helperStream.ReadLELong(); - _lastAccessTime = DateTime.FromFileTimeUtc(lastAccessTicks); - - long createTimeTicks = helperStream.ReadLELong(); - _createTime = DateTime.FromFileTimeUtc(createTimeTicks); - } - break; - } - else - { - // An unknown NTFS tag so simply skip it. - helperStream.Seek(ntfsLength, SeekOrigin.Current); - } - } - } - } - - /// - /// Get the binary data representing this instance. - /// - /// The raw binary data representing this instance. - public byte[] GetData() - { - using (MemoryStream ms = new MemoryStream()) - using (ZipHelperStream helperStream = new ZipHelperStream(ms)) - { - helperStream.IsStreamOwner = false; - helperStream.WriteLEInt(0); // Reserved - helperStream.WriteLEShort(1); // Tag - helperStream.WriteLEShort(24); // Length = 3 x 8. - helperStream.WriteLELong(_lastModificationTime.ToFileTimeUtc()); - helperStream.WriteLELong(_lastAccessTime.ToFileTimeUtc()); - helperStream.WriteLELong(_createTime.ToFileTimeUtc()); - return ms.ToArray(); - } - } - - /// - /// Test a valuie to see if is valid and can be represented here. - /// - /// The value to test. - /// Returns true if the value is valid and can be represented; false if not. - /// - /// NTFS filetimes are 64-bit unsigned integers, stored in Intel - /// (least significant byte first) byte order. They determine the - /// number of 1.0E-07 seconds (1/10th microseconds!) past WinNT "epoch", - /// which is "01-Jan-1601 00:00:00 UTC". 28 May 60056 is the upper limit - /// - public static bool IsValidValue(DateTime value) - { - bool result = true; - try - { - value.ToFileTimeUtc(); - } - catch - { - result = false; - } - return result; - } - - /// - /// Get/set the last modification time. - /// - public DateTime LastModificationTime - { - get { return _lastModificationTime; } - set - { - if (!IsValidValue(value)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - _lastModificationTime = value; - } - } - - /// - /// Get /set the create time - /// - public DateTime CreateTime - { - get { return _createTime; } - set - { - if (!IsValidValue(value)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - _createTime = value; - } - } - - /// - /// Get /set the last access time. - /// - public DateTime LastAccessTime - { - get { return _lastAccessTime; } - set - { - if (!IsValidValue(value)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - _lastAccessTime = value; - } - } - - #region Instance Fields - - private DateTime _lastAccessTime = DateTime.FromFileTimeUtc(0); - private DateTime _lastModificationTime = DateTime.FromFileTimeUtc(0); - private DateTime _createTime = DateTime.FromFileTimeUtc(0); - - #endregion Instance Fields - } - - /// - /// A factory that creates tagged data instances. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal interface ITaggedDataFactory - { - /// - /// Get data for a specific tag value. - /// - /// The tag ID to find. - /// The data to search. - /// The offset to begin extracting data from. - /// The number of bytes to extract. - /// The located value found, or null if not found. - ITaggedData Create(short tag, byte[] data, int offset, int count); - } - - /// - /// - /// A class to handle the extra data field for Zip entries - /// - /// - /// Extra data contains 0 or more values each prefixed by a header tag and length. - /// They contain zero or more bytes of actual data. - /// The data is held internally using a copy on write strategy. This is more efficient but - /// means that for extra data created by passing in data can have the values modified by the caller - /// in some circumstances. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - sealed public class ZipExtraData : IDisposable - { - #region Constructors - - /// - /// Initialise a default instance. - /// - public ZipExtraData() - { - Clear(); - } - - /// - /// Initialise with known extra data. - /// - /// The extra data. - public ZipExtraData(byte[] data) - { - if (data == null) - { - _data = Empty.Array(); - } - else - { - _data = data; - } - } - - #endregion Constructors - - /// - /// Get the raw extra data value - /// - /// Returns the raw byte[] extra data this instance represents. - public byte[] GetEntryData() - { - if (Length > ushort.MaxValue) - { - throw new ZipException("Data exceeds maximum length"); - } - - return (byte[])_data.Clone(); - } - - /// - /// Clear the stored data. - /// - public void Clear() - { - if ((_data == null) || (_data.Length != 0)) - { - _data = Empty.Array(); - } - } - - /// - /// Gets the current extra data length. - /// - public int Length - { - get { return _data.Length; } - } - - /// - /// Get a read-only for the associated tag. - /// - /// The tag to locate data for. - /// Returns a containing tag data or null if no tag was found. - public Stream GetStreamForTag(int tag) - { - Stream result = null; - if (Find(tag)) - { - result = new MemoryStream(_data, _index, _readValueLength, false); - } - return result; - } - - /// - /// Get the tagged data for a tag. - /// - /// The tag to search for. - /// Returns a tagged value or null if none found. - public T GetData() - where T : class, ITaggedData, new() - { - T result = new T(); - if (Find(result.TagID)) - { - result.SetData(_data, _readValueStart, _readValueLength); - return result; - } - else return null; - } - - /// - /// Get the length of the last value found by - /// - /// This is only valid if has previously returned true. - public int ValueLength - { - get { return _readValueLength; } - } - - /// - /// Get the index for the current read value. - /// - /// This is only valid if has previously returned true. - /// Initially the result will be the index of the first byte of actual data. The value is updated after calls to - /// , and . - public int CurrentReadIndex - { - get { return _index; } - } - - /// - /// Get the number of bytes remaining to be read for the current value; - /// - public int UnreadCount - { - get - { - if ((_readValueStart > _data.Length) || - (_readValueStart < 4)) - { - throw new ZipException("Find must be called before calling a Read method"); - } - - return _readValueStart + _readValueLength - _index; - } - } - - /// - /// Find an extra data value - /// - /// The identifier for the value to find. - /// Returns true if the value was found; false otherwise. - public bool Find(int headerID) - { - _readValueStart = _data.Length; - _readValueLength = 0; - _index = 0; - - int localLength = _readValueStart; - int localTag = headerID - 1; - - // Trailing bytes that cant make up an entry (as there arent enough - // bytes for a tag and length) are ignored! - while ((localTag != headerID) && (_index < _data.Length - 3)) - { - localTag = ReadShortInternal(); - localLength = ReadShortInternal(); - if (localTag != headerID) - { - _index += localLength; - } - } - - bool result = (localTag == headerID) && ((_index + localLength) <= _data.Length); - - if (result) - { - _readValueStart = _index; - _readValueLength = localLength; - } - - return result; - } - - /// - /// Add a new entry to extra data. - /// - /// The value to add. - public void AddEntry(ITaggedData taggedData) - { - if (taggedData == null) - { - throw new ArgumentNullException(nameof(taggedData)); - } - AddEntry(taggedData.TagID, taggedData.GetData()); - } - - /// - /// Add a new entry to extra data - /// - /// The ID for this entry. - /// The data to add. - /// If the ID already exists its contents are replaced. - public void AddEntry(int headerID, byte[] fieldData) - { - if ((headerID > ushort.MaxValue) || (headerID < 0)) - { - throw new ArgumentOutOfRangeException(nameof(headerID)); - } - - int addLength = (fieldData == null) ? 0 : fieldData.Length; - - if (addLength > ushort.MaxValue) - { - throw new ArgumentOutOfRangeException(nameof(fieldData), "exceeds maximum length"); - } - - // Test for new length before adjusting data. - int newLength = _data.Length + addLength + 4; - - if (Find(headerID)) - { - newLength -= (ValueLength + 4); - } - - if (newLength > ushort.MaxValue) - { - throw new ZipException("Data exceeds maximum length"); - } - - Delete(headerID); - - byte[] newData = new byte[newLength]; - _data.CopyTo(newData, 0); - int index = _data.Length; - _data = newData; - SetShort(ref index, headerID); - SetShort(ref index, addLength); - if (fieldData != null) - { - fieldData.CopyTo(newData, index); - } - } - - /// - /// Start adding a new entry. - /// - /// Add data using , , , or . - /// The new entry is completed and actually added by calling - /// - public void StartNewEntry() - { - _newEntry = new MemoryStream(); - } - - /// - /// Add entry data added since using the ID passed. - /// - /// The identifier to use for this entry. - public void AddNewEntry(int headerID) - { - byte[] newData = _newEntry.ToArray(); - _newEntry = null; - AddEntry(headerID, newData); - } - - /// - /// Add a byte of data to the pending new entry. - /// - /// The byte to add. - /// - public void AddData(byte data) - { - _newEntry.WriteByte(data); - } - - /// - /// Add data to a pending new entry. - /// - /// The data to add. - /// - public void AddData(byte[] data) - { - if (data == null) - { - throw new ArgumentNullException(nameof(data)); - } - - _newEntry.Write(data, 0, data.Length); - } - - /// - /// Add a short value in little endian order to the pending new entry. - /// - /// The data to add. - /// - public void AddLeShort(int toAdd) - { - unchecked - { - _newEntry.WriteByte((byte)toAdd); - _newEntry.WriteByte((byte)(toAdd >> 8)); - } - } - - /// - /// Add an integer value in little endian order to the pending new entry. - /// - /// The data to add. - /// - public void AddLeInt(int toAdd) - { - unchecked - { - AddLeShort((short)toAdd); - AddLeShort((short)(toAdd >> 16)); - } - } - - /// - /// Add a long value in little endian order to the pending new entry. - /// - /// The data to add. - /// - public void AddLeLong(long toAdd) - { - unchecked - { - AddLeInt((int)(toAdd & 0xffffffff)); - AddLeInt((int)(toAdd >> 32)); - } - } - - /// - /// Delete an extra data field. - /// - /// The identifier of the field to delete. - /// Returns true if the field was found and deleted. - public bool Delete(int headerID) - { - bool result = false; - - if (Find(headerID)) - { - result = true; - int trueStart = _readValueStart - 4; - - byte[] newData = new byte[_data.Length - (ValueLength + 4)]; - Array.Copy(_data, 0, newData, 0, trueStart); - - int trueEnd = trueStart + ValueLength + 4; - Array.Copy(_data, trueEnd, newData, trueStart, _data.Length - trueEnd); - _data = newData; - } - return result; - } - - #region Reading Support - - /// - /// Read a long in little endian form from the last found data value - /// - /// Returns the long value read. - public long ReadLong() - { - ReadCheck(8); - return (ReadInt() & 0xffffffff) | (((long)ReadInt()) << 32); - } - - /// - /// Read an integer in little endian form from the last found data value. - /// - /// Returns the integer read. - public int ReadInt() - { - ReadCheck(4); - - int result = _data[_index] + (_data[_index + 1] << 8) + - (_data[_index + 2] << 16) + (_data[_index + 3] << 24); - _index += 4; - return result; - } - - /// - /// Read a short value in little endian form from the last found data value. - /// - /// Returns the short value read. - public int ReadShort() - { - ReadCheck(2); - int result = _data[_index] + (_data[_index + 1] << 8); - _index += 2; - return result; - } - - /// - /// Read a byte from an extra data - /// - /// The byte value read or -1 if the end of data has been reached. - public int ReadByte() - { - int result = -1; - if ((_index < _data.Length) && (_readValueStart + _readValueLength > _index)) - { - result = _data[_index]; - _index += 1; - } - return result; - } - - /// - /// Skip data during reading. - /// - /// The number of bytes to skip. - public void Skip(int amount) - { - ReadCheck(amount); - _index += amount; - } - - private void ReadCheck(int length) - { - if ((_readValueStart > _data.Length) || - (_readValueStart < 4)) - { - throw new ZipException("Find must be called before calling a Read method"); - } - - if (_index > _readValueStart + _readValueLength - length) - { - throw new ZipException("End of extra data"); - } - - if (_index + length < 4) - { - throw new ZipException("Cannot read before start of tag"); - } - } - - /// - /// Internal form of that reads data at any location. - /// - /// Returns the short value read. - private int ReadShortInternal() - { - if (_index > _data.Length - 2) - { - throw new ZipException("End of extra data"); - } - - int result = _data[_index] + (_data[_index + 1] << 8); - _index += 2; - return result; - } - - private void SetShort(ref int index, int source) - { - _data[index] = (byte)source; - _data[index + 1] = (byte)(source >> 8); - index += 2; - } - - #endregion Reading Support - - #region IDisposable Members - - /// - /// Dispose of this instance. - /// - public void Dispose() - { - if (_newEntry != null) - { - _newEntry.Dispose(); - } - } - - #endregion IDisposable Members - - #region Instance Fields - - private int _index; - private int _readValueStart; - private int _readValueLength; - - private MemoryStream _newEntry; - private byte[] _data; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipFile.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipFile.cs deleted file mode 100644 index 1a3a617a7..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipFile.cs +++ /dev/null @@ -1,4926 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Checksum; -using MelonLoader.ICSharpCode.SharpZipLib.Core; -using MelonLoader.ICSharpCode.SharpZipLib.Encryption; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams; -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Security.Cryptography; -using System.Text; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - #region Keys Required Event Args - - /// - /// Arguments used with KeysRequiredEvent - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class KeysRequiredEventArgs : EventArgs - { - #region Constructors - - /// - /// Initialise a new instance of - /// - /// The name of the file for which keys are required. - public KeysRequiredEventArgs(string name) - { - fileName = name; - } - - /// - /// Initialise a new instance of - /// - /// The name of the file for which keys are required. - /// The current key value. - public KeysRequiredEventArgs(string name, byte[] keyValue) - { - fileName = name; - key = keyValue; - } - - #endregion Constructors - - #region Properties - - /// - /// Gets the name of the file for which keys are required. - /// - public string FileName - { - get { return fileName; } - } - - /// - /// Gets or sets the key value - /// - public byte[] Key - { - get { return key; } - set { key = value; } - } - - #endregion Properties - - #region Instance Fields - - private readonly string fileName; - private byte[] key; - - #endregion Instance Fields - } - - #endregion Keys Required Event Args - - #region Test Definitions - - /// - /// The strategy to apply to testing. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public enum TestStrategy - { - /// - /// Find the first error only. - /// - FindFirstError, - - /// - /// Find all possible errors. - /// - FindAllErrors, - } - - /// - /// The operation in progress reported by a during testing. - /// - /// TestArchive - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public enum TestOperation - { - /// - /// Setting up testing. - /// - Initialising, - - /// - /// Testing an individual entries header - /// - EntryHeader, - - /// - /// Testing an individual entries data - /// - EntryData, - - /// - /// Testing an individual entry has completed. - /// - EntryComplete, - - /// - /// Running miscellaneous tests - /// - MiscellaneousTests, - - /// - /// Testing is complete - /// - Complete, - } - - /// - /// Status returned by during testing. - /// - /// TestArchive - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class TestStatus - { - #region Constructors - - /// - /// Initialise a new instance of - /// - /// The this status applies to. - public TestStatus(ZipFile file) - { - file_ = file; - } - - #endregion Constructors - - #region Properties - - /// - /// Get the current in progress. - /// - public TestOperation Operation - { - get { return operation_; } - } - - /// - /// Get the this status is applicable to. - /// - public ZipFile File - { - get { return file_; } - } - - /// - /// Get the current/last entry tested. - /// - public ZipEntry Entry - { - get { return entry_; } - } - - /// - /// Get the number of errors detected so far. - /// - public int ErrorCount - { - get { return errorCount_; } - } - - /// - /// Get the number of bytes tested so far for the current entry. - /// - public long BytesTested - { - get { return bytesTested_; } - } - - /// - /// Get a value indicating whether the last entry test was valid. - /// - public bool EntryValid - { - get { return entryValid_; } - } - - #endregion Properties - - #region Internal API - - internal void AddError() - { - errorCount_++; - entryValid_ = false; - } - - internal void SetOperation(TestOperation operation) - { - operation_ = operation; - } - - internal void SetEntry(ZipEntry entry) - { - entry_ = entry; - entryValid_ = true; - bytesTested_ = 0; - } - - internal void SetBytesTested(long value) - { - bytesTested_ = value; - } - - #endregion Internal API - - #region Instance Fields - - private readonly ZipFile file_; - private ZipEntry entry_; - private bool entryValid_; - private int errorCount_; - private long bytesTested_; - private TestOperation operation_; - - #endregion Instance Fields - } - - /// - /// Delegate invoked during testing if supplied indicating current progress and status. - /// - /// If the message is non-null an error has occured. If the message is null - /// the operation as found in status has started. - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public delegate void ZipTestResultHandler(TestStatus status, string message); - - #endregion Test Definitions - - #region Update Definitions - - /// - /// The possible ways of applying updates to an archive. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public enum FileUpdateMode - { - /// - /// Perform all updates on temporary files ensuring that the original file is saved. - /// - Safe, - - /// - /// Update the archive directly, which is faster but less safe. - /// - Direct, - } - - #endregion Update Definitions - - #region ZipFile Class - - /// - /// This class represents a Zip archive. You can ask for the contained - /// entries, or get an input stream for a file entry. The entry is - /// automatically decompressed. - /// - /// You can also update the archive adding or deleting entries. - /// - /// This class is thread safe for input: You can open input streams for arbitrary - /// entries in different threads. - ///
- ///
Author of the original java version : Jochen Hoenicke - ///
- /// - /// - /// using System; - /// using System.Text; - /// using System.Collections; - /// using System.IO; - /// - /// using MelonLoader.ICSharpCode.SharpZipLib.Zip; - /// - /// class MainClass - /// { - /// static public void Main(string[] args) - /// { - /// using (ZipFile zFile = new ZipFile(args[0])) { - /// Console.WriteLine("Listing of : " + zFile.Name); - /// Console.WriteLine(""); - /// Console.WriteLine("Raw Size Size Date Time Name"); - /// Console.WriteLine("-------- -------- -------- ------ ---------"); - /// foreach (ZipEntry e in zFile) { - /// if ( e.IsFile ) { - /// DateTime d = e.DateTime; - /// Console.WriteLine("{0, -10}{1, -10}{2} {3} {4}", e.Size, e.CompressedSize, - /// d.ToString("dd-MM-yy"), d.ToString("HH:mm"), - /// e.Name); - /// } - /// } - /// } - /// } - /// } - /// - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class ZipFile : IEnumerable, IDisposable - { - #region KeyHandling - - /// - /// Delegate for handling keys/password setting during compression/decompression. - /// - public delegate void KeysRequiredEventHandler( - object sender, - KeysRequiredEventArgs e - ); - - /// - /// Event handler for handling encryption keys. - /// - public KeysRequiredEventHandler KeysRequired; - - /// - /// Handles getting of encryption keys when required. - /// - /// The file for which encryption keys are required. - private void OnKeysRequired(string fileName) - { - if (KeysRequired != null) - { - var krea = new KeysRequiredEventArgs(fileName, key); - KeysRequired(this, krea); - key = krea.Key; - } - } - - /// - /// Get/set the encryption key value. - /// - private byte[] Key - { - get { return key; } - set { key = value; } - } - - /// - /// Password to be used for encrypting/decrypting files. - /// - /// Set to null if no password is required. - public string Password - { - set - { - if (string.IsNullOrEmpty(value)) - { - key = null; - } - else - { - key = PkzipClassic.GenerateKeys(ZipStrings.ConvertToArray(value)); - } - - rawPassword_ = value; - } - } - - /// - /// Get a value indicating whether encryption keys are currently available. - /// - private bool HaveKeys - { - get { return key != null; } - } - - #endregion KeyHandling - - #region Constructors - - /// - /// Opens a Zip file with the given name for reading. - /// - /// The name of the file to open. - /// The argument supplied is null. - /// - /// An i/o error occurs - /// - /// - /// The file doesn't contain a valid zip archive. - /// - public ZipFile(string name) - { - name_ = name ?? throw new ArgumentNullException(nameof(name)); - - baseStream_ = File.Open(name, FileMode.Open, FileAccess.Read, FileShare.Read); - isStreamOwner = true; - - try - { - ReadEntries(); - } - catch - { - DisposeInternal(true); - throw; - } - } - - /// - /// Opens a Zip file reading the given . - /// - /// The to read archive data from. - /// The supplied argument is null. - /// - /// An i/o error occurs. - /// - /// - /// The file doesn't contain a valid zip archive. - /// - public ZipFile(FileStream file) : - this(file, false) - { - - } - - /// - /// Opens a Zip file reading the given . - /// - /// The to read archive data from. - /// true to leave the file open when the ZipFile is disposed, false to dispose of it - /// The supplied argument is null. - /// - /// An i/o error occurs. - /// - /// - /// The file doesn't contain a valid zip archive. - /// - public ZipFile(FileStream file, bool leaveOpen) - { - if (file == null) - { - throw new ArgumentNullException(nameof(file)); - } - - if (!file.CanSeek) - { - throw new ArgumentException("Stream is not seekable", nameof(file)); - } - - baseStream_ = file; - name_ = file.Name; - isStreamOwner = !leaveOpen; - - try - { - ReadEntries(); - } - catch - { - DisposeInternal(true); - throw; - } - } - - /// - /// Opens a Zip file reading the given . - /// - /// The to read archive data from. - /// - /// An i/o error occurs - /// - /// - /// The stream doesn't contain a valid zip archive.
- ///
- /// - /// The stream doesnt support seeking. - /// - /// - /// The stream argument is null. - /// - public ZipFile(Stream stream) : - this(stream, false) - { - - } - - /// - /// Opens a Zip file reading the given . - /// - /// The to read archive data from. - /// true to leave the stream open when the ZipFile is disposed, false to dispose of it - /// - /// An i/o error occurs - /// - /// - /// The stream doesn't contain a valid zip archive.
- ///
- /// - /// The stream doesnt support seeking. - /// - /// - /// The stream argument is null. - /// - public ZipFile(Stream stream, bool leaveOpen) - { - if (stream == null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanSeek) - { - throw new ArgumentException("Stream is not seekable", nameof(stream)); - } - - baseStream_ = stream; - isStreamOwner = !leaveOpen; - - if (baseStream_.Length > 0) - { - try - { - ReadEntries(); - } - catch - { - DisposeInternal(true); - throw; - } - } - else - { - entries_ = Empty.Array(); - isNewArchive_ = true; - } - } - - /// - /// Initialises a default instance with no entries and no file storage. - /// - internal ZipFile() - { - entries_ = Empty.Array(); - isNewArchive_ = true; - } - - #endregion Constructors - - #region Destructors and Closing - - /// - /// Finalize this instance. - /// - ~ZipFile() - { - Dispose(false); - } - - /// - /// Closes the ZipFile. If the stream is owned then this also closes the underlying input stream. - /// Once closed, no further instance methods should be called. - /// - /// - /// An i/o error occurs. - /// - public void Close() - { - DisposeInternal(true); - GC.SuppressFinalize(this); - } - - #endregion Destructors and Closing - - #region Creators - - /// - /// Create a new whose data will be stored in a file. - /// - /// The name of the archive to create. - /// Returns the newly created - /// is null - public static ZipFile Create(string fileName) - { - if (fileName == null) - { - throw new ArgumentNullException(nameof(fileName)); - } - - FileStream fs = File.Create(fileName); - - return new ZipFile - { - name_ = fileName, - baseStream_ = fs, - isStreamOwner = true - }; - } - - /// - /// Create a new whose data will be stored on a stream. - /// - /// The stream providing data storage. - /// Returns the newly created - /// is null - /// doesnt support writing. - public static ZipFile Create(Stream outStream) - { - if (outStream == null) - { - throw new ArgumentNullException(nameof(outStream)); - } - - if (!outStream.CanWrite) - { - throw new ArgumentException("Stream is not writeable", nameof(outStream)); - } - - if (!outStream.CanSeek) - { - throw new ArgumentException("Stream is not seekable", nameof(outStream)); - } - - var result = new ZipFile - { - baseStream_ = outStream - }; - return result; - } - - #endregion Creators - - #region Properties - - /// - /// Get/set a flag indicating if the underlying stream is owned by the ZipFile instance. - /// If the flag is true then the stream will be closed when Close is called. - /// - /// - /// The default value is true in all cases. - /// - public bool IsStreamOwner - { - get { return isStreamOwner; } - set { isStreamOwner = value; } - } - - /// - /// Get a value indicating whether - /// this archive is embedded in another file or not. - /// - public bool IsEmbeddedArchive - { - // Not strictly correct in all circumstances currently - get { return offsetOfFirstEntry > 0; } - } - - /// - /// Get a value indicating that this archive is a new one. - /// - public bool IsNewArchive - { - get { return isNewArchive_; } - } - - /// - /// Gets the comment for the zip file. - /// - public string ZipFileComment - { - get { return comment_; } - } - - /// - /// Gets the name of this zip file. - /// - public string Name - { - get { return name_; } - } - - /// - /// Gets the number of entries in this zip file. - /// - /// - /// The Zip file has been closed. - /// - [Obsolete("Use the Count property instead")] - public int Size - { - get - { - return entries_.Length; - } - } - - /// - /// Get the number of entries contained in this . - /// - public long Count - { - get - { - return entries_.Length; - } - } - - /// - /// Indexer property for ZipEntries - /// - [System.Runtime.CompilerServices.IndexerNameAttribute("EntryByIndex")] - public ZipEntry this[int index] - { - get - { - return (ZipEntry)entries_[index].Clone(); - } - } - - #endregion Properties - - #region Input Handling - - /// - /// Gets an enumerator for the Zip entries in this Zip file. - /// - /// Returns an for this archive. - /// - /// The Zip file has been closed. - /// - public IEnumerator GetEnumerator() - { - if (isDisposed_) - { - throw new ObjectDisposedException("ZipFile"); - } - - return new ZipEntryEnumerator(entries_); - } - - /// - /// Return the index of the entry with a matching name - /// - /// Entry name to find - /// If true the comparison is case insensitive - /// The index position of the matching entry or -1 if not found - /// - /// The Zip file has been closed. - /// - public int FindEntry(string name, bool ignoreCase) - { - if (isDisposed_) - { - throw new ObjectDisposedException("ZipFile"); - } - - // TODO: This will be slow as the next ice age for huge archives! - for (int i = 0; i < entries_.Length; i++) - { - if (string.Compare(name, entries_[i].Name, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) == 0) - { - return i; - } - } - return -1; - } - - /// - /// Searches for a zip entry in this archive with the given name. - /// String comparisons are case insensitive - /// - /// - /// The name to find. May contain directory components separated by slashes ('/'). - /// - /// - /// A clone of the zip entry, or null if no entry with that name exists. - /// - /// - /// The Zip file has been closed. - /// - public ZipEntry GetEntry(string name) - { - if (isDisposed_) - { - throw new ObjectDisposedException("ZipFile"); - } - - int index = FindEntry(name, true); - return (index >= 0) ? (ZipEntry)entries_[index].Clone() : null; - } - - /// - /// Gets an input stream for reading the given zip entry data in an uncompressed form. - /// Normally the should be an entry returned by GetEntry(). - /// - /// The to obtain a data for - /// An input containing data for this - /// - /// The ZipFile has already been closed - /// - /// - /// The compression method for the entry is unknown - /// - /// - /// The entry is not found in the ZipFile - /// - public Stream GetInputStream(ZipEntry entry) - { - if (entry == null) - { - throw new ArgumentNullException(nameof(entry)); - } - - if (isDisposed_) - { - throw new ObjectDisposedException("ZipFile"); - } - - long index = entry.ZipFileIndex; - if ((index < 0) || (index >= entries_.Length) || (entries_[index].Name != entry.Name)) - { - index = FindEntry(entry.Name, true); - if (index < 0) - { - throw new ZipException("Entry cannot be found"); - } - } - return GetInputStream(index); - } - - /// - /// Creates an input stream reading a zip entry - /// - /// The index of the entry to obtain an input stream for. - /// - /// An input containing data for this - /// - /// - /// The ZipFile has already been closed - /// - /// - /// The compression method for the entry is unknown - /// - /// - /// The entry is not found in the ZipFile - /// - public Stream GetInputStream(long entryIndex) - { - if (isDisposed_) - { - throw new ObjectDisposedException("ZipFile"); - } - - long start = LocateEntry(entries_[entryIndex]); - CompressionMethod method = entries_[entryIndex].CompressionMethod; - Stream result = new PartialInputStream(this, start, entries_[entryIndex].CompressedSize); - - if (entries_[entryIndex].IsCrypted == true) - { - result = CreateAndInitDecryptionStream(result, entries_[entryIndex]); - if (result == null) - { - throw new ZipException("Unable to decrypt this entry"); - } - } - - switch (method) - { - case CompressionMethod.Stored: - // read as is. - break; - - case CompressionMethod.Deflated: - // No need to worry about ownership and closing as underlying stream close does nothing. - result = new InflaterInputStream(result, new Inflater(true)); - break; - - case CompressionMethod.BZip2: - result = new BZip2.BZip2InputStream(result); - break; - - default: - throw new ZipException("Unsupported compression method " + method); - } - - return result; - } - - #endregion Input Handling - - #region Archive Testing - - /// - /// Test an archive for integrity/validity - /// - /// Perform low level data Crc check - /// true if all tests pass, false otherwise - /// Testing will terminate on the first error found. - public bool TestArchive(bool testData) - { - return TestArchive(testData, TestStrategy.FindFirstError, null); - } - - /// - /// Test an archive for integrity/validity - /// - /// Perform low level data Crc check - /// The to apply. - /// The handler to call during testing. - /// true if all tests pass, false otherwise - /// The object has already been closed. - public bool TestArchive(bool testData, TestStrategy strategy, ZipTestResultHandler resultHandler) - { - if (isDisposed_) - { - throw new ObjectDisposedException("ZipFile"); - } - - var status = new TestStatus(this); - - resultHandler?.Invoke(status, null); - - HeaderTest test = testData ? (HeaderTest.Header | HeaderTest.Extract) : HeaderTest.Header; - - bool testing = true; - - try - { - int entryIndex = 0; - - while (testing && (entryIndex < Count)) - { - if (resultHandler != null) - { - status.SetEntry(this[entryIndex]); - status.SetOperation(TestOperation.EntryHeader); - resultHandler(status, null); - } - - try - { - TestLocalHeader(this[entryIndex], test); - } - catch (ZipException ex) - { - status.AddError(); - - resultHandler?.Invoke(status, $"Exception during test - '{ex.Message}'"); - - testing &= strategy != TestStrategy.FindFirstError; - } - - if (testing && testData && this[entryIndex].IsFile) - { - // Don't check CRC for AES encrypted archives - var checkCRC = this[entryIndex].AESKeySize == 0; - - if (resultHandler != null) - { - status.SetOperation(TestOperation.EntryData); - resultHandler(status, null); - } - - var crc = new Crc32(); - - using (Stream entryStream = this.GetInputStream(this[entryIndex])) - { - byte[] buffer = new byte[4096]; - long totalBytes = 0; - int bytesRead; - while ((bytesRead = entryStream.Read(buffer, 0, buffer.Length)) > 0) - { - if (checkCRC) - { - crc.Update(new ArraySegment(buffer, 0, bytesRead)); - } - - if (resultHandler != null) - { - totalBytes += bytesRead; - status.SetBytesTested(totalBytes); - resultHandler(status, null); - } - } - } - - if (checkCRC && this[entryIndex].Crc != crc.Value) - { - status.AddError(); - - resultHandler?.Invoke(status, "CRC mismatch"); - - testing &= strategy != TestStrategy.FindFirstError; - } - - if ((this[entryIndex].Flags & (int)GeneralBitFlags.Descriptor) != 0) - { - var helper = new ZipHelperStream(baseStream_); - var data = new DescriptorData(); - helper.ReadDataDescriptor(this[entryIndex].LocalHeaderRequiresZip64, data); - - if (checkCRC && this[entryIndex].Crc != data.Crc) - { - status.AddError(); - resultHandler?.Invoke(status, "Descriptor CRC mismatch"); - } - - if (this[entryIndex].CompressedSize != data.CompressedSize) - { - status.AddError(); - resultHandler?.Invoke(status, "Descriptor compressed size mismatch"); - } - - if (this[entryIndex].Size != data.Size) - { - status.AddError(); - resultHandler?.Invoke(status, "Descriptor size mismatch"); - } - } - } - - if (resultHandler != null) - { - status.SetOperation(TestOperation.EntryComplete); - resultHandler(status, null); - } - - entryIndex += 1; - } - - if (resultHandler != null) - { - status.SetOperation(TestOperation.MiscellaneousTests); - resultHandler(status, null); - } - - // TODO: the 'Corrina Johns' test where local headers are missing from - // the central directory. They are therefore invisible to many archivers. - } - catch (Exception ex) - { - status.AddError(); - - resultHandler?.Invoke(status, $"Exception during test - '{ex.Message}'"); - } - - if (resultHandler != null) - { - status.SetOperation(TestOperation.Complete); - status.SetEntry(null); - resultHandler(status, null); - } - - return (status.ErrorCount == 0); - } - - [Flags] - private enum HeaderTest - { - Extract = 0x01, // Check that this header represents an entry whose data can be extracted - Header = 0x02, // Check that this header contents are valid - } - - /// - /// Test a local header against that provided from the central directory - /// - /// - /// The entry to test against - /// - /// The type of tests to carry out. - /// The offset of the entries data in the file - private long TestLocalHeader(ZipEntry entry, HeaderTest tests) - { - lock (baseStream_) - { - bool testHeader = (tests & HeaderTest.Header) != 0; - bool testData = (tests & HeaderTest.Extract) != 0; - - var entryAbsOffset = offsetOfFirstEntry + entry.Offset; - - baseStream_.Seek(entryAbsOffset, SeekOrigin.Begin); - var signature = (int)ReadLEUint(); - - if (signature != ZipConstants.LocalHeaderSignature) - { - throw new ZipException(string.Format("Wrong local header signature at 0x{0:x}, expected 0x{1:x8}, actual 0x{2:x8}", - entryAbsOffset, ZipConstants.LocalHeaderSignature, signature)); - } - - var extractVersion = (short)(ReadLEUshort() & 0x00ff); - var localFlags = (short)ReadLEUshort(); - var compressionMethod = (short)ReadLEUshort(); - var fileTime = (short)ReadLEUshort(); - var fileDate = (short)ReadLEUshort(); - uint crcValue = ReadLEUint(); - long compressedSize = ReadLEUint(); - long size = ReadLEUint(); - int storedNameLength = ReadLEUshort(); - int extraDataLength = ReadLEUshort(); - - byte[] nameData = new byte[storedNameLength]; - StreamUtils.ReadFully(baseStream_, nameData); - - byte[] extraData = new byte[extraDataLength]; - StreamUtils.ReadFully(baseStream_, extraData); - - var localExtraData = new ZipExtraData(extraData); - - // Extra data / zip64 checks - if (localExtraData.Find(1)) - { - // 2010-03-04 Forum 10512: removed checks for version >= ZipConstants.VersionZip64 - // and size or compressedSize = MaxValue, due to rogue creators. - - size = localExtraData.ReadLong(); - compressedSize = localExtraData.ReadLong(); - - if ((localFlags & (int)GeneralBitFlags.Descriptor) != 0) - { - // These may be valid if patched later - if ((size != -1) && (size != entry.Size)) - { - throw new ZipException("Size invalid for descriptor"); - } - - if ((compressedSize != -1) && (compressedSize != entry.CompressedSize)) - { - throw new ZipException("Compressed size invalid for descriptor"); - } - } - } - else - { - // No zip64 extra data but entry requires it. - if ((extractVersion >= ZipConstants.VersionZip64) && - (((uint)size == uint.MaxValue) || ((uint)compressedSize == uint.MaxValue))) - { - throw new ZipException("Required Zip64 extended information missing"); - } - } - - if (testData) - { - if (entry.IsFile) - { - if (!entry.IsCompressionMethodSupported()) - { - throw new ZipException("Compression method not supported"); - } - - if ((extractVersion > ZipConstants.VersionMadeBy) - || ((extractVersion > 20) && (extractVersion < ZipConstants.VersionZip64))) - { - throw new ZipException(string.Format("Version required to extract this entry not supported ({0})", extractVersion)); - } - - if ((localFlags & (int)(GeneralBitFlags.Patched | GeneralBitFlags.StrongEncryption | GeneralBitFlags.EnhancedCompress | GeneralBitFlags.HeaderMasked)) != 0) - { - throw new ZipException("The library does not support the zip version required to extract this entry"); - } - } - } - - if (testHeader) - { - if ((extractVersion <= 63) && // Ignore later versions as we dont know about them.. - (extractVersion != 10) && - (extractVersion != 11) && - (extractVersion != 20) && - (extractVersion != 21) && - (extractVersion != 25) && - (extractVersion != 27) && - (extractVersion != 45) && - (extractVersion != 46) && - (extractVersion != 50) && - (extractVersion != 51) && - (extractVersion != 52) && - (extractVersion != 61) && - (extractVersion != 62) && - (extractVersion != 63) - ) - { - throw new ZipException(string.Format("Version required to extract this entry is invalid ({0})", extractVersion)); - } - - // Local entry flags dont have reserved bit set on. - if ((localFlags & (int)(GeneralBitFlags.ReservedPKware4 | GeneralBitFlags.ReservedPkware14 | GeneralBitFlags.ReservedPkware15)) != 0) - { - throw new ZipException("Reserved bit flags cannot be set."); - } - - // Encryption requires extract version >= 20 - if (((localFlags & (int)GeneralBitFlags.Encrypted) != 0) && (extractVersion < 20)) - { - throw new ZipException(string.Format("Version required to extract this entry is too low for encryption ({0})", extractVersion)); - } - - // Strong encryption requires encryption flag to be set and extract version >= 50. - if ((localFlags & (int)GeneralBitFlags.StrongEncryption) != 0) - { - if ((localFlags & (int)GeneralBitFlags.Encrypted) == 0) - { - throw new ZipException("Strong encryption flag set but encryption flag is not set"); - } - - if (extractVersion < 50) - { - throw new ZipException(string.Format("Version required to extract this entry is too low for encryption ({0})", extractVersion)); - } - } - - // Patched entries require extract version >= 27 - if (((localFlags & (int)GeneralBitFlags.Patched) != 0) && (extractVersion < 27)) - { - throw new ZipException(string.Format("Patched data requires higher version than ({0})", extractVersion)); - } - - // Central header flags match local entry flags. - if (localFlags != entry.Flags) - { - throw new ZipException("Central header/local header flags mismatch"); - } - - // Central header compression method matches local entry - if (entry.CompressionMethodForHeader != (CompressionMethod)compressionMethod) - { - throw new ZipException("Central header/local header compression method mismatch"); - } - - if (entry.Version != extractVersion) - { - throw new ZipException("Extract version mismatch"); - } - - // Strong encryption and extract version match - if ((localFlags & (int)GeneralBitFlags.StrongEncryption) != 0) - { - if (extractVersion < 62) - { - throw new ZipException("Strong encryption flag set but version not high enough"); - } - } - - if ((localFlags & (int)GeneralBitFlags.HeaderMasked) != 0) - { - if ((fileTime != 0) || (fileDate != 0)) - { - throw new ZipException("Header masked set but date/time values non-zero"); - } - } - - if ((localFlags & (int)GeneralBitFlags.Descriptor) == 0) - { - if (crcValue != (uint)entry.Crc) - { - throw new ZipException("Central header/local header crc mismatch"); - } - } - - // Crc valid for empty entry. - // This will also apply to streamed entries where size isnt known and the header cant be patched - if ((size == 0) && (compressedSize == 0)) - { - if (crcValue != 0) - { - throw new ZipException("Invalid CRC for empty entry"); - } - } - - // TODO: make test more correct... can't compare lengths as was done originally as this can fail for MBCS strings - // Assuming a code page at this point is not valid? Best is to store the name length in the ZipEntry probably - if (entry.Name.Length > storedNameLength) - { - throw new ZipException("File name length mismatch"); - } - - // Name data has already been read convert it and compare. - string localName = ZipStrings.ConvertToStringExt(localFlags, nameData); - - // Central directory and local entry name match - if (localName != entry.Name) - { - throw new ZipException("Central header and local header file name mismatch"); - } - - // Directories have zero actual size but can have compressed size - if (entry.IsDirectory) - { - if (size > 0) - { - throw new ZipException("Directory cannot have size"); - } - - // There may be other cases where the compressed size can be greater than this? - // If so until details are known we will be strict. - if (entry.IsCrypted) - { - if (compressedSize > entry.EncryptionOverheadSize + 2) - { - throw new ZipException("Directory compressed size invalid"); - } - } - else if (compressedSize > 2) - { - // When not compressed the directory size can validly be 2 bytes - // if the true size wasn't known when data was originally being written. - // NOTE: Versions of the library 0.85.4 and earlier always added 2 bytes - throw new ZipException("Directory compressed size invalid"); - } - } - - if (!ZipNameTransform.IsValidName(localName, true)) - { - throw new ZipException("Name is invalid"); - } - } - - // Tests that apply to both data and header. - - // Size can be verified only if it is known in the local header. - // it will always be known in the central header. - if (((localFlags & (int)GeneralBitFlags.Descriptor) == 0) || - ((size > 0 || compressedSize > 0) && entry.Size > 0)) - { - if ((size != 0) - && (size != entry.Size)) - { - throw new ZipException( - string.Format("Size mismatch between central header({0}) and local header({1})", - entry.Size, size)); - } - - if ((compressedSize != 0) - && (compressedSize != entry.CompressedSize && compressedSize != 0xFFFFFFFF && compressedSize != -1)) - { - throw new ZipException( - string.Format("Compressed size mismatch between central header({0}) and local header({1})", - entry.CompressedSize, compressedSize)); - } - } - - int extraLength = storedNameLength + extraDataLength; - return offsetOfFirstEntry + entry.Offset + ZipConstants.LocalHeaderBaseSize + extraLength; - } - } - - #endregion Archive Testing - - #region Updating - - private const int DefaultBufferSize = 4096; - - /// - /// The kind of update to apply. - /// - private enum UpdateCommand - { - Copy, // Copy original file contents. - Modify, // Change encryption, compression, attributes, name, time etc, of an existing file. - Add, // Add a new file to the archive. - } - - #region Properties - - /// - /// Get / set the to apply to names when updating. - /// - public INameTransform NameTransform - { - get - { - return updateEntryFactory_.NameTransform; - } - - set - { - updateEntryFactory_.NameTransform = value; - } - } - - /// - /// Get/set the used to generate values - /// during updates. - /// - public IEntryFactory EntryFactory - { - get - { - return updateEntryFactory_; - } - - set - { - if (value == null) - { - updateEntryFactory_ = new ZipEntryFactory(); - } - else - { - updateEntryFactory_ = value; - } - } - } - - /// - /// Get /set the buffer size to be used when updating this zip file. - /// - public int BufferSize - { - get { return bufferSize_; } - set - { - if (value < 1024) - { - throw new ArgumentOutOfRangeException(nameof(value), "cannot be below 1024"); - } - - if (bufferSize_ != value) - { - bufferSize_ = value; - copyBuffer_ = null; - } - } - } - - /// - /// Get a value indicating an update has been started. - /// - public bool IsUpdating - { - get { return updates_ != null; } - } - - /// - /// Get / set a value indicating how Zip64 Extension usage is determined when adding entries. - /// - public UseZip64 UseZip64 - { - get { return useZip64_; } - set { useZip64_ = value; } - } - - #endregion Properties - - #region Immediate updating - - // TBD: Direct form of updating - // - // public void Update(IEntryMatcher deleteMatcher) - // { - // } - // - // public void Update(IScanner addScanner) - // { - // } - - #endregion Immediate updating - - #region Deferred Updating - - /// - /// Begin updating this archive. - /// - /// The archive storage for use during the update. - /// The data source to utilise during updating. - /// ZipFile has been closed. - /// One of the arguments provided is null - /// ZipFile has been closed. - public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource) - { - if (isDisposed_) - { - throw new ObjectDisposedException("ZipFile"); - } - - if (IsEmbeddedArchive) - { - throw new ZipException("Cannot update embedded/SFX archives"); - } - - archiveStorage_ = archiveStorage ?? throw new ArgumentNullException(nameof(archiveStorage)); - updateDataSource_ = dataSource ?? throw new ArgumentNullException(nameof(dataSource)); - - // NOTE: the baseStream_ may not currently support writing or seeking. - - updateIndex_ = new Dictionary(); - - updates_ = new List(entries_.Length); - foreach (ZipEntry entry in entries_) - { - int index = updates_.Count; - updates_.Add(new ZipUpdate(entry)); - updateIndex_.Add(entry.Name, index); - } - - // We must sort by offset before using offset's calculated sizes - updates_.Sort(new UpdateComparer()); - - int idx = 0; - foreach (ZipUpdate update in updates_) - { - //If last entry, there is no next entry offset to use - if (idx == updates_.Count - 1) - break; - - update.OffsetBasedSize = ((ZipUpdate)updates_[idx + 1]).Entry.Offset - update.Entry.Offset; - idx++; - } - updateCount_ = updates_.Count; - - contentsEdited_ = false; - commentEdited_ = false; - newComment_ = null; - } - - /// - /// Begin updating to this archive. - /// - /// The storage to use during the update. - public void BeginUpdate(IArchiveStorage archiveStorage) - { - BeginUpdate(archiveStorage, new DynamicDiskDataSource()); - } - - /// - /// Begin updating this archive. - /// - /// - /// - /// - public void BeginUpdate() - { - if (Name == null) - { - BeginUpdate(new MemoryArchiveStorage(), new DynamicDiskDataSource()); - } - else - { - BeginUpdate(new DiskArchiveStorage(this), new DynamicDiskDataSource()); - } - } - - /// - /// Commit current updates, updating this archive. - /// - /// - /// - /// ZipFile has been closed. - public void CommitUpdate() - { - if (isDisposed_) - { - throw new ObjectDisposedException("ZipFile"); - } - - CheckUpdating(); - - try - { - updateIndex_.Clear(); - updateIndex_ = null; - - if (contentsEdited_) - { - RunUpdates(); - } - else if (commentEdited_) - { - UpdateCommentOnly(); - } - else - { - // Create an empty archive if none existed originally. - if (entries_.Length == 0) - { - byte[] theComment = (newComment_ != null) ? newComment_.RawComment : ZipStrings.ConvertToArray(comment_); - using (ZipHelperStream zhs = new ZipHelperStream(baseStream_)) - { - zhs.WriteEndOfCentralDirectory(0, 0, 0, theComment); - } - } - } - } - finally - { - PostUpdateCleanup(); - } - } - - /// - /// Abort updating leaving the archive unchanged. - /// - /// - /// - public void AbortUpdate() - { - PostUpdateCleanup(); - } - - /// - /// Set the file comment to be recorded when the current update is commited. - /// - /// The comment to record. - /// ZipFile has been closed. - public void SetComment(string comment) - { - if (isDisposed_) - { - throw new ObjectDisposedException("ZipFile"); - } - - CheckUpdating(); - - newComment_ = new ZipString(comment); - - if (newComment_.RawLength > 0xffff) - { - newComment_ = null; - throw new ZipException("Comment length exceeds maximum - 65535"); - } - - // We dont take account of the original and current comment appearing to be the same - // as encoding may be different. - commentEdited_ = true; - } - - #endregion Deferred Updating - - #region Adding Entries - - private void AddUpdate(ZipUpdate update) - { - contentsEdited_ = true; - - int index = FindExistingUpdate(update.Entry.Name, isEntryName: true); - - if (index >= 0) - { - if (updates_[index] == null) - { - updateCount_ += 1; - } - - // Direct replacement is faster than delete and add. - updates_[index] = update; - } - else - { - index = updates_.Count; - updates_.Add(update); - updateCount_ += 1; - updateIndex_.Add(update.Entry.Name, index); - } - } - - /// - /// Add a new entry to the archive. - /// - /// The name of the file to add. - /// The compression method to use. - /// Ensure Unicode text is used for name and comment for this entry. - /// Argument supplied is null. - /// ZipFile has been closed. - /// Compression method is not supported for creating entries. - public void Add(string fileName, CompressionMethod compressionMethod, bool useUnicodeText) - { - if (fileName == null) - { - throw new ArgumentNullException(nameof(fileName)); - } - - if (isDisposed_) - { - throw new ObjectDisposedException("ZipFile"); - } - - CheckSupportedCompressionMethod(compressionMethod); - CheckUpdating(); - contentsEdited_ = true; - - ZipEntry entry = EntryFactory.MakeFileEntry(fileName); - entry.IsUnicodeText = useUnicodeText; - entry.CompressionMethod = compressionMethod; - - AddUpdate(new ZipUpdate(fileName, entry)); - } - - /// - /// Add a new entry to the archive. - /// - /// The name of the file to add. - /// The compression method to use. - /// ZipFile has been closed. - /// Compression method is not supported for creating entries. - public void Add(string fileName, CompressionMethod compressionMethod) - { - if (fileName == null) - { - throw new ArgumentNullException(nameof(fileName)); - } - - CheckSupportedCompressionMethod(compressionMethod); - CheckUpdating(); - contentsEdited_ = true; - - ZipEntry entry = EntryFactory.MakeFileEntry(fileName); - entry.CompressionMethod = compressionMethod; - AddUpdate(new ZipUpdate(fileName, entry)); - } - - /// - /// Add a file to the archive. - /// - /// The name of the file to add. - /// Argument supplied is null. - public void Add(string fileName) - { - if (fileName == null) - { - throw new ArgumentNullException(nameof(fileName)); - } - - CheckUpdating(); - AddUpdate(new ZipUpdate(fileName, EntryFactory.MakeFileEntry(fileName))); - } - - /// - /// Add a file to the archive. - /// - /// The name of the file to add. - /// The name to use for the on the Zip file created. - /// Argument supplied is null. - public void Add(string fileName, string entryName) - { - if (fileName == null) - { - throw new ArgumentNullException(nameof(fileName)); - } - - if (entryName == null) - { - throw new ArgumentNullException(nameof(entryName)); - } - - CheckUpdating(); - AddUpdate(new ZipUpdate(fileName, EntryFactory.MakeFileEntry(fileName, entryName, true))); - } - - /// - /// Add a file entry with data. - /// - /// The source of the data for this entry. - /// The name to give to the entry. - public void Add(IStaticDataSource dataSource, string entryName) - { - if (dataSource == null) - { - throw new ArgumentNullException(nameof(dataSource)); - } - - if (entryName == null) - { - throw new ArgumentNullException(nameof(entryName)); - } - - CheckUpdating(); - AddUpdate(new ZipUpdate(dataSource, EntryFactory.MakeFileEntry(entryName, false))); - } - - /// - /// Add a file entry with data. - /// - /// The source of the data for this entry. - /// The name to give to the entry. - /// The compression method to use. - /// Compression method is not supported for creating entries. - public void Add(IStaticDataSource dataSource, string entryName, CompressionMethod compressionMethod) - { - if (dataSource == null) - { - throw new ArgumentNullException(nameof(dataSource)); - } - - if (entryName == null) - { - throw new ArgumentNullException(nameof(entryName)); - } - - CheckSupportedCompressionMethod(compressionMethod); - CheckUpdating(); - - ZipEntry entry = EntryFactory.MakeFileEntry(entryName, false); - entry.CompressionMethod = compressionMethod; - - AddUpdate(new ZipUpdate(dataSource, entry)); - } - - /// - /// Add a file entry with data. - /// - /// The source of the data for this entry. - /// The name to give to the entry. - /// The compression method to use. - /// Ensure Unicode text is used for name and comments for this entry. - /// Compression method is not supported for creating entries. - public void Add(IStaticDataSource dataSource, string entryName, CompressionMethod compressionMethod, bool useUnicodeText) - { - if (dataSource == null) - { - throw new ArgumentNullException(nameof(dataSource)); - } - - if (entryName == null) - { - throw new ArgumentNullException(nameof(entryName)); - } - - CheckSupportedCompressionMethod(compressionMethod); - CheckUpdating(); - - ZipEntry entry = EntryFactory.MakeFileEntry(entryName, false); - entry.IsUnicodeText = useUnicodeText; - entry.CompressionMethod = compressionMethod; - - AddUpdate(new ZipUpdate(dataSource, entry)); - } - - /// - /// Add a that contains no data. - /// - /// The entry to add. - /// This can be used to add directories, volume labels, or empty file entries. - public void Add(ZipEntry entry) - { - if (entry == null) - { - throw new ArgumentNullException(nameof(entry)); - } - - CheckUpdating(); - - if ((entry.Size != 0) || (entry.CompressedSize != 0)) - { - throw new ZipException("Entry cannot have any data"); - } - - AddUpdate(new ZipUpdate(UpdateCommand.Add, entry)); - } - - /// - /// Add a with data. - /// - /// The source of the data for this entry. - /// The entry to add. - /// This can be used to add file entries with a custom data source. - /// - /// The encryption method specified in is unsupported. - /// - /// Compression method is not supported for creating entries. - public void Add(IStaticDataSource dataSource, ZipEntry entry) - { - if (entry == null) - { - throw new ArgumentNullException(nameof(entry)); - } - - if (dataSource == null) - { - throw new ArgumentNullException(nameof(dataSource)); - } - - // We don't currently support adding entries with AES encryption, so throw - // up front instead of failing or falling back to ZipCrypto later on - if (entry.AESKeySize > 0) - { - throw new NotSupportedException("Creation of AES encrypted entries is not supported"); - } - - CheckSupportedCompressionMethod(entry.CompressionMethod); - CheckUpdating(); - - AddUpdate(new ZipUpdate(dataSource, entry)); - } - - /// - /// Add a directory entry to the archive. - /// - /// The directory to add. - public void AddDirectory(string directoryName) - { - if (directoryName == null) - { - throw new ArgumentNullException(nameof(directoryName)); - } - - CheckUpdating(); - - ZipEntry dirEntry = EntryFactory.MakeDirectoryEntry(directoryName); - AddUpdate(new ZipUpdate(UpdateCommand.Add, dirEntry)); - } - - /// - /// Check if the specified compression method is supported for adding a new entry. - /// - /// The compression method for the new entry. - private static void CheckSupportedCompressionMethod(CompressionMethod compressionMethod) - { - if (compressionMethod != CompressionMethod.Deflated && compressionMethod != CompressionMethod.Stored && compressionMethod != CompressionMethod.BZip2) - { - throw new NotImplementedException("Compression method not supported"); - } - } - - #endregion Adding Entries - - #region Modifying Entries - - /* Modify not yet ready for public consumption. - Direct modification of an entry should not overwrite original data before its read. - Safe mode is trivial in this sense. - public void Modify(ZipEntry original, ZipEntry updated) - { - if ( original == null ) { - throw new ArgumentNullException("original"); - } - if ( updated == null ) { - throw new ArgumentNullException("updated"); - } - CheckUpdating(); - contentsEdited_ = true; - updates_.Add(new ZipUpdate(original, updated)); - } - */ - - #endregion Modifying Entries - - #region Deleting Entries - - /// - /// Delete an entry by name - /// - /// The filename to delete - /// True if the entry was found and deleted; false otherwise. - public bool Delete(string fileName) - { - if (fileName == null) - { - throw new ArgumentNullException(nameof(fileName)); - } - - CheckUpdating(); - - bool result = false; - int index = FindExistingUpdate(fileName); - if ((index >= 0) && (updates_[index] != null)) - { - result = true; - contentsEdited_ = true; - updates_[index] = null; - updateCount_ -= 1; - } - else - { - throw new ZipException("Cannot find entry to delete"); - } - return result; - } - - /// - /// Delete a from the archive. - /// - /// The entry to delete. - public void Delete(ZipEntry entry) - { - if (entry == null) - { - throw new ArgumentNullException(nameof(entry)); - } - - CheckUpdating(); - - int index = FindExistingUpdate(entry); - if (index >= 0) - { - contentsEdited_ = true; - updates_[index] = null; - updateCount_ -= 1; - } - else - { - throw new ZipException("Cannot find entry to delete"); - } - } - - #endregion Deleting Entries - - #region Update Support - - #region Writing Values/Headers - - private void WriteLEShort(int value) - { - baseStream_.WriteByte((byte)(value & 0xff)); - baseStream_.WriteByte((byte)((value >> 8) & 0xff)); - } - - /// - /// Write an unsigned short in little endian byte order. - /// - private void WriteLEUshort(ushort value) - { - baseStream_.WriteByte((byte)(value & 0xff)); - baseStream_.WriteByte((byte)(value >> 8)); - } - - /// - /// Write an int in little endian byte order. - /// - private void WriteLEInt(int value) - { - WriteLEShort(value & 0xffff); - WriteLEShort(value >> 16); - } - - /// - /// Write an unsigned int in little endian byte order. - /// - private void WriteLEUint(uint value) - { - WriteLEUshort((ushort)(value & 0xffff)); - WriteLEUshort((ushort)(value >> 16)); - } - - /// - /// Write a long in little endian byte order. - /// - private void WriteLeLong(long value) - { - WriteLEInt((int)(value & 0xffffffff)); - WriteLEInt((int)(value >> 32)); - } - - private void WriteLEUlong(ulong value) - { - WriteLEUint((uint)(value & 0xffffffff)); - WriteLEUint((uint)(value >> 32)); - } - - private void WriteLocalEntryHeader(ZipUpdate update) - { - ZipEntry entry = update.OutEntry; - - // TODO: Local offset will require adjusting for multi-disk zip files. - entry.Offset = baseStream_.Position; - - // TODO: Need to clear any entry flags that dont make sense or throw an exception here. - if (update.Command != UpdateCommand.Copy) - { - if (entry.CompressionMethod == CompressionMethod.Deflated) - { - if (entry.Size == 0) - { - // No need to compress - no data. - entry.CompressedSize = entry.Size; - entry.Crc = 0; - entry.CompressionMethod = CompressionMethod.Stored; - } - } - else if (entry.CompressionMethod == CompressionMethod.Stored) - { - entry.Flags &= ~(int)GeneralBitFlags.Descriptor; - } - - if (HaveKeys) - { - entry.IsCrypted = true; - if (entry.Crc < 0) - { - entry.Flags |= (int)GeneralBitFlags.Descriptor; - } - } - else - { - entry.IsCrypted = false; - } - - switch (useZip64_) - { - case UseZip64.Dynamic: - if (entry.Size < 0) - { - entry.ForceZip64(); - } - break; - - case UseZip64.On: - entry.ForceZip64(); - break; - - case UseZip64.Off: - // Do nothing. The entry itself may be using Zip64 independently. - break; - } - } - - // Write the local file header - WriteLEInt(ZipConstants.LocalHeaderSignature); - - WriteLEShort(entry.Version); - WriteLEShort(entry.Flags); - - WriteLEShort((byte)entry.CompressionMethodForHeader); - WriteLEInt((int)entry.DosTime); - - if (!entry.HasCrc) - { - // Note patch address for updating CRC later. - update.CrcPatchOffset = baseStream_.Position; - WriteLEInt((int)0); - } - else - { - WriteLEInt(unchecked((int)entry.Crc)); - } - - if (entry.LocalHeaderRequiresZip64) - { - WriteLEInt(-1); - WriteLEInt(-1); - } - else - { - if ((entry.CompressedSize < 0) || (entry.Size < 0)) - { - update.SizePatchOffset = baseStream_.Position; - } - - WriteLEInt((int)entry.CompressedSize); - WriteLEInt((int)entry.Size); - } - - byte[] name = ZipStrings.ConvertToArray(entry.Flags, entry.Name); - - if (name.Length > 0xFFFF) - { - throw new ZipException("Entry name too long."); - } - - var ed = new ZipExtraData(entry.ExtraData); - - if (entry.LocalHeaderRequiresZip64) - { - ed.StartNewEntry(); - - // Local entry header always includes size and compressed size. - // NOTE the order of these fields is reversed when compared to the normal headers! - ed.AddLeLong(entry.Size); - ed.AddLeLong(entry.CompressedSize); - ed.AddNewEntry(1); - } - else - { - ed.Delete(1); - } - - entry.ExtraData = ed.GetEntryData(); - - WriteLEShort(name.Length); - WriteLEShort(entry.ExtraData.Length); - - if (name.Length > 0) - { - baseStream_.Write(name, 0, name.Length); - } - - if (entry.LocalHeaderRequiresZip64) - { - if (!ed.Find(1)) - { - throw new ZipException("Internal error cannot find extra data"); - } - - update.SizePatchOffset = baseStream_.Position + ed.CurrentReadIndex; - } - - if (entry.ExtraData.Length > 0) - { - baseStream_.Write(entry.ExtraData, 0, entry.ExtraData.Length); - } - } - - private int WriteCentralDirectoryHeader(ZipEntry entry) - { - if (entry.CompressedSize < 0) - { - throw new ZipException("Attempt to write central directory entry with unknown csize"); - } - - if (entry.Size < 0) - { - throw new ZipException("Attempt to write central directory entry with unknown size"); - } - - if (entry.Crc < 0) - { - throw new ZipException("Attempt to write central directory entry with unknown crc"); - } - - // Write the central file header - WriteLEInt(ZipConstants.CentralHeaderSignature); - - // Version made by - WriteLEShort((entry.HostSystem << 8) | entry.VersionMadeBy); - - // Version required to extract - WriteLEShort(entry.Version); - - WriteLEShort(entry.Flags); - - unchecked - { - WriteLEShort((byte)entry.CompressionMethodForHeader); - WriteLEInt((int)entry.DosTime); - WriteLEInt((int)entry.Crc); - } - - bool useExtraCompressedSize = false; //Do we want to store the compressed size in the extra data? - if ((entry.IsZip64Forced()) || (entry.CompressedSize >= 0xffffffff)) - { - useExtraCompressedSize = true; - WriteLEInt(-1); - } - else - { - WriteLEInt((int)(entry.CompressedSize & 0xffffffff)); - } - - bool useExtraUncompressedSize = false; //Do we want to store the uncompressed size in the extra data? - if ((entry.IsZip64Forced()) || (entry.Size >= 0xffffffff)) - { - useExtraUncompressedSize = true; - WriteLEInt(-1); - } - else - { - WriteLEInt((int)entry.Size); - } - - byte[] name = ZipStrings.ConvertToArray(entry.Flags, entry.Name); - - if (name.Length > 0xFFFF) - { - throw new ZipException("Entry name is too long."); - } - - WriteLEShort(name.Length); - - // Central header extra data is different to local header version so regenerate. - var ed = new ZipExtraData(entry.ExtraData); - - if (entry.CentralHeaderRequiresZip64) - { - ed.StartNewEntry(); - - if (useExtraUncompressedSize) - { - ed.AddLeLong(entry.Size); - } - - if (useExtraCompressedSize) - { - ed.AddLeLong(entry.CompressedSize); - } - - if (entry.Offset >= 0xffffffff) - { - ed.AddLeLong(entry.Offset); - } - - // Number of disk on which this file starts isnt supported and is never written here. - ed.AddNewEntry(1); - } - else - { - // Should have already be done when local header was added. - ed.Delete(1); - } - - byte[] centralExtraData = ed.GetEntryData(); - - WriteLEShort(centralExtraData.Length); - WriteLEShort(entry.Comment != null ? entry.Comment.Length : 0); - - WriteLEShort(0); // disk number - WriteLEShort(0); // internal file attributes - - // External file attributes... - if (entry.ExternalFileAttributes != -1) - { - WriteLEInt(entry.ExternalFileAttributes); - } - else - { - if (entry.IsDirectory) - { - WriteLEUint(16); - } - else - { - WriteLEUint(0); - } - } - - if (entry.Offset >= 0xffffffff) - { - WriteLEUint(0xffffffff); - } - else - { - WriteLEUint((uint)(int)entry.Offset); - } - - if (name.Length > 0) - { - baseStream_.Write(name, 0, name.Length); - } - - if (centralExtraData.Length > 0) - { - baseStream_.Write(centralExtraData, 0, centralExtraData.Length); - } - - byte[] rawComment = (entry.Comment != null) ? Encoding.ASCII.GetBytes(entry.Comment) : Empty.Array(); - - if (rawComment.Length > 0) - { - baseStream_.Write(rawComment, 0, rawComment.Length); - } - - return ZipConstants.CentralHeaderBaseSize + name.Length + centralExtraData.Length + rawComment.Length; - } - - #endregion Writing Values/Headers - - private void PostUpdateCleanup() - { - updateDataSource_ = null; - updates_ = null; - updateIndex_ = null; - - if (archiveStorage_ != null) - { - archiveStorage_.Dispose(); - archiveStorage_ = null; - } - } - - private string GetTransformedFileName(string name) - { - INameTransform transform = NameTransform; - return (transform != null) ? - transform.TransformFile(name) : - name; - } - - private string GetTransformedDirectoryName(string name) - { - INameTransform transform = NameTransform; - return (transform != null) ? - transform.TransformDirectory(name) : - name; - } - - /// - /// Get a raw memory buffer. - /// - /// Returns a raw memory buffer. - private byte[] GetBuffer() - { - if (copyBuffer_ == null) - { - copyBuffer_ = new byte[bufferSize_]; - } - return copyBuffer_; - } - - private void CopyDescriptorBytes(ZipUpdate update, Stream dest, Stream source) - { - // Don't include the signature size to allow copy without seeking - var bytesToCopy = GetDescriptorSize(update, false); - - // Don't touch the source stream if no descriptor is present - if (bytesToCopy == 0) return; - - var buffer = GetBuffer(); - - // Copy the first 4 bytes of the descriptor - source.Read(buffer, 0, sizeof(int)); - dest.Write(buffer, 0, sizeof(int)); - - if (BitConverter.ToUInt32(buffer, 0) != ZipConstants.DataDescriptorSignature) - { - // The initial bytes wasn't the descriptor, reduce the pending byte count - bytesToCopy -= buffer.Length; - } - - while (bytesToCopy > 0) - { - int readSize = Math.Min(buffer.Length, bytesToCopy); - - int bytesRead = source.Read(buffer, 0, readSize); - if (bytesRead > 0) - { - dest.Write(buffer, 0, bytesRead); - bytesToCopy -= bytesRead; - } - else - { - throw new ZipException("Unxpected end of stream"); - } - } - } - - private void CopyBytes(ZipUpdate update, Stream destination, Stream source, - long bytesToCopy, bool updateCrc) - { - if (destination == source) - { - throw new InvalidOperationException("Destination and source are the same"); - } - - // NOTE: Compressed size is updated elsewhere. - var crc = new Crc32(); - byte[] buffer = GetBuffer(); - - long targetBytes = bytesToCopy; - long totalBytesRead = 0; - - int bytesRead; - do - { - int readSize = buffer.Length; - - if (bytesToCopy < readSize) - { - readSize = (int)bytesToCopy; - } - - bytesRead = source.Read(buffer, 0, readSize); - if (bytesRead > 0) - { - if (updateCrc) - { - crc.Update(new ArraySegment(buffer, 0, bytesRead)); - } - destination.Write(buffer, 0, bytesRead); - bytesToCopy -= bytesRead; - totalBytesRead += bytesRead; - } - } - while ((bytesRead > 0) && (bytesToCopy > 0)); - - if (totalBytesRead != targetBytes) - { - throw new ZipException(string.Format("Failed to copy bytes expected {0} read {1}", targetBytes, totalBytesRead)); - } - - if (updateCrc) - { - update.OutEntry.Crc = crc.Value; - } - } - - /// - /// Get the size of the source descriptor for a . - /// - /// The update to get the size for. - /// Whether to include the signature size - /// The descriptor size, zero if there isn't one. - private static int GetDescriptorSize(ZipUpdate update, bool includingSignature) - { - if (!((GeneralBitFlags)update.Entry.Flags).HasFlag(GeneralBitFlags.Descriptor)) - return 0; - - var descriptorWithSignature = update.Entry.LocalHeaderRequiresZip64 - ? ZipConstants.Zip64DataDescriptorSize - : ZipConstants.DataDescriptorSize; - - return includingSignature - ? descriptorWithSignature - : descriptorWithSignature - sizeof(int); - } - - private void CopyDescriptorBytesDirect(ZipUpdate update, Stream stream, ref long destinationPosition, long sourcePosition) - { - var buffer = GetBuffer(); ; - - stream.Position = sourcePosition; - stream.Read(buffer, 0, sizeof(int)); - var sourceHasSignature = BitConverter.ToUInt32(buffer, 0) == ZipConstants.DataDescriptorSignature; - - var bytesToCopy = GetDescriptorSize(update, sourceHasSignature); - - while (bytesToCopy > 0) - { - stream.Position = sourcePosition; - - var bytesRead = stream.Read(buffer, 0, bytesToCopy); - if (bytesRead > 0) - { - stream.Position = destinationPosition; - stream.Write(buffer, 0, bytesRead); - bytesToCopy -= bytesRead; - destinationPosition += bytesRead; - sourcePosition += bytesRead; - } - else - { - throw new ZipException("Unexpected end of stream"); - } - } - } - - private void CopyEntryDataDirect(ZipUpdate update, Stream stream, bool updateCrc, ref long destinationPosition, ref long sourcePosition) - { - long bytesToCopy = update.Entry.CompressedSize; - - // NOTE: Compressed size is updated elsewhere. - var crc = new Crc32(); - byte[] buffer = GetBuffer(); - - long targetBytes = bytesToCopy; - long totalBytesRead = 0; - - int bytesRead; - do - { - int readSize = buffer.Length; - - if (bytesToCopy < readSize) - { - readSize = (int)bytesToCopy; - } - - stream.Position = sourcePosition; - bytesRead = stream.Read(buffer, 0, readSize); - if (bytesRead > 0) - { - if (updateCrc) - { - crc.Update(new ArraySegment(buffer, 0, bytesRead)); - } - stream.Position = destinationPosition; - stream.Write(buffer, 0, bytesRead); - - destinationPosition += bytesRead; - sourcePosition += bytesRead; - bytesToCopy -= bytesRead; - totalBytesRead += bytesRead; - } - } - while ((bytesRead > 0) && (bytesToCopy > 0)); - - if (totalBytesRead != targetBytes) - { - throw new ZipException(string.Format("Failed to copy bytes expected {0} read {1}", targetBytes, totalBytesRead)); - } - - if (updateCrc) - { - update.OutEntry.Crc = crc.Value; - } - } - - private int FindExistingUpdate(ZipEntry entry) - { - int result = -1; - if (updateIndex_.ContainsKey(entry.Name)) - { - result = (int)updateIndex_[entry.Name]; - } - /* - // This is slow like the coming of the next ice age but takes less storage and may be useful - // for CF? - for (int index = 0; index < updates_.Count; ++index) - { - ZipUpdate zu = ( ZipUpdate )updates_[index]; - if ( (zu.Entry.ZipFileIndex == entry.ZipFileIndex) && - (string.Compare(convertedName, zu.Entry.Name, true, CultureInfo.InvariantCulture) == 0) ) { - result = index; - break; - } - } - */ - return result; - } - - private int FindExistingUpdate(string fileName, bool isEntryName = false) - { - int result = -1; - - string convertedName = !isEntryName ? GetTransformedFileName(fileName) : fileName; - - if (updateIndex_.ContainsKey(convertedName)) - { - result = (int)updateIndex_[convertedName]; - } - - /* - // This is slow like the coming of the next ice age but takes less storage and may be useful - // for CF? - for ( int index = 0; index < updates_.Count; ++index ) { - if ( string.Compare(convertedName, (( ZipUpdate )updates_[index]).Entry.Name, - true, CultureInfo.InvariantCulture) == 0 ) { - result = index; - break; - } - } - */ - - return result; - } - - /// - /// Get an output stream for the specified - /// - /// The entry to get an output stream for. - /// The output stream obtained for the entry. - private Stream GetOutputStream(ZipEntry entry) - { - Stream result = baseStream_; - - if (entry.IsCrypted == true) - { - result = CreateAndInitEncryptionStream(result, entry); - } - - switch (entry.CompressionMethod) - { - case CompressionMethod.Stored: - if (!entry.IsCrypted) - { - // If there is an encryption stream in use, that can be returned directly - // otherwise, wrap the base stream in an UncompressedStream instead of returning it directly - result = new UncompressedStream(result); - } - break; - - case CompressionMethod.Deflated: - var dos = new DeflaterOutputStream(result, new Deflater(9, true)) - { - // If there is an encryption stream in use, then we want that to be disposed when the deflator stream is disposed - // If not, then we don't want it to dispose the base stream - IsStreamOwner = entry.IsCrypted - }; - result = dos; - break; - - case CompressionMethod.BZip2: - var bzos = new BZip2.BZip2OutputStream(result) - { - // If there is an encryption stream in use, then we want that to be disposed when the BZip2OutputStream stream is disposed - // If not, then we don't want it to dispose the base stream - IsStreamOwner = entry.IsCrypted - }; - result = bzos; - break; - - default: - throw new ZipException("Unknown compression method " + entry.CompressionMethod); - } - return result; - } - - private void AddEntry(ZipFile workFile, ZipUpdate update) - { - Stream source = null; - - if (update.Entry.IsFile) - { - source = update.GetSource(); - - if (source == null) - { - source = updateDataSource_.GetSource(update.Entry, update.Filename); - } - } - - var useCrc = update.Entry.AESKeySize == 0; - - if (source != null) - { - using (source) - { - long sourceStreamLength = source.Length; - if (update.OutEntry.Size < 0) - { - update.OutEntry.Size = sourceStreamLength; - } - else - { - // Check for errant entries. - if (update.OutEntry.Size != sourceStreamLength) - { - throw new ZipException("Entry size/stream size mismatch"); - } - } - - workFile.WriteLocalEntryHeader(update); - - long dataStart = workFile.baseStream_.Position; - - using (Stream output = workFile.GetOutputStream(update.OutEntry)) - { - CopyBytes(update, output, source, sourceStreamLength, useCrc); - } - - long dataEnd = workFile.baseStream_.Position; - update.OutEntry.CompressedSize = dataEnd - dataStart; - - if ((update.OutEntry.Flags & (int)GeneralBitFlags.Descriptor) == (int)GeneralBitFlags.Descriptor) - { - var helper = new ZipHelperStream(workFile.baseStream_); - helper.WriteDataDescriptor(update.OutEntry); - } - } - } - else - { - workFile.WriteLocalEntryHeader(update); - update.OutEntry.CompressedSize = 0; - } - } - - private void ModifyEntry(ZipFile workFile, ZipUpdate update) - { - workFile.WriteLocalEntryHeader(update); - long dataStart = workFile.baseStream_.Position; - - // TODO: This is slow if the changes don't effect the data!! - if (update.Entry.IsFile && (update.Filename != null)) - { - using (Stream output = workFile.GetOutputStream(update.OutEntry)) - { - using (Stream source = this.GetInputStream(update.Entry)) - { - CopyBytes(update, output, source, source.Length, true); - } - } - } - - long dataEnd = workFile.baseStream_.Position; - update.Entry.CompressedSize = dataEnd - dataStart; - } - - private void CopyEntryDirect(ZipFile workFile, ZipUpdate update, ref long destinationPosition) - { - bool skipOver = false || update.Entry.Offset == destinationPosition; - - if (!skipOver) - { - baseStream_.Position = destinationPosition; - workFile.WriteLocalEntryHeader(update); - destinationPosition = baseStream_.Position; - } - - long sourcePosition = 0; - - const int NameLengthOffset = 26; - - // TODO: Add base for SFX friendly handling - long entryDataOffset = update.Entry.Offset + NameLengthOffset; - - baseStream_.Seek(entryDataOffset, SeekOrigin.Begin); - - // Clumsy way of handling retrieving the original name and extra data length for now. - // TODO: Stop re-reading name and data length in CopyEntryDirect. - - uint nameLength = ReadLEUshort(); - uint extraLength = ReadLEUshort(); - - sourcePosition = baseStream_.Position + nameLength + extraLength; - - if (skipOver) - { - if (update.OffsetBasedSize != -1) - { - destinationPosition += update.OffsetBasedSize; - } - else - { - // Skip entry header - destinationPosition += (sourcePosition - entryDataOffset) + NameLengthOffset; - - // Skip entry compressed data - destinationPosition += update.Entry.CompressedSize; - - // Seek to end of entry to check for descriptor signature - baseStream_.Seek(destinationPosition, SeekOrigin.Begin); - - var descriptorHasSignature = ReadLEUint() == ZipConstants.DataDescriptorSignature; - - // Skip descriptor and it's signature (if present) - destinationPosition += GetDescriptorSize(update, descriptorHasSignature); - } - } - else - { - if (update.Entry.CompressedSize > 0) - { - CopyEntryDataDirect(update, baseStream_, false, ref destinationPosition, ref sourcePosition); - } - CopyDescriptorBytesDirect(update, baseStream_, ref destinationPosition, sourcePosition); - } - } - - private void CopyEntry(ZipFile workFile, ZipUpdate update) - { - workFile.WriteLocalEntryHeader(update); - - if (update.Entry.CompressedSize > 0) - { - const int NameLengthOffset = 26; - - long entryDataOffset = update.Entry.Offset + NameLengthOffset; - - // TODO: This wont work for SFX files! - baseStream_.Seek(entryDataOffset, SeekOrigin.Begin); - - uint nameLength = ReadLEUshort(); - uint extraLength = ReadLEUshort(); - - baseStream_.Seek(nameLength + extraLength, SeekOrigin.Current); - - CopyBytes(update, workFile.baseStream_, baseStream_, update.Entry.CompressedSize, false); - } - CopyDescriptorBytes(update, workFile.baseStream_, baseStream_); - } - - private void Reopen(Stream source) - { - isNewArchive_ = false; - baseStream_ = source ?? throw new ZipException("Failed to reopen archive - no source"); - ReadEntries(); - } - - private void Reopen() - { - if (Name == null) - { - throw new InvalidOperationException("Name is not known cannot Reopen"); - } - - Reopen(File.Open(Name, FileMode.Open, FileAccess.Read, FileShare.Read)); - } - - private void UpdateCommentOnly() - { - long baseLength = baseStream_.Length; - - ZipHelperStream updateFile = null; - - if (archiveStorage_.UpdateMode == FileUpdateMode.Safe) - { - Stream copyStream = archiveStorage_.MakeTemporaryCopy(baseStream_); - updateFile = new ZipHelperStream(copyStream) - { - IsStreamOwner = true - }; - - baseStream_.Dispose(); - baseStream_ = null; - } - else - { - if (archiveStorage_.UpdateMode == FileUpdateMode.Direct) - { - // TODO: archiveStorage wasnt originally intended for this use. - // Need to revisit this to tidy up handling as archive storage currently doesnt - // handle the original stream well. - // The problem is when using an existing zip archive with an in memory archive storage. - // The open stream wont support writing but the memory storage should open the same file not an in memory one. - - // Need to tidy up the archive storage interface and contract basically. - baseStream_ = archiveStorage_.OpenForDirectUpdate(baseStream_); - updateFile = new ZipHelperStream(baseStream_); - } - else - { - baseStream_.Dispose(); - baseStream_ = null; - updateFile = new ZipHelperStream(Name); - } - } - - using (updateFile) - { - long locatedCentralDirOffset = - updateFile.LocateBlockWithSignature(ZipConstants.EndOfCentralDirectorySignature, - baseLength, ZipConstants.EndOfCentralRecordBaseSize, 0xffff); - if (locatedCentralDirOffset < 0) - { - throw new ZipException("Cannot find central directory"); - } - - const int CentralHeaderCommentSizeOffset = 16; - updateFile.Position += CentralHeaderCommentSizeOffset; - - byte[] rawComment = newComment_.RawComment; - - updateFile.WriteLEShort(rawComment.Length); - updateFile.Write(rawComment, 0, rawComment.Length); - updateFile.SetLength(updateFile.Position); - } - - if (archiveStorage_.UpdateMode == FileUpdateMode.Safe) - { - Reopen(archiveStorage_.ConvertTemporaryToFinal()); - } - else - { - ReadEntries(); - } - } - - /// - /// Class used to sort updates. - /// - private class UpdateComparer : IComparer - { - /// - /// Compares two objects and returns a value indicating whether one is - /// less than, equal to or greater than the other. - /// - /// First object to compare - /// Second object to compare. - /// Compare result. - public int Compare(ZipUpdate x, ZipUpdate y) - { - int result; - - if (x == null) - { - if (y == null) - { - result = 0; - } - else - { - result = -1; - } - } - else if (y == null) - { - result = 1; - } - else - { - int xCmdValue = ((x.Command == UpdateCommand.Copy) || (x.Command == UpdateCommand.Modify)) ? 0 : 1; - int yCmdValue = ((y.Command == UpdateCommand.Copy) || (y.Command == UpdateCommand.Modify)) ? 0 : 1; - - result = xCmdValue - yCmdValue; - if (result == 0) - { - long offsetDiff = x.Entry.Offset - y.Entry.Offset; - if (offsetDiff < 0) - { - result = -1; - } - else if (offsetDiff == 0) - { - result = 0; - } - else - { - result = 1; - } - } - } - return result; - } - } - - private void RunUpdates() - { - long sizeEntries = 0; - long endOfStream = 0; - bool directUpdate = false; - long destinationPosition = 0; // NOT SFX friendly - - ZipFile workFile; - - if (IsNewArchive) - { - workFile = this; - workFile.baseStream_.Position = 0; - directUpdate = true; - } - else if (archiveStorage_.UpdateMode == FileUpdateMode.Direct) - { - workFile = this; - workFile.baseStream_.Position = 0; - directUpdate = true; - - // Sort the updates by offset within copies/modifies, then adds. - // This ensures that data required by copies will not be overwritten. - updates_.Sort(new UpdateComparer()); - } - else - { - workFile = ZipFile.Create(archiveStorage_.GetTemporaryOutput()); - workFile.UseZip64 = UseZip64; - - if (key != null) - { - workFile.key = (byte[])key.Clone(); - } - } - - try - { - foreach (ZipUpdate update in updates_) - { - if (update != null) - { - switch (update.Command) - { - case UpdateCommand.Copy: - if (directUpdate) - { - CopyEntryDirect(workFile, update, ref destinationPosition); - } - else - { - CopyEntry(workFile, update); - } - break; - - case UpdateCommand.Modify: - // TODO: Direct modifying of an entry will take some legwork. - ModifyEntry(workFile, update); - break; - - case UpdateCommand.Add: - if (!IsNewArchive && directUpdate) - { - workFile.baseStream_.Position = destinationPosition; - } - - AddEntry(workFile, update); - - if (directUpdate) - { - destinationPosition = workFile.baseStream_.Position; - } - break; - } - } - } - - if (!IsNewArchive && directUpdate) - { - workFile.baseStream_.Position = destinationPosition; - } - - long centralDirOffset = workFile.baseStream_.Position; - - foreach (ZipUpdate update in updates_) - { - if (update != null) - { - sizeEntries += workFile.WriteCentralDirectoryHeader(update.OutEntry); - } - } - - byte[] theComment = (newComment_ != null) ? newComment_.RawComment : ZipStrings.ConvertToArray(comment_); - using (ZipHelperStream zhs = new ZipHelperStream(workFile.baseStream_)) - { - zhs.WriteEndOfCentralDirectory(updateCount_, sizeEntries, centralDirOffset, theComment); - } - - endOfStream = workFile.baseStream_.Position; - - // And now patch entries... - foreach (ZipUpdate update in updates_) - { - if (update != null) - { - // If the size of the entry is zero leave the crc as 0 as well. - // The calculated crc will be all bits on... - if ((update.CrcPatchOffset > 0) && (update.OutEntry.CompressedSize > 0)) - { - workFile.baseStream_.Position = update.CrcPatchOffset; - workFile.WriteLEInt((int)update.OutEntry.Crc); - } - - if (update.SizePatchOffset > 0) - { - workFile.baseStream_.Position = update.SizePatchOffset; - if (update.OutEntry.LocalHeaderRequiresZip64) - { - workFile.WriteLeLong(update.OutEntry.Size); - workFile.WriteLeLong(update.OutEntry.CompressedSize); - } - else - { - workFile.WriteLEInt((int)update.OutEntry.CompressedSize); - workFile.WriteLEInt((int)update.OutEntry.Size); - } - } - } - } - } - catch - { - workFile.Close(); - if (!directUpdate && (workFile.Name != null)) - { - File.Delete(workFile.Name); - } - throw; - } - - if (directUpdate) - { - workFile.baseStream_.SetLength(endOfStream); - workFile.baseStream_.Flush(); - isNewArchive_ = false; - ReadEntries(); - } - else - { - baseStream_.Dispose(); - Reopen(archiveStorage_.ConvertTemporaryToFinal()); - } - } - - private void CheckUpdating() - { - if (updates_ == null) - { - throw new InvalidOperationException("BeginUpdate has not been called"); - } - } - - #endregion Update Support - - #region ZipUpdate class - - /// - /// Represents a pending update to a Zip file. - /// - private class ZipUpdate - { - #region Constructors - - public ZipUpdate(string fileName, ZipEntry entry) - { - command_ = UpdateCommand.Add; - entry_ = entry; - filename_ = fileName; - } - - [Obsolete] - public ZipUpdate(string fileName, string entryName, CompressionMethod compressionMethod) - { - command_ = UpdateCommand.Add; - entry_ = new ZipEntry(entryName) - { - CompressionMethod = compressionMethod - }; - filename_ = fileName; - } - - [Obsolete] - public ZipUpdate(string fileName, string entryName) - : this(fileName, entryName, CompressionMethod.Deflated) - { - // Do nothing. - } - - [Obsolete] - public ZipUpdate(IStaticDataSource dataSource, string entryName, CompressionMethod compressionMethod) - { - command_ = UpdateCommand.Add; - entry_ = new ZipEntry(entryName) - { - CompressionMethod = compressionMethod - }; - dataSource_ = dataSource; - } - - public ZipUpdate(IStaticDataSource dataSource, ZipEntry entry) - { - command_ = UpdateCommand.Add; - entry_ = entry; - dataSource_ = dataSource; - } - - public ZipUpdate(ZipEntry original, ZipEntry updated) - { - throw new ZipException("Modify not currently supported"); - /* - command_ = UpdateCommand.Modify; - entry_ = ( ZipEntry )original.Clone(); - outEntry_ = ( ZipEntry )updated.Clone(); - */ - } - - public ZipUpdate(UpdateCommand command, ZipEntry entry) - { - command_ = command; - entry_ = (ZipEntry)entry.Clone(); - } - - /// - /// Copy an existing entry. - /// - /// The existing entry to copy. - public ZipUpdate(ZipEntry entry) - : this(UpdateCommand.Copy, entry) - { - // Do nothing. - } - - #endregion Constructors - - /// - /// Get the for this update. - /// - /// This is the source or original entry. - public ZipEntry Entry - { - get { return entry_; } - } - - /// - /// Get the that will be written to the updated/new file. - /// - public ZipEntry OutEntry - { - get - { - if (outEntry_ == null) - { - outEntry_ = (ZipEntry)entry_.Clone(); - } - - return outEntry_; - } - } - - /// - /// Get the command for this update. - /// - public UpdateCommand Command - { - get { return command_; } - } - - /// - /// Get the filename if any for this update. Null if none exists. - /// - public string Filename - { - get { return filename_; } - } - - /// - /// Get/set the location of the size patch for this update. - /// - public long SizePatchOffset - { - get { return sizePatchOffset_; } - set { sizePatchOffset_ = value; } - } - - /// - /// Get /set the location of the crc patch for this update. - /// - public long CrcPatchOffset - { - get { return crcPatchOffset_; } - set { crcPatchOffset_ = value; } - } - - /// - /// Get/set the size calculated by offset. - /// Specifically, the difference between this and next entry's starting offset. - /// - public long OffsetBasedSize - { - get { return _offsetBasedSize; } - set { _offsetBasedSize = value; } - } - - public Stream GetSource() - { - Stream result = null; - if (dataSource_ != null) - { - result = dataSource_.GetSource(); - } - - return result; - } - - #region Instance Fields - - private ZipEntry entry_; - private ZipEntry outEntry_; - private readonly UpdateCommand command_; - private IStaticDataSource dataSource_; - private readonly string filename_; - private long sizePatchOffset_ = -1; - private long crcPatchOffset_ = -1; - private long _offsetBasedSize = -1; - - #endregion Instance Fields - } - - #endregion ZipUpdate class - - #endregion Updating - - #region Disposing - - #region IDisposable Members - - void IDisposable.Dispose() - { - Close(); - } - - #endregion IDisposable Members - - private void DisposeInternal(bool disposing) - { - if (!isDisposed_) - { - isDisposed_ = true; - entries_ = Empty.Array(); - - if (IsStreamOwner && (baseStream_ != null)) - { - lock (baseStream_) - { - baseStream_.Dispose(); - } - } - - PostUpdateCleanup(); - } - } - - /// - /// Releases the unmanaged resources used by the this instance and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; - /// false to release only unmanaged resources. - protected virtual void Dispose(bool disposing) - { - DisposeInternal(disposing); - } - - #endregion Disposing - - #region Internal routines - - #region Reading - - /// - /// Read an unsigned short in little endian byte order. - /// - /// Returns the value read. - /// - /// The stream ends prematurely - /// - private ushort ReadLEUshort() - { - int data1 = baseStream_.ReadByte(); - - if (data1 < 0) - { - throw new EndOfStreamException("End of stream"); - } - - int data2 = baseStream_.ReadByte(); - - if (data2 < 0) - { - throw new EndOfStreamException("End of stream"); - } - - return unchecked((ushort)((ushort)data1 | (ushort)(data2 << 8))); - } - - /// - /// Read a uint in little endian byte order. - /// - /// Returns the value read. - /// - /// An i/o error occurs. - /// - /// - /// The file ends prematurely - /// - private uint ReadLEUint() - { - return (uint)(ReadLEUshort() | (ReadLEUshort() << 16)); - } - - private ulong ReadLEUlong() - { - return ReadLEUint() | ((ulong)ReadLEUint() << 32); - } - - #endregion Reading - - // NOTE this returns the offset of the first byte after the signature. - private long LocateBlockWithSignature(int signature, long endLocation, int minimumBlockSize, int maximumVariableData) - { - using (ZipHelperStream les = new ZipHelperStream(baseStream_)) - { - return les.LocateBlockWithSignature(signature, endLocation, minimumBlockSize, maximumVariableData); - } - } - - /// - /// Search for and read the central directory of a zip file filling the entries array. - /// - /// - /// An i/o error occurs. - /// - /// - /// The central directory is malformed or cannot be found - /// - private void ReadEntries() - { - // Search for the End Of Central Directory. When a zip comment is - // present the directory will start earlier - // - // The search is limited to 64K which is the maximum size of a trailing comment field to aid speed. - // This should be compatible with both SFX and ZIP files but has only been tested for Zip files - // If a SFX file has the Zip data attached as a resource and there are other resources occurring later then - // this could be invalid. - // Could also speed this up by reading memory in larger blocks. - - if (baseStream_.CanSeek == false) - { - throw new ZipException("ZipFile stream must be seekable"); - } - - long locatedEndOfCentralDir = LocateBlockWithSignature(ZipConstants.EndOfCentralDirectorySignature, - baseStream_.Length, ZipConstants.EndOfCentralRecordBaseSize, 0xffff); - - if (locatedEndOfCentralDir < 0) - { - throw new ZipException("Cannot find central directory"); - } - - // Read end of central directory record - ushort thisDiskNumber = ReadLEUshort(); - ushort startCentralDirDisk = ReadLEUshort(); - ulong entriesForThisDisk = ReadLEUshort(); - ulong entriesForWholeCentralDir = ReadLEUshort(); - ulong centralDirSize = ReadLEUint(); - long offsetOfCentralDir = ReadLEUint(); - uint commentSize = ReadLEUshort(); - - if (commentSize > 0) - { - byte[] comment = new byte[commentSize]; - - StreamUtils.ReadFully(baseStream_, comment); - comment_ = ZipStrings.ConvertToString(comment); - } - else - { - comment_ = string.Empty; - } - - bool isZip64 = false; - bool requireZip64 = false; - - // Check if zip64 header information is required. - if ((thisDiskNumber == 0xffff) || - (startCentralDirDisk == 0xffff) || - (entriesForThisDisk == 0xffff) || - (entriesForWholeCentralDir == 0xffff) || - (centralDirSize == 0xffffffff) || - (offsetOfCentralDir == 0xffffffff)) - { - requireZip64 = true; - } - - // #357 - always check for the existance of the Zip64 central directory. - // #403 - Take account of the fixed size of the locator when searching. - // Subtract from locatedEndOfCentralDir so that the endLocation is the location of EndOfCentralDirectorySignature, - // rather than the data following the signature. - long locatedZip64EndOfCentralDirLocator = LocateBlockWithSignature( - ZipConstants.Zip64CentralDirLocatorSignature, - locatedEndOfCentralDir - 4, - ZipConstants.Zip64EndOfCentralDirectoryLocatorSize, - 0); - - if (locatedZip64EndOfCentralDirLocator < 0) - { - if (requireZip64) - { - // This is only an error in cases where the Zip64 directory is required. - throw new ZipException("Cannot find Zip64 locator"); - } - } - else - { - isZip64 = true; - - // number of the disk with the start of the zip64 end of central directory 4 bytes - // relative offset of the zip64 end of central directory record 8 bytes - // total number of disks 4 bytes - ReadLEUint(); // startDisk64 is not currently used - ulong offset64 = ReadLEUlong(); - uint totalDisks = ReadLEUint(); - - baseStream_.Position = (long)offset64; - long sig64 = ReadLEUint(); - - if (sig64 != ZipConstants.Zip64CentralFileHeaderSignature) - { - throw new ZipException(string.Format("Invalid Zip64 Central directory signature at {0:X}", offset64)); - } - - // NOTE: Record size = SizeOfFixedFields + SizeOfVariableData - 12. - ulong recordSize = ReadLEUlong(); - int versionMadeBy = ReadLEUshort(); - int versionToExtract = ReadLEUshort(); - uint thisDisk = ReadLEUint(); - uint centralDirDisk = ReadLEUint(); - entriesForThisDisk = ReadLEUlong(); - entriesForWholeCentralDir = ReadLEUlong(); - centralDirSize = ReadLEUlong(); - offsetOfCentralDir = (long)ReadLEUlong(); - - // NOTE: zip64 extensible data sector (variable size) is ignored. - } - - entries_ = new ZipEntry[entriesForThisDisk]; - - // SFX/embedded support, find the offset of the first entry vis the start of the stream - // This applies to Zip files that are appended to the end of an SFX stub. - // Or are appended as a resource to an executable. - // Zip files created by some archivers have the offsets altered to reflect the true offsets - // and so dont require any adjustment here... - // TODO: Difficulty with Zip64 and SFX offset handling needs resolution - maths? - if (!isZip64 && (offsetOfCentralDir < locatedEndOfCentralDir - (4 + (long)centralDirSize))) - { - offsetOfFirstEntry = locatedEndOfCentralDir - (4 + (long)centralDirSize + offsetOfCentralDir); - if (offsetOfFirstEntry <= 0) - { - throw new ZipException("Invalid embedded zip archive"); - } - } - - baseStream_.Seek(offsetOfFirstEntry + offsetOfCentralDir, SeekOrigin.Begin); - - for (ulong i = 0; i < entriesForThisDisk; i++) - { - if (ReadLEUint() != ZipConstants.CentralHeaderSignature) - { - throw new ZipException("Wrong Central Directory signature"); - } - - int versionMadeBy = ReadLEUshort(); - int versionToExtract = ReadLEUshort(); - int bitFlags = ReadLEUshort(); - int method = ReadLEUshort(); - uint dostime = ReadLEUint(); - uint crc = ReadLEUint(); - var csize = (long)ReadLEUint(); - var size = (long)ReadLEUint(); - int nameLen = ReadLEUshort(); - int extraLen = ReadLEUshort(); - int commentLen = ReadLEUshort(); - - int diskStartNo = ReadLEUshort(); // Not currently used - int internalAttributes = ReadLEUshort(); // Not currently used - - uint externalAttributes = ReadLEUint(); - long offset = ReadLEUint(); - - byte[] buffer = new byte[Math.Max(nameLen, commentLen)]; - - StreamUtils.ReadFully(baseStream_, buffer, 0, nameLen); - string name = ZipStrings.ConvertToStringExt(bitFlags, buffer, nameLen); - - var entry = new ZipEntry(name, versionToExtract, versionMadeBy, (CompressionMethod)method) - { - Crc = crc & 0xffffffffL, - Size = size & 0xffffffffL, - CompressedSize = csize & 0xffffffffL, - Flags = bitFlags, - DosTime = dostime, - ZipFileIndex = (long)i, - Offset = offset, - ExternalFileAttributes = (int)externalAttributes - }; - - if ((bitFlags & 8) == 0) - { - entry.CryptoCheckValue = (byte)(crc >> 24); - } - else - { - entry.CryptoCheckValue = (byte)((dostime >> 8) & 0xff); - } - - if (extraLen > 0) - { - byte[] extra = new byte[extraLen]; - StreamUtils.ReadFully(baseStream_, extra); - entry.ExtraData = extra; - } - - entry.ProcessExtraData(false); - - if (commentLen > 0) - { - StreamUtils.ReadFully(baseStream_, buffer, 0, commentLen); - entry.Comment = ZipStrings.ConvertToStringExt(bitFlags, buffer, commentLen); - } - - entries_[i] = entry; - } - } - - /// - /// Locate the data for a given entry. - /// - /// - /// The start offset of the data. - /// - /// - /// The stream ends prematurely - /// - /// - /// The local header signature is invalid, the entry and central header file name lengths are different - /// or the local and entry compression methods dont match - /// - private long LocateEntry(ZipEntry entry) - { - return TestLocalHeader(entry, HeaderTest.Extract); - } - - private Stream CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry) - { - CryptoStream result = null; - - if (entry.CompressionMethodForHeader == CompressionMethod.WinZipAES) - { - if (entry.Version >= ZipConstants.VERSION_AES) - { - // Issue #471 - accept an empty string as a password, but reject null. - OnKeysRequired(entry.Name); - if (rawPassword_ == null) - { - throw new ZipException("No password available for AES encrypted stream"); - } - int saltLen = entry.AESSaltLen; - byte[] saltBytes = new byte[saltLen]; - int saltIn = StreamUtils.ReadRequestedBytes(baseStream, saltBytes, 0, saltLen); - if (saltIn != saltLen) - throw new ZipException("AES Salt expected " + saltLen + " got " + saltIn); - // - byte[] pwdVerifyRead = new byte[2]; - StreamUtils.ReadFully(baseStream, pwdVerifyRead); - int blockSize = entry.AESKeySize / 8; // bits to bytes - - var decryptor = new ZipAESTransform(rawPassword_, saltBytes, blockSize, false); - byte[] pwdVerifyCalc = decryptor.PwdVerifier; - if (pwdVerifyCalc[0] != pwdVerifyRead[0] || pwdVerifyCalc[1] != pwdVerifyRead[1]) - throw new ZipException("Invalid password for AES"); - result = new ZipAESStream(baseStream, decryptor, CryptoStreamMode.Read); - } - else - { - throw new ZipException("Decryption method not supported"); - } - } - else - { - if ((entry.Version < ZipConstants.VersionStrongEncryption) - || (entry.Flags & (int)GeneralBitFlags.StrongEncryption) == 0) - { - var classicManaged = new PkzipClassicManaged(); - - OnKeysRequired(entry.Name); - if (HaveKeys == false) - { - throw new ZipException("No password available for encrypted stream"); - } - - result = new CryptoStream(baseStream, classicManaged.CreateDecryptor(key, null), CryptoStreamMode.Read); - CheckClassicPassword(result, entry); - } - else - { - // We don't support PKWare strong encryption - throw new ZipException("Decryption method not supported"); - } - } - - return result; - } - - private Stream CreateAndInitEncryptionStream(Stream baseStream, ZipEntry entry) - { - CryptoStream result = null; - if ((entry.Version < ZipConstants.VersionStrongEncryption) - || (entry.Flags & (int)GeneralBitFlags.StrongEncryption) == 0) - { - var classicManaged = new PkzipClassicManaged(); - - OnKeysRequired(entry.Name); - if (HaveKeys == false) - { - throw new ZipException("No password available for encrypted stream"); - } - - // Closing a CryptoStream will close the base stream as well so wrap it in an UncompressedStream - // which doesnt do this. - result = new CryptoStream(new UncompressedStream(baseStream), - classicManaged.CreateEncryptor(key, null), CryptoStreamMode.Write); - - if ((entry.Crc < 0) || (entry.Flags & 8) != 0) - { - WriteEncryptionHeader(result, entry.DosTime << 16); - } - else - { - WriteEncryptionHeader(result, entry.Crc); - } - } - return result; - } - - private static void CheckClassicPassword(CryptoStream classicCryptoStream, ZipEntry entry) - { - byte[] cryptbuffer = new byte[ZipConstants.CryptoHeaderSize]; - StreamUtils.ReadFully(classicCryptoStream, cryptbuffer); - if (cryptbuffer[ZipConstants.CryptoHeaderSize - 1] != entry.CryptoCheckValue) - throw new ZipException("Invalid password"); - } - - private static void WriteEncryptionHeader(Stream stream, long crcValue) - { - byte[] cryptBuffer = new byte[ZipConstants.CryptoHeaderSize]; - var rng = RandomNumberGenerator.Create(); - rng.GetBytes(cryptBuffer); - cryptBuffer[11] = (byte)(crcValue >> 24); - stream.Write(cryptBuffer, 0, cryptBuffer.Length); - } - - #endregion Internal routines - - #region Instance Fields - - private bool isDisposed_; - private string name_; - private string comment_; - private string rawPassword_; - private Stream baseStream_; - private bool isStreamOwner; - private long offsetOfFirstEntry; - private ZipEntry[] entries_; - private byte[] key; - private bool isNewArchive_; - - // Default is dynamic which is not backwards compatible and can cause problems - // with XP's built in compression which cant read Zip64 archives. - // However it does avoid the situation were a large file is added and cannot be completed correctly. - // Hint: Set always ZipEntry size before they are added to an archive and this setting isnt needed. - private UseZip64 useZip64_ = UseZip64.Dynamic; - - #region Zip Update Instance Fields - - private List updates_; - private long updateCount_; // Count is managed manually as updates_ can contain nulls! - private Dictionary updateIndex_; - private IArchiveStorage archiveStorage_; - private IDynamicDataSource updateDataSource_; - private bool contentsEdited_; - private int bufferSize_ = DefaultBufferSize; - private byte[] copyBuffer_; - private ZipString newComment_; - private bool commentEdited_; - private IEntryFactory updateEntryFactory_ = new ZipEntryFactory(); - - #endregion Zip Update Instance Fields - - #endregion Instance Fields - - #region Support Classes - - /// - /// Represents a string from a which is stored as an array of bytes. - /// - private class ZipString - { - #region Constructors - - /// - /// Initialise a with a string. - /// - /// The textual string form. - public ZipString(string comment) - { - comment_ = comment; - isSourceString_ = true; - } - - /// - /// Initialise a using a string in its binary 'raw' form. - /// - /// - public ZipString(byte[] rawString) - { - rawComment_ = rawString; - } - - #endregion Constructors - - /// - /// Get a value indicating the original source of data for this instance. - /// True if the source was a string; false if the source was binary data. - /// - public bool IsSourceString - { - get { return isSourceString_; } - } - - /// - /// Get the length of the comment when represented as raw bytes. - /// - public int RawLength - { - get - { - MakeBytesAvailable(); - return rawComment_.Length; - } - } - - /// - /// Get the comment in its 'raw' form as plain bytes. - /// - public byte[] RawComment - { - get - { - MakeBytesAvailable(); - return (byte[])rawComment_.Clone(); - } - } - - /// - /// Reset the comment to its initial state. - /// - public void Reset() - { - if (isSourceString_) - { - rawComment_ = null; - } - else - { - comment_ = null; - } - } - - private void MakeTextAvailable() - { - if (comment_ == null) - { - comment_ = ZipStrings.ConvertToString(rawComment_); - } - } - - private void MakeBytesAvailable() - { - if (rawComment_ == null) - { - rawComment_ = ZipStrings.ConvertToArray(comment_); - } - } - - /// - /// Implicit conversion of comment to a string. - /// - /// The to convert to a string. - /// The textual equivalent for the input value. - static public implicit operator string(ZipString zipString) - { - zipString.MakeTextAvailable(); - return zipString.comment_; - } - - #region Instance Fields - - private string comment_; - private byte[] rawComment_; - private readonly bool isSourceString_; - - #endregion Instance Fields - } - - /// - /// An enumerator for Zip entries - /// - private class ZipEntryEnumerator : IEnumerator - { - #region Constructors - - public ZipEntryEnumerator(ZipEntry[] entries) - { - array = entries; - } - - #endregion Constructors - - #region IEnumerator Members - - public object Current - { - get - { - return array[index]; - } - } - - public void Reset() - { - index = -1; - } - - public bool MoveNext() - { - return (++index < array.Length); - } - - #endregion IEnumerator Members - - #region Instance Fields - - private ZipEntry[] array; - private int index = -1; - - #endregion Instance Fields - } - - /// - /// An is a stream that you can write uncompressed data - /// to and flush, but cannot read, seek or do anything else to. - /// - private class UncompressedStream : Stream - { - #region Constructors - - public UncompressedStream(Stream baseStream) - { - baseStream_ = baseStream; - } - - #endregion Constructors - - /// - /// Gets a value indicating whether the current stream supports reading. - /// - public override bool CanRead - { - get - { - return false; - } - } - - /// - /// Write any buffered data to underlying storage. - /// - public override void Flush() - { - baseStream_.Flush(); - } - - /// - /// Gets a value indicating whether the current stream supports writing. - /// - public override bool CanWrite - { - get - { - return baseStream_.CanWrite; - } - } - - /// - /// Gets a value indicating whether the current stream supports seeking. - /// - public override bool CanSeek - { - get - { - return false; - } - } - - /// - /// Get the length in bytes of the stream. - /// - public override long Length - { - get - { - return 0; - } - } - - /// - /// Gets or sets the position within the current stream. - /// - public override long Position - { - get - { - return baseStream_.Position; - } - set - { - throw new NotImplementedException(); - } - } - - /// - /// Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. - /// - /// An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source. - /// The zero-based byte offset in buffer at which to begin storing the data read from the current stream. - /// The maximum number of bytes to be read from the current stream. - /// - /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. - /// - /// The sum of offset and count is larger than the buffer length. - /// Methods were called after the stream was closed. - /// The stream does not support reading. - /// buffer is null. - /// An I/O error occurs. - /// offset or count is negative. - public override int Read(byte[] buffer, int offset, int count) - { - return 0; - } - - /// - /// Sets the position within the current stream. - /// - /// A byte offset relative to the origin parameter. - /// A value of type indicating the reference point used to obtain the new position. - /// - /// The new position within the current stream. - /// - /// An I/O error occurs. - /// The stream does not support seeking, such as if the stream is constructed from a pipe or console output. - /// Methods were called after the stream was closed. - public override long Seek(long offset, SeekOrigin origin) - { - return 0; - } - - /// - /// Sets the length of the current stream. - /// - /// The desired length of the current stream in bytes. - /// The stream does not support both writing and seeking, such as if the stream is constructed from a pipe or console output. - /// An I/O error occurs. - /// Methods were called after the stream was closed. - public override void SetLength(long value) - { - } - - /// - /// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. - /// - /// An array of bytes. This method copies count bytes from buffer to the current stream. - /// The zero-based byte offset in buffer at which to begin copying bytes to the current stream. - /// The number of bytes to be written to the current stream. - /// An I/O error occurs. - /// The stream does not support writing. - /// Methods were called after the stream was closed. - /// buffer is null. - /// The sum of offset and count is greater than the buffer length. - /// offset or count is negative. - public override void Write(byte[] buffer, int offset, int count) - { - baseStream_.Write(buffer, offset, count); - } - - private readonly - - #region Instance Fields - - Stream baseStream_; - - #endregion Instance Fields - } - - /// - /// A is an - /// whose data is only a part or subsection of a file. - /// - private class PartialInputStream : Stream - { - #region Constructors - - /// - /// Initialise a new instance of the class. - /// - /// The containing the underlying stream to use for IO. - /// The start of the partial data. - /// The length of the partial data. - public PartialInputStream(ZipFile zipFile, long start, long length) - { - start_ = start; - length_ = length; - - // Although this is the only time the zipfile is used - // keeping a reference here prevents premature closure of - // this zip file and thus the baseStream_. - - // Code like this will cause apparently random failures depending - // on the size of the files and when garbage is collected. - // - // ZipFile z = new ZipFile (stream); - // Stream reader = z.GetInputStream(0); - // uses reader here.... - zipFile_ = zipFile; - baseStream_ = zipFile_.baseStream_; - readPos_ = start; - end_ = start + length; - } - - #endregion Constructors - - /// - /// Read a byte from this stream. - /// - /// Returns the byte read or -1 on end of stream. - public override int ReadByte() - { - if (readPos_ >= end_) - { - // -1 is the correct value at end of stream. - return -1; - } - - lock (baseStream_) - { - baseStream_.Seek(readPos_++, SeekOrigin.Begin); - return baseStream_.ReadByte(); - } - } - - /// - /// Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. - /// - /// An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source. - /// The zero-based byte offset in buffer at which to begin storing the data read from the current stream. - /// The maximum number of bytes to be read from the current stream. - /// - /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. - /// - /// The sum of offset and count is larger than the buffer length. - /// Methods were called after the stream was closed. - /// The stream does not support reading. - /// buffer is null. - /// An I/O error occurs. - /// offset or count is negative. - public override int Read(byte[] buffer, int offset, int count) - { - lock (baseStream_) - { - if (count > end_ - readPos_) - { - count = (int)(end_ - readPos_); - if (count == 0) - { - return 0; - } - } - // Protect against Stream implementations that throw away their buffer on every Seek - // (for example, Mono FileStream) - if (baseStream_.Position != readPos_) - { - baseStream_.Seek(readPos_, SeekOrigin.Begin); - } - int readCount = baseStream_.Read(buffer, offset, count); - if (readCount > 0) - { - readPos_ += readCount; - } - return readCount; - } - } - - /// - /// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. - /// - /// An array of bytes. This method copies count bytes from buffer to the current stream. - /// The zero-based byte offset in buffer at which to begin copying bytes to the current stream. - /// The number of bytes to be written to the current stream. - /// An I/O error occurs. - /// The stream does not support writing. - /// Methods were called after the stream was closed. - /// buffer is null. - /// The sum of offset and count is greater than the buffer length. - /// offset or count is negative. - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotSupportedException(); - } - - /// - /// When overridden in a derived class, sets the length of the current stream. - /// - /// The desired length of the current stream in bytes. - /// The stream does not support both writing and seeking, such as if the stream is constructed from a pipe or console output. - /// An I/O error occurs. - /// Methods were called after the stream was closed. - public override void SetLength(long value) - { - throw new NotSupportedException(); - } - - /// - /// When overridden in a derived class, sets the position within the current stream. - /// - /// A byte offset relative to the origin parameter. - /// A value of type indicating the reference point used to obtain the new position. - /// - /// The new position within the current stream. - /// - /// An I/O error occurs. - /// The stream does not support seeking, such as if the stream is constructed from a pipe or console output. - /// Methods were called after the stream was closed. - public override long Seek(long offset, SeekOrigin origin) - { - long newPos = readPos_; - - switch (origin) - { - case SeekOrigin.Begin: - newPos = start_ + offset; - break; - - case SeekOrigin.Current: - newPos = readPos_ + offset; - break; - - case SeekOrigin.End: - newPos = end_ + offset; - break; - } - - if (newPos < start_) - { - throw new ArgumentException("Negative position is invalid"); - } - - if (newPos > end_) - { - throw new IOException("Cannot seek past end"); - } - readPos_ = newPos; - return readPos_; - } - - /// - /// Clears all buffers for this stream and causes any buffered data to be written to the underlying device. - /// - /// An I/O error occurs. - public override void Flush() - { - // Nothing to do. - } - - /// - /// Gets or sets the position within the current stream. - /// - /// - /// The current position within the stream. - /// An I/O error occurs. - /// The stream does not support seeking. - /// Methods were called after the stream was closed. - public override long Position - { - get { return readPos_ - start_; } - set - { - long newPos = start_ + value; - - if (newPos < start_) - { - throw new ArgumentException("Negative position is invalid"); - } - - if (newPos > end_) - { - throw new InvalidOperationException("Cannot seek past end"); - } - readPos_ = newPos; - } - } - - /// - /// Gets the length in bytes of the stream. - /// - /// - /// A long value representing the length of the stream in bytes. - /// A class derived from Stream does not support seeking. - /// Methods were called after the stream was closed. - public override long Length - { - get { return length_; } - } - - /// - /// Gets a value indicating whether the current stream supports writing. - /// - /// false - /// true if the stream supports writing; otherwise, false. - public override bool CanWrite - { - get { return false; } - } - - /// - /// Gets a value indicating whether the current stream supports seeking. - /// - /// true - /// true if the stream supports seeking; otherwise, false. - public override bool CanSeek - { - get { return true; } - } - - /// - /// Gets a value indicating whether the current stream supports reading. - /// - /// true. - /// true if the stream supports reading; otherwise, false. - public override bool CanRead - { - get { return true; } - } - - /// - /// Gets a value that determines whether the current stream can time out. - /// - /// - /// A value that determines whether the current stream can time out. - public override bool CanTimeout - { - get { return baseStream_.CanTimeout; } - } - - #region Instance Fields - - private ZipFile zipFile_; - private Stream baseStream_; - private readonly long start_; - private readonly long length_; - private long readPos_; - private readonly long end_; - - #endregion Instance Fields - } - - #endregion Support Classes - } - - #endregion ZipFile Class - - #region DataSources - - /// - /// Provides a static way to obtain a source of data for an entry. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public interface IStaticDataSource - { - /// - /// Get a source of data by creating a new stream. - /// - /// Returns a to use for compression input. - /// Ideally a new stream is created and opened to achieve this, to avoid locking problems. - Stream GetSource(); - } - - /// - /// Represents a source of data that can dynamically provide - /// multiple data sources based on the parameters passed. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public interface IDynamicDataSource - { - /// - /// Get a data source. - /// - /// The to get a source for. - /// The name for data if known. - /// Returns a to use for compression input. - /// Ideally a new stream is created and opened to achieve this, to avoid locking problems. - Stream GetSource(ZipEntry entry, string name); - } - - /// - /// Default implementation of a for use with files stored on disk. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class StaticDiskDataSource : IStaticDataSource - { - /// - /// Initialise a new instance of - /// - /// The name of the file to obtain data from. - public StaticDiskDataSource(string fileName) - { - fileName_ = fileName; - } - - #region IDataSource Members - - /// - /// Get a providing data. - /// - /// Returns a providing data. - public Stream GetSource() - { - return File.Open(fileName_, FileMode.Open, FileAccess.Read, FileShare.Read); - } - - private readonly - - #endregion IDataSource Members - - #region Instance Fields - - string fileName_; - - #endregion Instance Fields - } - - /// - /// Default implementation of for files stored on disk. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class DynamicDiskDataSource : IDynamicDataSource - { - #region IDataSource Members - - /// - /// Get a providing data for an entry. - /// - /// The entry to provide data for. - /// The file name for data if known. - /// Returns a stream providing data; or null if not available - public Stream GetSource(ZipEntry entry, string name) - { - Stream result = null; - - if (name != null) - { - result = File.Open(name, FileMode.Open, FileAccess.Read, FileShare.Read); - } - - return result; - } - - #endregion IDataSource Members - } - - #endregion DataSources - - #region Archive Storage - - /// - /// Defines facilities for data storage when updating Zip Archives. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public interface IArchiveStorage - { - /// - /// Get the to apply during updates. - /// - FileUpdateMode UpdateMode { get; } - - /// - /// Get an empty that can be used for temporary output. - /// - /// Returns a temporary output - /// - Stream GetTemporaryOutput(); - - /// - /// Convert a temporary output stream to a final stream. - /// - /// The resulting final - /// - Stream ConvertTemporaryToFinal(); - - /// - /// Make a temporary copy of the original stream. - /// - /// The to copy. - /// Returns a temporary output that is a copy of the input. - Stream MakeTemporaryCopy(Stream stream); - - /// - /// Return a stream suitable for performing direct updates on the original source. - /// - /// The current stream. - /// Returns a stream suitable for direct updating. - /// This may be the current stream passed. - Stream OpenForDirectUpdate(Stream stream); - - /// - /// Dispose of this instance. - /// - void Dispose(); - } - - /// - /// An abstract suitable for extension by inheritance. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - abstract public class BaseArchiveStorage : IArchiveStorage - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The update mode. - protected BaseArchiveStorage(FileUpdateMode updateMode) - { - updateMode_ = updateMode; - } - - #endregion Constructors - - #region IArchiveStorage Members - - /// - /// Gets a temporary output - /// - /// Returns the temporary output stream. - /// - public abstract Stream GetTemporaryOutput(); - - /// - /// Converts the temporary to its final form. - /// - /// Returns a that can be used to read - /// the final storage for the archive. - /// - public abstract Stream ConvertTemporaryToFinal(); - - /// - /// Make a temporary copy of a . - /// - /// The to make a copy of. - /// Returns a temporary output that is a copy of the input. - public abstract Stream MakeTemporaryCopy(Stream stream); - - /// - /// Return a stream suitable for performing direct updates on the original source. - /// - /// The to open for direct update. - /// Returns a stream suitable for direct updating. - public abstract Stream OpenForDirectUpdate(Stream stream); - - /// - /// Disposes this instance. - /// - public abstract void Dispose(); - - /// - /// Gets the update mode applicable. - /// - /// The update mode. - public FileUpdateMode UpdateMode - { - get - { - return updateMode_; - } - } - - #endregion IArchiveStorage Members - - #region Instance Fields - - private readonly FileUpdateMode updateMode_; - - #endregion Instance Fields - } - - /// - /// An implementation suitable for hard disks. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class DiskArchiveStorage : BaseArchiveStorage - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The file. - /// The update mode. - public DiskArchiveStorage(ZipFile file, FileUpdateMode updateMode) - : base(updateMode) - { - if (file.Name == null) - { - throw new ZipException("Cant handle non file archives"); - } - - fileName_ = file.Name; - } - - /// - /// Initializes a new instance of the class. - /// - /// The file. - public DiskArchiveStorage(ZipFile file) - : this(file, FileUpdateMode.Safe) - { - } - - #endregion Constructors - - #region IArchiveStorage Members - - /// - /// Gets a temporary output for performing updates on. - /// - /// Returns the temporary output stream. - public override Stream GetTemporaryOutput() - { - temporaryName_ = PathUtils.GetTempFileName(temporaryName_); - temporaryStream_ = File.Open(temporaryName_, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None); - - return temporaryStream_; - } - - /// - /// Converts a temporary to its final form. - /// - /// Returns a that can be used to read - /// the final storage for the archive. - public override Stream ConvertTemporaryToFinal() - { - if (temporaryStream_ == null) - { - throw new ZipException("No temporary stream has been created"); - } - - Stream result = null; - - string moveTempName = PathUtils.GetTempFileName(fileName_); - bool newFileCreated = false; - - try - { - temporaryStream_.Dispose(); - File.Move(fileName_, moveTempName); - File.Move(temporaryName_, fileName_); - newFileCreated = true; - File.Delete(moveTempName); - - result = File.Open(fileName_, FileMode.Open, FileAccess.Read, FileShare.Read); - } - catch (Exception) - { - result = null; - - // Try to roll back changes... - if (!newFileCreated) - { - File.Move(moveTempName, fileName_); - File.Delete(temporaryName_); - } - - throw; - } - - return result; - } - - /// - /// Make a temporary copy of a stream. - /// - /// The to copy. - /// Returns a temporary output that is a copy of the input. - public override Stream MakeTemporaryCopy(Stream stream) - { - stream.Dispose(); - - temporaryName_ = PathUtils.GetTempFileName(fileName_); - File.Copy(fileName_, temporaryName_, true); - - temporaryStream_ = new FileStream(temporaryName_, - FileMode.Open, - FileAccess.ReadWrite); - return temporaryStream_; - } - - /// - /// Return a stream suitable for performing direct updates on the original source. - /// - /// The current stream. - /// Returns a stream suitable for direct updating. - /// If the is not null this is used as is. - public override Stream OpenForDirectUpdate(Stream stream) - { - Stream result; - if ((stream == null) || !stream.CanWrite) - { - if (stream != null) - { - stream.Dispose(); - } - - result = new FileStream(fileName_, - FileMode.Open, - FileAccess.ReadWrite); - } - else - { - result = stream; - } - - return result; - } - - /// - /// Disposes this instance. - /// - public override void Dispose() - { - if (temporaryStream_ != null) - { - temporaryStream_.Dispose(); - } - } - - #endregion IArchiveStorage Members - - #region Instance Fields - - private Stream temporaryStream_; - private readonly string fileName_; - private string temporaryName_; - - #endregion Instance Fields - } - - /// - /// An implementation suitable for in memory streams. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class MemoryArchiveStorage : BaseArchiveStorage - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - public MemoryArchiveStorage() - : base(FileUpdateMode.Direct) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The to use - /// This constructor is for testing as memory streams dont really require safe mode. - public MemoryArchiveStorage(FileUpdateMode updateMode) - : base(updateMode) - { - } - - #endregion Constructors - - #region Properties - - /// - /// Get the stream returned by if this was in fact called. - /// - public MemoryStream FinalStream - { - get { return finalStream_; } - } - - #endregion Properties - - #region IArchiveStorage Members - - /// - /// Gets the temporary output - /// - /// Returns the temporary output stream. - public override Stream GetTemporaryOutput() - { - temporaryStream_ = new MemoryStream(); - return temporaryStream_; - } - - /// - /// Converts the temporary to its final form. - /// - /// Returns a that can be used to read - /// the final storage for the archive. - public override Stream ConvertTemporaryToFinal() - { - if (temporaryStream_ == null) - { - throw new ZipException("No temporary stream has been created"); - } - - finalStream_ = new MemoryStream(temporaryStream_.ToArray()); - return finalStream_; - } - - /// - /// Make a temporary copy of the original stream. - /// - /// The to copy. - /// Returns a temporary output that is a copy of the input. - public override Stream MakeTemporaryCopy(Stream stream) - { - temporaryStream_ = new MemoryStream(); - stream.Position = 0; - StreamUtils.Copy(stream, temporaryStream_, new byte[4096]); - return temporaryStream_; - } - - /// - /// Return a stream suitable for performing direct updates on the original source. - /// - /// The original source stream - /// Returns a stream suitable for direct updating. - /// If the passed is not null this is used; - /// otherwise a new is returned. - public override Stream OpenForDirectUpdate(Stream stream) - { - Stream result; - if ((stream == null) || !stream.CanWrite) - { - result = new MemoryStream(); - - if (stream != null) - { - stream.Position = 0; - StreamUtils.Copy(stream, result, new byte[4096]); - - stream.Dispose(); - } - } - else - { - result = stream; - } - - return result; - } - - /// - /// Disposes this instance. - /// - public override void Dispose() - { - if (temporaryStream_ != null) - { - temporaryStream_.Dispose(); - } - } - - #endregion IArchiveStorage Members - - #region Instance Fields - - private MemoryStream temporaryStream_; - private MemoryStream finalStream_; - - #endregion Instance Fields - } - - #endregion Archive Storage -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipHelperStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipHelperStream.cs deleted file mode 100644 index 294fbe723..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipHelperStream.cs +++ /dev/null @@ -1,632 +0,0 @@ -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// Holds data pertinent to a data descriptor. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class DescriptorData - { - /// - /// Get /set the compressed size of data. - /// - public long CompressedSize - { - get { return compressedSize; } - set { compressedSize = value; } - } - - /// - /// Get / set the uncompressed size of data - /// - public long Size - { - get { return size; } - set { size = value; } - } - - /// - /// Get /set the crc value. - /// - public long Crc - { - get { return crc; } - set { crc = (value & 0xffffffff); } - } - - #region Instance Fields - - private long size; - private long compressedSize; - private long crc; - - #endregion Instance Fields - } - - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal class EntryPatchData - { - public long SizePatchOffset - { - get { return sizePatchOffset_; } - set { sizePatchOffset_ = value; } - } - - public long CrcPatchOffset - { - get { return crcPatchOffset_; } - set { crcPatchOffset_ = value; } - } - - #region Instance Fields - - private long sizePatchOffset_; - private long crcPatchOffset_; - - #endregion Instance Fields - } - - /// - /// This class assists with writing/reading from Zip files. - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - internal class ZipHelperStream : Stream - { - #region Constructors - - /// - /// Initialise an instance of this class. - /// - /// The name of the file to open. - public ZipHelperStream(string name) - { - stream_ = new FileStream(name, FileMode.Open, FileAccess.ReadWrite); - isOwner_ = true; - } - - /// - /// Initialise a new instance of . - /// - /// The stream to use. - public ZipHelperStream(Stream stream) - { - stream_ = stream; - } - - #endregion Constructors - - /// - /// Get / set a value indicating whether the underlying stream is owned or not. - /// - /// If the stream is owned it is closed when this instance is closed. - public bool IsStreamOwner - { - get { return isOwner_; } - set { isOwner_ = value; } - } - - #region Base Stream Methods - - public override bool CanRead - { - get { return stream_.CanRead; } - } - - public override bool CanSeek - { - get { return stream_.CanSeek; } - } - - public override bool CanTimeout - { - get { return stream_.CanTimeout; } - } - - public override long Length - { - get { return stream_.Length; } - } - - public override long Position - { - get { return stream_.Position; } - set { stream_.Position = value; } - } - - public override bool CanWrite - { - get { return stream_.CanWrite; } - } - - public override void Flush() - { - stream_.Flush(); - } - - public override long Seek(long offset, SeekOrigin origin) - { - return stream_.Seek(offset, origin); - } - - public override void SetLength(long value) - { - stream_.SetLength(value); - } - - public override int Read(byte[] buffer, int offset, int count) - { - return stream_.Read(buffer, offset, count); - } - - public override void Write(byte[] buffer, int offset, int count) - { - stream_.Write(buffer, offset, count); - } - - /// - /// Close the stream. - /// - /// - /// The underlying stream is closed only if is true. - /// - protected override void Dispose(bool disposing) - { - Stream toClose = stream_; - stream_ = null; - if (isOwner_ && (toClose != null)) - { - isOwner_ = false; - toClose.Dispose(); - } - } - - #endregion Base Stream Methods - - // Write the local file header - // TODO: ZipHelperStream.WriteLocalHeader is not yet used and needs checking for ZipFile and ZipOuptutStream usage - private void WriteLocalHeader(ZipEntry entry, EntryPatchData patchData) - { - CompressionMethod method = entry.CompressionMethod; - bool headerInfoAvailable = true; // How to get this? - bool patchEntryHeader = false; - - WriteLEInt(ZipConstants.LocalHeaderSignature); - - WriteLEShort(entry.Version); - WriteLEShort(entry.Flags); - WriteLEShort((byte)method); - WriteLEInt((int)entry.DosTime); - - if (headerInfoAvailable == true) - { - WriteLEInt((int)entry.Crc); - if (entry.LocalHeaderRequiresZip64) - { - WriteLEInt(-1); - WriteLEInt(-1); - } - else - { - WriteLEInt(entry.IsCrypted ? (int)entry.CompressedSize + ZipConstants.CryptoHeaderSize : (int)entry.CompressedSize); - WriteLEInt((int)entry.Size); - } - } - else - { - if (patchData != null) - { - patchData.CrcPatchOffset = stream_.Position; - } - WriteLEInt(0); // Crc - - if (patchData != null) - { - patchData.SizePatchOffset = stream_.Position; - } - - // For local header both sizes appear in Zip64 Extended Information - if (entry.LocalHeaderRequiresZip64 && patchEntryHeader) - { - WriteLEInt(-1); - WriteLEInt(-1); - } - else - { - WriteLEInt(0); // Compressed size - WriteLEInt(0); // Uncompressed size - } - } - - byte[] name = ZipStrings.ConvertToArray(entry.Flags, entry.Name); - - if (name.Length > 0xFFFF) - { - throw new ZipException("Entry name too long."); - } - - var ed = new ZipExtraData(entry.ExtraData); - - if (entry.LocalHeaderRequiresZip64 && (headerInfoAvailable || patchEntryHeader)) - { - ed.StartNewEntry(); - if (headerInfoAvailable) - { - ed.AddLeLong(entry.Size); - ed.AddLeLong(entry.CompressedSize); - } - else - { - ed.AddLeLong(-1); - ed.AddLeLong(-1); - } - ed.AddNewEntry(1); - - if (!ed.Find(1)) - { - throw new ZipException("Internal error cant find extra data"); - } - - if (patchData != null) - { - patchData.SizePatchOffset = ed.CurrentReadIndex; - } - } - else - { - ed.Delete(1); - } - - byte[] extra = ed.GetEntryData(); - - WriteLEShort(name.Length); - WriteLEShort(extra.Length); - - if (name.Length > 0) - { - stream_.Write(name, 0, name.Length); - } - - if (entry.LocalHeaderRequiresZip64 && patchEntryHeader) - { - patchData.SizePatchOffset += stream_.Position; - } - - if (extra.Length > 0) - { - stream_.Write(extra, 0, extra.Length); - } - } - - /// - /// Locates a block with the desired . - /// - /// The signature to find. - /// Location, marking the end of block. - /// Minimum size of the block. - /// The maximum variable data. - /// Returns the offset of the first byte after the signature; -1 if not found - public long LocateBlockWithSignature(int signature, long endLocation, int minimumBlockSize, int maximumVariableData) - { - long pos = endLocation - minimumBlockSize; - if (pos < 0) - { - return -1; - } - - long giveUpMarker = Math.Max(pos - maximumVariableData, 0); - - // TODO: This loop could be optimised for speed. - do - { - if (pos < giveUpMarker) - { - return -1; - } - Seek(pos--, SeekOrigin.Begin); - } while (ReadLEInt() != signature); - - return Position; - } - - /// - /// Write Zip64 end of central directory records (File header and locator). - /// - /// The number of entries in the central directory. - /// The size of entries in the central directory. - /// The offset of the central directory. - public void WriteZip64EndOfCentralDirectory(long noOfEntries, long sizeEntries, long centralDirOffset) - { - long centralSignatureOffset = centralDirOffset + sizeEntries; - WriteLEInt(ZipConstants.Zip64CentralFileHeaderSignature); - WriteLELong(44); // Size of this record (total size of remaining fields in header or full size - 12) - WriteLEShort(ZipConstants.VersionMadeBy); // Version made by - WriteLEShort(ZipConstants.VersionZip64); // Version to extract - WriteLEInt(0); // Number of this disk - WriteLEInt(0); // number of the disk with the start of the central directory - WriteLELong(noOfEntries); // No of entries on this disk - WriteLELong(noOfEntries); // Total No of entries in central directory - WriteLELong(sizeEntries); // Size of the central directory - WriteLELong(centralDirOffset); // offset of start of central directory - // zip64 extensible data sector not catered for here (variable size) - - // Write the Zip64 end of central directory locator - WriteLEInt(ZipConstants.Zip64CentralDirLocatorSignature); - - // no of the disk with the start of the zip64 end of central directory - WriteLEInt(0); - - // relative offset of the zip64 end of central directory record - WriteLELong(centralSignatureOffset); - - // total number of disks - WriteLEInt(1); - } - - /// - /// Write the required records to end the central directory. - /// - /// The number of entries in the directory. - /// The size of the entries in the directory. - /// The start of the central directory. - /// The archive comment. (This can be null). - public void WriteEndOfCentralDirectory(long noOfEntries, long sizeEntries, - long startOfCentralDirectory, byte[] comment) - { - if ((noOfEntries >= 0xffff) || - (startOfCentralDirectory >= 0xffffffff) || - (sizeEntries >= 0xffffffff)) - { - WriteZip64EndOfCentralDirectory(noOfEntries, sizeEntries, startOfCentralDirectory); - } - - WriteLEInt(ZipConstants.EndOfCentralDirectorySignature); - - // TODO: ZipFile Multi disk handling not done - WriteLEShort(0); // number of this disk - WriteLEShort(0); // no of disk with start of central dir - - // Number of entries - if (noOfEntries >= 0xffff) - { - WriteLEUshort(0xffff); // Zip64 marker - WriteLEUshort(0xffff); - } - else - { - WriteLEShort((short)noOfEntries); // entries in central dir for this disk - WriteLEShort((short)noOfEntries); // total entries in central directory - } - - // Size of the central directory - if (sizeEntries >= 0xffffffff) - { - WriteLEUint(0xffffffff); // Zip64 marker - } - else - { - WriteLEInt((int)sizeEntries); - } - - // offset of start of central directory - if (startOfCentralDirectory >= 0xffffffff) - { - WriteLEUint(0xffffffff); // Zip64 marker - } - else - { - WriteLEInt((int)startOfCentralDirectory); - } - - int commentLength = (comment != null) ? comment.Length : 0; - - if (commentLength > 0xffff) - { - throw new ZipException(string.Format("Comment length({0}) is too long can only be 64K", commentLength)); - } - - WriteLEShort(commentLength); - - if (commentLength > 0) - { - Write(comment, 0, comment.Length); - } - } - - #region LE value reading/writing - - /// - /// Read an unsigned short in little endian byte order. - /// - /// Returns the value read. - /// - /// An i/o error occurs. - /// - /// - /// The file ends prematurely - /// - public int ReadLEShort() - { - int byteValue1 = stream_.ReadByte(); - - if (byteValue1 < 0) - { - throw new EndOfStreamException(); - } - - int byteValue2 = stream_.ReadByte(); - if (byteValue2 < 0) - { - throw new EndOfStreamException(); - } - - return byteValue1 | (byteValue2 << 8); - } - - /// - /// Read an int in little endian byte order. - /// - /// Returns the value read. - /// - /// An i/o error occurs. - /// - /// - /// The file ends prematurely - /// - public int ReadLEInt() - { - return ReadLEShort() | (ReadLEShort() << 16); - } - - /// - /// Read a long in little endian byte order. - /// - /// The value read. - public long ReadLELong() - { - return (uint)ReadLEInt() | ((long)ReadLEInt() << 32); - } - - /// - /// Write an unsigned short in little endian byte order. - /// - /// The value to write. - public void WriteLEShort(int value) - { - stream_.WriteByte((byte)(value & 0xff)); - stream_.WriteByte((byte)((value >> 8) & 0xff)); - } - - /// - /// Write a ushort in little endian byte order. - /// - /// The value to write. - public void WriteLEUshort(ushort value) - { - stream_.WriteByte((byte)(value & 0xff)); - stream_.WriteByte((byte)(value >> 8)); - } - - /// - /// Write an int in little endian byte order. - /// - /// The value to write. - public void WriteLEInt(int value) - { - WriteLEShort(value); - WriteLEShort(value >> 16); - } - - /// - /// Write a uint in little endian byte order. - /// - /// The value to write. - public void WriteLEUint(uint value) - { - WriteLEUshort((ushort)(value & 0xffff)); - WriteLEUshort((ushort)(value >> 16)); - } - - /// - /// Write a long in little endian byte order. - /// - /// The value to write. - public void WriteLELong(long value) - { - WriteLEInt((int)value); - WriteLEInt((int)(value >> 32)); - } - - /// - /// Write a ulong in little endian byte order. - /// - /// The value to write. - public void WriteLEUlong(ulong value) - { - WriteLEUint((uint)(value & 0xffffffff)); - WriteLEUint((uint)(value >> 32)); - } - - #endregion LE value reading/writing - - /// - /// Write a data descriptor. - /// - /// The entry to write a descriptor for. - /// Returns the number of descriptor bytes written. - public int WriteDataDescriptor(ZipEntry entry) - { - if (entry == null) - { - throw new ArgumentNullException(nameof(entry)); - } - - int result = 0; - - // Add data descriptor if flagged as required - if ((entry.Flags & (int)GeneralBitFlags.Descriptor) != 0) - { - // The signature is not PKZIP originally but is now described as optional - // in the PKZIP Appnote documenting the format. - WriteLEInt(ZipConstants.DataDescriptorSignature); - WriteLEInt(unchecked((int)(entry.Crc))); - - result += 8; - - if (entry.LocalHeaderRequiresZip64) - { - WriteLELong(entry.CompressedSize); - WriteLELong(entry.Size); - result += 16; - } - else - { - WriteLEInt((int)entry.CompressedSize); - WriteLEInt((int)entry.Size); - result += 8; - } - } - - return result; - } - - /// - /// Read data descriptor at the end of compressed data. - /// - /// if set to true [zip64]. - /// The data to fill in. - /// Returns the number of bytes read in the descriptor. - public void ReadDataDescriptor(bool zip64, DescriptorData data) - { - int intValue = ReadLEInt(); - - // In theory this may not be a descriptor according to PKZIP appnote. - // In practice its always there. - if (intValue != ZipConstants.DataDescriptorSignature) - { - throw new ZipException("Data descriptor signature not found"); - } - - data.Crc = ReadLEInt(); - - if (zip64) - { - data.CompressedSize = ReadLELong(); - data.Size = ReadLELong(); - } - else - { - data.CompressedSize = ReadLEInt(); - data.Size = ReadLEInt(); - } - } - - #region Instance Fields - - private bool isOwner_; - private Stream stream_; - - #endregion Instance Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipInputStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipInputStream.cs deleted file mode 100644 index cf799d098..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipInputStream.cs +++ /dev/null @@ -1,728 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Checksum; -using MelonLoader.ICSharpCode.SharpZipLib.Encryption; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams; -using System; -using System.IO; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// This is an InflaterInputStream that reads the files baseInputStream an zip archive - /// one after another. It has a special method to get the zip entry of - /// the next file. The zip entry contains information about the file name - /// size, compressed size, Crc, etc. - /// It includes support for Stored and Deflated entries. - ///
- ///
Author of the original java version : Jochen Hoenicke - ///
- /// - /// This sample shows how to read a zip file - /// - /// using System; - /// using System.Text; - /// using System.IO; - /// - /// using MelonLoader.ICSharpCode.SharpZipLib.Zip; - /// - /// class MainClass - /// { - /// public static void Main(string[] args) - /// { - /// using ( ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]))) { - /// - /// ZipEntry theEntry; - /// const int size = 2048; - /// byte[] data = new byte[2048]; - /// - /// while ((theEntry = s.GetNextEntry()) != null) { - /// if ( entry.IsFile ) { - /// Console.Write("Show contents (y/n) ?"); - /// if (Console.ReadLine() == "y") { - /// while (true) { - /// size = s.Read(data, 0, data.Length); - /// if (size > 0) { - /// Console.Write(new ASCIIEncoding().GetString(data, 0, size)); - /// } else { - /// break; - /// } - /// } - /// } - /// } - /// } - /// } - /// } - /// } - /// - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class ZipInputStream : InflaterInputStream - { - #region Instance Fields - - /// - /// Delegate for reading bytes from a stream. - /// - private delegate int ReadDataHandler(byte[] b, int offset, int length); - - /// - /// The current reader this instance. - /// - private ReadDataHandler internalReader; - - private Crc32 crc = new Crc32(); - private ZipEntry entry; - - private long size; - private CompressionMethod method; - private int flags; - private string password; - - #endregion Instance Fields - - #region Constructors - - /// - /// Creates a new Zip input stream, for reading a zip archive. - /// - /// The underlying providing data. - public ZipInputStream(Stream baseInputStream) - : base(baseInputStream, new Inflater(true)) - { - internalReader = new ReadDataHandler(ReadingNotAvailable); - } - - /// - /// Creates a new Zip input stream, for reading a zip archive. - /// - /// The underlying providing data. - /// Size of the buffer. - public ZipInputStream(Stream baseInputStream, int bufferSize) - : base(baseInputStream, new Inflater(true), bufferSize) - { - internalReader = new ReadDataHandler(ReadingNotAvailable); - } - - #endregion Constructors - - /// - /// Optional password used for encryption when non-null - /// - /// A password for all encrypted entries in this - public string Password - { - get - { - return password; - } - set - { - password = value; - } - } - - /// - /// Gets a value indicating if there is a current entry and it can be decompressed - /// - /// - /// The entry can only be decompressed if the library supports the zip features required to extract it. - /// See the ZipEntry Version property for more details. - /// - /// Since uses the local headers for extraction, entries with no compression combined with the - /// flag set, cannot be extracted as the end of the entry data cannot be deduced. - /// - public bool CanDecompressEntry - => entry != null - && IsEntryCompressionMethodSupported(entry) - && entry.CanDecompress - && (!entry.HasFlag(GeneralBitFlags.Descriptor) || entry.CompressionMethod != CompressionMethod.Stored || entry.IsCrypted); - - /// - /// Is the compression method for the specified entry supported? - /// - /// - /// Uses entry.CompressionMethodForHeader so that entries of type WinZipAES will be rejected. - /// - /// the entry to check. - /// true if the compression method is supported, false if not. - private static bool IsEntryCompressionMethodSupported(ZipEntry entry) - { - var entryCompressionMethod = entry.CompressionMethodForHeader; - - return entryCompressionMethod == CompressionMethod.Deflated || - entryCompressionMethod == CompressionMethod.Stored; - } - - /// - /// Advances to the next entry in the archive - /// - /// - /// The next entry in the archive or null if there are no more entries. - /// - /// - /// If the previous entry is still open CloseEntry is called. - /// - /// - /// Input stream is closed - /// - /// - /// Password is not set, password is invalid, compression method is invalid, - /// version required to extract is not supported - /// - public ZipEntry GetNextEntry() - { - if (crc == null) - { - throw new InvalidOperationException("Closed."); - } - - if (entry != null) - { - CloseEntry(); - } - - int header = inputBuffer.ReadLeInt(); - - if (header == ZipConstants.CentralHeaderSignature || - header == ZipConstants.EndOfCentralDirectorySignature || - header == ZipConstants.CentralHeaderDigitalSignature || - header == ZipConstants.ArchiveExtraDataSignature || - header == ZipConstants.Zip64CentralFileHeaderSignature) - { - // No more individual entries exist - Dispose(); - return null; - } - - // -jr- 07-Dec-2003 Ignore spanning temporary signatures if found - // Spanning signature is same as descriptor signature and is untested as yet. - if ((header == ZipConstants.SpanningTempSignature) || (header == ZipConstants.SpanningSignature)) - { - header = inputBuffer.ReadLeInt(); - } - - if (header != ZipConstants.LocalHeaderSignature) - { - throw new ZipException("Wrong Local header signature: 0x" + String.Format("{0:X}", header)); - } - - var versionRequiredToExtract = (short)inputBuffer.ReadLeShort(); - - flags = inputBuffer.ReadLeShort(); - method = (CompressionMethod)inputBuffer.ReadLeShort(); - var dostime = (uint)inputBuffer.ReadLeInt(); - int crc2 = inputBuffer.ReadLeInt(); - csize = inputBuffer.ReadLeInt(); - size = inputBuffer.ReadLeInt(); - int nameLen = inputBuffer.ReadLeShort(); - int extraLen = inputBuffer.ReadLeShort(); - - bool isCrypted = (flags & 1) == 1; - - byte[] buffer = new byte[nameLen]; - inputBuffer.ReadRawBuffer(buffer); - - string name = ZipStrings.ConvertToStringExt(flags, buffer); - - entry = new ZipEntry(name, versionRequiredToExtract, ZipConstants.VersionMadeBy, method) - { - Flags = flags, - }; - - if ((flags & 8) == 0) - { - entry.Crc = crc2 & 0xFFFFFFFFL; - entry.Size = size & 0xFFFFFFFFL; - entry.CompressedSize = csize & 0xFFFFFFFFL; - - entry.CryptoCheckValue = (byte)((crc2 >> 24) & 0xff); - } - else - { - // This allows for GNU, WinZip and possibly other archives, the PKZIP spec - // says these values are zero under these circumstances. - if (crc2 != 0) - { - entry.Crc = crc2 & 0xFFFFFFFFL; - } - - if (size != 0) - { - entry.Size = size & 0xFFFFFFFFL; - } - - if (csize != 0) - { - entry.CompressedSize = csize & 0xFFFFFFFFL; - } - - entry.CryptoCheckValue = (byte)((dostime >> 8) & 0xff); - } - - entry.DosTime = dostime; - - // If local header requires Zip64 is true then the extended header should contain - // both values. - - // Handle extra data if present. This can set/alter some fields of the entry. - if (extraLen > 0) - { - byte[] extra = new byte[extraLen]; - inputBuffer.ReadRawBuffer(extra); - entry.ExtraData = extra; - } - - entry.ProcessExtraData(true); - if (entry.CompressedSize >= 0) - { - csize = entry.CompressedSize; - } - - if (entry.Size >= 0) - { - size = entry.Size; - } - - if (method == CompressionMethod.Stored && (!isCrypted && csize != size || (isCrypted && csize - ZipConstants.CryptoHeaderSize != size))) - { - throw new ZipException("Stored, but compressed != uncompressed"); - } - - // Determine how to handle reading of data if this is attempted. - if (IsEntryCompressionMethodSupported(entry)) - { - internalReader = new ReadDataHandler(InitialRead); - } - else - { - internalReader = new ReadDataHandler(ReadingNotSupported); - } - - return entry; - } - - /// - /// Read data descriptor at the end of compressed data. - /// - private void ReadDataDescriptor() - { - if (inputBuffer.ReadLeInt() != ZipConstants.DataDescriptorSignature) - { - throw new ZipException("Data descriptor signature not found"); - } - - entry.Crc = inputBuffer.ReadLeInt() & 0xFFFFFFFFL; - - if (entry.LocalHeaderRequiresZip64) - { - csize = inputBuffer.ReadLeLong(); - size = inputBuffer.ReadLeLong(); - } - else - { - csize = inputBuffer.ReadLeInt(); - size = inputBuffer.ReadLeInt(); - } - entry.CompressedSize = csize; - entry.Size = size; - } - - /// - /// Complete cleanup as the final part of closing. - /// - /// True if the crc value should be tested - private void CompleteCloseEntry(bool testCrc) - { - StopDecrypting(); - - if ((flags & 8) != 0) - { - ReadDataDescriptor(); - } - - size = 0; - - if (testCrc && - ((crc.Value & 0xFFFFFFFFL) != entry.Crc) && (entry.Crc != -1)) - { - throw new ZipException("CRC mismatch"); - } - - crc.Reset(); - - if (method == CompressionMethod.Deflated) - { - inf.Reset(); - } - entry = null; - } - - /// - /// Closes the current zip entry and moves to the next one. - /// - /// - /// The stream is closed - /// - /// - /// The Zip stream ends early - /// - public void CloseEntry() - { - if (crc == null) - { - throw new InvalidOperationException("Closed"); - } - - if (entry == null) - { - return; - } - - if (method == CompressionMethod.Deflated) - { - if ((flags & 8) != 0) - { - // We don't know how much we must skip, read until end. - byte[] tmp = new byte[4096]; - - // Read will close this entry - while (Read(tmp, 0, tmp.Length) > 0) - { - } - return; - } - - csize -= inf.TotalIn; - inputBuffer.Available += inf.RemainingInput; - } - - if ((inputBuffer.Available > csize) && (csize >= 0)) - { - inputBuffer.Available = (int)((long)inputBuffer.Available - csize); - } - else - { - csize -= inputBuffer.Available; - inputBuffer.Available = 0; - while (csize != 0) - { - long skipped = Skip(csize); - - if (skipped <= 0) - { - throw new ZipException("Zip archive ends early."); - } - - csize -= skipped; - } - } - - CompleteCloseEntry(false); - } - - /// - /// Returns 1 if there is an entry available - /// Otherwise returns 0. - /// - public override int Available - { - get - { - return entry != null ? 1 : 0; - } - } - - /// - /// Returns the current size that can be read from the current entry if available - /// - /// Thrown if the entry size is not known. - /// Thrown if no entry is currently available. - public override long Length - { - get - { - if (entry != null) - { - if (entry.Size >= 0) - { - return entry.Size; - } - else - { - throw new ZipException("Length not available for the current entry"); - } - } - else - { - throw new InvalidOperationException("No current entry"); - } - } - } - - /// - /// Reads a byte from the current zip entry. - /// - /// - /// The byte or -1 if end of stream is reached. - /// - public override int ReadByte() - { - byte[] b = new byte[1]; - if (Read(b, 0, 1) <= 0) - { - return -1; - } - return b[0] & 0xff; - } - - /// - /// Handle attempts to read by throwing an . - /// - /// The destination array to store data in. - /// The offset at which data read should be stored. - /// The maximum number of bytes to read. - /// Returns the number of bytes actually read. - private int ReadingNotAvailable(byte[] destination, int offset, int count) - { - throw new InvalidOperationException("Unable to read from this stream"); - } - - /// - /// Handle attempts to read from this entry by throwing an exception - /// - private int ReadingNotSupported(byte[] destination, int offset, int count) - { - throw new ZipException("The compression method for this entry is not supported"); - } - - /// - /// Handle attempts to read from this entry by throwing an exception - /// - private int StoredDescriptorEntry(byte[] destination, int offset, int count) => - throw new StreamUnsupportedException( - "The combination of Stored compression method and Descriptor flag is not possible to read using ZipInputStream"); - - - /// - /// Perform the initial read on an entry which may include - /// reading encryption headers and setting up inflation. - /// - /// The destination to fill with data read. - /// The offset to start reading at. - /// The maximum number of bytes to read. - /// The actual number of bytes read. - private int InitialRead(byte[] destination, int offset, int count) - { - var usesDescriptor = (entry.Flags & (int)GeneralBitFlags.Descriptor) != 0; - - // Handle encryption if required. - if (entry.IsCrypted) - { - if (password == null) - { - throw new ZipException("No password set."); - } - - // Generate and set crypto transform... - var managed = new PkzipClassicManaged(); - byte[] key = PkzipClassic.GenerateKeys(ZipStrings.ConvertToArray(password)); - - inputBuffer.CryptoTransform = managed.CreateDecryptor(key, null); - - byte[] cryptbuffer = new byte[ZipConstants.CryptoHeaderSize]; - inputBuffer.ReadClearTextBuffer(cryptbuffer, 0, ZipConstants.CryptoHeaderSize); - - if (cryptbuffer[ZipConstants.CryptoHeaderSize - 1] != entry.CryptoCheckValue) - { - throw new ZipException("Invalid password"); - } - - if (csize >= ZipConstants.CryptoHeaderSize) - { - csize -= ZipConstants.CryptoHeaderSize; - } - else if (!usesDescriptor) - { - throw new ZipException($"Entry compressed size {csize} too small for encryption"); - } - } - else - { - inputBuffer.CryptoTransform = null; - } - - if (csize > 0 || usesDescriptor) - { - if (method == CompressionMethod.Deflated && inputBuffer.Available > 0) - { - inputBuffer.SetInflaterInput(inf); - } - - // It's not possible to know how many bytes to read when using "Stored" compression (unless using encryption) - if (!entry.IsCrypted && method == CompressionMethod.Stored && usesDescriptor) - { - internalReader = StoredDescriptorEntry; - return StoredDescriptorEntry(destination, offset, count); - } - - if (!CanDecompressEntry) - { - internalReader = ReadingNotSupported; - return ReadingNotSupported(destination, offset, count); - } - - internalReader = BodyRead; - return BodyRead(destination, offset, count); - } - - - internalReader = ReadingNotAvailable; - return 0; - } - - /// - /// Read a block of bytes from the stream. - /// - /// The destination for the bytes. - /// The index to start storing data. - /// The number of bytes to attempt to read. - /// Returns the number of bytes read. - /// Zero bytes read means end of stream. - public override int Read(byte[] buffer, int offset, int count) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (offset < 0) - { - throw new ArgumentOutOfRangeException(nameof(offset), "Cannot be negative"); - } - - if (count < 0) - { - throw new ArgumentOutOfRangeException(nameof(count), "Cannot be negative"); - } - - if ((buffer.Length - offset) < count) - { - throw new ArgumentException("Invalid offset/count combination"); - } - - return internalReader(buffer, offset, count); - } - - /// - /// Reads a block of bytes from the current zip entry. - /// - /// - /// The number of bytes read (this may be less than the length requested, even before the end of stream), or 0 on end of stream. - /// - /// - /// An i/o error occurred. - /// - /// - /// The deflated stream is corrupted. - /// - /// - /// The stream is not open. - /// - private int BodyRead(byte[] buffer, int offset, int count) - { - if (crc == null) - { - throw new InvalidOperationException("Closed"); - } - - if ((entry == null) || (count <= 0)) - { - return 0; - } - - if (offset + count > buffer.Length) - { - throw new ArgumentException("Offset + count exceeds buffer size"); - } - - bool finished = false; - - switch (method) - { - case CompressionMethod.Deflated: - count = base.Read(buffer, offset, count); - if (count <= 0) - { - if (!inf.IsFinished) - { - throw new ZipException("Inflater not finished!"); - } - inputBuffer.Available = inf.RemainingInput; - - // A csize of -1 is from an unpatched local header - if ((flags & 8) == 0 && - (inf.TotalIn != csize && csize != 0xFFFFFFFF && csize != -1 || inf.TotalOut != size)) - { - throw new ZipException("Size mismatch: " + csize + ";" + size + " <-> " + inf.TotalIn + ";" + inf.TotalOut); - } - inf.Reset(); - finished = true; - } - break; - - case CompressionMethod.Stored: - if ((count > csize) && (csize >= 0)) - { - count = (int)csize; - } - - if (count > 0) - { - count = inputBuffer.ReadClearTextBuffer(buffer, offset, count); - if (count > 0) - { - csize -= count; - size -= count; - } - } - - if (csize == 0) - { - finished = true; - } - else - { - if (count < 0) - { - throw new ZipException("EOF in stored block"); - } - } - break; - } - - if (count > 0) - { - crc.Update(new ArraySegment(buffer, offset, count)); - } - - if (finished) - { - CompleteCloseEntry(true); - } - - return count; - } - - /// - /// Closes the zip input stream - /// - protected override void Dispose(bool disposing) - { - internalReader = new ReadDataHandler(ReadingNotAvailable); - crc = null; - entry = null; - - base.Dispose(disposing); - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipNameTransform.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipNameTransform.cs deleted file mode 100644 index 48e5d3b5d..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipNameTransform.cs +++ /dev/null @@ -1,315 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Core; -using System; -using System.IO; -using System.Text; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// ZipNameTransform transforms names as per the Zip file naming convention. - /// - /// The use of absolute names is supported although its use is not valid - /// according to Zip naming conventions, and should not be used if maximum compatability is desired. - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class ZipNameTransform : INameTransform - { - #region Constructors - - /// - /// Initialize a new instance of - /// - public ZipNameTransform() - { - } - - /// - /// Initialize a new instance of - /// - /// The string to trim from the front of paths if found. - public ZipNameTransform(string trimPrefix) - { - TrimPrefix = trimPrefix; - } - - #endregion Constructors - - /// - /// Static constructor. - /// - static ZipNameTransform() - { - char[] invalidPathChars; - invalidPathChars = Path.GetInvalidPathChars(); - int howMany = invalidPathChars.Length + 2; - - InvalidEntryCharsRelaxed = new char[howMany]; - Array.Copy(invalidPathChars, 0, InvalidEntryCharsRelaxed, 0, invalidPathChars.Length); - InvalidEntryCharsRelaxed[howMany - 1] = '*'; - InvalidEntryCharsRelaxed[howMany - 2] = '?'; - - howMany = invalidPathChars.Length + 4; - InvalidEntryChars = new char[howMany]; - Array.Copy(invalidPathChars, 0, InvalidEntryChars, 0, invalidPathChars.Length); - InvalidEntryChars[howMany - 1] = ':'; - InvalidEntryChars[howMany - 2] = '\\'; - InvalidEntryChars[howMany - 3] = '*'; - InvalidEntryChars[howMany - 4] = '?'; - } - - /// - /// Transform a windows directory name according to the Zip file naming conventions. - /// - /// The directory name to transform. - /// The transformed name. - public string TransformDirectory(string name) - { - name = TransformFile(name); - if (name.Length > 0) - { - if (!name.EndsWith("/", StringComparison.Ordinal)) - { - name += "/"; - } - } - else - { - throw new ZipException("Cannot have an empty directory name"); - } - return name; - } - - /// - /// Transform a windows file name according to the Zip file naming conventions. - /// - /// The file name to transform. - /// The transformed name. - public string TransformFile(string name) - { - if (name != null) - { - string lowerName = name.ToLower(); - if ((trimPrefix_ != null) && (lowerName.IndexOf(trimPrefix_, StringComparison.Ordinal) == 0)) - { - name = name.Substring(trimPrefix_.Length); - } - - name = name.Replace(@"\", "/"); - name = PathUtils.DropPathRoot(name); - - // Drop any leading and trailing slashes. - name = name.Trim('/'); - - // Convert consecutive // characters to / - int index = name.IndexOf("//", StringComparison.Ordinal); - while (index >= 0) - { - name = name.Remove(index, 1); - index = name.IndexOf("//", StringComparison.Ordinal); - } - - name = MakeValidName(name, '_'); - } - else - { - name = string.Empty; - } - return name; - } - - /// - /// Get/set the path prefix to be trimmed from paths if present. - /// - /// The prefix is trimmed before any conversion from - /// a windows path is done. - public string TrimPrefix - { - get { return trimPrefix_; } - set - { - trimPrefix_ = value; - if (trimPrefix_ != null) - { - trimPrefix_ = trimPrefix_.ToLower(); - } - } - } - - /// - /// Force a name to be valid by replacing invalid characters with a fixed value - /// - /// The name to force valid - /// The replacement character to use. - /// Returns a valid name - private static string MakeValidName(string name, char replacement) - { - int index = name.IndexOfAny(InvalidEntryChars); - if (index >= 0) - { - var builder = new StringBuilder(name); - - while (index >= 0) - { - builder[index] = replacement; - - if (index >= name.Length) - { - index = -1; - } - else - { - index = name.IndexOfAny(InvalidEntryChars, index + 1); - } - } - name = builder.ToString(); - } - - if (name.Length > 0xffff) - { - throw new PathTooLongException(); - } - - return name; - } - - /// - /// Test a name to see if it is a valid name for a zip entry. - /// - /// The name to test. - /// If true checking is relaxed about windows file names and absolute paths. - /// Returns true if the name is a valid zip name; false otherwise. - /// Zip path names are actually in Unix format, and should only contain relative paths. - /// This means that any path stored should not contain a drive or - /// device letter, or a leading slash. All slashes should forward slashes '/'. - /// An empty name is valid for a file where the input comes from standard input. - /// A null name is not considered valid. - /// - public static bool IsValidName(string name, bool relaxed) - { - bool result = (name != null); - - if (result) - { - if (relaxed) - { - result = name.IndexOfAny(InvalidEntryCharsRelaxed) < 0; - } - else - { - result = - (name.IndexOfAny(InvalidEntryChars) < 0) && - (name.IndexOf('/') != 0); - } - } - - return result; - } - - /// - /// Test a name to see if it is a valid name for a zip entry. - /// - /// The name to test. - /// Returns true if the name is a valid zip name; false otherwise. - /// Zip path names are actually in unix format, - /// and should only contain relative paths if a path is present. - /// This means that the path stored should not contain a drive or - /// device letter, or a leading slash. All slashes should forward slashes '/'. - /// An empty name is valid where the input comes from standard input. - /// A null name is not considered valid. - /// - public static bool IsValidName(string name) - { - bool result = - (name != null) && - (name.IndexOfAny(InvalidEntryChars) < 0) && - (name.IndexOf('/') != 0) - ; - return result; - } - - #region Instance Fields - - private string trimPrefix_; - - #endregion Instance Fields - - #region Class Fields - - private static readonly char[] InvalidEntryChars; - private static readonly char[] InvalidEntryCharsRelaxed; - - #endregion Class Fields - } - - /// - /// An implementation of INameTransform that transforms entry paths as per the Zip file naming convention. - /// Strips path roots and puts directory separators in the correct format ('/') - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class PathTransformer : INameTransform - { - /// - /// Initialize a new instance of - /// - public PathTransformer() - { - } - - /// - /// Transform a windows directory name according to the Zip file naming conventions. - /// - /// The directory name to transform. - /// The transformed name. - public string TransformDirectory(string name) - { - name = TransformFile(name); - - if (name.Length > 0) - { - if (!name.EndsWith("/", StringComparison.Ordinal)) - { - name += "/"; - } - } - else - { - throw new ZipException("Cannot have an empty directory name"); - } - - return name; - } - - /// - /// Transform a windows file name according to the Zip file naming conventions. - /// - /// The file name to transform. - /// The transformed name. - public string TransformFile(string name) - { - if (name != null) - { - // Put separators in the expected format. - name = name.Replace(@"\", "/"); - - // Remove the path root. - name = PathUtils.DropPathRoot(name); - - // Drop any leading and trailing slashes. - name = name.Trim('/'); - - // Convert consecutive // characters to / - int index = name.IndexOf("//", StringComparison.Ordinal); - while (index >= 0) - { - name = name.Remove(index, 1); - index = name.IndexOf("//", StringComparison.Ordinal); - } - } - else - { - name = string.Empty; - } - - return name; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipOutputStream.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipOutputStream.cs deleted file mode 100644 index 60c32371f..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipOutputStream.cs +++ /dev/null @@ -1,1078 +0,0 @@ -using MelonLoader.ICSharpCode.SharpZipLib.Checksum; -using MelonLoader.ICSharpCode.SharpZipLib.Core; -using MelonLoader.ICSharpCode.SharpZipLib.Encryption; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression; -using MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression.Streams; -using System; -using System.Collections.Generic; -using System.IO; -using System.Security.Cryptography; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// This is a DeflaterOutputStream that writes the files into a zip - /// archive one after another. It has a special method to start a new - /// zip entry. The zip entries contains information about the file name - /// size, compressed size, CRC, etc. - /// - /// It includes support for Stored and Deflated entries. - /// This class is not thread safe. - ///
- ///
Author of the original java version : Jochen Hoenicke - ///
- /// This sample shows how to create a zip file - /// - /// using System; - /// using System.IO; - /// - /// using MelonLoader.ICSharpCode.SharpZipLib.Core; - /// using MelonLoader.ICSharpCode.SharpZipLib.Zip; - /// - /// class MainClass - /// { - /// public static void Main(string[] args) - /// { - /// string[] filenames = Directory.GetFiles(args[0]); - /// byte[] buffer = new byte[4096]; - /// - /// using ( ZipOutputStream s = new ZipOutputStream(File.Create(args[1])) ) { - /// - /// s.SetLevel(9); // 0 - store only to 9 - means best compression - /// - /// foreach (string file in filenames) { - /// ZipEntry entry = new ZipEntry(file); - /// s.PutNextEntry(entry); - /// - /// using (FileStream fs = File.OpenRead(file)) { - /// StreamUtils.Copy(fs, s, buffer); - /// } - /// } - /// } - /// } - /// } - /// - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public class ZipOutputStream : DeflaterOutputStream - { - #region Constructors - - /// - /// Creates a new Zip output stream, writing a zip archive. - /// - /// - /// The output stream to which the archive contents are written. - /// - public ZipOutputStream(Stream baseOutputStream) - : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true)) - { - } - - /// - /// Creates a new Zip output stream, writing a zip archive. - /// - /// The output stream to which the archive contents are written. - /// Size of the buffer to use. - public ZipOutputStream(Stream baseOutputStream, int bufferSize) - : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true), bufferSize) - { - } - - #endregion Constructors - - /// - /// Gets a flag value of true if the central header has been added for this archive; false if it has not been added. - /// - /// No further entries can be added once this has been done. - public bool IsFinished - { - get - { - return entries == null; - } - } - - /// - /// Set the zip file comment. - /// - /// - /// The comment text for the entire archive. - /// - /// - /// The converted comment is longer than 0xffff bytes. - /// - public void SetComment(string comment) - { - // TODO: Its not yet clear how to handle unicode comments here. - byte[] commentBytes = ZipStrings.ConvertToArray(comment); - if (commentBytes.Length > 0xffff) - { - throw new ArgumentOutOfRangeException(nameof(comment)); - } - zipComment = commentBytes; - } - - /// - /// Sets the compression level. The new level will be activated - /// immediately. - /// - /// The new compression level (1 to 9). - /// - /// Level specified is not supported. - /// - /// - public void SetLevel(int level) - { - deflater_.SetLevel(level); - defaultCompressionLevel = level; - } - - /// - /// Get the current deflater compression level - /// - /// The current compression level - public int GetLevel() - { - return deflater_.GetLevel(); - } - - /// - /// Get / set a value indicating how Zip64 Extension usage is determined when adding entries. - /// - /// Older archivers may not understand Zip64 extensions. - /// If backwards compatability is an issue be careful when adding entries to an archive. - /// Setting this property to off is workable but less desirable as in those circumstances adding a file - /// larger then 4GB will fail. - public UseZip64 UseZip64 - { - get { return useZip64_; } - set { useZip64_ = value; } - } - - /// - /// Used for transforming the names of entries added by . - /// Defaults to , set to null to disable transforms and use names as supplied. - /// - public INameTransform NameTransform { get; set; } = new PathTransformer(); - - /// - /// Get/set the password used for encryption. - /// - /// When set to null or if the password is empty no encryption is performed - public string Password - { - get - { - return password; - } - set - { - if ((value != null) && (value.Length == 0)) - { - password = null; - } - else - { - password = value; - } - } - } - - /// - /// Write an unsigned short in little endian byte order. - /// - private void WriteLeShort(int value) - { - unchecked - { - baseOutputStream_.WriteByte((byte)(value & 0xff)); - baseOutputStream_.WriteByte((byte)((value >> 8) & 0xff)); - } - } - - /// - /// Write an int in little endian byte order. - /// - private void WriteLeInt(int value) - { - unchecked - { - WriteLeShort(value); - WriteLeShort(value >> 16); - } - } - - /// - /// Write an int in little endian byte order. - /// - private void WriteLeLong(long value) - { - unchecked - { - WriteLeInt((int)value); - WriteLeInt((int)(value >> 32)); - } - } - - // Apply any configured transforms/cleaning to the name of the supplied entry. - private void TransformEntryName(ZipEntry entry) - { - if (this.NameTransform != null) - { - if (entry.IsDirectory) - { - entry.Name = this.NameTransform.TransformDirectory(entry.Name); - } - else - { - entry.Name = this.NameTransform.TransformFile(entry.Name); - } - } - } - - /// - /// Starts a new Zip entry. It automatically closes the previous - /// entry if present. - /// All entry elements bar name are optional, but must be correct if present. - /// If the compression method is stored and the output is not patchable - /// the compression for that entry is automatically changed to deflate level 0 - /// - /// - /// the entry. - /// - /// - /// if entry passed is null. - /// - /// - /// if an I/O error occured. - /// - /// - /// if stream was finished - /// - /// - /// Too many entries in the Zip file
- /// Entry name is too long
- /// Finish has already been called
- ///
- /// - /// The Compression method specified for the entry is unsupported. - /// - public void PutNextEntry(ZipEntry entry) - { - if (entry == null) - { - throw new ArgumentNullException(nameof(entry)); - } - - if (entries == null) - { - throw new InvalidOperationException("ZipOutputStream was finished"); - } - - if (curEntry != null) - { - CloseEntry(); - } - - if (entries.Count == int.MaxValue) - { - throw new ZipException("Too many entries for Zip file"); - } - - CompressionMethod method = entry.CompressionMethod; - - // Check that the compression is one that we support - if (method != CompressionMethod.Deflated && method != CompressionMethod.Stored) - { - throw new NotImplementedException("Compression method not supported"); - } - - // A password must have been set in order to add AES encrypted entries - if (entry.AESKeySize > 0 && string.IsNullOrEmpty(this.Password)) - { - throw new InvalidOperationException("The Password property must be set before AES encrypted entries can be added"); - } - - int compressionLevel = defaultCompressionLevel; - - // Clear flags that the library manages internally - entry.Flags &= (int)GeneralBitFlags.UnicodeText; - patchEntryHeader = false; - - bool headerInfoAvailable; - - // No need to compress - definitely no data. - if (entry.Size == 0) - { - entry.CompressedSize = entry.Size; - entry.Crc = 0; - method = CompressionMethod.Stored; - headerInfoAvailable = true; - } - else - { - headerInfoAvailable = (entry.Size >= 0) && entry.HasCrc && entry.CompressedSize >= 0; - - // Switch to deflation if storing isnt possible. - if (method == CompressionMethod.Stored) - { - if (!headerInfoAvailable) - { - if (!CanPatchEntries) - { - // Can't patch entries so storing is not possible. - method = CompressionMethod.Deflated; - compressionLevel = 0; - } - } - else // entry.size must be > 0 - { - entry.CompressedSize = entry.Size; - headerInfoAvailable = entry.HasCrc; - } - } - } - - if (headerInfoAvailable == false) - { - if (CanPatchEntries == false) - { - // Only way to record size and compressed size is to append a data descriptor - // after compressed data. - - // Stored entries of this form have already been converted to deflating. - entry.Flags |= 8; - } - else - { - patchEntryHeader = true; - } - } - - if (Password != null) - { - entry.IsCrypted = true; - if (entry.Crc < 0) - { - // Need to append a data descriptor as the crc isnt available for use - // with encryption, the date is used instead. Setting the flag - // indicates this to the decompressor. - entry.Flags |= 8; - } - } - - entry.Offset = offset; - entry.CompressionMethod = (CompressionMethod)method; - - curMethod = method; - sizePatchPos = -1; - - if ((useZip64_ == UseZip64.On) || ((entry.Size < 0) && (useZip64_ == UseZip64.Dynamic))) - { - entry.ForceZip64(); - } - - // Write the local file header - WriteLeInt(ZipConstants.LocalHeaderSignature); - - WriteLeShort(entry.Version); - WriteLeShort(entry.Flags); - WriteLeShort((byte)entry.CompressionMethodForHeader); - WriteLeInt((int)entry.DosTime); - - // TODO: Refactor header writing. Its done in several places. - if (headerInfoAvailable) - { - WriteLeInt((int)entry.Crc); - if (entry.LocalHeaderRequiresZip64) - { - WriteLeInt(-1); - WriteLeInt(-1); - } - else - { - WriteLeInt((int)entry.CompressedSize + entry.EncryptionOverheadSize); - WriteLeInt((int)entry.Size); - } - } - else - { - if (patchEntryHeader) - { - crcPatchPos = baseOutputStream_.Position; - } - WriteLeInt(0); // Crc - - if (patchEntryHeader) - { - sizePatchPos = baseOutputStream_.Position; - } - - // For local header both sizes appear in Zip64 Extended Information - if (entry.LocalHeaderRequiresZip64 || patchEntryHeader) - { - WriteLeInt(-1); - WriteLeInt(-1); - } - else - { - WriteLeInt(0); // Compressed size - WriteLeInt(0); // Uncompressed size - } - } - - // Apply any required transforms to the entry name, and then convert to byte array format. - TransformEntryName(entry); - byte[] name = ZipStrings.ConvertToArray(entry.Flags, entry.Name); - - if (name.Length > 0xFFFF) - { - throw new ZipException("Entry name too long."); - } - - var ed = new ZipExtraData(entry.ExtraData); - - if (entry.LocalHeaderRequiresZip64) - { - ed.StartNewEntry(); - if (headerInfoAvailable) - { - ed.AddLeLong(entry.Size); - ed.AddLeLong(entry.CompressedSize + entry.EncryptionOverheadSize); - } - else - { - ed.AddLeLong(-1); - ed.AddLeLong(-1); - } - ed.AddNewEntry(1); - - if (!ed.Find(1)) - { - throw new ZipException("Internal error cant find extra data"); - } - - if (patchEntryHeader) - { - sizePatchPos = ed.CurrentReadIndex; - } - } - else - { - ed.Delete(1); - } - - if (entry.AESKeySize > 0) - { - AddExtraDataAES(entry, ed); - } - byte[] extra = ed.GetEntryData(); - - WriteLeShort(name.Length); - WriteLeShort(extra.Length); - - if (name.Length > 0) - { - baseOutputStream_.Write(name, 0, name.Length); - } - - if (entry.LocalHeaderRequiresZip64 && patchEntryHeader) - { - sizePatchPos += baseOutputStream_.Position; - } - - if (extra.Length > 0) - { - baseOutputStream_.Write(extra, 0, extra.Length); - } - - offset += ZipConstants.LocalHeaderBaseSize + name.Length + extra.Length; - // Fix offsetOfCentraldir for AES - if (entry.AESKeySize > 0) - offset += entry.AESOverheadSize; - - // Activate the entry. - curEntry = entry; - crc.Reset(); - if (method == CompressionMethod.Deflated) - { - deflater_.Reset(); - deflater_.SetLevel(compressionLevel); - } - size = 0; - - if (entry.IsCrypted) - { - if (entry.AESKeySize > 0) - { - WriteAESHeader(entry); - } - else - { - if (entry.Crc < 0) - { // so testing Zip will says its ok - WriteEncryptionHeader(entry.DosTime << 16); - } - else - { - WriteEncryptionHeader(entry.Crc); - } - } - } - } - - /// - /// Closes the current entry, updating header and footer information as required - /// - /// - /// Invalid entry field values. - /// - /// - /// An I/O error occurs. - /// - /// - /// No entry is active. - /// - public void CloseEntry() - { - if (curEntry == null) - { - throw new InvalidOperationException("No open entry"); - } - - long csize = size; - - // First finish the deflater, if appropriate - if (curMethod == CompressionMethod.Deflated) - { - if (size >= 0) - { - base.Finish(); - csize = deflater_.TotalOut; - } - else - { - deflater_.Reset(); - } - } - else if (curMethod == CompressionMethod.Stored) - { - // This is done by Finish() for Deflated entries, but we need to do it - // ourselves for Stored ones - base.GetAuthCodeIfAES(); - } - - // Write the AES Authentication Code (a hash of the compressed and encrypted data) - if (curEntry.AESKeySize > 0) - { - baseOutputStream_.Write(AESAuthCode, 0, 10); - // Always use 0 as CRC for AE-2 format - curEntry.Crc = 0; - } - else - { - if (curEntry.Crc < 0) - { - curEntry.Crc = crc.Value; - } - else if (curEntry.Crc != crc.Value) - { - throw new ZipException($"crc was {crc.Value}, but {curEntry.Crc} was expected"); - } - } - - if (curEntry.Size < 0) - { - curEntry.Size = size; - } - else if (curEntry.Size != size) - { - throw new ZipException($"size was {size}, but {curEntry.Size} was expected"); - } - - if (curEntry.CompressedSize < 0) - { - curEntry.CompressedSize = csize; - } - else if (curEntry.CompressedSize != csize) - { - throw new ZipException($"compressed size was {csize}, but {curEntry.CompressedSize} expected"); - } - - offset += csize; - - if (curEntry.IsCrypted) - { - curEntry.CompressedSize += curEntry.EncryptionOverheadSize; - } - - // Patch the header if possible - if (patchEntryHeader) - { - patchEntryHeader = false; - - long curPos = baseOutputStream_.Position; - baseOutputStream_.Seek(crcPatchPos, SeekOrigin.Begin); - WriteLeInt((int)curEntry.Crc); - - if (curEntry.LocalHeaderRequiresZip64) - { - if (sizePatchPos == -1) - { - throw new ZipException("Entry requires zip64 but this has been turned off"); - } - - baseOutputStream_.Seek(sizePatchPos, SeekOrigin.Begin); - WriteLeLong(curEntry.Size); - WriteLeLong(curEntry.CompressedSize); - } - else - { - WriteLeInt((int)curEntry.CompressedSize); - WriteLeInt((int)curEntry.Size); - } - baseOutputStream_.Seek(curPos, SeekOrigin.Begin); - } - - // Add data descriptor if flagged as required - if ((curEntry.Flags & 8) != 0) - { - WriteLeInt(ZipConstants.DataDescriptorSignature); - WriteLeInt(unchecked((int)curEntry.Crc)); - - if (curEntry.LocalHeaderRequiresZip64) - { - WriteLeLong(curEntry.CompressedSize); - WriteLeLong(curEntry.Size); - offset += ZipConstants.Zip64DataDescriptorSize; - } - else - { - WriteLeInt((int)curEntry.CompressedSize); - WriteLeInt((int)curEntry.Size); - offset += ZipConstants.DataDescriptorSize; - } - } - - entries.Add(curEntry); - curEntry = null; - } - - /// - /// Initializes encryption keys based on given . - /// - /// The password. - private void InitializePassword(string password) - { - var pkManaged = new PkzipClassicManaged(); - byte[] key = PkzipClassic.GenerateKeys(ZipStrings.ConvertToArray(password)); - cryptoTransform_ = pkManaged.CreateEncryptor(key, null); - } - - /// - /// Initializes encryption keys based on given password. - /// - private void InitializeAESPassword(ZipEntry entry, string rawPassword, - out byte[] salt, out byte[] pwdVerifier) - { - salt = new byte[entry.AESSaltLen]; - - // Salt needs to be cryptographically random, and unique per file - _aesRnd.GetBytes(salt); - - int blockSize = entry.AESKeySize / 8; // bits to bytes - - cryptoTransform_ = new ZipAESTransform(rawPassword, salt, blockSize, true); - pwdVerifier = ((ZipAESTransform)cryptoTransform_).PwdVerifier; - } - - private void WriteEncryptionHeader(long crcValue) - { - offset += ZipConstants.CryptoHeaderSize; - - InitializePassword(Password); - - byte[] cryptBuffer = new byte[ZipConstants.CryptoHeaderSize]; - var rng = RandomNumberGenerator.Create(); - rng.GetBytes(cryptBuffer); - - cryptBuffer[11] = (byte)(crcValue >> 24); - - EncryptBlock(cryptBuffer, 0, cryptBuffer.Length); - baseOutputStream_.Write(cryptBuffer, 0, cryptBuffer.Length); - } - - private static void AddExtraDataAES(ZipEntry entry, ZipExtraData extraData) - { - // Vendor Version: AE-1 IS 1. AE-2 is 2. With AE-2 no CRC is required and 0 is stored. - const int VENDOR_VERSION = 2; - // Vendor ID is the two ASCII characters "AE". - const int VENDOR_ID = 0x4541; //not 6965; - extraData.StartNewEntry(); - // Pack AES extra data field see http://www.winzip.com/aes_info.htm - //extraData.AddLeShort(7); // Data size (currently 7) - extraData.AddLeShort(VENDOR_VERSION); // 2 = AE-2 - extraData.AddLeShort(VENDOR_ID); // "AE" - extraData.AddData(entry.AESEncryptionStrength); // 1 = 128, 2 = 192, 3 = 256 - extraData.AddLeShort((int)entry.CompressionMethod); // The actual compression method used to compress the file - extraData.AddNewEntry(0x9901); - } - - // Replaces WriteEncryptionHeader for AES - // - private void WriteAESHeader(ZipEntry entry) - { - byte[] salt; - byte[] pwdVerifier; - InitializeAESPassword(entry, Password, out salt, out pwdVerifier); - // File format for AES: - // Size (bytes) Content - // ------------ ------- - // Variable Salt value - // 2 Password verification value - // Variable Encrypted file data - // 10 Authentication code - // - // Value in the "compressed size" fields of the local file header and the central directory entry - // is the total size of all the items listed above. In other words, it is the total size of the - // salt value, password verification value, encrypted data, and authentication code. - baseOutputStream_.Write(salt, 0, salt.Length); - baseOutputStream_.Write(pwdVerifier, 0, pwdVerifier.Length); - } - - /// - /// Writes the given buffer to the current entry. - /// - /// The buffer containing data to write. - /// The offset of the first byte to write. - /// The number of bytes to write. - /// Archive size is invalid - /// No entry is active. - public override void Write(byte[] buffer, int offset, int count) - { - if (curEntry == null) - { - throw new InvalidOperationException("No open entry."); - } - - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (offset < 0) - { - throw new ArgumentOutOfRangeException(nameof(offset), "Cannot be negative"); - } - - if (count < 0) - { - throw new ArgumentOutOfRangeException(nameof(count), "Cannot be negative"); - } - - if ((buffer.Length - offset) < count) - { - throw new ArgumentException("Invalid offset/count combination"); - } - - if (curEntry.AESKeySize == 0) - { - // Only update CRC if AES is not enabled - crc.Update(new ArraySegment(buffer, offset, count)); - } - - size += count; - - switch (curMethod) - { - case CompressionMethod.Deflated: - base.Write(buffer, offset, count); - break; - - case CompressionMethod.Stored: - if (Password != null) - { - CopyAndEncrypt(buffer, offset, count); - } - else - { - baseOutputStream_.Write(buffer, offset, count); - } - break; - } - } - - private void CopyAndEncrypt(byte[] buffer, int offset, int count) - { - const int CopyBufferSize = 4096; - byte[] localBuffer = new byte[CopyBufferSize]; - while (count > 0) - { - int bufferCount = (count < CopyBufferSize) ? count : CopyBufferSize; - - Array.Copy(buffer, offset, localBuffer, 0, bufferCount); - EncryptBlock(localBuffer, 0, bufferCount); - baseOutputStream_.Write(localBuffer, 0, bufferCount); - count -= bufferCount; - offset += bufferCount; - } - } - - /// - /// Finishes the stream. This will write the central directory at the - /// end of the zip file and flush the stream. - /// - /// - /// This is automatically called when the stream is closed. - /// - /// - /// An I/O error occurs. - /// - /// - /// Comment exceeds the maximum length
- /// Entry name exceeds the maximum length - ///
- public override void Finish() - { - if (entries == null) - { - return; - } - - if (curEntry != null) - { - CloseEntry(); - } - - long numEntries = entries.Count; - long sizeEntries = 0; - - foreach (ZipEntry entry in entries) - { - WriteLeInt(ZipConstants.CentralHeaderSignature); - WriteLeShort((entry.HostSystem << 8) | entry.VersionMadeBy); - WriteLeShort(entry.Version); - WriteLeShort(entry.Flags); - WriteLeShort((short)entry.CompressionMethodForHeader); - WriteLeInt((int)entry.DosTime); - WriteLeInt((int)entry.Crc); - - if (entry.IsZip64Forced() || - (entry.CompressedSize >= uint.MaxValue)) - { - WriteLeInt(-1); - } - else - { - WriteLeInt((int)entry.CompressedSize); - } - - if (entry.IsZip64Forced() || - (entry.Size >= uint.MaxValue)) - { - WriteLeInt(-1); - } - else - { - WriteLeInt((int)entry.Size); - } - - byte[] name = ZipStrings.ConvertToArray(entry.Flags, entry.Name); - - if (name.Length > 0xffff) - { - throw new ZipException("Name too long."); - } - - var ed = new ZipExtraData(entry.ExtraData); - - if (entry.CentralHeaderRequiresZip64) - { - ed.StartNewEntry(); - if (entry.IsZip64Forced() || - (entry.Size >= 0xffffffff)) - { - ed.AddLeLong(entry.Size); - } - - if (entry.IsZip64Forced() || - (entry.CompressedSize >= 0xffffffff)) - { - ed.AddLeLong(entry.CompressedSize); - } - - if (entry.Offset >= 0xffffffff) - { - ed.AddLeLong(entry.Offset); - } - - ed.AddNewEntry(1); - } - else - { - ed.Delete(1); - } - - if (entry.AESKeySize > 0) - { - AddExtraDataAES(entry, ed); - } - byte[] extra = ed.GetEntryData(); - - byte[] entryComment = - (entry.Comment != null) ? - ZipStrings.ConvertToArray(entry.Flags, entry.Comment) : - Empty.Array(); - - if (entryComment.Length > 0xffff) - { - throw new ZipException("Comment too long."); - } - - WriteLeShort(name.Length); - WriteLeShort(extra.Length); - WriteLeShort(entryComment.Length); - WriteLeShort(0); // disk number - WriteLeShort(0); // internal file attributes - // external file attributes - - if (entry.ExternalFileAttributes != -1) - { - WriteLeInt(entry.ExternalFileAttributes); - } - else - { - if (entry.IsDirectory) - { // mark entry as directory (from nikolam.AT.perfectinfo.com) - WriteLeInt(16); - } - else - { - WriteLeInt(0); - } - } - - if (entry.Offset >= uint.MaxValue) - { - WriteLeInt(-1); - } - else - { - WriteLeInt((int)entry.Offset); - } - - if (name.Length > 0) - { - baseOutputStream_.Write(name, 0, name.Length); - } - - if (extra.Length > 0) - { - baseOutputStream_.Write(extra, 0, extra.Length); - } - - if (entryComment.Length > 0) - { - baseOutputStream_.Write(entryComment, 0, entryComment.Length); - } - - sizeEntries += ZipConstants.CentralHeaderBaseSize + name.Length + extra.Length + entryComment.Length; - } - - using (ZipHelperStream zhs = new ZipHelperStream(baseOutputStream_)) - { - zhs.WriteEndOfCentralDirectory(numEntries, sizeEntries, offset, zipComment); - } - - entries = null; - } - - /// - /// Flushes the stream by calling Flush on the deflater stream unless - /// the current compression method is . Then it flushes the underlying output stream. - /// - public override void Flush() - { - if(curMethod == CompressionMethod.Stored) - { - baseOutputStream_.Flush(); - } - else - { - base.Flush(); - } - } - - #region Instance Fields - - /// - /// The entries for the archive. - /// - private List entries = new List(); - - /// - /// Used to track the crc of data added to entries. - /// - private Crc32 crc = new Crc32(); - - /// - /// The current entry being added. - /// - private ZipEntry curEntry; - - private int defaultCompressionLevel = Deflater.DEFAULT_COMPRESSION; - - private CompressionMethod curMethod = CompressionMethod.Deflated; - - /// - /// Used to track the size of data for an entry during writing. - /// - private long size; - - /// - /// Offset to be recorded for each entry in the central header. - /// - private long offset; - - /// - /// Comment for the entire archive recorded in central header. - /// - private byte[] zipComment = Empty.Array(); - - /// - /// Flag indicating that header patching is required for the current entry. - /// - private bool patchEntryHeader; - - /// - /// Position to patch crc - /// - private long crcPatchPos = -1; - - /// - /// Position to patch size. - /// - private long sizePatchPos = -1; - - // Default is dynamic which is not backwards compatible and can cause problems - // with XP's built in compression which cant read Zip64 archives. - // However it does avoid the situation were a large file is added and cannot be completed correctly. - // NOTE: Setting the size for entries before they are added is the best solution! - private UseZip64 useZip64_ = UseZip64.Dynamic; - - /// - /// The password to use when encrypting archive entries. - /// - private string password; - - #endregion Instance Fields - - #region Static Fields - - // Static to help ensure that multiple files within a zip will get different random salt - private static RandomNumberGenerator _aesRnd = RandomNumberGenerator.Create(); - - #endregion Static Fields - } -} diff --git a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipStrings.cs b/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipStrings.cs deleted file mode 100644 index 5f159701e..000000000 --- a/MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipStrings.cs +++ /dev/null @@ -1,195 +0,0 @@ -using System; -using System.Text; -using MelonLoader.ICSharpCode.SharpZipLib.Core; - -namespace MelonLoader.ICSharpCode.SharpZipLib.Zip -{ - /// - /// This static class contains functions for encoding and decoding zip file strings - /// - [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] - public static class ZipStrings - { - static ZipStrings() - { - try - { - var platformCodepage = Encoding.GetEncoding(0).CodePage; - SystemDefaultCodePage = (platformCodepage == 1 || platformCodepage == 2 || platformCodepage == 3 || platformCodepage == 42) ? FallbackCodePage : platformCodepage; - } - catch - { - SystemDefaultCodePage = FallbackCodePage; - } - } - - /// Code page backing field - /// - /// The original Zip specification (https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) states - /// that file names should only be encoded with IBM Code Page 437 or UTF-8. - /// In practice, most zip apps use OEM or system encoding (typically cp437 on Windows). - /// Let's be good citizens and default to UTF-8 http://utf8everywhere.org/ - /// - private static int codePage = AutomaticCodePage; - - /// Automatically select codepage while opening archive - /// see https://github.com/icsharpcode/SharpZipLib/pull/280#issuecomment-433608324 - /// - private const int AutomaticCodePage = -1; - - /// - /// Encoding used for string conversion. Setting this to 65001 (UTF-8) will - /// also set the Language encoding flag to indicate UTF-8 encoded file names. - /// - public static int CodePage - { - get - { - return codePage == AutomaticCodePage? Encoding.UTF8.CodePage:codePage; - } - set - { - if ((value < 0) || (value > 65535) || - (value == 1) || (value == 2) || (value == 3) || (value == 42)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - codePage = value; - } - } - - private const int FallbackCodePage = 437; - - /// - /// Attempt to get the operating system default codepage, or failing that, to - /// the fallback code page IBM 437. - /// - public static int SystemDefaultCodePage { get; } - - /// - /// Get whether the default codepage is set to UTF-8. Setting this property to false will - /// set the to - /// - /// - /// Get OEM codepage from NetFX, which parses the NLP file with culture info table etc etc. - /// But sometimes it yields the special value of 1 which is nicknamed CodePageNoOEM in sources (might also mean CP_OEMCP, but Encoding puts it so). - /// This was observed on Ukranian and Hindu systems. - /// Given this value, throws an . - /// So replace it with , (IBM 437 which is the default code page in a default Windows installation console. - /// - public static bool UseUnicode - { - get - { - return codePage == Encoding.UTF8.CodePage; - } - set - { - if (value) - { - codePage = Encoding.UTF8.CodePage; - } - else - { - codePage = SystemDefaultCodePage; - } - } - } - - /// - /// Convert a portion of a byte array to a string using - /// - /// - /// Data to convert to string - /// - /// - /// Number of bytes to convert starting from index 0 - /// - /// - /// data[0]..data[count - 1] converted to a string - /// - public static string ConvertToString(byte[] data, int count) - => data == null - ? string.Empty - : Encoding.GetEncoding(CodePage).GetString(data, 0, count); - - /// - /// Convert a byte array to a string using - /// - /// - /// Byte array to convert - /// - /// - /// dataconverted to a string - /// - public static string ConvertToString(byte[] data) - => ConvertToString(data, data.Length); - - private static Encoding EncodingFromFlag(int flags) - => ((flags & (int)GeneralBitFlags.UnicodeText) != 0) - ? Encoding.UTF8 - : Encoding.GetEncoding( - // if CodePage wasn't set manually and no utf flag present - // then we must use SystemDefault (old behavior) - // otherwise, CodePage should be preferred over SystemDefault - // see https://github.com/icsharpcode/SharpZipLib/issues/274 - codePage == AutomaticCodePage? - SystemDefaultCodePage: - codePage); - - /// - /// Convert a byte array to a string using - /// - /// The applicable general purpose bits flags - /// - /// Byte array to convert - /// - /// The number of bytes to convert. - /// - /// dataconverted to a string - /// - public static string ConvertToStringExt(int flags, byte[] data, int count) - => (data == null) - ? string.Empty - : EncodingFromFlag(flags).GetString(data, 0, count); - - /// - /// Convert a byte array to a string using - /// - /// - /// Byte array to convert - /// - /// The applicable general purpose bits flags - /// - /// dataconverted to a string - /// - public static string ConvertToStringExt(int flags, byte[] data) - => ConvertToStringExt(flags, data, data.Length); - - /// - /// Convert a string to a byte array using - /// - /// - /// String to convert to an array - /// - /// Converted array - public static byte[] ConvertToArray(string str) - => str == null - ? Empty.Array() - : Encoding.GetEncoding(CodePage).GetBytes(str); - - /// - /// Convert a string to a byte array using - /// - /// The applicable general purpose bits flags - /// - /// String to convert to an array - /// - /// Converted array - public static byte[] ConvertToArray(int flags, string str) - => (string.IsNullOrEmpty(str)) - ? Empty.Array() - : EncodingFromFlag(flags).GetBytes(str); - } -} diff --git a/MelonLoader/BackwardsCompatibility/Melon/AssemblyResolveInfo.cs b/MelonLoader/BackwardsCompatibility/Melon/AssemblyResolveInfo.cs deleted file mode 100644 index 7e8dc10df..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/AssemblyResolveInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; - -namespace MelonLoader.MonoInternals -{ - [Obsolete("MelonLoader.MonoInternals.AssemblyResolveInfo is Only Here for Compatibility Reasons. Please use MelonLoader.Resolver.AssemblyResolveInfo instead. This will be removed in a future update.", true)] - public class AssemblyResolveInfo : Resolver.AssemblyResolveInfo { } -} diff --git a/MelonLoader/BackwardsCompatibility/Melon/HarmonyShield.cs b/MelonLoader/BackwardsCompatibility/Melon/HarmonyShield.cs deleted file mode 100644 index 74004f310..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/HarmonyShield.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Harmony -{ - [Obsolete("Harmony.HarmonyShield is Only Here for Compatibility Reasons. Please use MelonLoader.PatchShield instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Struct)] - public class HarmonyShield : MelonLoader.PatchShield { } -} diff --git a/MelonLoader/BackwardsCompatibility/Melon/Imports.cs b/MelonLoader/BackwardsCompatibility/Melon/Imports.cs deleted file mode 100644 index 1ed2714f1..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/Imports.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using MelonLoader.Utils; - -namespace MelonLoader -{ - [Obsolete("MelonLoader.Imports is Only Here for Compatibility Reasons. This will be removed in a future update.", true)] - public static class Imports - { - [Obsolete("MelonLoader.Imports.GetCompanyName is Only Here for Compatibility Reasons. Please use MelonLoader.InternalUtils.UnityInformationHandler.GameDeveloper instead. This will be removed in a future update.", true)] - public static string GetCompanyName() => InternalUtils.UnityInformationHandler.GameDeveloper; - [Obsolete("MelonLoader.Imports.GetProductName is Only Here for Compatibility Reasons. Please use MelonLoader.InternalUtils.UnityInformationHandler.GameName instead. This will be removed in a future update.", true)] - public static string GetProductName() => InternalUtils.UnityInformationHandler.GameName; - [Obsolete("MelonLoader.Imports.GetGameDirectory is Only Here for Compatibility Reasons. Please use MelonLoader.Utils.MelonEnvironment.GameRootDirectory instead. This will be removed in a future update.", true)] - public static string GetGameDirectory() => MelonEnvironment.GameRootDirectory; - [Obsolete("MelonLoader.Imports.GetGameDataDirectory is Only Here for Compatibility Reasons. Please use MelonLoader.Utils.MelonEnvironment.UnityGameDataDirectory instead. This will be removed in a future update.", true)] - public static string GetGameDataDirectory() => MelonEnvironment.UnityGameDataDirectory; - [Obsolete("MelonLoader.Imports.GetAssemblyDirectory is Only Here for Compatibility Reasons. Please use MelonLoader.Utils.MelonEnvironment.MelonManagedDirectory instead. This will be removed in a future update.", true)] - public static string GetAssemblyDirectory() => MelonEnvironment.MelonManagedDirectory; - [Obsolete("MelonLoader.Imports.IsIl2CppGame is Only Here for Compatibility Reasons. Please use MelonLoader.MelonUtils.IsGameIl2Cpp instead. This will be removed in a future update.", true)] - public static bool IsIl2CppGame() => MelonUtils.IsGameIl2Cpp(); - [Obsolete("MelonLoader.Imports.IsDebugMode is Only Here for Compatibility Reasons. Please use MelonLoader.MelonDebug.IsEnabled instead. This will be removed in a future update.", true)] - public static bool IsDebugMode() => MelonDebug.IsEnabled(); - [Obsolete("MelonLoader.Imports.Hook is Only Here for Compatibility Reasons. Please use MelonLoader.MelonUtils.NativeHookAttach instead. This will be removed in a future update.", true)] - public static void Hook(IntPtr target, IntPtr detour) => MelonUtils.NativeHookAttach(target, detour); - [Obsolete("MelonLoader.Imports.Unhook is Only Here for Compatibility Reasons. Please use MelonLoader.MelonUtils.NativeHookDetach instead. This will be removed in a future update.", true)] - public static void Unhook(IntPtr target, IntPtr detour) => MelonUtils.NativeHookDetach(target, detour); - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/Main.cs b/MelonLoader/BackwardsCompatibility/Melon/Main.cs deleted file mode 100644 index 9d422caf8..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/Main.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using MelonLoader.Utils; - -namespace MelonLoader -{ - [Obsolete("MelonLoader.Main is Only Here for Compatibility Reasons. This will be removed in a future update.", true)] - public static class Main - { - [Obsolete("MelonLoader.Main.Mods is Only Here for Compatibility Reasons. Please use MelonLoader.MelonHandler.Mods instead. This will be removed in a future update.", true)] - public static List Mods = null; - [Obsolete("MelonLoader.Main.Plugins is Only Here for Compatibility Reasons. Please use MelonLoader.MelonHandler.Plugins instead. This will be removed in a future update.", true)] - public static List Plugins = null; - [Obsolete("MelonLoader.Main.IsBoneworks is Only Here for Compatibility Reasons. Please use MelonLoader.MelonUtils.IsBONEWORKS instead. This will be removed in a future update.", true)] - public static bool IsBoneworks = false; - [Obsolete("MelonLoader.Main.GetUnityVersion is Only Here for Compatibility Reasons. Please use MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion instead. This will be removed in a future update.", true)] - public static string GetUnityVersion() => InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(); - [Obsolete("MelonLoader.Main.GetUserDataPath is Only Here for Compatibility Reasons. Please use MelonLoader.Utils.MelonEnvironment.UserDataDirectory instead. This will be removed in a future update.", true)] - public static string GetUserDataPath() => MelonEnvironment.UserDataDirectory; - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/MelonConsole.cs b/MelonLoader/BackwardsCompatibility/Melon/MelonConsole.cs deleted file mode 100644 index e32306f5e..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/MelonConsole.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace MelonLoader -{ - [Obsolete("MelonLoader.MelonConsole is Only Here for Compatibility Reasons. This will be removed in a future update.", true)] - public class MelonConsole - { - [Obsolete("MelonLoader.MelonConsole.SetTitle is Only Here for Compatibility Reasons. Please use MelonLoader.MelonUtils.SetConsoleTitle instead. This will be removed in a future update.", true)] - public static void SetTitle(string title) => MelonUtils.SetConsoleTitle(title); - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/MelonLoaderBase.cs b/MelonLoader/BackwardsCompatibility/Melon/MelonLoaderBase.cs deleted file mode 100644 index 74f9cedcb..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/MelonLoaderBase.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using MelonLoader.Utils; - -namespace MelonLoader -{ - [Obsolete("MelonLoader.MelonLoaderBase is Only Here for Compatibility Reasons. This will be removed in a future update.", true)] - public static class MelonLoaderBase - { - [Obsolete("MelonLoader.MelonLoaderBase.UserDataPath is Only Here for Compatibility Reasons. Please use MelonLoader.Utils.MelonEnvironment.UserDataDirectory instead. This will be removed in a future update.", true)] - public static string UserDataPath { get => MelonEnvironment.UserDataDirectory; } - [Obsolete("MelonLoader.MelonLoaderBase.UnityVersion is Only Here for Compatibility Reasons. Please use MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion instead. This will be removed in a future update.", true)] - public static string UnityVersion { get => InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(); } - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/MelonModGameAttribute.cs b/MelonLoader/BackwardsCompatibility/Melon/MelonModGameAttribute.cs deleted file mode 100644 index 8a349654e..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/MelonModGameAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace MelonLoader -{ - [Obsolete("MelonLoader.MelonModGameAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public class MelonModGameAttribute : MelonGameAttribute - { - [Obsolete("MelonLoader.MelonModGameAttribute.Developer is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame.Developer instead. This will be removed in a future update.", true)] - new public string Developer => base.Developer; - [Obsolete("MelonLoader.MelonModGameAttribute.GameName is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame.Name instead. This will be removed in a future update.", true)] - public string GameName => Name; - [Obsolete("MelonLoader.MelonModGameAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame instead. This will be removed in a future update.", true)] - public MelonModGameAttribute(string developer = null, string gameName = null) : base(developer, gameName) { } - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/MelonModInfoAttribute.cs b/MelonLoader/BackwardsCompatibility/Melon/MelonModInfoAttribute.cs deleted file mode 100644 index ed360e8b9..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/MelonModInfoAttribute.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace MelonLoader -{ - [Obsolete("MelonLoader.MelonPluginInfoAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] - public class MelonModInfoAttribute : MelonInfoAttribute - { - [Obsolete("MelonLoader.MelonPluginInfoAttribute.SystemType is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo.SystemType instead. This will be removed in a future update.", true)] - new public Type SystemType => base.SystemType; - [Obsolete("MelonLoader.MelonPluginInfoAttribute.Name is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo.Name instead. This will be removed in a future update.", true)] - new public string Name => base.Name; - [Obsolete("MelonLoader.MelonPluginInfoAttribute.Version is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo.Version instead. This will be removed in a future update.", true)] - new public string Version => base.Version; - [Obsolete("MelonLoader.MelonPluginInfoAttribute.Author is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo.Author instead. This will be removed in a future update.", true)] - new public string Author => base.Author; - [Obsolete("MelonLoader.MelonPluginInfoAttribute.DownloadLink is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo.DownloadLink instead. This will be removed in a future update.", true)] - new public string DownloadLink => base.DownloadLink; - [Obsolete("MelonLoader.MelonPluginInfoAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo instead. This will be removed in a future update.", true)] - public MelonModInfoAttribute(Type type, string name, string version, string author, string downloadLink = null) : base(type, name, version, author, downloadLink) { } - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/MelonModLogger.cs b/MelonLoader/BackwardsCompatibility/Melon/MelonModLogger.cs deleted file mode 100644 index c75a0e06d..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/MelonModLogger.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; - -namespace MelonLoader -{ - [Obsolete("MelonLoader.MelonModLogger is Only Here for Compatibility Reasons. Please use MelonLoader.MelonLogger instead. This will be removed in a future update.", true)] - public class MelonModLogger : MelonLogger { } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/MelonPluginGameAttribute.cs b/MelonLoader/BackwardsCompatibility/Melon/MelonPluginGameAttribute.cs deleted file mode 100644 index fbe7beb4f..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/MelonPluginGameAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace MelonLoader -{ - [Obsolete("MelonLoader.MelonPluginGameAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public class MelonPluginGameAttribute : MelonGameAttribute - { - [Obsolete("MelonLoader.MelonPluginGameAttribute.Developer is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame.Developer instead. This will be removed in a future update.", true)] - new public string Developer => base.Developer; - [Obsolete("MelonLoader.MelonPluginGameAttribute.GameName is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame.Name instead. This will be removed in a future update.", true)] - public string GameName => Name; - [Obsolete("MelonLoader.MelonPluginGameAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame instead. This will be removed in a future update.", true)] - public MelonPluginGameAttribute(string developer = null, string gameName = null) : base(developer, gameName) { } - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/MelonPluginInfoAttribute.cs b/MelonLoader/BackwardsCompatibility/Melon/MelonPluginInfoAttribute.cs deleted file mode 100644 index ae4a26f49..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/MelonPluginInfoAttribute.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace MelonLoader -{ - [Obsolete("MelonLoader.MelonPluginInfoAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo instead. This will be removed in a future update.", true)] - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] - public class MelonPluginInfoAttribute : MelonInfoAttribute - { - [Obsolete("MelonLoader.MelonPluginInfoAttribute.SystemType is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo.SystemType instead. This will be removed in a future update.", true)] - new public Type SystemType => base.SystemType; - [Obsolete("MelonLoader.MelonPluginInfoAttribute.Name is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo.Name instead. This will be removed in a future update.", true)] - new public string Name => base.Name; - [Obsolete("MelonLoader.MelonPluginInfoAttribute.Version is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo.Version instead. This will be removed in a future update.", true)] - new public string Version => base.Version; - [Obsolete("MelonLoader.MelonPluginInfoAttribute.Author is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo.Author instead. This will be removed in a future update.", true)] - new public string Author => base.Author; - [Obsolete("MelonLoader.MelonPluginInfoAttribute.DownloadLink is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo.DownloadLink instead. This will be removed in a future update.", true)] - new public string DownloadLink => base.DownloadLink; - [Obsolete("MelonLoader.MelonPluginInfoAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonInfo instead. This will be removed in a future update.", true)] - public MelonPluginInfoAttribute(Type type, string name, string version, string author, string downloadLink = null) : base(type, name, version, author, downloadLink) { } - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/MelonPrefs.cs b/MelonLoader/BackwardsCompatibility/Melon/MelonPrefs.cs deleted file mode 100644 index 54194851a..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/MelonPrefs.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MelonLoader -{ - [Obsolete("MelonLoader.MelonPrefs is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences instead. This will be removed in a future update.", true)] - public class MelonPrefs - { - [Obsolete("MelonLoader.MelonPrefs.RegisterCategory is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.CreateCategory instead. This will be removed in a future update.", true)] - public static void RegisterCategory(string name, string displayText) => MelonPreferences.CreateCategory(name, displayText); - [Obsolete("MelonLoader.MelonPrefs.RegisterString is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.CreateEntry instead. This will be removed in a future update.", true)] - public static void RegisterString(string section, string name, string defaultValue, string displayText = null, bool hideFromList = false) => MelonPreferences.CreateEntry(section, name, defaultValue, displayText, hideFromList); - [Obsolete("MelonLoader.MelonPrefs.RegisterBool is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.CreateEntry instead. This will be removed in a future update.", true)] - public static void RegisterBool(string section, string name, bool defaultValue, string displayText = null, bool hideFromList = false) => MelonPreferences.CreateEntry(section, name, defaultValue, displayText, hideFromList); - [Obsolete("MelonLoader.MelonPrefs.RegisterInt is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.CreateEntry instead. This will be removed in a future update.", true)] - public static void RegisterInt(string section, string name, int defaultValue, string displayText = null, bool hideFromList = false) => MelonPreferences.CreateEntry(section, name, defaultValue, displayText, hideFromList); - [Obsolete("MelonLoader.MelonPrefs.RegisterFloat is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.CreateEntry instead. This will be removed in a future update.", true)] - public static void RegisterFloat(string section, string name, float defaultValue, string displayText = null, bool hideFromList = false) => MelonPreferences.CreateEntry(section, name, defaultValue, displayText, hideFromList); - [Obsolete("MelonLoader.MelonPrefs.HasKey is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.HasEntry instead. This will be removed in a future update.", true)] - public static bool HasKey(string section, string name) => MelonPreferences.HasEntry(section, name); - [Obsolete("MelonLoader.MelonPrefs.GetPreferences is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.Categories instead. This will be removed in a future update.", true)] - public static Dictionary> GetPreferences() - { - Dictionary> output = new Dictionary>(); - if (MelonPreferences.Categories.Count <= 0) - return output; - foreach (MelonPreferences_Category category in MelonPreferences.Categories) - { - Dictionary newprefsdict = new Dictionary(); - foreach (MelonPreferences_Entry entry in category.Entries) - { - Type reflectedType = entry.GetReflectedType(); - if ((reflectedType != typeof(string)) - && (reflectedType != typeof(bool)) - && (reflectedType != typeof(int)) - && (reflectedType != typeof(float)) - && (reflectedType != typeof(double)) - && (reflectedType != typeof(long))) - continue; - MelonPreference newpref = new MelonPreference(entry); - newprefsdict.Add(entry.Identifier, newpref); - } - output.Add(category.Identifier, newprefsdict); - } - return output; - } - [Obsolete("MelonLoader.MelonPrefs.GetCategoryDisplayName is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.GetCategoryDisplayName instead. This will be removed in a future update.", true)] - public static string GetCategoryDisplayName(string key) => MelonPreferences.GetCategory(key)?.DisplayName; - [Obsolete("MelonLoader.MelonPrefs.SaveConfig is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.Save instead. This will be removed in a future update.", true)] - public static void SaveConfig() => MelonPreferences.Save(); - [Obsolete("MelonLoader.MelonPrefs.GetString is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.GetEntryString instead. This will be removed in a future update.", true)] - public static string GetString(string section, string name) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - return null; - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - return null; - return entry.GetValueAsString(); - } - [Obsolete("MelonLoader.MelonPrefs.SetString is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.SetEntryString instead. This will be removed in a future update.", true)] - public static void SetString(string section, string name, string value) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - return; - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - return; - switch (entry) - { - case MelonPreferences_Entry stringEntry: - stringEntry.Value = value; - break; - case MelonPreferences_Entry intEntry: - if (int.TryParse(value, out var parsedInt)) - intEntry.Value = parsedInt; - break; - case MelonPreferences_Entry floatEntry: - if (float.TryParse(value, out var parsedFloat)) - floatEntry.Value = parsedFloat; - break; - case MelonPreferences_Entry boolEntry: - if (value.ToLower().StartsWith("true") || value.ToLower().StartsWith("false")) - boolEntry.Value = value.ToLower().StartsWith("true"); - break; - } - } - [Obsolete("MelonLoader.MelonPrefs.GetBool is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.GetEntryBool instead. This will be removed in a future update.", true)] - public static bool GetBool(string section, string name) => MelonPreferences.GetEntryValue(section, name); - [Obsolete("MelonLoader.MelonPrefs.SetBool is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.SetEntryBool instead. This will be removed in a future update.", true)] - public static void SetBool(string section, string name, bool value) => MelonPreferences.SetEntryValue(section, name, value); - [Obsolete("MelonLoader.MelonPrefs.GetInt is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.GetEntryInt instead. This will be removed in a future update.", true)] - public static int GetInt(string section, string name) => MelonPreferences.GetEntryValue(section, name); - [Obsolete("MelonLoader.MelonPrefs.SetInt is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.SetEntryInt instead. This will be removed in a future update.", true)] - public static void SetInt(string section, string name, int value) => MelonPreferences.SetEntryValue(section, name, value); - [Obsolete("MelonLoader.MelonPrefs.GetFloat is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.GetEntryFloat instead. This will be removed in a future update.", true)] - public static float GetFloat(string section, string name) => MelonPreferences.GetEntryValue(section, name); - [Obsolete("MelonLoader.MelonPrefs.GetEntryFloat is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.SetEntryFloat instead. This will be removed in a future update.", true)] - public static void SetFloat(string section, string name, float value) => MelonPreferences.SetEntryValue(section, name, value); - [Obsolete("MelonLoader.MelonPrefs.MelonPreferenceType is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry.TypeEnum instead. This will be removed in a future update.", true)] - public enum MelonPreferenceType - { - STRING, - BOOL, - INT, - FLOAT - } - [Obsolete("MelonLoader.MelonPrefs.MelonPreference is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry instead. This will be removed in a future update.", true)] - public class MelonPreference - { - [Obsolete("MelonLoader.MelonPrefs.MelonPreference.Value is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry.GetValue instead. This will be removed in a future update.", true)] - public string Value { get => GetString(Entry.Category.Identifier, Entry.Identifier); set => SetString(Entry.Category.Identifier, Entry.Identifier, value); } - [Obsolete("MelonLoader.MelonPrefs.MelonPreference.ValueEdited is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry.GetValueEdited instead. This will be removed in a future update.", true)] - public string ValueEdited { get => GetEditedString(Entry.Category.Identifier, Entry.Identifier); set => SetEditedString(Entry.Category.Identifier, Entry.Identifier, value); } - [Obsolete("MelonLoader.MelonPrefs.MelonPreference.Type is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry.GetReflectedType instead. This will be removed in a future update.", true)] - public MelonPreferenceType Type - { - get - { - if (Entry.GetReflectedType() == typeof(string)) - return MelonPreferenceType.STRING; - else if (Entry.GetReflectedType() == typeof(bool)) - return MelonPreferenceType.BOOL; - else if ((Entry.GetReflectedType() == typeof(float)) - || (Entry.GetReflectedType() == typeof(double))) - return MelonPreferenceType.FLOAT; - else if ((Entry.GetReflectedType() == typeof(int)) - || (Entry.GetReflectedType() == typeof(long)) - || (Entry.GetReflectedType() == typeof(byte))) - return MelonPreferenceType.INT; - return (MelonPreferenceType)4; - } - } - [Obsolete("MelonLoader.MelonPrefs.MelonPreference.Hidden is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry.IsHidden instead. This will be removed in a future update.", true)] - public bool Hidden { get => Entry.IsHidden; } - [Obsolete("MelonLoader.MelonPrefs.MelonPreference.DisplayText is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry.DisplayName instead. This will be removed in a future update.", true)] - public string DisplayText { get => Entry.DisplayName; } - - internal MelonPreference(MelonPreferences_Entry entry) => Entry = entry; - internal MelonPreference(MelonPreference pref) => Entry = pref.Entry; - private MelonPreferences_Entry Entry = null; - private static string GetEditedString(string section, string name) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - return null; - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - return null; - - return entry.GetEditedValueAsString(); - } - private static void SetEditedString(string section, string name, string value) - { - MelonPreferences_Category category = MelonPreferences.GetCategory(section); - if (category == null) - return; - MelonPreferences_Entry entry = category.GetEntry(name); - if (entry == null) - return; - switch (entry) - { - case MelonPreferences_Entry stringEntry: - stringEntry.EditedValue = value; - break; - case MelonPreferences_Entry intEntry: - if (int.TryParse(value, out var parsedInt)) - intEntry.EditedValue = parsedInt; - break; - case MelonPreferences_Entry floatEntry: - if (float.TryParse(value, out var parsedFloat)) - floatEntry.EditedValue = parsedFloat; - break; - case MelonPreferences_Entry boolEntry: - if (value.ToLower().StartsWith("true") || value.ToLower().StartsWith("false")) - boolEntry.EditedValue = value.ToLower().StartsWith("true"); - break; - } - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/ModPrefs.cs b/MelonLoader/BackwardsCompatibility/Melon/ModPrefs.cs deleted file mode 100644 index 2a1a1d701..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/ModPrefs.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -#pragma warning disable 0108 - -namespace MelonLoader -{ - [Obsolete("MelonLoader.ModPrefs is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences instead. This will be removed in a future update.", true)] - public class ModPrefs : MelonPrefs - { - [Obsolete("MelonLoader.ModPrefs.GetPrefs is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences instead. This will be removed in a future update.", true)] - public static Dictionary> GetPrefs() - { - Dictionary> output = new Dictionary>(); - Dictionary> prefs = GetPreferences(); - for (int i = 0; i < prefs.Values.Count; i++) - { - Dictionary prefsdict = prefs.Values.ElementAt(i); - Dictionary newprefsdict = new Dictionary(); - for (int j = 0; j < prefsdict.Values.Count; j++) - { - MelonPreference pref = prefsdict.Values.ElementAt(j); - PrefDesc newpref = new PrefDesc(pref); - newpref.ValueEdited = pref.ValueEdited; - newprefsdict.Add(prefsdict.Keys.ElementAt(j), newpref); - } - output.Add(prefs.Keys.ElementAt(i), newprefsdict); - } - return output; - } - [Obsolete("MelonLoader.ModPrefs.RegisterPrefString is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.CreateEntry instead. This will be removed in a future update.", true)] - public static void RegisterPrefString(string section, string name, string defaultValue, string displayText = null, bool hideFromList = false) => RegisterString(section, name, defaultValue, displayText, hideFromList); - [Obsolete("MelonLoader.ModPrefs.RegisterPrefBool is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.CreateEntry instead. This will be removed in a future update.", true)] - public static void RegisterPrefBool(string section, string name, bool defaultValue, string displayText = null, bool hideFromList = false) => RegisterBool(section, name, defaultValue, displayText, hideFromList); - [Obsolete("MelonLoader.ModPrefs.RegisterPrefInt is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.CreateEntry instead. This will be removed in a future update.", true)] - public static void RegisterPrefInt(string section, string name, int defaultValue, string displayText = null, bool hideFromList = false) => RegisterInt(section, name, defaultValue, displayText, hideFromList); - [Obsolete("MelonLoader.ModPrefs.RegisterPrefFloat is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences.CreateEntry instead. This will be removed in a future update.", true)] - public static void RegisterPrefFloat(string section, string name, float defaultValue, string displayText = null, bool hideFromList = false) => RegisterFloat(section, name, defaultValue, displayText, hideFromList); - [Obsolete("MelonLoader.ModPrefs.PrefType is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry.TypeEnum instead. This will be removed in a future update.", true)] - public enum PrefType - { - STRING, - BOOL, - INT, - FLOAT - } - [Obsolete("MelonLoader.ModPrefs.PrefDesc is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry instead. This will be removed in a future update.", true)] - public class PrefDesc : MelonPreference - { - [Obsolete("MelonLoader.ModPrefs.PrefDesc.Type is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry.Type instead. This will be removed in a future update.", true)] - public PrefType Type { get => (PrefType)base.Type; } - [Obsolete("MelonLoader.ModPrefs.PrefDesc is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry instead. This will be removed in a future update.", true)] - public PrefDesc(MelonPreferences_Entry entry) : base(entry) { } - [Obsolete("MelonLoader.ModPrefs.PrefDesc is Only Here for Compatibility Reasons. Please use MelonLoader.MelonPreferences_Entry instead. This will be removed in a future update.", true)] - public PrefDesc(MelonPreference pref) : base(pref) { } - } - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/MonoLibrary.cs b/MelonLoader/BackwardsCompatibility/Melon/MonoLibrary.cs deleted file mode 100644 index 7c43a8a91..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/MonoLibrary.cs +++ /dev/null @@ -1,11 +0,0 @@ -#if !NET6_0_OR_GREATER - -using System; - -namespace MelonLoader.MonoInternals -{ - [Obsolete("MelonLoader.MonoInternals.MonoLibrary is Only Here for Compatibility Reasons. Please use MelonLoader.Utils.MonoLibrary instead. This will be removed in a future update.", true)] - public class MonoLibrary : Utils.MonoLibrary { } -} - -#endif \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/Melon/MonoResolveManager.cs b/MelonLoader/BackwardsCompatibility/Melon/MonoResolveManager.cs deleted file mode 100644 index f20e24034..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/MonoResolveManager.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Reflection; - -namespace MelonLoader.MonoInternals -{ - [Obsolete("MelonLoader.MonoInternals.MonoResolveManager is Only Here for Compatibility Reasons. Please use MelonLoader.Resolver.MelonAssemblyResolver instead. This will be removed in a future update.", true)] - public static class MonoResolveManager - { - [Obsolete("MelonLoader.MonoInternals.MonoResolveManager.AddSearchDirectory is Only Here for Compatibility Reasons. Please use MelonLoader.Resolver.MelonAssemblyResolver.AddSearchDirectory instead. This will be removed in a future update.", true)] - public static void AddSearchDirectory(string path, int priority = 0) - => Resolver.SearchDirectoryManager.Add(path, priority); - - [Obsolete("MelonLoader.MonoInternals.MonoResolveManager.RemoveSearchDirectory is Only Here for Compatibility Reasons. Please use MelonLoader.Resolver.MelonAssemblyResolver.RemoveSearchDirectory instead. This will be removed in a future update.", true)] - public static void RemoveSearchDirectory(string path) - => Resolver.SearchDirectoryManager.Remove(path); - - [Obsolete("MelonLoader.MonoInternals.MonoResolveManager.OnAssemblyLoadHandler is Only Here for Compatibility Reasons. Please use MelonLoader.Resolver.MelonAssemblyResolver.dOnAssemblyLoad instead. This will be removed in a future update.", true)] - public delegate void OnAssemblyLoadHandler(Assembly assembly); - [Obsolete("MelonLoader.MonoInternals.MonoResolveManager.OnAssemblyLoad is Only Here for Compatibility Reasons. Please use MelonLoader.Resolver.MelonAssemblyResolver.OnAssemblyLoad instead. This will be removed in a future update.", true)] - public static event OnAssemblyLoadHandler OnAssemblyLoad; - internal static void SafeInvoke_OnAssemblyLoad(Assembly assembly) - => OnAssemblyLoad?.Invoke(assembly); - - [Obsolete("MelonLoader.MonoInternals.MonoResolveManager.OnAssemblyResolveHandler is Only Here for Compatibility Reasons. Please use MelonLoader.Resolver.MelonAssemblyResolver.dOnAssemblyResolve instead. This will be removed in a future update.", true)] - public delegate Assembly OnAssemblyResolveHandler(string name, Version version); - [Obsolete("MelonLoader.MonoInternals.MonoResolveManager.OnAssemblyLoad is Only Here for Compatibility Reasons. Please use MelonLoader.Resolver.MelonAssemblyResolver.OnAssemblyLoad instead. This will be removed in a future update.", true)] - public static event OnAssemblyResolveHandler OnAssemblyResolve; - internal static Assembly SafeInvoke_OnAssemblyResolve(string name, Version version) - => OnAssemblyResolve?.Invoke(name, version); - - [Obsolete("MelonLoader.MonoInternals.MonoResolveManager.GetAssemblyResolveInfo is Only Here for Compatibility Reasons. Please use MelonLoader.Resolver.MelonAssemblyResolver.GetAssemblyResolveInfo instead. This will be removed in a future update.", true)] - public static AssemblyResolveInfo GetAssemblyResolveInfo(string name) - => (AssemblyResolveInfo)Resolver.AssemblyManager.GetInfo(name); - - [Obsolete("MelonLoader.MonoInternals.MonoResolveManager.LoadInfoFromAssembly is Only Here for Compatibility Reasons. Please use MelonLoader.Resolver.MelonAssemblyResolver.LoadInfoFromAssembly instead. This will be removed in a future update.", true)] - public static void LoadInfoFromAssembly(Assembly assembly) - => Resolver.AssemblyManager.LoadInfo(assembly); - } -} diff --git a/MelonLoader/BackwardsCompatibility/Melon/bHaptics.cs b/MelonLoader/BackwardsCompatibility/Melon/bHaptics.cs deleted file mode 100644 index 0d57b6f81..000000000 --- a/MelonLoader/BackwardsCompatibility/Melon/bHaptics.cs +++ /dev/null @@ -1,259 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -#pragma warning disable 0618 - -namespace MelonLoader -{ - public static class bHaptics - { - public static bool WasError { get => false; } - - [Obsolete("MelonLoader.bHaptics.IsPlaying is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.IsPlayingAny instead. This will be removed in a future update.", true)] - public static bool IsPlaying() - => bHapticsLib.bHapticsManager.IsPlayingAny(); - [Obsolete("MelonLoader.bHaptics.IsPlaying(string) is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.IsPlaying instead. This will be removed in a future update.", true)] - public static bool IsPlaying(string key) - => bHapticsLib.bHapticsManager.IsPlaying(key); - - [Obsolete("MelonLoader.bHaptics.IsDeviceConnected(DeviceType, bool) is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.IsDeviceConnected instead. This will be removed in a future update.", true)] - public static bool IsDeviceConnected(DeviceType type, bool isLeft = true) => IsDeviceConnected(DeviceTypeToPositionType(type, isLeft)); - [Obsolete("MelonLoader.bHaptics.IsDeviceConnected(PositionType) is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.IsDeviceConnected instead. This will be removed in a future update.", true)] - public static bool IsDeviceConnected(PositionType type) - => bHapticsLib.bHapticsManager.IsDeviceConnected(PositionTypeToPositionID(type)); - - [Obsolete("MelonLoader.bHaptics.IsFeedbackRegistered is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.IsPatternRegistered instead. This will be removed in a future update.", true)] - public static bool IsFeedbackRegistered(string key) - => bHapticsLib.bHapticsManager.IsPatternRegistered(key); - - [Obsolete("MelonLoader.bHaptics.RegisterFeedback is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.RegisterPatternFromJson instead. This will be removed in a future update.", true)] - public static void RegisterFeedback(string key, string tactFileStr) - { - TinyJSON.ProxyArray proxyArray = new TinyJSON.ProxyArray(); - proxyArray["project"] = TinyJSON.Decoder.Decode(tactFileStr); - bHapticsLib.bHapticsManager.RegisterPatternFromJson(key, TinyJSON.Encoder.Encode(proxyArray)); - } - - [Obsolete("MelonLoader.bHaptics.RegisterFeedbackFromTactFile is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.RegisterPatternFromJson instead. This will be removed in a future update.", true)] - public static void RegisterFeedbackFromTactFile(string key, string tactFileStr) - => bHapticsLib.bHapticsManager.RegisterPatternFromJson(key, tactFileStr); - [Obsolete("MelonLoader.bHaptics.RegisterFeedbackFromTactFileReflected is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.RegisterPatternSwappedFromJson instead. This will be removed in a future update.", true)] - public static void RegisterFeedbackFromTactFileReflected(string key, string tactFileStr) - => bHapticsLib.bHapticsManager.RegisterPatternSwappedFromJson(key, tactFileStr); - - [Obsolete("MelonLoader.bHaptics.SubmitRegistered is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.PlayRegistered instead. This will be removed in a future update.", true)] - public static void SubmitRegistered(string key) - => bHapticsLib.bHapticsManager.PlayRegistered(key); - [Obsolete("MelonLoader.bHaptics.SubmitRegistered is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.PlayRegistered instead. This will be removed in a future update.", true)] - public static void SubmitRegistered(string key, int startTimeMillis) - => bHapticsLib.bHapticsManager.PlayRegistered(key, startTimeMillis); - [Obsolete("MelonLoader.bHaptics.SubmitRegistered is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.PlayRegistered instead. This will be removed in a future update.", true)] - public static void SubmitRegistered(string key, string altKey, ScaleOption option) - => bHapticsLib.bHapticsManager.PlayRegistered(key, altKey, - new bHapticsLib.ScaleOption { Duration = option.Duration, Intensity = option.Intensity }); - [Obsolete("MelonLoader.bHaptics.SubmitRegistered is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.PlayRegistered instead. This will be removed in a future update.", true)] - public static void SubmitRegistered(string key, string altKey, ScaleOption sOption, RotationOption rOption) - => bHapticsLib.bHapticsManager.PlayRegistered(key, altKey, - new bHapticsLib.ScaleOption { Duration = sOption.Duration, Intensity = sOption.Intensity }, - new bHapticsLib.RotationOption { OffsetAngleX = rOption.OffsetX, OffsetY = rOption.OffsetY }); - - [Obsolete("MelonLoader.bHaptics.TurnOff is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.StopPlayingAll instead. This will be removed in a future update.", true)] - public static void TurnOff() - => bHapticsLib.bHapticsManager.StopPlayingAll(); - [Obsolete("MelonLoader.bHaptics.TurnOff(string) is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.StopPlaying instead. This will be removed in a future update.", true)] - public static void TurnOff(string key) - => bHapticsLib.bHapticsManager.StopPlaying(key); - - [Obsolete("MelonLoader.bHaptics.Submit is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.Play instead. This will be removed in a future update.", true)] - public static void Submit(string key, DeviceType type, bool isLeft, byte[] bytes, int durationMillis) => Submit(key, DeviceTypeToPositionType(type, isLeft), bytes, durationMillis); - [Obsolete("MelonLoader.bHaptics.Submit is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.Play instead. This will be removed in a future update.", true)] - public static void Submit(string key, PositionType position, byte[] bytes, int durationMillis) - => bHapticsLib.bHapticsManager.Play(key, durationMillis, PositionTypeToPositionID(position), bytes); - - [Obsolete] - private static Converter DotPointConverter = new Converter((x) - => new bHapticsLib.DotPoint - { - Index = x.Index, - Intensity = x.Intensity - }); - [Obsolete("MelonLoader.bHaptics.Submit is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.Play instead. This will be removed in a future update.", true)] - public static void Submit(string key, DeviceType type, bool isLeft, List points, int durationMillis) => Submit(key, DeviceTypeToPositionType(type, isLeft), points, durationMillis); - [Obsolete("MelonLoader.bHaptics.Submit is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.Play instead. This will be removed in a future update.", true)] - public static void Submit(string key, PositionType position, List points, int durationMillis) - => bHapticsLib.bHapticsManager.Play(key, durationMillis, PositionTypeToPositionID(position), points.ConvertAll(DotPointConverter)); - - [Obsolete] - private static Converter PathPointConverter = new Converter((x) - => new bHapticsLib.PathPoint - { - X = x.X, - Y = x.Y, - Intensity = x.Intensity, - MotorCount = x.MotorCount - }); - [Obsolete("MelonLoader.bHaptics.Submit is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.Play instead. This will be removed in a future update.", true)] - public static void Submit(string key, DeviceType type, bool isLeft, List points, int durationMillis) => Submit(key, DeviceTypeToPositionType(type, isLeft), points, durationMillis); - [Obsolete("MelonLoader.bHaptics.Submit is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.Play instead. This will be removed in a future update.", true)] - public static void Submit(string key, PositionType position, List points, int durationMillis) - => bHapticsLib.bHapticsManager.Play(key, durationMillis, PositionTypeToPositionID(position), (bHapticsLib.DotPoint[])null, points.ConvertAll(PathPointConverter)); - - [Obsolete("MelonLoader.bHaptics.GetCurrentFeedbackStatus is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.GetDeviceStatus instead. This will be removed in a future update.", true)] - public static FeedbackStatus GetCurrentFeedbackStatus(DeviceType type, bool isLeft = true) => GetCurrentFeedbackStatus(DeviceTypeToPositionType(type, isLeft)); - [Obsolete("MelonLoader.bHaptics.GetCurrentFeedbackStatus is Only Here for Compatibility Reasons. Please use bHapticsLib.bHapticsManager.GetDeviceStatus instead. This will be removed in a future update.", true)] - public static FeedbackStatus GetCurrentFeedbackStatus(PositionType pos) - => new FeedbackStatus { values = bHapticsLib.bHapticsManager.GetDeviceStatus(PositionTypeToPositionID(pos)) }; - - [Obsolete("MelonLoader.bHaptics.DeviceTypeToPositionType is Only Here for Compatibility Reasons. This will be removed in a future update.", true)] - public static PositionType DeviceTypeToPositionType(DeviceType pos, bool isLeft = true) - => (pos) switch - { - DeviceType.Tactal => PositionType.Head, - DeviceType.TactSuit => PositionType.Vest, - DeviceType.Tactosy_arms => isLeft ? PositionType.ForearmL : PositionType.ForearmR, - DeviceType.Tactosy_feet => isLeft ? PositionType.FootL : PositionType.FootR, - DeviceType.Tactosy_hands => isLeft ? PositionType.HandL : PositionType.HandR, - _ => PositionType.Head - }; - - [Obsolete("MelonLoader.bHaptics.DeviceType is Only Here for Compatibility Reasons. This will be removed in a future update.", true)] - public enum DeviceType - { - None = 0, - Tactal = 1, - TactSuit = 2, - Tactosy_arms = 3, - Tactosy_hands = 4, - Tactosy_feet = 5 - } - - [Obsolete("MelonLoader.bHaptics.PositionType is Only Here for Compatibility Reasons. Please use bHapticsLib.PositionID instead. This will be removed in a future update.", true)] - public enum PositionType - { - All = 0, - Left = 1, - Right = 2, - Vest = 3, - Head = 4, - Racket = 5, - HandL = 6, - HandR = 7, - FootL = 8, - FootR = 9, - ForearmL = 10, - ForearmR = 11, - VestFront = 201, - VestBack = 202, - GloveLeft = 203, - GloveRight = 204, - Custom1 = 251, - Custom2 = 252, - Custom3 = 253, - Custom4 = 254 - } - - [Obsolete("MelonLoader.bHaptics.RotationOption is Only Here for Compatibility Reasons. Please use bHapticsLib.RotationOption instead. This will be removed in a future update.", true)] - public class RotationOption - { - public float OffsetX, OffsetY; - - public RotationOption(float offsetX, float offsetY) - { - OffsetX = offsetX; - OffsetY = offsetY; - } - - public override string ToString() => "RotationOption { OffsetX=" + OffsetX.ToString() + - ", OffsetY=" + OffsetY.ToString() + " }"; - } - - [Obsolete("MelonLoader.bHaptics.ScaleOption is Only Here for Compatibility Reasons. Please use bHapticsLib.ScaleOption instead. This will be removed in a future update.", true)] - public class ScaleOption - { - public float Intensity, Duration; - - public ScaleOption(float intensity = 1f, float duration = 1f) - { - Intensity = intensity; - Duration = duration; - } - - public override string ToString() => "ScaleOption { Intensity=" + Intensity.ToString() + - ", Duration=" + Duration.ToString() + " }"; - } - - [Obsolete("MelonLoader.bHaptics.DotPoint is Only Here for Compatibility Reasons. Please use bHapticsLib.DotPoint instead. This will be removed in a future update.", true)] - public class DotPoint - { - public int Index, Intensity; - - public DotPoint(int index, int intensity = 50) - { - if ((index < 0) || (index > 19)) - throw new Exception("Invalid argument index : " + index); - Intensity = MelonUtils.Clamp(intensity, 0, 100); - Index = index; - } - - public override string ToString() => "DotPoint { Index=" + Index.ToString() + - ", Intensity=" + Intensity.ToString() + " }"; - } - - [Obsolete("MelonLoader.bHaptics.PathPoint is Only Here for Compatibility Reasons. Please use bHapticsLib.PathPoint instead. This will be removed in a future update.", true)] - [StructLayout(LayoutKind.Sequential)] - public struct PathPoint - { - public float X, Y; - public int Intensity; - public int MotorCount; - - public PathPoint(float x, float y, int intensity = 50, int motorCount = 3) - { - X = MelonUtils.Clamp(x, 0f, 1f); - Y = MelonUtils.Clamp(y, 0f, 1f); - Intensity = MelonUtils.Clamp(intensity, 0, 100); - MotorCount = MelonUtils.Clamp(motorCount, 0, 3); - } - - public override string ToString() => "PathPoint { X=" + X.ToString() + - ", Y=" + Y.ToString() + - ", MotorCount=" + MotorCount.ToString() + - ", Intensity=" + Intensity.ToString() + " }"; - } - - [Obsolete("MelonLoader.bHaptics.FeedbackStatus is Only Here for Compatibility Reasons. This will be removed in a future update.", true)] - [StructLayout(LayoutKind.Sequential)] - public struct FeedbackStatus - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] - public int[] values; - }; - - [Obsolete] - private static bHapticsLib.PositionID PositionTypeToPositionID(PositionType pos) - => (pos) switch - { - //PositionType.All => bHapticsLib.PositionID.All, - //PositionType.Left => bHapticsLib.PositionID.Left, - //PositionType.Right => bHapticsLib.PositionID.Right, - PositionType.Vest => bHapticsLib.PositionID.Vest, - PositionType.Head => bHapticsLib.PositionID.Head, - //PositionType.Racket => bHapticsLib.PositionID.Racket, - PositionType.HandL => bHapticsLib.PositionID.HandLeft, - PositionType.HandR => bHapticsLib.PositionID.HandRight, - PositionType.FootL => bHapticsLib.PositionID.FootLeft, - PositionType.FootR => bHapticsLib.PositionID.FootRight, - PositionType.ForearmL => bHapticsLib.PositionID.ArmLeft, - PositionType.ForearmR => bHapticsLib.PositionID.ArmRight, - PositionType.VestFront => bHapticsLib.PositionID.VestFront, - PositionType.VestBack => bHapticsLib.PositionID.VestBack, - PositionType.GloveLeft => bHapticsLib.PositionID.GloveLeft, - PositionType.GloveRight => bHapticsLib.PositionID.GloveRight, - //PositionType.Custom1 => bHapticsLib.PositionID.Custom1, - //PositionType.Custom2 => bHapticsLib.PositionID.Custom2, - //PositionType.Custom3 => bHapticsLib.PositionID.Custom3, - //PositionType.Custom4 => bHapticsLib.PositionID.Custom4, - _ => bHapticsLib.PositionID.Head - }; - } -} \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/Decoder.cs b/MelonLoader/BackwardsCompatibility/TinyJSON/Decoder.cs deleted file mode 100644 index 00cfce72d..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/Decoder.cs +++ /dev/null @@ -1,393 +0,0 @@ -using System.IO; -using System.Text; -using System; - -namespace MelonLoader.TinyJSON -{ - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public sealed class Decoder : IDisposable - { - const string whiteSpace = " \t\n\r"; - const string wordBreak = " \t\n\r{}[],:\""; - - enum Token - { - None, - OpenBrace, - CloseBrace, - OpenBracket, - CloseBracket, - Colon, - Comma, - String, - Number, - True, - False, - Null - } - - StringReader json; - - - Decoder( string jsonString ) - { - json = new StringReader( jsonString ); - } - - - public static Variant Decode( string jsonString ) - { - using (var instance = new Decoder( jsonString )) - { - return instance.DecodeValue(); - } - } - - - public void Dispose() - { - json.Dispose(); - json = null; - } - - - ProxyObject DecodeObject() - { - var proxy = new ProxyObject(); - - // Ditch opening brace. - json.Read(); - - // { - while (true) - { - // ReSharper disable once SwitchStatementMissingSomeCases - switch (NextToken) - { - case Token.None: - return null; - - case Token.Comma: - continue; - - case Token.CloseBrace: - return proxy; - - default: - // Key - string key = DecodeString(); - if (key == null) - { - return null; - } - - // : - if (NextToken != Token.Colon) - { - return null; - } - - json.Read(); - - // Value - proxy.Add( key, DecodeValue() ); - break; - } - } - } - - - ProxyArray DecodeArray() - { - var proxy = new ProxyArray(); - - // Ditch opening bracket. - json.Read(); - - // [ - var parsing = true; - while (parsing) - { - var nextToken = NextToken; - - // ReSharper disable once SwitchStatementMissingSomeCases - switch (nextToken) - { - case Token.None: - return null; - - case Token.Comma: - continue; - - case Token.CloseBracket: - parsing = false; - break; - - default: - proxy.Add( DecodeByToken( nextToken ) ); - break; - } - } - - return proxy; - } - - - Variant DecodeValue() - { - var nextToken = NextToken; - return DecodeByToken( nextToken ); - } - - - Variant DecodeByToken( Token token ) - { - // ReSharper disable once SwitchStatementMissingSomeCases - switch (token) - { - case Token.String: - return DecodeString(); - - case Token.Number: - return DecodeNumber(); - - case Token.OpenBrace: - return DecodeObject(); - - case Token.OpenBracket: - return DecodeArray(); - - case Token.True: - return new ProxyBoolean( true ); - - case Token.False: - return new ProxyBoolean( false ); - - case Token.Null: - return null; - - default: - return null; - } - } - - - Variant DecodeString() - { - var stringBuilder = new StringBuilder(); - - // ditch opening quote - json.Read(); - - var parsing = true; - while (parsing) - { - if (json.Peek() == -1) - { - // ReSharper disable once RedundantAssignment - parsing = false; - break; - } - - var c = NextChar; - switch (c) - { - case '"': - parsing = false; - break; - - case '\\': - if (json.Peek() == -1) - { - parsing = false; - break; - } - - c = NextChar; - - // ReSharper disable once SwitchStatementMissingSomeCases - switch (c) - { - case '"': - case '\\': - case '/': - stringBuilder.Append( c ); - break; - - case 'b': - stringBuilder.Append( '\b' ); - break; - - case 'f': - stringBuilder.Append( '\f' ); - break; - - case 'n': - stringBuilder.Append( '\n' ); - break; - - case 'r': - stringBuilder.Append( '\r' ); - break; - - case 't': - stringBuilder.Append( '\t' ); - break; - - case 'u': - var hex = new StringBuilder(); - - for (var i = 0; i < 4; i++) - { - hex.Append( NextChar ); - } - - stringBuilder.Append( (char) Convert.ToInt32( hex.ToString(), 16 ) ); - break; - - //default: - // throw new DecodeException( @"Illegal character following escape character: " + c ); - } - - break; - - default: - stringBuilder.Append( c ); - break; - } - } - - return new ProxyString( stringBuilder.ToString() ); - } - - - Variant DecodeNumber() - { - return new ProxyNumber( NextWord ); - } - - - void ConsumeWhiteSpace() - { - while (whiteSpace.IndexOf( PeekChar ) != -1) - { - json.Read(); - - if (json.Peek() == -1) - { - break; - } - } - } - - - char PeekChar - { - get - { - var peek = json.Peek(); - return peek == -1 ? '\0' : Convert.ToChar( peek ); - } - } - - - char NextChar - { - get - { - return Convert.ToChar( json.Read() ); - } - } - - - string NextWord - { - get - { - var word = new StringBuilder(); - - while (wordBreak.IndexOf( PeekChar ) == -1) - { - word.Append( NextChar ); - - if (json.Peek() == -1) - { - break; - } - } - - return word.ToString(); - } - } - - - Token NextToken - { - get - { - ConsumeWhiteSpace(); - - if (json.Peek() == -1) - { - return Token.None; - } - - // ReSharper disable once SwitchStatementMissingSomeCases - switch (PeekChar) - { - case '{': - return Token.OpenBrace; - - case '}': - json.Read(); - return Token.CloseBrace; - - case '[': - return Token.OpenBracket; - - case ']': - json.Read(); - return Token.CloseBracket; - - case ',': - json.Read(); - return Token.Comma; - - case '"': - return Token.String; - - case ':': - return Token.Colon; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': - return Token.Number; - } - - // ReSharper disable once SwitchStatementMissingSomeCases - switch (NextWord) - { - case "false": - return Token.False; - - case "true": - return Token.True; - - case "null": - return Token.Null; - } - - return Token.None; - } - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/EncodeOptions.cs b/MelonLoader/BackwardsCompatibility/TinyJSON/EncodeOptions.cs deleted file mode 100644 index 69b56540f..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/EncodeOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace MelonLoader.TinyJSON -{ - [Flags] - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public enum EncodeOptions - { - None = 0, - PrettyPrint = 1, - NoTypeHints = 2, - IncludePublicProperties = 4, - EnforceHierarchyOrder = 8, - - [Obsolete( "Use EncodeOptions.EnforceHierarchyOrder instead." )] - EnforceHeirarchyOrder = EnforceHierarchyOrder - } -} diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/Encoder.cs b/MelonLoader/BackwardsCompatibility/TinyJSON/Encoder.cs deleted file mode 100644 index d77f940c1..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/Encoder.cs +++ /dev/null @@ -1,612 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Reflection; -using System.Text; - -namespace MelonLoader.TinyJSON -{ - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public sealed class Encoder - { - static readonly Type includeAttrType = typeof(Include); - static readonly Type excludeAttrType = typeof(Exclude); - static readonly Type typeHintAttrType = typeof(TypeHint); - - readonly StringBuilder builder; - readonly EncodeOptions options; - int indent; - - - Encoder( EncodeOptions options ) - { - this.options = options; - builder = new StringBuilder(); - indent = 0; - } - - - // ReSharper disable once UnusedMember.Global - public static string Encode( object obj ) - { - return Encode( obj, EncodeOptions.None ); - } - - - public static string Encode( object obj, EncodeOptions options ) - { - var instance = new Encoder( options ); - instance.EncodeValue( obj, false ); - return instance.builder.ToString(); - } - - - bool PrettyPrintEnabled - { - get - { - return (options & EncodeOptions.PrettyPrint) == EncodeOptions.PrettyPrint; - } - } - - - bool TypeHintsEnabled - { - get - { - return (options & EncodeOptions.NoTypeHints) != EncodeOptions.NoTypeHints; - } - } - - - bool IncludePublicPropertiesEnabled - { - get - { - return (options & EncodeOptions.IncludePublicProperties) == EncodeOptions.IncludePublicProperties; - } - } - - - bool EnforceHierarchyOrderEnabled - { - get - { - return (options & EncodeOptions.EnforceHierarchyOrder) == EncodeOptions.EnforceHierarchyOrder; - } - } - - - void EncodeValue( object value, bool forceTypeHint ) - { - if (value == null) - { - builder.Append( "null" ); - return; - } - - if (value is string) - { - EncodeString( (string) value ); - return; - } - - if (value is ProxyString) - { - EncodeString( ((ProxyString) value).ToString( CultureInfo.InvariantCulture ) ); - return; - } - - if (value is char) - { - EncodeString( value.ToString() ); - return; - } - - if (value is bool) - { - builder.Append( (bool) value ? "true" : "false" ); - return; - } - - if (value is Enum) - { - EncodeString( value.ToString() ); - return; - } - - if (value is Array) - { - EncodeArray( (Array) value, forceTypeHint ); - return; - } - - if (value is IList) - { - EncodeList( (IList) value, forceTypeHint ); - return; - } - - if (value is IDictionary) - { - EncodeDictionary( (IDictionary) value, forceTypeHint ); - return; - } - - if (value is Guid) - { - EncodeString( value.ToString() ); - return; - } - - if (value is ProxyArray) - { - EncodeProxyArray( (ProxyArray) value ); - return; - } - - if (value is ProxyObject) - { - EncodeProxyObject( (ProxyObject) value ); - return; - } - - if (value is float || - value is double || - value is int || - value is uint || - value is long || - value is sbyte || - value is byte || - value is short || - value is ushort || - value is ulong || - value is decimal || - value is ProxyBoolean || - value is ProxyNumber) - { - builder.Append( Convert.ToString( value, CultureInfo.InvariantCulture ) ); - return; - } - - EncodeObject( value, forceTypeHint ); - } - - - IEnumerable GetFieldsForType( Type type ) - { - if (EnforceHierarchyOrderEnabled) - { - var types = new Stack(); - while (type != null) - { - types.Push( type ); - type = type.BaseType; - } - - var fields = new List(); - while (types.Count > 0) - { - fields.AddRange( types.Pop().GetFields( BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ) ); - } - - return fields; - } - - return type.GetFields( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ); - } - - - IEnumerable GetPropertiesForType( Type type ) - { - if (EnforceHierarchyOrderEnabled) - { - var types = new Stack(); - while (type != null) - { - types.Push( type ); - type = type.BaseType; - } - - var properties = new List(); - while (types.Count > 0) - { - properties.AddRange( types.Pop().GetProperties( BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ) ); - } - - return properties; - } - - return type.GetProperties( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ); - } - - - void EncodeObject( object value, bool forceTypeHint ) - { - var type = value.GetType(); - - AppendOpenBrace(); - - forceTypeHint = forceTypeHint || TypeHintsEnabled; - - var includePublicProperties = IncludePublicPropertiesEnabled; - - var firstItem = !forceTypeHint; - if (forceTypeHint) - { - if (PrettyPrintEnabled) - { - AppendIndent(); - } - - EncodeString( ProxyObject.TypeHintKey ); - AppendColon(); - EncodeString( type.FullName ); - - // ReSharper disable once RedundantAssignment - firstItem = false; - } - - foreach (var field in GetFieldsForType( type )) - { - var shouldTypeHint = false; - var shouldEncode = field.IsPublic; - foreach (var attribute in field.GetCustomAttributes( true )) - { - if (excludeAttrType.IsInstanceOfType( attribute )) - { - shouldEncode = false; - } - - if (includeAttrType.IsInstanceOfType( attribute )) - { - shouldEncode = true; - } - - if (typeHintAttrType.IsInstanceOfType( attribute )) - { - shouldTypeHint = true; - } - } - - if (shouldEncode) - { - AppendComma( firstItem ); - EncodeString( field.Name ); - AppendColon(); - EncodeValue( field.GetValue( value ), shouldTypeHint ); - firstItem = false; - } - } - - foreach (var property in GetPropertiesForType( type )) - { - if (property.CanRead) - { - var shouldTypeHint = false; - var shouldEncode = includePublicProperties; - - foreach (var attribute in property.GetCustomAttributes( true )) - { - if (excludeAttrType.IsInstanceOfType( attribute )) - { - shouldEncode = false; - } - - if (includeAttrType.IsInstanceOfType( attribute )) - { - shouldEncode = true; - } - - if (typeHintAttrType.IsInstanceOfType( attribute )) - { - shouldTypeHint = true; - } - } - - if (shouldEncode) - { - AppendComma( firstItem ); - EncodeString( property.Name ); - AppendColon(); - EncodeValue( property.GetValue( value, null ), shouldTypeHint ); - firstItem = false; - } - } - } - - AppendCloseBrace(); - } - - - void EncodeProxyArray( ProxyArray value ) - { - if (value.Count == 0) - { - builder.Append( "[]" ); - } - else - { - AppendOpenBracket(); - - var firstItem = true; - foreach (var obj in value) - { - AppendComma( firstItem ); - EncodeValue( obj, false ); - firstItem = false; - } - - AppendCloseBracket(); - } - } - - - void EncodeProxyObject( ProxyObject value ) - { - if (value.Count == 0) - { - builder.Append( "{}" ); - } - else - { - AppendOpenBrace(); - - var firstItem = true; - foreach (var e in value.Keys) - { - AppendComma( firstItem ); - EncodeString( e ); - AppendColon(); - EncodeValue( value[e], false ); - firstItem = false; - } - - AppendCloseBrace(); - } - } - - - void EncodeDictionary( IDictionary value, bool forceTypeHint ) - { - if (value.Count == 0) - { - builder.Append( "{}" ); - } - else - { - AppendOpenBrace(); - - var firstItem = true; - foreach (var e in value.Keys) - { - AppendComma( firstItem ); - EncodeString( e.ToString() ); - AppendColon(); - EncodeValue( value[e], forceTypeHint ); - firstItem = false; - } - - AppendCloseBrace(); - } - } - - - // ReSharper disable once SuggestBaseTypeForParameter - void EncodeList( IList value, bool forceTypeHint ) - { - if (value.Count == 0) - { - builder.Append( "[]" ); - } - else - { - AppendOpenBracket(); - - var firstItem = true; - foreach (var obj in value) - { - AppendComma( firstItem ); - EncodeValue( obj, forceTypeHint ); - firstItem = false; - } - - AppendCloseBracket(); - } - } - - - void EncodeArray( Array value, bool forceTypeHint ) - { - if (value.Rank == 1) - { - EncodeList( value, forceTypeHint ); - } - else - { - var indices = new int[value.Rank]; - EncodeArrayRank( value, 0, indices, forceTypeHint ); - } - } - - - void EncodeArrayRank( Array value, int rank, int[] indices, bool forceTypeHint ) - { - AppendOpenBracket(); - - var min = value.GetLowerBound( rank ); - var max = value.GetUpperBound( rank ); - - if (rank == value.Rank - 1) - { - for (var i = min; i <= max; i++) - { - indices[rank] = i; - AppendComma( i == min ); - EncodeValue( value.GetValue( indices ), forceTypeHint ); - } - } - else - { - for (var i = min; i <= max; i++) - { - indices[rank] = i; - AppendComma( i == min ); - EncodeArrayRank( value, rank + 1, indices, forceTypeHint ); - } - } - - AppendCloseBracket(); - } - - - void EncodeString( string value ) - { - builder.Append( '\"' ); - - var charArray = value.ToCharArray(); - foreach (var c in charArray) - { - switch (c) - { - case '"': - builder.Append( "\\\"" ); - break; - - case '\\': - builder.Append( "\\\\" ); - break; - - case '\b': - builder.Append( "\\b" ); - break; - - case '\f': - builder.Append( "\\f" ); - break; - - case '\n': - builder.Append( "\\n" ); - break; - - case '\r': - builder.Append( "\\r" ); - break; - - case '\t': - builder.Append( "\\t" ); - break; - - default: - var codepoint = Convert.ToInt32( c ); - if ((codepoint >= 32) && (codepoint <= 126)) - { - builder.Append( c ); - } - else - { - builder.Append( "\\u" + Convert.ToString( codepoint, 16 ).PadLeft( 4, '0' ) ); - } - - break; - } - } - - builder.Append( '\"' ); - } - - - #region Helpers - - void AppendIndent() - { - for (var i = 0; i < indent; i++) - { - builder.Append( '\t' ); - } - } - - - void AppendOpenBrace() - { - builder.Append( '{' ); - - if (PrettyPrintEnabled) - { - builder.Append( '\n' ); - indent++; - } - } - - - void AppendCloseBrace() - { - if (PrettyPrintEnabled) - { - builder.Append( '\n' ); - indent--; - AppendIndent(); - } - - builder.Append( '}' ); - } - - - void AppendOpenBracket() - { - builder.Append( '[' ); - - if (PrettyPrintEnabled) - { - builder.Append( '\n' ); - indent++; - } - } - - - void AppendCloseBracket() - { - if (PrettyPrintEnabled) - { - builder.Append( '\n' ); - indent--; - AppendIndent(); - } - - builder.Append( ']' ); - } - - - void AppendComma( bool firstItem ) - { - if (!firstItem) - { - builder.Append( ',' ); - - if (PrettyPrintEnabled) - { - builder.Append( '\n' ); - } - } - - if (PrettyPrintEnabled) - { - AppendIndent(); - } - } - - - void AppendColon() - { - builder.Append( ':' ); - - if (PrettyPrintEnabled) - { - builder.Append( ' ' ); - } - } - - #endregion - } -} diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/Extensions.cs b/MelonLoader/BackwardsCompatibility/TinyJSON/Extensions.cs deleted file mode 100644 index 14b014b1d..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/Extensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MelonLoader.TinyJSON -{ - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public static class Extensions - { - public static bool AnyOfType( this IEnumerable source, Type expectedType ) - { - if (source == null) - { - throw new ArgumentNullException( "source" ); - } - - if (expectedType == null) - { - throw new ArgumentNullException( "expectedType" ); - } - - foreach (var item in source) - { - if (expectedType.IsInstanceOfType( item )) - { - return true; - } - } - - return false; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/JSON.cs b/MelonLoader/BackwardsCompatibility/TinyJSON/JSON.cs deleted file mode 100644 index 0bd22fa48..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/JSON.cs +++ /dev/null @@ -1,666 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Reflection; - -namespace MelonLoader.TinyJSON -{ - /// - /// Mark members that should be included. - /// Public fields are included by default. - /// - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - [AttributeUsage( AttributeTargets.Field | AttributeTargets.Property )] - public sealed class Include : Attribute {} - - - /// - /// Mark members that should be excluded. - /// Private fields and all properties are excluded by default. - /// - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - [AttributeUsage( AttributeTargets.Field | AttributeTargets.Property )] - public class Exclude : Attribute {} - - - /// - /// Mark methods to be called after an object is decoded. - /// - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - [AttributeUsage( AttributeTargets.Method )] - public class AfterDecode : Attribute {} - - - /// - /// Mark methods to be called before an object is encoded. - /// - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - [AttributeUsage( AttributeTargets.Method )] - public class BeforeEncode : Attribute {} - - - /// - /// Mark members to force type hinting even when EncodeOptions.NoTypeHints is set. - /// - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - [AttributeUsage( AttributeTargets.Field | AttributeTargets.Property )] - public class TypeHint : Attribute {} - - - /// - /// Provide field and property aliases when an object is decoded. - /// If a field or property is not found while decoding, this list will be searched for a matching alias. - /// - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - [AttributeUsage( AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true )] - public class DecodeAlias : Attribute - { - public string[] Names { get; private set; } - - - public DecodeAlias( params string[] names ) - { - Names = names; - } - - - public bool Contains( string name ) - { - return Array.IndexOf( Names, name ) > -1; - } - } - - // ReSharper disable once UnusedMember.Global - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public sealed class Skip : Exclude {} - - // ReSharper disable once UnusedMember.Global - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public sealed class Load : AfterDecode {} - - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public sealed class DecodeException : Exception - { - public DecodeException( string message ) - : base( message ) {} - - - public DecodeException( string message, Exception innerException ) - : base( message, innerException ) {} - } - - - // ReSharper disable once InconsistentNaming - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public static class JSON - { - static readonly Type includeAttrType = typeof(Include); - static readonly Type excludeAttrType = typeof(Exclude); - static readonly Type decodeAliasAttrType = typeof(DecodeAlias); - - - public static Variant Load( string json ) - { - if (string.IsNullOrEmpty(json)) - { - throw new ArgumentNullException( "json" ); - } - - return Decoder.Decode( json ); - } - - - public static string Dump( object data ) - { - return Dump( data, EncodeOptions.None ); - } - - - public static string Dump( object data, EncodeOptions options ) - { - // Invoke methods tagged with [BeforeEncode] attribute. - if (data != null) - { - var type = data.GetType(); - if (!(type.IsEnum || type.IsPrimitive || type.IsArray)) - { - foreach (var method in type.GetMethods( instanceBindingFlags )) - { - if (method.GetCustomAttributes( false ).AnyOfType( typeof(BeforeEncode) )) - { - if (method.GetParameters().Length == 0) - { - method.Invoke( data, null ); - } - } - } - } - } - - return Encoder.Encode( data, options ); - } - - - public static void MakeInto( Variant data, out T item ) - { - item = DecodeType( data ); - } - - - public static void Populate( Variant data, T item ) where T : class - { - if (item == null) - { - throw new ArgumentNullException( nameof(item) ); - } - DecodeFields( data, ref item ); - } - - - static readonly Dictionary typeCache = new Dictionary(); - - static Type FindType( string fullName ) - { - if (fullName == null) - { - return null; - } - - Type type; - if (typeCache.TryGetValue( fullName, out type )) - { - return type; - } - - foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) - { - type = assembly.GetType( fullName ); - if (type != null) - { - typeCache.Add( fullName, type ); - return type; - } - } - - return null; - } - - static T DecodeType( Variant data ) - { - if (data == null) - { - return default(T); - } - - var type = typeof(T); - - Type nulledType = Nullable.GetUnderlyingType(type); - if (nulledType != null) - { - var makeFunc = decodeTypeMethod.MakeGenericMethod( nulledType ); - var v = makeFunc.Invoke( null, new object[] { data } ); - return (T) v; - } - - if (type.IsEnum) - { - return (T) Enum.Parse( type, data.ToString( CultureInfo.InvariantCulture ) ); - } - - if (type.IsPrimitive || type == typeof(string) || type == typeof(decimal)) - { - return (T) Convert.ChangeType( data, type ); - } - - if (type == typeof(Guid)) - { - return (T) (object) new Guid( data.ToString( CultureInfo.InvariantCulture ) ); - } - - if (type.IsArray) - { - if (type.GetArrayRank() == 1) - { - var makeFunc = decodeArrayMethod.MakeGenericMethod( type.GetElementType() ); - return (T) makeFunc.Invoke( null, new object[] { data } ); - } - - var arrayData = data as ProxyArray; - if (arrayData == null) - { - throw new DecodeException( "Variant is expected to be a ProxyArray here, but it is not." ); - } - - var arrayRank = type.GetArrayRank(); - var rankLengths = new int[arrayRank]; - if (arrayData.CanBeMultiRankArray( rankLengths )) - { - var elementType = type.GetElementType(); - if (elementType == null) - { - throw new DecodeException( "Array element type is expected to be not null, but it is." ); - } - - var array = Array.CreateInstance( elementType, rankLengths ); - var makeFunc = decodeMultiRankArrayMethod.MakeGenericMethod( elementType ); - try - { - makeFunc.Invoke( null, new object[] { arrayData, array, 1, rankLengths } ); - } - catch (Exception e) - { - throw new DecodeException( "Error decoding multidimensional array. Did you try to decode into an array of incompatible rank or element type?", e ); - } - - return (T) Convert.ChangeType( array, typeof(T) ); - } - - throw new DecodeException( "Error decoding multidimensional array; JSON data doesn't seem fit this structure." ); - } - - if (typeof(IList).IsAssignableFrom( type )) - { - var makeFunc = decodeListMethod.MakeGenericMethod( type.GetGenericArguments() ); - return (T) makeFunc.Invoke( null, new object[] { data } ); - } - - if (typeof(IDictionary).IsAssignableFrom( type )) - { - var makeFunc = decodeDictionaryMethod.MakeGenericMethod( type.GetGenericArguments() ); - return (T) makeFunc.Invoke( null, new object[] { data } ); - } - - // At this point we should be dealing with a class or struct. - T instance; - var proxyObject = data as ProxyObject; - if (proxyObject == null) - { - throw new InvalidCastException( "ProxyObject expected when decoding into '" + type.FullName + "'." ); - } - - // If there's a type hint, use it to create the instance. - var typeHint = proxyObject.TypeHint; - if (typeHint != null && typeHint != type.FullName) - { - var makeType = FindType( typeHint ); - if (makeType == null) - { - throw new TypeLoadException( "Could not load type '" + typeHint + "'." ); - } - - if (type.IsAssignableFrom( makeType )) - { - instance = (T) Activator.CreateInstance( makeType ); - type = makeType; - } - else - { - throw new InvalidCastException( "Cannot assign type '" + typeHint + "' to type '" + type.FullName + "'." ); - } - } - else - { - // We don't have a type hint, so just instantiate the type we have. - instance = Activator.CreateInstance(); - } - - foreach (var pair in proxyObject) - { - var field = type.GetField( pair.Key, instanceBindingFlags ); - - // If the field doesn't exist, search through any [DecodeAlias] attributes. - if (field == null) - { - var fields = type.GetFields( instanceBindingFlags ); - foreach (var fieldInfo in fields) - { - foreach (var attribute in fieldInfo.GetCustomAttributes( true )) - { - if (decodeAliasAttrType.IsInstanceOfType( attribute )) - { - if (((DecodeAlias) attribute).Contains( pair.Key )) - { - field = fieldInfo; - break; - } - } - } - } - } - - if (field != null) - { - var shouldDecode = field.IsPublic; - foreach (var attribute in field.GetCustomAttributes( true )) - { - if (excludeAttrType.IsInstanceOfType( attribute )) - { - shouldDecode = false; - } - - if (includeAttrType.IsInstanceOfType( attribute )) - { - shouldDecode = true; - } - } - - if (shouldDecode) - { - var makeFunc = decodeTypeMethod.MakeGenericMethod( field.FieldType ); - if (type.IsValueType) - { - // Type is a struct. - var instanceRef = (object) instance; - field.SetValue( instanceRef, makeFunc.Invoke( null, new object[] { pair.Value } ) ); - instance = (T) instanceRef; - } - else - { - // Type is a class. - field.SetValue( instance, makeFunc.Invoke( null, new object[] { pair.Value } ) ); - } - } - } - - var property = type.GetProperty( pair.Key, instanceBindingFlags ); - - // If the property doesn't exist, search through any [DecodeAlias] attributes. - if (property == null) - { - var properties = type.GetProperties( instanceBindingFlags ); - foreach (var propertyInfo in properties) - { - foreach (var attribute in propertyInfo.GetCustomAttributes( false )) - { - if (decodeAliasAttrType.IsInstanceOfType( attribute )) - { - if (((DecodeAlias) attribute).Contains( pair.Key )) - { - property = propertyInfo; - break; - } - } - } - } - } - - if (property != null) - { - if (property.CanWrite && property.GetCustomAttributes( false ).AnyOfType( includeAttrType )) - { - var makeFunc = decodeTypeMethod.MakeGenericMethod( new Type[] { property.PropertyType } ); - if (type.IsValueType) - { - // Type is a struct. - var instanceRef = (object) instance; - property.SetValue( instanceRef, makeFunc.Invoke( null, new object[] { pair.Value } ), null ); - instance = (T) instanceRef; - } - else - { - // Type is a class. - property.SetValue( instance, makeFunc.Invoke( null, new object[] { pair.Value } ), null ); - } - } - } - } - - // Invoke methods tagged with [AfterDecode] attribute. - foreach (var method in type.GetMethods( instanceBindingFlags )) - { - if (method.GetCustomAttributes( false ).AnyOfType( typeof(AfterDecode) )) - { - method.Invoke( instance, method.GetParameters().Length == 0 ? null : new object[] { data } ); - } - } - - return instance; - } - - static void DecodeFields( Variant data, ref T instance ) - { - var type = typeof(T); - var proxyObject = data as ProxyObject; - if (proxyObject == null) - { - throw new InvalidCastException( "ProxyObject expected when decoding into '" + type.FullName + "'." ); - } - - foreach (var pair in proxyObject) - { - var field = type.GetField( pair.Key, instanceBindingFlags ); - - // If the field doesn't exist, search through any [DecodeAlias] attributes. - if (field == null) - { - var fields = type.GetFields( instanceBindingFlags ); - foreach (var fieldInfo in fields) - { - foreach (var attribute in fieldInfo.GetCustomAttributes( true )) - { - if (decodeAliasAttrType.IsInstanceOfType( attribute )) - { - if (((DecodeAlias) attribute).Contains( pair.Key )) - { - field = fieldInfo; - break; - } - } - } - } - } - - if (field != null) - { - var shouldDecode = field.IsPublic; - foreach (var attribute in field.GetCustomAttributes( true )) - { - if (excludeAttrType.IsInstanceOfType( attribute )) - { - shouldDecode = false; - } - - if (includeAttrType.IsInstanceOfType( attribute )) - { - shouldDecode = true; - } - } - - if (shouldDecode) - { - var makeFunc = decodeTypeMethod.MakeGenericMethod( field.FieldType ); - if (type.IsValueType) - { - // Type is a struct. - var instanceRef = (object) instance; - field.SetValue( instanceRef, makeFunc.Invoke( null, new object[] { pair.Value } ) ); - instance = (T) instanceRef; - } - else - { - // Type is a class. - field.SetValue( instance, makeFunc.Invoke( null, new object[] { pair.Value } ) ); - } - } - } - - var property = type.GetProperty( pair.Key, instanceBindingFlags ); - - // If the property doesn't exist, search through any [DecodeAlias] attributes. - if (property == null) - { - var properties = type.GetProperties( instanceBindingFlags ); - foreach (var propertyInfo in properties) - { - foreach (var attribute in propertyInfo.GetCustomAttributes( false )) - { - if (decodeAliasAttrType.IsInstanceOfType( attribute )) - { - if (((DecodeAlias) attribute).Contains( pair.Key )) - { - property = propertyInfo; - break; - } - } - } - } - } - - if (property != null) - { - if (property.CanWrite && property.GetCustomAttributes( false ).AnyOfType( includeAttrType )) - { - var makeFunc = decodeTypeMethod.MakeGenericMethod( new Type[] { property.PropertyType } ); - if (type.IsValueType) - { - // Type is a struct. - var instanceRef = (object) instance; - property.SetValue( instanceRef, makeFunc.Invoke( null, new object[] { pair.Value } ), null ); - instance = (T) instanceRef; - } - else - { - // Type is a class. - property.SetValue( instance, makeFunc.Invoke( null, new object[] { pair.Value } ), null ); - } - } - } - } - - // Invoke methods tagged with [AfterDecode] attribute. - foreach (var method in type.GetMethods( instanceBindingFlags )) - { - if (method.GetCustomAttributes( false ).AnyOfType( typeof(AfterDecode) )) - { - method.Invoke( instance, method.GetParameters().Length == 0 ? null : new object[] { data } ); - } - } - } - - // ReSharper disable once UnusedMethodReturnValue.Local - static List DecodeList( Variant data ) - { - var list = new List(); - - var proxyArray = data as ProxyArray; - if (proxyArray == null) - { - throw new DecodeException( "Variant is expected to be a ProxyArray here, but it is not." ); - } - - foreach (var item in proxyArray) - { - list.Add( DecodeType( item ) ); - } - - return list; - } - - // ReSharper disable once UnusedMethodReturnValue.Local - static Dictionary DecodeDictionary( Variant data ) - { - var dict = new Dictionary(); - var type = typeof(TKey); - - var proxyObject = data as ProxyObject; - if (proxyObject == null) - { - throw new DecodeException( "Variant is expected to be a ProxyObject here, but it is not." ); - } - - foreach (var pair in proxyObject) - { - var k = (TKey) (type.IsEnum ? Enum.Parse( type, pair.Key ) : Convert.ChangeType( pair.Key, type )); - var v = DecodeType( pair.Value ); - dict.Add( k, v ); - } - - return dict; - } - - // ReSharper disable once UnusedMethodReturnValue.Local - static T[] DecodeArray( Variant data ) - { - var arrayData = data as ProxyArray; - if (arrayData == null) - { - throw new DecodeException( "Variant is expected to be a ProxyArray here, but it is not." ); - } - - var arraySize = arrayData.Count; - var array = new T[arraySize]; - - var i = 0; - foreach (var item in arrayData) - { - array[i++] = DecodeType( item ); - } - - return array; - } - - // ReSharper disable once UnusedMember.Local - static void DecodeMultiRankArray( ProxyArray arrayData, Array array, int arrayRank, int[] indices ) - { - var count = arrayData.Count; - for (var i = 0; i < count; i++) - { - indices[arrayRank - 1] = i; - if (arrayRank < array.Rank) - { - DecodeMultiRankArray( arrayData[i] as ProxyArray, array, arrayRank + 1, indices ); - } - else - { - array.SetValue( DecodeType( arrayData[i] ), indices ); - } - } - } - - - const BindingFlags instanceBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; - const BindingFlags staticBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static; - static readonly MethodInfo decodeTypeMethod = typeof(JSON).GetMethod( "DecodeType", staticBindingFlags ); - static readonly MethodInfo decodeListMethod = typeof(JSON).GetMethod( "DecodeList", staticBindingFlags ); - static readonly MethodInfo decodeDictionaryMethod = typeof(JSON).GetMethod( "DecodeDictionary", staticBindingFlags ); - static readonly MethodInfo decodeArrayMethod = typeof(JSON).GetMethod( "DecodeArray", staticBindingFlags ); - static readonly MethodInfo decodeMultiRankArrayMethod = typeof(JSON).GetMethod( "DecodeMultiRankArray", staticBindingFlags ); - - // ReSharper disable once InconsistentNaming - public static void SupportTypeForAOT() - { - DecodeType( null ); - DecodeList( null ); - DecodeArray( null ); - DecodeDictionary( null ); - DecodeDictionary( null ); - DecodeDictionary( null ); - DecodeDictionary( null ); - DecodeDictionary( null ); - DecodeDictionary( null ); - DecodeDictionary( null ); - DecodeDictionary( null ); - DecodeDictionary( null ); - DecodeDictionary( null ); - DecodeDictionary( null ); - } - - // ReSharper disable once InconsistentNaming - // ReSharper disable once UnusedMember.Local - static void SupportValueTypesForAOT() - { - SupportTypeForAOT(); - SupportTypeForAOT(); - SupportTypeForAOT(); - SupportTypeForAOT(); - SupportTypeForAOT(); - SupportTypeForAOT(); - SupportTypeForAOT(); - SupportTypeForAOT(); - SupportTypeForAOT(); - SupportTypeForAOT(); - SupportTypeForAOT(); - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/LICENSE.md b/MelonLoader/BackwardsCompatibility/TinyJSON/LICENSE.md deleted file mode 100644 index 5fa84f8d9..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/LICENSE.md +++ /dev/null @@ -1,26 +0,0 @@ -Copyright (c) 2013 Patrick Hogan - -Based on MiniJSON by Calvin Rien -https://gist.github.com/darktable/1411710 - -Based on the JSON parser by Patrick van Bergen -http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/README.md b/MelonLoader/BackwardsCompatibility/TinyJSON/README.md deleted file mode 100644 index 997981dec..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/README.md +++ /dev/null @@ -1,218 +0,0 @@ -## Description - -TinyJSON is a simple JSON library for C# that strives for ease of use. - -## Features - -* Transmogrify objects into JSON and back again. -* Uses reflection to dump and load object graphs automagically. -* Supports primitives, classes, structs, enums, lists, dictionaries and arrays. -* Supports single dimensional arrays, multidimensional arrays and jagged arrays. -* Parsed data uses proxy variants that can be implicitly cast to primitive types for cleaner code, or directly encoded back to JSON. -* Numeric types are handled without fuss. -* Polymorphic classes supported with a type hint encoded into the JSON. -* Supports optionally pretty printing JSON output. -* Supports optionally encode properties and private fields. -* Supports decoding fields and properties from aliased names. -* Unit tested. - -## Usage - -The API is namespaced under `TinyJSON` and the primary class is `JSON`. There are really only a few methods you need to know: - -```csharp -namespace TinyJSON -{ - public static class JSON - { - public static Variant Load( string json ); - public static string Dump( object data, EncodeOptions = EncodeOptions.None ); - public static void MakeInto( Variant data, out T item ); - } -} -``` - -`Load()` will load a string of JSON, returns `null` if invalid or a `Variant` proxy object if successful. The proxy allows for implicit casts and can convert between various C# numeric value types. - -```csharp -var data = JSON.Load( "{\"foo\": 1, \"bar\": 2.34}" ); -int i = data["foo"]; -float f = data["bar"]; -``` - -`Dump()` will take a C# object, list, dictionary or primitive value type and turn it into JSON. - -```csharp -var data = new List() { { 0 }, { 1 }, { 2 } }; -Console.WriteLine( JSON.Dump( data ) ); // output: [1,2,3] -``` - -TinyJSON can also handle classes, structs, enums and nested objects. Given these definitions: - -```csharp -enum TestEnum -{ - Thing1, - Thing2, - Thing3 -} - - -struct TestStruct -{ - public int x; - public int y; -} - - -class TestClass -{ - public string name; - public TestEnum type; - public List data = new List(); - - [Exclude] - public int _ignored; - - [BeforeEncode] - public void BeforeEncode() - { - Console.WriteLine( "BeforeEncode callback fired!" ); - } - - [AfterDecode] - public void AfterDecode() - { - Console.WriteLine( "AfterDecode callback fired!" ); - } -} -``` - -The following code: - -```csharp -var testClass = new TestClass(); -testClass.name = "Rumpelstiltskin Jones"; -testClass.type = TestEnum.Thing2; -testClass.data.Add( new TestStruct() { x = 1, y = 2 } ); -testClass.data.Add( new TestStruct() { x = 3, y = 4 } ); -testClass.data.Add( new TestStruct() { x = 5, y = 6 } ); - -var testClassJson = JSON.Dump( testClass, true ); -Console.WriteLine( testClassJson ); -``` - -Will output: - -```json -{ - "name": "Rumpelstiltskin Jones", - "type": "Thing2", - "data": [ - { - "x": 1, - "y": 2 - }, - { - "x": 3, - "y": 4 - }, - { - "x": 5, - "y": 6 - } - ] -} -``` - -You can use, `MakeInto()` can be used to reconstruct JSON data back into an object: - -```csharp -TestClass testClass; -JSON.MakeInto( JSON.Load( testClassJson ), out testClass ); -``` - -There are also `Make()` methods on `Variant` which provide options for slightly more natural syntax: - -```csharp -TestClass testClass; - -JSON.Load( json ).Make( out testClass ); -// or -testClass = JSON.Load( json ).Make(); -``` - -Finally, you'll notice that `TestClass` has the methods `BeforeEncode()` and `AfterDecode()` which have the `TinyJSON.BeforeEncode` and `TinyJSON.AfterDecode` attributes. These methods will be called *before* the object starts being serialized and *after* the object has been fully deserialized. This is useful when some further preparation or initialization logic is required. - -By default, only public fields are encoded, not properties or private fields. You can tag any field or property to be included with the `TinyJSON.Include` attribute, or force a public field to be excluded with the `TinyJSON.Exclude` attribute. - - -## Decode Aliases - -Fields and properties can be decoded from aliases using the `TinyJSON.DecodeAlias` attribute. While decoding, if no matching data is found in the JSON for a given field or property, its aliases will also be searched for. - -```csharp -class TestClass -{ - [DecodeAlias("anotherName")] - public string name; // decode from "name" or "anotherName" - - [DecodeAlias("anotherNumber", "yetAnotherNumber")] - public int number; // decode from "number", "anotherNumber", or "yetAnotherNumber" -} -``` - - -## Type Hinting - -When decoding polymorphic types, TinyJSON has no way of knowing which subclass to instantiate unless a type hint is included. So, by default, TinyJSON will add a key named `@type` to each encoded object with the fully qualified type of the object. - -## Encode Options - -Several options are currently available for JSON encoding, and can be passed in as a second parameter to `JSON.Dump()`. - -* `EncodeOptions.PrettyPrint` will output nicely formatted JSON to make it more readable. -* `EncodeOptions.NoTypeHints` will disable the outputting of type hints into the JSON output. This may be desirable if you plan to read the JSON into another application that might choke on the type information. You can override this on a per-member basis with the `TinyJSON.TypeHint` attribute. -* `EncodeOptions.IncludePublicProperties` will include public properties in the output. -* `EncodeOptions.EnforceHeirarchyOrder` will ensure fields and properties are encoded in class heirarchy order, from the root base class on down, but comes at a slight performance cost. - -## Using Variants - -For most use cases you can just assign, cast or make your object graph using the API outlined above, but at times you may need to work with the intermediate proxy objects to, say, dig through and iterate over a collection. To do this, cast the `Variant` to the appropriate subclass (likely either `ProxyArray` or `ProxyObject`) and you're good to go: - -```csharp -var list = JSON.Load( "[1,2,3]" ); -foreach (var item in list as ProxyArray) -{ - int number = item; - Console.WriteLine( number ); -} - -var dict = JSON.Load( "{\"x\":1,\"y\":2}" ); -foreach (var pair in dict as ProxyObject) -{ - float value = pair.Value; - Console.WriteLine( pair.Key + " = " + value ); -} -``` - -The non-collection `Variant` subclasses are `ProxyBoolean`, `ProxyNumber` and `ProxyString`. A variant can also be `null`. - -Any `Variant` object can be directly encoded to JSON by calling its `ToJSON()` method or passing it to `JSON.Dump()`. - -## Notes - -This project was developed with pain elimination and lightweight size in mind. It should be able to handle reasonable amounts of reasonable data at reasonable speeds, but it's not meant for massive data sets. - -The primary use case for this library is with Unity3D, so compatibility is focused there, though it should work with most modern C# environments. - -It has been used in several published games. It's good for preferences, level and progress data, etc. - -## Meta - -Handcrafted by Patrick Hogan [[twitter](http://twitter.com/pbhogan) • [github](http://github.com/pbhogan) • [website](http://www.gallantgames.com)] - -Based on [MiniJSON](https://gist.github.com/darktable/1411710) by Calvin Rien - -Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php). - diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyArray.cs b/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyArray.cs deleted file mode 100644 index befeb09a6..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyArray.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -namespace MelonLoader.TinyJSON -{ - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public sealed class ProxyArray : Variant, IEnumerable - { - readonly List list; - - - public ProxyArray() - { - list = new List(); - } - - - IEnumerator IEnumerable.GetEnumerator() - { - return list.GetEnumerator(); - } - - - IEnumerator IEnumerable.GetEnumerator() - { - return list.GetEnumerator(); - } - - - public void Add( Variant item ) - { - list.Add( item ); - } - - - public override Variant this[ int index ] - { - get - { - return list[index]; - } - set - { - list[index] = value; - } - } - - - public int Count - { - get - { - return list.Count; - } - } - - - internal bool CanBeMultiRankArray( int[] rankLengths ) - { - return CanBeMultiRankArray( 0, rankLengths ); - } - - - bool CanBeMultiRankArray( int rank, int[] rankLengths ) - { - var count = list.Count; - rankLengths[rank] = count; - - if (rank == rankLengths.Length - 1) - { - return true; - } - - var firstItem = list[0] as ProxyArray; - if (firstItem == null) - { - return false; - } - - var firstItemCount = firstItem.Count; - - for (var i = 1; i < count; i++) - { - var item = list[i] as ProxyArray; - - if (item == null) - { - return false; - } - - if (item.Count != firstItemCount) - { - return false; - } - - if (!item.CanBeMultiRankArray( rank + 1, rankLengths )) - { - return false; - } - } - - return true; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyBoolean.cs b/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyBoolean.cs deleted file mode 100644 index 0699701e9..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyBoolean.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; - -namespace MelonLoader.TinyJSON -{ - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public sealed class ProxyBoolean : Variant - { - readonly bool value; - - - public ProxyBoolean( bool value ) - { - this.value = value; - } - - - public override bool ToBoolean( IFormatProvider provider ) - { - return value; - } - - - public override string ToString( IFormatProvider provider ) - { - return value ? "true" : "false"; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyNumber.cs b/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyNumber.cs deleted file mode 100644 index b7b41da72..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyNumber.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using System.Globalization; - -namespace MelonLoader.TinyJSON -{ - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public sealed class ProxyNumber : Variant - { - static readonly char[] floatingPointCharacters = { '.', 'e' }; - readonly IConvertible value; - - - public ProxyNumber( IConvertible value ) - { - var stringValue = value as string; - this.value = stringValue != null ? Parse( stringValue ) : value; - } - - - static IConvertible Parse( string value ) - { - if (value.IndexOfAny( floatingPointCharacters ) == -1) - { - if (value[0] == '-') - { - Int64 parsedValue; - if (Int64.TryParse( value, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out parsedValue )) - { - return parsedValue; - } - } - else - { - UInt64 parsedValue; - if (UInt64.TryParse( value, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out parsedValue )) - { - return parsedValue; - } - } - } - - Decimal decimalValue; - if (Decimal.TryParse( value, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out decimalValue )) - { - // Check for decimal underflow. - if (decimalValue == Decimal.Zero) - { - Double parsedValue; - if (Double.TryParse( value, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out parsedValue )) - { - if (Math.Abs( parsedValue ) > Double.Epsilon) - { - return parsedValue; - } - } - } - - return decimalValue; - } - - Double doubleValue; - if (Double.TryParse( value, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out doubleValue )) - { - return doubleValue; - } - - return 0; - } - - - public override bool ToBoolean( IFormatProvider provider ) - { - return value.ToBoolean( provider ); - } - - - public override byte ToByte( IFormatProvider provider ) - { - return value.ToByte( provider ); - } - - - public override char ToChar( IFormatProvider provider ) - { - return value.ToChar( provider ); - } - - - public override decimal ToDecimal( IFormatProvider provider ) - { - return value.ToDecimal( provider ); - } - - - public override double ToDouble( IFormatProvider provider ) - { - return value.ToDouble( provider ); - } - - - public override short ToInt16( IFormatProvider provider ) - { - return value.ToInt16( provider ); - } - - - public override int ToInt32( IFormatProvider provider ) - { - return value.ToInt32( provider ); - } - - - public override long ToInt64( IFormatProvider provider ) - { - return value.ToInt64( provider ); - } - - - public override sbyte ToSByte( IFormatProvider provider ) - { - return value.ToSByte( provider ); - } - - - public override float ToSingle( IFormatProvider provider ) - { - return value.ToSingle( provider ); - } - - - public override string ToString( IFormatProvider provider ) - { - return value.ToString( provider ); - } - - - public override ushort ToUInt16( IFormatProvider provider ) - { - return value.ToUInt16( provider ); - } - - - public override uint ToUInt32( IFormatProvider provider ) - { - return value.ToUInt32( provider ); - } - - - public override ulong ToUInt64( IFormatProvider provider ) - { - return value.ToUInt64( provider ); - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyObject.cs b/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyObject.cs deleted file mode 100644 index e1d04583a..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyObject.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; - -namespace MelonLoader.TinyJSON -{ - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public sealed class ProxyObject : Variant, IEnumerable> - { - public const string TypeHintKey = "@type"; - readonly Dictionary dict; - - - public ProxyObject() - { - dict = new Dictionary(); - } - - - IEnumerator> IEnumerable>.GetEnumerator() - { - return dict.GetEnumerator(); - } - - - IEnumerator IEnumerable.GetEnumerator() - { - return dict.GetEnumerator(); - } - - - public void Add( string key, Variant item ) - { - dict.Add( key, item ); - } - - - public bool TryGetValue( string key, out Variant item ) - { - return dict.TryGetValue( key, out item ); - } - - - public string TypeHint - { - get - { - Variant item; - if (TryGetValue( TypeHintKey, out item )) - { - return item.ToString( CultureInfo.InvariantCulture ); - } - - return null; - } - } - - - public override Variant this[ string key ] - { - get - { - return dict[key]; - } - set - { - dict[key] = value; - } - } - - - public int Count - { - get - { - return dict.Count; - } - } - - - public Dictionary.KeyCollection Keys - { - get - { - return dict.Keys; - } - } - - - // ReSharper disable once UnusedMember.Global - public Dictionary.ValueCollection Values - { - get - { - return dict.Values; - } - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyString.cs b/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyString.cs deleted file mode 100644 index 30ef5feaa..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyString.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace MelonLoader.TinyJSON -{ - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public sealed class ProxyString : Variant - { - readonly string value; - - - public ProxyString( string value ) - { - this.value = value; - } - - - public override string ToString( IFormatProvider provider ) - { - return value; - } - } -} diff --git a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/Variant.cs b/MelonLoader/BackwardsCompatibility/TinyJSON/Types/Variant.cs deleted file mode 100644 index 307b9e0c0..000000000 --- a/MelonLoader/BackwardsCompatibility/TinyJSON/Types/Variant.cs +++ /dev/null @@ -1,251 +0,0 @@ -using System; -using System.Globalization; - -namespace MelonLoader.TinyJSON -{ - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public abstract class Variant : IConvertible - { - protected static readonly IFormatProvider FormatProvider = new NumberFormatInfo(); - - - // ReSharper disable once UnusedMember.Global - public void Make( out T item ) - { - JSON.MakeInto( this, out item ); - } - - - public T Make() - { - T item; - JSON.MakeInto( this, out item ); - return item; - } - - - public void Populate( T item ) where T : class - { - JSON.Populate( this, item ); - } - - - // ReSharper disable once InconsistentNaming - // ReSharper disable once UnusedMember.Global - public string ToJSON() - { - return JSON.Dump( this ); - } - - - public virtual TypeCode GetTypeCode() - { - return TypeCode.Object; - } - - - public virtual object ToType( Type conversionType, IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to " + conversionType.Name ); - } - - - public virtual DateTime ToDateTime( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to DateTime" ); - } - - - public virtual bool ToBoolean( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to Boolean" ); - } - - public virtual byte ToByte( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to Byte" ); - } - - - public virtual char ToChar( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to Char" ); - } - - - public virtual decimal ToDecimal( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to Decimal" ); - } - - - public virtual double ToDouble( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to Double" ); - } - - - public virtual short ToInt16( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to Int16" ); - } - - - public virtual int ToInt32( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to Int32" ); - } - - - public virtual long ToInt64( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to Int64" ); - } - - - public virtual sbyte ToSByte( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to SByte" ); - } - - - public virtual float ToSingle( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to Single" ); - } - - - public virtual string ToString( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to String" ); - } - - - public virtual ushort ToUInt16( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to UInt16" ); - } - - - public virtual uint ToUInt32( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to UInt32" ); - } - - - public virtual ulong ToUInt64( IFormatProvider provider ) - { - throw new InvalidCastException( "Cannot convert " + GetType() + " to UInt64" ); - } - - - public override string ToString() - { - return ToString( FormatProvider ); - } - - - // ReSharper disable once UnusedMemberInSuper.Global - public virtual Variant this[ string key ] - { - get - { - throw new NotSupportedException(); - } - - // ReSharper disable once UnusedMember.Global - set - { - throw new NotSupportedException(); - } - } - - - // ReSharper disable once UnusedMemberInSuper.Global - public virtual Variant this[ int index ] - { - get - { - throw new NotSupportedException(); - } - - // ReSharper disable once UnusedMember.Global - set - { - throw new NotSupportedException(); - } - } - - - public static implicit operator Boolean( Variant variant ) - { - return variant.ToBoolean( FormatProvider ); - } - - - public static implicit operator Single( Variant variant ) - { - return variant.ToSingle( FormatProvider ); - } - - - public static implicit operator Double( Variant variant ) - { - return variant.ToDouble( FormatProvider ); - } - - - public static implicit operator UInt16( Variant variant ) - { - return variant.ToUInt16( FormatProvider ); - } - - - public static implicit operator Int16( Variant variant ) - { - return variant.ToInt16( FormatProvider ); - } - - - public static implicit operator UInt32( Variant variant ) - { - return variant.ToUInt32( FormatProvider ); - } - - - public static implicit operator Int32( Variant variant ) - { - return variant.ToInt32( FormatProvider ); - } - - - public static implicit operator UInt64( Variant variant ) - { - return variant.ToUInt64( FormatProvider ); - } - - - public static implicit operator Int64( Variant variant ) - { - return variant.ToInt64( FormatProvider ); - } - - - public static implicit operator Decimal( Variant variant ) - { - return variant.ToDecimal( FormatProvider ); - } - - - public static implicit operator String( Variant variant ) - { - return variant.ToString( FormatProvider ); - } - - - public static implicit operator Guid( Variant variant ) - { - return new Guid( variant.ToString( FormatProvider ) ); - } - } -} diff --git a/MelonLoader/CompatibilityLayers/MelonCompatibilityLayer.cs b/MelonLoader/CompatibilityLayers/MelonCompatibilityLayer.cs deleted file mode 100644 index be5379988..000000000 --- a/MelonLoader/CompatibilityLayers/MelonCompatibilityLayer.cs +++ /dev/null @@ -1,84 +0,0 @@ -using MelonLoader.Modules; -using System; -using System.Collections.Generic; -using System.IO; -using MelonLoader.Utils; - -namespace MelonLoader -{ - public static class MelonCompatibilityLayer - { - public static string baseDirectory = $"{MelonEnvironment.MelonBaseDirectory}{Path.DirectorySeparatorChar}MelonLoader{Path.DirectorySeparatorChar}Dependencies{Path.DirectorySeparatorChar}CompatibilityLayers"; - - private static List layers = new List() - { - // Illusion Plugin Architecture - new MelonModule.Info(Path.Combine(baseDirectory, "IPA.dll"), MelonUtils.IsGameIl2Cpp), - }; - - private static void CheckGameLayerWithPlatform(string name, Func shouldBeIgnored) - { - if (string.IsNullOrEmpty(name)) - return; - - string nameNoSpaces = name.Replace(' ', '_'); - foreach (var file in Directory.GetFiles(baseDirectory)) - { - string fileName = Path.GetFileNameWithoutExtension(file); - if (string.IsNullOrEmpty(fileName)) - continue; - if (fileName.StartsWith(nameNoSpaces)) - layers.Add(new MelonModule.Info(file, shouldBeIgnored)); - } - } - - private static void CheckGameLayer(string name) - { - if (string.IsNullOrEmpty(name)) - return; - - CheckGameLayerWithPlatform(name, () => false); - CheckGameLayerWithPlatform($"{name}_Mono", () => MelonUtils.IsGameIl2Cpp()); - CheckGameLayerWithPlatform($"{name}_Il2Cpp", () => !MelonUtils.IsGameIl2Cpp()); - - int spaceIndex = name.IndexOf(' '); - if (spaceIndex > 0) - { - name = name.Substring(0, spaceIndex - 1); - if (string.IsNullOrEmpty(name)) - return; - - CheckGameLayerWithPlatform(name, () => false); - CheckGameLayerWithPlatform($"{name}_Mono", () => MelonUtils.IsGameIl2Cpp()); - CheckGameLayerWithPlatform($"{name}_Il2Cpp", () => !MelonUtils.IsGameIl2Cpp()); - } - } - - internal static void LoadModules() - { - if (!Directory.Exists(baseDirectory)) - return; - - CheckGameLayer(InternalUtils.UnityInformationHandler.GameName); - CheckGameLayer(InternalUtils.UnityInformationHandler.GameDeveloper); - CheckGameLayer($"{InternalUtils.UnityInformationHandler.GameDeveloper}_{InternalUtils.UnityInformationHandler.GameName}"); - - foreach (var m in layers) - { - if ((m.shouldBeIgnored != null) - && m.shouldBeIgnored()) - continue; - - MelonDebug.Msg($"Loading MelonModule '{m.fullPath}'"); - m.moduleGC = MelonModule.Load(m); - } - - foreach (var file in Directory.GetFiles(baseDirectory)) - { - string fileName = Path.GetFileName(file); - if (layers.Find(x => Path.GetFileName(x.fullPath).Equals(fileName)) == null) - File.Delete(file); - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Core.cs b/MelonLoader/Core.cs index 9a90f844a..f262d0ec7 100644 --- a/MelonLoader/Core.cs +++ b/MelonLoader/Core.cs @@ -1,14 +1,13 @@ using System; using System.Diagnostics; -using System.Reflection; -using System.IO; -using bHapticsLib; using System.Threading; using MelonLoader.Resolver; using MelonLoader.Utils; using MelonLoader.InternalUtils; using MelonLoader.Properties; using MelonLoader.Melons; +using MelonLoader.Modules; +using System.Net; [assembly: MelonLoader.PatchShield] @@ -18,12 +17,10 @@ namespace MelonLoader { internal static class Core { - private static bool _success = true; - internal static HarmonyLib.Harmony HarmonyInstance; - internal static bool Is_ALPHA_PreRelease = false; - internal static int Initialize() + // Runtime Initialization + internal static void Stage1(bool isNativeHost) { // The config should be set before running anything else due to static constructors depending on it // Don't ask me how this works, because I don't know either. -slxdy @@ -33,197 +30,99 @@ internal static int Initialize() MelonLaunchOptions.Load(); -#if NET35 - // Disabled for now because of issues - //Net20Compatibility.TryInstall(); -#endif + MelonEnvironment.Initialize(AppDomain.CurrentDomain); - MelonUtils.SetupWineCheck(); +#if NET6_0_OR_GREATER + if (isNativeHost) + { + MelonEnvironment.PrintBuild(); - if (MelonUtils.IsUnderWineOrSteamProton()) - Pastel.ConsoleExtensions.Disable(); + if (LoaderConfig.Current.Loader.LaunchDebugger && MelonEnvironment.IsDotnetRuntime) + { + MelonLogger.Msg("[Init] User requested debugger, attempting to launch now..."); + Debugger.Launch(); + } + } - Fixes.UnhandledException.Install(AppDomain.CurrentDomain); + // if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + // NativeStackWalk.LogNativeStackTrace(); -#if NET35 - Fixes.ServerCertificateValidation.Install(); #endif + if (isNativeHost && OsUtils.IsWineOrProton()) + Pastel.ConsoleExtensions.Disable(); - Assertions.LemonAssertMapping.Setup(); + Fixes.UnhandledException.Install(AppDomain.CurrentDomain); + Fixes.ServerCertificateValidation.Install(); - MelonUtils.Setup(AppDomain.CurrentDomain); + Assertions.LemonAssertMapping.Setup(); MelonAssemblyResolver.Setup(); - BootstrapInterop.SetDefaultConsoleTitleWithGameName(UnityInformationHandler.GameName, - UnityInformationHandler.GameVersion); -#if NET6_0_OR_GREATER - - if (LoaderConfig.Current.Loader.LaunchDebugger && MelonEnvironment.IsDotnetRuntime) - { - MelonLogger.Msg("[Init] User requested debugger, attempting to launch now..."); - Debugger.Launch(); - } - - Environment.SetEnvironmentVariable("IL2CPP_INTEROP_DATABASES_LOCATION", MelonEnvironment.Il2CppAssembliesDirectory); - -#else + HarmonyInstance = new HarmonyLib.Harmony(BuildInfo.Name); - try - { - if (!MonoLibrary.Setup()) - { - _success = false; - return 1; - } - } - catch (Exception ex) - { - MelonDebug.Msg($"[MonoLibrary] Caught Exception: {ex}"); - _success = false; - return 1; - } +#if NET35 -#endif + // Disabled for now because of issues + Fixes.Net20Compatibility.TryInstall(); - HarmonyInstance = new HarmonyLib.Harmony(BuildInfo.Name); - Fixes.DetourContextDisposeFix.Install(); - -#if NET6_0_OR_GREATER - // if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - // NativeStackWalk.LogNativeStackTrace(); +#elif NET6_0_OR_GREATER + Fixes.AsmResolverFix.Install(); Fixes.DotnetAssemblyLoadContextFix.Install(); Fixes.DotnetModHandlerRedirectionFix.Install(); + #endif + Fixes.DetourContextDisposeFix.Install(); Fixes.ForcedCultureInfo.Install(); Fixes.InstancePatchFix.Install(); Fixes.ProcessFix.Install(); -#if NET6_0_OR_GREATER - Fixes.AsmResolverFix.Install(); - Fixes.Il2CppInteropFixes.Install(); - Fixes.Il2CppICallInjector.Install(); -#endif - PatchShield.Install(); - MelonPreferences.Load(); - - MelonCompatibilityLayer.LoadModules(); - - bHapticsManager.Connect(BuildInfo.Name, UnityInformationHandler.GameName); - - MelonFolderHandler.ScanForFolders(); - MelonFolderHandler.LoadMelons(MelonFolderHandler.eScanType.UserLibs); - MelonFolderHandler.LoadMelons(MelonFolderHandler.eScanType.Plugins); - - MelonEvents.MelonHarmonyEarlyInit.Invoke(); - MelonEvents.OnPreInitialization.Invoke(); - - return 0; } - private static int PreSetup() + // After Engine Module Initializes + internal static void Stage2() { -#if NET6_0_OR_GREATER - if (_success) - _success = Il2CppAssemblyGenerator.Run(); -#endif + ModuleFolderHandler.ScanForFolders(); + ModuleFolderHandler.LoadMelons(ModuleFolderHandler.eScanType.UserLibs); + ModuleFolderHandler.LoadMelons(ModuleFolderHandler.eScanType.Plugins); - return _success ? 0 : 1; + MelonEvents.MelonHarmonyEarlyInit.Invoke(); + MelonEvents.OnPreInitialization.Invoke(); } - internal static bool Start() + // Application Start + internal static void Stage3(string supportModulePath) { MelonEvents.OnApplicationEarlyStart.Invoke(); - MelonStartScreen.LoadAndRun(PreSetup); - - if (!_success) - return false; MelonEvents.OnPreModsLoaded.Invoke(); - MelonFolderHandler.LoadMelons(MelonFolderHandler.eScanType.Mods); + ModuleFolderHandler.LoadMelons(ModuleFolderHandler.eScanType.Mods); MelonEvents.OnPreSupportModule.Invoke(); - if (!SupportModule.Setup()) - return false; - - AddUnityDebugLog(); -#if NET6_0_OR_GREATER - RegisterTypeInIl2Cpp.SetReady(); - RegisterTypeInIl2CppWithInterfaces.SetReady(); -#endif + ModuleInterop.StartSupport(supportModulePath); MelonEvents.MelonHarmonyInit.Invoke(); MelonEvents.OnApplicationStart.Invoke(); - - return true; - } - - internal static string GetVersionString() - { - var lemon = LoaderConfig.Current.Loader.Theme == LoaderConfig.CoreConfig.LoaderTheme.Lemon; - var versionStr = $"{(lemon ? "Lemon" : "Melon")}Loader " + - $"v{BuildInfo.Version} " + - $"{(Is_ALPHA_PreRelease ? "ALPHA Pre-Release" : "Open-Beta")}"; - return versionStr; - } - - internal static void WelcomeMessage() - { - //if (MelonDebug.IsEnabled()) - MelonLogger.WriteSpacer(); - - MelonLogger.MsgDirect("------------------------------"); - MelonLogger.MsgDirect(GetVersionString()); - MelonLogger.MsgDirect($"OS: {MelonUtils.GetOSVersion()}"); - MelonLogger.MsgDirect($"Hash Code: {MelonUtils.HashCode}"); - MelonLogger.MsgDirect("------------------------------"); - var typeString = MelonUtils.IsGameIl2Cpp() ? "Il2cpp" : MelonUtils.IsOldMono() ? "Mono" : "MonoBleedingEdge"; - MelonLogger.MsgDirect($"Game Type: {typeString}"); - var archString = MelonUtils.IsGame32Bit() ? "x86" : "x64"; - MelonLogger.MsgDirect($"Game Arch: {archString}"); - MelonLogger.MsgDirect("------------------------------"); - MelonLogger.MsgDirect("Command-Line: "); - foreach (var pair in MelonLaunchOptions.InternalArguments) - if (string.IsNullOrEmpty(pair.Value)) - MelonLogger.MsgDirect($" {pair.Key}"); - else - MelonLogger.MsgDirect($" {pair.Key} = {pair.Value}"); - MelonLogger.MsgDirect("------------------------------"); - MelonEnvironment.PrintEnvironment(); } internal static void Quit() { MelonDebug.Msg("[ML Core] Received Quit Request! Shutting down..."); + // Run Quit Callback + MelonPreferences.Save(); HarmonyInstance.UnpatchSelf(); - bHapticsManager.Disconnect(); - -#if NET6_0_OR_GREATER - Fixes.Il2CppInteropFixes.Shutdown(); - Fixes.Il2CppICallInjector.Shutdown(); -#endif Thread.Sleep(200); if (LoaderConfig.Current.Loader.ForceQuit) Process.GetCurrentProcess().Kill(); } - - private static void AddUnityDebugLog() - { - var msg = "~ This Game has been MODIFIED using MelonLoader. DO NOT report any issues to the Game Developers! ~"; - var line = new string('-', msg.Length); - SupportModule.Interface.UnityDebugLog(line); - SupportModule.Interface.UnityDebugLog(msg); - SupportModule.Interface.UnityDebugLog(line); - } } } \ No newline at end of file diff --git a/MelonLoader/CoreClrUtils/NativeStackWalk.cs b/MelonLoader/CoreClrUtils/NativeStackWalk.cs index b762dcca8..e960aa17d 100644 --- a/MelonLoader/CoreClrUtils/NativeStackWalk.cs +++ b/MelonLoader/CoreClrUtils/NativeStackWalk.cs @@ -415,7 +415,7 @@ private static int InitDbgHelp(void* handle) if (!Directory.Exists(cacheDir)) Directory.CreateDirectory(cacheDir); - var userPath = $"cache*{cacheDir};srv*https://msdl.microsoft.com/download/symbols;srv*https://symbolserver.unity3d.com;{MelonEnvironment.GameRootDirectory}"; + var userPath = $"cache*{cacheDir};srv*https://msdl.microsoft.com/download/symbols;srv*https://symbolserver.unity3d.com;{MelonEnvironment.ApplicationRootDirectory}"; SymSetOptions(SymOptions.SYMOPT_UNDNAME | SymOptions.SYMOPT_DEFERRED_LOADS); diff --git a/MelonLoader/Fixes/ServerCertificateValidation.cs b/MelonLoader/Fixes/ServerCertificateValidation.cs index e77c7ce71..70d47dfdb 100644 --- a/MelonLoader/Fixes/ServerCertificateValidation.cs +++ b/MelonLoader/Fixes/ServerCertificateValidation.cs @@ -1,5 +1,4 @@ -#if NET35 -using System; +using System; using System.Net; using System.Net.Security; using System.Reflection; @@ -20,7 +19,7 @@ internal static void Install() if (expectContinue != null) expectContinue.SetValue(null, true); - //ServicePointManager.SecurityProtocol + // ServicePointManager.SecurityProtocol FieldInfo _securityProtocol = SPMType.GetField(nameof(_securityProtocol), BindingFlags.NonPublic | BindingFlags.Static); if (_securityProtocol != null) _securityProtocol.SetValue(null, @@ -29,7 +28,15 @@ internal static void Install() | (SecurityProtocolType)768 /* SecurityProtocolType.Tls11 */ | (SecurityProtocolType)3072 /* SecurityProtocolType.Tls12 */); - ServicePointManager.ServerCertificateValidationCallback += CertificateValidation; + // ServicePointManager.DefaultConnectionLimit = int.MaxValue; + FieldInfo s_ConnectionLimit = SPMType.GetField(nameof(s_ConnectionLimit), BindingFlags.NonPublic | BindingFlags.Static); + if (s_ConnectionLimit != null) + s_ConnectionLimit.SetValue(null, int.MaxValue); + + // ServicePointManager.ServerCertificateValidationCallback += CertificateValidation; + FieldInfo s_ServerCertValidationCallback = SPMType.GetField(nameof(s_ServerCertValidationCallback), BindingFlags.NonPublic | BindingFlags.Static); + if (s_ServerCertValidationCallback != null) + s_ServerCertValidationCallback.SetValue(null, Activator.CreateInstance(s_ServerCertValidationCallback.FieldType, (RemoteCertificateValidationCallback)CertificateValidation)); } catch (Exception ex) { MelonLogger.Warning($"ServerCertificateValidation Exception: {ex}"); } } @@ -54,5 +61,4 @@ private static bool CertificateValidation(object sender, X509Certificate certifi return true; } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/MelonLoader/InternalUtils/BootstrapInterop.cs b/MelonLoader/InternalUtils/BootstrapInterop.cs index 0fe93df9c..f39d4bce1 100644 --- a/MelonLoader/InternalUtils/BootstrapInterop.cs +++ b/MelonLoader/InternalUtils/BootstrapInterop.cs @@ -1,25 +1,20 @@ using System; using System.Runtime.InteropServices; +using MelonLoader.Bootstrap; #if NET6_0_OR_GREATER using MelonLoader.CoreClrUtils; -using MelonLoader.InternalUtils; +using MelonLoader.Utils; #endif namespace MelonLoader.InternalUtils; -internal static unsafe class BootstrapInterop +public static unsafe class BootstrapInterop { + public static nint _handle { get; private set; } internal static BootstrapLibrary Library { get; private set; } - internal static void SetDefaultConsoleTitleWithGameName(string gameName, string gameVersion = null) - { - var versionStr = $"{Core.GetVersionString()} - {gameName} {gameVersion ?? ""}"; - - MelonUtils.SetConsoleTitle(versionStr); - } - #if WINDOWS private const int MF_BYCOMMAND = 0x00000000; @@ -49,7 +44,8 @@ public static void NativeHookAttach(nint target, nint detour) { #if NET6_0_OR_GREATER //SanityCheckDetour is able to wrap and fix the bad method in a delegate where possible, so we pass the detour by ref. - if (!MelonUtils.IsUnderWineOrSteamProton() && !CoreClrDelegateFixer.SanityCheckDetour(ref detour)) + if (!OsUtils.IsWineOrProton() + && !CoreClrDelegateFixer.SanityCheckDetour(ref detour)) return; #endif @@ -60,6 +56,16 @@ public static void NativeHookAttach(nint target, nint detour) #endif } + public static nint NativeLoadLibInteropPtr { get; private set; } + private static NativeLoadLibFn NativeLoadLibInterop; + internal static IntPtr NativeLoadLib(string libraryPath) + => NativeLoadLibInterop(Marshal.StringToHGlobalAnsi(libraryPath)); + + public static nint NativeGetExportInteropPtr { get; private set; } + private static NativeGetExportFn NativeGetExportInterop; + internal static IntPtr NativeGetExport(IntPtr hModule, string lpProcName) + => NativeGetExportInterop(hModule, Marshal.StringToHGlobalAnsi(lpProcName)); + internal static unsafe void NativeHookAttachDirect(nint target, nint detour) { Library.NativeHookAttach((nint*)target, detour); @@ -74,35 +80,29 @@ public static unsafe void NativeHookDetach(nint target, nint detour) #endif } - internal static void Initialize(nint bootstrapHandle) + public static void Stage1(nint bootstrapHandle, nint loadLibFunc, nint getExportFunc) + => Stage1(bootstrapHandle, loadLibFunc, getExportFunc, false); + internal static void Stage1(nint bootstrapHandle, nint loadLibFunc, nint getExportFunc, bool isNativeHost) { - Library = new NativeLibrary(bootstrapHandle).Instance; + _handle = bootstrapHandle; - try - { - Core.Initialize(); - } - catch (Exception ex) - { - MelonLogger.Error("Failed to initialize MelonLoader"); - MelonLogger.Error(ex); + NativeLoadLibInteropPtr = loadLibFunc; + NativeLoadLibInterop = (NativeLoadLibFn)Marshal.GetDelegateForFunctionPointer(NativeLoadLibInteropPtr, typeof(NativeLoadLibFn)); - throw new("Error at init"); - } - } + NativeGetExportInteropPtr = getExportFunc; + NativeGetExportInterop = (NativeGetExportFn)Marshal.GetDelegateForFunctionPointer(NativeGetExportInteropPtr, typeof(NativeGetExportFn)); + + Library = new MelonNativeLibrary(bootstrapHandle).Instance; - internal static void Start() - { try { - Core.Start(); + Core.Stage1(isNativeHost); } catch (Exception ex) { - MelonLogger.Error("Failed to start MelonLoader"); + MelonLogger.Error("Failed to run Stage1 of MelonLoader"); MelonLogger.Error(ex); - - throw new("Error at start"); + throw new("Error at Stage1"); } } } \ No newline at end of file diff --git a/MelonLoader/InternalUtils/BootstrapLibrary.cs b/MelonLoader/InternalUtils/BootstrapLibrary.cs index d7256bbfa..a782bde03 100644 --- a/MelonLoader/InternalUtils/BootstrapLibrary.cs +++ b/MelonLoader/InternalUtils/BootstrapLibrary.cs @@ -9,9 +9,6 @@ internal class BootstrapLibrary internal LogMsgFn LogMsg { get; private set; } internal LogErrorFn LogError { get; private set; } internal LogMelonInfoFn LogMelonInfo { get; private set; } - internal ActionFn MonoInstallHooks { get; private set; } - internal PtrRetFn MonoGetDomainPtr { get; private set; } - internal PtrRetFn MonoGetRuntimeHandle { get; private set; } internal BoolRetFn IsConsoleOpen { get; private set; } internal GetLoaderConfigFn GetLoaderConfig { get; private set; } } diff --git a/MelonLoader/InternalUtils/Il2CppAssemblyGenerator.cs b/MelonLoader/InternalUtils/Il2CppAssemblyGenerator.cs deleted file mode 100644 index a4672cd5a..000000000 --- a/MelonLoader/InternalUtils/Il2CppAssemblyGenerator.cs +++ /dev/null @@ -1,57 +0,0 @@ -#if NET6_0_OR_GREATER - -using MelonLoader.Modules; -using System; -using System.Diagnostics; -using System.IO; -using MelonLoader.Utils; - -namespace MelonLoader.InternalUtils -{ - internal static class Il2CppAssemblyGenerator - { - private static readonly string modulePath = Path.Combine(MelonEnvironment.Il2CppAssemblyGeneratorDirectory, "Il2CppAssemblyGenerator.dll"); - public static readonly MelonModule.Info moduleInfo = new MelonModule.Info(modulePath, () => !MelonUtils.IsGameIl2Cpp()); - - internal static bool Run() - { - if (MelonEnvironment.IsMonoRuntime) - return true; - - MelonLogger.MsgDirect("Loading Il2CppAssemblyGenerator..."); - var module = MelonModule.Load(moduleInfo); - if (module == null) - { - if (File.Exists(modulePath)) - MelonLogger.Error("Failed to Load Il2CppAssemblyGenerator!"); - else - MelonLogger.Error("Il2CppAssemblyGenerator was Not Found!"); - return false; - } - - if (MelonUtils.IsWindows) - { - IntPtr windowHandle = Process.GetCurrentProcess().MainWindowHandle; - -#if WINDOWS - BootstrapInterop.DisableCloseButton(windowHandle); -#endif - } - - var ret = module.SendMessage("Run"); - - if (MelonUtils.IsWindows) - { - IntPtr windowHandle = Process.GetCurrentProcess().MainWindowHandle; - -#if WINDOWS - BootstrapInterop.EnableCloseButton(windowHandle); -#endif - } - - return ret is 0; - } - } -} - -#endif \ No newline at end of file diff --git a/MelonLoader/InternalUtils/MelonStartScreen.cs b/MelonLoader/InternalUtils/MelonStartScreen.cs deleted file mode 100644 index 93978780a..000000000 --- a/MelonLoader/InternalUtils/MelonStartScreen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//using System.IO; -//using AssetRipper.VersionUtilities; -//using MelonLoader.Modules; -//using MelonLoader.Utils; - -namespace MelonLoader.InternalUtils -{ - internal class MelonStartScreen - { - // Doesn't support Unity versions lower than 2017.2.0 (yet?) - // Doesn't support Unity versions lower than 2018 (Crashing Issue) - // Doesn't support Unity versions higher than to 2020.3.21 (Crashing Issue) - //internal static readonly MelonModule.Info moduleInfo = new MelonModule.Info($"{MelonEnvironment.OurRuntimeDirectory}{Path.DirectorySeparatorChar}MelonStartScreen.dll" - // , () => !MelonLaunchOptions.Core.StartScreen || UnityInformationHandler.EngineVersion < new UnityVersion(2018)); - - internal static int LoadAndRun(LemonFunc functionToWaitForAsync) - { - //var module = MelonModule.Load(moduleInfo); - //if (module == null) - return functionToWaitForAsync(); - - //var result = module.SendMessage("LoadAndRun", functionToWaitForAsync); - //if (result is int resultCode) - // return resultCode; - - //return -1; - } - } -} diff --git a/MelonLoader/LoaderConfig.cs b/MelonLoader/LoaderConfig.cs deleted file mode 100644 index 2347689e5..000000000 --- a/MelonLoader/LoaderConfig.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using Tomlet.Attributes; - -namespace MelonLoader; - -[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] -public class LoaderConfig -{ - public static LoaderConfig Current { get; internal set; } = new(); - - [TomlProperty("loader")] - public CoreConfig Loader { get; internal set; } = new(); - - [TomlProperty("console")] - public ConsoleConfig Console { get; internal set; } = new(); - - [TomlProperty("logs")] - public LogsConfig Logs { get; internal set; } = new(); - - [TomlProperty("unityengine")] - public UnityEngineConfig UnityEngine { get; internal set; } = new(); - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public class CoreConfig - { - [TomlNonSerialized] - public string BaseDirectory { get; internal set; } = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule!.FileName)!; - - // Technically, this will always return false, but it's still a config ¯\_(ツ)_/¯ - [TomlProperty("disable")] - [TomlPrecedingComment("Disables MelonLoader. Equivalent to the '--no-mods' launch option")] - public bool Disable { get; internal set; } - - [TomlProperty("debug_mode")] - [TomlPrecedingComment("Equivalent to the '--melonloader.debug' launch option")] - public bool DebugMode { get; internal set; } -#if DEBUG - = true; -#endif - - [TomlProperty("force_quit")] - [TomlPrecedingComment("Only use this if the game freezes when trying to quit. Equivalent to the '--quitfix' launch option")] - public bool ForceQuit { get; internal set; } - - [TomlProperty("disable_start_screen")] - [TomlPrecedingComment("Disables the start screen. Equivalent to the '--melonloader.disablestartscreen' launch option")] - public bool DisableStartScreen { get; internal set; } - - [TomlProperty("launch_debugger")] - [TomlPrecedingComment("Starts the dotnet debugger (only for Il2Cpp games). Equivalent to the '--melonloader.launchdebugger' launch option")] - public bool LaunchDebugger { get; internal set; } - - [TomlProperty("theme")] - [TomlPrecedingComment("Sets the loader theme. Currently, the only available themes are \"Normal\" and \"Lemon\". Equivalent to the '--melonloader.consolemode' launch option (0 for Normal, 4 for Lemon)")] - public LoaderTheme Theme { get; internal set; } - - public enum LoaderTheme - { - Normal, - Magenta, - Rainbow, - RandomRainbow, - Lemon - }; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public class ConsoleConfig - { - [TomlProperty("hide_warnings")] - [TomlPrecedingComment("Hides warnings from displaying. Equivalent to the '--melonloader.hidewarnings' launch option")] - public bool HideWarnings { get; internal set; } - - [TomlProperty("hide_console")] - [TomlPrecedingComment("Hides the console. Equivalent to the '--melonloader.hideconsole' launch option")] - public bool Hide { get; internal set; } - - [TomlProperty("console_on_top")] - [TomlPrecedingComment("Forces the console to always stay on-top of all other applications. Equivalent to the '--melonloader.consoleontop' launch option")] - public bool AlwaysOnTop { get; internal set; } - - [TomlProperty("dont_set_title")] - [TomlPrecedingComment("Keeps the console title as original. Equivalent to the '--melonloader.consoledst' launch option")] - public bool DontSetTitle { get; internal set; } - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public class LogsConfig - { - [TomlProperty("max_logs")] - [TomlPrecedingComment("Sets the maximum amount of log files in the Logs folder (Default: 10). Equivalent to the '--melonloader.maxlogs' launch option")] - public uint MaxLogs { get; internal set; } = 10; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public class UnityEngineConfig - { - [TomlProperty("version_override")] - [TomlPrecedingComment("Overrides the detected UnityEngine version. Equivalent to the '--melonloader.unityversion' launch option")] - public string VersionOverride { get; internal set; } = ""; - - [TomlProperty("disable_console_log_cleaner")] - [TomlPrecedingComment("Disables the console log cleaner (only applies to Il2Cpp games). Equivalent to the '--melonloader.disableunityclc' launch option")] - public bool DisableConsoleLogCleaner { get; internal set; } - - [TomlProperty("force_offline_generation")] - [TomlPrecedingComment("Forces the Il2Cpp Assembly Generator to run without contacting the remote API. Equivalent to the '--melonloader.agfoffline' launch option")] - public bool ForceOfflineGeneration { get; internal set; } - - [TomlProperty("force_generator_regex")] - [TomlPrecedingComment("Forces the Il2Cpp Assembly Generator to use the specified regex. Equivalent to the '--melonloader.agfregex' launch option")] - public string ForceGeneratorRegex { get; internal set; } = ""; - - [TomlProperty("force_il2cpp_dumper_version")] - [TomlPrecedingComment("Forces the Il2Cpp Assembly Generator to use the specified Il2Cpp dumper version. Equivalent to the '--melonloader.agfvdumper' launch option")] - public string ForceIl2CppDumperVersion { get; internal set; } = ""; - - [TomlProperty("force_regeneration")] - [TomlPrecedingComment("Forces the Il2Cpp Assembly Generator to always regenerate assemblies. Equivalent to the '--melonloader.agfregenerate' launch option")] - public bool ForceRegeneration { get; internal set; } - - [TomlProperty("enable_cpp2il_call_analyzer")] - [TomlPrecedingComment("Enables the CallAnalyzer processor for Cpp2IL. Equivalent to the '--cpp2il.callanalyzer' launch option")] - public bool EnableCpp2ILCallAnalyzer { get; internal set; } - - [TomlProperty("enable_cpp2il_native_method_detector")] - [TomlPrecedingComment("Enables the NativeMethodDetector processor for Cpp2IL. Equivalent to the '--cpp2il.nativemethoddetector' launch option")] - public bool EnableCpp2ILNativeMethodDetector { get; internal set; } - } -} \ No newline at end of file diff --git a/MelonLoader/MelonEvents.cs b/MelonLoader/MelonEvents.cs deleted file mode 100644 index 757a1582c..000000000 --- a/MelonLoader/MelonEvents.cs +++ /dev/null @@ -1,99 +0,0 @@ -namespace MelonLoader -{ - public static class MelonEvents - { - /// - /// Called after all MelonPlugins are initialized. - /// - public readonly static MelonEvent OnPreInitialization = new(true); - - /// - /// Called after Game Initialization, before OnApplicationStart and before Assembly Generation on Il2Cpp games. - /// - public readonly static MelonEvent OnApplicationEarlyStart = new(true); - - /// - /// Called after all MelonMods are initialized and before the right Support Module is loaded. - /// - public readonly static MelonEvent OnPreSupportModule = new(true); - - /// - /// Called after all MelonLoader components are fully initialized (including all MelonMods). - /// Don't use this event to initialize your Melons anymore! Instead, override . - /// - public readonly static MelonEvent OnApplicationStart = new(true); - - /// - /// Called when the first 'Start' Unity Messages are invoked. - /// - public readonly static MelonEvent OnApplicationLateStart = new(true); - - /// - /// Called before the Application is closed. It is not possible to prevent the game from closing at this point. - /// - public readonly static MelonEvent OnApplicationDefiniteQuit = new(true); - - /// - /// Called on a quit request. It is possible to abort the request in this callback. - /// - public readonly static MelonEvent OnApplicationQuit = new(); - - /// - /// Called once per frame. - /// - public readonly static MelonEvent OnUpdate = new(); - - /// - /// Called every 0.02 seconds, unless Time.fixedDeltaTime has a different Value. It is recommended to do all important Physics calculations inside this Callback. - /// - public readonly static MelonEvent OnFixedUpdate = new(); - - /// - /// Called once per frame, after . - /// - public readonly static MelonEvent OnLateUpdate = new(); - - /// - /// Called at every IMGUI event. Only use this for drawing IMGUI Elements. - /// - public readonly static MelonEvent OnGUI = new(); - - /// - /// Called when a new Scene is loaded. - /// - /// Arguments: - ///
: Build Index of the Scene.
- ///
: Name of the Scene.
- ///
- ///
- public readonly static MelonEvent OnSceneWasLoaded = new(); - - /// - /// Called once a Scene is initialized. - /// - /// Arguments: - ///
: Build Index of the Scene.
- ///
: Name of the Scene.
- ///
- ///
- public readonly static MelonEvent OnSceneWasInitialized = new(); - - /// - /// Called once a Scene unloads. - /// - /// Arguments: - ///
: Build Index of the Scene.
- ///
: Name of the Scene.
- ///
- ///
- public readonly static MelonEvent OnSceneWasUnloaded = new(); - - /// - /// Called before MelonMods are loaded from the Mods folder. - /// - public readonly static MelonEvent OnPreModsLoaded = new(true); - - internal readonly static MelonEvent MelonHarmonyEarlyInit = new(true); - internal readonly static MelonEvent MelonHarmonyInit = new(true); - } -} diff --git a/MelonLoader/MelonLaunchOptions.cs b/MelonLoader/MelonLaunchOptions.cs deleted file mode 100644 index 43bf3e336..000000000 --- a/MelonLoader/MelonLaunchOptions.cs +++ /dev/null @@ -1,206 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MelonLoader -{ - public static class MelonLaunchOptions - { - private static Dictionary WithoutArg = new Dictionary(); - private static Dictionary> WithArg = new Dictionary>(); - private static string[] _cmd; - - /// - /// Dictionary of all Arguments with value (if found) that were not used by MelonLoader - /// - /// Key is the argument, Value is the value for the argument, null if not found - /// - /// - public static Dictionary ExternalArguments { get; private set; } = new Dictionary(); - public static Dictionary InternalArguments { get; private set; } = new Dictionary(); - - /// - /// Array of All Command Line Arguments - /// - public static string[] CommandLineArgs - { - get - { - if (_cmd == null) - _cmd = Environment.GetCommandLineArgs(); - return _cmd; - } - } - - internal static void Load() - { - string[] args = CommandLineArgs; - int maxLen = args.Length; - for (int i = 1; i < maxLen; i++) - { - string fullcmd = args[i]; - if (string.IsNullOrEmpty(fullcmd)) - continue; - - // Parse Prefix - string noPrefixCmd = fullcmd; - if (noPrefixCmd.StartsWith("--")) - noPrefixCmd = noPrefixCmd.Remove(0, 2); - else if (noPrefixCmd.StartsWith("-")) - noPrefixCmd = noPrefixCmd.Remove(0, 1); - else - { - // Unknown Command, Add it to Dictionary - ExternalArguments.Add(noPrefixCmd, null); - continue; - } - - // Parse Argumentless Commands - if (WithoutArg.TryGetValue(noPrefixCmd, out Action withoutArgFunc)) - { - InternalArguments.Add(noPrefixCmd, null); - withoutArgFunc(); - continue; - } - - // Parse Argument - string cmdArg = null; - if (noPrefixCmd.Contains("=")) - { - string[] split = noPrefixCmd.Split('='); - noPrefixCmd = split[0]; - cmdArg = split[1]; - } - - if ((string.IsNullOrEmpty(cmdArg) - && ((i + 1) >= maxLen)) - || string.IsNullOrEmpty(cmdArg) - || cmdArg.StartsWith("--") - || cmdArg.StartsWith("-")) - { - // Unknown Command, Add it to Dictionary - ExternalArguments.Add(noPrefixCmd, null); - continue; - } - - // Parse Argument Commands - if (WithArg.TryGetValue(noPrefixCmd, out Action withArgFunc)) - { - InternalArguments.Add(noPrefixCmd, cmdArg); - withArgFunc(cmdArg); - continue; - } - - // Unknown Command with Argument, Add it to Dictionary - ExternalArguments.Add(noPrefixCmd, cmdArg); - } - } - - #region Obsolete - - [Obsolete("Use LoaderConfig.Current.Loader instead. This will be removed in a future update.", true)] - public static class Core - { - [Obsolete("This option isn't used anymore. This will be removed in a future update.", true)] - public enum LoadModeEnum - { - NORMAL, - DEV, - BOTH - } - - [Obsolete("This option isn't used anymore. It will always return NORMAL. This will be removed in a future update.", true)] - public static LoadModeEnum LoadMode_Plugins => LoadModeEnum.NORMAL; - - [Obsolete("This option isn't used anymore. It will always return NORMAL. This will be removed in a future update.", true)] - public static LoadModeEnum LoadMode_Mods => LoadModeEnum.NORMAL; - - [Obsolete("Use LoaderConfig.Current.Loader.ForceQuit instead. This will be removed in a future update.", true)] - public static bool QuitFix => LoaderConfig.Current.Loader.ForceQuit; - - [Obsolete("Use LoaderConfig.Current.Loader.DisableStartScreen instead. This will be removed in a future update.", true)] - public static bool StartScreen => !LoaderConfig.Current.Loader.DisableStartScreen; - - [Obsolete("Use LoaderConfig.Current.UnityEngine.VersionOverride instead. This will be removed in a future update.", true)] - public static string UnityVersion => LoaderConfig.Current.UnityEngine.VersionOverride; - - [Obsolete("Use LoaderConfig.Current.Loader.DebugMode instead. This will be removed in a future update.", true)] - public static bool IsDebug => LoaderConfig.Current.Loader.DebugMode; - - [Obsolete("Use LoaderConfig.Current.Loader.LaunchDebugger instead. This will be removed in a future update.", true)] - public static bool UserWantsDebugger => LoaderConfig.Current.Loader.LaunchDebugger; - } - - [Obsolete("Use LoaderConfig.Current.Console instead. This will be removed in a future update.", true)] - public static class Console - { - [Obsolete("Use LoaderConfig.CoreConfig.LoaderTheme instead. This will be removed in a future update.", true)] - public enum DisplayMode - { - NORMAL, - MAGENTA, - RAINBOW, - RANDOMRAINBOW, - LEMON - }; - - [Obsolete("Use LoaderConfig.Current.Loader.Theme instead. This will be removed in a future update.", true)] - public static DisplayMode Mode => (DisplayMode)LoaderConfig.Current.Loader.Theme; - - [Obsolete("Use LoaderConfig.Current.UnityEngine.DisableConsoleLogCleaner instead. This will be removed in a future update.", true)] - public static bool CleanUnityLogs => !LoaderConfig.Current.UnityEngine.DisableConsoleLogCleaner; - - [Obsolete("Use LoaderConfig.Current.Console.DontSetTitle instead. This will be removed in a future update.", true)] - public static bool ShouldSetTitle => !LoaderConfig.Current.Console.DontSetTitle; - - [Obsolete("Use LoaderConfig.Current.Console.AlwaysOnTop instead. This will be removed in a future update.", true)] - public static bool AlwaysOnTop => LoaderConfig.Current.Console.AlwaysOnTop; - - [Obsolete("Use LoaderConfig.Current.Console.Hide instead. This will be removed in a future update.", true)] - public static bool ShouldHide => LoaderConfig.Current.Console.Hide; - - [Obsolete("Use LoaderConfig.Current.Console.HideWarnings instead. This will be removed in a future update.", true)] - public static bool HideWarnings => LoaderConfig.Current.Console.HideWarnings; - } - - [Obsolete("Use LoaderConfig.Current.UnityEngine instead. This will be removed in a future update.", true)] - public static class Cpp2IL - { - [Obsolete("Use LoaderConfig.Current.UnityEngine.EnableCpp2ILCallAnalyzer instead. This will be removed in a future update.", true)] - public static bool CallAnalyzer => LoaderConfig.Current.UnityEngine.EnableCpp2ILCallAnalyzer; - - [Obsolete("Use LoaderConfig.Current.UnityEngine.EnableCpp2ILNativeMethodDetector instead. This will be removed in a future update.", true)] - public static bool NativeMethodDetector => LoaderConfig.Current.UnityEngine.EnableCpp2ILNativeMethodDetector; - } - - [Obsolete("Use LoaderConfig.Current.UnityEngine instead. This will be removed in a future update.", true)] - public static class Il2CppAssemblyGenerator - { - [Obsolete("Use LoaderConfig.Current.UnityEngine.ForceRegeneration instead. This will be removed in a future update.", true)] - public static bool ForceRegeneration => LoaderConfig.Current.UnityEngine.ForceRegeneration; - - [Obsolete("Use LoaderConfig.Current.UnityEngine.ForceOfflineGeneration instead. This will be removed in a future update.", true)] - public static bool OfflineMode => LoaderConfig.Current.UnityEngine.ForceOfflineGeneration; - - [Obsolete("Use LoaderConfig.Current.UnityEngine.ForceIl2CppDumperVersion instead. This will be removed in a future update.", true)] - public static string ForceVersion_Dumper => LoaderConfig.Current.UnityEngine.ForceIl2CppDumperVersion; - - [Obsolete("Use LoaderConfig.Current.UnityEngine.ForceGeneratorRegex instead. This will be removed in a future update.", true)] - public static string ForceRegex => LoaderConfig.Current.UnityEngine.ForceGeneratorRegex; - } - - [Obsolete("Use LoaderConfig.Logs instead. This will be removed in a future update.", true)] - public static class Logger - { - [Obsolete("Use LoaderConfig.Current.Logs.MaxLogs instead. This will be removed in a future update.", true)] - public static int MaxLogs => (int)LoaderConfig.Current.Logs.MaxLogs; - - [Obsolete("This option isn't used anymore. It will always return 10. This will be removed in a future update.", true)] - public static int MaxWarnings => 10; - - [Obsolete("This option isn't used anymore. It will always return 10. This will be removed in a future update.", true)] - public static int MaxErrors => 10; - } - - #endregion Obsolete - } -} diff --git a/MelonLoader/MelonLoader.csproj b/MelonLoader/MelonLoader.csproj index d5bcc2ef7..c78b2a713 100644 --- a/MelonLoader/MelonLoader.csproj +++ b/MelonLoader/MelonLoader.csproj @@ -2,7 +2,7 @@ net35;net6 true - $(MLOutDir)/MelonLoader + $(MLOutDir)/MelonLoader/Dependencies true true true @@ -24,27 +24,28 @@ - - - - - + + + - - - + + + + + + @@ -52,15 +53,8 @@ - - - - - - - diff --git a/MelonLoader/MelonUtils.cs b/MelonLoader/MelonUtils.cs deleted file mode 100644 index 25aa10026..000000000 --- a/MelonLoader/MelonUtils.cs +++ /dev/null @@ -1,646 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; -using System.Security.Cryptography; -using System.Text; -using MonoMod.Cil; -using MonoMod.Utils; -using HarmonyLib; -using MelonLoader.TinyJSON; -using MelonLoader.InternalUtils; -using AssetsTools.NET; -using AssetsTools.NET.Extra; -using MelonLoader.Lemons.Cryptography; -using MelonLoader.Utils; - -namespace MelonLoader -{ - public static class MelonUtils - { - private static NativeLibrary.StringDelegate WineGetVersion; - //private static readonly Random RandomNumGen = new(); - private static readonly MethodInfo StackFrameGetMethod = typeof(StackFrame).GetMethod("GetMethod", BindingFlags.Instance | BindingFlags.Public); - private static readonly LemonSHA256 sha256 = new(); - private static readonly LemonSHA512 sha512 = new(); - - internal static void Setup(AppDomain domain) - { - using (var sha = SHA256.Create()) - HashCode = ComputeSimpleSHA256Hash(Assembly.GetExecutingAssembly().Location); - - Core.WelcomeMessage(); - - if (MelonEnvironment.IsMonoRuntime) - SetCurrentDomainBaseDirectory(MelonEnvironment.GameRootDirectory, domain); - - if (!Directory.Exists(MelonEnvironment.UserDataDirectory)) - Directory.CreateDirectory(MelonEnvironment.UserDataDirectory); - - if (!Directory.Exists(MelonEnvironment.UserLibsDirectory)) - Directory.CreateDirectory(MelonEnvironment.UserLibsDirectory); - AddNativeDLLDirectory(MelonEnvironment.UserLibsDirectory); - - MelonHandler.Setup(); - UnityInformationHandler.Setup(); - - CurrentGameAttribute = new MelonGameAttribute(UnityInformationHandler.GameDeveloper, UnityInformationHandler.GameName); - CurrentPlatform = IsGame32Bit() ? MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X86 : MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64; - CurrentDomain = IsGameIl2Cpp() ? MelonPlatformDomainAttribute.CompatibleDomains.IL2CPP : MelonPlatformDomainAttribute.CompatibleDomains.MONO; - } - - [Obsolete("Use MelonEnvironment.MelonBaseDirectory instead. This will be removed in a future update.", true)] - public static string BaseDirectory => MelonEnvironment.MelonBaseDirectory; - [Obsolete("Use MelonEnvironment.GameRootDirectory instead. This will be removed in a future update.", true)] - public static string GameDirectory => MelonEnvironment.GameRootDirectory; - [Obsolete("Use MelonEnvironment.MelonLoaderDirectory instead. This will be removed in a future update.", true)] - public static string MelonLoaderDirectory => MelonEnvironment.MelonLoaderDirectory; - [Obsolete("Use MelonEnvironment.UserDataDirectory instead. This will be removed in a future update.", true)] - public static string UserDataDirectory => MelonEnvironment.UserDataDirectory; - [Obsolete("Use MelonEnvironment.UserLibsDirectory instead. This will be removed in a future update.", true)] - public static string UserLibsDirectory => MelonEnvironment.UserLibsDirectory; - public static MelonPlatformAttribute.CompatiblePlatforms CurrentPlatform { get; private set; } - public static MelonPlatformDomainAttribute.CompatibleDomains CurrentDomain { get; private set; } - public static MelonGameAttribute CurrentGameAttribute { get; private set; } - public static T Clamp(T value, T min, T max) where T : IComparable { if (value.CompareTo(min) < 0) return min; if (value.CompareTo(max) > 0) return max; return value; } - public static string HashCode { get; private set; } - - // public static int RandomInt() - // { - // lock (RandomNumGen) - // return RandomNumGen.Next(); - // } - // - // public static int RandomInt(int max) - // { - // lock (RandomNumGen) - // return RandomNumGen.Next(max); - // } - // - // public static int RandomInt(int min, int max) - // { - // lock (RandomNumGen) - // return RandomNumGen.Next(min, max); - // } - // - // public static double RandomDouble() - // { - // lock (RandomNumGen) - // return RandomNumGen.NextDouble(); - // } - // - // public static string RandomString(int length) - // { - // StringBuilder builder = new(); - // for (int i = 0; i < length; i++) - // builder.Append(Convert.ToChar(Convert.ToInt32(Math.Floor(25 * RandomDouble())) + 65)); - // return builder.ToString(); - // } - - public static PlatformID GetPlatform => Environment.OSVersion.Platform; - - public static bool IsUnix => GetPlatform is PlatformID.Unix; - public static bool IsWindows => GetPlatform is PlatformID.Win32NT or PlatformID.Win32S or PlatformID.Win32Windows or PlatformID.WinCE; - public static bool IsMac => GetPlatform is PlatformID.MacOSX; - - public static void SetCurrentDomainBaseDirectory(string dirpath, AppDomain domain = null) - { - if(MelonEnvironment.IsDotnetRuntime) - return; - - if (domain == null) - domain = AppDomain.CurrentDomain; - try - { - ((AppDomainSetup)typeof(AppDomain).GetProperty("SetupInformationNoCopy", BindingFlags.NonPublic | BindingFlags.Instance) - .GetValue(domain, new object[0])) - .SetApplicationBase(dirpath); - } - catch (Exception ex) { MelonLogger.Warning($"AppDomainSetup.ApplicationBase Exception: {ex}"); } - Directory.SetCurrentDirectory(dirpath); - } - - public static MelonBase GetMelonFromStackTrace() - { - StackTrace st = new(3, true); - return GetMelonFromStackTrace(st); - } - - public static MelonBase GetMelonFromStackTrace(StackTrace st, bool allFrames = false) - { - if (st.FrameCount <= 0) - return null; - - if (allFrames) - { - foreach (StackFrame frame in st.GetFrames()) - { - MelonBase ret = CheckForMelonInFrame(frame); - if (ret != null) - return ret; - } - return null; - - } - - MelonBase output = CheckForMelonInFrame(st); - if (output == null) - output = CheckForMelonInFrame(st, 1); - if (output == null) - output = CheckForMelonInFrame(st, 2); - return output; - } - - private static MelonBase CheckForMelonInFrame(StackTrace st, int frame = 0) - { - StackFrame sf = st.GetFrame(frame); - if (sf == null) - return null; - - return CheckForMelonInFrame(sf); - } - - private static MelonBase CheckForMelonInFrame(StackFrame sf) - //The JIT compiler on .NET 6 on Windows 10 (win11 is fine, somehow) really doesn't like us calling StackFrame.GetMethod here - //Rather than trying to work out why, I'm just going to call it via reflection. - => GetMelonFromAssembly(((MethodBase)StackFrameGetMethod.Invoke(sf, new object[0]))?.DeclaringType?.Assembly); - - private static MelonBase GetMelonFromAssembly(Assembly asm) - => asm == null ? null : MelonPlugin.RegisteredMelons.Cast().FirstOrDefault(x => x.MelonAssembly.Assembly == asm) ?? MelonMod.RegisteredMelons.FirstOrDefault(x => x.MelonAssembly.Assembly == asm); - - public static string ComputeSimpleSHA256Hash(string filePath) - { - if (!File.Exists(filePath)) - return null; - - byte[] byteHash = File.ReadAllBytes(filePath); - if (byteHash == null) - return null; - - return sha256.ComputeHash(byteHash).ToString("X2"); - } - - public static string ComputeSimpleSHA512Hash(string filePath) - { - if (!File.Exists(filePath)) - return null; - - byte[] byteHash = File.ReadAllBytes(filePath); - if (byteHash == null) - return null; - - return sha512.ComputeHash(byteHash).ToString("X2"); - } - - public static string ToString(this byte[] data) - { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < data.Length; i++) - result.Append(data[i].ToString()); - return result.ToString(); - } - - public static string ToString(this byte[] data, string format) - { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < data.Length; i++) - result.Append(data[i].ToString(format)); - return result.ToString(); - } - - public static string ToString(this byte[] data, IFormatProvider provider) - { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < data.Length; i++) - result.Append(data[i].ToString(provider)); - return result.ToString(); - } - - public static string ToString(this byte[] data, string format, IFormatProvider provider) - { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < data.Length; i++) - result.Append(data[i].ToString(format, provider)); - return result.ToString(); - } - - [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] - public static T ParseJSONStringtoStruct(string jsonstr) - { - if (string.IsNullOrEmpty(jsonstr)) - return default; - Variant jsonarr; - try { jsonarr = JSON.Load(jsonstr); } - catch (Exception ex) - { - MelonLogger.Error($"Exception while Decoding JSON String to JSON Variant: {ex}"); - return default; - } - if (jsonarr == null) - return default; - T returnobj = default; - try { returnobj = jsonarr.Make(); } - catch (Exception ex) { MelonLogger.Error($"Exception while Converting JSON Variant to {typeof(T).Name}: {ex}"); } - return returnobj; - } - - public static T PullAttributeFromAssembly(Assembly asm, bool inherit = false) where T : Attribute - { - T[] attributetbl = PullAttributesFromAssembly(asm, inherit); - if ((attributetbl == null) || (attributetbl.Length <= 0)) - return null; - return attributetbl[0]; - } - - public static T[] PullAttributesFromAssembly(Assembly asm, bool inherit = false) where T : Attribute - { - Attribute[] att_tbl = Attribute.GetCustomAttributes(asm, inherit); - - if ((att_tbl == null) || (att_tbl.Length <= 0)) - return null; - - Type requestedType = typeof(T); - string requestedAssemblyName = requestedType.Assembly.GetName().Name; - List output = new(); - foreach (Attribute att in att_tbl) - { - Type attType = att.GetType(); - string attAssemblyName = attType.Assembly.GetName().Name; - - if ((attType == requestedType) - || IsTypeEqualToFullName(attType, requestedType.FullName) - || ((attAssemblyName.Equals("MelonLoader") - || attAssemblyName.Equals("MelonLoader.ModHandler")) - && (requestedAssemblyName.Equals("MelonLoader") - || requestedAssemblyName.Equals("MelonLoader.ModHandler")) - && IsTypeEqualToName(attType, requestedType.Name))) - output.Add(att as T); - } - - return output.ToArray(); - } - - public static bool IsTypeEqualToName(Type type1, string type2) - => type1.Name == type2 || (type1 != typeof(object) && IsTypeEqualToName(type1.BaseType, type2)); - - public static bool IsTypeEqualToFullName(Type type1, string type2) - => type1.FullName == type2 || (type1 != typeof(object) && IsTypeEqualToFullName(type1.BaseType, type2)); - - public static string MakePlural(this string str, int amount) - => amount == 1 ? str : $"{str}s"; - - public static IEnumerable GetValidTypes(this Assembly asm) - => GetValidTypes(asm, null); - - public static IEnumerable GetValidTypes(this Assembly asm, LemonFunc predicate) - { - IEnumerable returnval = Enumerable.Empty(); - try { returnval = asm.GetTypes().AsEnumerable(); } - catch (ReflectionTypeLoadException ex) - { - //MelonLogger.Error($"Failed to get all types in assembly {asm.FullName} due to: {ex.Message}", ex); - returnval = ex.Types; - } - //catch (Exception ex) - //{ - //MelonLogger.Error($"Failed to get all types in assembly {asm.FullName} due to: {ex.Message}", ex); - // returnval = null; - //} - return returnval.Where(x => (x != null) && (predicate == null || predicate(x))); - } - - public static Type GetValidType(this Assembly asm, string typeName) - => GetValidType(asm, typeName, null); - - public static Type GetValidType(this Assembly asm, string typeName, LemonFunc predicate) - { - Type x = null; - try { x = asm.GetType(typeName); } - catch //(Exception ex) - { - //MelonLogger.Error($"Failed to get type {typeName} from assembly {asm.FullName} due to: {ex.Message}", ex); - x = null; - } - if ((x != null) && (predicate == null || predicate(x))) - return x; - return null; - } - - public static bool IsNotImplemented(this MethodBase methodBase) - { - if (methodBase == null) - throw new ArgumentNullException(nameof(methodBase)); - - DynamicMethodDefinition method = methodBase.ToNewDynamicMethodDefinition(); - ILContext ilcontext = new(method.Definition); - ILCursor ilcursor = new(ilcontext); - - bool returnval = (ilcursor.Instrs.Count == 2) - && (ilcursor.Instrs[1].OpCode.Code == Mono.Cecil.Cil.Code.Throw); - - ilcontext.Dispose(); - method.Dispose(); - return returnval; - } - - public static bool IsManagedDLL(string path) - { - if (Path.GetExtension(path).ToLower() != ".dll") - return false; - - try - { - AssemblyName.GetAssemblyName(path); - return true; - } - catch (FileLoadException) - { - return true; - } - catch - { - return false; - } - } - - public static HarmonyMethod ToNewHarmonyMethod(this MethodInfo methodInfo) - { - if (methodInfo == null) - throw new ArgumentNullException(nameof(methodInfo)); - return new HarmonyMethod(methodInfo); - } - - public static DynamicMethodDefinition ToNewDynamicMethodDefinition(this MethodBase methodBase) - { - if (methodBase == null) - throw new ArgumentNullException(nameof(methodBase)); - return new DynamicMethodDefinition(methodBase); - } - - private static FieldInfo AppDomainSetup_application_base; - public static void SetApplicationBase(this AppDomainSetup _this, string value) - { - if (AppDomainSetup_application_base == null) - AppDomainSetup_application_base = typeof(AppDomainSetup).GetField("application_base", BindingFlags.NonPublic | BindingFlags.Instance); - if (AppDomainSetup_application_base != null) - AppDomainSetup_application_base.SetValue(_this, value); - } - - private static FieldInfo HashAlgorithm_HashSizeValue; - public static void SetHashSizeValue(this HashAlgorithm _this, int value) - { - if (HashAlgorithm_HashSizeValue == null) - HashAlgorithm_HashSizeValue = typeof(HashAlgorithm).GetField("HashSizeValue", BindingFlags.Public | BindingFlags.Instance); - if (HashAlgorithm_HashSizeValue != null) - HashAlgorithm_HashSizeValue.SetValue(_this, value); - } - - // Modified Version of System.IO.Path.HasExtension from .NET Framework's mscorlib.dll - public static bool ContainsExtension(this string path) - { - if (path != null) - { - path.CheckInvalidPathChars(); - int num = path.Length; - while (--num >= 0) - { - char c = path[num]; - if (c == '.') - return num != path.Length - 1; - if (c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar || c == Path.VolumeSeparatorChar) - break; - } - } - return false; - } - - // Modified Version of System.IO.Path.CheckInvalidPathChars from .NET Framework's mscorlib.dll - private static void CheckInvalidPathChars(this string path) - { - foreach (int num in path) - if (num == 34 || num == 60 || num == 62 || num == 124 || num < 32) - throw new ArgumentException("Argument_InvalidPathChars", nameof(path)); - } - - public static void GetDelegate(this IntPtr ptr, out T output) where T : Delegate - => output = GetDelegate(ptr); - public static T GetDelegate(this IntPtr ptr) where T : Delegate - => GetDelegate(ptr, typeof(T)) as T; - public static Delegate GetDelegate(this IntPtr ptr, Type type) - { - if (ptr == IntPtr.Zero) - throw new ArgumentNullException(nameof(ptr)); - Delegate del = Marshal.GetDelegateForFunctionPointer(ptr, type); - if (del == null) - throw new Exception($"Unable to Get Delegate of Type {type.FullName} for Function Pointer!"); - return del; - } - public static IntPtr GetFunctionPointer(this Delegate del) - => Marshal.GetFunctionPointerForDelegate(del); - - public static NativeLibrary ToNewNativeLibrary(this IntPtr ptr) - => new(ptr); - public static NativeLibrary ToNewNativeLibrary(this IntPtr ptr) - => new(ptr); - public static IntPtr GetNativeLibraryExport(this IntPtr ptr, string name) - => NativeLibrary.GetExport(ptr, name); - - public static ClassPackageFile LoadIncludedClassPackage(this AssetsManager assetsManager) - { - var asm = typeof(MelonUtils).Assembly; - var names = asm.GetManifestResourceNames(); - string resourceName = null; - foreach (var name in names) - if (name.Contains("classdata")) - { - resourceName = name; - break; - } - if (string.IsNullOrEmpty(resourceName)) - return null; - - ClassPackageFile classPackage = null; - using (var stream = asm.GetManifestResourceStream(resourceName)) - classPackage = assetsManager.LoadClassPackage(stream); - return classPackage; - } - - [Obsolete("MelonLoader.MelonUtils.GetUnityVersion() is obsolete. Please use MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion instead. This will be removed in a future update.", true)] - public static string GetUnityVersion() => UnityInformationHandler.EngineVersion.ToStringWithoutType(); - [Obsolete("MelonLoader.MelonUtils.GameDeveloper is obsolete. Please use MelonLoader.InternalUtils.UnityInformationHandler.GameDeveloper instead. This will be removed in a future update.", true)] - public static string GameDeveloper { get => UnityInformationHandler.GameDeveloper; } - [Obsolete("MelonLoader.MelonUtils.GameName is obsolete. Please use MelonLoader.InternalUtils.UnityInformationHandler.GameName instead. This will be removed in a future update.", true)] - public static string GameName { get => UnityInformationHandler.GameName; } - [Obsolete("MelonLoader.MelonUtils.GameVersion is obsolete. Please use MelonLoader.InternalUtils.UnityInformationHandler.GameVersion instead. This will be removed in a future update.", true)] - public static string GameVersion { get => UnityInformationHandler.GameVersion; } - - - public static unsafe bool IsGame32Bit() => -#if X64 - false; -#else - true; -#endif - - - public static bool IsGameIl2Cpp() => Directory.Exists(MelonEnvironment.Il2CppDataDirectory); - - public static bool IsOldMono() => File.Exists(MelonEnvironment.UnityGameDataDirectory + "\\Mono\\mono.dll") || - File.Exists(MelonEnvironment.UnityGameDataDirectory + "\\Mono\\libmono.so"); - - public static bool IsUnderWineOrSteamProton() => WineGetVersion is not null; - - [Obsolete("Use MelonEnvironment.GameExecutablePath instead. This will be removed in a future update.", true)] - public static string GetApplicationPath() => MelonEnvironment.GameExecutablePath; - - [Obsolete("Use MelonEnvironment.UnityGameDataDirectory instead. This will be removed in a future update.", true)] - public static string GetGameDataDirectory() => MelonEnvironment.UnityGameDataDirectory; - - [Obsolete("Use MelonEnvironment.MelonManagedDirectory instead. This will be removed in a future update.", true)] - public static string GetManagedDirectory() => MelonEnvironment.MelonManagedDirectory; - - public static void SetConsoleTitle(string title) - { - if (LoaderConfig.Current.Console.DontSetTitle || !BootstrapInterop.Library.IsConsoleOpen()) - return; - - // Using reflection to avoid resolver errors - AccessTools.Property(typeof(Console), "Title")?.SetValue(null, title, null); - } - - public static string GetFileProductName(string filepath) - { - var fileInfo = FileVersionInfo.GetVersionInfo(filepath); - if (fileInfo != null) - return fileInfo.ProductName; - return null; - } - - public static void AddNativeDLLDirectory(string path) - { - if (!IsWindows && !IsUnix) - return; - - path = Path.GetFullPath(path); - if (!Directory.Exists(path)) - return; - - string envName = IsWindows ? "PATH" : "LD_LIBRARY_PATH"; - string envSep = IsWindows ? ";" : ":"; - string envPaths = Environment.GetEnvironmentVariable(envName); - Environment.SetEnvironmentVariable(envName, $"{envPaths}{envSep}{path}"); - } - - internal static void SetupWineCheck() - { - if (IsUnix || IsMac) - return; - - IntPtr dll = NativeLibrary.LoadLib("ntdll.dll"); - if (dll == IntPtr.Zero) - return; - - IntPtr wine_get_version_proc = NativeLibrary.AgnosticGetProcAddress(dll, "wine_get_version"); - if (wine_get_version_proc == IntPtr.Zero) - return; - - WineGetVersion = (NativeLibrary.StringDelegate)Marshal.GetDelegateForFunctionPointer( - wine_get_version_proc, - typeof(NativeLibrary.StringDelegate) - ); - } - - [DllImport("ntdll.dll", SetLastError = true)] - internal static extern uint RtlGetVersion(out OsVersionInfo versionInformation); // return type should be the NtStatus enum - - [StructLayout(LayoutKind.Sequential)] - internal struct OsVersionInfo - { - private readonly uint OsVersionInfoSize; - - internal readonly uint MajorVersion; - internal readonly uint MinorVersion; - - internal readonly uint BuildNumber; - - private readonly uint PlatformId; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] - internal readonly string CSDVersion; - } - - internal static string GetOSVersion() - { - if (IsUnix || IsMac) - return Environment.OSVersion.VersionString; - - if (IsUnderWineOrSteamProton()) - return $"Wine {WineGetVersion()}"; - RtlGetVersion(out OsVersionInfo versionInformation); - var minor = versionInformation.MinorVersion; - var build = versionInformation.BuildNumber; - - string versionString = ""; - - switch (versionInformation.MajorVersion) - { - case 4: - versionString = "Windows 95/98/Me/NT"; - break; - case 5: - if (minor == 0) - versionString = "Windows 2000"; - if (minor == 1) - versionString = "Windows XP"; - if (minor == 2) - versionString = "Windows 2003"; - break; - case 6: - if (minor == 0) - versionString = "Windows Vista"; - if (minor == 1) - versionString = "Windows 7"; - if (minor == 2) - versionString = "Windows 8"; - if (minor == 3) - versionString = "Windows 8.1"; - break; - case 10: - if (build >= 22000) - versionString = "Windows 11"; - else - versionString = "Windows 10"; - break; - default: - versionString = "Unknown"; - break; - } - - return $"{versionString}"; - } - - [Obsolete("Use NativeUtils.NativeHook instead. This will be removed in a future update.", true)] - public static void NativeHookAttach(IntPtr target, IntPtr detour) => BootstrapInterop.NativeHookAttach(target, detour); - - [Obsolete("Use NativeUtils.NativeHook instead. This will be removed in a future update.", true)] - internal static void NativeHookAttachDirect(IntPtr target, IntPtr detour) => BootstrapInterop.NativeHookAttachDirect(target, detour); - - [Obsolete("Use NativeUtils.NativeHook instead. This will be removed in a future update.", true)] - public static void NativeHookDetach(IntPtr target, IntPtr detour) => BootstrapInterop.NativeHookDetach(target, detour); - - - //Removing these as they're private so mods shouldn't need them - //Can potentially be redirected to MelonEnvironment if really needed. - - //[MethodImpl(MethodImplOptions.InternalCall)] - //[return: MarshalAs(UnmanagedType.LPStr)] - //private extern static string Internal_GetBaseDirectory(); - //[MethodImpl(MethodImplOptions.InternalCall)] - //[return: MarshalAs(UnmanagedType.LPStr)] - //private extern static string Internal_GetGameDirectory(); - } -} diff --git a/MelonLoader/Melons/MelonAssembly.cs b/MelonLoader/Melons/MelonAssembly.cs index 8806bdc03..8b65f8aff 100644 --- a/MelonLoader/Melons/MelonAssembly.cs +++ b/MelonLoader/Melons/MelonAssembly.cs @@ -256,10 +256,10 @@ public void LoadMelons() var authorColorAttr = MelonUtils.PullAttributeFromAssembly(Assembly); var additionalCreditsAttr = MelonUtils.PullAttributeFromAssembly(Assembly); var procAttrs = MelonUtils.PullAttributesFromAssembly(Assembly); - var gameAttrs = MelonUtils.PullAttributesFromAssembly(Assembly); + var gameAttrs = MelonUtils.PullAttributesFromAssembly(Assembly); var optionalDependenciesAttr = MelonUtils.PullAttributeFromAssembly(Assembly); var idAttr = MelonUtils.PullAttributeFromAssembly(Assembly); - var gameVersionAttrs = MelonUtils.PullAttributesFromAssembly(Assembly); + var gameVersionAttrs = MelonUtils.PullAttributesFromAssembly(Assembly); var platformAttr = MelonUtils.PullAttributeFromAssembly(Assembly); var domainAttr = MelonUtils.PullAttributeFromAssembly(Assembly); var mlVersionAttr = MelonUtils.PullAttributeFromAssembly(Assembly); @@ -290,11 +290,6 @@ public void LoadMelons() } } -#if NET6_0_OR_GREATER - RegisterTypeInIl2Cpp.RegisterAssembly(Assembly); - RegisterTypeInIl2CppWithInterfaces.RegisterAssembly(Assembly); -#endif - if (rottenMelons.Count != 0) { MelonLogger.Error($"Failed to load {rottenMelons.Count} {"Melon".MakePlural(rottenMelons.Count)} from {Path.GetFileName(Location)}:"); diff --git a/MelonLoader/Melons/MelonBase.cs b/MelonLoader/Melons/MelonBase.cs index bf3cf0f4e..daa8a327f 100644 --- a/MelonLoader/Melons/MelonBase.cs +++ b/MelonLoader/Melons/MelonBase.cs @@ -1,5 +1,6 @@ using MelonLoader.InternalUtils; using MelonLoader.Properties; +using MelonLoader.Utils; using Semver; using System; using System.Collections.Generic; @@ -38,7 +39,7 @@ public abstract class MelonBase /// /// Creates a new Melon instance for a Wrapper. /// - public static T CreateWrapper(string name, string author, string version, MelonGameAttribute[] games = null, MelonProcessAttribute[] processes = null, int priority = 0, Color? color = null, Color? authorColor = null, string id = null) where T : MelonBase, new() + public static T CreateWrapper(string name, string author, string version, MelonApplicationAttribute[] games = null, MelonProcessAttribute[] processes = null, int priority = 0, Color? color = null, Color? authorColor = null, string id = null) where T : MelonBase, new() { var melon = new T { @@ -81,9 +82,9 @@ private static void SortMelons(ref List melons) where T : MelonBase #region Instance - private MelonGameAttribute[] _games = new MelonGameAttribute[0]; + private MelonApplicationAttribute[] _games = new MelonApplicationAttribute[0]; private MelonProcessAttribute[] _processes = new MelonProcessAttribute[0]; - private MelonGameVersionAttribute[] _gameVersions = new MelonGameVersionAttribute[0]; + private MelonApplicationVersionAttribute[] _gameVersions = new MelonApplicationVersionAttribute[0]; public readonly MelonEvent OnRegister = new(); public readonly MelonEvent OnUnregister = new(); @@ -130,19 +131,19 @@ public MelonProcessAttribute[] SupportedProcesses /// /// Game Attributes of the Melon. /// - public MelonGameAttribute[] Games + public MelonApplicationAttribute[] Games { get => _games; - internal set => _games = (value == null || value.Any(x => x.Universal)) ? new MelonGameAttribute[0] : value; + internal set => _games = (value == null || value.Any(x => x.Universal)) ? new MelonApplicationAttribute[0] : value; } /// /// Game Version Attributes of the Melon. /// - public MelonGameVersionAttribute[] SupportedGameVersions + public MelonApplicationVersionAttribute[] SupportedGameVersions { get => _gameVersions; - internal set => _gameVersions = (value == null || value.Any(x => x.Universal)) ? new MelonGameVersionAttribute[0] : value; + internal set => _gameVersions = (value == null || value.Any(x => x.Universal)) ? new MelonApplicationVersionAttribute[0] : value; } /// @@ -198,30 +199,10 @@ public MelonGameVersionAttribute[] SupportedGameVersions #region Callbacks /// - /// Runs before Support Module Initialization and after Assembly Generation for Il2Cpp Games. + /// Runs before Engine Module Initialization. /// public virtual void OnPreSupportModule() { } - /// - /// Runs once per frame. - /// - public virtual void OnUpdate() { } - - /// - /// Can run multiple times per frame. Mostly used for Physics. - /// - public virtual void OnFixedUpdate() { } - - /// - /// Runs once per frame, after . - /// - public virtual void OnLateUpdate() { } - - /// - /// Can run multiple times per frame. Mostly used for Unity's IMGUI. - /// - public virtual void OnGUI() { } - /// /// Runs on a quit request. It is possible to abort the request in this callback. /// @@ -273,12 +254,12 @@ public virtual void OnDeinitializeMelon() { } #endregion - public Incompatibility[] FindIncompatiblities(MelonGameAttribute game, string processName, string gameVersion, + public Incompatibility[] FindIncompatiblities(MelonApplicationAttribute game, string processName, string gameVersion, string mlVersion, string mlBuildHashCode, MelonPlatformAttribute.CompatiblePlatforms platform, MelonPlatformDomainAttribute.CompatibleDomains domain) => FindIncompatiblities(game, processName, gameVersion, SemVersion.Parse(mlVersion), mlBuildHashCode, platform, domain); - public Incompatibility[] FindIncompatiblities(MelonGameAttribute game, string processName, string gameVersion, + public Incompatibility[] FindIncompatiblities(MelonApplicationAttribute game, string processName, string gameVersion, SemVersion mlVersion, string mlBuildHashCode, MelonPlatformAttribute.CompatiblePlatforms platform, MelonPlatformDomainAttribute.CompatibleDomains domain) { @@ -312,7 +293,13 @@ public Incompatibility[] FindIncompatiblities(MelonGameAttribute game, string pr public Incompatibility[] FindIncompatiblitiesFromContext() { - return FindIncompatiblities(MelonUtils.CurrentGameAttribute, Process.GetCurrentProcess().ProcessName, UnityInformationHandler.GameVersion, BuildInfo.VersionNumber, MelonUtils.HashCode, MelonUtils.CurrentPlatform, MelonUtils.CurrentDomain); + return FindIncompatiblities(MelonEnvironment.CurrentApplicationAttribute, + Process.GetCurrentProcess().ProcessName, + MelonEnvironment.CurrentApplicationInfo.Version, + BuildInfo.VersionNumber, + MelonEnvironment.HashCode, + MelonEnvironment.CurrentPlatform, + MelonEnvironment.CurrentDomain); } public static void PrintIncompatibilities(Incompatibility[] incompatibilities, MelonBase melon) @@ -459,42 +446,18 @@ protected private virtual bool RegisterInternal() protected private virtual void UnregisterInternal() { } - protected private virtual void RegisterCallbacks() + public virtual void RegisterCallbacks() { MelonEvents.OnApplicationQuit.Subscribe(OnApplicationQuit, Priority); - MelonEvents.OnUpdate.Subscribe(OnUpdate, Priority); - MelonEvents.OnLateUpdate.Subscribe(OnLateUpdate, Priority); - MelonEvents.OnGUI.Subscribe(OnGUI, Priority); - MelonEvents.OnFixedUpdate.Subscribe(OnFixedUpdate, Priority); - -#pragma warning disable CS0612 // Type or member is obsolete - RegisterObsoleteCallbacks(); -#pragma warning restore CS0612 // Type or member is obsolete MelonPreferences.OnPreferencesLoaded.Subscribe(PrefsLoaded, Priority); MelonPreferences.OnPreferencesSaved.Subscribe(PrefsSaved, Priority); } - [Obsolete] - private void RegisterObsoleteCallbacks() - { - MelonEvents.OnApplicationLateStart.Subscribe(OnApplicationLateStart, Priority); - } - private void PrefsSaved(string path) { OnPreferencesSaved(path); OnPreferencesSaved(); - -#pragma warning disable CS0612 // Type or member is obsolete - PrefsSavedObsoleteCallback(); -#pragma warning restore CS0612 // Type or member is obsolete - } - - [Obsolete] - private void PrefsSavedObsoleteCallback() - { - OnModSettingsApplied(); } private void PrefsLoaded(string path) @@ -634,42 +597,6 @@ public object SendMessage(string name, params object[] arguments) } #endregion - #region Obsolete Members - - [Obsolete] - private Harmony.HarmonyInstance _OldHarmonyInstance; - - [Obsolete("Please use either the OnLateInitializeMelon callback, or the 'MelonEvents::OnApplicationLateStart' event instead. This will be removed in a future update.", true)] - public virtual void OnApplicationLateStart() { } - - [Obsolete("For mods, use OnInitializeMelon instead. For plugins, use OnPreModsLoaded instead. This will be removed in a future update.", true)] - public virtual void OnApplicationStart() { } - - [Obsolete("Please use OnPreferencesSaved instead. This will be removed in a future update.", true)] - public virtual void OnModSettingsApplied() { } - - [Obsolete("Please use HarmonyInstance instead. This will be removed in a future update.", true)] -#pragma warning disable IDE1006 // Naming Styles - public Harmony.HarmonyInstance harmonyInstance { get { _OldHarmonyInstance ??= new Harmony.HarmonyInstance(HarmonyInstance.Id); return _OldHarmonyInstance; } } -#pragma warning restore IDE1006 // Naming Styles - - [Obsolete("Please use HarmonyInstance instead. This will be removed in a future update.", true)] - public Harmony.HarmonyInstance Harmony { get { _OldHarmonyInstance ??= new Harmony.HarmonyInstance(HarmonyInstance.Id); return _OldHarmonyInstance; } } - - [Obsolete("Please use MelonAssembly.Assembly instead. This will be removed in a future update.", true)] - public Assembly Assembly => MelonAssembly.Assembly; - - [Obsolete("Please use MelonAssembly.HarmonyDontPatchAll instead. This will be removed in a future update.", true)] - public bool HarmonyDontPatchAll => MelonAssembly.HarmonyDontPatchAll; - - [Obsolete("Please use MelonAssembly.Hash instead. This will be removed in a future update.", true)] - public string Hash => MelonAssembly.Hash; - - [Obsolete("Please use MelonAssembly.Location instead. This will be removed in a future update.", true)] - public string Location => MelonAssembly.Location; - - #endregion - public enum Incompatibility { diff --git a/MelonLoader/Melons/MelonFolderHandler.cs b/MelonLoader/Melons/MelonFolderHandler.cs index bac85b688..bceba31d8 100644 --- a/MelonLoader/Melons/MelonFolderHandler.cs +++ b/MelonLoader/Melons/MelonFolderHandler.cs @@ -6,7 +6,7 @@ namespace MelonLoader.Melons { - internal class MelonFolderHandler + internal class ModuleFolderHandler { private static bool firstSpacer = false; private static List userLibDirs = new(); @@ -35,7 +35,7 @@ internal static void ScanForFolders() // Add Directories to Resolver foreach (string directory in userLibDirs) { - MelonUtils.AddNativeDLLDirectory(directory); + OsUtils.AddNativeDLLDirectory(directory); Resolver.MelonAssemblyResolver.AddSearchDirectory(directory); } foreach (string directory in pluginDirs) @@ -141,11 +141,6 @@ private static void ScanFolder(eScanType scanType, if (!Directory.Exists(dir)) continue; - // Validate Manifest - string manifestPath = Path.Combine(dir, "manifest.json"); - if (!File.Exists(manifestPath)) - continue; - // Check for Deeper UserLibs string userLibsPath = Path.Combine(dir, "UserLibs"); if (Directory.Exists(userLibsPath)) diff --git a/MelonLoader/Melons/MelonHandler.cs b/MelonLoader/Melons/MelonHandler.cs deleted file mode 100644 index 7931fcecf..000000000 --- a/MelonLoader/Melons/MelonHandler.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Reflection; -using MelonLoader.Melons; -using MelonLoader.Utils; - -namespace MelonLoader -{ - public static class MelonHandler - { - /// - /// Directory of Plugins. - /// - [Obsolete("Use MelonEnvironment.PluginsDirectory instead. This will be removed in a future update.", true)] - public static string PluginsDirectory => MelonEnvironment.PluginsDirectory; - - /// - /// Directory of Mods. - /// - [Obsolete("Use MelonEnvironment.ModsDirectory instead. This will be removed in a future update.", true)] - public static string ModsDirectory => MelonEnvironment.ModsDirectory; - - internal static void Setup() - { - if (!Directory.Exists(MelonEnvironment.PluginsDirectory)) - Directory.CreateDirectory(MelonEnvironment.PluginsDirectory); - - if (!Directory.Exists(MelonEnvironment.ModsDirectory)) - Directory.CreateDirectory(MelonEnvironment.ModsDirectory); - } - - #region Obsolete Members - /// - /// List of Plugins. - /// - [Obsolete("Use 'MelonPlugin.RegisteredMelons' instead. This will be removed in a future update.", true)] - public static List Plugins => MelonTypeBase.RegisteredMelons.ToList(); - - /// - /// List of Mods. - /// - [Obsolete("Use 'MelonMod.RegisteredMelons' instead. This will be removed in a future update.", true)] - public static List Mods => MelonTypeBase.RegisteredMelons.ToList(); - - [Obsolete("Use 'MelonBase.Load' and 'MelonBase.Register' instead. This will be removed in a future update.", true)] - public static void LoadFromFile(string filelocation, bool is_plugin) => LoadFromFile(filelocation); - - [Obsolete("Use 'MelonBase.Load' and 'MelonBase.Register' instead. This will be removed in a future update.", true)] - public static void LoadFromByteArray(byte[] filedata, string filelocation) => LoadFromByteArray(filedata, filepath: filelocation); - - [Obsolete("Use 'MelonBase.Load' and 'MelonBase.Register' instead. This will be removed in a future update.", true)] - public static void LoadFromByteArray(byte[] filedata, string filelocation, bool is_plugin) => LoadFromByteArray(filedata, filepath: filelocation); - - [Obsolete("Use 'MelonBase.Load' and 'MelonBase.Register' instead. This will be removed in a future update.", true)] - public static void LoadFromAssembly(Assembly asm, string filelocation, bool is_plugin) => LoadFromAssembly(asm, filelocation); - - [Obsolete("Use 'MelonBase.Hash' instead. This will be removed in a future update.", true)] - public static string GetMelonHash(MelonBase melonBase) - => melonBase.Hash; - - [Obsolete("Use 'MelonBase.RegisteredMelons.Exists(1)' instead. This will be removed in a future update.", true)] - public static bool IsMelonAlreadyLoaded(string name) - => MelonBase._registeredMelons.Exists(x => x.Info.Name == name); - - [Obsolete("Use 'MelonPlugin.RegisteredMelons.Exists(1)' instead. This will be removed in a future update.", true)] - public static bool IsPluginAlreadyLoaded(string name) - => MelonTypeBase._registeredMelons.Exists(x => x.Info.Name == name); - - [Obsolete("Use 'MelonMod.RegisteredMelons.Exists(1)' instead. This will be removed in a future update.", true)] - public static bool IsModAlreadyLoaded(string name) - => MelonTypeBase._registeredMelons.Exists(x => x.Info.Name == name); - - [Obsolete("Use 'MelonBase.Load' and 'MelonBase.Register' instead. This will be removed in a future update.", true)] - public static void LoadFromFile(string filepath, string symbolspath = null) - { - var asm = MelonAssembly.LoadMelonAssembly(filepath); - if (asm == null) - return; - - MelonBase.RegisterSorted(asm.LoadedMelons); - } - - [Obsolete("Use 'MelonBase.Load' and 'MelonBase.Register' instead. This will be removed in a future update.", true)] - public static void LoadFromByteArray(byte[] filedata, byte[] symbolsdata = null, string filepath = null) - { - var asm = MelonAssembly.LoadRawMelonAssembly(filepath, filedata, symbolsdata); - if (asm == null) - return; - - MelonBase.RegisterSorted(asm.LoadedMelons); - } - - [Obsolete("Use 'MelonBase.Load' and 'MelonBase.Register' instead. This will be removed in a future update.", true)] - public static void LoadFromAssembly(Assembly asm, string filepath = null) - { - var ma = MelonAssembly.LoadMelonAssembly(filepath, asm); - if (ma == null) - return; - - MelonBase.RegisterSorted(ma.LoadedMelons); - } - #endregion - } -} diff --git a/MelonLoader/Melons/MelonMod.cs b/MelonLoader/Melons/MelonMod.cs index e40ff0894..c895d8185 100644 --- a/MelonLoader/Melons/MelonMod.cs +++ b/MelonLoader/Melons/MelonMod.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -#pragma warning disable 0618 // Disabling the obsolete references warning to prevent the IDE going crazy when subscribing deprecated methods to some events in RegisterCallbacks namespace MelonLoader { @@ -34,75 +32,11 @@ protected private override bool RegisterInternal() return true; } + private void HarmonyInit() { if (!MelonAssembly.HarmonyDontPatchAll) HarmonyInstance.PatchAll(MelonAssembly.Assembly); } - - protected private override void RegisterCallbacks() - { - base.RegisterCallbacks(); - - MelonEvents.OnSceneWasLoaded.Subscribe(OnSceneWasLoaded, Priority); - MelonEvents.OnSceneWasInitialized.Subscribe(OnSceneWasInitialized, Priority); - MelonEvents.OnSceneWasUnloaded.Subscribe(OnSceneWasUnloaded, Priority); - -#pragma warning disable CS0612 // Type or member is obsolete - RegisterObsoleteCallbacks(); -#pragma warning restore CS0612 // Type or member is obsolete - } - - [Obsolete] - private void RegisterObsoleteCallbacks() - { - MelonEvents.OnSceneWasLoaded.Subscribe((idx, name) => OnLevelWasLoaded(idx), Priority); - MelonEvents.OnSceneWasInitialized.Subscribe((idx, name) => OnLevelWasInitialized(idx), Priority); - MelonEvents.OnApplicationStart.Subscribe(OnApplicationStart, Priority); - } - - #region Callbacks - - /// - /// Runs when a new Scene is loaded. - /// - public virtual void OnSceneWasLoaded(int buildIndex, string sceneName) { } - - /// - /// Runs once a Scene is initialized. - /// - public virtual void OnSceneWasInitialized(int buildIndex, string sceneName) { } - - /// - /// Runs once a Scene unloads. - /// - public virtual void OnSceneWasUnloaded(int buildIndex, string sceneName) { } - - #endregion - - #region Obsolete Members - [Obsolete("Override OnSceneWasLoaded instead. This will be removed in a future update.", true)] - public virtual void OnLevelWasLoaded(int level) { } - [Obsolete("Override OnSceneWasInitialized instead. This will be removed in a future update.", true)] - public virtual void OnLevelWasInitialized(int level) { } - - [Obsolete()] - private MelonModInfoAttribute _LegacyInfoAttribute = null; - [Obsolete("Use MelonBase.Info instead. This will be removed in a future update.", true)] - public MelonModInfoAttribute InfoAttribute { get { if (_LegacyInfoAttribute == null) _LegacyInfoAttribute = new MelonModInfoAttribute(Info.SystemType, Info.Name, Info.Version, Info.Author, Info.DownloadLink); return _LegacyInfoAttribute; } } - [Obsolete()] - private MelonModGameAttribute[] _LegacyGameAttributes = null; - [Obsolete("Use MelonBase.Games instead. This will be removed in a future update.", true)] - public MelonModGameAttribute[] GameAttributes { get { - if (_LegacyGameAttributes != null) - return _LegacyGameAttributes; - List newatts = new(); - foreach (MelonGameAttribute att in Games) - newatts.Add(new MelonModGameAttribute(att.Developer, att.Name)); - _LegacyGameAttributes = newatts.ToArray(); - return _LegacyGameAttributes; - } } - - #endregion } } \ No newline at end of file diff --git a/MelonLoader/Melons/MelonPlugin.cs b/MelonLoader/Melons/MelonPlugin.cs index 76cc793fe..f1da0f302 100644 --- a/MelonLoader/Melons/MelonPlugin.cs +++ b/MelonLoader/Melons/MelonPlugin.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -#pragma warning disable 0618 // Disabling the obsolete references warning to prevent the IDE going crazy when subscribing deprecated methods to some events in RegisterCallbacks - -namespace MelonLoader +namespace MelonLoader { public abstract class MelonPlugin : MelonTypeBase { @@ -11,28 +7,6 @@ static MelonPlugin() TypeName = "Plugin"; } - protected private override void RegisterCallbacks() - { - base.RegisterCallbacks(); - - MelonEvents.OnPreInitialization.Subscribe(OnPreInitialization, Priority); - MelonEvents.OnApplicationEarlyStart.Subscribe(OnApplicationEarlyStart, Priority); - MelonEvents.OnPreModsLoaded.Subscribe(OnPreModsLoaded, Priority); - -#pragma warning disable CS0612 // Type or member is obsolete - RegisterObsoleteCallbacks(); -#pragma warning restore CS0612 // Type or member is obsolete - - MelonEvents.OnApplicationStart.Subscribe(OnApplicationStarted, Priority); - MelonEvents.OnPreSupportModule.Subscribe(OnPreSupportModule, Priority); - } - - [Obsolete] - private void RegisterObsoleteCallbacks() - { - MelonEvents.OnPreModsLoaded.Subscribe(OnApplicationStart, Priority); - } - protected private override bool RegisterInternal() { if (!base.RegisterInternal()) @@ -45,12 +19,25 @@ protected private override bool RegisterInternal() return true; } + private void HarmonyInit() { if (!MelonAssembly.HarmonyDontPatchAll) HarmonyInstance.PatchAll(MelonAssembly.Assembly); } + public override void RegisterCallbacks() + { + base.RegisterCallbacks(); + + MelonEvents.OnPreInitialization.Subscribe(OnPreInitialization, Priority); + MelonEvents.OnApplicationEarlyStart.Subscribe(OnApplicationEarlyStart, Priority); + MelonEvents.OnPreModsLoaded.Subscribe(OnPreModsLoaded, Priority); + + MelonEvents.OnApplicationStart.Subscribe(OnApplicationStarted, Priority); + MelonEvents.OnPreSupportModule.Subscribe(OnPreSupportModule, Priority); + } + #region Callbacks /// @@ -59,7 +46,7 @@ private void HarmonyInit() public virtual void OnPreInitialization() { } /// - /// Runs after Game Initialization, before OnApplicationStart and before Assembly Generation on Il2Cpp games + /// Runs after Game Initialization, before OnApplicationStart /// public virtual void OnApplicationEarlyStart() { } @@ -74,30 +61,5 @@ public virtual void OnPreModsLoaded() { } public virtual void OnApplicationStarted() { } #endregion - - #region Obsolete Members - - [Obsolete()] - private MelonPluginInfoAttribute _LegacyInfoAttribute = null; - [Obsolete("MelonPlugin.InfoAttribute is obsolete. Please use MelonBase.Info instead. This will be removed in a future update.", true)] - public MelonPluginInfoAttribute InfoAttribute { get { if (_LegacyInfoAttribute == null) _LegacyInfoAttribute = new MelonPluginInfoAttribute(Info.SystemType, Info.Name, Info.Version, Info.Author, Info.DownloadLink); return _LegacyInfoAttribute; } } - [Obsolete()] - private MelonPluginGameAttribute[] _LegacyGameAttributes = null; - [Obsolete("MelonPlugin.GameAttributes is obsolete. Please use MelonBase.Games instead. This will be removed in a future update.", true)] - public MelonPluginGameAttribute[] GameAttributes - { - get - { - if (_LegacyGameAttributes != null) - return _LegacyGameAttributes; - List newatts = new(); - foreach (MelonGameAttribute att in Games) - newatts.Add(new MelonPluginGameAttribute(att.Developer, att.Name)); - _LegacyGameAttributes = newatts.ToArray(); - return _LegacyGameAttributes; - } - } - - #endregion } } \ No newline at end of file diff --git a/MelonLoader/Melons/MelonPreprocessor.cs b/MelonLoader/Melons/MelonPreprocessor.cs index 76228fc0f..850e92047 100644 --- a/MelonLoader/Melons/MelonPreprocessor.cs +++ b/MelonLoader/Melons/MelonPreprocessor.cs @@ -14,7 +14,7 @@ internal static void LoadFolders(List directoryPaths, ref List melonAssemblies) { // Find All Assemblies - Dictionary foundAssemblies = new(); + Dictionary> foundAssemblies = new(); foreach (string path in directoryPaths) PreprocessFolder(path, ref foundAssemblies); @@ -40,7 +40,7 @@ internal static void LoadFolders(List directoryPaths, } private static void PreprocessFolder(string path, - ref Dictionary foundAssemblies) + ref Dictionary> foundAssemblies) { // Validate Path if (!Directory.Exists(path)) @@ -67,12 +67,12 @@ private static void PreprocessFolder(string path, asmDef.Dispose(); // Check for Existing Version - if (foundAssemblies.TryGetValue(name, out (Version, string) existingVersion) + if (foundAssemblies.TryGetValue(name, out LemonTuple existingVersion) && (existingVersion.Item1 >= version)) continue; // Add File to List - foundAssemblies[name] = (version, f); + foundAssemblies[name] = new LemonTuple(version, f); } } diff --git a/MelonLoader/Modules/MelonEngineModule.cs b/MelonLoader/Modules/MelonEngineModule.cs new file mode 100644 index 000000000..519e87cbc --- /dev/null +++ b/MelonLoader/Modules/MelonEngineModule.cs @@ -0,0 +1,22 @@ +using MelonLoader.Utils; +using System; + +namespace MelonLoader.Modules +{ + public abstract class MelonEngineModule : MelonModule + { + public abstract bool Validate(); + public abstract void Initialize(); + + public void SetEngineInfo(string name, string version, string variant = null) + => MelonEnvironment.SetEngineInfo(name, version, variant); + public void SetApplicationInfo(string name, string developer, string version) + => MelonEnvironment.SetApplicationInfo(name, developer, version); + public void PrintAppInfo() + => MelonEnvironment.PrintAppInfo(); + public virtual void Stage2() + => ModuleInterop.Stage2(); + public virtual void Stage3(string supportModulePath) + => ModuleInterop.Stage3(supportModulePath); + } +} diff --git a/MelonLoader/Modules/MelonModule.cs b/MelonLoader/Modules/MelonModule.cs index ee23a5f83..ebb791d32 100644 --- a/MelonLoader/Modules/MelonModule.cs +++ b/MelonLoader/Modules/MelonModule.cs @@ -15,42 +15,16 @@ namespace MelonLoader.Modules /// public abstract class MelonModule { - private Type moduleType; - public string Name { get; private set; } - public Assembly Assembly { get; private set; } - public Info ModuleInfo { get; private set; } protected MelonLogger.Instance LoggerInstance { get; private set; } - protected MelonModule() { } - public virtual void OnInitialize() { } - - internal static MelonModule Load(Info moduleInfo) + internal static T Load(string filePath) + where T : MelonModule { - if (!File.Exists(moduleInfo.fullPath)) - { - MelonDebug.Msg($"MelonModule '{moduleInfo.fullPath}' doesn't exist, ignoring."); - return null; - } - - if (moduleInfo.shouldBeRemoved != null && moduleInfo.shouldBeRemoved()) - { - MelonDebug.Msg($"Removing MelonModule '{moduleInfo.fullPath}'..."); - try - { - File.Delete(moduleInfo.fullPath); - } - catch (Exception ex) - { - MelonLogger.Warning($"Failed to remove MelonModule '{moduleInfo.fullPath}':\n{ex}"); - } - return null; - } - - if (moduleInfo.shouldBeIgnored != null && moduleInfo.shouldBeIgnored()) + if (!File.Exists(filePath)) { - MelonDebug.Msg($"Ignoring MelonModule '{moduleInfo.fullPath}'..."); + MelonDebug.Msg($"MelonModule '{filePath}' doesn't exist, ignoring."); return null; } @@ -58,14 +32,14 @@ internal static MelonModule Load(Info moduleInfo) try { #if NET6_0_OR_GREATER - asm = AssemblyLoadContext.Default.LoadFromAssemblyPath(moduleInfo.fullPath); + asm = AssemblyLoadContext.Default.LoadFromAssemblyPath(filePath); #else - asm = Assembly.LoadFrom(moduleInfo.fullPath); + asm = Assembly.LoadFrom(filePath); #endif } catch (Exception ex) { - MelonLogger.Warning($"Failed to load Assembly of MelonModule '{moduleInfo.fullPath}':\n{ex}"); + MelonLogger.Warning($"Failed to load Assembly of MelonModule '{filePath}':\n{ex}"); return null; } @@ -74,63 +48,24 @@ internal static MelonModule Load(Info moduleInfo) var type = asm.GetTypes().FirstOrDefault(x => typeof(MelonModule).IsAssignableFrom(x)); if (type == null) { - MelonLogger.Warning($"Failed to load MelonModule '{moduleInfo.fullPath}': No type deriving from MelonModule found."); + MelonLogger.Warning($"Failed to load MelonModule '{filePath}': No type deriving from MelonModule found."); return null; } - MelonModule obj; + T obj; try { - obj = (MelonModule)Activator.CreateInstance(type, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, null, null); + obj = (T)Activator.CreateInstance(type, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, null, null); } catch (Exception ex) { - MelonLogger.Warning($"Failed to initialize MelonModule '{moduleInfo.fullPath}':\n{ex}"); + MelonLogger.Warning($"Failed to initialize MelonModule '{filePath}':\n{ex}"); return null; } - obj.moduleType = type; obj.Name = name; - obj.Assembly = asm; - obj.ModuleInfo = moduleInfo; obj.LoggerInstance = new MelonLogger.Instance(name, Color.Magenta); // Magenta cool :) - - try - { - obj.OnInitialize(); - } - catch (Exception ex) - { - obj.LoggerInstance.Error($"Local initialization failed:\n{ex}"); - return null; - } - return obj; } - - public object SendMessage(string name, params object[] arguments) - { - var msg = moduleType.GetMethod(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); - - if (msg == null) - return null; - - return msg.Invoke(msg.IsStatic ? null : this, arguments); - } - - public class Info - { - public readonly string fullPath; - internal readonly Func shouldBeRemoved; - internal readonly Func shouldBeIgnored; - internal MelonModule moduleGC; - - internal Info(string path, Func shouldBeIgnored = null, Func shouldBeRemoved = null) - { - fullPath = Path.GetFullPath(path); - this.shouldBeRemoved = shouldBeRemoved; - this.shouldBeIgnored = shouldBeIgnored; - } - } } } diff --git a/MelonLoader/Modules/MelonRuntimeInfo.cs b/MelonLoader/Modules/MelonRuntimeInfo.cs new file mode 100644 index 000000000..a14cec0e9 --- /dev/null +++ b/MelonLoader/Modules/MelonRuntimeInfo.cs @@ -0,0 +1,7 @@ +namespace MelonLoader.Modules; + +public abstract class MelonRuntimeInfo +{ + public string LibraryPath; + public string SupportModulePath; +} \ No newline at end of file diff --git a/MelonLoader/Modules/MelonSupportModule.cs b/MelonLoader/Modules/MelonSupportModule.cs new file mode 100644 index 000000000..0dbcf3f07 --- /dev/null +++ b/MelonLoader/Modules/MelonSupportModule.cs @@ -0,0 +1,8 @@ +namespace MelonLoader.Modules +{ + public abstract class MelonSupportModule + : MelonModule + { + public abstract void Initialize(); + } +} diff --git a/MelonLoader/Modules/ModuleInterop.cs b/MelonLoader/Modules/ModuleInterop.cs new file mode 100644 index 000000000..5c1ae06cd --- /dev/null +++ b/MelonLoader/Modules/ModuleInterop.cs @@ -0,0 +1,65 @@ +using MelonLoader.Utils; +using System; + +namespace MelonLoader.Modules +{ + public static class ModuleInterop + { + public static MelonEngineModule Engine { get; private set; } + public static MelonSupportModule Support { get; private set; } + + internal static void StartEngine() + { + Engine = ModuleManager.GetEngine(); + if (Engine == null) + { + MelonLogger.Warning("No Engine Module Found! Using Fallback Environment..."); + MelonEnvironment.PrintAppInfo(); + Stage2(); + Stage3(null); + return; + } + + MelonLogger.Msg($"Engine Module Found: {Engine.GetType().Assembly.Location}"); + Engine.Initialize(); + } + + internal static void StartSupport(string path) + { + Support = ModuleManager.GetSupport(path); + if (Support == null) + return; + + MelonLogger.Msg($"Support Module Found: {path}"); + Support.Initialize(); + } + + public static void Stage2() + { + try + { + Core.Stage2(); + } + catch (Exception ex) + { + MelonLogger.Error("Failed to run Stage2 of MelonLoader"); + MelonLogger.Error(ex); + throw new("Error at Stage2"); + } + } + + public static void Stage3(string supportModulePath) + { + try + { + Core.Stage3(supportModulePath); + } + catch (Exception ex) + { + MelonLogger.Error("Failed to run Stage3 of MelonLoader"); + MelonLogger.Error(ex); + throw new("Error at Stage3"); + } + } + } +} diff --git a/MelonLoader/Modules/ModuleManager.cs b/MelonLoader/Modules/ModuleManager.cs new file mode 100644 index 000000000..55f35a80f --- /dev/null +++ b/MelonLoader/Modules/ModuleManager.cs @@ -0,0 +1,45 @@ +using MelonLoader.Utils; +using System.IO; + +namespace MelonLoader.Modules +{ + internal static class ModuleManager + { + internal static MelonEngineModule GetEngine() + { + if (FindEngineModule(MelonEnvironment.LoadersDirectory, out MelonEngineModule module)) + return module; + + foreach (var directory in Directory.GetDirectories(MelonEnvironment.LoadersDirectory, "*", SearchOption.TopDirectoryOnly)) + if (FindEngineModule(directory, out module)) + return module; + + if (FindEngineModule(MelonEnvironment.EngineModulesDirectory, out module)) + return module; + + foreach (var directory in Directory.GetDirectories(MelonEnvironment.EngineModulesDirectory, "*", SearchOption.TopDirectoryOnly)) + if (FindEngineModule(directory, out module)) + return module; + + return null; + } + + internal static MelonSupportModule GetSupport(string filePath) + => MelonModule.Load(filePath); + + private static bool FindEngineModule(string directory, out MelonEngineModule module) + { + foreach (var filePath in Directory.GetFiles(directory, "*.dll", SearchOption.TopDirectoryOnly)) + { + module = MelonModule.Load(filePath); + if ((module == null) + || !module.Validate()) + continue; + return true; + } + + module = null; + return false; + } + } +} diff --git a/MelonLoader/NativeUtils/MelonNativeDetour.cs b/MelonLoader/NativeUtils/MelonNativeDetour.cs new file mode 100644 index 000000000..4fe1cb340 --- /dev/null +++ b/MelonLoader/NativeUtils/MelonNativeDetour.cs @@ -0,0 +1,104 @@ +using System; + +namespace MelonLoader.NativeUtils +{ + public class MelonNativeDetour where T : Delegate + { + #region Private Members + + private IntPtr _targetHandle; + private IntPtr _detourHandle; + private MelonNativeHook _hook; + + #endregion + + #region Public Members + + public bool IsAttached { get; private set; } + + public IntPtr Target + { + get => _targetHandle; + private set + { + if (value == IntPtr.Zero) + throw new ArgumentNullException(nameof(value)); + + _targetHandle = value; + } + } + + public IntPtr Detour + { + get => _detourHandle; + private set + { + if (value == IntPtr.Zero) + throw new ArgumentNullException(nameof(value)); + + _detourHandle = value; + } + } + + public T Trampoline { get => _hook.Trampoline; } + public IntPtr TrampolineHandle { get => _hook.TrampolineHandle; } + + #endregion + + #region Constructors + + public MelonNativeDetour(T target, T detour) : this(target.GetFunctionPointer(), detour.GetFunctionPointer(), true) { } + public MelonNativeDetour(T target, T detour, bool autoAttach) : this(target.GetFunctionPointer(), detour.GetFunctionPointer(), autoAttach) { } + + public MelonNativeDetour(IntPtr target, T detour) : this(target, detour.GetFunctionPointer(), true) { } + public MelonNativeDetour(IntPtr target, T detour, bool autoAttach) : this(target, detour.GetFunctionPointer(), autoAttach) { } + + public MelonNativeDetour(IntPtr target, IntPtr detour) : this(target, detour, true) { } + public MelonNativeDetour(IntPtr target, IntPtr detour, bool autoAttach) + { + if (target == IntPtr.Zero) + throw new ArgumentNullException(nameof(target)); + + if (detour == IntPtr.Zero) + throw new ArgumentNullException(nameof(detour)); + + _targetHandle = target; + _detourHandle = detour; + + _hook = new MelonNativeHook(_targetHandle, _detourHandle); + + if (autoAttach) + Attach(); + } + + #endregion + + #region Public Methods + + public void Attach() + { + if (IsAttached) + return; + + if (_hook == null) + throw new NullReferenceException("The Native Detour's Hook has not been set!"); + _hook.Attach(); + + IsAttached = true; + } + + public void Detach() + { + if (!IsAttached) + return; + + if (_hook == null) + throw new NullReferenceException("The Native Detour's Hook has not been set!"); + _hook.Detach(); + + IsAttached = false; + } + + #endregion + } +} diff --git a/MelonLoader/NativeUtils/MelonNativeHook.cs b/MelonLoader/NativeUtils/MelonNativeHook.cs new file mode 100644 index 000000000..bd5885885 --- /dev/null +++ b/MelonLoader/NativeUtils/MelonNativeHook.cs @@ -0,0 +1,139 @@ +using MelonLoader.InternalUtils; +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +namespace MelonLoader.NativeUtils +{ + public class MelonNativeHook where T : Delegate + { + #region Private Values + private static readonly List _gcProtect = new(); + + private IntPtr _targetHandle; + private IntPtr _detourHandle; + private IntPtr _trampolineHandle; + private T _trampoline; + #endregion + + #region Public Properties + public IntPtr Target + { + get + { + return _targetHandle; + } + + set + { + if (value == IntPtr.Zero) + throw new ArgumentNullException("value"); + + _targetHandle = value; + } + } + + public IntPtr Detour + { + get + { + return _detourHandle; + } + + set + { + if (value == IntPtr.Zero) + throw new ArgumentNullException("value"); + + _detourHandle = value; + } + } + + public T Trampoline + { + get => _trampoline; + private set + { + if (value == null) + throw new ArgumentNullException(nameof(value)); + + if (_trampoline != null) + _gcProtect.Remove(_trampoline); + + _trampoline = value; + _gcProtect.Add(_trampoline); + } + + } + + public IntPtr TrampolineHandle + { + get => _trampolineHandle; + private set + { + if (value == IntPtr.Zero) + throw new ArgumentNullException(nameof(value)); + + _trampolineHandle = value; + } + } + + public bool IsHooked { get; private set; } + #endregion + + public MelonNativeHook() { } + + public MelonNativeHook(IntPtr target, IntPtr detour) + { + if (target == IntPtr.Zero) + throw new ArgumentNullException("target"); + + if (detour == IntPtr.Zero) + throw new ArgumentNullException("detour"); + + _targetHandle = target; + _detourHandle = detour; + } + + public unsafe void Attach() + { + if (IsHooked) + return; + + if (_targetHandle == IntPtr.Zero) + throw new NullReferenceException("The NativeHook's target has not been set!"); + + if (_detourHandle == IntPtr.Zero) + throw new NullReferenceException("The NativeHook's detour has not been set!"); + + IntPtr trampoline = _targetHandle; + BootstrapInterop.NativeHookAttach((IntPtr)(&trampoline), _detourHandle); + _trampolineHandle = trampoline; + + _trampoline = (T)Marshal.GetDelegateForFunctionPointer(_trampolineHandle, typeof(T)); + _gcProtect.Add(_trampoline); + + IsHooked = true; + } + + public unsafe void Detach() + { + if (!IsHooked) + return; + + if (_targetHandle == IntPtr.Zero) + throw new NullReferenceException("The NativeHook's target has not been set!"); + + IntPtr original = _targetHandle; + BootstrapInterop.NativeHookDetach((IntPtr)(&original), _detourHandle); + + IsHooked= false; + _gcProtect.Remove(_trampoline); + _trampoline = null; + _trampolineHandle = IntPtr.Zero; + } + } +} diff --git a/MelonLoader/NativeUtils/MelonNativeLibrary.cs b/MelonLoader/NativeUtils/MelonNativeLibrary.cs new file mode 100644 index 000000000..edc6445a7 --- /dev/null +++ b/MelonLoader/NativeUtils/MelonNativeLibrary.cs @@ -0,0 +1,166 @@ +using MelonLoader.InternalUtils; +using System; +using System.IO; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace MelonLoader +{ + public class MelonNativeLibrary + { + public readonly IntPtr Ptr; + public MelonNativeLibrary(IntPtr ptr) + { + if (ptr == IntPtr.Zero) + throw new ArgumentNullException(nameof(ptr)); + Ptr = ptr; + } + + public static IntPtr LoadLib(string filepath) + { + if (string.IsNullOrEmpty(filepath)) + throw new ArgumentNullException(nameof(filepath)); + IntPtr ptr = BootstrapInterop.NativeLoadLib(filepath); + if (ptr == IntPtr.Zero) + throw new Exception($"Unable to Load Native Library {filepath}!"); + return ptr; + } + + public static bool TryLoadLib(string filepath, out IntPtr result) + { + bool wasSuccessful = false; + try + { + result = LoadLib(filepath); + wasSuccessful = result != IntPtr.Zero; + } + catch { result = IntPtr.Zero; } + return wasSuccessful; + } + + public IntPtr GetExport(string name) + => GetExport(Ptr, name); + public Delegate GetExport(Type type, string name) + => GetExport(Ptr, name).GetDelegate(type); + public T GetExport(string name) where T : Delegate + => GetExport(Ptr, name).GetDelegate(); + public void GetExport(string name, out T output) where T : Delegate + => output = GetExport(Ptr, name).GetDelegate(); + public static IntPtr GetExport(IntPtr nativeLib, string name) + { + if (nativeLib == IntPtr.Zero) + throw new ArgumentNullException(nameof(nativeLib)); + if (string.IsNullOrEmpty(name)) + throw new ArgumentNullException(nameof(name)); + + IntPtr returnval = BootstrapInterop.NativeGetExport(nativeLib, name); + if (returnval == IntPtr.Zero) + throw new Exception($"Unable to Find Native Library Export {name}!"); + + return returnval; + } + + public static bool TryGetExport(IntPtr handle, string name, out IntPtr result) + { + bool wasSuccessful = false; + try + { + result = GetExport(handle, name); + wasSuccessful = result != IntPtr.Zero; + } + catch { result = IntPtr.Zero; } + return wasSuccessful; + } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.LPStr)] + internal delegate string StringDelegate(); + } + + public class MelonNativeLibrary : MelonNativeLibrary + { + public readonly T Instance; + + public static MelonNativeLibrary Load(string libPath, bool throwOnError = true) + { + IntPtr libPtr = LoadLib(libPath); + if (libPtr == IntPtr.Zero) + throw new Exception($"Failed to load {libPath}"); + + return new(libPtr, throwOnError); + } + + public MelonNativeLibrary(IntPtr ptr, bool throwOnError = true) : base(ptr) + { + if (ptr == IntPtr.Zero) + throw new ArgumentNullException(nameof(ptr)); + + Type specifiedType = typeof(T); + if (specifiedType.IsAbstract && specifiedType.IsSealed) + throw new Exception($"Specified Type {specifiedType.FullName} must be Non-Static!"); + + Instance = (T)Activator.CreateInstance(specifiedType); + + foreach (var fieldInfo in specifiedType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) + { + if (fieldInfo.GetCustomAttributes(typeof(CompilerGeneratedAttribute), false).Length != 0) + continue; + + var fieldType = fieldInfo.FieldType; + MelonNativeLibraryImportAttribute[] nativeImportAtt = (MelonNativeLibraryImportAttribute[])fieldType.GetCustomAttributes(typeof(MelonNativeLibraryImportAttribute), false); + if (fieldType.GetCustomAttributes(typeof(UnmanagedFunctionPointerAttribute), false).Length == 0) + continue; + + string exportName = fieldInfo.Name; + if ((nativeImportAtt != null) + && (nativeImportAtt.Length > 0)) + exportName = nativeImportAtt[0].Name; + + Delegate export = null; + try + { + export = GetExport(fieldType, exportName); + } + catch + { + if (throwOnError) + throw; + continue; + } + + fieldInfo.SetValue(Instance, export); + } + + foreach (var propertyInfo in specifiedType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) + { + if (propertyInfo.GetCustomAttributes(typeof(CompilerGeneratedAttribute), false).Length != 0) + continue; + + var fieldType = propertyInfo.PropertyType; + MelonNativeLibraryImportAttribute[] nativeImportAtt = (MelonNativeLibraryImportAttribute[])fieldType.GetCustomAttributes(typeof(MelonNativeLibraryImportAttribute), false); + if (fieldType.GetCustomAttributes(typeof(UnmanagedFunctionPointerAttribute), false).Length == 0) + continue; + + string exportName = propertyInfo.Name; + if ((nativeImportAtt != null) + && (nativeImportAtt.Length > 0)) + exportName = nativeImportAtt[0].Name; + + Delegate export = null; + try + { + export = GetExport(fieldType, exportName); + } + catch + { + if (throwOnError) + throw; + continue; + } + + propertyInfo.SetValue(Instance, export, null); + } + } + } +} diff --git a/MelonLoader/NativeUtils/MelonNativeLibraryImport.cs b/MelonLoader/NativeUtils/MelonNativeLibraryImport.cs new file mode 100644 index 000000000..89b06db69 --- /dev/null +++ b/MelonLoader/NativeUtils/MelonNativeLibraryImport.cs @@ -0,0 +1,15 @@ +using System; + +namespace MelonLoader +{ + [AttributeUsage(AttributeTargets.Delegate)] + public class MelonNativeLibraryImportAttribute : Attribute + { + public MelonNativeLibraryImportAttribute(string name) { Name = name; } + + /// + /// Name of the Export. + /// + public string Name { get; internal set; } + } +} \ No newline at end of file diff --git a/MelonLoader/NativeUtils/NativeHooks.cs b/MelonLoader/NativeUtils/NativeHooks.cs deleted file mode 100644 index 42180b8a2..000000000 --- a/MelonLoader/NativeUtils/NativeHooks.cs +++ /dev/null @@ -1,139 +0,0 @@ -using MelonLoader.InternalUtils; -using System; -using System.CodeDom; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; - -namespace MelonLoader.NativeUtils -{ - public class NativeHook where T : Delegate - { - #region Private Values - private static readonly List _gcProtect = new(); - - private IntPtr _targetHandle; - private IntPtr _detourHandle; - private IntPtr _trampolineHandle; - private T _trampoline; - #endregion - - #region Public Properties - public IntPtr Target - { - get - { - return _targetHandle; - } - - set - { - if (value == IntPtr.Zero) - throw new ArgumentNullException("value"); - - _targetHandle = value; - } - } - - public IntPtr Detour - { - get - { - return _detourHandle; - } - - set - { - if (value == IntPtr.Zero) - throw new ArgumentNullException("value"); - - _detourHandle = value; - } - } - - public T Trampoline - { - get => _trampoline; - private set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - if (_trampoline != null) - _gcProtect.Remove(_trampoline); - - _trampoline = value; - _gcProtect.Add(_trampoline); - } - - } - - public IntPtr TrampolineHandle - { - get => _trampolineHandle; - private set - { - if (value == IntPtr.Zero) - throw new ArgumentNullException(nameof(value)); - - _trampolineHandle = value; - } - } - - public bool IsHooked { get; private set; } - #endregion - - public NativeHook() { } - - public NativeHook(IntPtr target, IntPtr detour) - { - if (target == IntPtr.Zero) - throw new ArgumentNullException("target"); - - if (detour == IntPtr.Zero) - throw new ArgumentNullException("detour"); - - _targetHandle = target; - _detourHandle = detour; - } - - public unsafe void Attach() - { - if (IsHooked) - return; - - if (_targetHandle == IntPtr.Zero) - throw new NullReferenceException("The NativeHook's target has not been set!"); - - if (_detourHandle == IntPtr.Zero) - throw new NullReferenceException("The NativeHook's detour has not been set!"); - - IntPtr trampoline = _targetHandle; - BootstrapInterop.NativeHookAttach((IntPtr)(&trampoline), _detourHandle); - _trampolineHandle = trampoline; - - _trampoline = (T)Marshal.GetDelegateForFunctionPointer(_trampolineHandle, typeof(T)); - _gcProtect.Add(_trampoline); - - IsHooked = true; - } - - public unsafe void Detach() - { - if (!IsHooked) - return; - - if (_targetHandle == IntPtr.Zero) - throw new NullReferenceException("The NativeHook's target has not been set!"); - - IntPtr original = _targetHandle; - BootstrapInterop.NativeHookDetach((IntPtr)(&original), _detourHandle); - - IsHooked= false; - _gcProtect.Remove(_trampoline); - _trampoline = null; - _trampolineHandle = IntPtr.Zero; - } - } -} diff --git a/MelonLoader/NativeUtils/PEParser/PEUtils.cs b/MelonLoader/NativeUtils/PEParser/PEUtils.cs index f4e55988e..8e77c43fc 100644 --- a/MelonLoader/NativeUtils/PEParser/PEUtils.cs +++ b/MelonLoader/NativeUtils/PEParser/PEUtils.cs @@ -1,4 +1,5 @@ -using System; +using MelonLoader.Utils; +using System; using System.Diagnostics; using System.Runtime.InteropServices; @@ -49,7 +50,7 @@ public static unsafe IntPtr GetExportedFunctionPointerForModule(long moduleBaseA { ImageNtHeaders* imageNtHeaders = AnalyseModuleWin((IntPtr)moduleBaseAddress); ImageSectionHeader* pSech = ImageFirstSection(imageNtHeaders); - ImageDataDirectory* imageDirectoryEntryExport = MelonUtils.IsGame32Bit() ? &imageNtHeaders->optionalHeader32.exportTable : &imageNtHeaders->optionalHeader64.exportTable; + ImageDataDirectory* imageDirectoryEntryExport = OsUtils.Is32Bit ? &imageNtHeaders->optionalHeader32.exportTable : &imageNtHeaders->optionalHeader64.exportTable; ImageExportDirectory* pExportDirectory = (ImageExportDirectory*)((long)moduleBaseAddress + imageDirectoryEntryExport->virtualAddress); //MelonLoader.MelonLogger.Msg("pExportDirectory at " + string.Format("{0:X}", (ulong)pExportDirectory - (ulong)moduleBaseAddress)); diff --git a/MelonLoader/Pastel/Pastel.cs b/MelonLoader/Pastel/Pastel.cs index 13b3b39ba..e3887af50 100644 --- a/MelonLoader/Pastel/Pastel.cs +++ b/MelonLoader/Pastel/Pastel.cs @@ -1,4 +1,5 @@ -using System; +using MelonLoader.Utils; +using System; using System.Collections.Generic; using System.Drawing; using System.Globalization; @@ -111,7 +112,7 @@ private enum ColorPlane : byte static ConsoleExtensions() { - if (MelonUtils.IsUnix || MelonUtils.IsMac) + if (OsUtils.IsUnix || OsUtils.IsMac) { Enable(); return; diff --git a/MelonLoader/Preferences/LoaderConfig.cs b/MelonLoader/Preferences/LoaderConfig.cs new file mode 100644 index 000000000..2546b6f07 --- /dev/null +++ b/MelonLoader/Preferences/LoaderConfig.cs @@ -0,0 +1,93 @@ +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using Tomlet.Attributes; + +namespace MelonLoader; + +[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] +public class LoaderConfig +{ + public static LoaderConfig Current { get; internal set; } = new(); + + [TomlProperty("loader")] + public CoreConfig Loader { get; internal set; } = new(); + + [TomlProperty("console")] + public ConsoleConfig Console { get; internal set; } = new(); + + [TomlProperty("logs")] + public LogsConfig Logs { get; internal set; } = new(); + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public class CoreConfig + { + [TomlNonSerialized] + public string BaseDirectory { get; internal set; } = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule!.FileName)!; + + // Technically, this will always return false, but it's still a config ¯\_(ツ)_/¯ + [TomlProperty("disable")] + [TomlPrecedingComment("Disables MelonLoader. Equivalent to the '--no-mods' launch option")] + public bool Disable { get; internal set; } + + [TomlProperty("debug_mode")] + [TomlPrecedingComment("Equivalent to the '--melonloader.debug' launch option")] + public bool DebugMode { get; internal set; } +#if DEBUG + = true; +#endif + + [TomlProperty("force_quit")] + [TomlPrecedingComment("Only use this if the game freezes when trying to quit. Equivalent to the '--quitfix' launch option")] + public bool ForceQuit { get; internal set; } + + [TomlProperty("disable_start_screen")] + [TomlPrecedingComment("Disables the start screen. Equivalent to the '--melonloader.disablestartscreen' launch option")] + public bool DisableStartScreen { get; internal set; } + + [TomlProperty("launch_debugger")] + [TomlPrecedingComment("Starts the dotnet debugger (only for Dotnet). Equivalent to the '--melonloader.launchdebugger' launch option")] + public bool LaunchDebugger { get; internal set; } + + [TomlProperty("theme")] + [TomlPrecedingComment("Sets the loader theme. Currently, the only available themes are \"Normal\" and \"Lemon\". Equivalent to the '--melonloader.consolemode' launch option (0 for Normal, 4 for Lemon)")] + public LoaderTheme Theme { get; internal set; } + + public enum LoaderTheme + { + Normal, + Magenta, + Rainbow, + RandomRainbow, + Lemon + }; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public class ConsoleConfig + { + [TomlProperty("hide_warnings")] + [TomlPrecedingComment("Hides warnings from displaying. Equivalent to the '--melonloader.hidewarnings' launch option")] + public bool HideWarnings { get; internal set; } + + [TomlProperty("hide_console")] + [TomlPrecedingComment("Hides the console. Equivalent to the '--melonloader.hideconsole' launch option")] + public bool Hide { get; internal set; } + + [TomlProperty("console_on_top")] + [TomlPrecedingComment("Forces the console to always stay on-top of all other applications. Equivalent to the '--melonloader.consoleontop' launch option")] + public bool AlwaysOnTop { get; internal set; } + + [TomlProperty("dont_set_title")] + [TomlPrecedingComment("Keeps the console title as original. Equivalent to the '--melonloader.consoledst' launch option")] + public bool DontSetTitle { get; internal set; } + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public class LogsConfig + { + [TomlProperty("max_logs")] + [TomlPrecedingComment("Sets the maximum amount of log files in the Logs folder (Default: 10). Equivalent to the '--melonloader.maxlogs' launch option")] + public uint MaxLogs { get; internal set; } = 10; + } +} \ No newline at end of file diff --git a/MelonLoader/Preferences/MelonPreferences_Entry.cs b/MelonLoader/Preferences/MelonPreferences_Entry.cs index 5bd911991..97c909995 100644 --- a/MelonLoader/Preferences/MelonPreferences_Entry.cs +++ b/MelonLoader/Preferences/MelonPreferences_Entry.cs @@ -38,11 +38,7 @@ public string GetExceptionMessage(string submsg) protected void FireUntypedValueChanged(object old, object neew) { OnEntryValueChangedUntyped.Invoke(old, neew); - OnValueChangedUntyped?.Invoke(); } - - [Obsolete("Please use the OnEntryValueChangedUntyped MelonEvent instead. This will be removed in a future update.", true)] - public event Action OnValueChangedUntyped; } public class MelonPreferences_Entry : MelonPreferences_Entry diff --git a/MelonLoader/Resolver/AssemblyManager.cs b/MelonLoader/Resolver/AssemblyManager.cs index e8025ddc0..d47926774 100644 --- a/MelonLoader/Resolver/AssemblyManager.cs +++ b/MelonLoader/Resolver/AssemblyManager.cs @@ -2,12 +2,6 @@ using System.Collections.Generic; using System.Reflection; -#if NET6_0_OR_GREATER -using System.Runtime.Loader; -#endif - -#pragma warning disable CS8632 - namespace MelonLoader.Resolver { internal class AssemblyManager @@ -16,8 +10,6 @@ internal class AssemblyManager internal static bool Setup() { - InstallHooks(); - // Setup all Loaded Assemblies foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) LoadInfo(assembly); @@ -34,7 +26,7 @@ internal static AssemblyResolveInfo GetInfo(string name) return InfoDict[name]; } - private static Assembly Resolve(string requested_name, Version requested_version, bool is_preload) + internal static Assembly Resolve(string requested_name, Version requested_version, bool is_preload) { // Get Resolve Information Object AssemblyResolveInfo resolveInfo = GetInfo(requested_name); @@ -72,26 +64,5 @@ internal static void LoadInfo(Assembly assembly) // Run Passthrough Events MelonAssemblyResolver.SafeInvoke_OnAssemblyLoad(assembly); } - - private static void InstallHooks() - { -#if NET6_0_OR_GREATER - AssemblyLoadContext.Default.Resolving += Resolve; -#else - InternalUtils.BootstrapInterop.Library.MonoInstallHooks(); -#endif - } - -#if NET6_0_OR_GREATER - private static Assembly? Resolve(AssemblyLoadContext alc, AssemblyName name) - => Resolve(name.Name, name.Version, true); - -#else - private static Assembly Resolve(string requested_name, ushort major, ushort minor, ushort build, ushort revision, bool is_preload) - { - Version requested_version = new Version(major, minor, build, revision); - return Resolve(requested_name, requested_version, is_preload); - } -#endif } } diff --git a/MelonLoader/Resolver/MelonAssemblyResolver.cs b/MelonLoader/Resolver/MelonAssemblyResolver.cs index 4a40a7b6b..5bf5b34c7 100644 --- a/MelonLoader/Resolver/MelonAssemblyResolver.cs +++ b/MelonLoader/Resolver/MelonAssemblyResolver.cs @@ -7,28 +7,44 @@ using System.Runtime.Loader; #endif -#pragma warning disable CS0618 // Type or member is obsolete - namespace MelonLoader.Resolver { - public class MelonAssemblyResolver + public static class MelonAssemblyResolver { internal static void Setup() { - if (!AssemblyManager.Setup()) - return; +#if NET6_0_OR_GREATER + AssemblyLoadContext.Default.Resolving += Resolve; +#endif + + // Setup all Loaded Assemblies + foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) + AssemblyManager.LoadInfo(assembly); + + // Add All Folders in Modules Directory as Searchable + AddSearchDirectories(MelonEnvironment.LoadersDirectory, + Path.Combine(MelonEnvironment.LoadersDirectory, MelonEnvironment.OurRuntimeName)); + foreach (string directory in Directory.GetDirectories(MelonEnvironment.LoadersDirectory, "*", SearchOption.TopDirectoryOnly)) + AddSearchDirectories(directory, Path.Combine(directory, MelonEnvironment.OurRuntimeName)); + + AddSearchDirectories(MelonEnvironment.RuntimeModulesDirectory, + Path.Combine(MelonEnvironment.RuntimeModulesDirectory, MelonEnvironment.OurRuntimeName)); + foreach (string directory in Directory.GetDirectories(MelonEnvironment.RuntimeModulesDirectory, "*", SearchOption.TopDirectoryOnly)) + AddSearchDirectories(directory, Path.Combine(directory, MelonEnvironment.OurRuntimeName)); + + AddSearchDirectories(MelonEnvironment.EngineModulesDirectory, + Path.Combine(MelonEnvironment.EngineModulesDirectory, MelonEnvironment.OurRuntimeName)); + foreach (string directory in Directory.GetDirectories(MelonEnvironment.EngineModulesDirectory, "*", SearchOption.TopDirectoryOnly)) + AddSearchDirectories(directory, Path.Combine(directory, MelonEnvironment.OurRuntimeName)); // Setup Search Directories AddSearchDirectories( MelonEnvironment.UserLibsDirectory, MelonEnvironment.PluginsDirectory, MelonEnvironment.ModsDirectory, - (MelonUtils.IsGameIl2Cpp() - ? MelonEnvironment.Il2CppAssembliesDirectory - : MelonEnvironment.UnityGameManagedDirectory), MelonEnvironment.OurRuntimeDirectory, MelonEnvironment.MelonBaseDirectory, - MelonEnvironment.GameRootDirectory); + MelonEnvironment.ApplicationRootDirectory); // Setup Redirections OverrideBaseAssembly(); @@ -65,7 +81,7 @@ private static void ForceResolveRuntime(params string[] fileNames) #if NET6_0_OR_GREATER assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(filePath); #else - assembly = Assembly.LoadFrom(filePath); + assembly = Assembly.LoadFrom(filePath); #endif } catch { assembly = null; } @@ -91,7 +107,7 @@ public static void AddSearchDirectories(int priority, params string[] directorie AddSearchDirectory(directory, priority); } - public static void AddSearchDirectories(params (string, int)[] directories) + public static void AddSearchDirectories(params LemonTuple[] directories) { foreach (var pair in directories) AddSearchDirectory(pair.Item1, pair.Item2); @@ -106,57 +122,24 @@ public static void RemoveSearchDirectory(string path) public delegate void OnAssemblyLoadHandler(Assembly assembly); public static event OnAssemblyLoadHandler OnAssemblyLoad; internal static void SafeInvoke_OnAssemblyLoad(Assembly assembly) - { -#if !NET6_0_OR_GREATER - // Backwards Compatibility -#pragma warning disable CS0612 // Type or member is obsolete - InvokeObsoleteOnAssemblyLoad(assembly); -#pragma warning restore CS0612 // Type or member is obsolete -#endif - OnAssemblyLoad?.Invoke(assembly); - } - -#if !NET6_0_OR_GREATER - [Obsolete] - private static void InvokeObsoleteOnAssemblyLoad(Assembly assembly) - { - MonoInternals.MonoResolveManager.SafeInvoke_OnAssemblyLoad(assembly); - } -#endif + => OnAssemblyLoad?.Invoke(assembly); public delegate Assembly OnAssemblyResolveHandler(string name, Version version); public static event OnAssemblyResolveHandler OnAssemblyResolve; internal static Assembly SafeInvoke_OnAssemblyResolve(string name, Version version) - { -#if NET6_0_OR_GREATER - - return OnAssemblyResolve?.Invoke(name, version); - -#else - - // Backwards Compatibility -#pragma warning disable CS0612 // Type or member is obsolete - var assembly = InvokeObsoleteOnAssemblyResolve(name, version); -#pragma warning restore CS0612 // Type or member is obsolete - - if (assembly == null) - assembly = OnAssemblyResolve?.Invoke(name, version); - return assembly; - -#endif - } - -#if !NET6_0_OR_GREATER - [Obsolete] - private static Assembly InvokeObsoleteOnAssemblyResolve(string name, Version version) - { - return MonoInternals.MonoResolveManager.SafeInvoke_OnAssemblyResolve(name, version); - } -#endif + => OnAssemblyResolve?.Invoke(name, version); public static AssemblyResolveInfo GetAssemblyResolveInfo(string name) => AssemblyManager.GetInfo(name); public static void LoadInfoFromAssembly(Assembly assembly) => AssemblyManager.LoadInfo(assembly); + + public static Assembly Resolve(string requested_name, Version requested_version, bool is_preload) + => AssemblyManager.Resolve(requested_name, requested_version, is_preload); + +#if NET6_0_OR_GREATER + private static Assembly? Resolve(AssemblyLoadContext alc, AssemblyName name) + => AssemblyManager.Resolve(name.Name, name.Version, true); +#endif } } diff --git a/MelonLoader/Resolver/SearchDirectoryManager.cs b/MelonLoader/Resolver/SearchDirectoryManager.cs index 83d4e4150..12c6f660a 100644 --- a/MelonLoader/Resolver/SearchDirectoryManager.cs +++ b/MelonLoader/Resolver/SearchDirectoryManager.cs @@ -5,10 +5,6 @@ #if NET6_0_OR_GREATER using System.Runtime.Loader; -#else -using System; -using System.Runtime.InteropServices; -using MelonLoader.Utils; #endif namespace MelonLoader.Resolver @@ -84,27 +80,9 @@ internal static Assembly Scan(string requested_name) MelonDebug.Msg($"[MelonAssemblyResolver] Loading from {filepath}..."); #if NET6_0_OR_GREATER - return AssemblyLoadContext.Default.LoadFromAssemblyPath(filepath); - #else - IntPtr filePathPtr = Marshal.StringToHGlobalAnsi(filepath); - if (filePathPtr == IntPtr.Zero) - continue; - - IntPtr rootPtr = InternalUtils.BootstrapInterop.Library.MonoGetDomainPtr(); - if (rootPtr == IntPtr.Zero) - continue; - - IntPtr assemblyPtr = MonoLibrary.Instance.mono_assembly_open_full(filePathPtr, IntPtr.Zero, false); - if (assemblyPtr == IntPtr.Zero) - continue; - - IntPtr assemblyReflectionPtr = MonoLibrary.Instance.mono_assembly_get_object(rootPtr, assemblyPtr); - if (assemblyReflectionPtr == IntPtr.Zero) - continue; - - return MonoLibrary.CastManagedAssemblyPtr(assemblyReflectionPtr); + return Assembly.LoadFile(filepath); #endif } diff --git a/MelonLoader/SupportModule/ISupportModule_From.cs b/MelonLoader/SupportModule/ISupportModule_From.cs deleted file mode 100644 index 6b0a6054c..000000000 --- a/MelonLoader/SupportModule/ISupportModule_From.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace MelonLoader -{ - public interface ISupportModule_From - { - void OnApplicationLateStart(); - void OnSceneWasLoaded(int buildIndex, string sceneName); - void OnSceneWasInitialized(int buildIndex, string sceneName); - void OnSceneWasUnloaded(int buildIndex, string sceneName); - void Update(); - void FixedUpdate(); - void LateUpdate(); - void OnGUI(); - void Quit(); - void DefiniteQuit(); - void SetInteropSupportInterface(InteropSupport.Interface interop); - } -} \ No newline at end of file diff --git a/MelonLoader/SupportModule/ISupportModule_To.cs b/MelonLoader/SupportModule/ISupportModule_To.cs deleted file mode 100644 index 1095eb523..000000000 --- a/MelonLoader/SupportModule/ISupportModule_To.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections; - -namespace MelonLoader -{ - public interface ISupportModule_To - { - object StartCoroutine(IEnumerator coroutine); - void StopCoroutine(object coroutineToken); - void UnityDebugLog(string msg); - } -} \ No newline at end of file diff --git a/MelonLoader/SupportModule/SupportModule.cs b/MelonLoader/SupportModule/SupportModule.cs deleted file mode 100644 index e7c26d01c..000000000 --- a/MelonLoader/SupportModule/SupportModule.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using MelonLoader.Utils; - -namespace MelonLoader -{ - internal static class SupportModule - { - internal static ISupportModule_To Interface = null; - - private static string BaseDirectory = null; - private static List Modules = new List() - { - new ModuleListing("Il2Cpp.dll", MelonUtils.IsGameIl2Cpp), - new ModuleListing("Mono.dll", () => !MelonUtils.IsGameIl2Cpp()) - }; - - internal static bool Setup() - { - BaseDirectory = MelonEnvironment.SupportModuleDirectory; - if (!Directory.Exists(BaseDirectory)) - { - MelonLogger.Error("Failed to Find SupportModules Directory!"); - return false; - } - - LemonEnumerator enumerator = new LemonEnumerator(Modules); - while (enumerator.MoveNext()) - { - string ModulePath = Path.Combine(BaseDirectory, enumerator.Current.FileName); - if (!File.Exists(ModulePath)) - continue; - - try - { - if (enumerator.Current.LoadSpecifier != null) - { - if (!enumerator.Current.LoadSpecifier()) - { - //File.Delete(ModulePath); - //string depsJson = Path.Combine(Path.GetDirectoryName(ModulePath), - // Path.GetFileNameWithoutExtension(ModulePath) + ".deps.json"); - //if (File.Exists(depsJson)) - // File.Delete(depsJson); - - continue; - } - } - - if (Interface != null) - continue; - - if (!LoadInterface(ModulePath)) - continue; - } - catch (Exception ex) - { - MelonDebug.Error($"Support Module [{enumerator.Current.FileName}] threw an Exception: {ex}"); - continue; - } - } - - if (Interface == null) - { - MelonLogger.Error("No Support Module Loaded!"); - return false; - } - return true; - } - - private static bool LoadInterface(string ModulePath) - { - Assembly assembly = Assembly.LoadFrom(ModulePath); - if (assembly == null) - return false; - - Type type = assembly.GetType("MelonLoader.Support.Main"); - if (type == null) - { - MelonLogger.Error("Failed to Get Type MelonLoader.Support.Main!"); - return false; - } - - MethodInfo method = type.GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Static); - if (method == null) - { - MelonLogger.Error("Failed to Get Method Initialize!"); - return false; - } - - Interface = (ISupportModule_To)method.Invoke(null, new object[] { new SupportModule_From() }); - if (Interface == null) - { - MelonLogger.Error("Failed to Initialize Interface!"); - return false; - } - - MelonLogger.Msg($"Support Module Loaded: {ModulePath}"); - - return true; - } - - // Module Listing - private class ModuleListing - { - internal string FileName = null; - internal delegate bool dLoadSpecifier(); - internal dLoadSpecifier LoadSpecifier = null; - internal ModuleListing(string filename) - => FileName = filename; - internal ModuleListing(string filename, dLoadSpecifier loadSpecifier) - { - FileName = filename; - LoadSpecifier = loadSpecifier; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/SupportModule/SupportModule_From.cs b/MelonLoader/SupportModule/SupportModule_From.cs deleted file mode 100644 index 371752935..000000000 --- a/MelonLoader/SupportModule/SupportModule_From.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace MelonLoader -{ - internal class SupportModule_From : ISupportModule_From - { - public void OnApplicationLateStart() - => MelonEvents.OnApplicationLateStart.Invoke(); - - public void OnSceneWasLoaded(int buildIndex, string sceneName) - => MelonEvents.OnSceneWasLoaded.Invoke(buildIndex, sceneName); - - public void OnSceneWasInitialized(int buildIndex, string sceneName) - => MelonEvents.OnSceneWasInitialized.Invoke(buildIndex, sceneName); - - public void OnSceneWasUnloaded(int buildIndex, string sceneName) - => MelonEvents.OnSceneWasUnloaded.Invoke(buildIndex, sceneName); - - public void Update() - => MelonEvents.OnUpdate.Invoke(); - - public void FixedUpdate() - => MelonEvents.OnFixedUpdate.Invoke(); - - public void LateUpdate() - => MelonEvents.OnLateUpdate.Invoke(); - - public void OnGUI() - => MelonEvents.OnGUI.Invoke(); - - public void Quit() - => MelonEvents.OnApplicationQuit.Invoke(); - - public void DefiniteQuit() - { - MelonEvents.OnApplicationDefiniteQuit.Invoke(); - Core.Quit(); - } - - public void SetInteropSupportInterface(InteropSupport.Interface interop) - { - if (InteropSupport.SMInterface == null) - InteropSupport.SMInterface = interop; - } - } -} \ No newline at end of file diff --git a/MelonLoader/Utils/Assertion.cs b/MelonLoader/Utils/Assertion.cs deleted file mode 100644 index 5fdb739a7..000000000 --- a/MelonLoader/Utils/Assertion.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace MelonLoader.Utils -{ - internal static class Assertion - { - internal static bool ShouldContinue = true; - - //TODO: Could this be done in a better way? net35/6 load PresentationFramework differently so I could not rely on it - //This crashes with start screen enabled - [DllImport("user32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr MessageBox(int hWnd, String text, String caption, uint type); - - internal static void ThrowInternalFailure(string msg) - { - if (!ShouldContinue) - return; - - ShouldContinue = false; - - MelonLogger.PassLogError(msg, "INTERNAL FAILURE", false); - - string caption = "INTERNAL FAILURE!"; - var result = MessageBox(0, msg, caption, 0); - while (result == IntPtr.Zero) - Environment.Exit(1); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Utils/InteropSupport.cs b/MelonLoader/Utils/InteropSupport.cs deleted file mode 100644 index dd11bab9e..000000000 --- a/MelonLoader/Utils/InteropSupport.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using System.Reflection; - -namespace MelonLoader -{ - public static class InteropSupport - { - public interface Interface - { - bool IsInheritedFromIl2CppObjectBase(Type type); - public bool IsInjectedType(Type type); - public IntPtr GetClassPointerForType(Type type); - FieldInfo MethodBaseToIl2CppFieldInfo(MethodBase method); - int? GetIl2CppMethodCallerCount(MethodBase method); - void RegisterTypeInIl2CppDomain(Type type, bool logSuccess); - void RegisterTypeInIl2CppDomainWithInterfaces(Type type, Type[] interfaces, bool logSuccess); - IntPtr CopyMethodInfoStruct(IntPtr ptr); - } - internal static Interface SMInterface; - - private static void ValidateInterface() - { - if (!MelonUtils.IsGameIl2Cpp()) - throw new Exception("MelonLoader.InteropSupport can't be used on Non-Il2Cpp Games"); - if (SMInterface == null) - throw new NullReferenceException("SMInterface cannot be null."); - } - - public static bool IsGeneratedAssemblyType(Type type) - => IsInheritedFromIl2CppObjectBase(type) && !IsInjectedType(type); - - public static bool IsInheritedFromIl2CppObjectBase(Type type) - { - ValidateInterface(); - if (type == null) - throw new NullReferenceException("The type cannot be null."); - return SMInterface.IsInheritedFromIl2CppObjectBase(type); - } - - public static bool IsInjectedType(Type type) - { - ValidateInterface(); - if (type == null) - throw new NullReferenceException("The type cannot be null."); - return SMInterface.IsInjectedType(type); - } - - public static IntPtr GetClassPointerForType(Type type) - { - ValidateInterface(); - if (type == null) - throw new NullReferenceException("The type cannot be null."); - return SMInterface.GetClassPointerForType(type); - } - - public static IntPtr MethodBaseToIl2CppMethodInfoPointer(MethodBase method) - { - ValidateInterface(); - if (method == null) - throw new NullReferenceException("The method cannot be null."); - FieldInfo field = MethodBaseToIl2CppFieldInfo(method); - if (field == null) - return IntPtr.Zero; - return (IntPtr)field.GetValue(null); - } - - public static FieldInfo MethodBaseToIl2CppFieldInfo(MethodBase method) - { - ValidateInterface(); - if (method == null) - throw new NullReferenceException("The method cannot be null."); - return SMInterface.MethodBaseToIl2CppFieldInfo(method); - } - - public static T Il2CppObjectPtrToIl2CppObject(IntPtr ptr) - { - ValidateInterface(); - if (ptr == IntPtr.Zero) - throw new NullReferenceException("The ptr cannot be IntPtr.Zero."); - if (!IsGeneratedAssemblyType(typeof(T))) - throw new NullReferenceException("The type must be a Generated Assembly Type."); - return (T)typeof(T).GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(IntPtr) }, new ParameterModifier[0]).Invoke(new object[] { ptr }); - } - - public static int? GetIl2CppMethodCallerCount(MethodBase method) - { - ValidateInterface(); - if (method == null) - throw new NullReferenceException("The method cannot be null."); - return SMInterface.GetIl2CppMethodCallerCount(method); - } - - public static void RegisterTypeInIl2CppDomain(Type type) - => RegisterTypeInIl2CppDomain(type, true); - - public static void RegisterTypeInIl2CppDomain(Type type, bool logSuccess) - { - ValidateInterface(); - if (type == null) - throw new NullReferenceException("The type cannot be null."); - SMInterface.RegisterTypeInIl2CppDomain(type, logSuccess); - } - - public static void RegisterTypeInIl2CppDomainWithInterfaces(Type type, Type[] interfaces) - => RegisterTypeInIl2CppDomainWithInterfaces(type, interfaces, true); - - public static void RegisterTypeInIl2CppDomainWithInterfaces(Type type, Type[] interfaces, bool logSuccess) - { - ValidateInterface(); - if (type == null) - throw new NullReferenceException("The type cannot be null."); - if (interfaces == null) - throw new NullReferenceException("The interfaces cannot be null."); - if (interfaces.Length <= 0) - throw new NullReferenceException("The interfaces cannot be empty."); - SMInterface.RegisterTypeInIl2CppDomainWithInterfaces(type, interfaces, logSuccess); - } - - public static IntPtr CopyMethodInfoStruct(IntPtr ptr) - { - ValidateInterface(); - return SMInterface.CopyMethodInfoStruct(ptr); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Utils/MelonAssertion.cs b/MelonLoader/Utils/MelonAssertion.cs new file mode 100644 index 000000000..1de5a8bd5 --- /dev/null +++ b/MelonLoader/Utils/MelonAssertion.cs @@ -0,0 +1,31 @@ +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace MelonLoader.Utils +{ + internal static class MelonAssertion + { + internal static bool ShouldContinue = true; + + //TODO: Could this be done in a better way? net35/6 load PresentationFramework differently so I could not rely on it + //This crashes with start screen enabled + [DllImport("user32.dll", CharSet = CharSet.Auto)] + internal static extern IntPtr MessageBox(int hWnd, String text, String caption, uint type); + + internal static void ThrowInternalFailure(string msg) + { + if (!ShouldContinue) + return; + + ShouldContinue = false; + + MelonLogger.PassLogError(msg, "INTERNAL FAILURE", false); + + string caption = "INTERNAL FAILURE!"; + var result = MessageBox(0, msg, caption, 0); + while (result == IntPtr.Zero) + Environment.Exit(1); + } + } +} \ No newline at end of file diff --git a/MelonLoader/Utils/MelonCoroutines.cs b/MelonLoader/Utils/MelonCoroutines.cs deleted file mode 100644 index 793467896..000000000 --- a/MelonLoader/Utils/MelonCoroutines.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections; - -namespace MelonLoader -{ - public class MelonCoroutines - { - /// - /// Start a new coroutine.
- /// Coroutines are called at the end of the game Update loops. - ///
- /// The target routine - /// An object that can be passed to Stop to stop this coroutine - public static object Start(IEnumerator routine) - { - if (SupportModule.Interface == null) - throw new NotSupportedException("Support module must be initialized before starting coroutines"); - return SupportModule.Interface.StartCoroutine(routine); - } - - /// - /// Stop a currently running coroutine - /// - /// The coroutine to stop - public static void Stop(object coroutineToken) - { - if (SupportModule.Interface == null) - throw new NotSupportedException("Support module must be initialized before starting coroutines"); - SupportModule.Interface.StopCoroutine(coroutineToken); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Utils/MelonEnvironment.cs b/MelonLoader/Utils/MelonEnvironment.cs index c10f77e55..a9084f8fa 100644 --- a/MelonLoader/Utils/MelonEnvironment.cs +++ b/MelonLoader/Utils/MelonEnvironment.cs @@ -1,57 +1,183 @@ using System.IO; using System.Diagnostics; using System; +using MelonLoader.Properties; +using System.Drawing; namespace MelonLoader.Utils { public static class MelonEnvironment { - private const string OurRuntimeName = + private static bool Is_ALPHA_PreRelease = true; + + public const string OurRuntimeName = #if !NET6_0 "net35"; #else "net6"; #endif + public static string HashCode { get; private set; } public static bool IsDotnetRuntime { get; } = OurRuntimeName == "net6"; public static bool IsMonoRuntime { get; } = !IsDotnetRuntime; public static string MelonBaseDirectory => LoaderConfig.Current.Loader.BaseDirectory; - public static string GameExecutablePath { get; } = Process.GetCurrentProcess().MainModule.FileName; public static string MelonLoaderDirectory { get; } = Path.Combine(MelonBaseDirectory, "MelonLoader"); - public static string GameRootDirectory { get; } = Path.GetDirectoryName(GameExecutablePath); + public static string ApplicationExecutablePath { get; } = Process.GetCurrentProcess().MainModule.FileName; + public static string ApplicationExecutableName { get; } = Path.GetFileNameWithoutExtension(ApplicationExecutablePath); + public static string ApplicationRootDirectory { get; } = Path.GetDirectoryName(ApplicationExecutablePath); + + public static string ModsDirectory { get; } = Path.Combine(MelonLoaderDirectory, "Mods"); + public static string PluginsDirectory { get; } = Path.Combine(MelonLoaderDirectory, "Plugins"); + public static string UserLibsDirectory { get; } = Path.Combine(MelonLoaderDirectory, "UserLibs"); + public static string UserDataDirectory { get; } = Path.Combine(MelonLoaderDirectory, "UserData"); + public static string LoadersDirectory { get; } = Path.Combine(MelonLoaderDirectory, "Loaders"); - public static string DependenciesDirectory { get; } = Path.Combine(MelonLoaderDirectory, "Dependencies"); - public static string SupportModuleDirectory { get; } = Path.Combine(DependenciesDirectory, "SupportModules"); - public static string CompatibilityLayerDirectory { get; } = Path.Combine(DependenciesDirectory, "CompatibilityLayers"); - public static string Il2CppAssemblyGeneratorDirectory { get; } = Path.Combine(DependenciesDirectory, "Il2CppAssemblyGenerator"); - public static string ModsDirectory { get; } = Path.Combine(MelonBaseDirectory, "Mods"); - public static string PluginsDirectory { get; } = Path.Combine(MelonBaseDirectory, "Plugins"); - public static string UserLibsDirectory { get; } = Path.Combine(MelonBaseDirectory, "UserLibs"); - public static string UserDataDirectory { get; } = Path.Combine(MelonBaseDirectory, "UserData"); public static string MelonLoaderLogsDirectory { get; } = Path.Combine(MelonLoaderDirectory, "Logs"); - public static string OurRuntimeDirectory { get; } = Path.Combine(MelonLoaderDirectory, OurRuntimeName); + public static string DependenciesDirectory { get; } = Path.Combine(MelonLoaderDirectory, "Dependencies"); + + public static string EngineModulesDirectory { get; } = Path.Combine(DependenciesDirectory, "Engines"); + public static string RuntimeModulesDirectory { get; } = Path.Combine(DependenciesDirectory, "Runtimes"); + + public static string OurRuntimeDirectory { get; } = Path.Combine(DependenciesDirectory, OurRuntimeName); + + public static MelonPlatformAttribute.CompatiblePlatforms CurrentPlatform { get; private set; } + public static MelonPlatformDomainAttribute.CompatibleDomains CurrentDomain { get; private set; } + public static MelonApplicationAttribute CurrentApplicationAttribute { get; private set; } = new(); + + public class EngineInfo + { + public string Name; + public string Version; + public string Variant; + } + public static EngineInfo CurrentEngineInfo { get; private set; } = new(); + + public class ApplicationInfo + { + public string Name; + public string Developer; + public string Version; + } + public static ApplicationInfo CurrentApplicationInfo { get; private set; } = new(); + + public static string GetVersionString() + { + var lemon = LoaderConfig.Current.Loader.Theme == LoaderConfig.CoreConfig.LoaderTheme.Lemon; + var versionStr = $"{(lemon ? "Lemon" : "Melon")}Loader " + + $"v{BuildInfo.Version} " + + $"{(Is_ALPHA_PreRelease ? "ALPHA Pre-Release" : "Open-Beta")}"; + return versionStr; + } + + public static void SetEngineInfo(string name, string version) + => SetEngineInfo(name, version, null); + public static void SetEngineInfo(string name, string version, string variant) + { + if (CurrentEngineInfo == null) + CurrentEngineInfo = new(); + CurrentEngineInfo.Name = name; + CurrentEngineInfo.Version = version; + CurrentEngineInfo.Variant = variant; + } + + public static void SetApplicationInfo(string name, string developer, string version) + { + if (CurrentApplicationInfo == null) + CurrentApplicationInfo = new(); + + CurrentApplicationInfo.Name = name; + CurrentApplicationInfo.Developer = developer; + CurrentApplicationInfo.Version = version; + + if (CurrentApplicationAttribute == null) + CurrentApplicationAttribute = new(); + CurrentApplicationAttribute.Name = name; + CurrentApplicationAttribute.Developer = developer; + } + + internal static void Initialize(AppDomain domain) + { + HashCode = MelonUtils.ComputeSimpleSHA256Hash(typeof(MelonEnvironment).Assembly.Location); + + if (IsMonoRuntime) + MelonUtils.SetCurrentDomainBaseDirectory(ApplicationRootDirectory, domain); + + if (!Directory.Exists(MelonLoaderDirectory)) + Directory.CreateDirectory(MelonLoaderDirectory); + + if (!Directory.Exists(MelonLoaderLogsDirectory)) + Directory.CreateDirectory(MelonLoaderLogsDirectory); + + if (!Directory.Exists(LoadersDirectory)) + Directory.CreateDirectory(LoadersDirectory); - public static string GameExecutableName { get; } = Path.GetFileNameWithoutExtension(GameExecutablePath); - public static string UnityGameDataDirectory { get; } = Path.Combine(GameRootDirectory, GameExecutableName + "_Data"); - public static string UnityGameManagedDirectory { get; } = Path.Combine(UnityGameDataDirectory, "Managed"); - public static string Il2CppDataDirectory { get; } = Path.Combine(UnityGameDataDirectory, "il2cpp_data"); - public static string UnityPlayerPath { get; } = Path.Combine(GameRootDirectory, "UnityPlayer.dll"); + if (!Directory.Exists(UserDataDirectory)) + Directory.CreateDirectory(UserDataDirectory); - public static string MelonManagedDirectory { get; } = Path.Combine(DependenciesDirectory, "Mono"); - public static string Il2CppAssembliesDirectory { get; } = Path.Combine(MelonLoaderDirectory, "Il2CppAssemblies"); + if (!Directory.Exists(UserLibsDirectory)) + Directory.CreateDirectory(UserLibsDirectory); + OsUtils.AddNativeDLLDirectory(UserLibsDirectory); - internal static void PrintEnvironment() + if (!Directory.Exists(PluginsDirectory)) + Directory.CreateDirectory(PluginsDirectory); + + if (!Directory.Exists(ModsDirectory)) + Directory.CreateDirectory(ModsDirectory); + + if (!Directory.Exists(DependenciesDirectory)) + Directory.CreateDirectory(DependenciesDirectory); + + if (!Directory.Exists(EngineModulesDirectory)) + Directory.CreateDirectory(EngineModulesDirectory); + + if (!Directory.Exists(RuntimeModulesDirectory)) + Directory.CreateDirectory(RuntimeModulesDirectory); + + CurrentPlatform = OsUtils.Is32Bit ? MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X86 : MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64; + CurrentDomain = IsDotnetRuntime ? MelonPlatformDomainAttribute.CompatibleDomains.DOTNET : MelonPlatformDomainAttribute.CompatibleDomains.MONO; + + SetEngineInfo(ApplicationExecutableName, "0.0.0"); + SetApplicationInfo(ApplicationExecutableName, ApplicationExecutableName, "0.0.0"); + } + + internal static void PrintBuild() { - //These must not be changed, lum needs them - MelonLogger.MsgDirect($"Core::BasePath = {MelonBaseDirectory}"); - MelonLogger.MsgDirect($"Game::BasePath = {GameRootDirectory}"); - MelonLogger.MsgDirect($"Game::DataPath = {UnityGameDataDirectory}"); - MelonLogger.MsgDirect($"Game::ApplicationPath = {GameExecutablePath}"); + MelonLogger.WriteSpacer(); + MelonLogger.MsgDirect(Color.Pink, "------------------------------"); + MelonLogger.MsgDirect(GetVersionString()); + MelonLogger.MsgDirect(Color.Pink, "------------------------------"); + MelonLogger.MsgDirect($"OS: {OsUtils.GetOSVersion()}"); + MelonLogger.MsgDirect($"Arch: {(OsUtils.Is32Bit ? "x86" : "x64")}"); + MelonLogger.MsgDirect($"Hash Code: {HashCode}"); + MelonLogger.MsgDirect(Color.Pink, "------------------------------"); + MelonLogger.MsgDirect("Command-Line: "); + foreach (var pair in MelonLaunchOptions.InternalArguments) + if (string.IsNullOrEmpty(pair.Value)) + MelonLogger.MsgDirect($" {pair.Key}"); + else + MelonLogger.MsgDirect($" {pair.Key} = {pair.Value}"); + MelonLogger.MsgDirect(Color.Pink, "------------------------------"); + MelonLogger.WriteSpacer(); + } - MelonLogger.MsgDirect($"Runtime Type: {OurRuntimeName}"); + public static void PrintAppInfo() + { + MelonUtils.SetConsoleTitle($"{GetVersionString()} - {CurrentApplicationInfo.Name} {CurrentApplicationInfo.Version ?? ""}"); + MelonLogger.WriteSpacer(); + MelonLogger.MsgDirect(Color.Pink, "------------------------------"); + MelonLogger.MsgDirect($"Engine: {CurrentEngineInfo.Name}"); + MelonLogger.MsgDirect($"Engine Version: {CurrentEngineInfo.Version}"); + if (!string.IsNullOrEmpty(CurrentEngineInfo.Variant)) + MelonLogger.MsgDirect($"Engine Variant: {CurrentEngineInfo.Variant}"); + MelonLogger.MsgDirect(Color.Pink, "------------------------------"); + MelonLogger.MsgDirect($"Application Name: {CurrentApplicationInfo.Name}"); + MelonLogger.MsgDirect($"Application Developer: {CurrentApplicationInfo.Name}"); + MelonLogger.MsgDirect($"Application Version: {CurrentApplicationInfo.Version}"); + MelonLogger.MsgDirect(Color.Pink, "------------------------------"); + MelonLogger.WriteSpacer(); } } } \ No newline at end of file diff --git a/MelonLoader/Utils/MelonEvents.cs b/MelonLoader/Utils/MelonEvents.cs new file mode 100644 index 000000000..ee50762b9 --- /dev/null +++ b/MelonLoader/Utils/MelonEvents.cs @@ -0,0 +1,49 @@ +namespace MelonLoader +{ + public class MelonEvents + { + /// + /// Called after all MelonPlugins are initialized. + /// + public readonly static MelonEvent OnPreInitialization = new(true); + + /// + /// Called after Game Initialization, before OnApplicationStart. + /// + public readonly static MelonEvent OnApplicationEarlyStart = new(true); + + /// + /// Called after all MelonMods are initialized and right before the Engine Support Module is Initialized. + /// + public readonly static MelonEvent OnPreSupportModule = new(true); + + /// + /// Called after all MelonLoader components are fully initialized (including all MelonMods). + /// Don't use this event to initialize your Melons anymore! Instead, override . + /// + public readonly static MelonEvent OnApplicationStart = new(true); + + /// + /// Called when the first 'Start' Unity Messages are invoked. + /// + public readonly static MelonEvent OnApplicationLateStart = new(true); + + /// + /// Called before the Application is closed. It is not possible to prevent the game from closing at this point. + /// + public readonly static MelonEvent OnApplicationDefiniteQuit = new(true); + + /// + /// Called on a quit request. It is possible to abort the request in this callback. + /// + public readonly static MelonEvent OnApplicationQuit = new(); + + /// + /// Called before MelonMods are loaded from the Mods folder. + /// + public readonly static MelonEvent OnPreModsLoaded = new(true); + + internal readonly static MelonEvent MelonHarmonyEarlyInit = new(true); + internal readonly static MelonEvent MelonHarmonyInit = new(true); + } +} diff --git a/MelonLoader/Utils/MelonLaunchOptions.cs b/MelonLoader/Utils/MelonLaunchOptions.cs new file mode 100644 index 000000000..4986dfbcd --- /dev/null +++ b/MelonLoader/Utils/MelonLaunchOptions.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; + +namespace MelonLoader.Utils +{ + public static class MelonLaunchOptions + { + private static Dictionary WithoutArg = new Dictionary(); + private static Dictionary> WithArg = new Dictionary>(); + private static string[] _cmd; + + /// + /// Dictionary of all Arguments with value (if found) that were not used by MelonLoader + /// + /// Key is the argument, Value is the value for the argument, null if not found + /// + /// + public static Dictionary ExternalArguments { get; private set; } = new Dictionary(); + public static Dictionary InternalArguments { get; private set; } = new Dictionary(); + + /// + /// Array of All Command Line Arguments + /// + public static string[] CommandLineArgs + { + get + { + if (_cmd == null) + _cmd = Environment.GetCommandLineArgs(); + return _cmd; + } + } + + internal static void Load() + { + string[] args = CommandLineArgs; + int maxLen = args.Length; + for (int i = 1; i < maxLen; i++) + { + string fullcmd = args[i]; + if (string.IsNullOrEmpty(fullcmd)) + continue; + + // Parse Prefix + string noPrefixCmd = fullcmd; + if (noPrefixCmd.StartsWith("--")) + noPrefixCmd = noPrefixCmd.Remove(0, 2); + else if (noPrefixCmd.StartsWith("-")) + noPrefixCmd = noPrefixCmd.Remove(0, 1); + else + { + // Unknown Command, Add it to Dictionary + ExternalArguments.Add(noPrefixCmd, null); + continue; + } + + // Parse Argumentless Commands + if (WithoutArg.TryGetValue(noPrefixCmd, out Action withoutArgFunc)) + { + InternalArguments.Add(noPrefixCmd, null); + withoutArgFunc(); + continue; + } + + // Parse Argument + string cmdArg = null; + if (noPrefixCmd.Contains("=")) + { + string[] split = noPrefixCmd.Split('='); + noPrefixCmd = split[0]; + cmdArg = split[1]; + } + + if (string.IsNullOrEmpty(cmdArg) + && i + 1 >= maxLen + || string.IsNullOrEmpty(cmdArg) + || cmdArg.StartsWith("--") + || cmdArg.StartsWith("-")) + { + // Unknown Command, Add it to Dictionary + ExternalArguments.Add(noPrefixCmd, null); + continue; + } + + // Parse Argument Commands + if (WithArg.TryGetValue(noPrefixCmd, out Action withArgFunc)) + { + InternalArguments.Add(noPrefixCmd, cmdArg); + withArgFunc(cmdArg); + continue; + } + + // Unknown Command with Argument, Add it to Dictionary + ExternalArguments.Add(noPrefixCmd, cmdArg); + } + } + } +} diff --git a/MelonLoader/Utils/MelonLogger.cs b/MelonLoader/Utils/MelonLogger.cs index ee2738c94..9c0a55703 100644 --- a/MelonLoader/Utils/MelonLogger.cs +++ b/MelonLoader/Utils/MelonLogger.cs @@ -140,13 +140,9 @@ public static void BigError(string namesection, string txt) internal static void RunMsgCallbacks(Color namesection_color, Color txt_color, string namesection, string txt) { - MsgCallbackHandler?.Invoke(DrawingColorToConsoleColor(namesection_color), DrawingColorToConsoleColor(txt_color), namesection, txt); MsgDrawingCallbackHandler?.Invoke(namesection_color, txt_color, namesection, txt); } - [Obsolete("MsgCallbackHandler is obsolete. Please use MsgDrawingCallbackHandler for full Color support. This will be removed in a future update.", true)] - public static event Action MsgCallbackHandler; - public static event Action MsgDrawingCallbackHandler; internal static void RunWarningCallbacks(string namesection, string txt) => WarningCallbackHandler?.Invoke(namesection, txt); @@ -249,9 +245,9 @@ internal static void Warning(string namesection, string txt) PassLogError(txt, namesection, true); } - internal static void ThrowInternalFailure(string txt) => Assertion.ThrowInternalFailure(txt); + public static void ThrowInternalFailure(string txt) => MelonAssertion.ThrowInternalFailure(txt); - internal static unsafe void WriteSpacer() + public static unsafe void WriteSpacer() { BootstrapInterop.Library.LogMsg(null, null, 0, null, null, 0); } diff --git a/MelonLoader/Utils/MelonUtils.cs b/MelonLoader/Utils/MelonUtils.cs new file mode 100644 index 000000000..09f10de73 --- /dev/null +++ b/MelonLoader/Utils/MelonUtils.cs @@ -0,0 +1,365 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using MonoMod.Cil; +using MonoMod.Utils; +using HarmonyLib; +using MelonLoader.InternalUtils; +using MelonLoader.Lemons.Cryptography; +using MelonLoader.Utils; +using MelonLoader.NativeUtils; + +namespace MelonLoader +{ + public static class MelonUtils + { + private static readonly MethodInfo StackFrameGetMethod = typeof(StackFrame).GetMethod("GetMethod", BindingFlags.Instance | BindingFlags.Public); + private static readonly LemonSHA256 sha256 = new(); + private static readonly LemonSHA512 sha512 = new(); + + public static T Clamp(T value, T min, T max) where T : IComparable { if (value.CompareTo(min) < 0) return min; if (value.CompareTo(max) > 0) return max; return value; } + + public static void SetCurrentDomainBaseDirectory(string dirpath, AppDomain domain = null) + { + if(MelonEnvironment.IsDotnetRuntime) + return; + + if (domain == null) + domain = AppDomain.CurrentDomain; + try + { + ((AppDomainSetup)typeof(AppDomain).GetProperty("SetupInformationNoCopy", BindingFlags.NonPublic | BindingFlags.Instance) + .GetValue(domain, new object[0])) + .SetApplicationBase(dirpath); + } + catch (Exception ex) { MelonLogger.Warning($"AppDomainSetup.ApplicationBase Exception: {ex}"); } + Directory.SetCurrentDirectory(dirpath); + } + + public static MelonBase GetMelonFromStackTrace() + { + StackTrace st = new(3, true); + return GetMelonFromStackTrace(st); + } + + public static MelonBase GetMelonFromStackTrace(StackTrace st, bool allFrames = false) + { + if (st.FrameCount <= 0) + return null; + + if (allFrames) + { + foreach (StackFrame frame in st.GetFrames()) + { + MelonBase ret = CheckForMelonInFrame(frame); + if (ret != null) + return ret; + } + return null; + + } + + MelonBase output = CheckForMelonInFrame(st); + if (output == null) + output = CheckForMelonInFrame(st, 1); + if (output == null) + output = CheckForMelonInFrame(st, 2); + return output; + } + + private static MelonBase CheckForMelonInFrame(StackTrace st, int frame = 0) + { + StackFrame sf = st.GetFrame(frame); + if (sf == null) + return null; + + return CheckForMelonInFrame(sf); + } + + private static MelonBase CheckForMelonInFrame(StackFrame sf) + //The JIT compiler on .NET 6 on Windows 10 (win11 is fine, somehow) really doesn't like us calling StackFrame.GetMethod here + //Rather than trying to work out why, I'm just going to call it via reflection. + => GetMelonFromAssembly(((MethodBase)StackFrameGetMethod.Invoke(sf, new object[0]))?.DeclaringType?.Assembly); + + private static MelonBase GetMelonFromAssembly(Assembly asm) + => asm == null ? null : MelonPlugin.RegisteredMelons.Cast().FirstOrDefault(x => x.MelonAssembly.Assembly == asm) ?? MelonMod.RegisteredMelons.FirstOrDefault(x => x.MelonAssembly.Assembly == asm); + + public static string ComputeSimpleSHA256Hash(string filePath) + { + if (!File.Exists(filePath)) + return null; + + byte[] byteHash = File.ReadAllBytes(filePath); + if (byteHash == null) + return null; + + return sha256.ComputeHash(byteHash).ToString("X2"); + } + + public static string ComputeSimpleSHA512Hash(string filePath) + { + if (!File.Exists(filePath)) + return null; + + byte[] byteHash = File.ReadAllBytes(filePath); + if (byteHash == null) + return null; + + return sha512.ComputeHash(byteHash).ToString("X2"); + } + + public static string ToString(this byte[] data) + { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < data.Length; i++) + result.Append(data[i].ToString()); + return result.ToString(); + } + + public static string ToString(this byte[] data, string format) + { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < data.Length; i++) + result.Append(data[i].ToString(format)); + return result.ToString(); + } + + public static string ToString(this byte[] data, IFormatProvider provider) + { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < data.Length; i++) + result.Append(data[i].ToString(provider)); + return result.ToString(); + } + + public static string ToString(this byte[] data, string format, IFormatProvider provider) + { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < data.Length; i++) + result.Append(data[i].ToString(format, provider)); + return result.ToString(); + } + + public static IntPtr ToAnsiPointer(this string data) + => Marshal.StringToHGlobalAnsi(data); + public static string ToAnsiString(this IntPtr ptr) + => Marshal.PtrToStringAnsi(ptr); + + public static T PullAttributeFromAssembly(Assembly asm, bool inherit = false) where T : Attribute + { + T[] attributetbl = PullAttributesFromAssembly(asm, inherit); + if ((attributetbl == null) || (attributetbl.Length <= 0)) + return null; + return attributetbl[0]; + } + + public static T[] PullAttributesFromAssembly(Assembly asm, bool inherit = false) where T : Attribute + { + Attribute[] att_tbl = Attribute.GetCustomAttributes(asm, inherit); + + if ((att_tbl == null) || (att_tbl.Length <= 0)) + return null; + + Type requestedType = typeof(T); + string requestedAssemblyName = requestedType.Assembly.GetName().Name; + List output = new(); + foreach (Attribute att in att_tbl) + { + Type attType = att.GetType(); + string attAssemblyName = attType.Assembly.GetName().Name; + + if ((attType == requestedType) + || IsTypeEqualToFullName(attType, requestedType.FullName) + || ((attAssemblyName.Equals("MelonLoader") + || attAssemblyName.Equals("MelonLoader.ModHandler")) + && (requestedAssemblyName.Equals("MelonLoader") + || requestedAssemblyName.Equals("MelonLoader.ModHandler")) + && IsTypeEqualToName(attType, requestedType.Name))) + output.Add(att as T); + } + + return output.ToArray(); + } + + public static bool IsTypeEqualToName(Type type1, string type2) + => type1.Name == type2 || (type1 != typeof(object) && IsTypeEqualToName(type1.BaseType, type2)); + + public static bool IsTypeEqualToFullName(Type type1, string type2) + => type1.FullName == type2 || (type1 != typeof(object) && IsTypeEqualToFullName(type1.BaseType, type2)); + + public static string MakePlural(this string str, int amount) + => amount == 1 ? str : $"{str}s"; + + public static IEnumerable GetValidTypes(this Assembly asm) + => GetValidTypes(asm, null); + + public static IEnumerable GetValidTypes(this Assembly asm, LemonFunc predicate) + { + IEnumerable returnval = Enumerable.Empty(); + try { returnval = asm.GetTypes().AsEnumerable(); } + catch (ReflectionTypeLoadException ex) + { + //MelonLogger.Error($"Failed to get all types in assembly {asm.FullName} due to: {ex.Message}", ex); + returnval = ex.Types; + } + //catch (Exception ex) + //{ + //MelonLogger.Error($"Failed to get all types in assembly {asm.FullName} due to: {ex.Message}", ex); + // returnval = null; + //} + return returnval.Where(x => (x != null) && (predicate == null || predicate(x))); + } + + public static Type GetValidType(this Assembly asm, string typeName) + => GetValidType(asm, typeName, null); + + public static Type GetValidType(this Assembly asm, string typeName, LemonFunc predicate) + { + Type x = null; + try { x = asm.GetType(typeName); } + catch //(Exception ex) + { + //MelonLogger.Error($"Failed to get type {typeName} from assembly {asm.FullName} due to: {ex.Message}", ex); + x = null; + } + if ((x != null) && (predicate == null || predicate(x))) + return x; + return null; + } + + public static bool IsNotImplemented(this MethodBase methodBase) + { + if (methodBase == null) + throw new ArgumentNullException(nameof(methodBase)); + + DynamicMethodDefinition method = methodBase.ToNewDynamicMethodDefinition(); + ILContext ilcontext = new(method.Definition); + ILCursor ilcursor = new(ilcontext); + + bool returnval = (ilcursor.Instrs.Count == 2) + && (ilcursor.Instrs[1].OpCode.Code == Mono.Cecil.Cil.Code.Throw); + + ilcontext.Dispose(); + method.Dispose(); + return returnval; + } + + public static bool IsManagedDLL(string path) + { + if (Path.GetExtension(path).ToLower() != ".dll") + return false; + + try + { + AssemblyName.GetAssemblyName(path); + return true; + } + catch (FileLoadException) + { + return true; + } + catch + { + return false; + } + } + + public static HarmonyMethod ToNewHarmonyMethod(this MethodInfo methodInfo) + { + if (methodInfo == null) + throw new ArgumentNullException(nameof(methodInfo)); + return new HarmonyMethod(methodInfo); + } + + public static DynamicMethodDefinition ToNewDynamicMethodDefinition(this MethodBase methodBase) + { + if (methodBase == null) + throw new ArgumentNullException(nameof(methodBase)); + return new DynamicMethodDefinition(methodBase); + } + + private static FieldInfo AppDomainSetup_application_base; + public static void SetApplicationBase(this AppDomainSetup _this, string value) + { + if (AppDomainSetup_application_base == null) + AppDomainSetup_application_base = typeof(AppDomainSetup).GetField("application_base", BindingFlags.NonPublic | BindingFlags.Instance); + if (AppDomainSetup_application_base != null) + AppDomainSetup_application_base.SetValue(_this, value); + } + + private static FieldInfo HashAlgorithm_HashSizeValue; + public static void SetHashSizeValue(this HashAlgorithm _this, int value) + { + if (HashAlgorithm_HashSizeValue == null) + HashAlgorithm_HashSizeValue = typeof(HashAlgorithm).GetField("HashSizeValue", BindingFlags.Public | BindingFlags.Instance); + if (HashAlgorithm_HashSizeValue != null) + HashAlgorithm_HashSizeValue.SetValue(_this, value); + } + + // Modified Version of System.IO.Path.HasExtension from .NET Framework's mscorlib.dll + public static bool ContainsExtension(this string path) + { + if (path != null) + { + path.CheckInvalidPathChars(); + int num = path.Length; + while (--num >= 0) + { + char c = path[num]; + if (c == '.') + return num != path.Length - 1; + if (c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar || c == Path.VolumeSeparatorChar) + break; + } + } + return false; + } + + // Modified Version of System.IO.Path.CheckInvalidPathChars from .NET Framework's mscorlib.dll + private static void CheckInvalidPathChars(this string path) + { + foreach (int num in path) + if (num == 34 || num == 60 || num == 62 || num == 124 || num < 32) + throw new ArgumentException("Argument_InvalidPathChars", nameof(path)); + } + + public static void GetDelegate(this IntPtr ptr, out T output) where T : Delegate + => output = GetDelegate(ptr); + public static T GetDelegate(this IntPtr ptr) where T : Delegate + => GetDelegate(ptr, typeof(T)) as T; + public static Delegate GetDelegate(this IntPtr ptr, Type type) + { + if (ptr == IntPtr.Zero) + throw new ArgumentNullException(nameof(ptr)); + Delegate del = Marshal.GetDelegateForFunctionPointer(ptr, type); + if (del == null) + throw new Exception($"Unable to Get Delegate of Type {type.FullName} for Function Pointer!"); + return del; + } + public static IntPtr GetFunctionPointer(this Delegate del) + => Marshal.GetFunctionPointerForDelegate(del); + + public static void SetConsoleTitle(string title) + { + if (LoaderConfig.Current.Console.DontSetTitle || !BootstrapInterop.Library.IsConsoleOpen()) + return; + + // Using reflection to avoid resolver errors + AccessTools.Property(typeof(Console), "Title")?.SetValue(null, title, null); + } + + public static string GetFileProductName(string filepath) + { + var fileInfo = FileVersionInfo.GetVersionInfo(filepath); + if (fileInfo != null) + return fileInfo.ProductName; + return null; + } + } +} diff --git a/MelonLoader/Utils/MonoLibrary.cs b/MelonLoader/Utils/MonoLibrary.cs deleted file mode 100644 index c7491c873..000000000 --- a/MelonLoader/Utils/MonoLibrary.cs +++ /dev/null @@ -1,50 +0,0 @@ -#if !NET6_0_OR_GREATER - -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using MelonLoader.InternalUtils; - -namespace MelonLoader.Utils -{ - public class MonoLibrary - { - internal static bool Setup() - { - IntPtr NativeMonoPtr = BootstrapInterop.Library.MonoGetRuntimeHandle(); - if (NativeMonoPtr == IntPtr.Zero) - { - MelonLogger.ThrowInternalFailure("[MonoLibrary] Failed to get Mono Library Pointer from Internal Call!"); - return false; - } - - try - { - Instance = NativeMonoPtr.ToNewNativeLibrary().Instance; - } - catch (Exception ex) - { - MelonLogger.ThrowInternalFailure($"[MonoLibrary] Failed to load Mono NativeLibrary!\n{ex}"); - return false; - } - - MelonDebug.Msg("[MonoLibrary] Setup Successful!"); - return true; - } - - public static MonoLibrary Instance { get; private set; } - - [MethodImpl(MethodImplOptions.InternalCall)] - public extern static Assembly CastManagedAssemblyPtr(IntPtr ptr); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr dmono_assembly_open_full(IntPtr filepath, IntPtr status, bool refonly); - public dmono_assembly_open_full mono_assembly_open_full = null; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr dmono_assembly_get_object(IntPtr domain, IntPtr assembly); - public dmono_assembly_get_object mono_assembly_get_object = null; - } -} -#endif \ No newline at end of file diff --git a/MelonLoader/Utils/NativeLibrary.cs b/MelonLoader/Utils/NativeLibrary.cs deleted file mode 100644 index e0ca8f71d..000000000 --- a/MelonLoader/Utils/NativeLibrary.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using System.IO; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace MelonLoader -{ - public class NativeLibrary - { - public readonly IntPtr Ptr; - public NativeLibrary(IntPtr ptr) - { - if (ptr == IntPtr.Zero) - throw new ArgumentNullException(nameof(ptr)); - Ptr = ptr; - } - - public static NativeLibrary Load(string filepath) - => LoadLib(filepath).ToNewNativeLibrary(); - public static NativeLibrary Load(string filepath) - => LoadLib(filepath).ToNewNativeLibrary(); - public static T ReflectiveLoad(string filepath) - => Load(filepath).Instance; - public static IntPtr LoadLib(string filepath) - { - if (string.IsNullOrEmpty(filepath)) - throw new ArgumentNullException(nameof(filepath)); - IntPtr ptr = AgnosticLoadLibrary(filepath); - if (ptr == IntPtr.Zero) - throw new Exception($"Unable to Load Native Library {filepath}!"); - return ptr; - } - - public IntPtr GetExport(string name) - => GetExport(Ptr, name); - public Delegate GetExport(Type type, string name) - => GetExport(name).GetDelegate(type); - public T GetExport(string name) where T : Delegate - => GetExport(name).GetDelegate(); - public void GetExport(string name, out T output) where T : Delegate - => output = GetExport(name); - public static IntPtr GetExport(IntPtr nativeLib, string name) - { - if (nativeLib == IntPtr.Zero) - throw new ArgumentNullException(nameof(nativeLib)); - if (string.IsNullOrEmpty(name)) - throw new ArgumentNullException(nameof(name)); - - IntPtr returnval = AgnosticGetProcAddress(nativeLib, name); - if (returnval == IntPtr.Zero) - throw new Exception($"Unable to Find Native Library Export {name}!"); - - return returnval; - } - - public static IntPtr AgnosticLoadLibrary(string name) - { -#if WINDOWS - return LoadLibrary(name); -#elif LINUX - if (!Path.HasExtension(name)) - name += ".so"; - - return dlopen(name, RTLD_NOW); -#endif - } - - public static IntPtr AgnosticGetProcAddress(IntPtr hModule, string lpProcName) - { -#if WINDOWS - return GetProcAddress(hModule, lpProcName); -#elif LINUX - return dlsym(hModule, lpProcName); -#endif - } - -#if WINDOWS - [DllImport("kernel32", CharSet = CharSet.Unicode)] - private static extern IntPtr LoadLibrary(string lpLibFileName); - [DllImport("kernel32")] - internal static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName); - [DllImport("kernel32")] - internal static extern IntPtr FreeLibrary(IntPtr hModule); -#elif LINUX - [DllImport("libdl.so.2")] - protected static extern IntPtr dlopen(string filename, int flags); - - [DllImport("libdl.so.2")] - protected static extern IntPtr dlsym(IntPtr handle, string symbol); - - const int RTLD_NOW = 2; // for dlopen's flags -#endif - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [return: MarshalAs(UnmanagedType.LPStr)] - internal delegate string StringDelegate(); - } - - public class NativeLibrary : NativeLibrary - { - public readonly T Instance; - - public NativeLibrary(IntPtr ptr) : base(ptr) - { - if (ptr == IntPtr.Zero) - throw new ArgumentNullException(nameof(ptr)); - - Type specifiedType = typeof(T); - if (specifiedType.IsAbstract && specifiedType.IsSealed) - throw new Exception($"Specified Type {specifiedType.FullName} must be Non-Static!"); - - Instance = (T)Activator.CreateInstance(specifiedType); - - foreach (var fieldInfo in specifiedType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) - { - if (fieldInfo.GetCustomAttributes(typeof(CompilerGeneratedAttribute), false).Length != 0) - continue; - - var fieldType = fieldInfo.FieldType; - if (fieldType.GetCustomAttributes(typeof(UnmanagedFunctionPointerAttribute), false).Length == 0) - continue; - - fieldInfo.SetValue(Instance, GetExport(fieldType, fieldInfo.Name)); - } - - foreach (var propertyInfo in specifiedType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) - { - var fieldType = propertyInfo.PropertyType; - if (fieldType.GetCustomAttributes(typeof(UnmanagedFunctionPointerAttribute), false).Length == 0) - continue; - - propertyInfo.SetValue(Instance, GetExport(fieldType, propertyInfo.Name), null); - } - } - } -} diff --git a/MelonLoader/Utils/OsUtils.cs b/MelonLoader/Utils/OsUtils.cs new file mode 100644 index 000000000..a5d22f31d --- /dev/null +++ b/MelonLoader/Utils/OsUtils.cs @@ -0,0 +1,146 @@ +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace MelonLoader.Utils; + +public static class OsUtils +{ + public static PlatformID GetPlatform => Environment.OSVersion.Platform; + public static bool IsUnix => GetPlatform is PlatformID.Unix; + public static bool IsWindows => GetPlatform is PlatformID.Win32NT or PlatformID.Win32S or PlatformID.Win32Windows or PlatformID.WinCE; + public static bool IsMac => GetPlatform is PlatformID.MacOSX; + +#if !NET35 + + public static bool IsAndroid => RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")); + public static bool Is32Bit => !Environment.Is64BitProcess; + public static bool Is64Bit => Environment.Is64BitProcess; + +#else + + public static bool Is32Bit => IntPtr.Size == 4; + public static bool Is64Bit => IntPtr.Size != 4; + public static bool IsAndroid => false; + +#endif + + public static string NativeFileExtension + { + get + { + if (IsUnix || IsAndroid) + return ".so"; + if (IsMac) + return ".dylib"; + return ".dll"; + } + } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.LPStr)] + private delegate string dWineGetVersion(); + private static dWineGetVersion WineGetVersion; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate uint dRtlGetVersion(out OsVersionInfo versionInformation); // return type should be the NtStatus enum + private static dRtlGetVersion RtlGetVersion; + + static OsUtils() + { + if (!IsWindows) + return; + + if (!MelonNativeLibrary.TryLoadLib("ntdll.dll", out IntPtr ntdll)) + return; + + if (MelonNativeLibrary.TryGetExport(ntdll, "RtlGetVersion", out var rtlGetVersion)) + RtlGetVersion = rtlGetVersion.GetDelegate(); + if (MelonNativeLibrary.TryGetExport(ntdll, "wine_get_version", out var wineGetVersion)) + WineGetVersion = wineGetVersion.GetDelegate(); + } + + public static bool IsWineOrProton() + => WineGetVersion != null; + + public static void AddNativeDLLDirectory(string path) + { + if (!IsWindows && !IsUnix) + return; + + path = Path.GetFullPath(path); + if (!Directory.Exists(path)) + return; + + string envName = IsWindows ? "PATH" : "LD_LIBRARY_PATH"; + string envSep = IsWindows ? ";" : ":"; + string envPaths = Environment.GetEnvironmentVariable(envName); + Environment.SetEnvironmentVariable(envName, $"{envPaths}{envSep}{path}"); + } + + public static string GetOSVersion() + { + if (!IsWindows) + return Environment.OSVersion.VersionString; + + if (IsWineOrProton()) + return $"Wine {WineGetVersion()}"; + + if (RtlGetVersion == null) + return "Unknown"; + + RtlGetVersion(out OsVersionInfo versionInformation); + var minor = versionInformation.MinorVersion; + var build = versionInformation.BuildNumber; + + string versionString = ""; + switch (versionInformation.MajorVersion) + { + case 4: + versionString = "Windows 95/98/Me/NT"; + break; + case 5: + if (minor == 0) + versionString = "Windows 2000"; + if (minor == 1) + versionString = "Windows XP"; + if (minor == 2) + versionString = "Windows 2003"; + break; + case 6: + if (minor == 0) + versionString = "Windows Vista"; + if (minor == 1) + versionString = "Windows 7"; + if (minor == 2) + versionString = "Windows 8"; + if (minor == 3) + versionString = "Windows 8.1"; + break; + case 10: + if (build >= 22000) + versionString = "Windows 11"; + else + versionString = "Windows 10"; + break; + default: + versionString = "Unknown"; + break; + } + + return $"{versionString}"; + } + + [StructLayout(LayoutKind.Sequential)] + private struct OsVersionInfo + { + private readonly uint OsVersionInfoSize; + internal readonly uint MajorVersion; + internal readonly uint MinorVersion; + internal readonly uint BuildNumber; + private readonly uint PlatformId; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + internal readonly string CSDVersion; + } +} \ No newline at end of file diff --git a/MelonLoader/Utils/SteamManifestReader.cs b/MelonLoader/Utils/SteamManifestReader.cs index d35e0a2ac..a75847618 100644 --- a/MelonLoader/Utils/SteamManifestReader.cs +++ b/MelonLoader/Utils/SteamManifestReader.cs @@ -9,8 +9,8 @@ public static class SteamManifestReader { public static string GetInstallPathFromAppId(string appid) { - if (!MelonUtils.IsWindows - || MelonUtils.IsUnderWineOrSteamProton()) + if (!OsUtils.IsWindows + || OsUtils.IsWineOrProton()) return null; if (string.IsNullOrEmpty(appid)) @@ -39,8 +39,8 @@ public static string GetInstallPathFromAppId(string appid) private static string ReadAppManifestInstallDir(string appmanifestpath) { - if (!MelonUtils.IsWindows - || MelonUtils.IsUnderWineOrSteamProton()) + if (!OsUtils.IsWindows + || OsUtils.IsWineOrProton()) return null; if (!File.Exists(appmanifestpath)) @@ -65,8 +65,8 @@ private static string ReadAppManifestInstallDir(string appmanifestpath) private static string ReadLibraryFolders(string appmanifestfilename, ref string steamappspath) { - if (!MelonUtils.IsWindows - || MelonUtils.IsUnderWineOrSteamProton()) + if (!OsUtils.IsWindows + || OsUtils.IsWineOrProton()) return null; string libraryfoldersfilepath = Path.Combine(steamappspath, "libraryfolders.vdf"); @@ -98,8 +98,8 @@ private static string ReadLibraryFolders(string appmanifestfilename, ref string private static string GetSteamInstallPath() { - if (!MelonUtils.IsWindows - || MelonUtils.IsUnderWineOrSteamProton()) + if (!OsUtils.IsWindows + || OsUtils.IsWineOrProton()) return null; RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Valve\\Steam"); diff --git a/README.md b/README.md index 4c2797a13..fafaeaccb 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,12 @@ MelonLoader uses a proxy DLL to trick the game into loading itself on startup. T | dinput8.dll | | dsound.dll | | d3d8.dll | +| d3d9.dll | +| d3d10.dll | +| d3d11.dll | +| d3d12.dll | +| ddraw.dll | +| msacm32.dll | --- @@ -246,13 +252,14 @@ MelonLoader uses a proxy DLL to trick the game into loading itself on startup. T MelonLoader is licensed under the Apache License, Version 2.0. See [LICENSE](https://github.com/LavaGang/MelonLoader/blob/master/LICENSE.md) for the full License. Third-party Libraries used as Source Code and/or bundled in Binary Form: -- [Dobby](https://github.com/jmpews/Dobby) is licensed under the Apache License, Version 2.0. See [LICENSE](https://github.com/jmpews/Dobby/blob/master/LICENSE) for the full License. +- [.NET Runtime](https://github.com/dotnet/runtime) is licensed under the MIT License. See [LICENSE](https://github.com/dotnet/runtime/blob/main/LICENSE.TXT) for the full License. +- [Dobby](https://github.com/LavaGang/Dobby) is licensed under the Apache License, Version 2.0. See [LICENSE](https://github.com/LavaGang/Dobby/LICENSE) for the full License. - [Mono](https://github.com/Unity-Technologies/mono) is licensed under multiple licenses. See [LICENSE](https://github.com/Unity-Technologies/mono/blob/unity-master/LICENSE) for full details. - [HarmonyX](https://github.com/BepInEx/HarmonyX) is licensed under the MIT License. See [LICENSE](https://github.com/BepInEx/HarmonyX/blob/master/LICENSE) for the full License. - [MonoMod](https://github.com/MonoMod/MonoMod) is licensed under the MIT License. See [LICENSE](https://github.com/MonoMod/MonoMod/blob/master/LICENSE) for the full License. - [Mono.Cecil](https://github.com/jbevain/cecil) is licensed under the MIT License. See [LICENSE](https://github.com/jbevain/cecil/blob/master/LICENSE.txt) for the full License. +- [Iced](https://github.com/icedland/iced) is licensed under the MIT License. See [LICENSE](https://github.com/icedland/iced/blob/master/LICENSE.txt) for the full License. - [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) is licensed under the MIT License. See [LICENSE](https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md) for the full License. -- [TinyJSON](https://github.com/pbhogan/TinyJSON) is licensed under the MIT License. See [LICENSE](https://github.com/LavaGang/MelonLoader/blob/master/MelonLoader/TinyJSON/LICENSE.md) for the full License. - [Tomlet](https://github.com/SamboyCoding/Tomlet) is licensed under the MIT License. See [LICENSE](https://github.com/SamboyCoding/Tomlet/blob/master/LICENSE) for the full License. - [AsmResolver](https://github.com/Washi1337/AsmResolver) is licensed under the MIT License. See [LICENSE](https://github.com/Washi1337/AsmResolver/blob/master/LICENSE.md) for the full License. - [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) is licensed under the MIT License. See [LICENSE](https://github.com/LavaGang/MelonLoader/blob/master/MelonLoader/SharpZipLib/LICENSE.txt) for the full License. @@ -262,19 +269,19 @@ Third-party Libraries used as Source Code and/or bundled in Binary Form: - [mgGif](https://github.com/gwaredd/mgGif) is licensed under the MIT License. See [LICENSE](https://github.com/gwaredd/mgGif/blob/main/LICENSE) for the full License. - [AssetsTools.NET](https://github.com/nesrak1/AssetsTools.NET) is licensed under the MIT License. See [LICENSE](https://github.com/nesrak1/AssetsTools.NET/blob/master/LICENSE) for the full License. - [AssetRipper.VersionUtilities](https://github.com/AssetRipper/VersionUtilities) is licensed under the MIT License. See [LICENSE](https://github.com/AssetRipper/VersionUtilities/blob/master/License.md) for the full License. -- Steam Library, VDF, and ACF Parsing from [SteamFinder.cs](https://github.com/Umbranoxio/BeatSaberModInstaller/blob/master/BeatSaberModManager/Dependencies/SteamFinder.cs) by [Umbranoxio](https://github.com/Umbranoxio) and [Dalet](https://github.com/Dalet). - [bHapticsLib](https://github.com/HerpDerpinstine/bHapticsLib) is licensed under the MIT License. See [LICENSE](https://github.com/HerpDerpinstine/bHapticsLib/blob/master/LICENSE.md) for the full License. - [IndexRange](https://github.com/bgrainger/IndexRange) is licensed under the MIT License. See [LICENSE](https://github.com/bgrainger/IndexRange/blob/master/LICENSE) for the full License. - [ValueTupleBridge](https://github.com/OrangeCube/MinimumAsyncBridge) is licensed under the MIT License. See [LICENSE](https://github.com/OrangeCube/MinimumAsyncBridge/blob/master/LICENSE) for the full License. - [WebSocketDotNet](https://github.com/SamboyCoding/WebSocketDotNet) is licensed under the MIT License. See [LICENSE](https://github.com/SamboyCoding/WebSocketDotNet/blob/master/LICENSE) for the full License. - [Pastel](https://github.com/silkfire/Pastel) is licensed under the MIT License. See [LICENSE](https://github.com/silkfire/Pastel/blob/master/LICENSE) for the full License. - [Il2CppInterop](https://github.com/BepInEx/Il2CppInterop) is licensed under the LGPLv3 License. See [LICENSE](https://github.com/BepInEx/Il2CppInterop/blob/master/LICENSE) for the full License. +- [GodotPCKExplorer](https://github.com/DmitriySalnikov/GodotPCKExplorer) is licensed under the MIT License. See [LICENSE](https://github.com/DmitriySalnikov/GodotPCKExplorer/blob/master/LICENSE) for the full License. +- Steam Library, VDF, and ACF Parsing from [SteamFinder.cs](https://github.com/Umbranoxio/BeatSaberModInstaller/blob/master/BeatSaberModManager/Dependencies/SteamFinder.cs) by [Umbranoxio](https://github.com/Umbranoxio) and [Dalet](https://github.com/Dalet). External Libraries and Tools that are downloaded and used at Runtime: - [Cpp2IL](https://github.com/SamboyCoding/Cpp2IL) is licensed under the MIT License. See [LICENSE](https://github.com/SamboyCoding/Cpp2IL/blob/master/LICENSE) for the full License. - Unity Runtime Libraries from [MelonLoader.UnityDependencies](https://github.com/LavaGang/MelonLoader.UnityDependencies) are part of Unity Software. Their usage is subject to [Unity Terms of Service](https://unity3d.com/legal/terms-of-service), including [Unity Software Additional Terms](https://unity3d.com/legal/terms-of-service/software). -- [.NET Runtime](https://github.com/dotnet/runtime) is licensed under the MIT License. See [LICENSE](https://github.com/dotnet/runtime/blob/main/LICENSE.TXT) for the full License. See [MelonLoader Wiki](https://melonwiki.xyz/#/credits) for the full Credits. diff --git a/UnityUtilities/UnityEngine.Il2CppAssetBundleManager/UnityEngine.Il2CppAssetBundleManager.csproj b/UnityUtilities/UnityEngine.Il2CppAssetBundleManager/UnityEngine.Il2CppAssetBundleManager.csproj deleted file mode 100644 index d48815e12..000000000 --- a/UnityUtilities/UnityEngine.Il2CppAssetBundleManager/UnityEngine.Il2CppAssetBundleManager.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - net6 - UnityEngine - $(MLOutDir)/MelonLoader - true - - - - - - - - \ No newline at end of file diff --git a/UnityUtilities/UnityEngine.Il2CppImageConversionManager/UnityEngine.Il2CppImageConversionManager.csproj b/UnityUtilities/UnityEngine.Il2CppImageConversionManager/UnityEngine.Il2CppImageConversionManager.csproj deleted file mode 100644 index d48815e12..000000000 --- a/UnityUtilities/UnityEngine.Il2CppImageConversionManager/UnityEngine.Il2CppImageConversionManager.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - net6 - UnityEngine - $(MLOutDir)/MelonLoader - true - - - - - - - - \ No newline at end of file