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 <windows.h> | 5 #include <windows.h> |
6 #include <Sddl.h> // For ConvertSidToStringSidW. | 6 #include <Sddl.h> // For ConvertSidToStringSidW. |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 NULL, 0)) | 34 NULL, 0)) |
35 return false; | 35 return false; |
36 | 36 |
37 *number = number_local; | 37 *number = number_local; |
38 return true; | 38 return true; |
39 } | 39 } |
40 | 40 |
41 bool GetComputerSid(const wchar_t* account_name, SID* sid, DWORD sid_size) { | 41 bool GetComputerSid(const wchar_t* account_name, SID* sid, DWORD sid_size) { |
42 static const DWORD kStartDomainLength = 128; // reasonable to start with | 42 static const DWORD kStartDomainLength = 128; // reasonable to start with |
43 | 43 |
44 scoped_array<wchar_t> domain_buffer(new wchar_t[kStartDomainLength]); | 44 scoped_ptr<wchar_t[]> domain_buffer(new wchar_t[kStartDomainLength]); |
45 DWORD domain_size = kStartDomainLength; | 45 DWORD domain_size = kStartDomainLength; |
46 DWORD sid_dword_size = sid_size; | 46 DWORD sid_dword_size = sid_size; |
47 SID_NAME_USE sid_name_use; | 47 SID_NAME_USE sid_name_use; |
48 | 48 |
49 BOOL success = ::LookupAccountNameW(NULL, account_name, sid, | 49 BOOL success = ::LookupAccountNameW(NULL, account_name, sid, |
50 &sid_dword_size, domain_buffer.get(), | 50 &sid_dword_size, domain_buffer.get(), |
51 &domain_size, &sid_name_use); | 51 &domain_size, &sid_name_use); |
52 if (!success && ::GetLastError() == ERROR_INSUFFICIENT_BUFFER) { | 52 if (!success && ::GetLastError() == ERROR_INSUFFICIENT_BUFFER) { |
53 // We could have gotten the insufficient buffer error because | 53 // We could have gotten the insufficient buffer error because |
54 // one or both of sid and szDomain was too small. Check for that | 54 // one or both of sid and szDomain was too small. Check for that |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 *volume_id = 0; | 121 *volume_id = 0; |
122 if (!GetSystemVolumeSerialNumber(volume_id)) { | 122 if (!GetSystemVolumeSerialNumber(volume_id)) { |
123 ASSERT_STRING("GetMachineId: Failed to retrieve volume serial number"); | 123 ASSERT_STRING("GetMachineId: Failed to retrieve volume serial number"); |
124 *volume_id = 0; | 124 *volume_id = 0; |
125 } | 125 } |
126 | 126 |
127 return true; | 127 return true; |
128 } | 128 } |
129 | 129 |
130 } // namespace rlz_lib | 130 } // namespace rlz_lib |
OLD | NEW |