Fixed blame crash at XP system
[TortoiseGit.git] / src / TGitCache / CacheInterface.cpp
blobd212ea91659dac7767a85be4290e8c01c1717cab
1 // TortoiseGit - a Windows shell extension for easy version control
3 // External Cache Copyright (C) 2007 - TortoiseSVN
4 // Copyright (C) 2008-2011 - TortoiseGit
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "CacheInterface.h"
23 CString GetCachePipeName()
25 return TSVN_CACHE_PIPE_NAME + GetCacheID();
28 CString GetCacheCommandPipeName()
30 return TSVN_CACHE_COMMANDPIPE_NAME + GetCacheID();
33 CString GetCacheMutexName()
35 return TSVN_CACHE_MUTEX_NAME + GetCacheID();
37 CString GetCacheID()
39 HANDLE token;
40 DWORD len;
41 BOOL result = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
42 if(result)
44 GetTokenInformation(token, TokenStatistics, NULL, 0, &len);
45 LPBYTE data = new BYTE[len];
46 GetTokenInformation(token, TokenStatistics, data, len, &len);
47 LUID uid = ((PTOKEN_STATISTICS)data)->AuthenticationId;
48 delete [ ] data;
49 CString t;
50 t.Format(_T("-%08x%08x"), uid.HighPart, uid.LowPart);
51 CloseHandle(token);
52 return t;
54 return _T("");