Browse Source

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

creating a new BDB on every API call.

JackTools::GetUID() would return the PID of the calling process.
(I think this was a stub because there is no Windows equivalent).
The linux version appears to return a linux UID. This patch does
something similar on Windows so as to create/open the same DB
on Windows.
pull/991/head
Matthew Smith 6 months ago
parent
commit
b8d5799d01
1 changed files with 13 additions and 2 deletions
  1. +13
    -2
      common/JackTools.cpp

+ 13
- 2
common/JackTools.cpp View File

@@ -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


Loading…
Cancel
Save