mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 08:38:20 +00:00
[host] windows: allow capture of login screen
WTSGetActiveConsoleSessionId will return a session even if it's not logged in, unlike our old GetInteractiveSessionID function. Launching looking glass on such a console session will allow the login screen to be captured. Note that WTSGetActiveConsoleSessionId() will return 0xFFFFFFFF if there are no sessions attached.
This commit is contained in:
parent
2738e822a4
commit
c5c43d99f3
@ -247,29 +247,6 @@ err_proc:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD GetInteractiveSessionID(void)
|
|
||||||
{
|
|
||||||
PWTS_SESSION_INFO pSessionInfo;
|
|
||||||
DWORD count;
|
|
||||||
DWORD ret = 0;
|
|
||||||
|
|
||||||
if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, &pSessionInfo,
|
|
||||||
&count))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for(DWORD i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
if (pSessionInfo[i].State == WTSActive)
|
|
||||||
{
|
|
||||||
ret = pSessionInfo[i].SessionId;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WTSFreeMemory(pSessionInfo);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launch(void)
|
void Launch(void)
|
||||||
{
|
{
|
||||||
if (service.process)
|
if (service.process)
|
||||||
@ -301,7 +278,7 @@ void Launch(void)
|
|||||||
if (!enablePriv(SE_TCB_NAME))
|
if (!enablePriv(SE_TCB_NAME))
|
||||||
goto fail_token;
|
goto fail_token;
|
||||||
|
|
||||||
targetSessionID = GetInteractiveSessionID();
|
targetSessionID = WTSGetActiveConsoleSessionId();
|
||||||
if (origSessionID != targetSessionID)
|
if (origSessionID != targetSessionID)
|
||||||
{
|
{
|
||||||
if (!SetTokenInformation(hToken, TokenSessionId,
|
if (!SetTokenInformation(hToken, TokenSessionId,
|
||||||
@ -669,7 +646,8 @@ VOID WINAPI SvcMain(DWORD dwArgc, LPTSTR *lpszArgv)
|
|||||||
{
|
{
|
||||||
ULONGLONG launchTime;
|
ULONGLONG launchTime;
|
||||||
|
|
||||||
if (GetInteractiveSessionID() != 0)
|
DWORD interactiveSession = WTSGetActiveConsoleSessionId();
|
||||||
|
if (interactiveSession != 0 && interactiveSession != 0xFFFFFFFF)
|
||||||
{
|
{
|
||||||
Launch();
|
Launch();
|
||||||
launchTime = GetTickCount64();
|
launchTime = GetTickCount64();
|
||||||
|
Loading…
Reference in New Issue
Block a user