@hxl1/commontools 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ .prettierrc.js +11 -0
- package/.idea/.name +1 -0
- package/.idea/commTools.iml +2 -0
- package/.idea/encodings.xml +8 -0
- package/.idea/misc.xml +1 -3
- package/.idea/modules.xml +1 -1
- package/.idea/prettier.xml +7 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +30 -0
- package/include/win_delay_load_hook.cc +52 -0
- package/package.json +31 -6
- package/test/commonTools.ts +3 -0
- package/test/index.d.ts +3 -0
- package/test/index.ts +4 -0
- package/test/types/H.ts +84 -0
- package/test/types/HD.ts +98 -0
- package/test/types/HPath.ts +107 -0
- package/test/types/HR.ts +141 -0
- package/test/types/commonTools.ts +11 -0
- package/test/utils/HFile.ts +169 -0
- package/test/utils/HPath.ts +80 -0
- package/test/views/H.ts +50 -0
- package/test/views/HD.ts +17 -0
- package/test/views/HPath.ts +16 -0
- package/test/views/HR.ts +43 -0
- package/tsconfig.json +34 -0
- package/.idea/my-first-npm-package.iml +0 -9
- package/index.js +0 -16
package/ .prettierrc.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
printWidth: 140, // ÿ�д��볤��
|
|
3
|
+
tabWidth: 2, // tab ���ȣ�2���ո�
|
|
4
|
+
useTabs: false, // ��ʹ�� tab ����
|
|
5
|
+
singleQuote: true, // ʹ�õ�����
|
|
6
|
+
semi: true, // ʹ�÷ֺ�
|
|
7
|
+
trailingComma: "all", // ʹ��β����
|
|
8
|
+
bracketSpacing: true, // �����������Ĵ����ż�ʹ�ÿո�
|
|
9
|
+
arrowParens: "avoid", // ֻ��һ�������ļ�ͷ������������Բ����
|
|
10
|
+
endOfLine: "auto",
|
|
11
|
+
};
|
package/.idea/.name
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nApiTest
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="Encoding">
|
|
4
|
+
<file url="file://$PROJECT_DIR$/test/types/H.ts" charset="UTF-8" />
|
|
5
|
+
<file url="file://$PROJECT_DIR$/test/views/H.ts" charset="UTF-8" />
|
|
6
|
+
<file url="file://$PROJECT_DIR$/test/views/HR.ts" charset="UTF-8" />
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/misc.xml
CHANGED
package/.idea/modules.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ProjectModuleManager">
|
|
4
4
|
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/commTools.iml" filepath="$PROJECT_DIR$/.idea/commTools.iml" />
|
|
6
6
|
</modules>
|
|
7
7
|
</component>
|
|
8
8
|
</project>
|
package/.idea/vcs.xml
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
## cmake-js ����Ĵ���
|
|
2
|
+
��Ҫ�ص㲻��ֱ��ʹ��cmkr.exe ����c++ ���룬��ʹ��cmake-js ����,
|
|
3
|
+
|
|
4
|
+
���ұ���node��c++ ��,ȫ�̴���ʾ,node�İ�ȫ������, ��д���벻���д�����ʾ
|
|
5
|
+
|
|
6
|
+
���ֿ������һ��imgui��node�汾, ֻ����Ϊ����IJ��Բֿ�,��������֧����@����
|
|
7
|
+
|
|
8
|
+
#### 1.��Ҫ��װnode��
|
|
9
|
+
```
|
|
10
|
+
npm i -g cnpm
|
|
11
|
+
cnpm i
|
|
12
|
+
```
|
|
13
|
+
#### 2.������Ҫ����node��ͷ�ļ���lib��
|
|
14
|
+
```asm
|
|
15
|
+
cmake-js install // ��${user}/.cmake-jsĿ¼�����ص�ǰnode�ı����node
|
|
16
|
+
```
|
|
17
|
+
#### 3.����
|
|
18
|
+
```asm
|
|
19
|
+
.\cmkr.exe gen // ����cmake.total
|
|
20
|
+
|
|
21
|
+
����nApiTest.node
|
|
22
|
+
|
|
23
|
+
npm run dev
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### 4.���
|
|
27
|
+
```
|
|
28
|
+
pkg �����
|
|
29
|
+
npm run build
|
|
30
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* When this file is linked to a DLL, it sets up a delay-load hook that
|
|
3
|
+
* intervenes when the DLL is trying to load 'node.exe' or 'iojs.exe'
|
|
4
|
+
* dynamically. Instead of trying to locate the .exe file it'll just return
|
|
5
|
+
* a handle to the process image.
|
|
6
|
+
*
|
|
7
|
+
* This allows compiled addons to work when node.exe or iojs.exe is renamed.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#ifdef _MSC_VER
|
|
11
|
+
|
|
12
|
+
#ifndef WIN32_LEAN_AND_MEAN
|
|
13
|
+
#define WIN32_LEAN_AND_MEAN
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
#include <Windows.h>
|
|
17
|
+
|
|
18
|
+
#include <delayimp.h>
|
|
19
|
+
#include <string.h>
|
|
20
|
+
|
|
21
|
+
static HMODULE node_dll = NULL;
|
|
22
|
+
static HMODULE nw_dll = NULL;
|
|
23
|
+
|
|
24
|
+
static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) {
|
|
25
|
+
if (event == dliNotePreGetProcAddress) {
|
|
26
|
+
FARPROC ret = NULL;
|
|
27
|
+
ret = GetProcAddress(node_dll, info->dlp.szProcName);
|
|
28
|
+
if (ret)
|
|
29
|
+
return ret;
|
|
30
|
+
ret = GetProcAddress(nw_dll, info->dlp.szProcName);
|
|
31
|
+
return ret;
|
|
32
|
+
}
|
|
33
|
+
if (event == dliStartProcessing) {
|
|
34
|
+
node_dll = GetModuleHandleA("node.dll");
|
|
35
|
+
nw_dll = GetModuleHandleA("nw.dll");
|
|
36
|
+
return NULL;
|
|
37
|
+
}
|
|
38
|
+
if (event != dliNotePreLoadLibrary)
|
|
39
|
+
return NULL;
|
|
40
|
+
|
|
41
|
+
if (_stricmp(info->szDll, "node.exe") != 0)
|
|
42
|
+
return NULL;
|
|
43
|
+
|
|
44
|
+
// Fall back to the current process
|
|
45
|
+
if(!node_dll) node_dll = GetModuleHandleA(NULL);
|
|
46
|
+
|
|
47
|
+
return (FARPROC) node_dll;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
decltype(__pfnDliNotifyHook2) __pfnDliNotifyHook2 = load_exe_hook;
|
|
51
|
+
|
|
52
|
+
#endif
|
package/package.json
CHANGED
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hxl1/commontools",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"license": "ISC",
|
|
6
|
-
"author": "",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"description": "hxl1的node版本公共代码仓库",
|
|
7
5
|
"type": "module",
|
|
8
|
-
"main": "index.js",
|
|
6
|
+
"main": "test/index.js",
|
|
7
|
+
"types": "test/index.d.ts",
|
|
9
8
|
"publishConfig": {
|
|
10
9
|
"registry": "https://registry.npmjs.org/",
|
|
11
10
|
"access": "public"
|
|
12
11
|
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">= 20.8.0"
|
|
14
|
+
},
|
|
13
15
|
"scripts": {
|
|
14
|
-
"
|
|
16
|
+
"dev": "node test/index.ts",
|
|
17
|
+
"build_node": "webpack",
|
|
18
|
+
"build": "npm run build_node && pkg package.json --no-bytecode --compress Brotli && create-nodew-exe ./dist/cmake-js-example.exe ./dist/cmake-js-example.exe"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [],
|
|
21
|
+
"author": "deepso",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^22.7.5",
|
|
25
|
+
"cmake-js": "^7.3.0",
|
|
26
|
+
"tsx": "^4.19.1",
|
|
27
|
+
"typescript": "^5.6.3",
|
|
28
|
+
"webpack-cli": "^7.0.0",
|
|
29
|
+
"node-addon-api": "^8.2.1",
|
|
30
|
+
"node-loader": "^2.1.0",
|
|
31
|
+
"prettier": "^3.8.1",
|
|
32
|
+
"ts-loader": "^9.5.4",
|
|
33
|
+
"webpack": "^5.105.4",
|
|
34
|
+
"webpack-node-externals": "^3.0.0"
|
|
35
|
+
},
|
|
36
|
+
"bin": "dist/index.cjs",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@types/node": "^25.5.0",
|
|
39
|
+
"node-addon-api": "^8.6.0"
|
|
15
40
|
}
|
|
16
41
|
}
|
package/test/index.d.ts
ADDED
package/test/index.ts
ADDED
package/test/types/H.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// test/types/H.ts
|
|
2
|
+
export interface WindowRect {
|
|
3
|
+
left: number;
|
|
4
|
+
top: number;
|
|
5
|
+
right: number;
|
|
6
|
+
bottom: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface WindowInfo {
|
|
10
|
+
className: string;
|
|
11
|
+
windowText: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type Matrix4x4 = [
|
|
15
|
+
[number, number, number, number],
|
|
16
|
+
[number, number, number, number],
|
|
17
|
+
[number, number, number, number],
|
|
18
|
+
[number, number, number, number],
|
|
19
|
+
];
|
|
20
|
+
export interface IH {
|
|
21
|
+
// 全局进程ID
|
|
22
|
+
setGlobalProcessId(pid: number): void;
|
|
23
|
+
getGlobalProcessId(): number;
|
|
24
|
+
|
|
25
|
+
// 进程和窗口操作
|
|
26
|
+
getPidByName(processName: string): number;
|
|
27
|
+
getHandByPid(pid: number): number;
|
|
28
|
+
getPidByHand(handle: number): number;
|
|
29
|
+
getWindowRect(handle: number): WindowRect | null;
|
|
30
|
+
findWindowSS(subString: string): bigint;
|
|
31
|
+
getHandleByName(className: string): bigint;
|
|
32
|
+
findWindow(className?: string, windowName?: string): bigint;
|
|
33
|
+
getCurrentPid(): number;
|
|
34
|
+
|
|
35
|
+
// 内存操作
|
|
36
|
+
allocMem(pid: number, size?: number): number;
|
|
37
|
+
freeMem(pid: number, pointer: number, size?: number): void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 读取进程内存数据
|
|
41
|
+
* @param address 内存地址
|
|
42
|
+
* @param typeOrSize 数据类型或大小 - 可以是字符串类型("string"/"utf8"/"utf16")或数值类型(1/2/4/8)
|
|
43
|
+
* @param length 可选,当读取字符串时指定长度
|
|
44
|
+
* @returns 根据参数类型返回字符串、数值或Buffer
|
|
45
|
+
*/
|
|
46
|
+
getData(
|
|
47
|
+
address: number,
|
|
48
|
+
typeOrSize: "string" | "utf8" | "utf16" | number,
|
|
49
|
+
length?: number,
|
|
50
|
+
): string | number | Buffer | null;
|
|
51
|
+
/**
|
|
52
|
+
* 写入进程内存数据
|
|
53
|
+
* @param address 内存地址
|
|
54
|
+
* @param value 要写入的值 - 可以是字符串、数值或Buffer
|
|
55
|
+
* @param size 可选,当写入数值时指定大小(1/2/4/8)
|
|
56
|
+
* @returns 是否写入成功 @TODO:目前字符串类型还有问题
|
|
57
|
+
*/
|
|
58
|
+
setData(
|
|
59
|
+
address: number,
|
|
60
|
+
value: string | number | Buffer,
|
|
61
|
+
size?: number, // @TODO:目前字符串类型还有问题
|
|
62
|
+
): boolean;
|
|
63
|
+
getMatrixFromMem(pid: number, address: bigint): Matrix4x4 | null;
|
|
64
|
+
|
|
65
|
+
// 系统工具
|
|
66
|
+
improvePower(enable?: boolean): boolean;
|
|
67
|
+
getInfoByHand(handle: number): WindowInfo;
|
|
68
|
+
is64BitProcess(pid: number): boolean;
|
|
69
|
+
getRunPath(): string;
|
|
70
|
+
getAsyncKeyState(keyCode: number): number;
|
|
71
|
+
|
|
72
|
+
// 字符串和文件操作
|
|
73
|
+
strToUtf8(str: string): string;
|
|
74
|
+
createFileByBinary(
|
|
75
|
+
fileName: string,
|
|
76
|
+
filePath: string,
|
|
77
|
+
data: Buffer,
|
|
78
|
+
dataLength: number,
|
|
79
|
+
hideFile?: boolean,
|
|
80
|
+
): boolean;
|
|
81
|
+
|
|
82
|
+
// 实用工具
|
|
83
|
+
genUuid(): string;
|
|
84
|
+
}
|
package/test/types/HD.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export interface IHDriver {
|
|
2
|
+
/**
|
|
3
|
+
* ���캯��
|
|
4
|
+
* @param driverName ��ѡ����������
|
|
5
|
+
* @param driverPath ��ѡ�������ļ�·��
|
|
6
|
+
*/
|
|
7
|
+
constructor(driverName?: string, driverPath?: string);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* ��װ����
|
|
11
|
+
*/
|
|
12
|
+
installDriver(): boolean;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* �����
|
|
16
|
+
*/
|
|
17
|
+
unloadDriver(): boolean;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* ��ȡģ���ַ
|
|
21
|
+
* @param pid ����ID
|
|
22
|
+
* @param moduleName ���
|
|
23
|
+
*/
|
|
24
|
+
getModuleAddr(pid: number, moduleName: string): bigint;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* ��ȡ�ڴ棨ģ�巽�����˴�ռλ��
|
|
28
|
+
* @param pid ����ID
|
|
29
|
+
* @param address ��ַ
|
|
30
|
+
* @param data ������ݣ����ã�
|
|
31
|
+
*/
|
|
32
|
+
readData(pid: number, address: bigint, data: any): boolean;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* д���ڴ棨ģ�巽����ռλ��
|
|
36
|
+
*/
|
|
37
|
+
writeData(pid: number, address: bigint, data: any): boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* ��������
|
|
41
|
+
*/
|
|
42
|
+
protectProcess(pid: number): boolean;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* ���ؽ���
|
|
46
|
+
* @param status 1���� 0��ʾ
|
|
47
|
+
*/
|
|
48
|
+
hideProcess(pid: number, status: number): boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* ��ֹ����
|
|
52
|
+
*/
|
|
53
|
+
killProcess(pid: number): boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* ����αװ
|
|
57
|
+
* @param pid Ŀ�����
|
|
58
|
+
* @param toPid αװ���ĸ�����
|
|
59
|
+
*/
|
|
60
|
+
processCamouflage(pid: number, toPid: number): boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* �����ڴ棨�ڵ�ǰ���̣�
|
|
64
|
+
*/
|
|
65
|
+
allocMemory(): bigint;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* �ͷ��ڴ�
|
|
69
|
+
*/
|
|
70
|
+
freeMemory(pid: number, address: bigint): boolean;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* �������豸
|
|
74
|
+
* @param deviceName �豸��������\\.\��
|
|
75
|
+
*/
|
|
76
|
+
openDevice(deviceName: string): number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* ��װ����������ʽ��δ��ȫʵ�֣�
|
|
80
|
+
*/
|
|
81
|
+
installDriverNormal(driverName: string, driverPath: string): boolean;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* ��������������ʽ��δ��ȫʵ�֣�
|
|
85
|
+
*/
|
|
86
|
+
startDriverNormal(): boolean;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* ֹͣ����������ʽ��δ��ȫʵ�֣�
|
|
90
|
+
*/
|
|
91
|
+
stopDriverNormal(): boolean;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* �Ƴ�����������ʽ��δ��ȫʵ�֣�
|
|
95
|
+
*/
|
|
96
|
+
removeDriverNormal(): boolean;
|
|
97
|
+
}
|
|
98
|
+
export type IHD = new () => IHDriver;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ·������ģ��
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* �����ļ�������ö��
|
|
6
|
+
*/
|
|
7
|
+
export enum SpecialFolderType {
|
|
8
|
+
/**
|
|
9
|
+
* �������
|
|
10
|
+
*/
|
|
11
|
+
DESKTOP = 0x0000,
|
|
12
|
+
/**
|
|
13
|
+
* �������
|
|
14
|
+
*/
|
|
15
|
+
DOWNLOADS = 0x0001,
|
|
16
|
+
/**
|
|
17
|
+
* �ĵ��ļ���
|
|
18
|
+
*/
|
|
19
|
+
DOCUMENTS = 0x0002,
|
|
20
|
+
/**
|
|
21
|
+
* ͼƬ�ļ���
|
|
22
|
+
*/
|
|
23
|
+
PICTURES = 0x0003,
|
|
24
|
+
/**
|
|
25
|
+
* �������
|
|
26
|
+
*/
|
|
27
|
+
MUSIC = 0x0004,
|
|
28
|
+
/**
|
|
29
|
+
* ��Ƶ�ļ���
|
|
30
|
+
*/
|
|
31
|
+
VIDEOS = 0x0005,
|
|
32
|
+
/**
|
|
33
|
+
* ��ʱ�ļ���
|
|
34
|
+
*/
|
|
35
|
+
TEMP = 0x0006,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* ·�������ӿ�
|
|
40
|
+
*/
|
|
41
|
+
export interface IHPath {
|
|
42
|
+
/**
|
|
43
|
+
* ��ȡ��ǰִ���ļ���Ŀ¼·��
|
|
44
|
+
* @returns ��ǰ·���ַ���
|
|
45
|
+
*/
|
|
46
|
+
getCurrentPath(): string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* ��ȡ·����Ŀ¼����
|
|
50
|
+
* @param path ����·��
|
|
51
|
+
* @returns Ŀ¼·��
|
|
52
|
+
*/
|
|
53
|
+
dirName(path: string): string;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* ��ȡ·�����ļ�������
|
|
57
|
+
* @param path ����·��
|
|
58
|
+
* @returns ���
|
|
59
|
+
*/
|
|
60
|
+
fileName(path: string): string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* ��ȡϵͳ��ʱ�ļ���·��
|
|
64
|
+
* @returns ��ʱ�ļ���·��
|
|
65
|
+
*/
|
|
66
|
+
getTempPath(): string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* ��ȡ�û������ļ���·��
|
|
70
|
+
* @param type �ļ�������ö��
|
|
71
|
+
* @returns �ļ���·��
|
|
72
|
+
*/
|
|
73
|
+
getUserPath(type: SpecialFolderType): string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* ��ָ��Ŀ¼
|
|
77
|
+
* @param path Ŀ¼·��
|
|
78
|
+
* @returns �Ƿ�ɹ���
|
|
79
|
+
*/
|
|
80
|
+
openDir(path: string): boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* ���·��
|
|
84
|
+
* @param paths Ҫ��ϵ�·��Ƭ��
|
|
85
|
+
* @returns ��Ϻ��·��
|
|
86
|
+
*/
|
|
87
|
+
join(...paths: string[]): string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* ���·���Ƿ����
|
|
91
|
+
* @param path Ҫ����·��
|
|
92
|
+
* @returns �Ƿ����
|
|
93
|
+
*/
|
|
94
|
+
exists(path: string): boolean;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* ����Ŀ¼
|
|
98
|
+
* @param path Ŀ¼·��
|
|
99
|
+
* @returns �Ƿ��ɹ�
|
|
100
|
+
*/
|
|
101
|
+
mkdir(path: string): boolean;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* ���������
|
|
105
|
+
*/
|
|
106
|
+
test(): void;
|
|
107
|
+
}
|
package/test/types/HR.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows ע�������ö��
|
|
3
|
+
*/
|
|
4
|
+
export enum RegistryRootKey {
|
|
5
|
+
/**
|
|
6
|
+
* ��ǰ�û���������
|
|
7
|
+
*/
|
|
8
|
+
HKEY_CURRENT_USER = 0x80000001,
|
|
9
|
+
/**
|
|
10
|
+
* ���ؼ������������
|
|
11
|
+
*/
|
|
12
|
+
HKEY_LOCAL_MACHINE = 0x80000002,
|
|
13
|
+
/**
|
|
14
|
+
* �����û���������
|
|
15
|
+
*/
|
|
16
|
+
HKEY_USERS = 0x80000003,
|
|
17
|
+
/**
|
|
18
|
+
* ��������
|
|
19
|
+
*/
|
|
20
|
+
HKEY_PERFORMANCE_DATA = 0x80000004,
|
|
21
|
+
/**
|
|
22
|
+
* ��ǰ�û��������� (64λϵͳ�ϵ�32λӦ��)
|
|
23
|
+
*/
|
|
24
|
+
HKEY_CURRENT_CONFIG = 0x80000005,
|
|
25
|
+
/**
|
|
26
|
+
* ��̬����
|
|
27
|
+
*/
|
|
28
|
+
HKEY_DYN_DATA = 0x80000006,
|
|
29
|
+
/**
|
|
30
|
+
* ����������
|
|
31
|
+
*/
|
|
32
|
+
HKEY_CLASSES_ROOT = 0x80000000,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* ע���ֵ����ö��
|
|
37
|
+
*/
|
|
38
|
+
export enum RegistryValueType {
|
|
39
|
+
/**
|
|
40
|
+
* �������
|
|
41
|
+
*/
|
|
42
|
+
REG_NONE = 0,
|
|
43
|
+
/**
|
|
44
|
+
* ��null��β���ַ���
|
|
45
|
+
*/
|
|
46
|
+
REG_SZ = 1,
|
|
47
|
+
/**
|
|
48
|
+
* ��null��β���ַ��� (������������)
|
|
49
|
+
*/
|
|
50
|
+
REG_EXPAND_SZ = 2,
|
|
51
|
+
/**
|
|
52
|
+
* ����������
|
|
53
|
+
*/
|
|
54
|
+
REG_BINARY = 3,
|
|
55
|
+
/**
|
|
56
|
+
* 32���
|
|
57
|
+
*/
|
|
58
|
+
REG_DWORD = 4,
|
|
59
|
+
/**
|
|
60
|
+
* 32λ���� (С����)
|
|
61
|
+
*/
|
|
62
|
+
REG_DWORD_LITTLE_ENDIAN = 4,
|
|
63
|
+
/**
|
|
64
|
+
* 32��� (�����)
|
|
65
|
+
*/
|
|
66
|
+
REG_DWORD_BIG_ENDIAN = 5,
|
|
67
|
+
/**
|
|
68
|
+
* ��������
|
|
69
|
+
*/
|
|
70
|
+
REG_LINK = 6,
|
|
71
|
+
/**
|
|
72
|
+
* ���ַ�������
|
|
73
|
+
*/
|
|
74
|
+
REG_MULTI_SZ = 7,
|
|
75
|
+
/**
|
|
76
|
+
* ��Դ�б�
|
|
77
|
+
*/
|
|
78
|
+
REG_RESOURCE_LIST = 8,
|
|
79
|
+
/**
|
|
80
|
+
* ������Դ������
|
|
81
|
+
*/
|
|
82
|
+
REG_FULL_RESOURCE_DESCRIPTOR = 9,
|
|
83
|
+
/**
|
|
84
|
+
* ��Դ�����б�
|
|
85
|
+
*/
|
|
86
|
+
REG_RESOURCE_REQUIREMENTS_LIST = 10,
|
|
87
|
+
/**
|
|
88
|
+
* 64���
|
|
89
|
+
*/
|
|
90
|
+
REG_QWORD = 11,
|
|
91
|
+
/**
|
|
92
|
+
* 64λ���� (С����)
|
|
93
|
+
*/
|
|
94
|
+
REG_QWORD_LITTLE_ENDIAN = 11,
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface IHR {
|
|
98
|
+
/**
|
|
99
|
+
* ��ȡע���ֵ
|
|
100
|
+
* @param rootKey HKEY ����ö��
|
|
101
|
+
* @param path ע���·�� (�� "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")
|
|
102
|
+
* @param type ��������������ö��
|
|
103
|
+
* @returns �ַ�����Buffer��ȡ��������
|
|
104
|
+
*/
|
|
105
|
+
readRegistry(
|
|
106
|
+
rootKey: RegistryRootKey,
|
|
107
|
+
path: string,
|
|
108
|
+
type: RegistryValueType,
|
|
109
|
+
): string | Buffer | null;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* д��ע���ֵ
|
|
113
|
+
* @param rootKey HKEY ����ö��
|
|
114
|
+
* @param path ע���·��
|
|
115
|
+
* @param value Ҫд���ֵ (�ַ�����Buffer)
|
|
116
|
+
* @param type ��������ö��
|
|
117
|
+
* @returns �Ƿ�ɹ�
|
|
118
|
+
*/
|
|
119
|
+
writeRegistry(
|
|
120
|
+
rootKey: RegistryRootKey,
|
|
121
|
+
path: string,
|
|
122
|
+
value: string | Buffer,
|
|
123
|
+
type: RegistryValueType,
|
|
124
|
+
): boolean;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* ɾ��ע���ֵ
|
|
128
|
+
* @param rootKey HKEY ����ö��
|
|
129
|
+
* @param path ע���·��
|
|
130
|
+
* @returns �Ƿ�ɹ�
|
|
131
|
+
*/
|
|
132
|
+
deleteRegValue(rootKey: RegistryRootKey, path: string): boolean;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* ɾ��ע�����
|
|
136
|
+
* @param rootKey HKEY ����ö��
|
|
137
|
+
* @param path ע���·��
|
|
138
|
+
* @returns �Ƿ�ɹ�
|
|
139
|
+
*/
|
|
140
|
+
deleteRegKey(rootKey: RegistryRootKey, path: string): boolean;
|
|
141
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// 封装文件的各种操作
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import { exec } from 'child_process';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
interface FileAttribute {
|
|
6
|
+
hide?: boolean; // 隐藏
|
|
7
|
+
system?: boolean; // 系统文件
|
|
8
|
+
readonly?: boolean; // 只读文件
|
|
9
|
+
archive?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const g_offset = [0x30, 0x20, 0x40, 0x83, 0xed, 0x54, 0x67, 0x89, 0x0a, 0x0b];
|
|
13
|
+
class HFile {
|
|
14
|
+
static isFileExist(filePath: string): boolean {
|
|
15
|
+
return fs.existsSync(filePath);
|
|
16
|
+
}
|
|
17
|
+
static async createDir(filePath: string) {
|
|
18
|
+
try {
|
|
19
|
+
fs.mkdirSync(filePath, { recursive: true });
|
|
20
|
+
return true;
|
|
21
|
+
} catch (e) {
|
|
22
|
+
if (e.code === 'EEXIST') {
|
|
23
|
+
console.log('目录已经存在');
|
|
24
|
+
return true;
|
|
25
|
+
} else {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// 写文件
|
|
31
|
+
static writeFile(filePathData: string, data: string) {
|
|
32
|
+
try {
|
|
33
|
+
fs.writeFileSync(filePathData, data);
|
|
34
|
+
return true;
|
|
35
|
+
} catch (e) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
static readFile(filePath: string, opt: object = { encoding: 'utf8' }) {
|
|
40
|
+
try {
|
|
41
|
+
return fs.readFileSync(filePath, opt).toString();
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// 类似文件夹一样打开指定应用
|
|
47
|
+
static openFile(filePath: string) {
|
|
48
|
+
if (!fs.existsSync(filePath)) return false;
|
|
49
|
+
const absolutePath = path.resolve(filePath);
|
|
50
|
+
let command;
|
|
51
|
+
switch (process.platform) {
|
|
52
|
+
case 'win32':
|
|
53
|
+
command = `start "" "${absolutePath}"`;
|
|
54
|
+
break;
|
|
55
|
+
case 'darwin':
|
|
56
|
+
command = `open "${absolutePath}"`;
|
|
57
|
+
break;
|
|
58
|
+
case 'linux':
|
|
59
|
+
command = `xdg-open "${absolutePath}"`;
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
throw new Error(`Unsupported platform: ${process.platform}`);
|
|
63
|
+
}
|
|
64
|
+
exec(command);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
// 把数组写入倒文件
|
|
68
|
+
static writeArrayToFile(filePath: string, array: number[], isEncrypt: boolean = true) {
|
|
69
|
+
const arrayBuffer = new ArrayBuffer(array.length);
|
|
70
|
+
const view = new DataView(arrayBuffer);
|
|
71
|
+
for (let i = 0; i < array.length; i++) {
|
|
72
|
+
if (isEncrypt) {
|
|
73
|
+
view.setUint8(i, array[i] ^ g_offset[i % 10]);
|
|
74
|
+
} else {
|
|
75
|
+
view.setUint8(i, array[i]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
80
|
+
fs.writeFileSync(filePath, Buffer.from(arrayBuffer));
|
|
81
|
+
return true;
|
|
82
|
+
} catch (e) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// 把文件读取到数组里面
|
|
87
|
+
static readArrayFromFile(filePath: string, isEncrypt: boolean = true): number[] | null {
|
|
88
|
+
try {
|
|
89
|
+
// 读取文件内容
|
|
90
|
+
const fileBuffer = fs.readFileSync(filePath);
|
|
91
|
+
const array = new Array<number>(fileBuffer.length);
|
|
92
|
+
// 解密数据
|
|
93
|
+
for (let i = 0; i < fileBuffer.length; i++) {
|
|
94
|
+
if (!isEncrypt) {
|
|
95
|
+
array[i] = fileBuffer[i];
|
|
96
|
+
} else {
|
|
97
|
+
array[i] = fileBuffer[i] ^ g_offset[i % 10];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return array;
|
|
101
|
+
} catch (e) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// 数字数组转为arraybuffer
|
|
106
|
+
static arrayToBuffer(numberArray: number[], type: string) {
|
|
107
|
+
const typeMap = {
|
|
108
|
+
uint8: Uint8Array,
|
|
109
|
+
int8: Int8Array,
|
|
110
|
+
uint16: Uint16Array,
|
|
111
|
+
int16: Int16Array,
|
|
112
|
+
uint32: Uint32Array,
|
|
113
|
+
int32: Int32Array,
|
|
114
|
+
float32: Float32Array,
|
|
115
|
+
float64: Float64Array,
|
|
116
|
+
};
|
|
117
|
+
const TypedArrayConstructor = typeMap[type];
|
|
118
|
+
if (!TypedArrayConstructor) {
|
|
119
|
+
throw new Error('Unsupported type');
|
|
120
|
+
}
|
|
121
|
+
const typedArray = new TypedArrayConstructor(numberArray);
|
|
122
|
+
return typedArray.buffer;
|
|
123
|
+
}
|
|
124
|
+
// arraybuffer转为数字数组
|
|
125
|
+
static bufferToArray(buffer: ArrayBuffer, type: string) {
|
|
126
|
+
const typeMap = {
|
|
127
|
+
uint8: Uint8Array,
|
|
128
|
+
int8: Int8Array,
|
|
129
|
+
uint16: Uint16Array,
|
|
130
|
+
int16: Int16Array,
|
|
131
|
+
uint32: Uint32Array,
|
|
132
|
+
int32: Int32Array,
|
|
133
|
+
float32: Float32Array,
|
|
134
|
+
float64: Float64Array,
|
|
135
|
+
};
|
|
136
|
+
const TypedArrayConstructor = typeMap[type];
|
|
137
|
+
if (!TypedArrayConstructor) {
|
|
138
|
+
throw new Error('Unsupported type');
|
|
139
|
+
}
|
|
140
|
+
const typedArray = new TypedArrayConstructor(buffer);
|
|
141
|
+
return Array.from(typedArray);
|
|
142
|
+
}
|
|
143
|
+
// 删除文件
|
|
144
|
+
static deleteFile(filePath: string) {
|
|
145
|
+
try {
|
|
146
|
+
fs.unlinkSync(filePath);
|
|
147
|
+
return true;
|
|
148
|
+
} catch (e) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// 设置指定文件的属性
|
|
153
|
+
public static setFileAttribute(filePath: string, config: FileAttribute) {
|
|
154
|
+
try {
|
|
155
|
+
// winattr.setSync(filePath, config);
|
|
156
|
+
console.log(`设置文件属性成功${filePath}`);
|
|
157
|
+
} catch (err) {
|
|
158
|
+
console.error('设置文件属性失败:', err);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
static test() {
|
|
162
|
+
console.log('test');
|
|
163
|
+
this.writeArrayToFile('./test.sys', [1, 2, 3]);
|
|
164
|
+
const a = HFile.readFile('C:\\Users\\Administrator\\Pictures\\CfDll.dll');
|
|
165
|
+
console.log(a);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// HFile.test();
|
|
169
|
+
export default HFile;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import os from "os";
|
|
3
|
+
import { exec } from "child_process";
|
|
4
|
+
import HFile from "../utils/HFile.ts";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
|
|
8
|
+
class HPath {
|
|
9
|
+
// 获取下载目录
|
|
10
|
+
public static getDownloadPath() {
|
|
11
|
+
return path.join(os.homedir(), "Downloads");
|
|
12
|
+
}
|
|
13
|
+
// 桌面路径
|
|
14
|
+
public static getDesktopPath() {
|
|
15
|
+
return path.join(os.homedir(), "Desktop");
|
|
16
|
+
}
|
|
17
|
+
// 获取临时目录
|
|
18
|
+
public static getTempPath() {
|
|
19
|
+
return os.tmpdir();
|
|
20
|
+
}
|
|
21
|
+
// 打开指定目录
|
|
22
|
+
public static openDir(dirPath: string): boolean {
|
|
23
|
+
const isSuccess = HFile.isFileExist(dirPath);
|
|
24
|
+
if (!isSuccess) return false;
|
|
25
|
+
// 解析为绝对路径
|
|
26
|
+
const absolutePath = path.resolve(dirPath);
|
|
27
|
+
let command;
|
|
28
|
+
switch (process.platform) {
|
|
29
|
+
case "darwin": // macOS
|
|
30
|
+
command = `open "${absolutePath}"`;
|
|
31
|
+
break;
|
|
32
|
+
case "win32": // Windows
|
|
33
|
+
command = `explorer "${absolutePath.replace(/\//g, "\\")}"`;
|
|
34
|
+
break;
|
|
35
|
+
case "linux": // Linux
|
|
36
|
+
command = `xdg-open "${absolutePath}"`;
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
throw new Error(`Unsupported platform: ${process.platform}`);
|
|
40
|
+
}
|
|
41
|
+
exec(command);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
// 根据环境获取electron不同的public路径
|
|
45
|
+
public static getPublicPath() {
|
|
46
|
+
if (process.env.NODE_ENV !== "development") {
|
|
47
|
+
return path.join(process.resourcesPath, "app.asar.unpacked", "public");
|
|
48
|
+
} else {
|
|
49
|
+
return path.join(path.resolve(), "\\public");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// 获取当前目录的
|
|
53
|
+
public static getDllPath(fileUrl: string) {
|
|
54
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
55
|
+
if (isDev) {
|
|
56
|
+
return path.dirname(fileURLToPath(fileUrl));
|
|
57
|
+
} else {
|
|
58
|
+
return __dirname;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// 获取resourcesPath
|
|
62
|
+
public static getResourcesPath() {
|
|
63
|
+
if (process.env.NODE_ENV === "production") {
|
|
64
|
+
return __dirname;
|
|
65
|
+
} else {
|
|
66
|
+
return path.resolve();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// 获取require方法
|
|
70
|
+
public static getRequire(url: string) {
|
|
71
|
+
if (process.env.NODE_ENV === "production") {
|
|
72
|
+
return require;
|
|
73
|
+
} else {
|
|
74
|
+
return createRequire(url);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
process.resourcesPath = HPath.getResourcesPath();
|
|
80
|
+
export default HPath;
|
package/test/views/H.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import HPath from "../utils/HPath";
|
|
2
|
+
const require = HPath.getRequire(import.meta.url);
|
|
3
|
+
import type { ICommonTools } from "../types/commonTools";
|
|
4
|
+
|
|
5
|
+
const commonTools: ICommonTools = require("../../cmake-build-release/commonToolsNode.node");
|
|
6
|
+
const H = commonTools.H;
|
|
7
|
+
|
|
8
|
+
function toHex(value: number | bigint): string {
|
|
9
|
+
return "0x" + value.toString(16);
|
|
10
|
+
}
|
|
11
|
+
function test() {
|
|
12
|
+
console.log("H.test");
|
|
13
|
+
const pid = H.getPidByName("chrome.exe");
|
|
14
|
+
const hand = H.getHandByPid(pid);
|
|
15
|
+
console.log("getPidByName = " + pid);
|
|
16
|
+
console.log("getHandByPid = " + hand);
|
|
17
|
+
console.log("getPidByHand = " + H.getPidByHand(hand));
|
|
18
|
+
console.log("getWindowRect = " + H.getWindowRect(hand));
|
|
19
|
+
console.log("findWindow = " + H.findWindow("Chrome_WidgetWin_1"));
|
|
20
|
+
console.log("findWindowSS = " + H.findWindowSS("Chrome_WidgetWin"));
|
|
21
|
+
console.log("getCurrentPid = " + H.getCurrentPid());
|
|
22
|
+
|
|
23
|
+
let addr = H.allocMem(pid);
|
|
24
|
+
console.log("allocMem = " + toHex(addr));
|
|
25
|
+
H.freeMem(pid, addr);
|
|
26
|
+
console.log("freeMem");
|
|
27
|
+
// addr = H.allocMem(pid);
|
|
28
|
+
// H.setGlobalProcessId(pid);
|
|
29
|
+
// let isSuccess = H.setData(0x22c04760000, Buffer.from("12345678", "utf8"));
|
|
30
|
+
// let res = H.getData(0x22c04760000, 8);
|
|
31
|
+
console.log(res);
|
|
32
|
+
console.log("improvePower = " + H.improvePower());
|
|
33
|
+
console.log("getInfoByHand = " + JSON.stringify(H.getInfoByHand(hand)));
|
|
34
|
+
console.log("is64BitProcess = " + H.is64BitProcess(pid));
|
|
35
|
+
console.log("getRunPath = " + H.getRunPath());
|
|
36
|
+
let isSuccess = H.createFileByBinary(
|
|
37
|
+
"test.txt",
|
|
38
|
+
"C:\\",
|
|
39
|
+
Buffer.from("12345678", "utf8"),
|
|
40
|
+
8,
|
|
41
|
+
false,
|
|
42
|
+
);
|
|
43
|
+
console.log("genUuid = " + H.genUuid());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default H;
|
|
47
|
+
|
|
48
|
+
if (import.meta.main) {
|
|
49
|
+
test();
|
|
50
|
+
}
|
package/test/views/HD.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import HPath from "../utils/HPath";
|
|
2
|
+
const require = HPath.getRequire(import.meta.url);
|
|
3
|
+
import type { ICommonTools } from "../types/commonTools";
|
|
4
|
+
import { IHD } from "../types/HD.js";
|
|
5
|
+
|
|
6
|
+
const commonTools: ICommonTools = require("../../cmake-build-release/commonToolsNode.node");
|
|
7
|
+
const HD = commonTools.HD;
|
|
8
|
+
export default HD;
|
|
9
|
+
|
|
10
|
+
function test() {
|
|
11
|
+
console.log("HD-test");
|
|
12
|
+
const driver = new HD();
|
|
13
|
+
console.log("allocMemory" + driver.allocMemory());
|
|
14
|
+
}
|
|
15
|
+
if (import.meta.main) {
|
|
16
|
+
test();
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import HPath from "../utils/HPath";
|
|
2
|
+
const require = HPath.getRequire(import.meta.url);
|
|
3
|
+
import type { ICommonTools } from "../types/commonTools";
|
|
4
|
+
|
|
5
|
+
const commonTools: ICommonTools = require("../../cmake-build-release/commonToolsNode.node");
|
|
6
|
+
const HPath1 = commonTools.HPath;
|
|
7
|
+
export default HPath1;
|
|
8
|
+
|
|
9
|
+
function test() {
|
|
10
|
+
console.log("HPath.test");
|
|
11
|
+
console.log(HPath1.getCurrentPath());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (import.meta.main) {
|
|
15
|
+
test();
|
|
16
|
+
}
|
package/test/views/HR.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import HPath from "../utils/HPath";
|
|
2
|
+
const require = HPath.getRequire(import.meta.url);
|
|
3
|
+
import type { ICommonTools } from "../types/commonTools";
|
|
4
|
+
import { RegistryRootKey, RegistryValueType } from "../types/HR.js";
|
|
5
|
+
|
|
6
|
+
const commonTools: ICommonTools = require("../../cmake-build-release/commonToolsNode.node");
|
|
7
|
+
const HR = commonTools.HR;
|
|
8
|
+
export default HR;
|
|
9
|
+
|
|
10
|
+
function test() {
|
|
11
|
+
console.log("HR.test");
|
|
12
|
+
let res = HR.readRegistry(
|
|
13
|
+
RegistryRootKey.HKEY_LOCAL_MACHINE,
|
|
14
|
+
"SOFTWARE\\{2F767CD4-6DB3-459D-B730-9566FE11F4AF}_is1\\test1",
|
|
15
|
+
RegistryValueType.REG_SZ,
|
|
16
|
+
);
|
|
17
|
+
console.log("readRegistry = " + res);
|
|
18
|
+
|
|
19
|
+
const buffer = Buffer.alloc(4, 0x1111);
|
|
20
|
+
buffer.writeUint32LE(0x1111); // 写入无符号 32 位整数 (小端序)
|
|
21
|
+
res = HR.writeRegistry(
|
|
22
|
+
RegistryRootKey.HKEY_LOCAL_MACHINE,
|
|
23
|
+
"SOFTWARE\\{2F767CD4-6DB3-459D-B730-9566FE11F4AF}_is1\\test2",
|
|
24
|
+
buffer,
|
|
25
|
+
RegistryValueType.REG_DWORD,
|
|
26
|
+
);
|
|
27
|
+
console.log("writeRegistry = " + res);
|
|
28
|
+
|
|
29
|
+
res = HR.deleteRegValue(
|
|
30
|
+
RegistryRootKey.HKEY_LOCAL_MACHINE,
|
|
31
|
+
"SOFTWARE\\{2F767CD4-6DB3-459D-B730-9566FE11F4AF}_is1\\test2",
|
|
32
|
+
);
|
|
33
|
+
console.log("deleteRegistry = " + res);
|
|
34
|
+
res = HR.deleteRegKey(
|
|
35
|
+
RegistryRootKey.HKEY_LOCAL_MACHINE,
|
|
36
|
+
"SOFTWARE\\{2F767CD4-6DB3-459D-B730-9566FE11F4AF}_is1\\k1",
|
|
37
|
+
);
|
|
38
|
+
console.log("deleteRegKey = " + res);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (import.meta.main) {
|
|
42
|
+
test();
|
|
43
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"types": ["node"], // ȷ������ Node
|
|
4
|
+
/* Base Options: */
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"target": "es2022",
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"moduleDetection": "force",
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"declaration": true, // ? ���� .d.ts �����ļ�
|
|
13
|
+
/* Strictness */
|
|
14
|
+
"strict": true,
|
|
15
|
+
"noUncheckedIndexedAccess": true,
|
|
16
|
+
/* If transpiling with TypeScript: */
|
|
17
|
+
"moduleResolution": "NodeNext",
|
|
18
|
+
"module": "NodeNext",
|
|
19
|
+
"outDir": "dist",
|
|
20
|
+
"sourceMap": true,
|
|
21
|
+
/* If your code doesn't run in the DOM: */
|
|
22
|
+
"lib": ["es2022","DOM"],
|
|
23
|
+
/* Custom */
|
|
24
|
+
"noUnusedLocals": true,
|
|
25
|
+
"useUnknownInCatchVariables": true,
|
|
26
|
+
"forceConsistentCasingInFileNames": true,
|
|
27
|
+
"strictNullChecks": true,
|
|
28
|
+
"noImplicitAny": true,
|
|
29
|
+
"noUnusedParameters": true,
|
|
30
|
+
"rootDir": "./test"
|
|
31
|
+
},
|
|
32
|
+
"include": ["test/**/*.ts","test/**/*.node","test/**/*.d.ts"],
|
|
33
|
+
"exclude": ["node_modules"]
|
|
34
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="JAVA_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$" />
|
|
6
|
-
<orderEntry type="inheritedJdk" />
|
|
7
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
-
</component>
|
|
9
|
-
</module>
|
package/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
console.log('hello')
|
|
2
|
-
console.log('hello')
|
|
3
|
-
console.log('hello')
|
|
4
|
-
console.log('hello')
|
|
5
|
-
console.log('hello')
|
|
6
|
-
console.log('hello')
|
|
7
|
-
console.log('hello')
|
|
8
|
-
console.log('hello')
|
|
9
|
-
console.log('hello')
|
|
10
|
-
console.log('hello')
|
|
11
|
-
console.log('hello')
|
|
12
|
-
console.log('hello')
|
|
13
|
-
console.log('hello')
|
|
14
|
-
console.log('hello')
|
|
15
|
-
console.log('hello')
|
|
16
|
-
console.log('hello')
|