5
i think microsoft windows security is kind of a joke honestly
cohost.orgyou are just idly browsing the documentation when you find this article [https://learn.microsoft.com/en-us/windows/win32/dxtecharts/disabling-shortcut-keys-in-games]:
> DISABLING SHORTCUT KEYS IN GAMES
>
> This articles describes how to temporarily disable keyboard shortcuts in Microsoft Windows to prevent disruption of game play for full screen games.
sure, that sounds reasonable! if you accidentally press the Windows key while playing a video game, it sucks when it suddenly opens the app launcher and unfocuses the game window.
let’s see how to do it
> DISABLE THE WINDOWS KEY WITH A KEYBOARD HOOK
>
> Use a low-level keyboard hook to filter out the Windows key from being processed.
sure, i guess it makes sense that the Windows key might be a more low-level event, since applications don’t usually handle it.
> The low-level keyboard hook shown in Example 1 remains in effect even if a user minimizes the window or switches to another application.
wait, huh? wait. what’s it say in example 1
g_hKeyboardHook = SetWindowsHookEx(
WH_KEYBOARD_LL,
LowLevelKeyboardProc,
GetModuleHandle(nullptr),
0
);
ok…it sets up a “keyboard hook” using a function “LowLevelKeyboardProc”…
LRESULT CALLBACK LowLevelKeyboardProc(
int nCode,
WPARAM wParam,
LPARAM lParam
) {
// -- cut --
bool bEatKeystroke = false;
switch (wParam) {
case WM_KEYDOWN:
case WM_KEYUP:
{
↓↓ what ↓↓
bEatKeystroke = (g_bFullscreen && g_bWindowActive && ((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)));
// Note that this will not block the Xbox Game Bar hotkeys (Win+G, Win+Alt+R, etc.)
break;
}
}
if (bEatKeystroke)
return 1;
else
return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam);
}
hold up. this function is looking at every keystroke on the system. and then in here… there’s a condition that it should only block the windows key… if the window is full-screen, and it’s the currently active window.
s…so.wh…what’s there to stop me from…not having that condition? and blocking every keystroke across the entire system? what’s there to stop me from logging every keystroke even while my application is in the background?
good news! nothing at all. i just tried it. you can use this code to very easily make a keylogger or keyboard disabler for your local windows machine. yes, it logs password fields, of course. and, conveniently, windows applications don’t need to create a visible window! they can just hang out in the background as a little row in the tasque manager.
whwhwhfhg
ghjhj
fwwh
w
why can a userland application with no special privileges just,simply, very easily, intercept every keystroke sent on the system ?? ??? why .w
why is this the recommended method for disabling the windows key in a video game
i’m not implementing this. this is just absolutely baffling
----------------------------------------
edit addendum: here’s what happens when you try to do something like this on mac os Keystroke Receiving: “iTerm” would like to receive keystrokes from any application. Grant access to this application in Privacy & Security settings, located in System Settings [https://staging.cohostcdn.org/attachment/ae864c1d-934e-4306-beb5-1e7963fbca59/a.png] windows has uac prompts…it could do this…
[ comments | sourced from HackerNews ]
You must log in or register to comment.