-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在 Electron 环境下 对一个 External 执行 restorePointer,程序直接闪退了 #58
Comments
不需要加wrapPointer |
const pointer = createPointer({
paramsType: [Point],
paramsValue: [point],
}); 这样吗? |
不需要加 ffiTypeTag: DataType.StackStruct, |
const point = {
x: 0,
y: 0,
}
const Point = {
x: DataType.I32,
y: DataType.I32,
}
const pointer = createPointer({
paramsType: [Point],
paramsValue: [point],
});
const pos = load({
library: "user32",
funcName: "GetCaretPos",
retType: DataType.Boolean,
paramsValue: pointer,
paramsType: [DataType.External]
}); 还是同样的问题 |
const Point = { |
给出完整代码 |
let timer;
const point = {
x: 0,
y: 0,
}
const Point = {
x: DataType.I64,
y: DataType.I64,
}
const pointer = createPointer({
paramsType: [Point],
paramsValue: [point],
});
const getForegroundWindow = async () => {
const hwnd = load(
{
library: 'user32',
funcName: 'GetForegroundWindow',
retType: DataType.I32,
paramsType: [],
paramsValue: []
}
)
return hwnd
}
const getCaretPos = async () => {
const pos = load({
library: "user32",
funcName: "GetCaretPos",
retType: DataType.Boolean,
paramsValue: wrapPointer(pointer),
paramsType: [DataType.External]
});
return pos;
}
const loop = () => {
open({
library: 'user32', // key
path: 'user32.dll' // path
})
if (timer) {
clearInterval(timer);
}
timer = setInterval(async () => {
const hwnd = await this.getForegroundWindow();
console.log('hwnd', hwnd);
if (hwnd) {
const isCatch = await this.getCaretPos();
const p = restorePointer({
paramsValue: pointer,
retType: [Point],
})
console.log(isCatch, point, p);
// console.log(p)
}
}, 2000);
}
loop() 这里 |
结果输出的坐标和原始值一样 |
看起来没什么问题,你应该根据GetCaretPos的返回值以及调用load方法时设置errno:true来自行debug |
|
|
getcarepos的返回值是int而不是boolean,你应该去查询这个函数的文档来根据errno信息debug |
谢谢,我会了 |
问题定位了吗 |
Current ffi-rs version
Current Node.js arch
x64 win32
Descibe your problem in detail
这行 restorePointer 会导致程序闪退(提示: [12828:0704/002445.028:ERROR:crashpad_client_win.cc(868)] not connected)
What's your expect result
期望得到 caret 的坐标,如果有的话
The reproduction repo address
The text was updated successfully, but these errors were encountered: