OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/win/win_util.h" | 5 #include "base/win/win_util.h" |
6 | 6 |
7 #include <aclapi.h> | 7 #include <aclapi.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #include <shobjidl.h> // Must be before propkey. | 10 #include <shobjidl.h> // Must be before propkey. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 | 77 |
78 bool GetUserSidString(std::wstring* user_sid) { | 78 bool GetUserSidString(std::wstring* user_sid) { |
79 // Get the current token. | 79 // Get the current token. |
80 HANDLE token = NULL; | 80 HANDLE token = NULL; |
81 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)) | 81 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)) |
82 return false; | 82 return false; |
83 base::win::ScopedHandle token_scoped(token); | 83 base::win::ScopedHandle token_scoped(token); |
84 | 84 |
85 DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE; | 85 DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE; |
86 scoped_array<BYTE> user_bytes(new BYTE[size]); | 86 scoped_ptr<BYTE[]> user_bytes(new BYTE[size]); |
87 TOKEN_USER* user = reinterpret_cast<TOKEN_USER*>(user_bytes.get()); | 87 TOKEN_USER* user = reinterpret_cast<TOKEN_USER*>(user_bytes.get()); |
88 | 88 |
89 if (!::GetTokenInformation(token, TokenUser, user, size, &size)) | 89 if (!::GetTokenInformation(token, TokenUser, user, size, &size)) |
90 return false; | 90 return false; |
91 | 91 |
92 if (!user->User.Sid) | 92 if (!user->User.Sid) |
93 return false; | 93 return false; |
94 | 94 |
95 // Convert the data to a string. | 95 // Convert the data to a string. |
96 wchar_t* sid_string; | 96 wchar_t* sid_string; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 #ifndef COPY_FILE_COPY_SYMLINK | 343 #ifndef COPY_FILE_COPY_SYMLINK |
344 #error You must install the Windows 2008 or Vista Software Development Kit and \ | 344 #error You must install the Windows 2008 or Vista Software Development Kit and \ |
345 set it as your default include path to build this library. You can grab it by \ | 345 set it as your default include path to build this library. You can grab it by \ |
346 searching for "download windows sdk 2008" in your favorite web search engine. \ | 346 searching for "download windows sdk 2008" in your favorite web search engine. \ |
347 Also make sure you register the SDK with Visual Studio, by selecting \ | 347 Also make sure you register the SDK with Visual Studio, by selecting \ |
348 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ | 348 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ |
349 menu (see Start - All Programs - Microsoft Windows SDK - \ | 349 menu (see Start - All Programs - Microsoft Windows SDK - \ |
350 Visual Studio Registration). | 350 Visual Studio Registration). |
351 #endif | 351 #endif |
OLD | NEW |