-
Notifications
You must be signed in to change notification settings - Fork 378
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're only closing the handle if |
||
return 0; | ||
} | ||
|
||
return(tokenStats.AuthenticationId.LowPart); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: |
||
#else | ||
return geteuid(); | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize
tokenStats
andreturnLength
:TOKEN_STATISTICS tokenStats{}; DWORD returnLength = sizeof tokenStats;