This commit is contained in:
HolographicHat
2022-05-23 12:14:24 +08:00
parent bf01214971
commit 89ab4408d6
9 changed files with 98 additions and 112 deletions

12
.gitignore vendored
View File

@@ -1,12 +1,6 @@
cache cache
cert
config.json
out.*
node_modules
.idea .idea
YaeAchievement-*.7z generated
YaeAchievement-*.exe node_modules
export*.json config.json
secret.js
package-lock.json package-lock.json
native.node

11
native.d.ts vendored
View File

@@ -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

1
native/.gitignore vendored
View File

@@ -3,3 +3,4 @@ CMakeLists.txt
cmake-build-debug cmake-build-debug
node_modules node_modules
build build
src/homu.cpp

View File

@@ -3,10 +3,12 @@
{ {
"target_name": "native", "target_name": "native",
"sources": [ "sources": [
"src/homu.h",
"src/main.cc", "src/main.cc",
"src/utils.h", "src/utils.h",
"src/utils.cc", "src/utils.cc",
"src/define.h", "src/define.h",
"src/homu.cpp",
"src/wmi/wmi.cpp", "src/wmi/wmi.cpp",
"src/wmi/wmi.hpp", "src/wmi/wmi.hpp",
"src/wmi/unistd.h", "src/wmi/unistd.h",

View File

@@ -3,8 +3,8 @@
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"scripts": { "scripts": {
"build": "node-gyp rebuild && 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\\" "build-for-win7": "node-gyp rebuild --target=v14.17.0 && copy .\\build\\Release\\native.node ..\\genshin-export\\generated"
}, },
"gypfile": true, "gypfile": true,
"devDependencies": { "devDependencies": {

View File

@@ -6,9 +6,10 @@
#include <Windows.h> #include <Windows.h>
#include <TlHelp32.h> #include <TlHelp32.h>
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; using Napi::Object, Napi::Env, Napi::Function, Napi::Value, Napi::CallbackInfo, Napi::TypeError, Napi::Error;
typedef unsigned char byte; typedef unsigned char byte;
typedef unsigned int ui;
typedef unsigned long ul; typedef unsigned long ul;
typedef unsigned long long ull; typedef unsigned long long ull;

11
native/src/homu.h Normal file
View File

@@ -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

View File

@@ -1,3 +1,4 @@
#include "homu.h"
#include "utils.h" #include "utils.h"
#include "define.h" #include "define.h"
#include "wmi/wmi.hpp" #include "wmi/wmi.hpp"
@@ -218,7 +219,6 @@ namespace native {
pAdapter = pAdapter->Next; pAdapter = pAdapter->Next;
continue; continue;
} }
auto addr = (char *) malloc(16);
char *result; char *result;
ToHex((char *)pAdapter->Address, 6, &result); ToHex((char *)pAdapter->Address, 6, &result);
auto ret = Napi::String::New(env, result); auto ret = Napi::String::New(env, result);
@@ -232,6 +232,7 @@ namespace native {
Object init(Env env, Object exports) { Object init(Env env, Object exports) {
exports.Set("pause", Function::New(env, Pause)); exports.Set("pause", Function::New(env, Pause));
exports.Set("openUrl", Function::New(env, OpenUrl)); exports.Set("openUrl", Function::New(env, OpenUrl));
exports.Set("homuInit", Function::New(env, Initialize));
exports.Set("getDeviceID", Function::New(env, GetDeviceID)); exports.Set("getDeviceID", Function::New(env, GetDeviceID));
exports.Set("getMACAddress", Function::New(env, GetMACAddress)); exports.Set("getMACAddress", Function::New(env, GetMACAddress));
exports.Set("getDeviceInfo", Function::New(env, GetDeviceInfo)); exports.Set("getDeviceInfo", Function::New(env, GetDeviceInfo));

View File

@@ -1,102 +1,89 @@
syntax = "proto3"; syntax = "proto3";
message AllAchievement { message QueryRegionList {
repeated Achievement list = 1; message SimpleInfo {
} string name = 2;
string url = 4;
message Achievement {
enum Status {
INVALID = 0;
UNFINISHED = 1;
FINISHED = 2;
REWARD_TAKEN = 3;
} }
int32 retcode = 1;
uint32 id = 1; repeated SimpleInfo list = 2;
Status status = 2;
uint32 current = 3;
uint32 require = 4;
uint32 finish_timestamp = 5;
} }
message QueryCurRegion { 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; int32 retcode = 1;
string message = 2; string message = 2;
msg0 info = 3; RegionInfo info = 3;
oneof group { }
msg3 field2 = 4;
msg4 field3 = 5;
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; repeated Achievement list = 1;
bytes field5 = 12;
bytes field6 = 13;
} }
message QueryRegionList { message Notify2 { // 4612 HWAvatarReward
int32 retcode = 1; repeated uint32 id = 1;
bytes field0 = 5;
bytes field1 = 6;
bool field2 = 7;
repeated msg2 list = 2;
} }
message msg0 { message Notify3 { // 4571 HWBGM
string ip = 1; repeated uint32 id = 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;
} }