瞎折腾的
当写笔记
装上windows-build-tools 和 node-gyp
管理员运行powershell
yarn config set registry https://registry.npm.taobao.org/
yarn config set ELECTRON_MIRROR https://npm.taobao.org/mirrors/electron/
yarn global add windows-build-tools
yarn global add node-gyp
初始化项目
使用ffi的分支,不然node12过不了编译 electron 版本在这里找
https://npm.taobao.org/mirrors/atom-shell/
yarn init
yarn add electron@5.0.9 --dev
yarn add github:lxe/node-ffi#node-12 --dev
yarn add github:lxe/ref#node-12 --dev
yarn add github:lxe/ref-array#node-12 --dev
编译ffi和ref
–target=5.0.9 是electron的版本
–arch=ia32 32位node
ffi 和 ref 都CD 进去编译一下
cd .\node_modules\ffi\
node-gyp rebuild --runtime=electron --target=5.0.9 --arch=ia32 --dist-url=https://npm.taobao.org/mirrors/atom-shell/
cd ..\ref\
node-gyp rebuild --runtime=electron --target=5.0.9 --arch=ia32 --dist-url=https://npm.taobao.org/mirrors/atom-shell/
DLL注入代码
/**
* node -v v12.16.1
* "electron": "5.0.9",
* "ffi": "github:lxe/node-ffi#node-12",
* "ref": "github:lxe/ref#node-12",
* "ref-array": "github:lxe/ref-array#node-12"
*
*/
const ffi = require('ffi')
const ref = require('ref');
const refArray = require('ref-array');
const refStruct = require('ref-struct');
const customTypes = {
// 进程快照数据类型
PROCESSENTRY32: refStruct({
dwSize: 'int',
cntUsage: 'int',
th32ProcessID: 'int',
th32DefaultHeapID: 'int',
th32ModuleID: 'int',
cntThreads: 'int',
th32ParentProcessID: 'int',
pcPriClassBase: 'int',
dwFlags: 'int',
szExeFile: refArray(ref.types.char, 260),
}),
// 模块快照数据类型
MODULEENTRY32: refStruct({
dwSize: 'int',
th32ModuleID: 'int',
th32ProcessID: 'int',
GlblcntUsage: 'int',
ProccntUsage: 'int',
modBaseAddr: 'int',
modBaseSize: 'int',
hModule: 'int',
szModule: refArray(ref.types.char, 256),
szExePath: refArray(ref.types.char, 256),
}),
// 没用上
lpctstr: {
name: 'lpctstr',
indirection: 1,
size: ref.sizeof.pointer,
get: function (buffer, offset