Author Topic: Lock workstation detection and UAC  (Read 3565 times)

0 Members and 1 Guest are viewing this topic.

Offline MVV

  • Newbie
  • *
  • Posts: 3
Lock workstation detection and UAC
« on: 14 08 2014, 09:13:41 »
It seems that IsWorkstationLocked function (src\mir_core\winver.cpp) wasn't updated a while ago because it reports lock when UAC confirmations pop up. As a consequence, it causes false lock detects e.g. in AdvancedAutoAway plugin which changes status on every UAC confirmation.

AFAIK Windows switches to safe desktop when UAC confirmation pops up, so it causes false detect with current IsWorkstationLocked implementation:
Code: [Select]
MIR_CORE_DLL(BOOL) IsWorkstationLocked(void)
if (hDesk == NULL)
return true;

TCHAR tszName[100];
DWORD cbName;
BOOL bLocked = (!GetUserObjectInformation(hDesk, UOI_NAME, tszName, SIZEOF(tszName), &cbName) || lstrcmpi(tszName,_T("default")) != 0);
return bLocked;
« Last Edit: 14 08 2014, 09:16:11 by MVV »

Offline Wishmaster

Re: Lock workstation detection and UAC
« Reply #1 on: 14 08 2014, 09:31:33 »
Could you provide a patch for it? :)

Offline MVV

  • Newbie
  • *
  • Posts: 3
Re: Lock workstation detection and UAC
« Reply #2 on: 18 08 2014, 12:04:51 »
I can't say about exact patch but here is a working solution (found here and tested by myself). Unfortunately it is not the call-to-get-answer one, it requires a window message processing.

We need to register main Miranda window for WM_WTSSESSION_CHANGE notifications using WTSRegisterSessionNotification function. Then we need to set a lock flag when OS reports that workstation is locked/unlocked. All notifications that are sent with this message are listed here. We are interested in two ones: wParam==WTS_SESSION_LOCK and wParam==WTS_SESSION_UNLOCK. So, fixed IsWorkstationLocked should simply return this flag state (it may simply be a static variable in winver.cpp source file).

I tried some things with OpenInputDesktop function but it returns ERROR_ACCESS_DENIED on both lock and UAC prompt.
« Last Edit: 18 08 2014, 12:09:29 by MVV »