diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj
index ab841dc..266bd85 100644
--- a/CreamInstaller/CreamInstaller.csproj
+++ b/CreamInstaller/CreamInstaller.csproj
@@ -5,7 +5,7 @@
True
Resources\ini.ico
true
- 3.5.2.1
+ 3.5.3.0
Resources\ini.ico
LICENSE
2021, pointfeev (https://github.com/pointfeev)
diff --git a/CreamInstaller/Epic/EpicLibrary.cs b/CreamInstaller/Epic/EpicLibrary.cs
index 37c17ee..b4b3ba8 100644
--- a/CreamInstaller/Epic/EpicLibrary.cs
+++ b/CreamInstaller/Epic/EpicLibrary.cs
@@ -5,6 +5,8 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
+using CreamInstaller.Resources;
+
using Microsoft.Win32;
namespace CreamInstaller.Epic;
diff --git a/CreamInstaller/Forms/InstallForm.cs b/CreamInstaller/Forms/InstallForm.cs
index 865da8b..b24c5d2 100644
--- a/CreamInstaller/Forms/InstallForm.cs
+++ b/CreamInstaller/Forms/InstallForm.cs
@@ -81,18 +81,23 @@ internal partial class InstallForm : CustomForm
}
else
writer.WriteLine(" \"override\": [],");
- writer.WriteLine(" \"dlc_ids\": [");
- KeyValuePair lastAllDlc = allDlc.Last();
- foreach (KeyValuePair pair in allDlc)
+ if (allDlc.Count > 0)
{
- Thread.Sleep(0);
- string dlcId = pair.Key;
- (_, string dlcName, _) = pair.Value;
- writer.WriteLine($" {dlcId}{(pair.Equals(lastAllDlc) ? "" : ",")}");
- if (installForm is not null)
- installForm.UpdateUser($"Added DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", InstallationLog.Action, info: false);
+ writer.WriteLine(" \"dlc_ids\": [");
+ KeyValuePair lastAllDlc = allDlc.Last();
+ foreach (KeyValuePair pair in allDlc)
+ {
+ Thread.Sleep(0);
+ string dlcId = pair.Key;
+ (_, string dlcName, _) = pair.Value;
+ writer.WriteLine($" {dlcId}{(pair.Equals(lastAllDlc) ? "" : ",")}");
+ if (installForm is not null)
+ installForm.UpdateUser($"Added DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", InstallationLog.Action, info: false);
+ }
+ writer.WriteLine(" ],");
}
- writer.WriteLine(" ],");
+ else
+ writer.WriteLine(" \"dlc_ids\": [],");
writer.WriteLine(" \"auto_inject_inventory\": true,");
writer.WriteLine(" \"inventory_items\": []");
writer.WriteLine("}");
@@ -135,6 +140,13 @@ internal partial class InstallForm : CustomForm
internal static async Task InstallSmokeAPI(string directory, ProgramSelection selection, InstallForm installForm = null) => await Task.Run(() =>
{
+ directory.GetCreamApiComponents(out _, out _, out _, out _, out string oldConfig);
+ if (File.Exists(oldConfig))
+ {
+ File.Delete(oldConfig);
+ if (installForm is not null)
+ installForm.UpdateUser($"Deleted old config: {Path.GetFileName(oldConfig)}", InstallationLog.Action, info: false);
+ }
directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config);
if (File.Exists(sdk32) && !File.Exists(sdk32_o))
{
diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs
index d005f3f..54c81fb 100644
--- a/CreamInstaller/Forms/SelectForm.cs
+++ b/CreamInstaller/Forms/SelectForm.cs
@@ -12,6 +12,7 @@ using System.Windows.Forms;
using CreamInstaller.Components;
using CreamInstaller.Epic;
using CreamInstaller.Paradox;
+using CreamInstaller.Resources;
using CreamInstaller.Steam;
using CreamInstaller.Utility;
diff --git a/CreamInstaller/Paradox/ParadoxLauncher.cs b/CreamInstaller/Paradox/ParadoxLauncher.cs
index 865a395..97a7a66 100644
--- a/CreamInstaller/Paradox/ParadoxLauncher.cs
+++ b/CreamInstaller/Paradox/ParadoxLauncher.cs
@@ -8,6 +8,8 @@ using CreamInstaller.Resources;
using Microsoft.Win32;
+using static CreamInstaller.Resources.Resources;
+
namespace CreamInstaller.Paradox;
internal static class ParadoxLauncher
@@ -67,7 +69,7 @@ internal static class ParadoxLauncher
internal static async Task Repair(Form form, ProgramSelection selection)
{
if (!Program.IsProgramRunningDialog(form, selection)) return -2;
- byte[] creamConfig = null;
+ byte[] smokeConfig = null;
byte[] steamOriginalSdk32 = null;
byte[] steamOriginalSdk64 = null;
byte[] screamConfig = null;
@@ -76,20 +78,20 @@ internal static class ParadoxLauncher
foreach (string directory in selection.DllDirectories)
{
directory.GetSmokeApiComponents(out string sdk32, out string _, out string sdk64, out string _, out string config);
- if (creamConfig is null && File.Exists(config))
- creamConfig = File.ReadAllBytes(config);
+ if (smokeConfig is null && File.Exists(config))
+ smokeConfig = File.ReadAllBytes(config);
await InstallForm.UninstallSmokeAPI(directory);
- if (steamOriginalSdk32 is null && File.Exists(sdk32) && !Properties.Resources.Steamworks32.EqualsFile(sdk32))
+ if (steamOriginalSdk32 is null && File.Exists(sdk32) && !sdk32.IsResourceFile(ResourceIdentifier.Steamworks32))
steamOriginalSdk32 = File.ReadAllBytes(sdk32);
- if (steamOriginalSdk64 is null && File.Exists(sdk64) && !Properties.Resources.Steamworks64.EqualsFile(sdk64))
+ if (steamOriginalSdk64 is null && File.Exists(sdk64) && !sdk64.IsResourceFile(ResourceIdentifier.Steamworks64))
steamOriginalSdk64 = File.ReadAllBytes(sdk64);
directory.GetScreamApiComponents(out sdk32, out string _, out sdk64, out string _, out config);
if (screamConfig is null && File.Exists(config))
screamConfig = File.ReadAllBytes(config);
await InstallForm.UninstallScreamAPI(directory);
- if (epicOriginalSdk32 is null && File.Exists(sdk32) && !Properties.Resources.EpicOnlineServices32.EqualsFile(sdk32))
+ if (epicOriginalSdk32 is null && File.Exists(sdk32) && !sdk32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32))
epicOriginalSdk32 = File.ReadAllBytes(sdk32);
- if (epicOriginalSdk64 is null && File.Exists(sdk64) && !Properties.Resources.EpicOnlineServices64.EqualsFile(sdk64))
+ if (epicOriginalSdk64 is null && File.Exists(sdk64) && !sdk64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64))
epicOriginalSdk64 = File.ReadAllBytes(sdk64);
}
using DialogForm dialogForm = new(form);
@@ -99,29 +101,29 @@ internal static class ParadoxLauncher
foreach (string directory in selection.DllDirectories)
{
directory.GetSmokeApiComponents(out string sdk32, out string _, out string sdk64, out string _, out string config);
- if (steamOriginalSdk32 is not null && Properties.Resources.Steamworks32.EqualsFile(sdk32))
+ if (steamOriginalSdk32 is not null && sdk32.IsResourceFile(ResourceIdentifier.Steamworks32))
{
steamOriginalSdk32.Write(sdk32);
neededRepair = true;
}
- if (steamOriginalSdk64 is not null && Properties.Resources.Steamworks64.EqualsFile(sdk64))
+ if (steamOriginalSdk64 is not null && sdk64.IsResourceFile(ResourceIdentifier.Steamworks64))
{
steamOriginalSdk64.Write(sdk64);
neededRepair = true;
}
- if (creamConfig is not null)
+ if (smokeConfig is not null)
{
await InstallForm.InstallSmokeAPI(directory, selection);
- creamConfig.Write(config);
+ smokeConfig.Write(config);
}
directory.GetScreamApiComponents(out sdk32, out string _, out sdk64, out string _, out config);
- if (epicOriginalSdk32 is not null && Properties.Resources.EpicOnlineServices32.EqualsFile(sdk32))
+ if (epicOriginalSdk32 is not null && sdk32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32))
{
epicOriginalSdk32.Write(sdk32);
neededRepair = true;
}
- if (epicOriginalSdk64 is not null && Properties.Resources.EpicOnlineServices64.EqualsFile(sdk64))
+ if (epicOriginalSdk64 is not null && sdk64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64))
{
epicOriginalSdk64.Write(sdk64);
neededRepair = true;
diff --git a/CreamInstaller/Program.cs b/CreamInstaller/Program.cs
index 26a9406..0d13e6a 100644
--- a/CreamInstaller/Program.cs
+++ b/CreamInstaller/Program.cs
@@ -41,14 +41,6 @@ internal static class Program
return false;
}
- internal static bool IsFilePathLocked(this string filePath)
- {
- try { File.Open(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None).Close(); }
- catch (FileNotFoundException) { return false; }
- catch (IOException) { return true; }
- return false;
- }
-
internal static bool IsProgramRunningDialog(Form form, ProgramSelection selection)
{
if (selection.AreDllsLocked)
@@ -64,24 +56,6 @@ internal static class Program
return false;
}
- internal static void GetSmokeApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config)
- {
- sdk32 = directory + @"\steam_api.dll";
- sdk32_o = directory + @"\steam_api_o.dll";
- sdk64 = directory + @"\steam_api64.dll";
- sdk64_o = directory + @"\steam_api64_o.dll";
- config = directory + @"\SmokeAPI.json";
- }
-
- internal static void GetScreamApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config)
- {
- sdk32 = directory + @"\EOSSDK-Win32-Shipping.dll";
- sdk32_o = directory + @"\EOSSDK-Win32-Shipping_o.dll";
- sdk64 = directory + @"\EOSSDK-Win64-Shipping.dll";
- sdk64_o = directory + @"\EOSSDK-Win64-Shipping_o.dll";
- config = directory + @"\ScreamAPI.json";
- }
-
[STAThread]
private static void Main()
{
diff --git a/CreamInstaller/ProgramSelection.cs b/CreamInstaller/ProgramSelection.cs
index 6c9cb09..6679878 100644
--- a/CreamInstaller/ProgramSelection.cs
+++ b/CreamInstaller/ProgramSelection.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using CreamInstaller.Components;
+using CreamInstaller.Resources;
namespace CreamInstaller;
diff --git a/CreamInstaller/Resources/FileResourceExtensions.cs b/CreamInstaller/Resources/FileResourceExtensions.cs
deleted file mode 100644
index bbfaffe..0000000
--- a/CreamInstaller/Resources/FileResourceExtensions.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System.IO;
-
-namespace CreamInstaller.Resources;
-
-internal static class FileResourceExtensions
-{
- internal static void Write(this byte[] resource, string filePath)
- {
- using FileStream file = new(filePath, FileMode.Create, FileAccess.Write);
- file.Write(resource);
- }
-
- internal static bool EqualsFile(this byte[] resource, string filePath)
- {
- byte[] file = File.ReadAllBytes(filePath);
- if (resource.Length != file.Length)
- return false;
- for (int i = 0; i < resource.Length; i++)
- if (resource[i] != file[i])
- return false;
- return true;
- }
-}
diff --git a/CreamInstaller/Resources/Resources.cs b/CreamInstaller/Resources/Resources.cs
new file mode 100644
index 0000000..b5c0fac
--- /dev/null
+++ b/CreamInstaller/Resources/Resources.cs
@@ -0,0 +1,131 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Security.Cryptography;
+
+namespace CreamInstaller.Resources;
+
+internal static class Resources
+{
+ internal static void Write(this byte[] resource, string filePath)
+ {
+ using FileStream file = new(filePath, FileMode.Create, FileAccess.Write);
+ file.Write(resource);
+ }
+
+ internal static bool IsFilePathLocked(this string filePath)
+ {
+ try
+ {
+ File.Open(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None).Close();
+ }
+ catch (FileNotFoundException)
+ {
+ return false;
+ }
+ catch (IOException)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ internal static void GetCreamApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config)
+ {
+ sdk32 = directory + @"\steam_api.dll";
+ sdk32_o = directory + @"\steam_api_o.dll";
+ sdk64 = directory + @"\steam_api64.dll";
+ sdk64_o = directory + @"\steam_api64_o.dll";
+ config = directory + @"\cream_api.ini";
+ }
+
+ internal static void GetSmokeApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config)
+ {
+ sdk32 = directory + @"\steam_api.dll";
+ sdk32_o = directory + @"\steam_api_o.dll";
+ sdk64 = directory + @"\steam_api64.dll";
+ sdk64_o = directory + @"\steam_api64_o.dll";
+ config = directory + @"\SmokeAPI.json";
+ }
+
+ internal static void GetScreamApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config)
+ {
+ sdk32 = directory + @"\EOSSDK-Win32-Shipping.dll";
+ sdk32_o = directory + @"\EOSSDK-Win32-Shipping_o.dll";
+ sdk64 = directory + @"\EOSSDK-Win64-Shipping.dll";
+ sdk64_o = directory + @"\EOSSDK-Win64-Shipping_o.dll";
+ config = directory + @"\ScreamAPI.json";
+ }
+
+ public enum ResourceIdentifier
+ {
+ Steamworks32 = 0,
+ Steamworks64 = 1,
+ EpicOnlineServices32 = 2,
+ EpicOnlineServices64 = 3
+ }
+
+ internal static readonly Dictionary> ResourceMD5s = new()
+ {
+ {
+ ResourceIdentifier.EpicOnlineServices32,
+ new List()
+ {
+ "069A57B1834A960193D2AD6B96926D70", // ScreamAPI v3.0.0
+ "E2FB3A4A9583FDC215832E5F935E4440" // ScreamAPI v3.0.1
+ }
+ },
+ {
+ ResourceIdentifier.EpicOnlineServices64,
+ new List()
+ {
+ "0D62E57139F1A64F807A9934946A9474", // ScreamAPI v3.0.0
+ "3875C7B735EE80C23239CC4749FDCBE6" // ScreamAPI v3.0.1
+ }
+ },
+ {
+ ResourceIdentifier.Steamworks32,
+ new List()
+ {
+ "02594110FE56B2945955D46670B9A094", // CreamAPI v4.5.0.0 Hotfix
+ "B2434578957CBE38BDCE0A671C1262FC", // SmokeAPI v1.0.0
+ "973AB1632B747D4BF3B2666F32E34327", // SmokeAPI v1.0.1
+ "C7E41F569FC6A347D67D2BFB2BD10F25", // SmokeAPI v1.0.2
+ "F9E7D5B248B86D1C2F2F2905A9F37755" // SmokeAPI v1.0.3
+ }
+ },
+ {
+ ResourceIdentifier.Steamworks64,
+ new List()
+ {
+ "30091B91923D9583A54A93ED1145554B", // CreamAPI v4.5.0.0 Hotfix
+ "08713035CAD6F52548FF324D0487B88D", // SmokeAPI v1.0.0
+ "D077737B9979D32458AC938A2978FA3C", // SmokeAPI v1.0.1
+ "49122A2E2E51CBB0AE5E1D59B280E4CD", // SmokeAPI v1.0.2
+ "13F3E9476116F7670E21365A400357AC" // SmokeAPI v1.0.3
+ }
+ }
+ };
+
+ internal static string ComputeMD5(this string filePath)
+ {
+#pragma warning disable CA5351 // Do Not Use Broken Cryptographic Algorithms
+ using MD5 md5 = MD5.Create();
+#pragma warning restore CA5351 // Do Not Use Broken Cryptographic Algorithms
+ using FileStream stream = File.OpenRead(filePath);
+ byte[] hash = md5.ComputeHash(stream);
+ return BitConverter.ToString(hash).Replace("-", "").ToUpperInvariant();
+ }
+
+ internal static bool IsResourceFile(this string filePath, ResourceIdentifier identifier) => ResourceMD5s[identifier].Contains(filePath.ComputeMD5());
+
+ internal static bool IsResourceFile(this string filePath)
+ {
+ string hash = filePath.ComputeMD5();
+ foreach (IReadOnlyList md5s in ResourceMD5s.Values)
+ if (md5s.Contains(hash))
+ return true;
+ return false;
+ }
+}
diff --git a/CreamInstaller/Steam/SteamLibrary.cs b/CreamInstaller/Steam/SteamLibrary.cs
index 55cfb19..731fae7 100644
--- a/CreamInstaller/Steam/SteamLibrary.cs
+++ b/CreamInstaller/Steam/SteamLibrary.cs
@@ -5,6 +5,8 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using CreamInstaller.Resources;
+
using Gameloop.Vdf.Linq;
using Microsoft.Win32;