2020-07-04 18:45:02 +12:00
|
|
|
|
using System;
|
2018-11-29 23:51:49 +01:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
2020-07-04 18:45:02 +12:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using NexusForever.ClientConnector.Configuration;
|
|
|
|
|
|
using NexusForever.ClientConnector.Native;
|
2018-11-29 23:51:49 +01:00
|
|
|
|
|
|
|
|
|
|
namespace NexusForever.ClientConnector
|
|
|
|
|
|
{
|
|
|
|
|
|
internal static class Program
|
|
|
|
|
|
{
|
|
|
|
|
|
private const string jsonFile = "config.json";
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("kernel32.dll")]
|
|
|
|
|
|
static extern bool CreateProcess(
|
|
|
|
|
|
string lpApplicationName,
|
|
|
|
|
|
string lpCommandLine,
|
|
|
|
|
|
IntPtr lpProcessAttributes,
|
|
|
|
|
|
IntPtr lpThreadAttributes,
|
|
|
|
|
|
bool bInheritHandles,
|
|
|
|
|
|
uint dwCreationFlags,
|
|
|
|
|
|
IntPtr lpEnvironment,
|
|
|
|
|
|
string lpCurrentDirectory,
|
|
|
|
|
|
ref STARTUPINFO lpStartupInfo,
|
|
|
|
|
|
out PROCESS_INFORMATION lpProcessInformation
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
public static void Main()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!File.Exists(jsonFile))
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.Write("Type in your host name: ");
|
|
|
|
|
|
string hostName = Console.ReadLine();
|
|
|
|
|
|
|
2018-12-12 17:23:40 +01:00
|
|
|
|
Console.Write("Type in your language: [en,de]");
|
|
|
|
|
|
string language = Console.ReadLine();
|
|
|
|
|
|
|
2021-01-30 10:41:52 +01:00
|
|
|
|
var clientConfig = new ClientConfiguration
|
2018-11-29 23:51:49 +01:00
|
|
|
|
{
|
2018-12-12 17:23:40 +01:00
|
|
|
|
HostName = hostName,
|
|
|
|
|
|
Language = language
|
2018-11-29 23:51:49 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
File.WriteAllText(jsonFile, JsonConvert.SerializeObject(clientConfig));
|
|
|
|
|
|
}
|
2018-12-12 17:23:40 +01:00
|
|
|
|
|
|
|
|
|
|
ConfigurationManager<ClientConfiguration>.Initialise(jsonFile);
|
|
|
|
|
|
LaunchClient(ConfigurationManager<ClientConfiguration>.Config);
|
2018-11-29 23:51:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-12 17:23:40 +01:00
|
|
|
|
private static void LaunchClient(ClientConfiguration config)
|
2018-11-29 23:51:49 +01:00
|
|
|
|
{
|
2021-01-30 10:41:52 +01:00
|
|
|
|
var si = new STARTUPINFO();
|
|
|
|
|
|
var pi = new PROCESS_INFORMATION();
|
2018-11-29 23:51:49 +01:00
|
|
|
|
|
2020-07-04 18:45:02 +12:00
|
|
|
|
string client = "WildStar64.exe";
|
|
|
|
|
|
if (!File.Exists(client))
|
|
|
|
|
|
client = "WildStar32.exe";
|
|
|
|
|
|
|
|
|
|
|
|
CreateProcess(client,
|
2018-12-12 17:23:40 +01:00
|
|
|
|
$"/auth {config.HostName} /authNc {config.HostName} /lang {config.Language} /patcher {config.HostName} /SettingsKey WildStar /realmDataCenterId 9",
|
2018-11-29 23:51:49 +01:00
|
|
|
|
IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref si, out pi);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|