From 89ab4408d6e446daee439fe41425f8b578d4c878 Mon Sep 17 00:00:00 2001 From: HolographicHat Date: Mon, 23 May 2022 12:14:24 +0800 Subject: [PATCH] Update --- .gitignore | 12 +--- native.d.ts | 11 --- native/.gitignore | 1 + native/binding.gyp | 2 + native/package.json | 4 +- native/src/define.h | 3 +- native/src/homu.h | 11 +++ native/src/main.cc | 3 +- proto/Messages.proto | 163 ++++++++++++++++++++----------------------- 9 files changed, 98 insertions(+), 112 deletions(-) delete mode 100644 native.d.ts create mode 100644 native/src/homu.h diff --git a/.gitignore b/.gitignore index 3b61391..8eb9733 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,6 @@ cache -cert -config.json -out.* -node_modules .idea -YaeAchievement-*.7z -YaeAchievement-*.exe -export*.json -secret.js +generated +node_modules +config.json package-lock.json -native.node diff --git a/native.d.ts b/native.d.ts deleted file mode 100644 index 54fa858..0000000 --- a/native.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export function selectGameExecutable(): string -export function checkGameIsRunning(processName: string): boolean -export function whoUseThePort(port: number): object -export function copyToClipboard(value: string): void -export function checkSnapFastcall(): boolean -export function enablePrivilege(): void -export function getDeviceInfo(): object -export function getMACAddress(): string -export function getDeviceID(): string -export function openUrl(url: string): number -export function pause(): void diff --git a/native/.gitignore b/native/.gitignore index 07e4818..4978b9c 100644 --- a/native/.gitignore +++ b/native/.gitignore @@ -3,3 +3,4 @@ CMakeLists.txt cmake-build-debug node_modules build +src/homu.cpp diff --git a/native/binding.gyp b/native/binding.gyp index f38d3b6..857123c 100644 --- a/native/binding.gyp +++ b/native/binding.gyp @@ -3,10 +3,12 @@ { "target_name": "native", "sources": [ + "src/homu.h", "src/main.cc", "src/utils.h", "src/utils.cc", "src/define.h", + "src/homu.cpp", "src/wmi/wmi.cpp", "src/wmi/wmi.hpp", "src/wmi/unistd.h", diff --git a/native/package.json b/native/package.json index 4666d73..a1c9a31 100644 --- a/native/package.json +++ b/native/package.json @@ -3,8 +3,8 @@ "version": "1.0.0", "description": "", "scripts": { - "build": "node-gyp rebuild && copy .\\build\\Release\\native.node ..\\genshin-export\\", - "build-for-win7": "node-gyp rebuild --target=v14.17.0 && copy .\\build\\Release\\native.node ..\\genshin-export\\" + "build": "node-gyp rebuild && copy .\\build\\Release\\native.node ..\\genshin-export\\generated", + "build-for-win7": "node-gyp rebuild --target=v14.17.0 && copy .\\build\\Release\\native.node ..\\genshin-export\\generated" }, "gypfile": true, "devDependencies": { diff --git a/native/src/define.h b/native/src/define.h index b63b1b4..87aa1e4 100644 --- a/native/src/define.h +++ b/native/src/define.h @@ -6,9 +6,10 @@ #include #include -using std::string, std::wstring, std::cout, std::to_string; +using std::string, std::wstring, std::cout, std::to_string, std::unique_ptr, std::make_unique; using Napi::Object, Napi::Env, Napi::Function, Napi::Value, Napi::CallbackInfo, Napi::TypeError, Napi::Error; typedef unsigned char byte; +typedef unsigned int ui; typedef unsigned long ul; typedef unsigned long long ull; diff --git a/native/src/homu.h b/native/src/homu.h new file mode 100644 index 0000000..d63e69f --- /dev/null +++ b/native/src/homu.h @@ -0,0 +1,11 @@ +// +// Created by holog on 2022/5/20. +// +#include "define.h" + +Value Initialize(const CallbackInfo &info); + +#ifndef GENSHIN_EXPORT_NATIVE_HOMU_H +#define GENSHIN_EXPORT_NATIVE_HOMU_H + +#endif //GENSHIN_EXPORT_NATIVE_HOMU_H diff --git a/native/src/main.cc b/native/src/main.cc index 6785503..52435d9 100644 --- a/native/src/main.cc +++ b/native/src/main.cc @@ -1,3 +1,4 @@ +#include "homu.h" #include "utils.h" #include "define.h" #include "wmi/wmi.hpp" @@ -218,7 +219,6 @@ namespace native { pAdapter = pAdapter->Next; continue; } - auto addr = (char *) malloc(16); char *result; ToHex((char *)pAdapter->Address, 6, &result); auto ret = Napi::String::New(env, result); @@ -232,6 +232,7 @@ namespace native { Object init(Env env, Object exports) { exports.Set("pause", Function::New(env, Pause)); exports.Set("openUrl", Function::New(env, OpenUrl)); + exports.Set("homuInit", Function::New(env, Initialize)); exports.Set("getDeviceID", Function::New(env, GetDeviceID)); exports.Set("getMACAddress", Function::New(env, GetMACAddress)); exports.Set("getDeviceInfo", Function::New(env, GetDeviceInfo)); diff --git a/proto/Messages.proto b/proto/Messages.proto index ca33254..5acb745 100644 --- a/proto/Messages.proto +++ b/proto/Messages.proto @@ -1,102 +1,89 @@ syntax = "proto3"; -message AllAchievement { - repeated Achievement list = 1; -} - -message Achievement { - - enum Status { - INVALID = 0; - UNFINISHED = 1; - FINISHED = 2; - REWARD_TAKEN = 3; +message QueryRegionList { + message SimpleInfo { + string name = 2; + string url = 4; } - - uint32 id = 1; - Status status = 2; - uint32 current = 3; - uint32 require = 4; - uint32 finish_timestamp = 5; - + int32 retcode = 1; + repeated SimpleInfo list = 2; } message QueryCurRegion { + message ResVersion { + uint32 v = 1; + } + message RegionInfo { + string ip = 1; + uint32 port = 2; + uint32 cdv = 14; + uint32 csv = 18; + ResVersion res = 22; + bytes sec = 23; + } int32 retcode = 1; string message = 2; - msg0 info = 3; - oneof group { - msg3 field2 = 4; - msg4 field3 = 5; + RegionInfo info = 3; +} + + +message Req1 { + uint32 t = 1; + string u = 2; + string tk = 3; + uint32 pl = 7; + uint32 ch = 11; + uint32 sc = 12; +} + +message Rsp1 { + int32 ret = 1; + string msg = 2; + uint32 uid = 3; + uint64 sd = 11; + bytes rc = 12; + string cv = 22; +} + +message Req2 { + string tk = 1; + string cv = 2; + string sv = 3; + string dn = 4; + string du = 5; + uint32 ln = 9; + uint32 at = 10; + string di = 13; + uint32 pf = 14; + string cs = 18; + bytes rc = 21; + uint32 sc = 25; + string cvc = 26; + uint32 cvd = 30; + string cvh = 34; +} + +message Notify1 { + message Achievement { + enum Status { + INVALID = 0; + UNFINISHED = 1; + FINISHED = 2; + REWARD_TAKEN = 3; + } + uint32 id = 1; + Status status = 2; + uint32 current = 3; + uint32 require = 4; + uint32 finishTimestamp = 5; } - bytes field4 = 11; - bytes field5 = 12; - bytes field6 = 13; + repeated Achievement list = 1; } -message QueryRegionList { - int32 retcode = 1; - bytes field0 = 5; - bytes field1 = 6; - bool field2 = 7; - repeated msg2 list = 2; +message Notify2 { // 4612 HWAvatarReward + repeated uint32 id = 1; } -message msg0 { - string ip = 1; - uint32 port = 2; - string field0 = 3; - string field1 = 7; - string field2 = 8; - string field3 = 9; - string field4 = 10; - string field5 = 11; - string field6 = 12; - string field7 = 13; - uint32 field8 = 14; - string field9 = 16; - uint32 fieldA = 18; - string fieldB = 19; - string fieldC = 20; - msg1 fieldD = 22; - bytes fieldE = 23; - string fieldF = 24; - string fieldG = 26; - string fieldH = 27; - bool fieldI = 28; - string fieldJ = 29; - string fieldK = 30; - string fieldL = 31; - string fieldM = 32; - string fieldN = 33; - string fieldO = 34; - msg1 fieldP = 35; -} - -message msg1 { - uint32 field0 = 1; - bool field1 = 2; - string field2 = 3; - string field3 = 4; - string field4 = 5; - string field5 = 6; - string field6 = 7; -} - -message msg2 { - string field0 = 1; - string field1 = 2; - string field2 = 3; - string url = 4; -} - -message msg3 { - string field0 = 1; -} - -message msg4 { - uint32 field0 = 1; - uint32 field1 = 2; - string field2 = 3; - string field3 = 4; +message Notify3 { // 4571 HWBGM + repeated uint32 id = 1; }