Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to JackTools::GetUID() on Windows that fixes metadata #991

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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