v3.5.3.0
- Minor visual fixes and refactoring - While installing SmokeAPI to games, old CreamAPI configurations will now be deleted if they exist - Paradox Launcher repair methods will now be able to fix old CreamAPI/SmokeAPI versions - Fixed Paradox Launcher SmokeAPI repair exception
This commit is contained in:
parent
591eeb7024
commit
b874edaa3e
10 changed files with 175 additions and 73 deletions
|
@ -5,7 +5,7 @@
|
|||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<Version>3.5.2.1</Version>
|
||||
<Version>3.5.3.0</Version>
|
||||
<PackageIcon>Resources\ini.ico</PackageIcon>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>
|
||||
|
|
|
@ -5,6 +5,8 @@ using System.Text.Json;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using CreamInstaller.Resources;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace CreamInstaller.Epic;
|
||||
|
|
|
@ -81,18 +81,23 @@ internal partial class InstallForm : CustomForm
|
|||
}
|
||||
else
|
||||
writer.WriteLine(" \"override\": [],");
|
||||
writer.WriteLine(" \"dlc_ids\": [");
|
||||
KeyValuePair<string, (DlcType type, string name, string icon)> lastAllDlc = allDlc.Last();
|
||||
foreach (KeyValuePair<string, (DlcType type, string name, string icon)> 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<string, (DlcType type, string name, string icon)> lastAllDlc = allDlc.Last();
|
||||
foreach (KeyValuePair<string, (DlcType type, string name, string icon)> 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))
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<int> 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;
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
|
||||
using CreamInstaller.Components;
|
||||
using CreamInstaller.Resources;
|
||||
|
||||
namespace CreamInstaller;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
131
CreamInstaller/Resources/Resources.cs
Normal file
131
CreamInstaller/Resources/Resources.cs
Normal file
|
@ -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<ResourceIdentifier, IReadOnlyList<string>> ResourceMD5s = new()
|
||||
{
|
||||
{
|
||||
ResourceIdentifier.EpicOnlineServices32,
|
||||
new List<string>()
|
||||
{
|
||||
"069A57B1834A960193D2AD6B96926D70", // ScreamAPI v3.0.0
|
||||
"E2FB3A4A9583FDC215832E5F935E4440" // ScreamAPI v3.0.1
|
||||
}
|
||||
},
|
||||
{
|
||||
ResourceIdentifier.EpicOnlineServices64,
|
||||
new List<string>()
|
||||
{
|
||||
"0D62E57139F1A64F807A9934946A9474", // ScreamAPI v3.0.0
|
||||
"3875C7B735EE80C23239CC4749FDCBE6" // ScreamAPI v3.0.1
|
||||
}
|
||||
},
|
||||
{
|
||||
ResourceIdentifier.Steamworks32,
|
||||
new List<string>()
|
||||
{
|
||||
"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<string>()
|
||||
{
|
||||
"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<string> md5s in ResourceMD5s.Values)
|
||||
if (md5s.Contains(hash))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -5,6 +5,8 @@ using System.Text;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using CreamInstaller.Resources;
|
||||
|
||||
using Gameloop.Vdf.Linq;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
|
Loading…
Reference in a new issue