mirror of
https://github.com/HolographicHat/Yae.git
synced 2025-12-15 19:08:12 +08:00
add export
This commit is contained in:
@@ -16,6 +16,7 @@ public static class Export {
|
|||||||
[2] Paimon.moe
|
[2] Paimon.moe
|
||||||
[3] Seelie.me
|
[3] Seelie.me
|
||||||
[4] 表格文件
|
[4] 表格文件
|
||||||
|
[5] 原魔工具箱
|
||||||
输入一个数字(0-4): ".Split("\n").Select(s => s.Trim()).JoinToString("\n") + " ");
|
输入一个数字(0-4): ".Split("\n").Select(s => s.Trim()).JoinToString("\n") + " ");
|
||||||
if (!int.TryParse(Console.ReadLine(), out var num)) num = 0;
|
if (!int.TryParse(Console.ReadLine(), out var num)) num = 0;
|
||||||
((Action<AchievementAllDataNotify>) (num switch {
|
((Action<AchievementAllDataNotify>) (num switch {
|
||||||
@@ -23,6 +24,7 @@ public static class Export {
|
|||||||
2 => ToPaimon,
|
2 => ToPaimon,
|
||||||
3 => ToSeelie,
|
3 => ToSeelie,
|
||||||
4 => ToCSV,
|
4 => ToCSV,
|
||||||
|
5 => ToWxApp1,
|
||||||
7 => ToRawJson,
|
7 => ToRawJson,
|
||||||
_ => ToCocogoat
|
_ => ToCocogoat
|
||||||
})).Invoke(data);
|
})).Invoke(data);
|
||||||
@@ -46,6 +48,21 @@ public static class Export {
|
|||||||
: $"https://cocogoat.work/achievement?memo={memo.key}");
|
: $"https://cocogoat.work/achievement?memo={memo.key}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ToWxApp1(AchievementAllDataNotify data) {
|
||||||
|
var id = Guid.NewGuid().ToString("N").Substring(20, 8);
|
||||||
|
var result = JsonConvert.SerializeObject(new Dictionary<string, object> {
|
||||||
|
{ "key", id },
|
||||||
|
{ "data", ExportToUIAFApp(data) }
|
||||||
|
});
|
||||||
|
using var request = new HttpRequestMessage {
|
||||||
|
Method = HttpMethod.Post,
|
||||||
|
RequestUri = new Uri("https://api.qyinter.com/achievementRedis"),
|
||||||
|
Content = new StringContent(result, Encoding.UTF8, "application/json")
|
||||||
|
};
|
||||||
|
using var response = Utils.CHttpClient.Value.Send(request);
|
||||||
|
Console.WriteLine($"在小程序导入页面输入以下代码: {id}");
|
||||||
|
}
|
||||||
|
|
||||||
private static void ToSnapGenshin(AchievementAllDataNotify data) {
|
private static void ToSnapGenshin(AchievementAllDataNotify data) {
|
||||||
if (CheckSnapScheme()) {
|
if (CheckSnapScheme()) {
|
||||||
Utils.CopyToClipboard(JsonConvert.SerializeObject(ExportToUIAFApp(data)));
|
Utils.CopyToClipboard(JsonConvert.SerializeObject(ExportToUIAFApp(data)));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using YaeAchievement.Win32;
|
using YaeAchievement.Win32;
|
||||||
|
using static YaeAchievement.Win32.Native;
|
||||||
|
|
||||||
namespace YaeAchievement;
|
namespace YaeAchievement;
|
||||||
|
|
||||||
@@ -19,31 +20,33 @@ public static class Injector {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int LoadLibraryAndInject(IntPtr handle, string libPath) {
|
// todo: refactor
|
||||||
var hKernel = Native.GetModuleHandle("kernel32.dll");
|
public static int LoadLibraryAndInject(IntPtr hProc, string libPath) {
|
||||||
|
var hKernel = GetModuleHandle("kernel32.dll");
|
||||||
if (hKernel == IntPtr.Zero) {
|
if (hKernel == IntPtr.Zero) {
|
||||||
return new Win32Exception().PrintMsgAndReturnErrCode("GetModuleHandle fail");
|
return new Win32Exception().PrintMsgAndReturnErrCode("GetModuleHandle fail");
|
||||||
}
|
}
|
||||||
var pLoadLibrary = Native.GetProcAddress(hKernel, "LoadLibraryA");
|
var pLoadLibrary = GetProcAddress(hKernel, "LoadLibraryA");
|
||||||
if (pLoadLibrary == IntPtr.Zero) {
|
if (pLoadLibrary == IntPtr.Zero) {
|
||||||
return new Win32Exception().PrintMsgAndReturnErrCode("GetProcAddress fail");
|
return new Win32Exception().PrintMsgAndReturnErrCode("GetProcAddress fail");
|
||||||
}
|
}
|
||||||
var pBase = Native.VirtualAllocEx(handle, IntPtr.Zero, libPath.Length + 1, AllocationType.Reserve | AllocationType.Commit, MemoryProtection.ReadWrite);
|
var pBase = VirtualAllocEx(hProc, IntPtr.Zero, libPath.Length + 1, AllocationType.Reserve | AllocationType.Commit, MemoryProtection.ReadWrite);
|
||||||
if (pBase == IntPtr.Zero) {
|
if (pBase == IntPtr.Zero) {
|
||||||
return new Win32Exception().PrintMsgAndReturnErrCode("VirtualAllocEx fail");
|
return new Win32Exception().PrintMsgAndReturnErrCode("VirtualAllocEx fail");
|
||||||
}
|
}
|
||||||
if (!Native.WriteProcessMemory(handle, pBase, libPath.ToCharArray(), libPath.Length, out _)) {
|
if (!WriteProcessMemory(hProc, pBase, libPath.ToCharArray(), libPath.Length, out _)) {
|
||||||
return new Win32Exception().PrintMsgAndReturnErrCode("WriteProcessMemory fail");
|
return new Win32Exception().PrintMsgAndReturnErrCode("WriteProcessMemory fail");
|
||||||
}
|
}
|
||||||
var hThread = Native.CreateRemoteThread(handle, IntPtr.Zero, 0, pLoadLibrary, pBase, 0, out _);
|
var hThread = CreateRemoteThread(hProc, IntPtr.Zero, 0, pLoadLibrary, pBase, 0, out _);
|
||||||
if (hThread == IntPtr.Zero) {
|
if (hThread == IntPtr.Zero) {
|
||||||
var e = new Win32Exception();
|
var e = new Win32Exception();
|
||||||
if (!Native.VirtualFreeEx(handle, pBase, 0, AllocationType.Release)) {
|
VirtualFreeEx(hProc, pBase, 0, AllocationType.Release);
|
||||||
new Win32Exception().PrintMsgAndReturnErrCode("VirtualFreeEx fail");
|
|
||||||
}
|
|
||||||
return e.PrintMsgAndReturnErrCode("CreateRemoteThread fail");
|
return e.PrintMsgAndReturnErrCode("CreateRemoteThread fail");
|
||||||
}
|
}
|
||||||
return !Native.CloseHandle(hThread) ? new Win32Exception().PrintMsgAndReturnErrCode("CloseHandle fail") : 0;
|
if (WaitForSingleObject(hThread, 2000) == 0) {
|
||||||
|
VirtualFreeEx(hProc, pBase, 0, AllocationType.Release);
|
||||||
|
}
|
||||||
|
return !CloseHandle(hThread) ? new Win32Exception().PrintMsgAndReturnErrCode("CloseHandle fail") : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ public static class Utils {
|
|||||||
public static void CheckGenshinIsRunning() {
|
public static void CheckGenshinIsRunning() {
|
||||||
Process.EnterDebugMode();
|
Process.EnterDebugMode();
|
||||||
foreach (var process in Process.GetProcesses()) {
|
foreach (var process in Process.GetProcesses()) {
|
||||||
if (process.ProcessName is "GenshinImpact" or "YuanShen") {
|
if (process.ProcessName is "GenshinImpact" or "YuanShen" && !process.HasExited) {
|
||||||
Console.WriteLine($"原神正在运行,请关闭后重试 ({process.Id})");
|
Console.WriteLine($"原神正在运行,请关闭后重试 ({process.Id})");
|
||||||
Environment.Exit(301);
|
Environment.Exit(301);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,15 @@
|
|||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum AllocationType : uint {
|
public enum AllocationType : uint {
|
||||||
Commit = 0x1000,
|
Commit = 0x00001000,
|
||||||
Reserve = 0x2000,
|
Reserve = 0x00002000,
|
||||||
Decommit = 0x4000,
|
Reset = 0x00080000,
|
||||||
Release = 0x8000,
|
TopDown = 0x00100000,
|
||||||
Reset = 0x80000,
|
WriteWatch = 0x00200000,
|
||||||
Physical = 0x400000,
|
Physical = 0x00400000,
|
||||||
TopDown = 0x100000,
|
Rotate = 0x00800000,
|
||||||
WriteWatch = 0x200000,
|
ResetUndo = 0x01000000,
|
||||||
LargePages = 0x20000000
|
LargePages = 0x20000000,
|
||||||
|
Decommit = 0x00004000,
|
||||||
|
Release = 0x00008000
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,4 +146,7 @@ public static class Native {
|
|||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hdc);
|
public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hdc);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
public static extern uint WaitForSingleObject(IntPtr handle, ulong dwMilliseconds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user