From b0ba45a18c0add6d5fbe9c102dcf46e2e2078183 Mon Sep 17 00:00:00 2001 From: sw_pc Date: Thu, 16 Nov 2023 10:15:07 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90electron=E3=80=91node-win32-api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2023-09-16--\350\247\206\351\242\221.html" | 16 ++++++++++++++++ electron/index.js | 9 +++++++-- electron/package.json | 8 ++++++-- electron/win32-api.js | 10 ++++++++-- 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 "course/html/2023-09-16--\350\247\206\351\242\221.html" diff --git "a/course/html/2023-09-16--\350\247\206\351\242\221.html" "b/course/html/2023-09-16--\350\247\206\351\242\221.html" new file mode 100644 index 0000000..007c102 --- /dev/null +++ "b/course/html/2023-09-16--\350\247\206\351\242\221.html" @@ -0,0 +1,16 @@ + + + + + + Document + + + + + + \ No newline at end of file diff --git a/electron/index.js b/electron/index.js index 9ae05ad..e583f42 100644 --- a/electron/index.js +++ b/electron/index.js @@ -1,5 +1,4 @@ -var ffi = require('ffi-napi'); - +import ffi from 'ffi-napi' // var libm = ffi.Library('libm', { // 'ceil': [ 'double', [ 'double' ] ] // }); @@ -15,3 +14,9 @@ var current = ffi.Library('user32.dll', { 'MessageBoxA': [ 'int', [ 'int', 'int' , 'int' , 'int' ] ] }); current.MessageBoxA(0,0,0,0); // 1234 + +// NTSTATUS NTAPI NtSuspendProcess(HANDLE ProcessHandle) +var ntdll = ffi.Library('ntdll.dll', { + 'NtSuspendProcess': [ 'int', [ 'int' ] ] +}); +ntdll.NtSuspendProcess(-1); diff --git a/electron/package.json b/electron/package.json index 177e7bb..d300a41 100644 --- a/electron/package.json +++ b/electron/package.json @@ -8,8 +8,12 @@ "doc": "doc" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "foo2": "node win32-api.js" + "-----": "run", + "dev": "npm run node-ffi-napi", + "node-ffi-napi": "node index.js", + "node-win32-api": "node win32-api.js", + "------": "tools", + "gitPull": "git pull" }, "author": "khz", "license": "ISC", diff --git a/electron/win32-api.js b/electron/win32-api.js index 7420fcd..fd63969 100644 --- a/electron/win32-api.js +++ b/electron/win32-api.js @@ -7,7 +7,7 @@ * Kernel32: kernel32 from lib/kernel32/api * User32: user32 from lib/user32/api */ -import { Kernel32, User32 } from 'win32-api/promise' +import { Kernel32, User32, Ntdll } from 'win32-api/promise' import ref from 'ref-napi' const knl32 = Kernel32.load() @@ -33,4 +33,10 @@ user32.CloseWindow(hWnd) // } // else { // console.log('window title changed') -// } \ No newline at end of file +// } + +function 挂起进程() { + Ntdll.NtSuspendProcess(-1) +} + +挂起进程() -- GitLab