Skip to content

Instantly share code, notes, and snippets.

@1ocalhost
Created September 27, 2018 18:32
Show Gist options
  • Save 1ocalhost/10a119f7a523e6f1fd03dc97c18b86cf to your computer and use it in GitHub Desktop.
Save 1ocalhost/10a119f7a523e6f1fd03dc97c18b86cf to your computer and use it in GitHub Desktop.
#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