Created
September 27, 2018 18:32
-
-
Save 1ocalhost/10a119f7a523e6f1fd03dc97c18b86cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <ntsecapi.h> | |
#pragma comment(lib, "Secur32.lib") | |
bool didUserLogined() | |
{ | |
ULONG logonSessionCount = 0; | |
PLUID logonSessionList = NULL; | |
NTSTATUS status = LsaEnumerateLogonSessions( | |
&logonSessionCount, &logonSessionList); | |
//assert(!status); | |
for (ULONG i = 0; i < logonSessionCount; ++i) | |
{ | |
PSECURITY_LOGON_SESSION_DATA data = NULL; | |
status = LsaGetLogonSessionData(&logonSessionList[i], &data); | |
ULONG session = data->Session; | |
LsaFreeReturnBuffer(data); | |
//assert(!status); | |
if (!status && !session) | |
return true; | |
} | |
LsaFreeReturnBuffer(logonSessionList); | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment