From 9f2f0c176dfb1a2944fbbcee0f4eb14af4cd5d12 Mon Sep 17 00:00:00 2001 From: pointfeev Date: Sun, 28 Aug 2022 07:40:53 -0400 Subject: [PATCH] v4.1.1.0 - Consolidated and vastly improved the performance of the program's methods of gathering game executables and DLLs - Koaloader's respective unlocker DLLs are now correctly deployed based on executable bitnesses instead of which API DLLs exist --- CreamInstaller/Components/ContextMenuItem.cs | 2 +- CreamInstaller/CreamInstaller.csproj | 2 +- CreamInstaller/Epic/EpicLibrary.cs | 29 +--- CreamInstaller/Forms/SelectForm.cs | 16 +- CreamInstaller/Resources/Koaloader.cs | 155 ++++++++----------- CreamInstaller/Resources/Resources.cs | 118 +++++++++----- CreamInstaller/Steam/SteamCMD.cs | 10 +- CreamInstaller/Steam/SteamLibrary.cs | 29 +--- CreamInstaller/Steam/SteamStore.cs | 16 ++ CreamInstaller/Ubisoft/UbisoftLibrary.cs | 38 ----- 10 files changed, 175 insertions(+), 240 deletions(-) diff --git a/CreamInstaller/Components/ContextMenuItem.cs b/CreamInstaller/Components/ContextMenuItem.cs index 038722c..c5b801f 100644 --- a/CreamInstaller/Components/ContextMenuItem.cs +++ b/CreamInstaller/Components/ContextMenuItem.cs @@ -23,7 +23,7 @@ internal class ContextMenuItem : ToolStripMenuItem { case "Paradox Launcher": if (Directory.Exists(ParadoxLauncher.InstallPath)) - foreach (string file in Directory.GetFiles(ParadoxLauncher.InstallPath, "*.exe")) + foreach (string file in Directory.EnumerateFiles(ParadoxLauncher.InstallPath, "*.exe")) { image = IconGrabber.GetFileIconImage(file); break; diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 21e81fc..8e2b866 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -5,7 +5,7 @@ True Resources\ini.ico true - 4.1.0.0 + 4.1.1.0 Resources\ini.ico LICENSE 2021, pointfeev (https://github.com/pointfeev) diff --git a/CreamInstaller/Epic/EpicLibrary.cs b/CreamInstaller/Epic/EpicLibrary.cs index 5a08064..50e1424 100644 --- a/CreamInstaller/Epic/EpicLibrary.cs +++ b/CreamInstaller/Epic/EpicLibrary.cs @@ -5,7 +5,6 @@ using Microsoft.Win32; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text.Json; using System.Threading.Tasks; @@ -37,8 +36,7 @@ internal static class EpicLibrary List games = new(); string manifests = EpicManifestsPath; if (!Directory.Exists(manifests)) return games; - string[] files = Directory.GetFiles(manifests, "*.item"); - foreach (string file in files) + foreach (string file in Directory.EnumerateFiles(manifests, "*.item")) { if (Program.Canceled) return games; string json = File.ReadAllText(file); @@ -52,29 +50,4 @@ internal static class EpicLibrary } return games; }); - - internal static async Task> GetDllDirectoriesFromGameDirectory(string gameDirectory) => await Task.Run(async () => - { - List dllDirectories = new(); - if (Program.Canceled || !Directory.Exists(gameDirectory)) return null; - gameDirectory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config); - if (File.Exists(api32) - || File.Exists(api32_o) - || File.Exists(api64) - || File.Exists(api64_o) - || File.Exists(config)) - dllDirectories.Add(gameDirectory.BeautifyPath()); - string[] directories = Directory.GetDirectories(gameDirectory); - foreach (string _directory in directories) - { - if (Program.Canceled) return null; - try - { - List moreDllDirectories = await GetDllDirectoriesFromGameDirectory(_directory); - if (moreDllDirectories is not null) dllDirectories.AddRange(moreDllDirectories); - } - catch { } - } - return !dllDirectories.Any() ? null : dllDirectories; - }); } \ No newline at end of file diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index 1b8b4f2..e1235cf 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -109,14 +109,8 @@ internal partial class SelectForm : CustomForm List appTasks = new(); if (ProgramsToScan.Any(c => c.platform is Platform.Paradox)) { - List steamDllDirectories = await SteamLibrary.GetDllDirectoriesFromGameDirectory(ParadoxLauncher.InstallPath); - List epicDllDirectories = await EpicLibrary.GetDllDirectoriesFromGameDirectory(ParadoxLauncher.InstallPath); - List dllDirectories = new(); - if (steamDllDirectories is not null) - dllDirectories = dllDirectories.Union(steamDllDirectories).ToList(); - if (epicDllDirectories is not null) - dllDirectories = dllDirectories.Union(epicDllDirectories).ToList(); - if (steamDllDirectories is not null || epicDllDirectories is not null) + List dllDirectories = await ParadoxLauncher.InstallPath.GetDllDirectoriesFromGameDirectory(Platform.Paradox); + if (dllDirectories is not null) { ProgramSelection selection = ProgramSelection.FromPlatformId(Platform.Paradox, "PL"); selection ??= new(); @@ -155,7 +149,7 @@ internal partial class SelectForm : CustomForm Task task = Task.Run(async () => { if (Program.Canceled) return; - List dllDirectories = await SteamLibrary.GetDllDirectoriesFromGameDirectory(gameDirectory); + List dllDirectories = await gameDirectory.GetDllDirectoriesFromGameDirectory(Platform.Steam); if (dllDirectories is null) { Interlocked.Decrement(ref steamGamesToCheck); @@ -296,7 +290,7 @@ internal partial class SelectForm : CustomForm Task task = Task.Run(async () => { if (Program.Canceled) return; - List dllDirectories = await EpicLibrary.GetDllDirectoriesFromGameDirectory(directory); + List dllDirectories = await directory.GetDllDirectoriesFromGameDirectory(Platform.Epic); if (dllDirectories is null) { RemoveFromRemainingGames(name); @@ -410,7 +404,7 @@ internal partial class SelectForm : CustomForm Task task = Task.Run(async () => { if (Program.Canceled) return; - List dllDirectories = await UbisoftLibrary.GetDllDirectoriesFromGameDirectory(gameDirectory); + List dllDirectories = await gameDirectory.GetDllDirectoriesFromGameDirectory(Platform.Ubisoft); if (dllDirectories is null) { RemoveFromRemainingGames(name); diff --git a/CreamInstaller/Resources/Koaloader.cs b/CreamInstaller/Resources/Koaloader.cs index 1a5847e..30a86b4 100644 --- a/CreamInstaller/Resources/Koaloader.cs +++ b/CreamInstaller/Resources/Koaloader.cs @@ -165,108 +165,85 @@ internal static class Koaloader path.WriteProxy(selection.KoaloaderProxy, binaryType); if (installForm is not null) installForm.UpdateUser($"Wrote {(binaryType == BinaryType.BIT32 ? "32-bit" : "64-bit")} Koaloader: {Path.GetFileName(path)}", InstallationLog.Action, info: false); - if (selection.Platform is Platform.Steam or Platform.Paradox) - { - bool did32 = false, did64 = false; - foreach (string dllDirectory in selection.DllDirectories) + bool bit32 = false, bit64 = false; + foreach (string executable in Directory.EnumerateFiles(directory, "*.exe")) + if (executable.TryGetFileBinaryType(out BinaryType binaryType)) { - dllDirectory.GetSmokeApiComponents(out string api32, out _, out string api64, out _, out _, out _); - if (!did32 && File.Exists(api32)) - { - did32 = true; - path = directory + @"\SmokeAPI32.dll"; - "SmokeAPI.steam_api.dll".Write(path); - if (installForm is not null) - installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); - } - if (!did64 && File.Exists(api64)) - { - did64 = true; - path = directory + @"\SmokeAPI64.dll"; - "SmokeAPI.steam_api64.dll".Write(path); - if (installForm is not null) - installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); - } - if (did32 && did64) + if (binaryType == BinaryType.BIT32) + bit32 = true; + else if (binaryType == BinaryType.BIT64) + bit64 = true; + if (bit32 && bit64) break; } - if (did32 || did64) - SmokeAPI.CheckConfig(directory, selection, installForm); + if (selection.Platform is Platform.Steam or Platform.Paradox) + { + if (bit32) + { + path = directory + @"\SmokeAPI32.dll"; + "SmokeAPI.steam_api.dll".Write(path); + if (installForm is not null) + installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); + } + if (bit64) + { + path = directory + @"\SmokeAPI64.dll"; + "SmokeAPI.steam_api64.dll".Write(path); + if (installForm is not null) + installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); + } + SmokeAPI.CheckConfig(directory, selection, installForm); } if (selection.Platform is Platform.Epic or Platform.Paradox) { - bool did32 = false, did64 = false; - foreach (string dllDirectory in selection.DllDirectories) + if (bit32) { - dllDirectory.GetScreamApiComponents(out string api32, out _, out string api64, out _, out _); - if (!did32 && File.Exists(api32)) - { - did32 = true; - path = directory + @"\ScreamAPI32.dll"; - "ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(path); - if (installForm is not null) - installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); - } - if (!did64 && File.Exists(api64)) - { - did64 = true; - path = directory + @"\ScreamAPI64.dll"; - "ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(path); - if (installForm is not null) - installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); - } - if (did32 && did64) - break; + path = directory + @"\ScreamAPI32.dll"; + "ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(path); + if (installForm is not null) + installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); } - if (did32 || did64) - ScreamAPI.CheckConfig(directory, selection, installForm); + if (bit64) + { + path = directory + @"\ScreamAPI64.dll"; + "ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(path); + if (installForm is not null) + installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); + } + ScreamAPI.CheckConfig(directory, selection, installForm); } if (selection.Platform is Platform.Ubisoft) { - bool did32r1 = false, did64r1 = false, did32r2 = false, did64r2 = false; - foreach (string dllDirectory in selection.DllDirectories) + if (bit32) { - dllDirectory.GetUplayR1Components(out string api32, out _, out string api64, out _, out _); - if (!did32r1 && File.Exists(api32)) - { - did32r1 = true; - path = directory + @"\UplayR1Unlocker32.dll"; - "UplayR1.uplay_r1_loader.dll".Write(path); - if (installForm is not null) - installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); - } - if (!did64r1 && File.Exists(api64)) - { - did64r1 = true; - path = directory + @"\UplayR1Unlocker64.dll"; - "UplayR1.uplay_r1_loader64.dll".Write(path); - if (installForm is not null) - installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); - } - dllDirectory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out _, out api64, out _, out _); - if (!did32r2 && (File.Exists(old_api32) || File.Exists(old_api32))) - { - did32r2 = true; - path = directory + @"\UplayR2Unlocker32.dll"; - "UplayR2.upc_r2_loader.dll".Write(path); - if (installForm is not null) - installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); - } - if (!did64r2 && (File.Exists(old_api64) || File.Exists(api64))) - { - did64r2 = true; - path = directory + @"\UplayR2Unlocker64.dll"; - "UplayR2.upc_r2_loader64.dll".Write(path); - if (installForm is not null) - installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); - } - if (did32r1 && did64r1 && did32r2 && did64r2) - break; + path = directory + @"\UplayR1Unlocker32.dll"; + "UplayR1.uplay_r1_loader.dll".Write(path); + if (installForm is not null) + installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); } - if (did32r1 || did64r1) - UplayR1.CheckConfig(directory, selection, installForm); - if (did32r2 || did64r2) - UplayR2.CheckConfig(directory, selection, installForm); + if (bit64) + { + path = directory + @"\UplayR1Unlocker64.dll"; + "UplayR1.uplay_r1_loader64.dll".Write(path); + if (installForm is not null) + installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); + } + UplayR1.CheckConfig(directory, selection, installForm); + if (bit32) + { + path = directory + @"\UplayR2Unlocker32.dll"; + "UplayR2.upc_r2_loader.dll".Write(path); + if (installForm is not null) + installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); + } + if (bit64) + { + path = directory + @"\UplayR2Unlocker64.dll"; + "UplayR2.upc_r2_loader64.dll".Write(path); + if (installForm is not null) + installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); + } + UplayR2.CheckConfig(directory, selection, installForm); } if (generateConfig) CheckConfig(directory, selection, installForm); diff --git a/CreamInstaller/Resources/Resources.cs b/CreamInstaller/Resources/Resources.cs index 84fa11f..eb2c5bd 100644 --- a/CreamInstaller/Resources/Resources.cs +++ b/CreamInstaller/Resources/Resources.cs @@ -77,6 +77,41 @@ internal static class Resources private static extern bool GetBinaryType(string lpApplicationName, out BinaryType lpBinaryType); internal static bool TryGetFileBinaryType(this string path, out BinaryType binaryType) => GetBinaryType(path, out binaryType); + internal static async Task> GetExecutableDirectories(this string rootDirectory, bool filterCommon = false, Func validFunc = null) => + await Task.Run(async () => (await rootDirectory.GetExecutables(filterCommon: filterCommon, validFunc: validFunc) ?? await rootDirectory.GetExecutables()).Select(e => + { + e.path = Path.GetDirectoryName(e.path); + return e; + }).DistinctBy(e => e.path).ToList()); + + internal static async Task> GetExecutables(this string rootDirectory, bool filterCommon = false, Func validFunc = null) => await Task.Run(() => + { + List<(string path, BinaryType binaryType)> executables = new(); + if (Program.Canceled || !Directory.Exists(rootDirectory)) return null; + List files = new(Directory.EnumerateFiles(rootDirectory, "*.exe", new EnumerationOptions() { RecurseSubdirectories = true })); + foreach (string path in files) + { + if (Program.Canceled) return null; + Thread.Sleep(0); + if (!executables.Any(e => e.path == path) + && (!filterCommon || !rootDirectory.IsCommonIncorrectExecutable(path)) + && (validFunc is null || validFunc(path)) + && path.TryGetFileBinaryType(out BinaryType binaryType) && binaryType is BinaryType.BIT64) + executables.Add((path, binaryType)); + } + foreach (string path in files) + { + if (Program.Canceled) return null; + Thread.Sleep(0); + if (!executables.Any(e => e.path == path) + && (!filterCommon || !rootDirectory.IsCommonIncorrectExecutable(path)) + && (validFunc is null || validFunc(path)) + && path.TryGetFileBinaryType(out BinaryType binaryType) && binaryType is BinaryType.BIT32) + executables.Add((path, binaryType)); + } + return !executables.Any() ? null : executables; + }); + internal static bool IsCommonIncorrectExecutable(this string rootDirectory, string path) { string subPath = path[rootDirectory.Length..].ToUpperInvariant().BeautifyPath(); @@ -84,53 +119,58 @@ internal static class Resources || subPath.Contains("CRASH") && (subPath.Contains("PAD") || subPath.Contains("REPORT")); } - internal static async Task> GetExecutables(this string rootDirectory, string subDirectory = null, bool filterCommon = false, Func validFunc = null) => - await Task.Run(async () => + internal static async Task> GetDllDirectoriesFromGameDirectory(this string gameDirectory, Platform platform, List dllDirectories = null) => await Task.Run(() => + { + dllDirectories ??= new(); + if (Program.Canceled || !Directory.Exists(gameDirectory)) return null; + List directories = new(Directory.EnumerateDirectories(gameDirectory, "*", new EnumerationOptions() { RecurseSubdirectories = true })) { gameDirectory }; + foreach (string subDirectory in directories) { - List<(string path, BinaryType binaryType)> executables = new(); - if (Program.Canceled || !Directory.Exists(subDirectory ?? rootDirectory)) return null; + if (Program.Canceled) return null; Thread.Sleep(0); - string[] files = Directory.GetFiles(subDirectory ?? rootDirectory, "*.exe"); - foreach (string path in files) + if (platform is Platform.Steam or Platform.Paradox) { - Thread.Sleep(0); - if (!executables.Any(e => e.path == path) - && (!filterCommon || !rootDirectory.IsCommonIncorrectExecutable(path)) - && (validFunc is null || validFunc(path)) - && path.TryGetFileBinaryType(out BinaryType binaryType) && binaryType is BinaryType.BIT64) - executables.Add((path, binaryType)); + subDirectory.GetSmokeApiComponents(out string api, out string api_o, out string api64, out string api64_o, out string config, out string cache); + if (File.Exists(api) + || File.Exists(api_o) + || File.Exists(api64) + || File.Exists(api64_o) + || File.Exists(config) + || File.Exists(cache)) + dllDirectories.Add(subDirectory.BeautifyPath()); } - foreach (string path in files) + if (platform is Platform.Epic or Platform.Paradox) { - Thread.Sleep(0); - if (!executables.Any(e => e.path == path) - && (!filterCommon || !rootDirectory.IsCommonIncorrectExecutable(path)) - && (validFunc is null || validFunc(path)) - && path.TryGetFileBinaryType(out BinaryType binaryType) && binaryType is BinaryType.BIT32) - executables.Add((path, binaryType)); + subDirectory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config); + if (File.Exists(api32) + || File.Exists(api32_o) + || File.Exists(api64) + || File.Exists(api64_o) + || File.Exists(config)) + dllDirectories.Add(subDirectory.BeautifyPath()); } - string[] directories = Directory.GetDirectories(subDirectory ?? rootDirectory); - foreach (string directory in directories) + if (platform is Platform.Ubisoft) { - if (Program.Canceled) return null; - Thread.Sleep(0); - try - { - List<(string path, BinaryType binaryType)> moreExecutables = await rootDirectory.GetExecutables(directory, filterCommon, validFunc); - if (moreExecutables is not null) - executables.AddRange(moreExecutables); - } - catch { } + subDirectory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config); + if (File.Exists(api32) + || File.Exists(api32_o) + || File.Exists(api64) + || File.Exists(api64_o) + || File.Exists(config)) + dllDirectories.Add(subDirectory.BeautifyPath()); + subDirectory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config); + if (File.Exists(old_api32) + || File.Exists(old_api64) + || File.Exists(api32) + || File.Exists(api32_o) + || File.Exists(api64) + || File.Exists(api64_o) + || File.Exists(config)) + dllDirectories.Add(subDirectory.BeautifyPath()); } - return !executables.Any() ? null : executables; - }); - - internal static async Task> GetExecutableDirectories(this string rootDirectory, bool filterCommon = false, Func validFunc = null) => - await Task.Run(async () => (await rootDirectory.GetExecutables(filterCommon: filterCommon, validFunc: validFunc) ?? await rootDirectory.GetExecutables()).Select(e => - { - e.path = Path.GetDirectoryName(e.path); - return e; - }).DistinctBy(e => e.path).ToList()); + } + return !dllDirectories.Any() ? null : new List(dllDirectories.Distinct()); + }); internal static void GetCreamApiComponents( this string directory, diff --git a/CreamInstaller/Steam/SteamCMD.cs b/CreamInstaller/Steam/SteamCMD.cs index b272d60..819288b 100644 --- a/CreamInstaller/Steam/SteamCMD.cs +++ b/CreamInstaller/Steam/SteamCMD.cs @@ -156,15 +156,15 @@ internal static class SteamCMD try { if (Directory.Exists(ConfigPath)) - foreach (string file in Directory.GetFiles(ConfigPath, "*.tmp")) + foreach (string file in Directory.EnumerateFiles(ConfigPath, "*.tmp")) File.Delete(file); - foreach (string file in Directory.GetFiles(DirectoryPath, "*.old")) + foreach (string file in Directory.EnumerateFiles(DirectoryPath, "*.old")) File.Delete(file); - foreach (string file in Directory.GetFiles(DirectoryPath, "*.delete")) + foreach (string file in Directory.EnumerateFiles(DirectoryPath, "*.delete")) File.Delete(file); - foreach (string file in Directory.GetFiles(DirectoryPath, "*.crash")) + foreach (string file in Directory.EnumerateFiles(DirectoryPath, "*.crash")) File.Delete(file); - foreach (string file in Directory.GetFiles(DirectoryPath, "*.ntfs_transaction_failed")) + foreach (string file in Directory.EnumerateFiles(DirectoryPath, "*.ntfs_transaction_failed")) File.Delete(file); if (Directory.Exists(AppCachePath)) Directory.Delete(AppCachePath, true); // this is definitely needed, so SteamCMD gets the latest information for us diff --git a/CreamInstaller/Steam/SteamLibrary.cs b/CreamInstaller/Steam/SteamLibrary.cs index 296773e..46a2ee5 100644 --- a/CreamInstaller/Steam/SteamLibrary.cs +++ b/CreamInstaller/Steam/SteamLibrary.cs @@ -47,38 +47,11 @@ internal static class SteamLibrary return games; }); - internal static async Task> GetDllDirectoriesFromGameDirectory(string gameDirectory) => await Task.Run(async () => - { - List dllDirectories = new(); - if (Program.Canceled || !Directory.Exists(gameDirectory)) return null; - gameDirectory.GetSmokeApiComponents(out string api, out string api_o, out string api64, out string api64_o, out string config, out string cache); - if (File.Exists(api) - || File.Exists(api_o) - || File.Exists(api64) - || File.Exists(api64_o) - || File.Exists(config) - || File.Exists(cache)) - dllDirectories.Add(gameDirectory.BeautifyPath()); - string[] directories = Directory.GetDirectories(gameDirectory); - foreach (string _directory in directories) - { - if (Program.Canceled) return null; - try - { - List moreDllDirectories = await GetDllDirectoriesFromGameDirectory(_directory); - if (moreDllDirectories is not null) dllDirectories.AddRange(moreDllDirectories); - } - catch { } - } - return !dllDirectories.Any() ? null : dllDirectories; - }); - internal static async Task> GetGamesFromLibraryDirectory(string libraryDirectory) => await Task.Run(() => { List<(string appId, string name, string branch, int buildId, string gameDirectory)> games = new(); if (Program.Canceled || !Directory.Exists(libraryDirectory)) return null; - string[] files = Directory.GetFiles(libraryDirectory, "*.acf"); - foreach (string file in files) + foreach (string file in Directory.EnumerateFiles(libraryDirectory, "*.acf")) { if (Program.Canceled) return null; if (ValveDataFile.TryDeserialize(File.ReadAllText(file, Encoding.UTF8), out VProperty result)) diff --git a/CreamInstaller/Steam/SteamStore.cs b/CreamInstaller/Steam/SteamStore.cs index ca9c40b..5d559c4 100644 --- a/CreamInstaller/Steam/SteamStore.cs +++ b/CreamInstaller/Steam/SteamStore.cs @@ -41,6 +41,7 @@ internal static class SteamStore { IDictionary apps = (IDictionary)JsonConvert.DeserializeObject(response); if (apps is not null) + { foreach (KeyValuePair app in apps) { try @@ -76,7 +77,22 @@ internal static class SteamStore { } #endif } + } +#if DEBUG + else + { + using DialogForm dialogForm = new(null); + dialogForm.Show(SystemIcons.Error, "Response deserialization null for appid: " + appId); + } +#endif } +#if DEBUG + else + { + using DialogForm dialogForm = new(null); + dialogForm.Show(SystemIcons.Error, "Response null for appid: " + appId); + } +#endif } if (cachedExists) { diff --git a/CreamInstaller/Ubisoft/UbisoftLibrary.cs b/CreamInstaller/Ubisoft/UbisoftLibrary.cs index 74dcf61..e873bca 100644 --- a/CreamInstaller/Ubisoft/UbisoftLibrary.cs +++ b/CreamInstaller/Ubisoft/UbisoftLibrary.cs @@ -5,7 +5,6 @@ using Microsoft.Win32; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Threading.Tasks; using static CreamInstaller.Resources.Resources; @@ -42,41 +41,4 @@ internal static class UbisoftLibrary } return games; }); - - internal static async Task> GetDllDirectoriesFromGameDirectory(string gameDirectory) => await Task.Run(async () => - { - List dllDirectories = new(); - if (Program.Canceled || !Directory.Exists(gameDirectory)) return null; - gameDirectory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config); - if (File.Exists(api32) - || File.Exists(api32_o) - || File.Exists(api64) - || File.Exists(api64_o) - || File.Exists(config)) - dllDirectories.Add(gameDirectory.BeautifyPath()); - else - { - gameDirectory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config); - if (File.Exists(old_api32) - || File.Exists(old_api64) - || File.Exists(api32) - || File.Exists(api32_o) - || File.Exists(api64) - || File.Exists(api64_o) - || File.Exists(config)) - dllDirectories.Add(gameDirectory.BeautifyPath()); - } - string[] directories = Directory.GetDirectories(gameDirectory); - foreach (string _directory in directories) - { - if (Program.Canceled) return null; - try - { - List moreDllDirectories = await GetDllDirectoriesFromGameDirectory(_directory); - if (moreDllDirectories is not null) dllDirectories.AddRange(moreDllDirectories); - } - catch { } - } - return !dllDirectories.Any() ? null : dllDirectories; - }); }