Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions common/JackTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,19 @@ namespace Jack {
int JackTools::GetUID()
{
#ifdef WIN32
return _getpid();
//#error "No getuid function available"
HANDLE tokenHandle = nullptr;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &tokenHandle)) {
return 0;
}

TOKEN_STATISTICS tokenStats;
DWORD returnLength;
if (!GetTokenInformation(tokenHandle, TokenStatistics, &tokenStats, sizeof(tokenStats), &returnLength)) {
CloseHandle(tokenHandle);
return 0;
}

return(tokenStats.AuthenticationId.LowPart);
#else
return geteuid();
#endif
Expand Down