├── .editorconfig ├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.yaml │ ├── config.yml │ └── enhancement.yaml └── dependabot.yml ├── .gitignore ├── BaseLibs └── NetStandardPatches │ ├── System.Configuration.dll │ ├── System.Core.dll │ ├── System.Xml.dll │ └── System.dll ├── CHANGELOG.md ├── Dependencies ├── CompatibilityLayers │ ├── Demeo │ │ ├── Demeo.csproj │ │ ├── Demeo_LobbyRequirement.cs │ │ └── Module.cs │ ├── IPA │ │ ├── IPA.csproj │ │ ├── IPA │ │ │ ├── IEnhancedPlugin.cs │ │ │ ├── IPlugin.cs │ │ │ ├── ModPrefs.cs │ │ │ └── PluginManager.cs │ │ ├── IPAPluginWrapper.cs │ │ └── Module.cs │ ├── Muse_Dash_Mono │ │ ├── Module.cs │ │ ├── MuseDashModLoader │ │ │ ├── IMod.cs │ │ │ ├── ModLoader.cs │ │ │ └── ModLogger.cs │ │ ├── MuseDashModWrapper.cs │ │ └── Muse_Dash_Mono.csproj │ └── Stress_Level_Zero_Il2Cpp │ │ ├── Module.cs │ │ └── Stress_Level_Zero_Il2Cpp.csproj ├── Il2CppAssemblyGenerator │ ├── Config.cs │ ├── Core.cs │ ├── Extensions.cs │ ├── FileHandler.cs │ ├── Il2CppAssemblyGenerator.csproj │ ├── Packages │ │ ├── Cpp2IL.cs │ │ ├── Cpp2IL_NetFramework.cs │ │ ├── Cpp2IL_StrippedCodeRegSupport.cs │ │ ├── DeobfuscationMap.cs │ │ ├── DeobfuscationRegex.cs │ │ ├── Il2CppInterop.cs │ │ ├── Models │ │ │ ├── ExecutablePackage.cs │ │ │ └── PackageBase.cs │ │ └── UnityDependencies.cs │ └── RemoteAPI.cs ├── MelonStartScreen │ ├── Core.cs │ ├── MelonStartScreen.csproj │ ├── ModLoadStep.cs │ ├── NativeUtils │ │ ├── NativeFieldValueAttribute.cs │ │ ├── NativeSignatureAttribute.cs │ │ ├── NativeSignatureFlags.cs │ │ └── NativeSignatureResolver.cs │ ├── ProgressParser.cs │ ├── Resources │ │ ├── Loading_Halloween.dat │ │ ├── Loading_Lemon.dat │ │ ├── Loading_Melon.dat │ │ ├── Logo_Halloween.dat │ │ ├── Logo_Lemon.dat │ │ └── Logo_Melon.dat │ ├── ScreenRenderer.cs │ ├── TextMeshGenerator.cs │ ├── UI │ │ ├── Objects │ │ │ ├── UI_AnimatedImage.cs │ │ │ ├── UI_Background.cs │ │ │ ├── UI_Image.cs │ │ │ ├── UI_Object.cs │ │ │ ├── UI_ProgressBar.cs │ │ │ └── UI_Text.cs │ │ ├── StartScreenResources.cs │ │ ├── Themes │ │ │ ├── UI_Theme_Default.cs │ │ │ ├── UI_Theme_Lemon.cs │ │ │ └── UI_Theme_Pumpkin.cs │ │ ├── UI_Anchor.cs │ │ ├── UI_Style.cs │ │ ├── UI_Theme.cs │ │ └── UI_Utils.cs │ ├── UnhollowerMini │ │ ├── Il2CppException.cs │ │ ├── Il2CppSystem │ │ │ ├── Byte.cs │ │ │ ├── Int32.cs │ │ │ └── Type.cs │ │ ├── InternalClassPointerStore.cs │ │ ├── InternalObjectBase.cs │ │ ├── InternalType.cs │ │ ├── ObjectCollectedException.cs │ │ └── UnityInternals.cs │ ├── UnityEngine │ │ ├── CoreModule │ │ │ ├── Color.cs │ │ │ ├── Color32.cs │ │ │ ├── FilterMode.cs │ │ │ ├── GL.cs │ │ │ ├── Graphics.cs │ │ │ ├── HideFlags.cs │ │ │ ├── ImageConversion.cs │ │ │ ├── Internal_DrawTextureArguments.cs │ │ │ ├── Material.cs │ │ │ ├── Mesh.cs │ │ │ ├── Quaternion.cs │ │ │ ├── Rect.cs │ │ │ ├── Resources.cs │ │ │ ├── Screen.cs │ │ │ ├── SystemInfo.cs │ │ │ ├── Texture.cs │ │ │ ├── Texture2D.cs │ │ │ ├── UnityDebug.cs │ │ │ ├── UnityObject.cs │ │ │ ├── Vector2.cs │ │ │ ├── Vector3.cs │ │ │ ├── Vector4.cs │ │ │ ├── VertexAttribute.cs │ │ │ └── VerticalWrapMode.cs │ │ └── TextRenderingModule │ │ │ ├── Font.cs │ │ │ ├── FontStyle.cs │ │ │ ├── TextAnchor.cs │ │ │ ├── TextGenerationSettings.cs │ │ │ ├── TextGenerator.cs │ │ │ └── UIVertex.cs │ ├── UnityPlayer │ │ └── GfxDevice.cs │ ├── Windows │ │ ├── DropFile.cs │ │ ├── Msg.cs │ │ ├── Point.cs │ │ ├── User32.cs │ │ └── WindowMessage.cs │ └── mgGif │ │ ├── Decoder.cs │ │ ├── Image.cs │ │ └── LICENSE.txt └── SupportModules │ ├── Component.cs │ ├── ComponentSiblingFix.cs │ ├── Il2Cpp │ ├── Il2Cpp.csproj │ ├── InteropInterface.cs │ ├── Libs │ │ ├── Il2CppSystem.dll │ │ ├── Il2Cppmscorlib.dll │ │ └── UnityEngine.CoreModule.dll │ ├── Main.cs │ └── MonoEnumeratorWrapper.cs │ ├── Mono │ ├── Libs │ │ └── UnityEngine.dll │ ├── Main.cs │ └── Mono.csproj │ ├── SceneHandler.cs │ ├── SupportModule_To.cs │ └── UnityMappers.cs ├── Directory.Build.props ├── LICENSE.md ├── MelonLoader.Bootstrap ├── BionicNativeAot.targets ├── Core.cs ├── Deps │ ├── linux-bionic-arm64 │ │ ├── libdobby.a │ │ └── libplthook.a │ ├── linux-x64 │ │ ├── libdobby.a │ │ └── libplthook.a │ ├── osx-x64 │ │ ├── libdobby.a │ │ └── libplthook.a │ ├── win-x64 │ │ ├── dobby.lib │ │ └── plthook.lib │ └── win-x86 │ │ ├── dobby.lib │ │ └── plthook.lib ├── Exports.cs ├── Exports.def ├── InternalLogger.cs ├── LibcNative.cs ├── Logging │ ├── ColorRGB.cs │ ├── ConsoleHandler.cs │ ├── LinuxPlayerLogsMirroring.cs │ ├── MelonLogger.cs │ ├── PastelExtensions.cs │ └── WindowsPlayerLogsMirroring.cs ├── MelonDebug.cs ├── MelonLoader.Bootstrap.csproj ├── OSXEntry │ └── osxentry.cpp ├── PltHook.cs ├── Proxy │ ├── Android │ │ ├── AndroidBootstrap.cs │ │ ├── AndroidProxy.cs │ │ └── StdRedirect.cs │ ├── Exports │ │ ├── D3D10Exports.cs │ │ ├── D3D11Exports.cs │ │ ├── D3D12Exports.cs │ │ ├── D3D8Exports.cs │ │ ├── D3D9Exports.cs │ │ ├── DDrawExports.cs │ │ ├── DInput8Exports.cs │ │ ├── DInputExports.cs │ │ ├── DSoundExports.cs │ │ ├── MSACM32Exports.cs │ │ ├── SharedExports.cs │ │ ├── VersionExports.cs │ │ ├── WinHTTPExports.cs │ │ └── WinMMExports.cs │ ├── ProxyMap.cs │ └── ProxyResolver.cs ├── RuntimeHandlers │ ├── Il2Cpp │ │ ├── ClrMonoLib.cs │ │ ├── Dotnet.cs │ │ ├── DotnetInstaller.cs │ │ ├── Il2CppHandler.cs │ │ └── Il2CppLib.cs │ └── Mono │ │ ├── MonoHandler.cs │ │ └── MonoLib.cs ├── SharedDelegates.cs ├── TrimmerRoots.xml ├── Utils │ ├── ArgParser.cs │ ├── Dobby.cs │ ├── NativeFunc.cs │ └── WineUtils.cs ├── WindowsNative.cs ├── androidexports.def ├── linuxexports.def └── osxexports.def ├── MelonLoader.NativeHost ├── MelonLoader.NativeHost.csproj └── NativeEntryPoint.cs ├── MelonLoader.sln ├── MelonLoader ├── Assertions │ ├── LemonAssert.cs │ ├── LemonAssertException.cs │ └── LemonAssertMapping.cs ├── Attributes │ ├── HarmonyDontPatchAllAttribute.cs │ ├── MelonAdditionalCreditsAttribute.cs │ ├── MelonAdditionalDependenciesAttribute.cs │ ├── MelonAuthorColorAttribute.cs │ ├── MelonColorAttribute.cs │ ├── MelonGameAttribute.cs │ ├── MelonGameVersionAttribute.cs │ ├── MelonIDAttribute.cs │ ├── MelonIncompatibleAssembliesAttribute.cs │ ├── MelonInfoAttribute.cs │ ├── MelonOptionalDependenciesAttribute.cs │ ├── MelonPlatformAttribute.cs │ ├── MelonPlatformDomainAttribute.cs │ ├── MelonPriorityAttribute.cs │ ├── MelonProcessAttribute.cs │ ├── PatchShield.cs │ ├── RegisterTypeInIl2Cpp.cs │ ├── RegisterTypeInIl2CppWithInterfaces.cs │ ├── VerifyLoaderBuildAttribute.cs │ └── VerifyLoaderVersionAttribute.cs ├── BackwardsCompatibility │ ├── ForwardingAttributes │ │ ├── 0Harmony.cs │ │ ├── Mono.Cecil.Mdb.cs │ │ ├── Mono.Cecil.Pdb.cs │ │ ├── Mono.Cecil.Rocks.cs │ │ ├── Mono.Cecil.cs │ │ ├── MonoMod.RuntimeDetour.cs │ │ ├── MonoMod.Utils.cs │ │ └── Tomlet.cs │ ├── Harmony │ │ ├── Attributes.cs │ │ ├── Extras │ │ │ ├── DelegateTypeFactory.cs │ │ │ ├── FastAccess.cs │ │ │ └── MethodInvoker.cs │ │ ├── HarmonyInstance.cs │ │ ├── HarmonyMethod.cs │ │ ├── Patch.cs │ │ ├── Priority.cs │ │ └── Tools │ │ │ ├── AccessTools.cs │ │ │ ├── Extensions.cs │ │ │ └── SymbolExtensions.cs │ ├── ICSharpCode │ │ └── SharpZipLib │ │ │ ├── BZip2 │ │ │ ├── BZip2.cs │ │ │ ├── BZip2Constants.cs │ │ │ ├── BZip2Exception.cs │ │ │ ├── BZip2InputStream.cs │ │ │ └── BZip2OutputStream.cs │ │ │ ├── Checksum │ │ │ ├── Adler32.cs │ │ │ ├── BZip2Crc.cs │ │ │ ├── Crc32.cs │ │ │ ├── CrcUtilities.cs │ │ │ └── IChecksum.cs │ │ │ ├── Core │ │ │ ├── EmptyRefs.cs │ │ │ ├── Exceptions │ │ │ │ ├── SharpZipBaseException.cs │ │ │ │ ├── StreamDecodingException.cs │ │ │ │ ├── StreamUnsupportedException.cs │ │ │ │ ├── UnexpectedEndOfStreamException.cs │ │ │ │ └── ValueOutOfRangeException.cs │ │ │ ├── FileSystemScanner.cs │ │ │ ├── INameTransform.cs │ │ │ ├── IScanFilter.cs │ │ │ ├── InvalidNameException.cs │ │ │ ├── NameFilter.cs │ │ │ ├── PathFilter.cs │ │ │ ├── PathUtils.cs │ │ │ └── StreamUtils.cs │ │ │ ├── Encryption │ │ │ ├── PkzipClassic.cs │ │ │ ├── ZipAESStream.cs │ │ │ └── ZipAESTransform.cs │ │ │ ├── GZip │ │ │ ├── GZIPConstants.cs │ │ │ ├── GZip.cs │ │ │ ├── GZipException.cs │ │ │ ├── GzipInputStream.cs │ │ │ └── GzipOutputStream.cs │ │ │ ├── LICENSE.txt │ │ │ ├── Lzw │ │ │ ├── LzwConstants.cs │ │ │ ├── LzwException.cs │ │ │ └── LzwInputStream.cs │ │ │ ├── README.md │ │ │ ├── Tar │ │ │ ├── InvalidHeaderException.cs │ │ │ ├── TarArchive.cs │ │ │ ├── TarBuffer.cs │ │ │ ├── TarEntry.cs │ │ │ ├── TarException.cs │ │ │ ├── TarExtendedHeaderReader.cs │ │ │ ├── TarHeader.cs │ │ │ ├── TarInputStream.cs │ │ │ └── TarOutputStream.cs │ │ │ └── Zip │ │ │ ├── Compression │ │ │ ├── Deflater.cs │ │ │ ├── DeflaterConstants.cs │ │ │ ├── DeflaterEngine.cs │ │ │ ├── DeflaterHuffman.cs │ │ │ ├── DeflaterPending.cs │ │ │ ├── Inflater.cs │ │ │ ├── InflaterDynHeader.cs │ │ │ ├── InflaterHuffmanTree.cs │ │ │ ├── PendingBuffer.cs │ │ │ └── Streams │ │ │ │ ├── DeflaterOutputStream.cs │ │ │ │ ├── InflaterInputStream.cs │ │ │ │ ├── OutputWindow.cs │ │ │ │ └── StreamManipulator.cs │ │ │ ├── FastZip.cs │ │ │ ├── IEntryFactory.cs │ │ │ ├── WindowsNameTransform.cs │ │ │ ├── ZipConstants.cs │ │ │ ├── ZipEncryptionMethod.cs │ │ │ ├── ZipEntry.cs │ │ │ ├── ZipEntryExtensions.cs │ │ │ ├── ZipEntryFactory.cs │ │ │ ├── ZipException.cs │ │ │ ├── ZipExtraData.cs │ │ │ ├── ZipFile.cs │ │ │ ├── ZipHelperStream.cs │ │ │ ├── ZipInputStream.cs │ │ │ ├── ZipNameTransform.cs │ │ │ ├── ZipOutputStream.cs │ │ │ └── ZipStrings.cs │ ├── Melon │ │ ├── AssemblyResolveInfo.cs │ │ ├── HarmonyShield.cs │ │ ├── Imports.cs │ │ ├── Main.cs │ │ ├── MelonConsole.cs │ │ ├── MelonLoaderBase.cs │ │ ├── MelonModGameAttribute.cs │ │ ├── MelonModInfoAttribute.cs │ │ ├── MelonModLogger.cs │ │ ├── MelonPluginGameAttribute.cs │ │ ├── MelonPluginInfoAttribute.cs │ │ ├── MelonPrefs.cs │ │ ├── ModPrefs.cs │ │ ├── MonoLibrary.cs │ │ ├── MonoResolveManager.cs │ │ └── bHaptics.cs │ └── TinyJSON │ │ ├── Decoder.cs │ │ ├── EncodeOptions.cs │ │ ├── Encoder.cs │ │ ├── Extensions.cs │ │ ├── JSON.cs │ │ ├── LICENSE.md │ │ ├── README.md │ │ └── Types │ │ ├── ProxyArray.cs │ │ ├── ProxyBoolean.cs │ │ ├── ProxyNumber.cs │ │ ├── ProxyObject.cs │ │ ├── ProxyString.cs │ │ └── Variant.cs ├── CompatibilityLayers │ └── MelonCompatibilityLayer.cs ├── Core.cs ├── CoreClrUtils │ ├── CoreClrDelegateFixer.cs │ ├── MethodBaseHelper.cs │ └── NativeStackWalk.cs ├── Fixes │ ├── AsmResolverFix.cs │ ├── DetourContextDisposeFix.cs │ ├── DotnetAssemblyLoadContextFix.cs │ ├── DotnetModHandlerRedirectionFix.cs │ ├── ForcedCultureInfo.cs │ ├── Il2CppICallInjector.cs │ ├── Il2CppInteropFixes.cs │ ├── InstancePatchFix.cs │ ├── NativeLibraryFix.cs │ ├── Net20Compatibility.cs │ ├── ProcessFix.cs │ ├── ProcessModulesFix.cs │ ├── ServerCertificateValidation.cs │ ├── UnhandledException.cs │ └── XTermFix.cs ├── InternalUtils │ ├── BootstrapInterop.cs │ ├── BootstrapLibrary.cs │ ├── DependencyGraph.cs │ ├── HarmonyLogger.cs │ ├── Il2CppAssemblyGenerator.cs │ ├── MelonStartScreen.cs │ ├── UnityInformationHandler.cs │ └── UnityMagicMethods.cs ├── JNI │ ├── JArray.cs │ ├── JClass.cs │ ├── JFieldID.cs │ ├── JMethodID.cs │ ├── JNI.cs │ ├── JNIEnv.cs │ ├── JNIResultException.cs │ ├── JObject.cs │ ├── JObjectArray.cs │ ├── JString.cs │ ├── JThrowable.cs │ ├── JThrowableException.cs │ ├── JValue.cs │ ├── JavaVM.cs │ ├── ReferenceType.cs │ ├── ReleaseMode.cs │ ├── Result.cs │ ├── TypeSignature.cs │ └── Version.cs ├── Lemons │ ├── Cryptography │ │ ├── LemonMD5.cs │ │ ├── LemonSHA256.cs │ │ └── LemonSHA512.cs │ ├── LemonAction.cs │ ├── LemonArraySegment.cs │ ├── LemonEnumerator.cs │ ├── LemonFunc.cs │ └── LemonTuple.cs ├── LoaderConfig.cs ├── MelonEvents.cs ├── MelonLaunchOptions.cs ├── MelonLoader.csproj ├── MelonUtils.cs ├── Melons │ ├── Events │ │ ├── MelonAction.cs │ │ └── MelonEvent.cs │ ├── Melon.cs │ ├── MelonAssembly.cs │ ├── MelonBase.cs │ ├── MelonFolderHandler.cs │ ├── MelonHandler.cs │ ├── MelonMod.cs │ ├── MelonPlugin.cs │ ├── MelonPreprocessor.cs │ ├── MelonTypeBase.cs │ ├── ResolvedMelons.cs │ └── RottenMelon.cs ├── Modules │ └── MelonModule.cs ├── NativeUtils │ ├── CppUtils.cs │ ├── NativeHooks.cs │ └── PEParser │ │ ├── ImageDataDirectory.cs │ │ ├── ImageExportDirectory.cs │ │ ├── ImageFileHeader.cs │ │ ├── ImageNtHeaders.cs │ │ ├── ImageResourceDirectory.cs │ │ ├── ImageSectionHeader.cs │ │ ├── ImageThunkData32.cs │ │ ├── ImageThunkData64.cs │ │ ├── OptionalFileHeader32.cs │ │ ├── OptionalFileHeader64.cs │ │ └── PEUtils.cs ├── Pastel │ └── Pastel.cs ├── Preferences │ ├── IO │ │ ├── File.cs │ │ └── Watcher.cs │ ├── MelonPreferences.cs │ ├── MelonPreferences_Category.cs │ ├── MelonPreferences_Entry.cs │ ├── MelonPreferences_ReflectiveCategory.cs │ ├── TomlMapper.cs │ └── ValueValidator.cs ├── Properties │ └── BuildInfo.cs ├── Resolver │ ├── AssemblyManager.cs │ ├── AssemblyResolveInfo.cs │ ├── MelonAssemblyResolver.cs │ └── SearchDirectoryManager.cs ├── Resources │ └── classdata.tpk ├── Semver │ ├── IntExtensions.cs │ ├── License.txt │ ├── README.md │ └── SemVersion.cs ├── SupportModule │ ├── ISupportModule_From.cs │ ├── ISupportModule_To.cs │ ├── SupportModule.cs │ └── SupportModule_From.cs └── Utils │ ├── APKAssetManager.cs │ ├── AssemblyVerifier.cs │ ├── Assertion.cs │ ├── EnumExtensions.cs │ ├── IniFile.cs │ ├── InteropSupport.cs │ ├── LoggerUtils.cs │ ├── MelonCoroutines.cs │ ├── MelonDebug.cs │ ├── MelonEnvironment.cs │ ├── MelonLogger.cs │ ├── MonoLibrary.cs │ ├── NativeLibrary.cs │ └── SteamManifestReader.cs ├── NOTICE.txt ├── NuGet.config ├── PortablePdbToMdb ├── PortablePdbToMdb.cs └── PortablePdbToMdb.csproj ├── README.md ├── UnityUtilities ├── UnityEngine.Il2CppAssetBundleManager │ ├── Il2CppAssetBundle.cs │ ├── Il2CppAssetBundleManager.cs │ ├── Il2CppAssetBundleRequest.cs │ └── UnityEngine.Il2CppAssetBundleManager.csproj └── UnityEngine.Il2CppImageConversionManager │ ├── Il2CppImageConversionManager.cs │ └── UnityEngine.Il2CppImageConversionManager.csproj ├── compile_bootstrap_android.bat └── compile_bootstrap_android_debug.bat /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # CS1591: Missing XML comment for publicly visible type or member 4 | dotnet_diagnostic.CS1591.severity = none 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 2 | patreon: # Replace with a single Patreon username 3 | open_collective: # Replace with a single Open Collective username 4 | ko_fi: # Replace with a single Ko-fi username 5 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 6 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 7 | liberapay: # Replace with a single Liberapay username 8 | issuehunt: # Replace with a single IssueHunt username 9 | otechie: # Replace with a single Otechie username 10 | custom: ['https://melonwiki.xyz/#/credits'] 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement.yaml: -------------------------------------------------------------------------------- 1 | name: New feature or enhancement 2 | description: Suggest a feature or enhancement for MelonLoader 3 | title: "[Enhancement]: " 4 | labels: [enhancement] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Please provide as much detail as possible for your suggestion. 10 | - type: textarea 11 | id: description 12 | attributes: 13 | label: Describe the new feature or enhancement 14 | description: | 15 | Please go into as much detail as necessary in describing the new feature or enhancement. 16 | validations: 17 | required: true 18 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "nuget" # See documentation for possible values 9 | target-branch: "alpha-development" 10 | directory: "/" # Location of package manifests 11 | schedule: 12 | interval: "daily" 13 | 14 | - package-ecosystem: "cargo" 15 | directory: "/" 16 | schedule: 17 | interval: "monthly" 18 | ignore: 19 | - dependency-name: "*" 20 | 21 | 22 | - package-ecosystem: "github-actions" 23 | target-branch: "alpha-development" 24 | # Workflow files stored in the 25 | # default location of `.github/workflows` 26 | directory: "/" 27 | schedule: 28 | interval: "daily" 29 | -------------------------------------------------------------------------------- /BaseLibs/NetStandardPatches/System.Configuration.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/BaseLibs/NetStandardPatches/System.Configuration.dll -------------------------------------------------------------------------------- /BaseLibs/NetStandardPatches/System.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/BaseLibs/NetStandardPatches/System.Core.dll -------------------------------------------------------------------------------- /BaseLibs/NetStandardPatches/System.Xml.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/BaseLibs/NetStandardPatches/System.Xml.dll -------------------------------------------------------------------------------- /BaseLibs/NetStandardPatches/System.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/BaseLibs/NetStandardPatches/System.dll -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/Demeo/Demeo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | MelonLoader.CompatibilityLayers 4 | net472 5 | true 6 | $(MLOutDir)/MelonLoader/Dependencies/CompatibilityLayers 7 | true 8 | portable 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/Demeo/Demeo_LobbyRequirement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly)] 6 | public class Demeo_LobbyRequirement : Attribute 7 | { 8 | public Demeo_LobbyRequirement() { } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/IPA/IPA.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | MelonLoader.CompatibilityLayers 4 | net35 5 | true 6 | $(MLOutDir)/MelonLoader/Dependencies/CompatibilityLayers 7 | true 8 | portable 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/IPA/IPA/IEnhancedPlugin.cs: -------------------------------------------------------------------------------- 1 | namespace IllusionPlugin 2 | { 3 | public interface IEnhancedPlugin : IPlugin 4 | { 5 | string[] Filter { get; } 6 | void OnLateUpdate(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/IPA/IPA/IPlugin.cs: -------------------------------------------------------------------------------- 1 | namespace IllusionPlugin 2 | { 3 | public interface IPlugin 4 | { 5 | string Name { get; } 6 | string Version { get; } 7 | void OnApplicationStart(); 8 | void OnApplicationQuit(); 9 | void OnLevelWasLoaded(int level); 10 | void OnLevelWasInitialized(int level); 11 | void OnUpdate(); 12 | void OnFixedUpdate(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/IPA/IPA/PluginManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using IllusionPlugin; 3 | using MelonLoader.Utils; 4 | 5 | namespace IllusionInjector 6 | { 7 | public static class PluginManager 8 | { 9 | internal static List _Plugins = new List(); 10 | public static IEnumerable Plugins { get => _Plugins; } 11 | public class AppInfo 12 | { 13 | public static string StartupPath { get => MelonEnvironment.GameRootDirectory; } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/IPA/IPAPluginWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | using IllusionPlugin; 7 | using IllusionInjector; 8 | 9 | namespace MelonLoader.CompatibilityLayers 10 | { 11 | internal class IPAPluginWrapper : MelonMod 12 | { 13 | internal IPlugin pluginInstance; 14 | public override void OnInitializeMelon() => pluginInstance.OnApplicationStart(); 15 | public override void OnDeinitializeMelon() => pluginInstance.OnApplicationQuit(); 16 | public override void OnSceneWasLoaded(int buildIndex, string sceneName) => pluginInstance.OnLevelWasLoaded(buildIndex); 17 | public override void OnSceneWasInitialized(int buildIndex, string sceneName) => pluginInstance.OnLevelWasInitialized(buildIndex); 18 | public override void OnUpdate() => pluginInstance.OnUpdate(); 19 | public override void OnFixedUpdate() => pluginInstance.OnFixedUpdate(); 20 | public override void OnLateUpdate() { if (pluginInstance is IEnhancedPlugin plugin) plugin.OnLateUpdate(); } 21 | } 22 | } -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/IMod.cs: -------------------------------------------------------------------------------- 1 | namespace ModHelper 2 | { 3 | public interface IMod 4 | { 5 | string Name { get; } 6 | string Description { get; } 7 | string Author { get; } 8 | string HomePage { get; } 9 | void DoPatching(); 10 | } 11 | } -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/ModLoader.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using MelonLoader; 4 | using ModHelper; 5 | 6 | namespace ModLoader 7 | { 8 | public class ModLoader 9 | { 10 | internal static List mods = new List(); 11 | internal static Dictionary depends = new Dictionary(); 12 | 13 | public static void LoadDependency(Assembly assembly) 14 | { 15 | foreach (string dependStr in assembly.GetManifestResourceNames()) 16 | { 17 | string filter = $"{assembly.GetName().Name}.Depends."; 18 | if (dependStr.StartsWith(filter) && dependStr.EndsWith(".dll")) 19 | { 20 | string dependName = dependStr.Remove(dependStr.LastIndexOf(".dll")).Remove(0, filter.Length); 21 | if (depends.ContainsKey(dependName)) 22 | { 23 | MelonLogger.Error($"Dependency conflict: {dependName} First at: {depends[dependName].GetName().Name}"); 24 | continue; 25 | } 26 | 27 | Assembly dependAssembly; 28 | using (var stream = assembly.GetManifestResourceStream(dependStr)) 29 | { 30 | byte[] buffer = new byte[stream.Length]; 31 | stream.Read(buffer, 0, buffer.Length); 32 | dependAssembly = Assembly.Load(buffer); 33 | } 34 | depends.Add(dependName, dependAssembly); 35 | } 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModLoader/ModLogger.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using MelonLoader; 3 | 4 | namespace ModHelper 5 | { 6 | public static class ModLogger 7 | { 8 | public static void Debug(object obj) 9 | { 10 | var frame = new StackTrace().GetFrame(1); 11 | var className = frame.GetMethod().ReflectedType.Name; 12 | var methodName = frame.GetMethod().Name; 13 | AddLog(className, methodName, obj); 14 | } 15 | 16 | public static void AddLog(string className, string methodName, object obj) 17 | { 18 | MelonLogger.Msg($"[{className}:{methodName}]: {obj}"); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/Muse_Dash_Mono/MuseDashModWrapper.cs: -------------------------------------------------------------------------------- 1 | using ModHelper; 2 | 3 | namespace MelonLoader 4 | { 5 | internal class MuseDashModWrapper : MelonMod 6 | { 7 | internal IMod modInstance; 8 | public override void OnInitializeMelon() => modInstance.DoPatching(); 9 | } 10 | } -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/Muse_Dash_Mono/Muse_Dash_Mono.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | MelonLoader.CompatibilityLayers 4 | net35 5 | true 6 | $(MLOutDir)/MelonLoader/Dependencies/CompatibilityLayers 7 | true 8 | portable 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Dependencies/CompatibilityLayers/Stress_Level_Zero_Il2Cpp/Stress_Level_Zero_Il2Cpp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | MelonLoader.CompatibilityLayers 4 | net472 5 | true 6 | $(MLOutDir)/MelonLoader/Dependencies/CompatibilityLayers 7 | true 8 | None 9 | 10 | 11 | 12 | 13 | false 14 | false 15 | 16 | 17 | -------------------------------------------------------------------------------- /Dependencies/Il2CppAssemblyGenerator/Config.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using MelonLoader.Preferences; 5 | 6 | namespace MelonLoader.Il2CppAssemblyGenerator 7 | { 8 | internal class Config 9 | { 10 | private static string FilePath; 11 | private static MelonPreferences_ReflectiveCategory Category; 12 | internal static AssemblyGeneratorConfiguration Values; 13 | 14 | internal static void Initialize() 15 | { 16 | FilePath = Path.Combine(Core.BasePath, "Config.cfg"); 17 | 18 | Category = MelonPreferences.CreateCategory("Il2CppAssemblyGenerator"); 19 | Category.SetFilePath(FilePath, printmsg: false); 20 | Category.DestroyFileWatcher(); 21 | 22 | Values = Category.GetValue(); 23 | 24 | if (!File.Exists(FilePath)) 25 | Save(); 26 | } 27 | 28 | internal static void Save() => Category.SaveToFile(false); 29 | 30 | public class AssemblyGeneratorConfiguration 31 | { 32 | public string GameAssemblyHash = null; 33 | public string DeobfuscationRegex = null; 34 | public string UnityVersion = "0.0.0.0"; 35 | public string DumperVersion = "0.0.0.0"; 36 | public string DumperSCRSVersion = "0.0.0.0"; 37 | 38 | [Obsolete("Il2CppAssemblyUnhollower support was discontinued. This will be removed in a future update.", true)] 39 | public bool UseInterop = true; 40 | 41 | public List OldFiles = new List(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Dependencies/Il2CppAssemblyGenerator/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Net.Http; 3 | 4 | namespace MelonLoader.Il2CppAssemblyGenerator; 5 | 6 | internal static class Extensions 7 | { 8 | public static void DownloadFile(this HttpClient client, string url, string dest) 9 | { 10 | using var dlStream = client.GetStreamAsync(url).Result; 11 | using var fileStream = File.Open(dest, FileMode.Create, FileAccess.Write); 12 | dlStream.CopyTo(fileStream); 13 | } 14 | } -------------------------------------------------------------------------------- /Dependencies/Il2CppAssemblyGenerator/Il2CppAssemblyGenerator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | MelonLoader.Il2CppAssemblyGenerator 4 | net6 5 | true 6 | true 7 | $(MLOutDir)/MelonLoader/Dependencies/Il2CppAssemblyGenerator 8 | true 9 | embedded 10 | false 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Dependencies/Il2CppAssemblyGenerator/Packages/Cpp2IL_StrippedCodeRegSupport.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader.Il2CppAssemblyGenerator.Packages.Models; 2 | using Semver; 3 | using System.IO; 4 | 5 | namespace MelonLoader.Il2CppAssemblyGenerator.Packages 6 | { 7 | internal class Cpp2IL_StrippedCodeRegSupport : PackageBase 8 | { 9 | private static SemVersion MinVersion = SemVersion.Parse("2022.1.0-pre-release.19"); 10 | private string _pluginsFolder; 11 | private SemVersion VersionSem; 12 | 13 | internal Cpp2IL_StrippedCodeRegSupport(ExecutablePackage cpp2IL) 14 | { 15 | Name = $"{cpp2IL.Name}.Plugin.StrippedCodeRegSupport"; 16 | Version = cpp2IL.Version; 17 | VersionSem = SemVersion.Parse(Version); 18 | 19 | string folderpath = Path.Combine(Core.BasePath, cpp2IL.Name); 20 | string fileName = $"{Name}.dll"; 21 | _pluginsFolder = Path.Combine(folderpath, "Plugins"); 22 | 23 | FilePath = 24 | Destination = 25 | Path.Combine(_pluginsFolder, fileName); 26 | 27 | URL = $"https://github.com/SamboyCoding/{cpp2IL.Name}/releases/download/{cpp2IL.Version}/{fileName}"; 28 | } 29 | 30 | internal override bool ShouldSetup() 31 | { 32 | if (VersionSem < MinVersion) 33 | return false; 34 | 35 | return string.IsNullOrEmpty(Config.Values.DumperSCRSVersion) 36 | || !Config.Values.DumperSCRSVersion.Equals(Version); 37 | } 38 | 39 | internal override bool Setup() 40 | { 41 | if (VersionSem < Cpp2IL.NetCoreMinVersion) 42 | return true; 43 | 44 | if (!Directory.Exists(_pluginsFolder)) 45 | Directory.CreateDirectory(_pluginsFolder); 46 | 47 | return base.Setup(); 48 | } 49 | 50 | internal override void Save() 51 | => Save(ref Config.Values.DumperSCRSVersion); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Dependencies/Il2CppAssemblyGenerator/Packages/DeobfuscationMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | using MelonLoader.Lemons.Cryptography; 5 | 6 | namespace MelonLoader.Il2CppAssemblyGenerator.Packages 7 | { 8 | internal class DeobfuscationMap : Models.PackageBase 9 | { 10 | private static LemonSHA512 lemonSHA512 = new LemonSHA512(); 11 | 12 | internal DeobfuscationMap() 13 | { 14 | Name = nameof(DeobfuscationMap); 15 | FilePath = Path.Combine(Core.BasePath, $"{Name}.csv.gz"); 16 | Destination = FilePath; 17 | URL = RemoteAPI.Info.MappingURL; 18 | Version = RemoteAPI.Info.MappingFileSHA512; 19 | } 20 | 21 | internal override bool ShouldSetup() 22 | { 23 | if (string.IsNullOrEmpty(URL)) 24 | return false; 25 | if (string.IsNullOrEmpty(Version)) 26 | return false; 27 | else 28 | { 29 | if (!File.Exists(FilePath)) 30 | return true; 31 | byte[] hash = lemonSHA512.ComputeHash(File.ReadAllBytes(FilePath)); 32 | StringBuilder hashstrb = new StringBuilder(128); 33 | foreach (byte b in hash) 34 | hashstrb.Append(b.ToString("x2")); 35 | string hashstr = hashstrb.ToString(); 36 | if (!hashstr.Equals(Version, StringComparison.OrdinalIgnoreCase)) 37 | return true; 38 | } 39 | return false; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Dependencies/Il2CppAssemblyGenerator/Packages/DeobfuscationRegex.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader.Il2CppAssemblyGenerator.Packages 2 | { 3 | internal class DeobfuscationRegex 4 | { 5 | internal string Regex = null; 6 | 7 | internal DeobfuscationRegex() 8 | { 9 | Regex = LoaderConfig.Current.UnityEngine.ForceGeneratorRegex; 10 | if (string.IsNullOrEmpty(Regex)) 11 | Regex = RemoteAPI.Info.ObfuscationRegex; 12 | } 13 | 14 | internal void Setup() 15 | { 16 | if (string.IsNullOrEmpty(Regex)) 17 | { 18 | if (!string.IsNullOrEmpty(Config.Values.DeobfuscationRegex)) 19 | { 20 | Core.AssemblyGenerationNeeded = true; 21 | return; 22 | } 23 | } 24 | else 25 | { 26 | if (string.IsNullOrEmpty(Config.Values.DeobfuscationRegex)) 27 | { 28 | Core.AssemblyGenerationNeeded = true; 29 | return; 30 | } 31 | if (!Config.Values.DeobfuscationRegex.Equals(Regex)) 32 | { 33 | Core.AssemblyGenerationNeeded = true; 34 | return; 35 | } 36 | } 37 | } 38 | 39 | internal void Save() 40 | { 41 | Config.Values.DeobfuscationRegex = Regex; 42 | Config.Save(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Dependencies/Il2CppAssemblyGenerator/Packages/UnityDependencies.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace MelonLoader.Il2CppAssemblyGenerator.Packages 4 | { 5 | internal class UnityDependencies : Models.PackageBase 6 | { 7 | internal UnityDependencies() 8 | { 9 | Name = nameof(UnityDependencies); 10 | Version = InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(); 11 | URL = $"https://github.com/LavaGang/MelonLoader.UnityDependencies/releases/download/{Version}/Managed.zip"; 12 | Destination = Path.Combine(Core.BasePath, Name); 13 | FilePath = Path.Combine(Core.BasePath, $"{Name}_{Version}.zip"); 14 | } 15 | 16 | internal override bool ShouldSetup() 17 | => string.IsNullOrEmpty(Config.Values.UnityVersion) 18 | || !Config.Values.UnityVersion.Equals(Version); 19 | 20 | internal override void Save() 21 | => Save(ref Config.Values.UnityVersion); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/MelonStartScreen.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | MelonLoader.MelonStartScreen 4 | net35;net6 5 | true 6 | $(MLOutDir)/MelonLoader 7 | true 8 | true 9 | portable 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Runtime 22 | 23 | 24 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/ModLoadStep.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader.MelonStartScreen 2 | { 3 | internal enum ModLoadStep 4 | { 5 | Generation, 6 | LoadMelons, 7 | InitializeMelons, 8 | OnApplicationStart 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/NativeUtils/NativeFieldValueAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.MelonStartScreen.NativeUtils 4 | { 5 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] 6 | class NativeFieldValueAttribute : Attribute 7 | { 8 | internal uint LookupIndex { get; } 9 | internal NativeSignatureFlags Flags { get; } 10 | internal object Value { get; } 11 | internal string[] MinimalUnityVersions { get; } 12 | 13 | public NativeFieldValueAttribute(uint lookupIndex, NativeSignatureFlags flags, object value, params string[] minimalUnityVersions) 14 | { 15 | LookupIndex = lookupIndex; 16 | Flags = flags; 17 | Value = value; 18 | MinimalUnityVersions = minimalUnityVersions; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/NativeUtils/NativeSignatureAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.MelonStartScreen.NativeUtils 4 | { 5 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] 6 | internal class NativeSignatureAttribute : Attribute 7 | { 8 | internal uint LookupIndex { get; } 9 | internal NativeSignatureFlags Flags { get; } 10 | internal string Signature { get; } 11 | internal string[] MinimalUnityVersions { get; } 12 | 13 | internal NativeSignatureAttribute(uint lookupIndex, NativeSignatureFlags flags, string signature, params string[] minimalUnityVersions) 14 | { 15 | LookupIndex = lookupIndex; 16 | Flags = flags; 17 | Signature = signature; 18 | MinimalUnityVersions = minimalUnityVersions; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/NativeUtils/NativeSignatureFlags.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader.MelonStartScreen.NativeUtils 2 | { 3 | internal enum NativeSignatureFlags 4 | { 5 | None = 0, 6 | 7 | Il2Cpp = 1, 8 | Mono = 2, 9 | 10 | //Dev = 4, 11 | //NonDev = 8 12 | 13 | X86 = 16, 14 | X64 = 32, 15 | //ARMEABIV7A = 64, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/Resources/Loading_Halloween.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/Dependencies/MelonStartScreen/Resources/Loading_Halloween.dat -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/Resources/Loading_Lemon.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/Dependencies/MelonStartScreen/Resources/Loading_Lemon.dat -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/Resources/Loading_Melon.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/Dependencies/MelonStartScreen/Resources/Loading_Melon.dat -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/Resources/Logo_Halloween.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/Dependencies/MelonStartScreen/Resources/Logo_Halloween.dat -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/Resources/Logo_Lemon.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/Dependencies/MelonStartScreen/Resources/Logo_Lemon.dat -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/Resources/Logo_Melon.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/Dependencies/MelonStartScreen/Resources/Logo_Melon.dat -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UI/Objects/UI_Background.cs: -------------------------------------------------------------------------------- 1 | using MelonUnityEngine; 2 | 3 | namespace MelonLoader.MelonStartScreen.UI.Objects 4 | { 5 | internal class UI_Background : UI_Object 6 | { 7 | private UI_Theme.cBackground config; 8 | private UI_Image image; 9 | internal Texture2D solidTexture; 10 | 11 | internal UI_Background(UI_Theme.cBackground backgroundSettings) 12 | { 13 | config = backgroundSettings; 14 | image = UI_Utils.LoadImage(config, "Background"); 15 | 16 | solidTexture = UI_Utils.CreateColorTexture(config.SolidColor); 17 | solidTexture.hideFlags = HideFlags.HideAndDontSave; 18 | solidTexture.DontDestroyOnLoad(); 19 | AllElements.Add(this); 20 | } 21 | 22 | internal override void Render() 23 | { 24 | int sw = Screen.width; 25 | int sh = Screen.height; 26 | 27 | if (solidTexture != null) 28 | Graphics.DrawTexture(new Rect(0, 0, sw, sh), solidTexture); 29 | 30 | if (image != null) 31 | { 32 | if (config.StretchToScreen) 33 | image.Render(0, 0, sw, sh); 34 | else 35 | image.Render(); 36 | } 37 | } 38 | 39 | internal override void Dispose() 40 | { 41 | if (solidTexture == null) 42 | return; 43 | 44 | solidTexture.DestroyImmediate(); 45 | solidTexture = null; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UI/Objects/UI_Object.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace MelonLoader.MelonStartScreen.UI.Objects 5 | { 6 | internal abstract class UI_Object : IDisposable 7 | { 8 | internal static List AllElements = new List(); 9 | private bool disposedValue; 10 | 11 | internal virtual void Dispose() { } 12 | internal abstract void Render(); 13 | 14 | protected virtual void Dispose(bool managed) 15 | { 16 | if (disposedValue) 17 | return; 18 | if (managed) 19 | Dispose(); 20 | disposedValue = true; 21 | } 22 | 23 | void IDisposable.Dispose() 24 | { 25 | Dispose(managed: true); 26 | GC.SuppressFinalize(this); 27 | } 28 | 29 | internal static void DisposeOfAll() 30 | { 31 | if (AllElements.Count <= 0) 32 | return; 33 | foreach (UI_Object obj in AllElements) 34 | obj.Dispose(); 35 | AllElements.Clear(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UI/StartScreenResources.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Reflection; 3 | using MelonUnityEngine; 4 | 5 | namespace MelonLoader.MelonStartScreen.UI 6 | { 7 | internal static class StartScreenResources 8 | { 9 | public static byte[] HalloweenLoadingIcon => GetResource("Loading_Halloween.dat"); 10 | public static byte[] MelonLoadingIcon => GetResource("Loading_Melon.dat"); 11 | public static byte[] LemonLoadingIcon => GetResource("Loading_Lemon.dat"); 12 | 13 | //Logos 14 | public static byte[] HalloweenLogo => GetResource("Logo_Halloween.dat"); 15 | public static byte[] MelonLogo => GetResource("Logo_Melon.dat"); 16 | public static byte[] LemonLogo => GetResource("Logo_Lemon.dat"); 17 | 18 | private static byte[] GetResource(string name) 19 | { 20 | using var s = Assembly.GetExecutingAssembly().GetManifestResourceStream($"MelonLoader.MelonStartScreen.Resources.{name}"); 21 | if (s == null) 22 | return null; 23 | #if NET6_0_OR_GREATER 24 | using var ms = new MemoryStream(); 25 | s.CopyTo(ms); 26 | return ms.ToArray(); 27 | #else 28 | var ret = new byte[s.Length]; 29 | s.Read(ret, 0, ret.Length); 30 | return ret; 31 | #endif 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Default.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader.MelonStartScreen.UI.Themes 2 | { 3 | internal class UI_Theme_Default : UI_Theme 4 | { 5 | internal UI_Theme_Default() => Defaults(); 6 | 7 | internal override byte[] GetLoadingImage() 8 | => StartScreenResources.MelonLoadingIcon; 9 | 10 | internal override byte[] GetLogoImage() 11 | => StartScreenResources.MelonLogo; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Lemon.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader.MelonStartScreen.UI.Themes 2 | { 3 | internal class UI_Theme_Lemon : UI_Theme 4 | { 5 | internal UI_Theme_Lemon() => Defaults(); 6 | 7 | internal override byte[] GetLoadingImage() 8 | => StartScreenResources.LemonLoadingIcon; 9 | 10 | internal override byte[] GetLogoImage() 11 | => StartScreenResources.LemonLogo; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UI/Themes/UI_Theme_Pumpkin.cs: -------------------------------------------------------------------------------- 1 | using MelonUnityEngine; 2 | 3 | namespace MelonLoader.MelonStartScreen.UI.Themes 4 | { 5 | internal class UI_Theme_Pumpkin : UI_Theme 6 | { 7 | internal UI_Theme_Pumpkin() 8 | { 9 | Background = new hBackground(); 10 | ProgressBar = new hProgressBar(); 11 | VersionText = new hVersionTextSettings(); 12 | Defaults(); 13 | } 14 | 15 | internal override byte[] GetLoadingImage() 16 | => StartScreenResources.HalloweenLoadingIcon; 17 | 18 | internal override byte[] GetLogoImage() 19 | => StartScreenResources.HalloweenLogo; 20 | 21 | internal class hBackground : cBackground 22 | { 23 | public hBackground() 24 | => SolidColor = new Color(0.078f, 0f, 0.141f); 25 | } 26 | 27 | internal class hProgressBar : cProgressBar 28 | { 29 | public hProgressBar() : base() 30 | { 31 | OuterColor = new Color(0.478f, 0.169f, 0.749f); 32 | InnerColor = new Color(1f, 0.435f, 0f); 33 | Defaults(); 34 | } 35 | } 36 | 37 | internal class hVersionTextSettings : VersionTextSettings 38 | { 39 | public hVersionTextSettings() 40 | { 41 | Text = $" v {(Is_ALPHA_PreRelease ? "ALPHA Pre-Release" : "Open-Beta")}"; 42 | Defaults(); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UI/UI_Anchor.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader.MelonStartScreen.UI 2 | { 3 | internal enum UI_Anchor 4 | { 5 | // Upper 6 | UpperLeft, 7 | UpperCenter, 8 | UpperRight, 9 | 10 | // Middle 11 | MiddleLeft, 12 | MiddleCenter, 13 | MiddleRight, 14 | 15 | // Lower 16 | LowerLeft, 17 | LowerCenter, 18 | LowerRight 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UI/UI_Style.cs: -------------------------------------------------------------------------------- 1 | using MelonUnityEngine; 2 | using System; 3 | 4 | namespace MelonLoader.MelonStartScreen.UI 5 | { 6 | internal class UI_Style 7 | { 8 | internal static Objects.UI_Background Background; 9 | internal static Objects.UI_Image LogoImage; 10 | internal static Objects.UI_Image LoadingImage; 11 | internal static Objects.UI_Text VersionText; 12 | internal static Objects.UI_ProgressBar ProgressBar; 13 | 14 | internal static void Init() 15 | { 16 | Background = new Objects.UI_Background(UI_Theme.Instance.Background); 17 | VersionText = new Objects.UI_Text(UI_Theme.Instance.VersionText); 18 | ProgressBar = new Objects.UI_ProgressBar(UI_Theme.Instance.ProgressBar, UI_Theme.Instance.ProgressText); 19 | 20 | if (UI_Theme.Instance.LogoImage.ScanForCustomImage) 21 | LogoImage = UI_Utils.LoadImage(UI_Theme.Instance.LogoImage, "Logo"); 22 | if (LogoImage == null) 23 | LogoImage = new Objects.UI_Image(UI_Theme.Instance.LogoImage, UI_Theme.Instance.GetLogoImage()); 24 | 25 | if (UI_Theme.Instance.LoadingImage.ScanForCustomImage) 26 | LoadingImage = UI_Utils.LoadImage(UI_Theme.Instance.LoadingImage, "Loading"); 27 | if (LoadingImage == null) 28 | LoadingImage = new Objects.UI_AnimatedImage(UI_Theme.Instance.LoadingImage, UI_Theme.Instance.GetLoadingImage()); 29 | } 30 | 31 | 32 | internal static void Render() 33 | { 34 | Background.Render(); 35 | LogoImage.Render(); 36 | LoadingImage.Render(); 37 | ProgressBar.Render(); 38 | VersionText.Render(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnhollowerMini/Il2CppException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | #pragma warning disable 0649 4 | 5 | namespace UnhollowerMini 6 | { 7 | internal class Il2CppException : Exception 8 | { 9 | [ThreadStatic] private static byte[] ourMessageBytes; 10 | 11 | public static Func ParseMessageHook; 12 | 13 | public Il2CppException(IntPtr exception) : base(BuildMessage(exception)) { } 14 | 15 | private static unsafe string BuildMessage(IntPtr exception) 16 | { 17 | if (ParseMessageHook != null) return ParseMessageHook(exception); 18 | if (ourMessageBytes == null) ourMessageBytes = new byte[65536]; 19 | fixed (byte* message = ourMessageBytes) 20 | UnityInternals.format_exception(exception, message, ourMessageBytes.Length); 21 | string builtMessage = Encoding.UTF8.GetString(ourMessageBytes, 0, Array.IndexOf(ourMessageBytes, (byte)0)); 22 | fixed (byte* message = ourMessageBytes) 23 | UnityInternals.format_stack_trace(exception, message, ourMessageBytes.Length); 24 | builtMessage += 25 | "\n" + Encoding.UTF8.GetString(ourMessageBytes, 0, Array.IndexOf(ourMessageBytes, (byte)0)); 26 | return builtMessage; 27 | } 28 | 29 | public static void RaiseExceptionIfNecessary(IntPtr returnedException) 30 | { 31 | if (returnedException == IntPtr.Zero) return; 32 | throw new Il2CppException(returnedException); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Byte.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using UnhollowerMini; 3 | 4 | namespace Il2CppSystem 5 | { 6 | [StructLayout(LayoutKind.Explicit)] 7 | internal class Byte 8 | { 9 | [FieldOffset(0)] 10 | public byte m_value; 11 | 12 | static Byte() 13 | { 14 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("mscorlib.dll", "System", "Byte"); 15 | UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Int32.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using UnhollowerMini; 3 | 4 | namespace Il2CppSystem 5 | { 6 | [StructLayout(LayoutKind.Explicit)] 7 | internal class Int32 8 | { 9 | [FieldOffset(0)] 10 | public int m_value; 11 | 12 | static Int32() 13 | { 14 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("mscorlib.dll", "System", "Int32"); 15 | UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnhollowerMini/Il2CppSystem/Type.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader; 2 | using System; 3 | using UnhollowerMini; 4 | 5 | namespace Il2CppSystem 6 | { 7 | internal class Type : InternalObjectBase 8 | { 9 | private static readonly IntPtr m_internal_from_handle; 10 | 11 | static Type() 12 | { 13 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("mscorlib.dll", "System", "Type"); 14 | 15 | m_internal_from_handle = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "internal_from_handle", "System.Type", "System.IntPtr"); 16 | } 17 | 18 | public Type(IntPtr ptr) : base(ptr) { } 19 | 20 | public unsafe static Type internal_from_handle(IntPtr handle) 21 | { 22 | void** args = stackalloc void*[1]; 23 | args[0] = &handle; 24 | IntPtr returnedException = default; 25 | IntPtr intPtr = UnityInternals.runtime_invoke(Type.m_internal_from_handle, IntPtr.Zero, (void**)args, ref returnedException); 26 | Il2CppException.RaiseExceptionIfNecessary(returnedException); 27 | return (intPtr != IntPtr.Zero) ? new Type(intPtr) : null; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnhollowerMini/InternalClassPointerStore.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader; 2 | using System; 3 | using System.Runtime.CompilerServices; 4 | #pragma warning disable 0649 5 | 6 | namespace UnhollowerMini 7 | { 8 | internal static class InternalClassPointerStore 9 | { 10 | public static IntPtr NativeClassPtr; 11 | public static Type CreatedTypeRedirect; 12 | 13 | static InternalClassPointerStore() 14 | { 15 | var targetType = typeof(T); 16 | 17 | RuntimeHelpers.RunClassConstructor(targetType.TypeHandle); 18 | 19 | if (targetType.IsPrimitive || targetType == typeof(string)) 20 | { 21 | MelonDebug.Msg("Running class constructor on Il2Cpp" + targetType.FullName); 22 | RuntimeHelpers.RunClassConstructor(typeof(InternalClassPointerStore<>).Assembly.GetType("Il2Cpp" + targetType.FullName).TypeHandle); 23 | MelonDebug.Msg("Done running class constructor"); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnhollowerMini/InternalObjectBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnhollowerMini 4 | { 5 | internal class InternalObjectBase 6 | { 7 | public IntPtr Pointer 8 | { 9 | get 10 | { 11 | var handleTarget = UnityInternals.gchandle_get_target(myGcHandle); 12 | if (handleTarget == IntPtr.Zero) throw new ObjectCollectedException("Object was garbage collected"); 13 | return handleTarget; 14 | } 15 | } 16 | 17 | protected uint myGcHandle; 18 | 19 | protected InternalObjectBase() { } 20 | 21 | public InternalObjectBase(IntPtr pointer) 22 | { 23 | if (pointer == IntPtr.Zero) 24 | throw new NullReferenceException(); 25 | 26 | myGcHandle = UnityInternals.gchandle_new(pointer, false); 27 | } 28 | 29 | ~InternalObjectBase() 30 | { 31 | UnityInternals.gchandle_free(myGcHandle); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnhollowerMini/InternalType.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader; 2 | using System; 3 | 4 | namespace UnhollowerMini 5 | { 6 | internal static class InternalType 7 | { 8 | public static Il2CppSystem.Type TypeFromPointer(IntPtr classPointer, string typeName = "") 9 | { 10 | if (classPointer == IntPtr.Zero) throw new ArgumentException($"{typeName} does not have a corresponding internal class pointer"); 11 | var il2CppType = UnityInternals.class_get_type(classPointer); 12 | if (il2CppType == IntPtr.Zero) throw new ArgumentException($"{typeName} does not have a corresponding class type pointer"); 13 | return Il2CppSystem.Type.internal_from_handle(il2CppType); 14 | } 15 | 16 | public static Il2CppSystem.Type Of() 17 | { 18 | var classPointer = InternalClassPointerStore.NativeClassPtr; 19 | return TypeFromPointer(classPointer, typeof(T).Name); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnhollowerMini/ObjectCollectedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnhollowerMini 4 | { 5 | internal class ObjectCollectedException : Exception 6 | { 7 | public ObjectCollectedException(string message) : base(message) { } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/Color.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using UnhollowerMini; 4 | 5 | namespace MelonUnityEngine 6 | { 7 | [StructLayout(LayoutKind.Explicit)] 8 | internal struct Color 9 | { 10 | private static readonly IntPtr m_ToString; 11 | 12 | [FieldOffset(0)] 13 | public float r; 14 | [FieldOffset(4)] 15 | public float g; 16 | [FieldOffset(8)] 17 | public float b; 18 | [FieldOffset(12)] 19 | public float a; 20 | 21 | static Color() 22 | { 23 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Color"); 24 | UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); 25 | m_ToString = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "ToString", "System.String"); 26 | } 27 | 28 | public Color(float r, float g, float b, float a = 1f) 29 | { 30 | this.r = r; 31 | this.g = g; 32 | this.b = b; 33 | this.a = a; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/Color32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using UnhollowerMini; 4 | 5 | namespace MelonUnityEngine 6 | { 7 | [StructLayout(LayoutKind.Explicit)] 8 | internal struct Color32 9 | { 10 | [FieldOffset(0)] 11 | public byte r; 12 | [FieldOffset(1)] 13 | public byte g; 14 | [FieldOffset(2)] 15 | public byte b; 16 | [FieldOffset(3)] 17 | public byte a; 18 | 19 | [FieldOffset(0)] 20 | public int rgba; 21 | 22 | static Color32() 23 | { 24 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Color32"); 25 | UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); 26 | } 27 | 28 | public Color32(byte r, byte g, byte b, byte a) 29 | { 30 | this.rgba = 0; 31 | this.r = r; 32 | this.g = g; 33 | this.b = b; 34 | this.a = a; 35 | } 36 | 37 | public static implicit operator Color(Color32 c) 38 | { 39 | return new Color(c.r / 255f, c.g / 255f, c.b / 255f, c.a / 255f); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/FilterMode.cs: -------------------------------------------------------------------------------- 1 | namespace MelonUnityEngine 2 | { 3 | internal enum FilterMode 4 | { 5 | Point, 6 | Bilinear, 7 | Trilinear 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/GL.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnhollowerMini; 3 | 4 | namespace MelonUnityEngine 5 | { 6 | internal sealed class GL 7 | { 8 | private delegate bool d_get_sRGBWrite(); 9 | private static readonly d_get_sRGBWrite m_get_sRGBWrite; 10 | 11 | unsafe static GL() 12 | { 13 | m_get_sRGBWrite = UnityInternals.ResolveICall("UnityEngine.GL::get_sRGBWrite"); 14 | } 15 | 16 | public unsafe static bool sRGBWrite 17 | { 18 | get => m_get_sRGBWrite(); 19 | // set 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/HideFlags.cs: -------------------------------------------------------------------------------- 1 | namespace MelonUnityEngine 2 | { 3 | internal enum HideFlags 4 | { 5 | None = 0, 6 | HideInHierarchy = 1, 7 | HideInInspector = 2, 8 | DontSaveInEditor = 4, 9 | NotEditable = 8, 10 | DontSaveInBuild = 16, 11 | DontUnloadUnusedAsset = 32, 12 | DontSave = 52, 13 | HideAndDontSave = 61 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/ImageConversion.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader; 2 | using System; 3 | using System.Runtime.InteropServices; 4 | using UnhollowerMini; 5 | 6 | namespace MelonUnityEngine 7 | { 8 | internal static class ImageConversion 9 | { 10 | private delegate bool ImageConversion_LoadImage_Delegate(IntPtr tex, IntPtr data, bool markNonReadable); 11 | private static ImageConversion_LoadImage_Delegate ImageConversion_LoadImage; 12 | 13 | static ImageConversion() 14 | { 15 | IntPtr ptr = UnityInternals.ResolveICall("UnityEngine.ImageConversion::LoadImage(UnityEngine.Texture2D,System.Byte[],System.Boolean)"); 16 | if (ptr != IntPtr.Zero) 17 | ImageConversion_LoadImage = (ImageConversion_LoadImage_Delegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(ImageConversion_LoadImage_Delegate)); 18 | else 19 | MelonLogger.Error("Failed to resolve icall UnityEngine.ImageConversion::LoadImage(UnityEngine.Texture2D,System.Byte[],System.Boolean)"); 20 | } 21 | 22 | public unsafe static bool LoadImage(Texture2D tex, byte[] data, bool markNonReadable) 23 | { 24 | if (ImageConversion_LoadImage == null) 25 | { 26 | MelonLogger.Error("Failed to run UnityEngine.ImageConversion::LoadImage(UnityEngine.Texture2D,System.Byte[],System.Boolean)"); 27 | return false; 28 | } 29 | 30 | IntPtr dataPtr = UnityInternals.array_new(InternalClassPointerStore.NativeClassPtr, (uint)data.Length); 31 | for (var i = 0; i < data.Length; i++) 32 | { 33 | IntPtr arrayStartPointer = (IntPtr)((long)dataPtr + 4 * IntPtr.Size); 34 | ((byte*)arrayStartPointer.ToPointer())[i] = data[i]; 35 | } 36 | 37 | return ImageConversion_LoadImage(tex.Pointer, dataPtr, markNonReadable); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/Material.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnhollowerMini; 3 | 4 | namespace MelonUnityEngine 5 | { 6 | internal class Material : UnityObject 7 | { 8 | private delegate bool d_SetPass(IntPtr @this, int pass); 9 | private static readonly d_SetPass m_SetPass; 10 | 11 | unsafe static Material() 12 | { 13 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Material"); 14 | UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); 15 | 16 | //m_SetPass = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "SetPass", "System.Boolean", "System.Int32"); 17 | m_SetPass = UnityInternals.ResolveICall("UnityEngine.Material::SetPass"); 18 | } 19 | 20 | public Material(IntPtr ptr) : base(ptr) { } 21 | 22 | public unsafe bool SetPass(int pass) 23 | { 24 | return m_SetPass(UnityInternals.ObjectBaseToPtrNotNull(this), pass); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/Quaternion.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using UnhollowerMini; 3 | 4 | namespace MelonUnityEngine 5 | { 6 | [StructLayout(LayoutKind.Explicit)] 7 | internal struct Quaternion 8 | { 9 | [FieldOffset(0)] 10 | public float x; 11 | [FieldOffset(4)] 12 | public float y; 13 | [FieldOffset(8)] 14 | public float z; 15 | [FieldOffset(12)] 16 | public float w; 17 | 18 | static Quaternion() 19 | { 20 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Quaternion"); 21 | } 22 | 23 | public static Quaternion identity => new Quaternion(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/Rect.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using UnhollowerMini; 3 | 4 | namespace MelonUnityEngine 5 | { 6 | [StructLayout(LayoutKind.Explicit)] 7 | internal struct Rect 8 | { 9 | [FieldOffset(0)] 10 | public float m_XMin; 11 | [FieldOffset(4)] 12 | public float m_YMin; 13 | [FieldOffset(8)] 14 | public float m_Width; 15 | [FieldOffset(12)] 16 | public float m_Height; 17 | 18 | static Rect() 19 | { 20 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Rect"); 21 | UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); 22 | } 23 | 24 | public Rect(int x, int y, int width, int height) 25 | { 26 | m_XMin = x; 27 | m_YMin = y; 28 | m_Width = width; 29 | m_Height = height; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/Resources.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader; 2 | using System; 3 | using System.Runtime.InteropServices; 4 | using UnhollowerMini; 5 | 6 | namespace MelonUnityEngine 7 | { 8 | internal class Resources 9 | { 10 | private static readonly IntPtr m_GetBuiltinResource; 11 | 12 | static Resources() 13 | { 14 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Resources"); 15 | //UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); 16 | 17 | m_GetBuiltinResource = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "GetBuiltinResource", "UnityEngine.Object", "System.Type", "System.String"); 18 | 19 | } 20 | 21 | public unsafe static IntPtr GetBuiltinResource(Il2CppSystem.Type type, string path) 22 | { 23 | void** ptr = stackalloc void*[2]; 24 | ptr[0] = (void*)UnityInternals.ObjectBaseToPtr(type); 25 | ptr[1] = (void*)UnityInternals.ManagedStringToInternal(path); 26 | IntPtr returnedException = default; 27 | MelonDebug.Msg("Calling runtime_invoke for GetBuiltinResource"); 28 | IntPtr objectPointer = UnityInternals.runtime_invoke(m_GetBuiltinResource, IntPtr.Zero, ptr, ref returnedException); 29 | MelonDebug.Msg("returnedException: " + returnedException + ", objectPointer: " + objectPointer); 30 | Il2CppException.RaiseExceptionIfNecessary(returnedException); 31 | return objectPointer; 32 | } 33 | 34 | public static T GetBuiltinResource(string path) where T : InternalObjectBase 35 | { 36 | MelonDebug.Msg("GetBuiltinResource"); 37 | IntPtr ptr = GetBuiltinResource(InternalType.Of(), path); 38 | return ptr != IntPtr.Zero ? (T)typeof(T).GetConstructor(new[] { typeof(IntPtr) }).Invoke(new object[] { ptr }) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/Screen.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnhollowerMini; 3 | 4 | namespace MelonUnityEngine 5 | { 6 | internal class Screen 7 | { 8 | private static IntPtr m_get_width; 9 | private static IntPtr m_get_height; 10 | 11 | static Screen() 12 | { 13 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Screen"); 14 | m_get_width = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "get_width", "System.Int32"); 15 | m_get_height = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "get_height", "System.Int32"); 16 | } 17 | 18 | public unsafe static int width 19 | { 20 | get 21 | { 22 | IntPtr* param = null; 23 | IntPtr returnedException = IntPtr.Zero; 24 | IntPtr intPtr = UnityInternals.runtime_invoke(m_get_width, IntPtr.Zero, (void**)param, ref returnedException); 25 | Il2CppException.RaiseExceptionIfNecessary(returnedException); 26 | return *(int*)UnityInternals.object_unbox(intPtr); 27 | } 28 | } 29 | 30 | public unsafe static int height 31 | { 32 | get 33 | { 34 | IntPtr* param = null; 35 | IntPtr returnedException = IntPtr.Zero; 36 | IntPtr intPtr = UnityInternals.runtime_invoke(m_get_height, IntPtr.Zero, (void**)param, ref returnedException); 37 | Il2CppException.RaiseExceptionIfNecessary(returnedException); 38 | return *(int*)UnityInternals.object_unbox(intPtr); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/SystemInfo.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader; 2 | using MelonLoader.MelonStartScreen.NativeUtils; 3 | using UnhollowerMini; 4 | 5 | namespace MelonUnityEngine.CoreModule 6 | { 7 | internal sealed class SystemInfo 8 | { 9 | private delegate uint d_GetGraphicsDeviceType(); 10 | private static readonly d_GetGraphicsDeviceType m_GetGraphicsDeviceType; 11 | 12 | unsafe static SystemInfo() 13 | { 14 | if (NativeSignatureResolver.IsUnityVersionOverOrEqual(MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(), new string[] { "2018.1.0" })) 15 | m_GetGraphicsDeviceType = UnityInternals.ResolveICall("UnityEngine.SystemInfo::GetGraphicsDeviceType"); 16 | else 17 | m_GetGraphicsDeviceType = UnityInternals.ResolveICall("UnityEngine.SystemInfo::get_graphicsDeviceType"); 18 | } 19 | 20 | public static uint GetGraphicsDeviceType() => 21 | m_GetGraphicsDeviceType(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/UnityDebug.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader; 2 | using System; 3 | using System.Runtime.InteropServices; 4 | using UnhollowerMini; 5 | 6 | namespace MelonUnityEngine 7 | { 8 | internal static class UnityDebug 9 | { 10 | private delegate bool get_isDebugBuild_Delegate(); 11 | private static get_isDebugBuild_Delegate get_isDebugBuild_Ptr; 12 | 13 | static UnityDebug() 14 | { 15 | IntPtr ptr = UnityInternals.ResolveICall("UnityEngine.Debug::get_isDebugBuild"); 16 | if (ptr != IntPtr.Zero) 17 | get_isDebugBuild_Ptr = (get_isDebugBuild_Delegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(get_isDebugBuild_Delegate)); 18 | else 19 | MelonLogger.Error("Failed to resolve icall UnityEngine.Debug::get_isDebugBuild"); 20 | } 21 | 22 | internal static bool isDebugBuild { get => get_isDebugBuild_Ptr(); } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector2.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using UnhollowerMini; 3 | 4 | namespace MelonUnityEngine 5 | { 6 | [StructLayout(LayoutKind.Explicit)] 7 | internal struct Vector2 8 | { 9 | [FieldOffset(0)] 10 | public float x; 11 | [FieldOffset(4)] 12 | public float y; 13 | 14 | static Vector2() 15 | { 16 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Vector2"); 17 | } 18 | 19 | public Vector2(float x, float y) 20 | { 21 | this.x = x; 22 | this.y = y; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector3.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using UnhollowerMini; 3 | 4 | namespace MelonUnityEngine 5 | { 6 | [StructLayout(LayoutKind.Explicit)] 7 | internal struct Vector3 8 | { 9 | [FieldOffset(0)] 10 | public float x; 11 | [FieldOffset(4)] 12 | public float y; 13 | [FieldOffset(8)] 14 | public float z; 15 | 16 | static Vector3() 17 | { 18 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Vector3"); 19 | } 20 | 21 | public static Vector3 zero => new Vector3(); 22 | 23 | public Vector3(float x, float y, float z) 24 | { 25 | this.x = x; 26 | this.y = y; 27 | this.z = z; 28 | } 29 | 30 | public static Vector3 operator*(Vector3 a, float d) 31 | { 32 | return new Vector3(a.x * d, a.y * d, a.z * d); 33 | } 34 | 35 | public override string ToString() 36 | { 37 | return $"{x} {y} {z}"; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/Vector4.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using UnhollowerMini; 3 | 4 | namespace MelonUnityEngine 5 | { 6 | [StructLayout(LayoutKind.Explicit)] 7 | internal struct Vector4 8 | { 9 | [FieldOffset(0)] 10 | public float x; 11 | [FieldOffset(4)] 12 | public float y; 13 | [FieldOffset(8)] 14 | public float z; 15 | [FieldOffset(12)] 16 | public float w; 17 | 18 | static Vector4() 19 | { 20 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.CoreModule.dll", "UnityEngine", "Vector4"); 21 | } 22 | 23 | public static explicit operator Vector2(Vector4 src) => new Vector2(src.x, src.y); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/VertexAttribute.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader.MelonStartScreen.NativeUtils; 2 | 3 | namespace MelonUnityEngine.Rendering 4 | { 5 | static class VertexAttribute 6 | { 7 | public static int Vertex = 0; 8 | public static int Normal = 1; 9 | 10 | [NativeFieldValue(01, NativeSignatureFlags.None, 7, "2017.1.0")] 11 | [NativeFieldValue(02, NativeSignatureFlags.None, 2, "2018.1.0")] 12 | public static int Tangent = 0; 13 | 14 | [NativeFieldValue(01, NativeSignatureFlags.None, 2, "2017.1.0")] 15 | [NativeFieldValue(02, NativeSignatureFlags.None, 3, "2018.1.0")] 16 | public static int Color = 0; 17 | 18 | [NativeFieldValue(01, NativeSignatureFlags.None, 3, "2017.1.0")] 19 | [NativeFieldValue(02, NativeSignatureFlags.None, 4, "2018.1.0")] 20 | public static int TexCoord0 = 0; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/CoreModule/VerticalWrapMode.cs: -------------------------------------------------------------------------------- 1 | namespace MelonUnityEngine 2 | { 3 | internal enum VerticalWrapMode 4 | { 5 | Truncate, 6 | Overflow 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/Font.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnhollowerMini; 3 | 4 | namespace MelonUnityEngine 5 | { 6 | internal class Font : UnityObject 7 | { 8 | private static IntPtr m_get_material; 9 | 10 | static Font() 11 | { 12 | InternalClassPointerStore.NativeClassPtr = UnityInternals.GetClass("UnityEngine.TextRenderingModule.dll", "UnityEngine", "Font"); 13 | UnityInternals.runtime_class_init(InternalClassPointerStore.NativeClassPtr); 14 | 15 | m_get_material = UnityInternals.GetMethod(InternalClassPointerStore.NativeClassPtr, "get_material", "UnityEngine.Material"); 16 | } 17 | 18 | public Font(IntPtr ptr) : base(ptr) { } 19 | 20 | public unsafe Material material 21 | { 22 | get 23 | { 24 | UnityInternals.ObjectBaseToPtrNotNull(this); 25 | IntPtr returnedException = default; 26 | IntPtr intPtr = UnityInternals.runtime_invoke(Font.m_get_material, UnityInternals.ObjectBaseToPtrNotNull(this), (void**)0, ref returnedException); 27 | Il2CppException.RaiseExceptionIfNecessary(returnedException); 28 | return (intPtr != IntPtr.Zero) ? new Material(intPtr) : null; 29 | } 30 | // set 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/FontStyle.cs: -------------------------------------------------------------------------------- 1 | namespace MelonUnityEngine 2 | { 3 | internal enum FontStyle 4 | { 5 | Normal, 6 | Bold, 7 | Italic, 8 | BoldAndItalic 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/UnityEngine/TextRenderingModule/TextAnchor.cs: -------------------------------------------------------------------------------- 1 | namespace MelonUnityEngine 2 | { 3 | internal enum TextAnchor 4 | { 5 | UpperLeft, 6 | UpperCenter, 7 | UpperRight, 8 | MiddleLeft, 9 | MiddleCenter, 10 | MiddleRight, 11 | LowerLeft, 12 | LowerCenter, 13 | LowerRight 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/Windows/DropFile.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Windows 4 | { 5 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] 6 | class DropFile 7 | { 8 | uint pFiles = 14; 9 | public Point pt; 10 | public bool fNC; 11 | bool fWide = true; 12 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 300)] // Max path size on windows is 260 13 | public string file = ""; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/Windows/Msg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Windows 5 | { 6 | [StructLayout(LayoutKind.Sequential)] 7 | internal struct Msg 8 | { 9 | public IntPtr hwnd; 10 | public WindowMessage message; 11 | public IntPtr wParam; 12 | public IntPtr lParam; 13 | public uint time; 14 | public Point pt; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/Windows/Point.cs: -------------------------------------------------------------------------------- 1 | namespace Windows 2 | { 3 | internal struct Point 4 | { 5 | public int x; 6 | public int y; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/Windows/User32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Windows 5 | { 6 | internal static class User32 7 | { 8 | [DllImport("user32.dll")] 9 | public static extern bool PeekMessage(out Msg lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg); 10 | 11 | [DllImport("user32.dll")] 12 | public static extern bool TranslateMessage([In] ref Msg lpMsg); 13 | 14 | [DllImport("user32.dll")] 15 | public static extern IntPtr DispatchMessage([In] ref Msg lpmsg); 16 | 17 | [DllImport("user32.dll", SetLastError = false)] 18 | public static extern IntPtr GetMessageExtraInfo(); 19 | 20 | [DllImport("user32.dll", ExactSpelling = true)] 21 | public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc); 22 | public delegate void TimerProc(IntPtr hWnd, uint uMsg, IntPtr nIDEvent, uint dwTime); 23 | 24 | [DllImport("user32.dll", ExactSpelling = true)] 25 | public static extern bool KillTimer(IntPtr hWnd, IntPtr uIDEvent); 26 | 27 | [DllImport("user32.dll")] 28 | public static extern IntPtr SetClipboardData(uint uFormat, ref DropFile hMem); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/mgGif/Image.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MelonUnityEngine; 3 | 4 | namespace mgGif 5 | { 6 | internal class Image : ICloneable 7 | { 8 | public int Width; 9 | public int Height; 10 | public int Delay; // milliseconds 11 | public Color32[] RawImage; 12 | 13 | public Image() { } 14 | 15 | public Image(Image img) 16 | { 17 | Width = img.Width; 18 | Height = img.Height; 19 | Delay = img.Delay; 20 | RawImage = img.RawImage != null ? (Color32[])img.RawImage.Clone() : null; 21 | } 22 | 23 | public object Clone() => new Image(this); 24 | 25 | public Texture2D CreateTexture(FilterMode filterMode = FilterMode.Bilinear) 26 | { 27 | var tex = new Texture2D(Width, Height); 28 | tex.filterMode = filterMode; 29 | 30 | Color[] colors = new Color[RawImage.Length]; 31 | for (int i = 0; i < colors.Length; i++) 32 | colors[i] = RawImage[i]; 33 | 34 | tex.SetPixels(colors); 35 | tex.Apply(); 36 | 37 | return tex; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Dependencies/MelonStartScreen/mgGif/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Gwaredd Mountain 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Dependencies/SupportModules/Il2Cpp/Libs/Il2CppSystem.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/Dependencies/SupportModules/Il2Cpp/Libs/Il2CppSystem.dll -------------------------------------------------------------------------------- /Dependencies/SupportModules/Il2Cpp/Libs/Il2Cppmscorlib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/Dependencies/SupportModules/Il2Cpp/Libs/Il2Cppmscorlib.dll -------------------------------------------------------------------------------- /Dependencies/SupportModules/Il2Cpp/Libs/UnityEngine.CoreModule.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/Dependencies/SupportModules/Il2Cpp/Libs/UnityEngine.CoreModule.dll -------------------------------------------------------------------------------- /Dependencies/SupportModules/Mono/Libs/UnityEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/Dependencies/SupportModules/Mono/Libs/UnityEngine.dll -------------------------------------------------------------------------------- /Dependencies/SupportModules/Mono/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using MelonLoader.Support.Preferences; 4 | using UnityEngine; 5 | 6 | [assembly: MelonLoader.PatchShield] 7 | 8 | namespace MelonLoader.Support 9 | { 10 | internal static class Main 11 | { 12 | internal static ISupportModule_From Interface = null; 13 | internal static GameObject obj = null; 14 | internal static SM_Component component = null; 15 | 16 | private static ISupportModule_To Initialize(ISupportModule_From interface_from) 17 | { 18 | Interface = interface_from; 19 | UnityMappers.RegisterMappers(); 20 | 21 | if (IsUnity53OrLower()) 22 | SM_Component.Create(); 23 | else 24 | SceneHandler.Init(); 25 | 26 | return new SupportModule_To(); 27 | } 28 | 29 | private static bool IsUnity53OrLower() 30 | { 31 | try 32 | { 33 | Assembly unityengine = Assembly.Load("UnityEngine"); 34 | if (unityengine == null) 35 | return true; 36 | Type scenemanager = unityengine.GetType("UnityEngine.SceneManagement.SceneManager"); 37 | if (scenemanager == null) 38 | return true; 39 | EventInfo sceneLoaded = scenemanager.GetEvent("sceneLoaded"); 40 | if (sceneLoaded == null) 41 | return true; 42 | return false; 43 | } 44 | catch { return true; } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Dependencies/SupportModules/Mono/Mono.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | MelonLoader.Support 4 | net35 5 | true 6 | $(MLOutDir)/MelonLoader/Dependencies/SupportModules 7 | true 8 | portable 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Dependencies/SupportModules/SupportModule_To.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace MelonLoader.Support 6 | { 7 | internal class SupportModule_To : ISupportModule_To 8 | { 9 | internal static readonly List QueuedCoroutines = new List(); 10 | public object StartCoroutine(IEnumerator coroutine) 11 | { 12 | if (Main.component != null) 13 | #if SM_Il2Cpp 14 | return Main.component.StartCoroutine(new Il2CppSystem.Collections.IEnumerator(new MonoEnumeratorWrapper(coroutine).Pointer)); 15 | #else 16 | return Main.component.StartCoroutine(coroutine); 17 | #endif 18 | QueuedCoroutines.Add(coroutine); 19 | return coroutine; 20 | } 21 | public void StopCoroutine(object coroutineToken) 22 | { 23 | if (Main.component == null) 24 | QueuedCoroutines.Remove(coroutineToken as IEnumerator); 25 | else 26 | Main.component.StopCoroutine(coroutineToken as Coroutine); 27 | } 28 | public void UnityDebugLog(string msg) => Debug.Log(msg); 29 | } 30 | } -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Deps/linux-bionic-arm64/libdobby.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/MelonLoader.Bootstrap/Deps/linux-bionic-arm64/libdobby.a -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Deps/linux-bionic-arm64/libplthook.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/MelonLoader.Bootstrap/Deps/linux-bionic-arm64/libplthook.a -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Deps/linux-x64/libdobby.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/MelonLoader.Bootstrap/Deps/linux-x64/libdobby.a -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Deps/linux-x64/libplthook.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/MelonLoader.Bootstrap/Deps/linux-x64/libplthook.a -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Deps/osx-x64/libdobby.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/MelonLoader.Bootstrap/Deps/osx-x64/libdobby.a -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Deps/osx-x64/libplthook.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/MelonLoader.Bootstrap/Deps/osx-x64/libplthook.a -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Deps/win-x64/dobby.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/MelonLoader.Bootstrap/Deps/win-x64/dobby.lib -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Deps/win-x64/plthook.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/MelonLoader.Bootstrap/Deps/win-x64/plthook.lib -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Deps/win-x86/dobby.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/MelonLoader.Bootstrap/Deps/win-x86/dobby.lib -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Deps/win-x86/plthook.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/MelonLoader.Bootstrap/Deps/win-x86/plthook.lib -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/InternalLogger.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader.Bootstrap.Logging; 2 | using MelonLoader.Logging; 3 | 4 | namespace MelonLoader.Bootstrap; 5 | 6 | internal class InternalLogger(ColorARGB sectionColor, string sectionName) 7 | { 8 | public void Msg(string msg) 9 | { 10 | MelonLogger.Log(ColorARGB.LightGray, msg, sectionColor, sectionName); 11 | } 12 | 13 | public void Error(string msg) 14 | { 15 | MelonLogger.LogError(msg, sectionName); 16 | } 17 | 18 | public void Warning(string msg) 19 | { 20 | MelonLogger.LogWarning(msg, sectionName); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Logging/PastelExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using MelonLoader.Logging; 3 | using Pastel; 4 | 5 | namespace MelonLoader.Bootstrap.Logging; 6 | 7 | internal static class PastelExtensions 8 | { 9 | private static string _colorReset = new ReadOnlySpan().Pastel(Color.FromArgb(255, 211, 211, 211)); 10 | 11 | internal static string Pastel(this string input, ColorARGB color) 12 | { 13 | return input.AsSpan().Pastel(color); 14 | } 15 | 16 | internal static string Pastel(in this ReadOnlySpan input, ColorARGB color) 17 | { 18 | // TODO: loader config option to disable color 19 | return input.Pastel(Color.FromArgb(color.R, color.G, color.B)) + _colorReset; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/MelonDebug.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader.Bootstrap.Logging; 2 | using MelonLoader.Logging; 3 | 4 | namespace MelonLoader.Bootstrap; 5 | 6 | internal static class MelonDebug 7 | { 8 | private static readonly InternalLogger logger = new(ColorARGB.CornflowerBlue, "BS DEBUG"); 9 | 10 | public static void Log(string msg) 11 | { 12 | if (!LoaderConfig.Current.Loader.DebugMode) 13 | return; 14 | 15 | logger.Msg(msg); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/OSXEntry/osxentry.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" 4 | { 5 | void Init(); 6 | } 7 | 8 | #define DYLD_INTERPOSE(_replacement,_replacee) \ 9 | __attribute__((used)) static struct{ const void* replacement; const void* replacee; } _interpose_##_replacee \ 10 | __attribute__ ((section ("__DATA,__interpose"))) = { (const void*)(unsigned long)&_replacement, (const void*)(unsigned long)&_replacee }; 11 | 12 | int SetRlimitHook(int resource, rlimit* rlp) 13 | { 14 | int result = setrlimit(resource, rlp); 15 | Init(); 16 | return result; 17 | } 18 | 19 | DYLD_INTERPOSE(SetRlimitHook, setrlimit) 20 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Proxy/Exports/D3D8Exports.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS 2 | using System.Runtime.InteropServices; 3 | 4 | namespace MelonLoader.Bootstrap.Proxy.Exports; 5 | 6 | internal static class D3D8Exports 7 | { 8 | [UnmanagedCallersOnly(EntryPoint = "ImplDirect3DCreate8")] 9 | public static void ImplDirect3DCreate8() { } 10 | [UnmanagedCallersOnly(EntryPoint = "ImplDirect3D8EnableMaximizedWindowedModeShim")] 11 | public static void ImplDirect3D8EnableMaximizedWindowedModeShim() { } 12 | [UnmanagedCallersOnly(EntryPoint = "ImplValidatePixelShader")] 13 | public static void ImplValidatePixelShader() { } 14 | [UnmanagedCallersOnly(EntryPoint = "ImplValidateVertexShader")] 15 | public static void ImplValidateVertexShader() { } 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Proxy/Exports/DInput8Exports.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS 2 | using System.Runtime.InteropServices; 3 | 4 | namespace MelonLoader.Bootstrap.Proxy.Exports; 5 | 6 | internal static class DInput8Exports 7 | { 8 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectInput8Create")] 9 | public static void ImplDirectInput8Create() { } 10 | } 11 | #endif 12 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Proxy/Exports/DInputExports.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS 2 | using System.Runtime.InteropServices; 3 | 4 | namespace MelonLoader.Bootstrap.Proxy.Exports; 5 | 6 | internal static class DInputExports 7 | { 8 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectInputCreateA")] 9 | public static void ImplDirectInputCreateA() { } 10 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectInputCreateEx")] 11 | public static void ImplDirectInputCreateEx() { } 12 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectInputCreateW")] 13 | public static void ImplDirectInputCreateW() { } 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Proxy/Exports/DSoundExports.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS 2 | using System.Runtime.InteropServices; 3 | 4 | namespace MelonLoader.Bootstrap.Proxy.Exports; 5 | 6 | internal static class DSoundExports 7 | { 8 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectSoundCaptureCreate")] 9 | public static void ImplDirectSoundCaptureCreate() { } 10 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectSoundCaptureCreate8")] 11 | public static void ImplDirectSoundCaptureCreate8() { } 12 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectSoundCaptureEnumerateA")] 13 | public static void ImplDirectSoundCaptureEnumerateA() { } 14 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectSoundCaptureEnumerateW")] 15 | public static void ImplDirectSoundCaptureEnumerateW() { } 16 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectSoundCreate")] 17 | public static void ImplDirectSoundCreate() { } 18 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectSoundCreate8")] 19 | public static void ImplDirectSoundCreate8() { } 20 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectSoundEnumerateA")] 21 | public static void ImplDirectSoundEnumerateA() { } 22 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectSoundEnumerateW")] 23 | public static void ImplDirectSoundEnumerateW() { } 24 | [UnmanagedCallersOnly(EntryPoint = "ImplDirectSoundFullDuplexCreate")] 25 | public static void ImplDirectSoundFullDuplexCreate() { } 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Proxy/Exports/SharedExports.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS 2 | using System.Runtime.InteropServices; 3 | 4 | namespace MelonLoader.Bootstrap.Proxy.Exports; 5 | 6 | internal static class SharedExports 7 | { 8 | [UnmanagedCallersOnly(EntryPoint = "ImplDllCanUnloadNow")] 9 | public static void ImplDllCanUnloadNow() { } 10 | [UnmanagedCallersOnly(EntryPoint = "ImplDllGetClassObject")] 11 | public static void ImplDllGetClassObject() { } 12 | [UnmanagedCallersOnly(EntryPoint = "ImplDllRegisterServer")] 13 | public static void ImplDllRegisterServer() { } 14 | [UnmanagedCallersOnly(EntryPoint = "ImplDllUnregisterServer")] 15 | public static void ImplDllUnregisterServer() { } 16 | [UnmanagedCallersOnly(EntryPoint = "ImplPrivate1")] 17 | public static void ImplPrivate1() { } 18 | [UnmanagedCallersOnly(EntryPoint = "ImplDebugSetMute")] 19 | public static void ImplDebugSetMute() { } 20 | [UnmanagedCallersOnly(EntryPoint = "ImplDebugSetLevel")] 21 | public static void ImplDebugSetLevel() { } 22 | [UnmanagedCallersOnly(EntryPoint = "ImplGetDeviceID")] 23 | public static void ImplGetDeviceID() { } 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/SharedDelegates.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader.Logging; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace MelonLoader.Bootstrap; 5 | 6 | [UnmanagedFunctionPointer(CallingConvention.StdCall)] 7 | internal unsafe delegate void NativeHookFn(nint* target, nint detour); 8 | 9 | [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] 10 | internal unsafe delegate void LogMsgFn(ColorARGB* msgColor, string msg, int msgLength, ColorARGB* sectionColor, string section, int sectionLength); 11 | 12 | [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] 13 | internal unsafe delegate void LogErrorFn(string msg, int msgLength, string section, int sectionLength, bool warning); 14 | 15 | [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] 16 | internal unsafe delegate void LogMelonInfoFn(ColorARGB* nameColor, string name, int nameLength, string info, int infoLength); 17 | 18 | [UnmanagedFunctionPointer(CallingConvention.StdCall)] 19 | internal delegate nint PtrRetFn(); 20 | 21 | [UnmanagedFunctionPointer(CallingConvention.StdCall)] 22 | internal delegate nint CastManagedAssemblyPtrFn(nint ptr); 23 | 24 | [UnmanagedFunctionPointer(CallingConvention.StdCall)] 25 | internal delegate void ActionFn(); 26 | 27 | [UnmanagedFunctionPointer(CallingConvention.StdCall)] 28 | [return: MarshalAs(UnmanagedType.U1)] 29 | internal delegate bool BoolRetFn(); 30 | 31 | [UnmanagedFunctionPointer(CallingConvention.StdCall)] 32 | internal delegate void GetLoaderConfigFn(ref LoaderConfig config); 33 | 34 | #if ANDROID 35 | [UnmanagedFunctionPointer(CallingConvention.StdCall)] 36 | internal delegate System.IntPtr GetJavaVM(); 37 | #endif -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/TrimmerRoots.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Utils/ArgParser.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader.Bootstrap.Utils; 2 | 3 | internal static class ArgParser 4 | { 5 | private static readonly List arguments; 6 | 7 | static ArgParser() 8 | { 9 | arguments = []; 10 | 11 | var args = Environment.GetCommandLineArgs(); 12 | 13 | for (var i = 1; i < args.Length; i++) 14 | { 15 | var arg = args[i]; 16 | 17 | if (arg.StartsWith("--")) 18 | { 19 | arg = arg[2..]; 20 | } 21 | else if (arg.StartsWith('-')) 22 | { 23 | arg = arg[1..]; 24 | } 25 | else 26 | { 27 | continue; 28 | } 29 | 30 | string? value = null; 31 | 32 | var eqIdx = arg.IndexOf('='); 33 | if (eqIdx >= 0) 34 | { 35 | value = arg[(eqIdx + 1)..]; 36 | arg = arg[..eqIdx]; 37 | } 38 | else if (i + 1 < args.Length) 39 | { 40 | var next = args[i + 1]; 41 | 42 | if (!next.StartsWith('-')) 43 | { 44 | value = next; 45 | i++; 46 | } 47 | } 48 | 49 | arguments.Add(new() 50 | { 51 | Name = arg, 52 | Value = value 53 | }); 54 | } 55 | } 56 | 57 | public static bool IsDefined(string longName) 58 | { 59 | return arguments.Exists(x => x.Name.Equals(longName, StringComparison.OrdinalIgnoreCase)); 60 | } 61 | 62 | public static string? GetValue(string longName) 63 | { 64 | var arg = arguments.Find(x => x.Name.Equals(longName, StringComparison.OrdinalIgnoreCase)); 65 | 66 | return arg?.Value; 67 | } 68 | 69 | private class Argument 70 | { 71 | public required string Name { get; init; } 72 | public string? Value { get; init; } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Utils/NativeFunc.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace MelonLoader.Bootstrap.Utils; 5 | 6 | internal static class NativeFunc 7 | { 8 | public static T? GetExport(nint hModule, string name) where T : Delegate 9 | { 10 | return !NativeLibrary.TryGetExport(hModule, name, out var export) ? null : Marshal.GetDelegateForFunctionPointer(export); 11 | } 12 | 13 | public static bool GetExport(nint hModule, string name, [NotNullWhen(true)] out T? func) where T : Delegate 14 | { 15 | func = GetExport(hModule, name); 16 | return func != null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/Utils/WineUtils.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS 2 | using System.Runtime.InteropServices; 3 | #endif 4 | 5 | namespace MelonLoader.Bootstrap.Utils; 6 | 7 | internal static class WineUtils 8 | { 9 | public static bool IsWine { get; } 10 | 11 | static WineUtils() 12 | { 13 | #if WINDOWS 14 | if (NativeLibrary.TryLoad("ntdll.dll", out var ntdll) && NativeLibrary.TryGetExport(ntdll, "wine_get_version", out _)) 15 | IsWine = true; 16 | #endif 17 | #if LINUX || ANDROID 18 | IsWine = false; 19 | #endif 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/androidexports.def: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | DotNetRuntimeDebugHeader; 4 | NativeHookAttach; 5 | NativeHookDetach; 6 | LogMsg; 7 | LogError; 8 | LogMelonInfo; 9 | MonoInstallHooks; 10 | MonoGetDomainPtr; 11 | MonoGetRuntimeHandle; 12 | IsConsoleOpen; 13 | GetLoaderConfig; 14 | GetJavaVM; 15 | JNI_OnLoad; 16 | local: *; 17 | }; 18 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/linuxexports.def: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | DotNetRuntimeDebugHeader; 4 | __libc_start_main; 5 | NativeHookAttach; 6 | NativeHookDetach; 7 | LogMsg; 8 | LogError; 9 | LogMelonInfo; 10 | MonoInstallHooks; 11 | MonoGetDomainPtr; 12 | MonoGetRuntimeHandle; 13 | IsConsoleOpen; 14 | GetLoaderConfig; 15 | local: *; 16 | }; 17 | -------------------------------------------------------------------------------- /MelonLoader.Bootstrap/osxexports.def: -------------------------------------------------------------------------------- 1 | _DotNetRuntimeDebugHeader 2 | _Init 3 | _NativeHookAttach 4 | _NativeHookDetach 5 | _LogMsg 6 | _LogError 7 | _LogMelonInfo 8 | _MonoInstallHooks 9 | _MonoGetDomainPtr 10 | _MonoGetRuntimeHandle 11 | _IsConsoleOpen 12 | _GetLoaderConfig 13 | -------------------------------------------------------------------------------- /MelonLoader.NativeHost/MelonLoader.NativeHost.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6 5 | enable 6 | enable 7 | $(MLOutDir)/MelonLoader 8 | true 9 | True 10 | embedded 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /MelonLoader/Assertions/LemonAssertException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.Assertions 4 | { 5 | public class LemonAssertException : Exception 6 | { 7 | private string UserMessage; 8 | 9 | public LemonAssertException(string exceptionMsg, string userMessage) : base(exceptionMsg) 10 | => UserMessage = userMessage; 11 | 12 | public override string Message 13 | { 14 | get 15 | { 16 | if (!string.IsNullOrEmpty(UserMessage)) 17 | return $"{base.Message}\n{UserMessage}"; 18 | return base.Message; 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MelonLoader/Assertions/LemonAssertMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace MelonLoader.Assertions 5 | { 6 | public static class LemonAssertMapping 7 | { 8 | internal static Dictionary IsNull = new Dictionary(); 9 | internal static Dictionary IsEqual = new Dictionary(); 10 | 11 | internal static void Setup() 12 | { 13 | Register_IsNull(IsNull_object); 14 | Register_IsNull(IsNull_string); 15 | Register_IsEqual(IsEqual_object); 16 | } 17 | 18 | public static void Register_IsNull(Func method) 19 | => Register(method, ref IsNull); 20 | public static void Register_IsEqual(Func method) 21 | => Register(method, ref IsEqual); 22 | private static void Register(Delegate method, ref Dictionary tbl) 23 | { 24 | if (method == null) 25 | throw new NullReferenceException(nameof(method)); 26 | Type inputType = typeof(T); 27 | if (tbl.ContainsKey(inputType)) 28 | return; 29 | lock (tbl) 30 | tbl[inputType] = method; 31 | } 32 | 33 | private static bool IsNull_object(object obj) 34 | => obj == null; 35 | private static bool IsNull_string(string obj) 36 | => string.IsNullOrEmpty(obj); 37 | private static bool IsEqual_object(object obj, object obj2) 38 | { 39 | if (obj == null) 40 | return obj2 == null; 41 | if (obj2 == null) 42 | return obj == null; 43 | return obj.Equals(obj2); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /MelonLoader/Attributes/HarmonyDontPatchAllAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly)] 6 | public class HarmonyDontPatchAllAttribute : Attribute { public HarmonyDontPatchAllAttribute() { } } 7 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonAdditionalCreditsAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader { 4 | [AttributeUsage(AttributeTargets.Assembly)] 5 | public class MelonAdditionalCreditsAttribute : Attribute { 6 | /// 7 | /// Any additional credits that the mod author might want to include 8 | /// 9 | public string Credits { get; internal set; } 10 | 11 | /// 12 | /// AdditionalCredits constructor 13 | /// 14 | /// The additional credits of the mod 15 | public MelonAdditionalCreditsAttribute(string credits) { 16 | Credits = credits; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonAdditionalDependenciesAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly)] 6 | public class MelonAdditionalDependenciesAttribute : Attribute 7 | { 8 | /// 9 | /// The (simple) assembly names of Additional Dependencies that aren't directly referenced but should still be regarded as important. 10 | /// 11 | public string[] AssemblyNames { get; internal set; } 12 | 13 | public MelonAdditionalDependenciesAttribute(params string[] assemblyNames) { AssemblyNames = assemblyNames; } 14 | } 15 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonAuthorColorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MelonLoader.Logging; 3 | using MelonLoader.Utils; 4 | 5 | namespace MelonLoader 6 | { 7 | [AttributeUsage(AttributeTargets.Assembly)] 8 | public class MelonAuthorColorAttribute : Attribute 9 | { 10 | /// 11 | /// Color of the Author Log. 12 | /// 13 | [Obsolete("Color is obsolete. Use DrawingColor for full Color support. This will be removed in a future update.", true)] 14 | public ConsoleColor Color 15 | { 16 | get => LoggerUtils.DrawingColorToConsoleColor(DrawingColor); 17 | set => DrawingColor = LoggerUtils.ConsoleColorToDrawingColor(value); 18 | } 19 | 20 | /// 21 | /// Color of the Author Log. 22 | /// 23 | public ColorARGB DrawingColor { get; internal set; } 24 | 25 | public MelonAuthorColorAttribute() 26 | => DrawingColor = MelonLogger.DefaultTextColor; 27 | 28 | [Obsolete("ConsoleColor is obsolete, use the (int, int, int, int) constructor instead. This will be removed in a future update.", true)] 29 | public MelonAuthorColorAttribute(ConsoleColor color) 30 | => Color = ((color == ConsoleColor.Black) ? LoggerUtils.DrawingColorToConsoleColor(MelonLogger.DefaultMelonColor) : color); 31 | 32 | public MelonAuthorColorAttribute(int alpha, int red, int green, int blue) 33 | => DrawingColor = ColorARGB.FromArgb((byte)alpha, (byte)red, (byte)green, (byte)blue); 34 | } 35 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonColorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MelonLoader.Logging; 3 | using MelonLoader.Utils; 4 | 5 | namespace MelonLoader 6 | { 7 | [AttributeUsage(AttributeTargets.Assembly)] 8 | public class MelonColorAttribute : Attribute 9 | { 10 | /// 11 | /// Color of the Melon. 12 | /// 13 | [Obsolete("Color is obsolete. Use DrawingColor for full Color support. This will be removed in a future update.", true)] 14 | public ConsoleColor Color 15 | { 16 | get => LoggerUtils.DrawingColorToConsoleColor(DrawingColor); 17 | set => DrawingColor = LoggerUtils.ConsoleColorToDrawingColor(value); 18 | } 19 | 20 | /// 21 | /// Color of the Author Log. 22 | /// 23 | public ColorARGB DrawingColor { get; internal set; } 24 | 25 | public MelonColorAttribute() 26 | => DrawingColor = MelonLogger.DefaultTextColor; 27 | 28 | [Obsolete("ConsoleColor is obsolete, use the (int, int, int, int) constructor instead. This will be removed in a future update.", true)] 29 | public MelonColorAttribute(ConsoleColor color) 30 | => Color = ((color == ConsoleColor.Black) ? LoggerUtils.DrawingColorToConsoleColor(MelonLogger.DefaultMelonColor) : color); 31 | 32 | public MelonColorAttribute(int alpha, int red, int green, int blue) 33 | => DrawingColor = ColorARGB.FromArgb((byte)alpha, (byte)red, (byte)green, (byte)blue); 34 | } 35 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonGameVersionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public class MelonGameVersionAttribute : Attribute 7 | { 8 | public MelonGameVersionAttribute(string version = null) 9 | => Version = version; 10 | 11 | /// 12 | /// Version of the Game. 13 | /// 14 | public string Version { get; internal set; } 15 | 16 | /// 17 | /// If the Attribute is set as Universal or not. 18 | /// 19 | public bool Universal { get => string.IsNullOrEmpty(Version); } 20 | } 21 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonIDAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly)] 6 | public class MelonIDAttribute : Attribute 7 | { 8 | /// ID of the Melon. 9 | public string ID { get; internal set; } 10 | 11 | public MelonIDAttribute(string id) 12 | => ID = id; 13 | public MelonIDAttribute(int id) 14 | => ID = id.ToString(); 15 | } 16 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonIncompatibleAssembliesAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly)] 6 | public class MelonIncompatibleAssembliesAttribute : Attribute 7 | { 8 | /// 9 | /// The (simple) assembly names of the mods that are incompatible. 10 | /// 11 | public string[] AssemblyNames { get; internal set; } 12 | 13 | public MelonIncompatibleAssembliesAttribute(params string[] assemblyNames) { AssemblyNames = assemblyNames; } 14 | } 15 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonOptionalDependenciesAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly)] 6 | public class MelonOptionalDependenciesAttribute : Attribute 7 | { 8 | /// 9 | /// The (simple) assembly names of the dependencies that should be regarded as optional. 10 | /// 11 | public string[] AssemblyNames { get; internal set; } 12 | 13 | public MelonOptionalDependenciesAttribute(params string[] assemblyNames) { AssemblyNames = assemblyNames; } 14 | } 15 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonPlatformAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace MelonLoader 5 | { 6 | [AttributeUsage(AttributeTargets.Assembly)] 7 | public class MelonPlatformAttribute : Attribute 8 | { 9 | public MelonPlatformAttribute(params CompatiblePlatforms[] platforms) => Platforms = platforms; 10 | 11 | // Enum for Melon Platform Compatibility. 12 | public enum CompatiblePlatforms 13 | { 14 | UNIVERSAL, 15 | WINDOWS_X86, 16 | WINDOWS_X64 17 | }; 18 | 19 | // Platforms Compatible with the Melon. 20 | public CompatiblePlatforms[] Platforms { get; internal set; } 21 | 22 | public bool IsCompatible(CompatiblePlatforms platform) 23 | => Platforms == null || Platforms.Length == 0 || Platforms.Contains(platform); 24 | } 25 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonPlatformDomainAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly)] 6 | public class MelonPlatformDomainAttribute : Attribute 7 | { 8 | public MelonPlatformDomainAttribute(CompatibleDomains domain = CompatibleDomains.UNIVERSAL) => Domain = domain; 9 | 10 | // Enum for Melon Platform Domain Compatibility. 11 | public enum CompatibleDomains 12 | { 13 | UNIVERSAL, 14 | MONO, 15 | IL2CPP 16 | }; 17 | 18 | // Platform Domain Compatibility of the Melon. 19 | public CompatibleDomains Domain { get; internal set; } 20 | 21 | public bool IsCompatible(CompatibleDomains domain) 22 | => Domain == CompatibleDomains.UNIVERSAL || domain == CompatibleDomains.UNIVERSAL || Domain == domain; 23 | } 24 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonPriorityAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly)] 6 | public class MelonPriorityAttribute : Attribute 7 | { 8 | /// 9 | /// Priority of the Melon. 10 | /// 11 | public int Priority; 12 | 13 | public MelonPriorityAttribute(int priority = 0) => Priority = priority; 14 | } 15 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/MelonProcessAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public class MelonProcessAttribute : Attribute 7 | { 8 | public MelonProcessAttribute(string exe_name = null) 9 | => EXE_Name = RemoveExtension(exe_name); 10 | 11 | /// 12 | /// Name of the Game's Executable without the '.exe' extension. 13 | /// 14 | public string EXE_Name { get; internal set; } 15 | 16 | /// 17 | /// If the Attribute is set as Universal or not. 18 | /// 19 | public bool Universal 20 | => string.IsNullOrEmpty(EXE_Name); 21 | 22 | /// 23 | /// Checks if the Attribute is compatible with or not. 24 | /// 25 | public bool IsCompatible(string processName) 26 | => Universal || string.IsNullOrEmpty(processName) || (RemoveExtension(processName) == EXE_Name); 27 | 28 | private string RemoveExtension(string name) 29 | => name == null ? null : (name.EndsWith(".exe") ? name.Remove(name.Length - 4) : name); 30 | 31 | } 32 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/RegisterTypeInIl2Cpp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace MelonLoader 7 | { 8 | [AttributeUsage(AttributeTargets.Class)] 9 | public class RegisterTypeInIl2Cpp : Attribute //Naming violation? 10 | { 11 | internal static List registrationQueue = new List(); 12 | internal static bool ready; 13 | internal bool LogSuccess = true; 14 | 15 | public RegisterTypeInIl2Cpp() { } 16 | public RegisterTypeInIl2Cpp(bool logSuccess) { LogSuccess = logSuccess; } 17 | 18 | public static void RegisterAssembly(Assembly asm) 19 | { 20 | if (!MelonUtils.IsGameIl2Cpp()) 21 | return; 22 | 23 | if (!ready) 24 | { 25 | registrationQueue.Add(asm); 26 | return; 27 | } 28 | 29 | IEnumerable typeTbl = asm.GetValidTypes(); 30 | if ((typeTbl == null) || (typeTbl.Count() <= 0)) 31 | return; 32 | foreach (Type type in typeTbl) 33 | { 34 | object[] attTbl = type.GetCustomAttributes(typeof(RegisterTypeInIl2Cpp), false); 35 | if ((attTbl == null) || (attTbl.Length <= 0)) 36 | continue; 37 | RegisterTypeInIl2Cpp att = (RegisterTypeInIl2Cpp)attTbl[0]; 38 | if (att == null) 39 | continue; 40 | InteropSupport.RegisterTypeInIl2CppDomain(type, att.LogSuccess); 41 | } 42 | } 43 | 44 | internal static void SetReady() 45 | { 46 | ready = true; 47 | 48 | if (registrationQueue == null) 49 | return; 50 | 51 | foreach (var asm in registrationQueue) 52 | RegisterAssembly(asm); 53 | 54 | registrationQueue = null; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /MelonLoader/Attributes/VerifyLoaderBuildAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly)] 6 | public class VerifyLoaderBuildAttribute : Attribute 7 | { 8 | /// 9 | /// Build HashCode of MelonLoader. 10 | /// 11 | public string HashCode { get; internal set; } 12 | 13 | public VerifyLoaderBuildAttribute(string hashcode) { HashCode = hashcode; } 14 | 15 | public bool IsCompatible(string hashCode) 16 | => string.IsNullOrEmpty(HashCode) || string.IsNullOrEmpty(hashCode) || HashCode == hashCode; 17 | } 18 | } -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.Pdb.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.NativePdbReader))] 4 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.NativePdbWriter))] 5 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.NativePdbReaderProvider))] 6 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.PdbReaderProvider))] 7 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.NativePdbWriterProvider))] 8 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Pdb.PdbWriterProvider))] 9 | 10 | #if !NET6_0 11 | [assembly: TypeForwardedTo(typeof(Microsoft.Cci.ILocalScope))] 12 | [assembly: TypeForwardedTo(typeof(Microsoft.Cci.INamespaceScope))] 13 | [assembly: TypeForwardedTo(typeof(Microsoft.Cci.IUsedNamespace))] 14 | [assembly: TypeForwardedTo(typeof(Microsoft.Cci.IName))] 15 | #endif 16 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ForwardingAttributes/Mono.Cecil.Rocks.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.DocCommentId))] 4 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.IILVisitor))] 5 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.ILParser))] 6 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.MethodBodyRocks))] 7 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.MethodDefinitionRocks))] 8 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.ModuleDefinitionRocks))] 9 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.ParameterReferenceRocks))] 10 | #if !NET6_0 11 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.SecurityDeclarationRocks))] 12 | #endif 13 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.TypeDefinitionRocks))] 14 | [assembly: TypeForwardedTo(typeof(Mono.Cecil.Rocks.TypeReferenceRocks))] 15 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Harmony/Extras/DelegateTypeFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Harmony 2 | { 3 | public class DelegateTypeFactory : HarmonyLib.DelegateTypeFactory { } 4 | } -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Harmony/Extras/MethodInvoker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Reflection.Emit; 4 | 5 | namespace Harmony 6 | { 7 | public delegate object FastInvokeHandler(object target, object[] paramters); 8 | public class MethodInvoker 9 | { 10 | public static FastInvokeHandler GetHandler(DynamicMethod methodInfo, Module module) => 11 | ConvertFastInvokeHandler(HarmonyLib.MethodInvoker.GetHandler(methodInfo)); 12 | public static FastInvokeHandler GetHandler(MethodInfo methodInfo) => 13 | ConvertFastInvokeHandler(HarmonyLib.MethodInvoker.GetHandler(methodInfo)); 14 | private static FastInvokeHandler ConvertFastInvokeHandler(HarmonyLib.FastInvokeHandler sourceDelegate) => 15 | (FastInvokeHandler)Delegate.CreateDelegate(typeof(FastInvokeHandler), sourceDelegate.Target, sourceDelegate.Method); 16 | } 17 | } -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Harmony/HarmonyInstance.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Reflection.Emit; 4 | #pragma warning disable 0618 5 | 6 | namespace Harmony 7 | { 8 | [Obsolete("Harmony.HarmonyInstance is obsolete. Please use HarmonyLib.Harmony instead. This will be removed in a future update.", true)] 9 | public class HarmonyInstance : HarmonyLib.Harmony 10 | { 11 | [Obsolete("Harmony.HarmonyInstance is obsolete. Please use HarmonyLib.Harmony instead. This will be removed in a future update.", true)] 12 | public HarmonyInstance(string id) : base(id) { } 13 | 14 | [Obsolete("Harmony.HarmonyInstance.Create is obsolete. Please use the HarmonyLib.Harmony Constructor instead. This will be removed in a future update.", true)] 15 | public static HarmonyInstance Create(string id) 16 | { 17 | if (id == null) throw new Exception("id cannot be null"); 18 | return new HarmonyInstance(id); 19 | } 20 | 21 | [Obsolete("Harmony.HarmonyInstance.Patch is obsolete. Please use HarmonyLib.Harmony.Patch instead. This will be removed in a future update.", true)] 22 | public DynamicMethod Patch(MethodBase original, HarmonyMethod prefix = null, HarmonyMethod postfix = null, HarmonyMethod transpiler = null) 23 | { 24 | base.Patch(original, prefix, postfix, transpiler); 25 | return null; 26 | } 27 | 28 | public void Unpatch(MethodBase original, HarmonyPatchType type, string harmonyID = null) => Unpatch(original, (HarmonyLib.HarmonyPatchType)type, harmonyID); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Harmony/Tools/SymbolExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | using System.Reflection; 4 | 5 | namespace Harmony 6 | { 7 | [Obsolete("Harmony.SymbolExtensions is Only Here for Compatibility Reasons. Please use HarmonyLib.SymbolExtensions instead. This will be removed in a future update.", true)] 8 | public static class SymbolExtensions 9 | { 10 | [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)] 11 | public static MethodInfo GetMethodInfo(Expression expression) => HarmonyLib.SymbolExtensions.GetMethodInfo(expression); 12 | [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)] 13 | public static MethodInfo GetMethodInfo(Expression> expression) => GetMethodInfo((LambdaExpression)expression); 14 | [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)] 15 | public static MethodInfo GetMethodInfo(Expression> expression) => GetMethodInfo((LambdaExpression)expression); 16 | [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)] 17 | public static MethodInfo GetMethodInfo(LambdaExpression expression) => HarmonyLib.SymbolExtensions.GetMethodInfo(expression); 18 | } 19 | } -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Checksum/IChecksum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum 4 | { 5 | /// 6 | /// Interface to compute a data checksum used by checked input/output streams. 7 | /// A data checksum can be updated by one byte or with a byte array. After each 8 | /// update the value of the current checksum can be returned by calling 9 | /// getValue. The complete checksum object can also be reset 10 | /// so it can be used again with new data. 11 | /// 12 | [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] 13 | public interface IChecksum 14 | { 15 | /// 16 | /// Resets the data checksum as if no update was ever called. 17 | /// 18 | void Reset(); 19 | 20 | /// 21 | /// Returns the data checksum computed so far. 22 | /// 23 | long Value 24 | { 25 | get; 26 | } 27 | 28 | /// 29 | /// Adds one byte to the data checksum. 30 | /// 31 | /// 32 | /// the data value to add. The high byte of the int is ignored. 33 | /// 34 | void Update(int bval); 35 | 36 | /// 37 | /// Updates the data checksum with the bytes taken from the array. 38 | /// 39 | /// 40 | /// buffer an array of bytes 41 | /// 42 | void Update(byte[] buffer); 43 | 44 | /// 45 | /// Adds the byte array to the data checksum. 46 | /// 47 | /// 48 | /// The chunk of data to add 49 | /// 50 | void Update(ArraySegment segment); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/EmptyRefs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.ICSharpCode.SharpZipLib.Core 4 | { 5 | [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] 6 | internal static class Empty 7 | { 8 | internal static class EmptyArray 9 | { 10 | public static readonly T[] Value = new T[0]; 11 | } 12 | public static T[] Array() => EmptyArray.Value; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/INameTransform.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.ICSharpCode.SharpZipLib.Core 4 | { 5 | /// 6 | /// INameTransform defines how file system names are transformed for use with archives, or vice versa. 7 | /// 8 | [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] 9 | public interface INameTransform 10 | { 11 | /// 12 | /// Given a file name determine the transformed value. 13 | /// 14 | /// The name to transform. 15 | /// The transformed file name. 16 | string TransformFile(string name); 17 | 18 | /// 19 | /// Given a directory name determine the transformed value. 20 | /// 21 | /// The name to transform. 22 | /// The transformed directory name 23 | string TransformDirectory(string name); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Core/IScanFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.ICSharpCode.SharpZipLib.Core 4 | { 5 | /// 6 | /// Scanning filters support filtering of names. 7 | /// 8 | [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] 9 | public interface IScanFilter 10 | { 11 | /// 12 | /// Test a name to see if it 'matches' the filter. 13 | /// 14 | /// The name to test. 15 | /// Returns true if the name matches the filter, false if it does not match. 16 | bool IsMatch(string name); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright © 2000-2018 SharpZipLib Contributors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | software and associated documentation files (the "Software"), to deal in the Software 5 | without restriction, including without limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 7 | to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or 10 | substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 13 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 14 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 15 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 16 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 17 | DEALINGS IN THE SOFTWARE. 18 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Lzw/LzwConstants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.ICSharpCode.SharpZipLib.Lzw 4 | { 5 | /// 6 | /// This class contains constants used for LZW 7 | /// 8 | [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] 9 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "kept for backwards compatibility")] 10 | sealed public class LzwConstants 11 | { 12 | /// 13 | /// Magic number found at start of LZW header: 0x1f 0x9d 14 | /// 15 | public const int MAGIC = 0x1f9d; 16 | 17 | /// 18 | /// Maximum number of bits per code 19 | /// 20 | public const int MAX_BITS = 16; 21 | 22 | /* 3rd header byte: 23 | * bit 0..4 Number of compression bits 24 | * bit 5 Extended header 25 | * bit 6 Free 26 | * bit 7 Block mode 27 | */ 28 | 29 | /// 30 | /// Mask for 'number of compression bits' 31 | /// 32 | public const int BIT_MASK = 0x1f; 33 | 34 | /// 35 | /// Indicates the presence of a fourth header byte 36 | /// 37 | public const int EXTENDED_MASK = 0x20; 38 | 39 | //public const int FREE_MASK = 0x40; 40 | 41 | /// 42 | /// Reserved bits 43 | /// 44 | public const int RESERVED_MASK = 0x60; 45 | 46 | /// 47 | /// Block compression: if table is full and compression rate is dropping, 48 | /// clear the dictionary. 49 | /// 50 | public const int BLOCK_MODE_MASK = 0x80; 51 | 52 | /// 53 | /// LZW file header size (in bytes) 54 | /// 55 | public const int HDR_SIZE = 3; 56 | 57 | /// 58 | /// Initial number of bits per code 59 | /// 60 | public const int INIT_BITS = 9; 61 | 62 | private LzwConstants() 63 | { 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Tar/TarException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace MelonLoader.ICSharpCode.SharpZipLib.Tar 5 | { 6 | /// 7 | /// TarException represents exceptions specific to Tar classes and code. 8 | /// 9 | [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] 10 | [Serializable] 11 | public class TarException : SharpZipBaseException 12 | { 13 | /// 14 | /// Initialise a new instance of . 15 | /// 16 | public TarException() 17 | { 18 | } 19 | 20 | /// 21 | /// Initialise a new instance of with its message string. 22 | /// 23 | /// A that describes the error. 24 | public TarException(string message) 25 | : base(message) 26 | { 27 | } 28 | 29 | /// 30 | /// Initialise a new instance of . 31 | /// 32 | /// A that describes the error. 33 | /// The that caused this exception. 34 | public TarException(string message, Exception innerException) 35 | : base(message, innerException) 36 | { 37 | } 38 | 39 | /// 40 | /// Initializes a new instance of the TarException class with serialized data. 41 | /// 42 | /// 43 | /// The System.Runtime.Serialization.SerializationInfo that holds the serialized 44 | /// object data about the exception being thrown. 45 | /// 46 | /// 47 | /// The System.Runtime.Serialization.StreamingContext that contains contextual information 48 | /// about the source or destination. 49 | /// 50 | protected TarException(SerializationInfo info, StreamingContext context) 51 | : base(info, context) 52 | { 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/Compression/DeflaterPending.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.ICSharpCode.SharpZipLib.Zip.Compression 4 | { 5 | /// 6 | /// This class stores the pending output of the Deflater. 7 | /// 8 | /// author of the original java version : Jochen Hoenicke 9 | /// 10 | [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] 11 | public class DeflaterPending : PendingBuffer 12 | { 13 | /// 14 | /// Construct instance with default buffer size 15 | /// 16 | public DeflaterPending() : base(DeflaterConstants.PENDING_BUF_SIZE) 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEncryptionMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.ICSharpCode.SharpZipLib.Zip 4 | { 5 | /// 6 | /// The method of encrypting entries when creating zip archives. 7 | /// 8 | [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] 9 | public enum ZipEncryptionMethod 10 | { 11 | /// 12 | /// No encryption will be used. 13 | /// 14 | None, 15 | 16 | /// 17 | /// Encrypt entries with ZipCrypto. 18 | /// 19 | ZipCrypto, 20 | 21 | /// 22 | /// Encrypt entries with AES 128. 23 | /// 24 | AES128, 25 | 26 | /// 27 | /// Encrypt entries with AES 256. 28 | /// 29 | AES256 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipEntryExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MelonLoader.ICSharpCode.SharpZipLib.Zip 6 | { 7 | /// 8 | /// General ZipEntry helper extensions 9 | /// 10 | [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] 11 | public static class ZipEntryExtensions 12 | { 13 | /// 14 | /// Efficiently check if a flag is set without enum un-/boxing 15 | /// 16 | /// 17 | /// 18 | /// Returns whether the flag was set 19 | public static bool HasFlag(this ZipEntry entry, GeneralBitFlags flag) 20 | => (entry.Flags & (int) flag) != 0; 21 | 22 | /// 23 | /// Efficiently set a flag without enum un-/boxing 24 | /// 25 | /// 26 | /// 27 | /// Whether the passed flag should be set (1) or cleared (0) 28 | public static void SetFlag(this ZipEntry entry, GeneralBitFlags flag, bool enabled = true) 29 | => entry.Flags = enabled 30 | ? entry.Flags | (int) flag 31 | : entry.Flags & ~(int) flag; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/ICSharpCode/SharpZipLib/Zip/ZipException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace MelonLoader.ICSharpCode.SharpZipLib.Zip 5 | { 6 | /// 7 | /// ZipException represents exceptions specific to Zip classes and code. 8 | /// 9 | [Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)] 10 | [Serializable] 11 | public class ZipException : SharpZipBaseException 12 | { 13 | /// 14 | /// Initialise a new instance of . 15 | /// 16 | public ZipException() 17 | { 18 | } 19 | 20 | /// 21 | /// Initialise a new instance of with its message string. 22 | /// 23 | /// A that describes the error. 24 | public ZipException(string message) 25 | : base(message) 26 | { 27 | } 28 | 29 | /// 30 | /// Initialise a new instance of . 31 | /// 32 | /// A that describes the error. 33 | /// The that caused this exception. 34 | public ZipException(string message, Exception innerException) 35 | : base(message, innerException) 36 | { 37 | } 38 | 39 | /// 40 | /// Initializes a new instance of the ZipException class with serialized data. 41 | /// 42 | /// 43 | /// The System.Runtime.Serialization.SerializationInfo that holds the serialized 44 | /// object data about the exception being thrown. 45 | /// 46 | /// 47 | /// The System.Runtime.Serialization.StreamingContext that contains contextual information 48 | /// about the source or destination. 49 | /// 50 | protected ZipException(SerializationInfo info, StreamingContext context) 51 | : base(info, context) 52 | { 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Melon/AssemblyResolveInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.MonoInternals 4 | { 5 | [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)] 6 | public class AssemblyResolveInfo : Resolver.AssemblyResolveInfo { } 7 | } 8 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Melon/HarmonyShield.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Harmony 4 | { 5 | [Obsolete("Harmony.HarmonyShield is Only Here for Compatibility Reasons. Please use MelonLoader.PatchShield instead. This will be removed in a future update.", true)] 6 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Struct)] 7 | public class HarmonyShield : MelonLoader.PatchShield { } 8 | } 9 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Melon/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using MelonLoader.Utils; 4 | 5 | namespace MelonLoader 6 | { 7 | [Obsolete("MelonLoader.Main is Only Here for Compatibility Reasons. This will be removed in a future update.", true)] 8 | public static class Main 9 | { 10 | [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)] 11 | public static List Mods = null; 12 | [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)] 13 | public static List Plugins = null; 14 | [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)] 15 | public static bool IsBoneworks = false; 16 | [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)] 17 | public static string GetUnityVersion() => InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(); 18 | [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)] 19 | public static string GetUserDataPath() => MelonEnvironment.UserDataDirectory; 20 | } 21 | } -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Melon/MelonConsole.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [Obsolete("MelonLoader.MelonConsole is Only Here for Compatibility Reasons. This will be removed in a future update.", true)] 6 | public class MelonConsole 7 | { 8 | [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)] 9 | public static void SetTitle(string title) => MelonUtils.SetConsoleTitle(title); 10 | } 11 | } -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Melon/MelonLoaderBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MelonLoader.Utils; 3 | 4 | namespace MelonLoader 5 | { 6 | [Obsolete("MelonLoader.MelonLoaderBase is Only Here for Compatibility Reasons. This will be removed in a future update.", true)] 7 | public static class MelonLoaderBase 8 | { 9 | [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)] 10 | public static string UserDataPath { get => MelonEnvironment.UserDataDirectory; } 11 | [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)] 12 | public static string UnityVersion { get => InternalUtils.UnityInformationHandler.EngineVersion.ToStringWithoutType(); } 13 | } 14 | } -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Melon/MelonModGameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [Obsolete("MelonLoader.MelonModGameAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame instead. This will be removed in a future update.", true)] 6 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 7 | public class MelonModGameAttribute : MelonGameAttribute 8 | { 9 | [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)] 10 | new public string Developer => base.Developer; 11 | [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)] 12 | public string GameName => Name; 13 | [Obsolete("MelonLoader.MelonModGameAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame instead. This will be removed in a future update.", true)] 14 | public MelonModGameAttribute(string developer = null, string gameName = null) : base(developer, gameName) { } 15 | } 16 | } -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Melon/MelonModLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [Obsolete("MelonLoader.MelonModLogger is Only Here for Compatibility Reasons. Please use MelonLoader.MelonLogger instead. This will be removed in a future update.", true)] 6 | public class MelonModLogger : MelonLogger { } 7 | } -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Melon/MelonPluginGameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | [Obsolete("MelonLoader.MelonPluginGameAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame instead. This will be removed in a future update.", true)] 6 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 7 | public class MelonPluginGameAttribute : MelonGameAttribute 8 | { 9 | [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)] 10 | new public string Developer => base.Developer; 11 | [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)] 12 | public string GameName => Name; 13 | [Obsolete("MelonLoader.MelonPluginGameAttribute is Only Here for Compatibility Reasons. Please use MelonLoader.MelonGame instead. This will be removed in a future update.", true)] 14 | public MelonPluginGameAttribute(string developer = null, string gameName = null) : base(developer, gameName) { } 15 | } 16 | } -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/Melon/MonoLibrary.cs: -------------------------------------------------------------------------------- 1 | #if !NET6_0_OR_GREATER 2 | 3 | using System; 4 | 5 | namespace MelonLoader.MonoInternals 6 | { 7 | [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)] 8 | public class MonoLibrary : Utils.MonoLibrary { } 9 | } 10 | 11 | #endif -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/TinyJSON/EncodeOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.TinyJSON 4 | { 5 | [Flags] 6 | [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] 7 | public enum EncodeOptions 8 | { 9 | None = 0, 10 | PrettyPrint = 1, 11 | NoTypeHints = 2, 12 | IncludePublicProperties = 4, 13 | EnforceHierarchyOrder = 8, 14 | 15 | [Obsolete( "Use EncodeOptions.EnforceHierarchyOrder instead." )] 16 | EnforceHeirarchyOrder = EnforceHierarchyOrder 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/TinyJSON/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace MelonLoader.TinyJSON 5 | { 6 | [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] 7 | public static class Extensions 8 | { 9 | public static bool AnyOfType( this IEnumerable source, Type expectedType ) 10 | { 11 | if (source == null) 12 | { 13 | throw new ArgumentNullException( "source" ); 14 | } 15 | 16 | if (expectedType == null) 17 | { 18 | throw new ArgumentNullException( "expectedType" ); 19 | } 20 | 21 | foreach (var item in source) 22 | { 23 | if (expectedType.IsInstanceOfType( item )) 24 | { 25 | return true; 26 | } 27 | } 28 | 29 | return false; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/TinyJSON/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Patrick Hogan 2 | 3 | Based on MiniJSON by Calvin Rien 4 | https://gist.github.com/darktable/1411710 5 | 6 | Based on the JSON parser by Patrick van Bergen 7 | http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining 10 | a copy of this software and associated documentation files (the 11 | "Software"), to deal in the Software without restriction, including 12 | without limitation the rights to use, copy, modify, merge, publish, 13 | distribute, sublicense, and/or sell copies of the Software, and to 14 | permit persons to whom the Software is furnished to do so, subject to 15 | the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be 18 | included in all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 24 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyBoolean.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.TinyJSON 4 | { 5 | [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] 6 | public sealed class ProxyBoolean : Variant 7 | { 8 | readonly bool value; 9 | 10 | 11 | public ProxyBoolean( bool value ) 12 | { 13 | this.value = value; 14 | } 15 | 16 | 17 | public override bool ToBoolean( IFormatProvider provider ) 18 | { 19 | return value; 20 | } 21 | 22 | 23 | public override string ToString( IFormatProvider provider ) 24 | { 25 | return value ? "true" : "false"; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /MelonLoader/BackwardsCompatibility/TinyJSON/Types/ProxyString.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.TinyJSON 4 | { 5 | [Obsolete("Please use Newtonsoft.Json or System.Text.Json instead. This will be removed in a future version.", true)] 6 | public sealed class ProxyString : Variant 7 | { 8 | readonly string value; 9 | 10 | 11 | public ProxyString( string value ) 12 | { 13 | this.value = value; 14 | } 15 | 16 | 17 | public override string ToString( IFormatProvider provider ) 18 | { 19 | return value; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MelonLoader/Fixes/AsmResolverFix.cs: -------------------------------------------------------------------------------- 1 | #if NET6_0_OR_GREATER 2 | 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Reflection.Emit; 6 | using AsmResolver.PE.DotNet.Metadata; 7 | using HarmonyLib; 8 | using MethodInfo = System.Reflection.MethodInfo; 9 | 10 | namespace MelonLoader.Fixes 11 | { 12 | internal static class AsmResolverFix 13 | { 14 | //adds https://github.com/Washi1337/AsmResolver/pull/609 15 | public static void Install() 16 | { 17 | MelonDebug.Msg("Patching AsmResolver SerializedTableStream GetCodedIndexSize..."); 18 | MethodInfo methodInfo = AccessTools.Method(typeof(SerializedTableStream).GetNestedType("<>c__DisplayClass18_0", AccessTools.all), "b__1"); 19 | Core.HarmonyInstance.Patch(methodInfo, null, null, new HarmonyMethod(typeof(AsmResolverFix).GetMethod(nameof(GetCodexIndexSizePatch)))); 20 | } 21 | 22 | public static IEnumerable GetCodexIndexSizePatch(IEnumerable instructions) 23 | { 24 | List codes = instructions.ToList(); 25 | for (int i = 0; i < codes.Count; i++) 26 | { 27 | if (codes[i].opcode == OpCodes.Clt) 28 | { 29 | codes[i].opcode = OpCodes.Cgt; 30 | codes.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4_0)); 31 | codes.Insert(i + 2, new CodeInstruction(OpCodes.Ceq)); 32 | break; 33 | } 34 | } 35 | return codes; 36 | } 37 | 38 | } 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /MelonLoader/Fixes/DotnetModHandlerRedirectionFix.cs: -------------------------------------------------------------------------------- 1 | #if NET6_0_OR_GREATER 2 | using HarmonyLib; 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.Loader; 6 | 7 | namespace MelonLoader.Fixes 8 | { 9 | internal class DotnetModHandlerRedirectionFix 10 | { 11 | public static void Install() 12 | { 13 | try 14 | { 15 | Core.HarmonyInstance.Patch(typeof(AssemblyLoadContext).GetMethod("ValidateAssemblyNameWithSimpleName", BindingFlags.Static | BindingFlags.NonPublic), 16 | new HarmonyMethod(typeof(DotnetModHandlerRedirectionFix), nameof(PreValidateAssembly))); 17 | } 18 | catch (Exception ex) { MelonLogger.Warning($"DotnetModHandlerRedirectionFix Exception: {ex}"); } 19 | } 20 | 21 | public static bool PreValidateAssembly(Assembly assembly, string requestedSimpleName, ref Assembly __result) 22 | { 23 | if(requestedSimpleName.Contains("MelonLoader.ModHandler")) 24 | { 25 | __result = assembly; 26 | return false; //Don't validate the name. What could go wrong? 27 | } 28 | 29 | return true; 30 | } 31 | } 32 | } 33 | 34 | #endif -------------------------------------------------------------------------------- /MelonLoader/Fixes/InstancePatchFix.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using HarmonyLib; 4 | using MonoMod.RuntimeDetour; 5 | 6 | namespace MelonLoader.Fixes 7 | { 8 | internal static class InstancePatchFix 9 | { 10 | internal static void Install() 11 | { 12 | Type instancePatchFixType = typeof(InstancePatchFix); 13 | HarmonyMethod patchMethod = AccessTools.Method(instancePatchFixType, "PatchMethod").ToNewHarmonyMethod(); 14 | 15 | try 16 | { 17 | Core.HarmonyInstance.Patch(AccessTools.Method("HarmonyLib.PatchFunctions:ReversePatch"), patchMethod); 18 | Core.HarmonyInstance.Patch(AccessTools.Method("HarmonyLib.HarmonyMethod:ImportMethod"), patchMethod); 19 | } 20 | catch (Exception ex) { MelonLogger.Warning($"InstancePatchFix Exception: {ex}"); } 21 | 22 | Hook.OnDetour += (detour, originalMethod, patchMethod, delegateTarget) => PatchMethod(patchMethod); 23 | Detour.OnDetour += (detour, originalMethod, patchMethod) => PatchMethod(patchMethod); 24 | } 25 | 26 | private static bool PatchMethod(MethodBase __0) 27 | { 28 | if (__0 == null) 29 | throw new NullReferenceException("Patch Method"); 30 | if ((__0 != null) && !__0.IsStatic) 31 | throw new Exception("Patch Method must be a Static Method!"); 32 | return true; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /MelonLoader/Fixes/NativeLibraryFix.cs: -------------------------------------------------------------------------------- 1 | #if OSX && NET6_0_OR_GREATER 2 | using System; 3 | using System.IO; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | using HarmonyLib; 7 | using MelonLoader.Utils; 8 | 9 | namespace MelonLoader.Fixes; 10 | 11 | // This fix helps il2cppinterop to find GameAssembly.dylib 12 | public class NativeLibraryFix 13 | { 14 | internal static void Install() 15 | { 16 | try 17 | { 18 | Core.HarmonyInstance.Patch(AccessTools.Method(typeof(System.Runtime.InteropServices.NativeLibrary), 19 | nameof(System.Runtime.InteropServices.NativeLibrary.Load), 20 | [typeof(string), typeof(Assembly), typeof(DllImportSearchPath?)]), 21 | AccessTools.Method(typeof(NativeLibraryFix), nameof(LoadLibrary)).ToNewHarmonyMethod()); 22 | } 23 | catch (Exception ex) { MelonLogger.Warning($"NativeLibraryFix Exception: {ex}"); } 24 | } 25 | 26 | private static bool LoadLibrary(ref string __0, Assembly __1, DllImportSearchPath? __2) 27 | { 28 | if (__0 != "GameAssembly") 29 | return true; 30 | __0 = Path.Combine(MelonEnvironment.GameExecutablePath, "Contents", "Frameworks", $"{__0}.dylib"); 31 | MelonDebug.Msg($"Loading library {__0}"); 32 | return true; 33 | } 34 | } 35 | #endif -------------------------------------------------------------------------------- /MelonLoader/Fixes/Net20Compatibility.cs: -------------------------------------------------------------------------------- 1 | #if NET35 2 | using HarmonyLib; 3 | using System; 4 | using System.Text.RegularExpressions; 5 | using MelonLoader.Logging; 6 | 7 | namespace MelonLoader.Fixes 8 | { 9 | internal static class Net20Compatibility 10 | { 11 | public static void TryInstall() 12 | { 13 | if (Environment.Version.Major != 2) 14 | return; 15 | 16 | MelonEvents.OnPreInitialization.Subscribe(OnPreInit, unsubscribeOnFirstInvocation: true); 17 | 18 | Core.HarmonyInstance.Patch(AccessTools.Constructor(typeof(Regex), [typeof(string), typeof(RegexOptions)]), new(typeof(Net20Compatibility), nameof(RegexCtor))); 19 | } 20 | 21 | private static void OnPreInit() 22 | { 23 | MelonLogger.MsgDirect(ColorARGB.Yellow, "The current game is running on .NET Framework 2.0, which is obsolete. Some universal Melons may run into unexpected errors."); 24 | } 25 | 26 | private static void RegexCtor([HarmonyArgument(1)] ref RegexOptions options) 27 | { 28 | // Compiled regex is not supported and results in an exception 29 | options &= ~RegexOptions.Compiled; 30 | } 31 | } 32 | } 33 | #endif -------------------------------------------------------------------------------- /MelonLoader/Fixes/UnhandledException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.Fixes 4 | { 5 | internal static class UnhandledException 6 | { 7 | internal static void Install(AppDomain domain) => 8 | domain.UnhandledException += 9 | (sender, args) => 10 | MelonLogger.Error((args.ExceptionObject as Exception).ToString()); 11 | } 12 | } -------------------------------------------------------------------------------- /MelonLoader/InternalUtils/BootstrapLibrary.cs: -------------------------------------------------------------------------------- 1 | using MelonLoader.Bootstrap; 2 | 3 | namespace MelonLoader.InternalUtils; 4 | 5 | internal class BootstrapLibrary 6 | { 7 | internal NativeHookFn NativeHookAttach { get; private set; } 8 | internal NativeHookFn NativeHookDetach { get; private set; } 9 | internal LogMsgFn LogMsg { get; private set; } 10 | internal LogErrorFn LogError { get; private set; } 11 | internal LogMelonInfoFn LogMelonInfo { get; private set; } 12 | internal ActionFn MonoInstallHooks { get; private set; } 13 | internal PtrRetFn MonoGetDomainPtr { get; private set; } 14 | internal PtrRetFn MonoGetRuntimeHandle { get; private set; } 15 | internal BoolRetFn IsConsoleOpen { get; private set; } 16 | internal GetLoaderConfigFn GetLoaderConfig { get; private set; } 17 | internal GetJavaVM GetJavaVM { get; private set; } 18 | } 19 | -------------------------------------------------------------------------------- /MelonLoader/InternalUtils/Il2CppAssemblyGenerator.cs: -------------------------------------------------------------------------------- 1 | #if NET6_0_OR_GREATER 2 | 3 | using MelonLoader.Modules; 4 | using System; 5 | using System.Diagnostics; 6 | using System.IO; 7 | using MelonLoader.Utils; 8 | 9 | namespace MelonLoader.InternalUtils 10 | { 11 | internal static class Il2CppAssemblyGenerator 12 | { 13 | private static readonly string modulePath = Path.Combine(MelonEnvironment.Il2CppAssemblyGeneratorDirectory, "Il2CppAssemblyGenerator.dll"); 14 | public static readonly MelonModule.Info moduleInfo = new MelonModule.Info(modulePath, () => !MelonUtils.IsGameIl2Cpp()); 15 | 16 | internal static bool Run() 17 | { 18 | if (MelonEnvironment.IsMonoRuntime) 19 | return true; 20 | 21 | MelonLogger.MsgDirect("Loading Il2CppAssemblyGenerator..."); 22 | var module = MelonModule.Load(moduleInfo); 23 | if (module == null) 24 | { 25 | if (File.Exists(modulePath)) 26 | MelonLogger.Error("Failed to Load Il2CppAssemblyGenerator!"); 27 | else 28 | MelonLogger.Error("Il2CppAssemblyGenerator was Not Found!"); 29 | return false; 30 | } 31 | 32 | if (MelonUtils.IsWindows) 33 | { 34 | IntPtr windowHandle = Process.GetCurrentProcess().MainWindowHandle; 35 | 36 | #if WINDOWS 37 | BootstrapInterop.DisableCloseButton(windowHandle); 38 | #endif 39 | } 40 | 41 | var ret = module.SendMessage("Run"); 42 | 43 | if (MelonUtils.IsWindows) 44 | { 45 | IntPtr windowHandle = Process.GetCurrentProcess().MainWindowHandle; 46 | 47 | #if WINDOWS 48 | BootstrapInterop.EnableCloseButton(windowHandle); 49 | #endif 50 | } 51 | 52 | return ret is 0; 53 | } 54 | } 55 | } 56 | 57 | #endif -------------------------------------------------------------------------------- /MelonLoader/InternalUtils/MelonStartScreen.cs: -------------------------------------------------------------------------------- 1 | //using System.IO; 2 | //using AssetRipper.VersionUtilities; 3 | //using MelonLoader.Modules; 4 | //using MelonLoader.Utils; 5 | 6 | namespace MelonLoader.InternalUtils 7 | { 8 | internal class MelonStartScreen 9 | { 10 | // Doesn't support Unity versions lower than 2017.2.0 (yet?) 11 | // Doesn't support Unity versions lower than 2018 (Crashing Issue) 12 | // Doesn't support Unity versions higher than to 2020.3.21 (Crashing Issue) 13 | //internal static readonly MelonModule.Info moduleInfo = new MelonModule.Info($"{MelonEnvironment.OurRuntimeDirectory}{Path.DirectorySeparatorChar}MelonStartScreen.dll" 14 | // , () => !MelonLaunchOptions.Core.StartScreen || UnityInformationHandler.EngineVersion < new UnityVersion(2018)); 15 | 16 | internal static int LoadAndRun(LemonFunc functionToWaitForAsync) 17 | { 18 | //var module = MelonModule.Load(moduleInfo); 19 | //if (module == null) 20 | return functionToWaitForAsync(); 21 | 22 | //var result = module.SendMessage("LoadAndRun", functionToWaitForAsync); 23 | //if (result is int resultCode) 24 | // return resultCode; 25 | 26 | //return -1; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MelonLoader/JNI/JArray.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | namespace MelonLoader.Java; 3 | 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | 7 | public class JArray : JObject, IEnumerable 8 | { 9 | public JArray() : base() { } 10 | 11 | public JArray(int size) => JNI.NewArray(size); 12 | 13 | public int Length => JNI.GetArrayLength(this); 14 | 15 | public T this[int index] 16 | { 17 | get => JNI.GetArrayElement(this, index); 18 | set => JNI.SetArrayElement(this, index, value); 19 | } 20 | 21 | public T[] GetElements() 22 | { 23 | return JNI.GetArrayElements(this); 24 | } 25 | 26 | public IEnumerator GetEnumerator() 27 | { 28 | for (int i = 0; i < this.Length; i++) 29 | { 30 | yield return JNI.GetArrayElement(this, i); 31 | } 32 | } 33 | 34 | IEnumerator IEnumerable.GetEnumerator() 35 | { 36 | return this.GetEnumerator(); 37 | } 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /MelonLoader/JNI/JFieldID.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | using System; 3 | 4 | namespace MelonLoader.Java; 5 | 6 | public readonly struct JFieldID : IEquatable 7 | { 8 | public readonly IntPtr Handle { get; } 9 | 10 | internal JFieldID(IntPtr handle) 11 | { 12 | this.Handle = handle; 13 | } 14 | 15 | public static implicit operator IntPtr(JFieldID fieldID) => fieldID.Handle; 16 | 17 | public static implicit operator JFieldID(IntPtr pointer) => new(pointer); 18 | 19 | public bool Equals(JFieldID other) 20 | { 21 | return this.Handle == other.Handle; 22 | } 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /MelonLoader/JNI/JMethodID.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | using System; 3 | 4 | namespace MelonLoader.Java; 5 | 6 | public readonly struct JMethodID : IEquatable 7 | { 8 | public readonly IntPtr Handle { get; } 9 | 10 | internal JMethodID(IntPtr handle) 11 | { 12 | this.Handle = handle; 13 | } 14 | 15 | public static implicit operator IntPtr(JMethodID methodID) => methodID.Handle; 16 | 17 | public static implicit operator JMethodID(IntPtr pointer) => new(pointer); 18 | 19 | public bool Equals(JMethodID other) 20 | { 21 | return this.Handle == other.Handle; 22 | } 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /MelonLoader/JNI/JNIResultException.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | using System; 3 | 4 | namespace MelonLoader.Java; 5 | 6 | public class JNIResultException : Exception 7 | { 8 | public JNI.Result Result { get; set;} 9 | 10 | public JNIResultException(JNI.Result result) : base($"JNI error occurred: {result}") 11 | { 12 | this.Result = result; 13 | } 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /MelonLoader/JNI/JObject.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | using System; 3 | 4 | namespace MelonLoader.Java; 5 | 6 | public class JObject : IDisposable 7 | { 8 | private bool Disposed { get; set; } 9 | 10 | public IntPtr Handle { get; set;} 11 | 12 | internal JNI.ReferenceType ReferenceType { get; set;} 13 | 14 | public JObject() { } 15 | 16 | public JObject(IntPtr handle, JNI.ReferenceType referenceType) 17 | { 18 | this.Handle = handle; 19 | this.ReferenceType = referenceType; 20 | } 21 | 22 | public JObject(JObject obj) : this(obj.Handle, obj.ReferenceType) 23 | { 24 | this.Disposed = obj.Disposed; 25 | obj.Disposed = true; 26 | } 27 | 28 | protected virtual void Dispose(bool disposing) 29 | { 30 | if (Disposed || this.Handle == IntPtr.Zero) 31 | return; 32 | 33 | switch (this.ReferenceType) 34 | { 35 | case JNI.ReferenceType.Local: 36 | JNI.DeleteLocalRef(this); 37 | break; 38 | 39 | case JNI.ReferenceType.Global: 40 | JNI.DeleteGlobalRef(this); 41 | break; 42 | 43 | case JNI.ReferenceType.WeakGlobal: 44 | JNI.DeleteWeakGlobalRef(this); 45 | break; 46 | } 47 | 48 | Disposed = true; 49 | } 50 | 51 | public bool Valid() 52 | { 53 | return this.Handle != IntPtr.Zero; 54 | } 55 | 56 | ~JObject() 57 | { 58 | Dispose(disposing: false); 59 | } 60 | 61 | public void Dispose() 62 | { 63 | Dispose(disposing: true); 64 | GC.SuppressFinalize(this); 65 | } 66 | } 67 | #endif 68 | -------------------------------------------------------------------------------- /MelonLoader/JNI/JObjectArray.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | namespace MelonLoader.Java; 3 | 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | 7 | public class JObjectArray : JObject, IEnumerable where T : JObject, new() 8 | { 9 | public int Length => JNI.GetArrayLength(this); 10 | 11 | public T this[int index] 12 | { 13 | get => JNI.GetObjectArrayElement(this, index); 14 | set => JNI.SetObjectArrayElement(this, index, value); 15 | } 16 | 17 | public void SetElement(T value, int index) 18 | { 19 | JNI.SetObjectArrayElement(this, index, value); 20 | } 21 | 22 | public IEnumerator GetEnumerator() 23 | { 24 | for (int i = 0; i < this.Length; i++) 25 | { 26 | yield return JNI.GetObjectArrayElement(this, i); 27 | } 28 | } 29 | 30 | IEnumerator IEnumerable.GetEnumerator() 31 | { 32 | return this.GetEnumerator(); 33 | } 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /MelonLoader/JNI/JString.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | namespace MelonLoader.Java; 3 | 4 | public class JString : JObject 5 | { 6 | public JString() : base() { } 7 | 8 | public string GetString() => JNI.GetJStringString(this); 9 | } 10 | #endif 11 | -------------------------------------------------------------------------------- /MelonLoader/JNI/JThrowable.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | namespace MelonLoader.Java; 3 | 4 | public class JThrowable : JObject 5 | { 6 | public JThrowable() { } 7 | 8 | public string GetMessage() => JNI.FindClass("java/lang/Throwable").CallObjectMethod(this, "getMessage", "()Ljava/lang/String;").GetString(); 9 | 10 | public override string ToString() => JNI.FindClass("java/lang/Throwable").CallObjectMethod(this, "toString", "()Ljava/lang/String;").GetString(); 11 | } 12 | #endif 13 | -------------------------------------------------------------------------------- /MelonLoader/JNI/JThrowableException.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | using System; 3 | 4 | namespace MelonLoader.Java; 5 | 6 | public class JThrowableException : Exception 7 | { 8 | public JThrowable Throwable { get; set;} 9 | 10 | public JThrowableException() { } 11 | 12 | public JThrowableException(JThrowable throwable) : base() 13 | { 14 | this.Throwable = throwable; 15 | } 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /MelonLoader/JNI/JavaVM.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | namespace MelonLoader.Java; 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | /// 8 | /// Represents a JavaVM C struct. 9 | /// 10 | [StructLayout(LayoutKind.Sequential)] 11 | internal readonly unsafe struct JavaVM 12 | { 13 | [StructLayout(LayoutKind.Sequential)] 14 | internal readonly unsafe struct FunctionTable 15 | { 16 | internal readonly IntPtr Reserved0; 17 | 18 | internal readonly IntPtr Reserved1; 19 | 20 | internal readonly IntPtr Reserved2; 21 | 22 | // jint (JNICALL *DestroyJavaVM)(JavaVM *vm); 23 | internal readonly delegate* unmanaged[Stdcall] DestroyJavaVM; 24 | 25 | // jint (JNICALL *AttachCurrentThread)(JavaVM *vm, void **penv, void *args); 26 | internal readonly delegate* unmanaged[Stdcall] AttachCurrentThread; 27 | 28 | // jint (JNICALL *DetachCurrentThread)(JavaVM *vm); 29 | internal readonly delegate* unmanaged[Stdcall] DetachCurrentThread; 30 | 31 | // jint (JNICALL *GetEnv)(JavaVM *vm, void **penv, jint version); 32 | internal readonly delegate* unmanaged[Stdcall] GetEnv; 33 | 34 | // jint (JNICALL *AttachCurrentThreadAsDaemon)(JavaVM *vm, void **penv, void *args); 35 | internal readonly delegate* unmanaged[Stdcall] AttachCurrentThreadAsDaemon; 36 | } 37 | 38 | internal readonly FunctionTable* Functions; 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /MelonLoader/JNI/ReferenceType.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | namespace MelonLoader.Java; 3 | 4 | public static partial class JNI 5 | { 6 | public enum ReferenceType 7 | { 8 | Local = 0, 9 | Global = 1, 10 | WeakGlobal = 2 11 | } 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /MelonLoader/JNI/ReleaseMode.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | namespace MelonLoader.Java; 3 | 4 | public static partial class JNI 5 | { 6 | public enum ReleaseMode 7 | { 8 | Default = 0, 9 | Commit = 1, 10 | Abort = 2 11 | } 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /MelonLoader/JNI/Result.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | namespace MelonLoader.Java; 3 | 4 | public static partial class JNI 5 | { 6 | /// 7 | /// Represents a JNI error. 8 | /// 9 | public enum Result 10 | { 11 | /// 12 | /// Success. 13 | /// 14 | Ok = 0, 15 | /// 16 | /// Unknown error occured. 17 | /// 18 | Unknown = -1, 19 | /// 20 | /// Thread detached from the JVM. 21 | /// 22 | Detached = -2, 23 | /// 24 | /// Version unsupported. 25 | /// 26 | Version = -3, 27 | /// 28 | /// JVM out of memory. 29 | /// 30 | OutOfMemory = -4, 31 | /// 32 | /// JVM already exists. 33 | /// 34 | AlreadyExists = -5, 35 | /// 36 | /// Invalid arguments passed. 37 | /// 38 | InvalidArguments = -6 39 | } 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /MelonLoader/JNI/TypeSignature.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | using System; 3 | 4 | namespace MelonLoader.Java; 5 | 6 | public static partial class JNI 7 | { 8 | public static class TypeSignature 9 | { 10 | public const string Bool = "Z"; 11 | 12 | public const string Byte = "B"; 13 | 14 | public const string Char = "C"; 15 | 16 | public const string Short = "S"; 17 | 18 | public const string Int = "I"; 19 | 20 | public const string Long = "J"; 21 | 22 | public const string Float = "F"; 23 | 24 | public const string Double = "D"; 25 | } 26 | 27 | public static string GetTypeSignature() 28 | { 29 | Type t = typeof(T); 30 | 31 | if (t == typeof(bool)) 32 | { 33 | return TypeSignature.Bool; 34 | } 35 | else if (t == typeof(sbyte)) 36 | { 37 | return TypeSignature.Byte; 38 | } 39 | else if (t == typeof(char)) 40 | { 41 | return TypeSignature.Char; 42 | } 43 | else if (t == typeof(short)) 44 | { 45 | return TypeSignature.Short; 46 | } 47 | else if (t == typeof(int)) 48 | { 49 | return TypeSignature.Int; 50 | } 51 | else if (t == typeof(long)) 52 | { 53 | return TypeSignature.Long; 54 | } 55 | else if (t == typeof(float)) 56 | { 57 | return TypeSignature.Float; 58 | } 59 | else if (t == typeof(double)) 60 | { 61 | return TypeSignature.Double; 62 | } 63 | else 64 | { 65 | throw new ArgumentException($"GetTypeSignature Type {t} not supported."); 66 | } 67 | } 68 | } 69 | #endif 70 | -------------------------------------------------------------------------------- /MelonLoader/JNI/Version.cs: -------------------------------------------------------------------------------- 1 | #if ANDROID 2 | namespace MelonLoader.Java; 3 | 4 | public static partial class JNI 5 | { 6 | public enum Version 7 | { 8 | V1_1 = 0x00010001, 9 | V1_2 = 0x00010001, 10 | V1_4 = 0x00010004, 11 | V1_6 = 0x00010006, 12 | V1_8 = 0x00010008 13 | } 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /MelonLoader/Lemons/Cryptography/LemonMD5.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Security.Cryptography; 3 | 4 | namespace MelonLoader.Lemons.Cryptography 5 | { 6 | public class LemonMD5 7 | { 8 | private HashAlgorithm algorithm; 9 | private static LemonMD5 static_algorithm = new(); 10 | 11 | public LemonMD5() 12 | { 13 | algorithm = (HashAlgorithm)CryptoConfig.CreateFromName("System.Security.Cryptography.MD5"); 14 | algorithm.SetHashSizeValue(256); 15 | } 16 | 17 | public static byte[] ComputeMD5Hash(byte[] buffer) => static_algorithm.ComputeHash(buffer); 18 | public static byte[] ComputeMD5Hash(byte[] buffer, int offset, int count) => static_algorithm.ComputeHash(buffer, offset, count); 19 | public static byte[] ComputeMD5Hash(Stream inputStream) => static_algorithm.ComputeHash(inputStream); 20 | 21 | public byte[] ComputeHash(byte[] buffer) => algorithm.ComputeHash(buffer); 22 | public byte[] ComputeHash(byte[] buffer, int offset, int count) => algorithm.ComputeHash(buffer, offset, count); 23 | public byte[] ComputeHash(Stream inputStream) => algorithm.ComputeHash(inputStream); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MelonLoader/Lemons/Cryptography/LemonSHA256.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Security.Cryptography; 4 | 5 | namespace MelonLoader.Lemons.Cryptography 6 | { 7 | public class LemonSHA256 8 | { 9 | private HashAlgorithm algorithm; 10 | private static LemonSHA256 static_algorithm = new(); 11 | 12 | public LemonSHA256() 13 | { 14 | algorithm = (HashAlgorithm)CryptoConfig.CreateFromName("System.Security.Cryptography.SHA256"); 15 | algorithm.SetHashSizeValue(256); 16 | } 17 | 18 | public static byte[] ComputeSHA256Hash(byte[] buffer) => static_algorithm.ComputeHash(buffer); 19 | public static byte[] ComputeSHA256Hash(byte[] buffer, int offset, int count) => static_algorithm.ComputeHash(buffer, offset, count); 20 | public static byte[] ComputeSHA256Hash(Stream inputStream) => static_algorithm.ComputeHash(inputStream); 21 | 22 | public byte[] ComputeHash(byte[] buffer) => algorithm.ComputeHash(buffer); 23 | public byte[] ComputeHash(byte[] buffer, int offset, int count) => algorithm.ComputeHash(buffer, offset, count); 24 | public byte[] ComputeHash(Stream inputStream) => algorithm.ComputeHash(inputStream); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MelonLoader/Lemons/Cryptography/LemonSHA512.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Security.Cryptography; 3 | 4 | namespace MelonLoader.Lemons.Cryptography 5 | { 6 | public class LemonSHA512 7 | { 8 | private HashAlgorithm algorithm; 9 | private static LemonSHA512 static_algorithm = new(); 10 | 11 | public LemonSHA512() 12 | { 13 | algorithm = (HashAlgorithm)CryptoConfig.CreateFromName("System.Security.Cryptography.SHA512"); 14 | algorithm.SetHashSizeValue(512); 15 | } 16 | 17 | public static byte[] ComputeSHA512Hash(byte[] buffer) => static_algorithm.ComputeHash(buffer); 18 | public static byte[] ComputeSHA512Hash(byte[] buffer, int offset, int count) => static_algorithm.ComputeHash(buffer, offset, count); 19 | public static byte[] ComputeSHA512Hash(Stream inputStream) => static_algorithm.ComputeHash(inputStream); 20 | 21 | public byte[] ComputeHash(byte[] buffer) => algorithm.ComputeHash(buffer); 22 | public byte[] ComputeHash(byte[] buffer, int offset, int count) => algorithm.ComputeHash(buffer, offset, count); 23 | public byte[] ComputeHash(Stream inputStream) => algorithm.ComputeHash(inputStream); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MelonLoader/Lemons/LemonAction.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader 2 | { 3 | public delegate void LemonAction(); 4 | public delegate void LemonAction(T1 arg1); 5 | public delegate void LemonAction(T1 arg1, T2 arg2); 6 | public delegate void LemonAction(T1 arg1, T2 arg2, T3 arg3); 7 | public delegate void LemonAction(T1 arg1, T2 arg2, T3 arg3, T4 arg4); 8 | public delegate void LemonAction(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); 9 | public delegate void LemonAction(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6); 10 | public delegate void LemonAction(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7); 11 | public delegate void LemonAction(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8); 12 | } -------------------------------------------------------------------------------- /MelonLoader/Lemons/LemonFunc.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader 2 | { 3 | public delegate RT LemonFunc(); 4 | public delegate RT LemonFunc(T1 arg1); 5 | public delegate RT LemonFunc(T1 arg1, T2 arg2); 6 | public delegate RT LemonFunc(T1 arg1, T2 arg2, T3 arg3); 7 | public delegate RT LemonFunc(T1 arg1, T2 arg2, T3 arg3, T4 arg4); 8 | public delegate RT LemonFunc(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); 9 | public delegate RT LemonFunc(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6); 10 | public delegate RT LemonFunc(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7); 11 | public delegate RT LemonFunc(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8); 12 | } -------------------------------------------------------------------------------- /MelonLoader/Melons/Events/MelonAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace MelonLoader 5 | { 6 | internal class MelonAction where T : Delegate 7 | { 8 | internal readonly T del; 9 | internal readonly bool unsubscribeOnFirstInvocation; 10 | internal readonly int priority; 11 | 12 | internal readonly MelonAssembly melonAssembly; 13 | 14 | private MelonAction(T singleDel, int priority, bool unsubscribeOnFirstInvocation) 15 | { 16 | del = singleDel; 17 | melonAssembly = MelonAssembly.GetMelonAssemblyOfMember(del.Method, del.Target); 18 | this.priority = priority; 19 | this.unsubscribeOnFirstInvocation = unsubscribeOnFirstInvocation; 20 | } 21 | 22 | internal static List> Get(T del, int priority = 0, bool unsubscribeOnFirstInvocation = false) 23 | { 24 | var mets = del.GetInvocationList(); 25 | var result = new List>(); 26 | foreach (var met in mets) 27 | { 28 | if (met.Target != null && met.Target is MelonBase melon && !melon.Registered) 29 | continue; 30 | 31 | result.Add(new MelonAction((T)met, priority, unsubscribeOnFirstInvocation)); 32 | } 33 | return result; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /MelonLoader/Melons/Melon.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader 2 | { 3 | public static class Melon where T : MelonBase 4 | { 5 | private static T _instance; 6 | 7 | public static T Instance 8 | { 9 | get 10 | { 11 | if (_instance != null) 12 | return _instance; 13 | 14 | var melon = MelonAssembly.FindMelonInstance(); 15 | if (melon == null) 16 | return null; 17 | 18 | _instance = melon; 19 | return melon; 20 | } 21 | } 22 | 23 | public static MelonLogger.Instance Logger => Instance?.LoggerInstance; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MelonLoader/Melons/MelonTypeBase.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace MelonLoader 5 | { 6 | public abstract class MelonTypeBase : MelonBase where T : MelonTypeBase 7 | { 8 | /// 9 | /// List of registered s. 10 | /// 11 | new public static ReadOnlyCollection RegisteredMelons => _registeredMelons.AsReadOnly(); 12 | new internal static List _registeredMelons = new(); 13 | 14 | /// 15 | /// A Human-Readable Name for . 16 | /// 17 | public static string TypeName { get; protected internal set; } 18 | 19 | static MelonTypeBase() 20 | { 21 | System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(typeof(T).TypeHandle); // To make sure that the type initializer of T was triggered. 22 | } 23 | 24 | public sealed override string MelonTypeName => TypeName; 25 | 26 | protected private override bool RegisterInternal() 27 | { 28 | if (!base.RegisterInternal()) 29 | return false; 30 | _registeredMelons.Add((T)this); 31 | return true; 32 | } 33 | 34 | protected private override void UnregisterInternal() 35 | { 36 | _registeredMelons.Remove((T)this); 37 | } 38 | 39 | public static void ExecuteAll(LemonAction func, bool unregisterOnFail = false, string unregistrationReason = null) 40 | => ExecuteList(func, _registeredMelons, unregisterOnFail, unregistrationReason); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /MelonLoader/Melons/ResolvedMelons.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader 2 | { 3 | public sealed class ResolvedMelons // This class only exists because I can't use Tuples 4 | { 5 | public readonly MelonBase[] loadedMelons; 6 | public readonly RottenMelon[] rottenMelons; 7 | 8 | public ResolvedMelons(MelonBase[] loadedMelons, RottenMelon[] rottenMelons) 9 | { 10 | this.loadedMelons = loadedMelons ?? new MelonBase[0]; 11 | this.rottenMelons = rottenMelons ?? new RottenMelon[0]; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /MelonLoader/Melons/RottenMelon.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | /// 6 | /// An info class for broken Melons. 7 | /// 8 | public sealed class RottenMelon 9 | { 10 | public readonly MelonAssembly assembly; 11 | public readonly Type type; 12 | public readonly string errorMessage; 13 | public readonly Exception exception; 14 | 15 | public RottenMelon(Type type, string errorMessage, Exception exception = null) 16 | { 17 | assembly = MelonAssembly.LoadMelonAssembly(null, type.Assembly); 18 | this.type = type; 19 | this.errorMessage = errorMessage; 20 | this.exception = exception; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MelonLoader/NativeUtils/PEParser/ImageDataDirectory.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MelonLoader.NativeUtils.PEParser 4 | { 5 | [StructLayout(LayoutKind.Explicit)] 6 | public struct ImageDataDirectory 7 | { 8 | [FieldOffset(0)] 9 | public uint virtualAddress; 10 | [FieldOffset(4)] 11 | public uint size; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /MelonLoader/NativeUtils/PEParser/ImageExportDirectory.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MelonLoader.NativeUtils.PEParser 4 | { 5 | [StructLayout(LayoutKind.Explicit)] 6 | public struct ImageExportDirectory 7 | { 8 | [FieldOffset(0)] 9 | public uint characteristics; 10 | [FieldOffset(4)] 11 | public uint timedatestamp; 12 | [FieldOffset(8)] 13 | public ushort majorVersion; 14 | [FieldOffset(10)] 15 | public ushort minorVersion; 16 | [FieldOffset(12)] 17 | public uint name; 18 | [FieldOffset(16)] 19 | public uint base_; 20 | [FieldOffset(20)] 21 | public uint numberOfFunctions; 22 | [FieldOffset(24)] 23 | public uint numberOfNames; 24 | [FieldOffset(28)] 25 | public uint addressOfFunctions; 26 | [FieldOffset(32)] 27 | public uint addressOfNames; 28 | [FieldOffset(36)] 29 | public uint addressOfNameOrdinals; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MelonLoader/NativeUtils/PEParser/ImageFileHeader.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader.NativeUtils.PEParser 2 | { 3 | public struct ImageFileHeader 4 | { 5 | public ushort machine; 6 | public ushort numberOfSections; 7 | public uint timeDateStamp; 8 | public uint pointerToSymbolTable; 9 | public uint numberOfSymbols; 10 | public ushort sizeOfOptionalHeader; 11 | public ushort characteristrics; 12 | } 13 | } -------------------------------------------------------------------------------- /MelonLoader/NativeUtils/PEParser/ImageNtHeaders.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MelonLoader.NativeUtils.PEParser 4 | { 5 | [StructLayout(LayoutKind.Explicit)] 6 | public struct ImageNtHeaders 7 | { 8 | [FieldOffset(0)] 9 | public uint signature; 10 | [FieldOffset(4)] 11 | public ImageFileHeader fileHeader; 12 | [FieldOffset(24)] 13 | public OptionalFileHeader64 optionalHeader64; 14 | [FieldOffset(24)] 15 | public OptionalFileHeader32 optionalHeader32; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MelonLoader/NativeUtils/PEParser/ImageResourceDirectory.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MelonLoader.NativeUtils.PEParser 4 | { 5 | [StructLayout(LayoutKind.Explicit)] 6 | public struct ImageResourceDirectory 7 | { 8 | [FieldOffset(0)] 9 | public uint characteristics; 10 | [FieldOffset(4)] 11 | public uint timedatestamp; 12 | [FieldOffset(8)] 13 | public ushort majorVersion; 14 | [FieldOffset(10)] 15 | public ushort minorVersion; 16 | [FieldOffset(12)] 17 | public uint numberOfNames; 18 | [FieldOffset(14)] 19 | public uint numberOfIds; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MelonLoader/NativeUtils/PEParser/ImageSectionHeader.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MelonLoader.NativeUtils.PEParser 4 | { 5 | [StructLayout(LayoutKind.Explicit)] 6 | public struct ImageSectionHeader 7 | { 8 | //[FieldOffset(0)] 9 | //[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] 10 | //public char[8] name; 11 | [FieldOffset(8)] 12 | public int virtualSize; 13 | [FieldOffset(12)] 14 | public int virtualAddress; 15 | [FieldOffset(16)] 16 | public int sizeOfRawData; 17 | [FieldOffset(20)] 18 | public int pointerToRawData; 19 | [FieldOffset(24)] 20 | public int pointerToRelocations; 21 | [FieldOffset(28)] 22 | public int pointerToLinenumbers; 23 | [FieldOffset(32)] 24 | public ushort numberOfRelocations; 25 | [FieldOffset(34)] 26 | public ushort numberOfLinenumbers; 27 | [FieldOffset(36)] 28 | public /* DataSectionFlags */ uint characteristics; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /MelonLoader/NativeUtils/PEParser/ImageThunkData32.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MelonLoader.NativeUtils.PEParser 4 | { 5 | [StructLayout(LayoutKind.Explicit)] 6 | public struct ImageThunkData32 7 | { 8 | [FieldOffset(0)] 9 | public uint forwarderString; 10 | [FieldOffset(0)] 11 | public uint function; 12 | [FieldOffset(0)] 13 | public uint ordinal; 14 | [FieldOffset(0)] 15 | public uint addressOfData; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MelonLoader/NativeUtils/PEParser/ImageThunkData64.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MelonLoader.NativeUtils.PEParser 4 | { 5 | [StructLayout(LayoutKind.Explicit)] 6 | public struct ImageThunkData64 7 | { 8 | [FieldOffset(0)] 9 | public ulong forwarderString; 10 | [FieldOffset(0)] 11 | public ulong function; 12 | [FieldOffset(0)] 13 | public ulong ordinal; 14 | [FieldOffset(0)] 15 | public ulong addressOfData; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MelonLoader/NativeUtils/PEParser/OptionalFileHeader32.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MelonLoader.NativeUtils.PEParser 4 | { 5 | [StructLayout(LayoutKind.Explicit)] 6 | public struct OptionalFileHeader32 7 | { 8 | [FieldOffset(96)] 9 | public ImageDataDirectory exportTable; 10 | [FieldOffset(112)] 11 | public ImageDataDirectory resourceTable; 12 | } 13 | } -------------------------------------------------------------------------------- /MelonLoader/NativeUtils/PEParser/OptionalFileHeader64.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MelonLoader.NativeUtils.PEParser 4 | { 5 | [StructLayout(LayoutKind.Explicit)] 6 | public struct OptionalFileHeader64 7 | { 8 | [FieldOffset(112)] 9 | public ImageDataDirectory exportTable; 10 | [FieldOffset(128)] 11 | public ImageDataDirectory resourceTable; 12 | } 13 | } -------------------------------------------------------------------------------- /MelonLoader/Preferences/TomlMapper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Tomlet; 3 | using Tomlet.Models; 4 | 5 | namespace MelonLoader 6 | { 7 | public class TomlMapper 8 | { 9 | static TomlMapper() 10 | => TomletMain.RegisterMapper(WriteLemonTupleInt, ReadLemonTupleInt); 11 | 12 | public T[] ReadArray(TomlValue value) => TomletMain.To(value); 13 | public TomlArray WriteArray(T[] value) => (TomlArray)TomletMain.ValueFrom(value); 14 | 15 | public List ReadList(TomlValue value) => TomletMain.To>(value); 16 | public TomlArray WriteList(List value) => (TomlArray)TomletMain.ValueFrom(value); 17 | 18 | public TomlValue ToToml(T value) => TomletMain.ValueFrom(value); 19 | public T FromToml(TomlValue value) => TomletMain.To(value); 20 | 21 | private static TomlValue WriteLemonTupleInt(LemonTuple value) 22 | { 23 | int[] ints = new[] { value.Item1, value.Item2 }; 24 | return MelonPreferences.Mapper.WriteArray(ints); 25 | } 26 | 27 | private static LemonTuple ReadLemonTupleInt(TomlValue value) 28 | { 29 | int[] ints = MelonPreferences.Mapper.ReadArray(value); 30 | if (ints == null || ints.Length != 2) 31 | return default; 32 | return new LemonTuple() { Item1 = ints[0], Item2 = ints[1] }; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /MelonLoader/Preferences/ValueValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader.Preferences 4 | { 5 | public abstract class ValueValidator 6 | { 7 | public abstract bool IsValid(object value); 8 | public abstract object EnsureValid(object value); 9 | } 10 | 11 | public interface IValueRange 12 | { 13 | object MinValue { get; } 14 | object MaxValue { get; } 15 | } 16 | 17 | public class ValueRange : ValueValidator, IValueRange where T : IComparable 18 | { 19 | public T MinValue { get; } 20 | public T MaxValue { get; } 21 | 22 | public ValueRange(T minValue, T maxValue) 23 | { 24 | if (minValue.CompareTo(maxValue) >= 0) 25 | throw new ArgumentException($"Min value ({minValue}) must be less than max value ({maxValue})!"); 26 | 27 | MinValue = minValue; 28 | MaxValue = maxValue; 29 | } 30 | 31 | public override bool IsValid(object value) 32 | => MaxValue.CompareTo(value) >= 0 && MinValue.CompareTo(value) <= 0; 33 | 34 | public override object EnsureValid(object value) 35 | { 36 | if (MaxValue.CompareTo(value) < 0) 37 | return MaxValue; 38 | if (MinValue.CompareTo(value) > 0) 39 | return MinValue; 40 | return value; 41 | } 42 | 43 | object IValueRange.MinValue => MinValue; 44 | object IValueRange.MaxValue => MaxValue; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /MelonLoader/Properties/BuildInfo.cs: -------------------------------------------------------------------------------- 1 | using Semver; 2 | 3 | namespace MelonLoader; 4 | 5 | public static class BuildInfo 6 | { 7 | public const string Name = "MelonLoader"; 8 | public const string Description = "MelonLoader"; 9 | public const string Author = "Lava Gang"; 10 | public const string Company = "discord.gg/2Wn3N2P"; 11 | 12 | public static SemVersion VersionNumber { get; private set; } 13 | 14 | // NOTICE: This used to be a constant. Making it a property won't break backwards compatibility. 15 | public static string Version { get; private set; } 16 | 17 | static BuildInfo() 18 | { 19 | var version = typeof(BuildInfo).Assembly.GetName().Version!; 20 | VersionNumber = new(version.Major, version.Minor, version.Build, ((version.Revision == 0) 21 | ? "" 22 | : ("ci." + version.Revision.ToString()))); 23 | Version = VersionNumber.ToString(); 24 | } 25 | } -------------------------------------------------------------------------------- /MelonLoader/Resolver/AssemblyResolveInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace MelonLoader.Resolver; 6 | 7 | public class AssemblyResolveInfo 8 | { 9 | public Assembly Override = null; 10 | public Assembly Fallback = null; 11 | internal Dictionary Versions = new Dictionary(); 12 | 13 | internal Assembly Resolve(Version requested_version) 14 | { 15 | // Check for Override 16 | if (Override != null) 17 | return Override; 18 | 19 | // Check for Requested Version 20 | if (requested_version != null 21 | && GetVersionSpecific(requested_version, out Assembly assembly)) 22 | return assembly; 23 | 24 | // Check for Fallback 25 | if (Fallback != null) 26 | return Fallback; 27 | 28 | return null; 29 | } 30 | 31 | public void SetVersionSpecific(Version version, Assembly assembly = null) 32 | { 33 | lock (Versions) 34 | Versions[version] = assembly; 35 | } 36 | public Assembly GetVersionSpecific(Version version) 37 | => GetVersionSpecific(version, out Assembly assembly) 38 | ? assembly 39 | : null; 40 | public bool GetVersionSpecific(Version version, out Assembly assembly) 41 | => Versions.TryGetValue(version, out assembly) && assembly != null; 42 | } -------------------------------------------------------------------------------- /MelonLoader/Resources/classdata.tpk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonLoader/MelonLoader/7b14dac3281fe9a88a1b8f0c96f5b9a46f558cdf/MelonLoader/Resources/classdata.tpk -------------------------------------------------------------------------------- /MelonLoader/Semver/IntExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace Semver 4 | { 5 | internal static class IntExtensions 6 | { 7 | /// 8 | /// The number of digits in a non-negative number. Returns 1 for all 9 | /// negative numbers. That is ok because we are using it to calculate 10 | /// string length for a for numbers that 11 | /// aren't supposed to be negative, but when they are it is just a little 12 | /// slower. 13 | /// 14 | /// 15 | /// This approach is based on https://stackoverflow.com/a/51099524/268898 16 | /// where the poster offers performance benchmarks showing this is the 17 | /// fastest way to get a number of digits. 18 | /// 19 | public static int Digits(this int n) 20 | { 21 | if (n < 10) return 1; 22 | if (n < 100) return 2; 23 | if (n < 1_000) return 3; 24 | if (n < 10_000) return 4; 25 | if (n < 100_000) return 5; 26 | if (n < 1_000_000) return 6; 27 | if (n < 10_000_000) return 7; 28 | if (n < 100_000_000) return 8; 29 | if (n < 1_000_000_000) return 9; 30 | return 10; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /MelonLoader/Semver/License.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Max Hauser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /MelonLoader/Semver/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://ci.appveyor.com/api/projects/status/kek3h7gflo3qqidb/branch/master?svg=true)](https://ci.appveyor.com/project/maxhauser/semver/branch/master) 2 | [![NuGet](https://img.shields.io/nuget/v/semver.svg)](https://www.nuget.org/packages/semver/) 3 | 4 | A Semantic Version Library for .Net 5 | =================================== 6 | 7 | This library implements the `SemVersion` class, which 8 | complies with v2.0.0 of the spec from 9 | 10 | ## Installation 11 | 12 | With the NuGet console: 13 | 14 | ```powershell 15 | Install-Package semver 16 | ``` 17 | 18 | ## Parsing 19 | 20 | ```csharp 21 | var version = SemVersion.Parse("1.1.0-rc.1+nightly.2345"); 22 | ``` 23 | 24 | ## Comparing 25 | 26 | ```csharp 27 | if(version >= "1.0") 28 | Console.WriteLine("released version {0}!", version) 29 | ``` 30 | -------------------------------------------------------------------------------- /MelonLoader/SupportModule/ISupportModule_From.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader 2 | { 3 | public interface ISupportModule_From 4 | { 5 | void OnApplicationLateStart(); 6 | void OnSceneWasLoaded(int buildIndex, string sceneName); 7 | void OnSceneWasInitialized(int buildIndex, string sceneName); 8 | void OnSceneWasUnloaded(int buildIndex, string sceneName); 9 | void Update(); 10 | void FixedUpdate(); 11 | void LateUpdate(); 12 | void OnGUI(); 13 | void Quit(); 14 | void DefiniteQuit(); 15 | void SetInteropSupportInterface(InteropSupport.Interface interop); 16 | } 17 | } -------------------------------------------------------------------------------- /MelonLoader/SupportModule/ISupportModule_To.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | 3 | namespace MelonLoader 4 | { 5 | public interface ISupportModule_To 6 | { 7 | object StartCoroutine(IEnumerator coroutine); 8 | void StopCoroutine(object coroutineToken); 9 | void UnityDebugLog(string msg); 10 | } 11 | } -------------------------------------------------------------------------------- /MelonLoader/SupportModule/SupportModule_From.cs: -------------------------------------------------------------------------------- 1 | namespace MelonLoader 2 | { 3 | internal class SupportModule_From : ISupportModule_From 4 | { 5 | public void OnApplicationLateStart() 6 | => MelonEvents.OnApplicationLateStart.Invoke(); 7 | 8 | public void OnSceneWasLoaded(int buildIndex, string sceneName) 9 | => MelonEvents.OnSceneWasLoaded.Invoke(buildIndex, sceneName); 10 | 11 | public void OnSceneWasInitialized(int buildIndex, string sceneName) 12 | => MelonEvents.OnSceneWasInitialized.Invoke(buildIndex, sceneName); 13 | 14 | public void OnSceneWasUnloaded(int buildIndex, string sceneName) 15 | => MelonEvents.OnSceneWasUnloaded.Invoke(buildIndex, sceneName); 16 | 17 | public void Update() 18 | => MelonEvents.OnUpdate.Invoke(); 19 | 20 | public void FixedUpdate() 21 | => MelonEvents.OnFixedUpdate.Invoke(); 22 | 23 | public void LateUpdate() 24 | => MelonEvents.OnLateUpdate.Invoke(); 25 | 26 | public void OnGUI() 27 | => MelonEvents.OnGUI.Invoke(); 28 | 29 | public void Quit() 30 | => MelonEvents.OnApplicationQuit.Invoke(); 31 | 32 | public void DefiniteQuit() 33 | { 34 | MelonEvents.OnApplicationDefiniteQuit.Invoke(); 35 | Core.Quit(); 36 | } 37 | 38 | public void SetInteropSupportInterface(InteropSupport.Interface interop) 39 | { 40 | if (InteropSupport.SMInterface == null) 41 | InteropSupport.SMInterface = interop; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /MelonLoader/Utils/Assertion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace MelonLoader.Utils 6 | { 7 | internal static class Assertion 8 | { 9 | internal static bool ShouldContinue = true; 10 | 11 | //TODO: Could this be done in a better way? net35/6 load PresentationFramework differently so I could not rely on it 12 | //This crashes with start screen enabled 13 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 14 | internal static extern IntPtr MessageBox(int hWnd, String text, String caption, uint type); 15 | 16 | internal static void ThrowInternalFailure(string msg) 17 | { 18 | if (!ShouldContinue) 19 | return; 20 | 21 | ShouldContinue = false; 22 | 23 | MelonLogger.PassLogError(msg, "INTERNAL FAILURE", false); 24 | 25 | string caption = "INTERNAL FAILURE!"; 26 | var result = MessageBox(0, msg, caption, 0); 27 | while (result == IntPtr.Zero) 28 | Environment.Exit(1); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /MelonLoader/Utils/EnumExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MelonLoader 4 | { 5 | /// 6 | /// Extentions for enums. 7 | /// 8 | public static class EnumExtensions 9 | { 10 | /// 11 | /// From: http://www.sambeauvois.be/blog/2011/08/enum-hasflag-method-extension-for-4-0-framework/ 12 | /// A FX 3.5 way to mimic the FX4 "HasFlag" method. 13 | /// 14 | /// The tested enum. 15 | /// The value to test. 16 | /// True if the flag is set. Otherwise false. 17 | public static bool HasFlag(this Enum variable, Enum value) 18 | { 19 | // check if from the same type. 20 | if (variable.GetType() != value.GetType()) 21 | { 22 | throw new ArgumentException("The checked flag is not from the same type as the checked variable."); 23 | } 24 | 25 | ulong num = Convert.ToUInt64(value); 26 | ulong num2 = Convert.ToUInt64(variable); 27 | 28 | return (num2 & num) == num; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MelonLoader/Utils/MelonCoroutines.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace MelonLoader 5 | { 6 | public class MelonCoroutines 7 | { 8 | /// 9 | /// Start a new coroutine.
10 | /// Coroutines are called at the end of the game Update loops. 11 | ///
12 | /// The target routine 13 | /// An object that can be passed to Stop to stop this coroutine 14 | public static object Start(IEnumerator routine) 15 | { 16 | if (SupportModule.Interface == null) 17 | throw new NotSupportedException("Support module must be initialized before starting coroutines"); 18 | return SupportModule.Interface.StartCoroutine(routine); 19 | } 20 | 21 | /// 22 | /// Stop a currently running coroutine 23 | /// 24 | /// The coroutine to stop 25 | public static void Stop(object coroutineToken) 26 | { 27 | if (SupportModule.Interface == null) 28 | throw new NotSupportedException("Support module must be initialized before starting coroutines"); 29 | SupportModule.Interface.StopCoroutine(coroutineToken); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /MelonLoader/Utils/MelonDebug.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MelonLoader.Logging; 3 | using MelonLoader.Utils; 4 | 5 | namespace MelonLoader 6 | { 7 | public static class MelonDebug 8 | { 9 | public static void Msg(object obj) 10 | { 11 | if (!IsEnabled()) 12 | return; 13 | MelonLogger.PassLogMsg(MelonLogger.DefaultTextColor, obj.ToString(), ColorARGB.CornflowerBlue, "DEBUG"); 14 | MsgCallbackHandler?.Invoke(LoggerUtils.DrawingColorToConsoleColor(MelonLogger.DefaultTextColor), obj.ToString()); 15 | } 16 | 17 | public static void Msg(string txt) 18 | { 19 | if (!IsEnabled()) 20 | return; 21 | MelonLogger.PassLogMsg(MelonLogger.DefaultTextColor, txt, ColorARGB.CornflowerBlue, "DEBUG"); 22 | MsgCallbackHandler?.Invoke(LoggerUtils.DrawingColorToConsoleColor(MelonLogger.DefaultTextColor), txt); 23 | } 24 | 25 | public static void Msg(string txt, params object[] args) 26 | { 27 | if (!IsEnabled()) 28 | return; 29 | MelonLogger.PassLogMsg(MelonLogger.DefaultTextColor, string.Format(txt, args), ColorARGB.CornflowerBlue, "DEBUG"); 30 | MsgCallbackHandler?.Invoke(LoggerUtils.DrawingColorToConsoleColor(MelonLogger.DefaultTextColor), string.Format(txt, args)); 31 | } 32 | 33 | public static void Error(string txt) 34 | { 35 | if (!IsEnabled()) 36 | return; 37 | MelonLogger.PassLogError(txt, "DEBUG", false); 38 | ErrorCallbackHandler?.Invoke(txt); 39 | } 40 | 41 | public static event Action MsgCallbackHandler; 42 | 43 | public static event Action ErrorCallbackHandler; 44 | 45 | public static bool IsEnabled() 46 | => LoaderConfig.Current.Loader.DebugMode; 47 | } 48 | } -------------------------------------------------------------------------------- /MelonLoader/Utils/MonoLibrary.cs: -------------------------------------------------------------------------------- 1 | #if !NET6_0_OR_GREATER 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | using System.Runtime.InteropServices; 7 | using MelonLoader.InternalUtils; 8 | 9 | namespace MelonLoader.Utils 10 | { 11 | public class MonoLibrary 12 | { 13 | internal static bool Setup() 14 | { 15 | IntPtr NativeMonoPtr = BootstrapInterop.Library.MonoGetRuntimeHandle(); 16 | if (NativeMonoPtr == IntPtr.Zero) 17 | { 18 | MelonLogger.ThrowInternalFailure("[MonoLibrary] Failed to get Mono Library Pointer from Internal Call!"); 19 | return false; 20 | } 21 | 22 | try 23 | { 24 | Instance = NativeMonoPtr.ToNewNativeLibrary().Instance; 25 | } 26 | catch (Exception ex) 27 | { 28 | MelonLogger.ThrowInternalFailure($"[MonoLibrary] Failed to load Mono NativeLibrary!\n{ex}"); 29 | return false; 30 | } 31 | 32 | MelonDebug.Msg("[MonoLibrary] Setup Successful!"); 33 | return true; 34 | } 35 | 36 | public static MonoLibrary Instance { get; private set; } 37 | 38 | [MethodImpl(MethodImplOptions.InternalCall)] 39 | public extern static Assembly CastManagedAssemblyPtr(IntPtr ptr); 40 | 41 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 42 | public delegate IntPtr dmono_assembly_open_full(IntPtr filepath, IntPtr status, bool refonly); 43 | public dmono_assembly_open_full mono_assembly_open_full = null; 44 | 45 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 46 | public delegate IntPtr dmono_assembly_get_object(IntPtr domain, IntPtr assembly); 47 | public dmono_assembly_get_object mono_assembly_get_object = null; 48 | } 49 | } 50 | #endif -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | MelonLoader 2 | Copyright 2020 - 2022 Lava Gang 3 | 4 | This product contains software (https://github.com/LavaGang/MelonLoader) developed 5 | by Lava Gang, licensed under the Apache-2.0 license. -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /PortablePdbToMdb/PortablePdbToMdb.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using Microsoft.Build.Framework; 5 | using Microsoft.Build.Utilities; 6 | using Mono.Cecil; 7 | using Mono.Cecil.Mdb; 8 | 9 | namespace PortablePdbToMdb; 10 | 11 | public class PortablePdbToMdb : Task 12 | { 13 | [Required] 14 | public string? AssemblyPath { get; set; } 15 | 16 | public override bool Execute() 17 | { 18 | try 19 | { 20 | var module = ModuleDefinition.ReadModule(AssemblyPath, new() 21 | { 22 | ReadSymbols = true, 23 | }); 24 | 25 | var allMethod = module.GetTypes().SelectMany(x => x.Methods); 26 | var writerProvider = new MdbWriterProvider(); 27 | using (var writer = writerProvider.GetSymbolWriter(module, AssemblyPath)) 28 | { 29 | foreach (MethodDefinition methodDefinition in allMethod) 30 | writer.Write(methodDefinition.DebugInformation); 31 | } 32 | } 33 | catch (Exception e) 34 | { 35 | Log.LogError(e.Message); 36 | return false; 37 | } 38 | 39 | string mdbPath = AssemblyPath + ".mdb"; 40 | if (File.Exists(mdbPath)) 41 | Log.LogMessage(MessageImportance.High, $"Mdb file created successfully at {mdbPath}"); 42 | return true; 43 | } 44 | } -------------------------------------------------------------------------------- /PortablePdbToMdb/PortablePdbToMdb.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | latest 6 | enable 7 | AnyCpu 8 | true 9 | $(MSBuildProjectDirectory)/bin 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /UnityUtilities/UnityEngine.Il2CppAssetBundleManager/UnityEngine.Il2CppAssetBundleManager.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net6 4 | UnityEngine 5 | $(MLOutDir)/MelonLoader 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /UnityUtilities/UnityEngine.Il2CppImageConversionManager/UnityEngine.Il2CppImageConversionManager.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net6 4 | UnityEngine 5 | $(MLOutDir)/MelonLoader 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /compile_bootstrap_android.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | dotnet restore 3 | dotnet publish -r linux-bionic-arm64 -p:DisableUnsupportedError=true -p:PublishAotUsingRuntimePack=true 4 | 5 | pause -------------------------------------------------------------------------------- /compile_bootstrap_android_debug.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | dotnet restore 3 | dotnet publish -r linux-bionic-arm64 -p:DisableUnsupportedError=true -p:PublishAotUsingRuntimePack=true -p:Configuration=Debug 4 | 5 | pause --------------------------------------------------------------------------------