mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-17 13:27:43 +01:00
WIP dalamud.launcher rewrite
This commit is contained in:
parent
6cdbfd452a
commit
3f78ca5b81
409 changed files with 367 additions and 273916 deletions
|
|
@ -1,15 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup Label="Target">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Build">
|
||||
<OutputType>Exe</OutputType>
|
||||
<OutputPath>$(SolutionDir)/bin</OutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>Portable</DebugType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.7.82" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Dalamud\Dalamud.csproj" />
|
||||
<ProjectReference Include="..\lib\CoreHook\src\CoreHook.BinaryInjection\CoreHook.BinaryInjection.csproj" />
|
||||
|
|
|
|||
26
Dalamud.Injector/DalamudLauncher.cs
Normal file
26
Dalamud.Injector/DalamudLauncher.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Dalamud.Injector
|
||||
{
|
||||
public sealed class DalamudLauncher
|
||||
{
|
||||
private readonly DalamudLauncherOptions m_options;
|
||||
|
||||
public DalamudLauncher(DalamudLauncherOptions options)
|
||||
{
|
||||
m_options = options;
|
||||
}
|
||||
|
||||
public void Launch(string exePath)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public void Inject(uint pid)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Dalamud.Injector/DalamudLauncherOptions.cs
Normal file
24
Dalamud.Injector/DalamudLauncherOptions.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Dalamud.Injector
|
||||
{
|
||||
public sealed class DalamudLauncherOptions
|
||||
{
|
||||
public static DalamudLauncherOptions Default => new DalamudLauncherOptions
|
||||
{
|
||||
RootDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Dalamud"),
|
||||
BinaryDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Dalamud", "bin"),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string RootDirectory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string BinaryDirectory { get; set; }
|
||||
}
|
||||
}
|
||||
10
Dalamud.Injector/FFI/Win32.cs
Normal file
10
Dalamud.Injector/FFI/Win32.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Dalamud.Injector.FFI
|
||||
{
|
||||
internal static class Win32
|
||||
{
|
||||
}
|
||||
}
|
||||
10
Dalamud.Injector/OS/Process.cs
Normal file
10
Dalamud.Injector/OS/Process.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Dalamud.Injector.OS
|
||||
{
|
||||
internal sealed class Process
|
||||
{
|
||||
}
|
||||
}
|
||||
18
Dalamud.Injector/Options.cs
Normal file
18
Dalamud.Injector/Options.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using CommandLine;
|
||||
|
||||
namespace Dalamud.Injector
|
||||
{
|
||||
[Verb("inject")]
|
||||
internal sealed class InjectOptions
|
||||
{
|
||||
[Option('p', "pid", Required = true, HelpText = "A target process id to inject.")]
|
||||
public uint Pid { get; set; }
|
||||
|
||||
[Option("root", Required = true, HelpText = "")]
|
||||
public string RootDirectory { get; set; }
|
||||
|
||||
[Option("bin", Required = true, HelpText = "")]
|
||||
public string BinaryDirectory { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +1,17 @@
|
|||
using System;
|
||||
using CommandLine;
|
||||
|
||||
namespace Dalamud.Injector {
|
||||
internal static class Program {
|
||||
private static void Main(string[] args) {
|
||||
var pid = int.Parse(args[0]);
|
||||
namespace Dalamud.Injector
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
Parser.Default.ParseArguments<InjectOptions>(args)
|
||||
.WithParsed<InjectOptions>(opt =>
|
||||
{
|
||||
|
||||
Process process = null;
|
||||
|
||||
switch (pid) {
|
||||
case -1:
|
||||
process = Process.GetProcessesByName("ffxiv_dx11")[0];
|
||||
break;
|
||||
case -2:
|
||||
process = Process.Start(
|
||||
"C:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\ffxiv_dx11.exe",
|
||||
"DEV.TestSID=0 DEV.UseSqPack=1 DEV.DataPathType=1 DEV.LobbyHost01=127.0.0.1 DEV.LobbyPort01=54994 DEV.LobbyHost02=127.0.0.1 DEV.LobbyPort02=54994 DEV.LobbyHost03=127.0.0.1 DEV.LobbyPort03=54994 DEV.LobbyHost04=127.0.0.1 DEV.LobbyPort04=54994 DEV.LobbyHost05=127.0.0.1 DEV.LobbyPort05=54994 DEV.LobbyHost06=127.0.0.1 DEV.LobbyPort06=54994 DEV.LobbyHost07=127.0.0.1 DEV.LobbyPort07=54994 DEV.LobbyHost08=127.0.0.1 DEV.LobbyPort08=54994 SYS.Region=0 language=1 version=1.0.0.0 DEV.MaxEntitledExpansionID=2 DEV.GMServerHost=127.0.0.1 DEV.GameQuitMessageBox=0");
|
||||
Thread.Sleep(1000);
|
||||
break;
|
||||
default:
|
||||
process = Process.GetProcessById(pid);
|
||||
break;
|
||||
}
|
||||
|
||||
DalamudStartInfo startInfo;
|
||||
if (args.Length == 1) {
|
||||
startInfo = GetDefaultStartInfo();
|
||||
Console.WriteLine("\nA Dalamud start info was not found in the program arguments. One has been generated for you.");
|
||||
Console.WriteLine("\nCopy the following contents into the program arguments:");
|
||||
} else {
|
||||
startInfo = JsonConvert.DeserializeObject<DalamudStartInfo>(Encoding.UTF8.GetString(Convert.FromBase64String(args[1])));
|
||||
}
|
||||
|
||||
startInfo.WorkingDirectory = Directory.GetCurrentDirectory();
|
||||
|
||||
// Seems to help with the STATUS_INTERNAL_ERROR condition
|
||||
Thread.Sleep(1000);
|
||||
|
||||
// Inject to process
|
||||
Inject(process, startInfo);
|
||||
}
|
||||
|
||||
private static void Inject(Process process, DalamudStartInfo info) {
|
||||
Console.WriteLine($"Injecting to {process.Id}");
|
||||
|
||||
// File check
|
||||
var libPath = Path.GetFullPath("Dalamud.dll");
|
||||
if (!File.Exists(libPath)) {
|
||||
Console.WriteLine($"Can't find a dll on {libPath}");
|
||||
return;
|
||||
}
|
||||
|
||||
Remote
|
||||
RemoteHooking.Inject(process.Id, InjectionOptions.DoNotRequireStrongName, libPath, libPath, info);
|
||||
|
||||
Console.WriteLine("Injected");
|
||||
}
|
||||
|
||||
private static DalamudStartInfo GetDefaultStartInfo() {
|
||||
var startInfo = new DalamudStartInfo {
|
||||
WorkingDirectory = null,
|
||||
ConfigurationPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
|
||||
@"\XIVLauncher\dalamudConfig.json",
|
||||
PluginDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
|
||||
@"\XIVLauncher\plugins",
|
||||
DefaultPluginDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
|
||||
@"\XIVLauncher\defaultplugins",
|
||||
Language = ClientLanguage.English
|
||||
};
|
||||
|
||||
Console.WriteLine("Creating a StartInfo with:\n" +
|
||||
$"ConfigurationPath: {startInfo.ConfigurationPath}\n" +
|
||||
$"PluginDirectory: {startInfo.PluginDirectory}\n" +
|
||||
$"DefaultPluginDirectory: {startInfo.DefaultPluginDirectory}\n" +
|
||||
$"Language: {startInfo.Language}");
|
||||
|
||||
return startInfo;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue