mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
fix: network sig, some installer bugs
This commit is contained in:
parent
558aa6ec16
commit
15d340d0ed
5 changed files with 105 additions and 28 deletions
39
Dalamud/Game/Internal/AntiDebug.cs
Normal file
39
Dalamud/Game/Internal/AntiDebug.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Hooking;
|
||||
using EasyHook;
|
||||
using Serilog;
|
||||
|
||||
namespace Dalamud.Game.Internal
|
||||
{
|
||||
class AntiDebug : IDisposable
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
|
||||
private delegate bool IsDebuggerPresentDelegate();
|
||||
|
||||
private Hook<IsDebuggerPresentDelegate> debuggerPresentHook;
|
||||
|
||||
public AntiDebug() {
|
||||
this.debuggerPresentHook = new Hook<IsDebuggerPresentDelegate>(LocalHook.GetProcAddress("Kernel32", "IsDebuggerPresent"),
|
||||
new IsDebuggerPresentDelegate(IsDebuggerPresentDetour));
|
||||
|
||||
Log.Verbose("IsDebuggerPresent address {IsDebuggerPresent}", this.debuggerPresentHook.Address);
|
||||
}
|
||||
|
||||
public void Enable() {
|
||||
this.debuggerPresentHook.Enable();
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.debuggerPresentHook.Disable();
|
||||
}
|
||||
|
||||
private bool IsDebuggerPresentDetour() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,8 @@ namespace Dalamud.Game.Internal {
|
|||
|
||||
public LibcFunction Libc { get; private set; }
|
||||
|
||||
private AntiDebug antiDebug;
|
||||
|
||||
#endregion
|
||||
|
||||
public Framework(SigScanner scanner, Dalamud dalamud) {
|
||||
|
|
@ -65,6 +67,8 @@ namespace Dalamud.Game.Internal {
|
|||
Network = new GameNetwork(dalamud, scanner);
|
||||
|
||||
//Resource = new ResourceManager(dalamud, scanner);
|
||||
|
||||
this.antiDebug = new AntiDebug();
|
||||
}
|
||||
|
||||
private void HookVTable() {
|
||||
|
|
@ -81,6 +85,7 @@ namespace Dalamud.Game.Internal {
|
|||
}
|
||||
|
||||
public void Enable() {
|
||||
this.antiDebug.Enable();
|
||||
Gui.Enable();
|
||||
Network.Enable();
|
||||
//Resource.Enable();
|
||||
|
|
@ -89,6 +94,7 @@ namespace Dalamud.Game.Internal {
|
|||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.antiDebug.Dispose();
|
||||
Gui.Dispose();
|
||||
Network.Dispose();
|
||||
//Resource.Dispose();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ namespace Dalamud.Game.Internal.Network {
|
|||
|
||||
protected override void Setup64Bit(SigScanner sig) {
|
||||
//ProcessZonePacket = sig.ScanText("48 89 74 24 18 57 48 83 EC 50 8B F2 49 8B F8 41 0F B7 50 02 8B CE E8 ?? ?? 7A FF 0F B7 57 02 8D 42 89 3D 5F 02 00 00 0F 87 60 01 00 00 4C 8D 05");
|
||||
ProcessZonePacket = sig.ScanText("48 89 74 24 18 57 48 83 EC 50 8B F2 49 8B F8 41 0F B7 50 02 8B CE E8 ?? ?? 73 FF 0F B7 57 02 8D 42 ?? 3D ?? ?? 00 00 0F 87 60 01 00 00 4C 8D 05");
|
||||
//ProcessZonePacket = sig.ScanText("48 89 74 24 18 57 48 83 EC 50 8B F2 49 8B F8 41 0F B7 50 02 8B CE E8 ?? ?? 73 FF 0F B7 57 02 8D 42 ?? 3D ?? ?? 00 00 0F 87 60 01 00 00 4C 8D 05");
|
||||
ProcessZonePacket = sig.ScanText("48 89 74 24 ?? 57 48 83 EC 50 8B FA 49 8B F0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ namespace Dalamud.Plugin
|
|||
private string pluginDirectory;
|
||||
private ReadOnlyCollection<PluginDefinition> pluginMaster;
|
||||
private bool errorModalDrawing = true;
|
||||
private bool errorModalOnNextFrame = false;
|
||||
|
||||
private enum PluginInstallStatus {
|
||||
None,
|
||||
|
|
@ -38,7 +39,11 @@ namespace Dalamud.Plugin
|
|||
public PluginInstallerWindow(PluginManager manager, string pluginDirectory) {
|
||||
this.manager = manager;
|
||||
this.pluginDirectory = pluginDirectory;
|
||||
Task.Run(CachePluginMaster).ContinueWith(t => { this.masterDownloadFailed = t.IsFaulted; });
|
||||
Task.Run(CachePluginMaster).ContinueWith(t => {
|
||||
this.masterDownloadFailed = this.masterDownloadFailed || t.IsFaulted;
|
||||
this.errorModalDrawing = this.masterDownloadFailed;
|
||||
this.errorModalOnNextFrame = this.masterDownloadFailed;
|
||||
});
|
||||
}
|
||||
|
||||
private void CachePluginMaster() {
|
||||
|
|
@ -55,28 +60,34 @@ namespace Dalamud.Plugin
|
|||
|
||||
private void InstallPlugin(PluginDefinition definition) {
|
||||
try {
|
||||
var path = Path.GetTempFileName();
|
||||
var outputDir = new DirectoryInfo(Path.Combine(this.pluginDirectory, definition.InternalName, definition.AssemblyVersion));
|
||||
var dllFile = new FileInfo(Path.Combine(outputDir.FullName, $"{definition.InternalName}.dll"));
|
||||
var disabledFile = new FileInfo(Path.Combine(outputDir.FullName, ".disabled"));
|
||||
|
||||
Log.Information("Downloading plugin to {0}", path);
|
||||
if (dllFile.Exists) {
|
||||
if (disabledFile.Exists)
|
||||
disabledFile.Delete();
|
||||
|
||||
using var client = new WebClient();
|
||||
|
||||
client.DownloadFile(PluginRepoBaseUrl + $"/plugins/{definition.InternalName}/latest.zip", path);
|
||||
var outputDir = Path.Combine(this.pluginDirectory, definition.InternalName);
|
||||
|
||||
if (File.Exists(Path.Combine(outputDir, ".disabled"))) {
|
||||
Log.Information("Plugin was disabled, re-enabling.");
|
||||
File.Delete(Path.Combine(outputDir, ".disabled"));
|
||||
this.manager.LoadPluginFromAssembly(dllFile);
|
||||
this.installStatus = PluginInstallStatus.Success;
|
||||
return;
|
||||
}
|
||||
|
||||
if (outputDir.Exists)
|
||||
outputDir.Delete(true);
|
||||
outputDir.Create();
|
||||
|
||||
var path = Path.GetTempFileName();
|
||||
Log.Information("Downloading plugin to {0}", path);
|
||||
using var client = new WebClient();
|
||||
client.DownloadFile(PluginRepoBaseUrl + $"/plugins/{definition.InternalName}/latest.zip", path);
|
||||
|
||||
Log.Information("Extracting to {0}", outputDir);
|
||||
|
||||
Directory.CreateDirectory(outputDir);
|
||||
|
||||
ZipFile.ExtractToDirectory(path, outputDir);
|
||||
ZipFile.ExtractToDirectory(path, outputDir.FullName);
|
||||
|
||||
this.installStatus = PluginInstallStatus.Success;
|
||||
this.manager.LoadPluginFromAssembly(new FileInfo(Path.Combine(outputDir, $"{definition.InternalName}.dll")));
|
||||
this.manager.LoadPluginFromAssembly(dllFile);
|
||||
} catch (Exception e) {
|
||||
Log.Error(e, "Plugin download failed hard.");
|
||||
this.installStatus = PluginInstallStatus.Fail;
|
||||
|
|
@ -129,7 +140,11 @@ namespace Dalamud.Plugin
|
|||
{
|
||||
this.installStatus = PluginInstallStatus.InProgress;
|
||||
|
||||
Task.Run(() => InstallPlugin(pluginDefinition)).ContinueWith(t => { this.installStatus = t.IsFaulted ? PluginInstallStatus.Fail : this.installStatus; });
|
||||
Task.Run(() => InstallPlugin(pluginDefinition)).ContinueWith(t => {
|
||||
this.installStatus = t.IsFaulted ? PluginInstallStatus.Fail : this.installStatus;
|
||||
this.errorModalDrawing = this.installStatus == PluginInstallStatus.Fail;
|
||||
this.errorModalOnNextFrame = this.installStatus == PluginInstallStatus.Fail;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -184,21 +199,30 @@ namespace Dalamud.Plugin
|
|||
|
||||
if (ImGui.Button("test modal")) {
|
||||
this.installStatus = PluginInstallStatus.Fail;
|
||||
this.errorModalDrawing = true;
|
||||
this.errorModalOnNextFrame = true;
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
if (this.installStatus == PluginInstallStatus.Fail || this.masterDownloadFailed) {
|
||||
if (ImGui.BeginPopupModal("Installer failed", ref this.errorModalDrawing, ImGuiWindowFlags.AlwaysAutoResize))
|
||||
{
|
||||
ImGui.TextWrapped("The installer ran into an issue. Please restart the game and report this error on our discord.");
|
||||
ImGui.Text("The plugin installer ran into an issue.");
|
||||
ImGui.Text("Please restart the game and report this error on our discord.");
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGui.Button("OK", new Vector2(120, 40))) { ImGui.CloseCurrentPopup(); }
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
if (this.errorModalOnNextFrame) {
|
||||
ImGui.OpenPopup("Installer failed");
|
||||
this.errorModalOnNextFrame = false;
|
||||
}
|
||||
|
||||
|
||||
ImGui.End();
|
||||
|
||||
return windowOpen;
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ namespace Dalamud.Plugin
|
|||
var thisPlugin = this.Plugins.Where(x => x.Definition != null)
|
||||
.First(x => x.Definition.InternalName == definition.InternalName);
|
||||
|
||||
var outputDir = Path.Combine(this.pluginDirectory, definition.InternalName);
|
||||
File.Create(Path.Combine(outputDir, ".disabled"));
|
||||
var outputDir = new DirectoryInfo(Path.Combine(this.pluginDirectory, definition.InternalName, definition.AssemblyVersion));
|
||||
File.Create(Path.Combine(outputDir.FullName, ".disabled"));
|
||||
|
||||
thisPlugin.Plugin.Dispose();
|
||||
|
||||
|
|
@ -68,9 +68,12 @@ namespace Dalamud.Plugin
|
|||
|
||||
if (type.GetInterface(interfaceType.FullName) != null)
|
||||
{
|
||||
var plugin = (IDalamudPlugin)Activator.CreateInstance(type);
|
||||
var disabledFile = new FileInfo(Path.Combine(dllFile.Directory.FullName, ".disabled"));
|
||||
|
||||
var dalamudInterface = new DalamudPluginInterface(this.dalamud, type.Assembly.GetName().Name);
|
||||
if (disabledFile.Exists) {
|
||||
Log.Information("Plugin {0} is disabled.", dllFile.FullName);
|
||||
return;
|
||||
}
|
||||
|
||||
var defJsonFile = new FileInfo(Path.Combine(dllFile.Directory.FullName, $"{Path.GetFileNameWithoutExtension(dllFile.Name)}.json"));
|
||||
|
||||
|
|
@ -86,8 +89,12 @@ namespace Dalamud.Plugin
|
|||
else
|
||||
{
|
||||
Log.Information("Plugin DLL {0} has no definition.", dllFile.FullName);
|
||||
return;
|
||||
}
|
||||
|
||||
var plugin = (IDalamudPlugin)Activator.CreateInstance(type);
|
||||
|
||||
var dalamudInterface = new DalamudPluginInterface(this.dalamud, type.Assembly.GetName().Name);
|
||||
plugin.Initialize(dalamudInterface);
|
||||
Log.Information("Loaded plugin: {0}", plugin.Name);
|
||||
this.Plugins.Add((plugin, pluginDef));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue