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

1
native/.gitignore vendored
View File

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

View File

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

View File

@@ -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": {

View File

@@ -6,9 +6,10 @@
#include <Windows.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;
typedef unsigned char byte;
typedef unsigned int ui;
typedef unsigned long ul;
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 "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));