mirror of
https://github.com/HolographicHat/Yae.git
synced 2026-03-16 00:53:17 +08:00
fix
This commit is contained in:
@@ -62,7 +62,7 @@ public class AchievementAllDataNotify {
|
|||||||
}
|
}
|
||||||
dict[tag >> 3] = eStream.ReadUInt32();
|
dict[tag >> 3] = eStream.ReadUInt32();
|
||||||
}
|
}
|
||||||
if (dict != null) {
|
if (dict is { Count: > 2 }) { // at least 3 fields
|
||||||
data.Add(dict);
|
data.Add(dict);
|
||||||
}
|
}
|
||||||
} catch (InvalidProtocolBufferException) {
|
} catch (InvalidProtocolBufferException) {
|
||||||
|
|||||||
@@ -37,14 +37,14 @@ public unsafe class GameProcess {
|
|||||||
Task.Run(() => {
|
Task.Run(() => {
|
||||||
Native.WaitForSingleObject(Handle, 0xFFFFFFFF); // INFINITE
|
Native.WaitForSingleObject(Handle, 0xFFFFFFFF); // INFINITE
|
||||||
OnExit?.Invoke();
|
OnExit?.Invoke();
|
||||||
});
|
}).ContinueWith(task => { if (task.IsFaulted) Utils.OnUnhandledException(task.Exception!); });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadLibrary(string libPath) {
|
public void LoadLibrary(string libPath) {
|
||||||
var hKrnl32 = NativeLibrary.Load("kernel32");
|
var hKrnl32 = NativeLibrary.Load("kernel32");
|
||||||
var mLoadLibraryW = NativeLibrary.GetExport(hKrnl32, "LoadLibraryW");
|
var mLoadLibraryW = NativeLibrary.GetExport(hKrnl32, "LoadLibraryW");
|
||||||
var libPathLen = (uint) libPath.Length * sizeof(char);
|
var libPathLen = (uint) libPath.Length * sizeof(char);
|
||||||
var lpLibPath = Native.VirtualAllocEx(Handle, default, libPathLen + 2, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
|
var lpLibPath = Native.VirtualAllocEx(Handle, null, libPathLen + 2, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
|
||||||
if (lpLibPath == null) {
|
if (lpLibPath == null) {
|
||||||
throw new ApplicationException($"VirtualAllocEx fail: {Marshal.GetLastPInvokeErrorMessage()}");
|
throw new ApplicationException($"VirtualAllocEx fail: {Marshal.GetLastPInvokeErrorMessage()}");
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ public unsafe class GameProcess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var lpStartAddress = (delegate*unmanaged[Stdcall]<void*, uint>) mLoadLibraryW; // THREAD_START_ROUTINE
|
var lpStartAddress = (delegate*unmanaged[Stdcall]<void*, uint>) mLoadLibraryW; // THREAD_START_ROUTINE
|
||||||
var hThread = Native.CreateRemoteThread(Handle, default, 0, lpStartAddress, lpLibPath, 0);
|
var hThread = Native.CreateRemoteThread(Handle, null, 0, lpStartAddress, lpLibPath, 0);
|
||||||
if (hThread.IsNull) {
|
if (hThread.IsNull) {
|
||||||
var error = Marshal.GetLastPInvokeErrorMessage();
|
var error = Marshal.GetLastPInvokeErrorMessage();
|
||||||
Native.VirtualFreeEx(Handle, lpLibPath, 0, MEM_RELEASE);
|
Native.VirtualFreeEx(Handle, lpLibPath, 0, MEM_RELEASE);
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public static class Utils {
|
|||||||
var appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
var appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||||
foreach (var path in Directory.EnumerateDirectories($"{appdata}/../LocalLow/miHoYo").Where(p => File.Exists($"{p}/info.txt"))) {
|
foreach (var path in Directory.EnumerateDirectories($"{appdata}/../LocalLow/miHoYo").Where(p => File.Exists($"{p}/info.txt"))) {
|
||||||
try {
|
try {
|
||||||
using var handle = File.OpenHandle($"{path}/output_log.txt", share: FileShare.None);
|
using var handle = File.OpenHandle($"{path}/output_log.txt", share: FileShare.None, mode: FileMode.OpenOrCreate);
|
||||||
} catch (IOException) {
|
} catch (IOException) {
|
||||||
AnsiConsole.WriteLine(App.GenshinIsRunning, 0);
|
AnsiConsole.WriteLine(App.GenshinIsRunning, 0);
|
||||||
Environment.Exit(301);
|
Environment.Exit(301);
|
||||||
@@ -176,24 +176,25 @@ public static class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void InstallExceptionHook() {
|
public static void InstallExceptionHook() {
|
||||||
AppDomain.CurrentDomain.UnhandledException += (_, e) => {
|
AppDomain.CurrentDomain.UnhandledException += (_, e) => OnUnhandledException((Exception) e.ExceptionObject);
|
||||||
var ex = e.ExceptionObject;
|
}
|
||||||
switch (ex) {
|
|
||||||
case ApplicationException ex1:
|
public static void OnUnhandledException(Exception ex) {
|
||||||
AnsiConsole.WriteLine(ex1.Message);
|
switch (ex) {
|
||||||
break;
|
case ApplicationException ex1:
|
||||||
case SocketException ex2:
|
AnsiConsole.WriteLine(ex1.Message);
|
||||||
AnsiConsole.WriteLine(App.ExceptionNetwork, nameof(SocketException), ex2.Message);
|
break;
|
||||||
break;
|
case SocketException ex2:
|
||||||
case HttpRequestException ex3:
|
AnsiConsole.WriteLine(App.ExceptionNetwork, nameof(SocketException), ex2.Message);
|
||||||
AnsiConsole.WriteLine(App.ExceptionNetwork, nameof(HttpRequestException), ex3.Message);
|
break;
|
||||||
break;
|
case HttpRequestException ex3:
|
||||||
default:
|
AnsiConsole.WriteLine(App.ExceptionNetwork, nameof(HttpRequestException), ex3.Message);
|
||||||
AnsiConsole.WriteLine(ex.ToString()!);
|
break;
|
||||||
break;
|
default:
|
||||||
}
|
AnsiConsole.WriteLine(ex.ToString());
|
||||||
Environment.Exit(-1);
|
break;
|
||||||
};
|
}
|
||||||
|
Environment.Exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool _isUnexpectedExit = true;
|
private static bool _isUnexpectedExit = true;
|
||||||
@@ -228,7 +229,7 @@ public static class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}).ContinueWith(task => { if (task.IsFaulted) OnUnhandledException(task.Exception!); });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe void SetQuickEditMode(bool enable) {
|
public static unsafe void SetQuickEditMode(bool enable) {
|
||||||
|
|||||||
Reference in New Issue
Block a user