From 16dafe63166d065f40b57a9b7cf8017a6ba0b1ef Mon Sep 17 00:00:00 2001 From: mageven <62494521+mageven@users.noreply.github.com> Date: Wed, 15 Jul 2020 05:10:17 +0530 Subject: [PATCH] mods: Fix crash when loading via LoadCart (#1388) --- Ryujinx.HLE/HOS/ApplicationLoader.cs | 2 ++ Ryujinx.HLE/HOS/ModLoader.cs | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Ryujinx.HLE/HOS/ApplicationLoader.cs b/Ryujinx.HLE/HOS/ApplicationLoader.cs index 994d0f2595..2972656714 100644 --- a/Ryujinx.HLE/HOS/ApplicationLoader.cs +++ b/Ryujinx.HLE/HOS/ApplicationLoader.cs @@ -69,6 +69,8 @@ namespace Ryujinx.HLE.HOS Npdm metaData = ReadNpdm(codeFs); + _fileSystem.ModLoader.CollectMods(TitleId, _fileSystem.GetBaseModsPath()); + if (TitleId != 0) { EnsureSaveData(new TitleId(TitleId)); diff --git a/Ryujinx.HLE/HOS/ModLoader.cs b/Ryujinx.HLE/HOS/ModLoader.cs index 654d0cbe3e..4fb5d0fa9c 100644 --- a/Ryujinx.HLE/HOS/ModLoader.cs +++ b/Ryujinx.HLE/HOS/ModLoader.cs @@ -451,8 +451,12 @@ namespace Ryujinx.HLE.HOS internal bool ApplyNsoPatches(ulong titleId, params IExecutable[] programs) { - AppMods.TryGetValue(titleId, out ModCache mods); - var nsoMods = Patches.NsoPatches.Concat(mods.ExefsDirs); + IEnumerable> nsoMods = Patches.NsoPatches; + + if (AppMods.TryGetValue(titleId, out ModCache mods)) + { + nsoMods = nsoMods.Concat(mods.ExefsDirs); + } // NSO patches are created with offset 0 according to Atmosphere's patcher module // But `Program` doesn't contain the header which is 0x100 bytes. So, we adjust for that here