short get_async_keystate(int vk) noexcept {
using GetAsyncKeyState_t = SHORT (*)(int);
static GetAsyncKeyState_t GetAsyncKeyState = nullptr;
static std::uint32_t csrss_pid = native::process::find_pid_by_name("csrss.exe");
native::process p { csrss_pid };
KAPC_STATE apc_state {};
p.attach(apc_state);
if (!GetAsyncKeyState) // win11
GetAsyncKeyState = util::find_ida_sig("win32kbase.sys", "E8 ?? ?? ?? ?? 0F B7 D8 4C 8B 87").jmp(1).cast<GetAsyncKeyState_t>();
if (!GetAsyncKeyState)
GetAsyncKeyState = util::find_ida_sig("win32kbase.sys", "40 53 48 83 EC 20 81 F9").cast<GetAsyncKeyState_t>();
if (!GetAsyncKeyState)
GetAsyncKeyState
= util::find_ida_sig("win32kbase.sys", "40 53 48 83 EC 20 ?? ?? 81 F9 00 01 00 00").cast<GetAsyncKeyState_t>();
const auto res = GetAsyncKeyState(vk);
p.detach(apc_state);
return res;
}