From 3d63457a45099fb5f494a7544b403984f168707c Mon Sep 17 00:00:00 2001 From: pointfeev Date: Sun, 29 Jan 2023 20:22:28 -0500 Subject: [PATCH] name conflict fix --- CreamInstaller/Forms/MainForm.cs | 4 ++-- .../Platforms/Paradox/ParadoxLauncher.cs | 8 +++---- CreamInstaller/Platforms/Steam/SteamCMD.cs | 2 +- CreamInstaller/Resources/Koaloader.cs | 18 +++++++-------- CreamInstaller/Resources/Resources.cs | 23 +++++++++++++++---- CreamInstaller/Resources/ScreamAPI.cs | 4 ++-- CreamInstaller/Resources/SmokeAPI.cs | 4 ++-- CreamInstaller/Resources/UplayR1.cs | 4 ++-- CreamInstaller/Resources/UplayR2.cs | 4 ++-- 9 files changed, 43 insertions(+), 28 deletions(-) diff --git a/CreamInstaller/Forms/MainForm.cs b/CreamInstaller/Forms/MainForm.cs index 176081a..57d2452 100644 --- a/CreamInstaller/Forms/MainForm.cs +++ b/CreamInstaller/Forms/MainForm.cs @@ -76,8 +76,8 @@ internal sealed partial class MainForm : CustomForm if (checkForUpdatesResult.CanUpdate) { #endif - latestVersion = checkForUpdatesResult.LastVersion; - versions = checkForUpdatesResult.Versions; + latestVersion = checkForUpdatesResult.LastVersion; + versions = checkForUpdatesResult.Versions; #if !DEBUG } #endif diff --git a/CreamInstaller/Platforms/Paradox/ParadoxLauncher.cs b/CreamInstaller/Platforms/Paradox/ParadoxLauncher.cs index 0bcf27e..44a390d 100644 --- a/CreamInstaller/Platforms/Paradox/ParadoxLauncher.cs +++ b/CreamInstaller/Platforms/Paradox/ParadoxLauncher.cs @@ -122,13 +122,13 @@ internal static class ParadoxLauncher directory.GetSmokeApiComponents(out string api32, out _, out string api64, out _, out _, out _, out _, out _, out _); if (steamOriginalSdk32 is not null && api32.IsResourceFile(ResourceIdentifier.Steamworks32)) { - steamOriginalSdk32.Write(api32); + steamOriginalSdk32.WriteResource(api32); installForm?.UpdateUser("Corrected Steamworks: " + api32, LogTextBox.Action); neededRepair = true; } if (steamOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.Steamworks64)) { - steamOriginalSdk64.Write(api64); + steamOriginalSdk64.WriteResource(api64); installForm?.UpdateUser("Corrected Steamworks: " + api64, LogTextBox.Action); neededRepair = true; } @@ -137,13 +137,13 @@ internal static class ParadoxLauncher directory.GetScreamApiComponents(out api32, out _, out api64, out _, out _, out _); if (epicOriginalSdk32 is not null && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32)) { - epicOriginalSdk32.Write(api32); + epicOriginalSdk32.WriteResource(api32); installForm?.UpdateUser("Corrected Epic Online Services: " + api32, LogTextBox.Action); neededRepair = true; } if (epicOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64)) { - epicOriginalSdk64.Write(api64); + epicOriginalSdk64.WriteResource(api64); installForm?.UpdateUser("Corrected Epic Online Services: " + api64, LogTextBox.Action); neededRepair = true; } diff --git a/CreamInstaller/Platforms/Steam/SteamCMD.cs b/CreamInstaller/Platforms/Steam/SteamCMD.cs index 9cb9d79..c1d2979 100644 --- a/CreamInstaller/Platforms/Steam/SteamCMD.cs +++ b/CreamInstaller/Platforms/Steam/SteamCMD.cs @@ -126,7 +126,7 @@ internal static class SteamCMD if (httpClient is null) return; byte[] file = await httpClient.GetByteArrayAsync(new Uri("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip")); - file.Write(ArchivePath); + file.WriteResource(ArchivePath); ZipFile.ExtractToDirectory(ArchivePath, DirectoryPath); ArchivePath.Delete(); } diff --git a/CreamInstaller/Resources/Koaloader.cs b/CreamInstaller/Resources/Koaloader.cs index ed11585..6199d1e 100644 --- a/CreamInstaller/Resources/Koaloader.cs +++ b/CreamInstaller/Resources/Koaloader.cs @@ -43,7 +43,7 @@ internal static class Koaloader resourceIdentifier.GetProxyInfoFromIdentifier(out string _proxyName, out BinaryType _binaryType); if (_proxyName != proxyName || _binaryType != binaryType) continue; - resourceIdentifier.Write(path); + resourceIdentifier.WriteManifestResource(path); break; } } @@ -213,7 +213,7 @@ internal static class Koaloader } path = rootDirectory + @"\SmokeAPI32.dll"; } - "SmokeAPI.steam_api.dll".Write(path); + "SmokeAPI.steam_api.dll".WriteManifestResource(path); installForm?.UpdateUser( $"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, false); @@ -230,7 +230,7 @@ internal static class Koaloader } path = rootDirectory + @"\SmokeAPI64.dll"; } - "SmokeAPI.steam_api64.dll".Write(path); + "SmokeAPI.steam_api64.dll".WriteManifestResource(path); installForm?.UpdateUser( $"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, false); @@ -253,7 +253,7 @@ internal static class Koaloader } path = rootDirectory + @"\ScreamAPI32.dll"; } - "ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(path); + "ScreamAPI.EOSSDK-Win32-Shipping.dll".WriteManifestResource(path); installForm?.UpdateUser( $"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, false); @@ -270,7 +270,7 @@ internal static class Koaloader } path = rootDirectory + @"\ScreamAPI64.dll"; } - "ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(path); + "ScreamAPI.EOSSDK-Win64-Shipping.dll".WriteManifestResource(path); installForm?.UpdateUser( $"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, false); @@ -293,7 +293,7 @@ internal static class Koaloader } path = rootDirectory + @"\UplayR1Unlocker32.dll"; } - "UplayR1.uplay_r1_loader.dll".Write(path); + "UplayR1.uplay_r1_loader.dll".WriteManifestResource(path); installForm?.UpdateUser( $"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, false); @@ -311,7 +311,7 @@ internal static class Koaloader } path = rootDirectory + @"\UplayR1Unlocker64.dll"; } - "UplayR1.uplay_r1_loader64.dll".Write(path); + "UplayR1.uplay_r1_loader64.dll".WriteManifestResource(path); installForm?.UpdateUser( $"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, false); @@ -330,7 +330,7 @@ internal static class Koaloader } path = rootDirectory + @"\UplayR2Unlocker32.dll"; } - "UplayR2.upc_r2_loader.dll".Write(path); + "UplayR2.upc_r2_loader.dll".WriteManifestResource(path); installForm?.UpdateUser( $"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, false); @@ -348,7 +348,7 @@ internal static class Koaloader } path = rootDirectory + @"\UplayR2Unlocker64.dll"; } - "UplayR2.upc_r2_loader64.dll".Write(path); + "UplayR2.upc_r2_loader64.dll".WriteManifestResource(path); installForm?.UpdateUser( $"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, false); diff --git a/CreamInstaller/Resources/Resources.cs b/CreamInstaller/Resources/Resources.cs index 7eeefec..a0ef27e 100644 --- a/CreamInstaller/Resources/Resources.cs +++ b/CreamInstaller/Resources/Resources.cs @@ -8,6 +8,7 @@ using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using CreamInstaller.Forms; using CreamInstaller.Utility; namespace CreamInstaller.Resources; @@ -437,14 +438,28 @@ internal static class Resources } } - internal static void Write(this string resourceIdentifier, string filePath) + internal static void WriteManifestResource(this string resourceIdentifier, string filePath) { using Stream resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("CreamInstaller.Resources." + resourceIdentifier); - using FileStream file = new(filePath, FileMode.Create, FileAccess.Write); - resource?.CopyTo(file); + try + { + using FileStream file = new(filePath, FileMode.Create, FileAccess.Write); + resource?.CopyTo(file); + } +#if DEBUG + catch (Exception e) + { + DebugForm.Current.Log("resource write exception for '" + resourceIdentifier + "' to '" + filePath + "': " + e); + } +#else + catch + { + //ignored + } +#endif } - internal static void Write(this byte[] resource, string filePath) + internal static void WriteResource(this byte[] resource, string filePath) { using FileStream fileStream = new(filePath, FileMode.Create, FileAccess.Write); fileStream.Write(resource); diff --git a/CreamInstaller/Resources/ScreamAPI.cs b/CreamInstaller/Resources/ScreamAPI.cs index 96bdf17..891f189 100644 --- a/CreamInstaller/Resources/ScreamAPI.cs +++ b/CreamInstaller/Resources/ScreamAPI.cs @@ -150,7 +150,7 @@ internal static class ScreamAPI } if (api32_o.Exists(form: installForm)) { - "ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(api32); + "ScreamAPI.EOSSDK-Win32-Shipping.dll".WriteManifestResource(api32); installForm?.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false); } if (api64.Exists(form: installForm) && !api64_o.Exists(form: installForm)) @@ -160,7 +160,7 @@ internal static class ScreamAPI } if (api64_o.Exists(form: installForm)) { - "ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(api64); + "ScreamAPI.EOSSDK-Win64-Shipping.dll".WriteManifestResource(api64); installForm?.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false); } if (generateConfig) diff --git a/CreamInstaller/Resources/SmokeAPI.cs b/CreamInstaller/Resources/SmokeAPI.cs index 1db9394..991d064 100644 --- a/CreamInstaller/Resources/SmokeAPI.cs +++ b/CreamInstaller/Resources/SmokeAPI.cs @@ -228,7 +228,7 @@ internal static class SmokeAPI } if (api32_o.Exists(form: installForm)) { - "SmokeAPI.steam_api.dll".Write(api32); + "SmokeAPI.steam_api.dll".WriteManifestResource(api32); installForm?.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false); } if (api64.Exists(form: installForm) && !api64_o.Exists(form: installForm)) @@ -238,7 +238,7 @@ internal static class SmokeAPI } if (api64_o.Exists(form: installForm)) { - "SmokeAPI.steam_api64.dll".Write(api64); + "SmokeAPI.steam_api64.dll".WriteManifestResource(api64); installForm?.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false); } if (generateConfig) diff --git a/CreamInstaller/Resources/UplayR1.cs b/CreamInstaller/Resources/UplayR1.cs index a64f120..7a52f7f 100644 --- a/CreamInstaller/Resources/UplayR1.cs +++ b/CreamInstaller/Resources/UplayR1.cs @@ -120,7 +120,7 @@ internal static class UplayR1 } if (api32_o.Exists(form: installForm)) { - "UplayR1.uplay_r1_loader.dll".Write(api32); + "UplayR1.uplay_r1_loader.dll".WriteManifestResource(api32); installForm?.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, false); } if (api64.Exists(form: installForm) && !api64_o.Exists(form: installForm)) @@ -130,7 +130,7 @@ internal static class UplayR1 } if (api64_o.Exists(form: installForm)) { - "UplayR1.uplay_r1_loader64.dll".Write(api64); + "UplayR1.uplay_r1_loader64.dll".WriteManifestResource(api64); installForm?.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, false); } if (generateConfig) diff --git a/CreamInstaller/Resources/UplayR2.cs b/CreamInstaller/Resources/UplayR2.cs index 7cc9014..b00c029 100644 --- a/CreamInstaller/Resources/UplayR2.cs +++ b/CreamInstaller/Resources/UplayR2.cs @@ -129,7 +129,7 @@ internal static class UplayR2 } if (api32_o.Exists(form: installForm)) { - "UplayR2.upc_r2_loader.dll".Write(api); + "UplayR2.upc_r2_loader.dll".WriteManifestResource(api); installForm?.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false); } api = old_api64.Exists(form: installForm) ? old_api64 : api64; @@ -140,7 +140,7 @@ internal static class UplayR2 } if (api64_o.Exists(form: installForm)) { - "UplayR2.upc_r2_loader64.dll".Write(api); + "UplayR2.upc_r2_loader64.dll".WriteManifestResource(api); installForm?.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false); } if (generateConfig)