Keep PLAP dialog alive by simulating user activity

Add a timer to periodically simulate mouse movement
using SendInput, preventing the pre-logon UI from being
dismissed due to inactivity during mobile QR code authentication.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
pull/744/head
Lev Stipakov 2025-04-21 12:00:25 +03:00
parent 3e4adfa49e
commit 4ff7980cfb
1 changed files with 19 additions and 0 deletions

19
qr.c
View File

@ -97,6 +97,8 @@ INT_PTR CALLBACK
QrDialogProc(HWND hwnd, UINT msg, UNUSED WPARAM wp, LPARAM lp)
{
static HBITMAP hQRBitmap = NULL;
static UINT_PTR timerId = 1;
static UINT timerElapse = 20000; /* must be less than 30 sec pre-logon timeout */
switch (msg)
{
@ -172,6 +174,8 @@ QrDialogProc(HWND hwnd, UINT msg, UNUSED WPARAM wp, LPARAM lp)
SetWindowText(hwnd, uc->config_name);
g_hwndQR = hwnd;
SetTimer(hwnd, timerId, timerElapse, NULL);
}
return TRUE;
@ -179,10 +183,25 @@ QrDialogProc(HWND hwnd, UINT msg, UNUSED WPARAM wp, LPARAM lp)
EndDialog(hwnd, 0);
return TRUE;
case WM_TIMER:
if (wp == timerId)
{
/* Simulate mouse movement to keep Winlogon from dismissing the PLAP dialog */
INPUT input = { 0 };
input.type = INPUT_MOUSE;
input.mi.dwFlags = MOUSEEVENTF_MOVE;
input.mi.dx = 0;
input.mi.dy = 0;
SendInput(1, &input, sizeof(INPUT));
}
return TRUE;
case WM_DESTROY:
if (hQRBitmap)
DeleteObject(hQRBitmap);
g_hwndQR = NULL;
KillTimer(hwnd, timerId);
return TRUE;
}
return FALSE;