- Koaloader autoload DLLs are now placed in the root game/program directory
- Installation/uninstallation output clarifications
- Minor refactoring
This commit is contained in:
pointfeev 2022-10-08 05:01:38 -04:00
parent ac32af2c74
commit 10bd823d2b
8 changed files with 114 additions and 32 deletions

View file

@ -4,7 +4,7 @@
<TargetFramework>net6.0-windows10.0.22621.0</TargetFramework> <TargetFramework>net6.0-windows10.0.22621.0</TargetFramework>
<UseWindowsForms>True</UseWindowsForms> <UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Resources\ini.ico</ApplicationIcon> <ApplicationIcon>Resources\ini.ico</ApplicationIcon>
<Version>4.2.2.0</Version> <Version>4.2.3.0</Version>
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright> <Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>
<Company>CreamInstaller</Company> <Company>CreamInstaller</Company>
<Product>Automatic DLC Unlocker Installer &amp; Configuration Generator</Product> <Product>Automatic DLC Unlocker Installer &amp; Configuration Generator</Product>

View file

@ -64,7 +64,8 @@ internal partial class InstallForm : CustomForm
UpdateUser($"Repairing Paradox Launcher . . . ", LogTextBox.Operation); UpdateUser($"Repairing Paradox Launcher . . . ", LogTextBox.Operation);
_ = await Repair(this, selection); _ = await Repair(this, selection);
} }
UpdateUser($"Checking directories for {selection.Name} . . . ", LogTextBox.Operation); UpdateUser($"{(Uninstalling ? "Uninstalling" : "Installing")}" +
$" {(Uninstalling ? "from" : "for")} " + selection.Name + $" with root directory \"{selection.RootDirectory}\" . . . ", LogTextBox.Operation);
IEnumerable<string> invalidDirectories = (await selection.RootDirectory.GetExecutables()) IEnumerable<string> invalidDirectories = (await selection.RootDirectory.GetExecutables())
?.Where(d => !selection.ExecutableDirectories.Any(s => s.directory == Path.GetDirectoryName(d.path))) ?.Where(d => !selection.ExecutableDirectories.Any(s => s.directory == Path.GetDirectoryName(d.path)))
?.Select(d => Path.GetDirectoryName(d.path)); ?.Select(d => Path.GetDirectoryName(d.path));
@ -77,11 +78,11 @@ internal partial class InstallForm : CustomForm
if (Program.Canceled) throw new CustomMessageException("The operation was canceled."); if (Program.Canceled) throw new CustomMessageException("The operation was canceled.");
directory.GetKoaloaderComponents(out List<string> proxies, out string config); directory.GetKoaloaderComponents(out List<string> proxies, out string config);
if (proxies.Any(proxy => File.Exists(proxy) && proxy.IsResourceFile(ResourceIdentifier.Koaloader)) if (proxies.Any(proxy => File.Exists(proxy) && proxy.IsResourceFile(ResourceIdentifier.Koaloader))
|| Koaloader.AutoLoadDlls.Any(pair => File.Exists(directory + @"\" + pair.dll)) || directory != selection.RootDirectory && Koaloader.AutoLoadDlls.Any(pair => File.Exists(directory + @"\" + pair.dll))
|| File.Exists(config)) || File.Exists(config))
{ {
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in incorrect directory \"{directory}\" . . . ", LogTextBox.Operation); UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in incorrect directory \"{directory}\" . . . ", LogTextBox.Operation);
await Koaloader.Uninstall(directory, this); await Koaloader.Uninstall(directory, rootDirectory: selection.RootDirectory, this);
} }
Thread.Sleep(1); Thread.Sleep(1);
} }
@ -96,7 +97,7 @@ internal partial class InstallForm : CustomForm
|| File.Exists(config)) || File.Exists(config))
{ {
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
await Koaloader.Uninstall(directory, this); await Koaloader.Uninstall(directory, rootDirectory: selection.RootDirectory, this);
} }
Thread.Sleep(1); Thread.Sleep(1);
} }
@ -164,7 +165,7 @@ internal partial class InstallForm : CustomForm
{ {
if (Program.Canceled) throw new CustomMessageException("The operation was canceled."); if (Program.Canceled) throw new CustomMessageException("The operation was canceled.");
UpdateUser("Installing Koaloader to " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); UpdateUser("Installing Koaloader to " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
await Koaloader.Install(directory, binaryType, selection, this); await Koaloader.Install(directory, binaryType, selection, rootDirectory: selection.RootDirectory, this);
Thread.Sleep(1); Thread.Sleep(1);
} }
} }

View file

@ -22,7 +22,6 @@ using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using static CreamInstaller.Resources.Resources; using static CreamInstaller.Resources.Resources;
using static System.ComponentModel.Design.ObjectSelectorEditor;
namespace CreamInstaller; namespace CreamInstaller;

View file

@ -67,8 +67,8 @@ internal static class Koaloader
SortedList<string, string> modules = new(PlatformIdComparer.String); SortedList<string, string> modules = new(PlatformIdComparer.String);
if (targets.Any() || modules.Any()) if (targets.Any() || modules.Any())
{ {
if (installForm is not null) /*if (installForm is not null)
installForm.UpdateUser("Generating Koaloader configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); installForm.UpdateUser("Generating Koaloader configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
File.Create(config).Close(); File.Create(config).Close();
StreamWriter writer = new(config, true, Encoding.UTF8); StreamWriter writer = new(config, true, Encoding.UTF8);
WriteConfig(writer, targets, modules, installForm); WriteConfig(writer, targets, modules, installForm);
@ -125,10 +125,10 @@ internal static class Koaloader
writer.WriteLine("}"); writer.WriteLine("}");
} }
internal static async Task Uninstall(string directory, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(async () => internal static async Task Uninstall(string directory, string rootDirectory = null, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(async () =>
{ {
directory.GetKoaloaderComponents(out List<string> proxies, out string config); directory.GetKoaloaderComponents(out List<string> proxies, out string config);
foreach (string proxyPath in proxies.Where(proxyPath => File.Exists(proxyPath) && proxyPath.IsResourceFile(Resources.ResourceIdentifier.Koaloader))) foreach (string proxyPath in proxies.Where(proxyPath => File.Exists(proxyPath) && proxyPath.IsResourceFile(ResourceIdentifier.Koaloader)))
{ {
File.Delete(proxyPath); File.Delete(proxyPath);
if (installForm is not null) if (installForm is not null)
@ -152,9 +152,11 @@ internal static class Koaloader
await ScreamAPI.Uninstall(directory, installForm, deleteConfig); await ScreamAPI.Uninstall(directory, installForm, deleteConfig);
await UplayR1.Uninstall(directory, installForm, deleteConfig); await UplayR1.Uninstall(directory, installForm, deleteConfig);
await UplayR2.Uninstall(directory, installForm, deleteConfig); await UplayR2.Uninstall(directory, installForm, deleteConfig);
if (rootDirectory is not null && directory != rootDirectory)
await Uninstall(rootDirectory, null, installForm, deleteConfig);
}); });
internal static async Task Install(string directory, BinaryType binaryType, ProgramSelection selection, InstallForm installForm = null, bool generateConfig = true) => await Task.Run(() => internal static async Task Install(string directory, BinaryType binaryType, ProgramSelection selection, string rootDirectory = null, InstallForm installForm = null, bool generateConfig = true) => await Task.Run(() =>
{ {
directory.GetKoaloaderComponents(out List<string> proxies, out string config); directory.GetKoaloaderComponents(out List<string> proxies, out string config);
string proxy = selection.KoaloaderProxy ?? ProgramSelection.DefaultKoaloaderProxy; string proxy = selection.KoaloaderProxy ?? ProgramSelection.DefaultKoaloaderProxy;
@ -186,69 +188,149 @@ internal static class Koaloader
if (bit32) if (bit32)
{ {
path = directory + @"\SmokeAPI32.dll"; path = directory + @"\SmokeAPI32.dll";
if (rootDirectory is not null && directory != rootDirectory)
{
if (File.Exists(path))
{
File.Delete(path);
if (installForm is not null)
installForm.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
}
path = rootDirectory + @"\SmokeAPI32.dll";
}
"SmokeAPI.steam_api.dll".Write(path); "SmokeAPI.steam_api.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false); installForm.UpdateUser($"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
path = directory + @"\SmokeAPI64.dll"; path = directory + @"\SmokeAPI64.dll";
if (rootDirectory is not null && directory != rootDirectory)
{
if (File.Exists(path))
{
File.Delete(path);
if (installForm is not null)
installForm.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
}
path = rootDirectory + @"\SmokeAPI64.dll";
}
"SmokeAPI.steam_api64.dll".Write(path); "SmokeAPI.steam_api64.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false); installForm.UpdateUser($"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
SmokeAPI.CheckConfig(directory, selection, installForm); SmokeAPI.CheckConfig(rootDirectory ?? directory, selection, installForm);
} }
if (selection.Platform is Platform.Epic or Platform.Paradox) if (selection.Platform is Platform.Epic or Platform.Paradox)
{ {
if (bit32) if (bit32)
{ {
path = directory + @"\ScreamAPI32.dll"; path = directory + @"\ScreamAPI32.dll";
if (rootDirectory is not null && directory != rootDirectory)
{
if (File.Exists(path))
{
File.Delete(path);
if (installForm is not null)
installForm.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
}
path = rootDirectory + @"\ScreamAPI32.dll";
}
"ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(path); "ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false); installForm.UpdateUser($"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
path = directory + @"\ScreamAPI64.dll"; path = directory + @"\ScreamAPI64.dll";
if (rootDirectory is not null && directory != rootDirectory)
{
if (File.Exists(path))
{
File.Delete(path);
if (installForm is not null)
installForm.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
}
path = rootDirectory + @"\ScreamAPI64.dll";
}
"ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(path); "ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false); installForm.UpdateUser($"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
ScreamAPI.CheckConfig(directory, selection, installForm); ScreamAPI.CheckConfig(rootDirectory ?? directory, selection, installForm);
} }
if (selection.Platform is Platform.Ubisoft) if (selection.Platform is Platform.Ubisoft)
{ {
if (bit32) if (bit32)
{ {
path = directory + @"\UplayR1Unlocker32.dll"; path = directory + @"\UplayR1Unlocker32.dll";
if (rootDirectory is not null && directory != rootDirectory)
{
if (File.Exists(path))
{
File.Delete(path);
if (installForm is not null)
installForm.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
}
path = rootDirectory + @"\UplayR1Unlocker32.dll";
}
"UplayR1.uplay_r1_loader.dll".Write(path); "UplayR1.uplay_r1_loader.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false); installForm.UpdateUser($"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
path = directory + @"\UplayR1Unlocker64.dll"; path = directory + @"\UplayR1Unlocker64.dll";
if (rootDirectory is not null && directory != rootDirectory)
{
if (File.Exists(path))
{
File.Delete(path);
if (installForm is not null)
installForm.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
}
path = rootDirectory + @"\UplayR1Unlocker64.dll";
}
"UplayR1.uplay_r1_loader64.dll".Write(path); "UplayR1.uplay_r1_loader64.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false); installForm.UpdateUser($"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
UplayR1.CheckConfig(directory, selection, installForm); UplayR1.CheckConfig(rootDirectory ?? directory, selection, installForm);
if (bit32) if (bit32)
{ {
path = directory + @"\UplayR2Unlocker32.dll"; path = directory + @"\UplayR2Unlocker32.dll";
if (rootDirectory is not null && directory != rootDirectory)
{
if (File.Exists(path))
{
File.Delete(path);
if (installForm is not null)
installForm.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
}
path = rootDirectory + @"\UplayR2Unlocker32.dll";
}
"UplayR2.upc_r2_loader.dll".Write(path); "UplayR2.upc_r2_loader.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false); installForm.UpdateUser($"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
path = directory + @"\UplayR2Unlocker64.dll"; path = directory + @"\UplayR2Unlocker64.dll";
if (rootDirectory is not null && directory != rootDirectory)
{
if (File.Exists(path))
{
File.Delete(path);
if (installForm is not null)
installForm.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
}
path = rootDirectory + @"\UplayR2Unlocker64.dll";
}
"UplayR2.upc_r2_loader64.dll".Write(path); "UplayR2.upc_r2_loader64.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false); installForm.UpdateUser($"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
UplayR2.CheckConfig(directory, selection, installForm); UplayR2.CheckConfig(rootDirectory ?? directory, selection, installForm);
} }
if (generateConfig) if (generateConfig)
CheckConfig(directory, selection, installForm); CheckConfig(directory, selection, installForm);

View file

@ -36,8 +36,8 @@ internal static class ScreamAPI
entitlements = entitlements.Concat(_dlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement)); entitlements = entitlements.Concat(_dlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement));
if (overrideCatalogItems.Any() || entitlements.Any()) if (overrideCatalogItems.Any() || entitlements.Any())
{ {
if (installForm is not null) /*if (installForm is not null)
installForm.UpdateUser("Generating ScreamAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); installForm.UpdateUser("Generating ScreamAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
File.Create(config).Close(); File.Create(config).Close();
StreamWriter writer = new(config, true, Encoding.UTF8); StreamWriter writer = new(config, true, Encoding.UTF8);
WriteConfig(writer, WriteConfig(writer,

View file

@ -42,8 +42,8 @@ internal static class SmokeAPI
} }
if (overrideDlc.Any() || injectDlc.Any()) if (overrideDlc.Any() || injectDlc.Any())
{ {
if (installForm is not null) /*if (installForm is not null)
installForm.UpdateUser("Generating SmokeAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); installForm.UpdateUser("Generating SmokeAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
File.Create(config).Close(); File.Create(config).Close();
StreamWriter writer = new(config, true, Encoding.UTF8); StreamWriter writer = new(config, true, Encoding.UTF8);
WriteConfig(writer, WriteConfig(writer,

View file

@ -33,8 +33,8 @@ internal static class UplayR1
blacklistDlc = blacklistDlc.Except(extraDlc); blacklistDlc = blacklistDlc.Except(extraDlc);
if (blacklistDlc.Any()) if (blacklistDlc.Any())
{ {
if (installForm is not null) /*if (installForm is not null)
installForm.UpdateUser("Generating Uplay R1 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); installForm.UpdateUser("Generating Uplay R1 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
File.Create(config).Close(); File.Create(config).Close();
StreamWriter writer = new(config, true, Encoding.UTF8); StreamWriter writer = new(config, true, Encoding.UTF8);
WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm); WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm);

View file

@ -35,8 +35,8 @@ internal static class UplayR2
blacklistDlc = blacklistDlc.Except(extraDlc); blacklistDlc = blacklistDlc.Except(extraDlc);
if (blacklistDlc.Any()) if (blacklistDlc.Any())
{ {
if (installForm is not null) /*if (installForm is not null)
installForm.UpdateUser("Generating Uplay R2 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); installForm.UpdateUser("Generating Uplay R2 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
File.Create(config).Close(); File.Create(config).Close();
StreamWriter writer = new(config, true, Encoding.UTF8); StreamWriter writer = new(config, true, Encoding.UTF8);
WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm); WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm);