| 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/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 int sub_auth_count = *::GetSidSubAuthorityCount(sid); | 96 int sub_auth_count = *::GetSidSubAuthorityCount(sid); |
| 97 for(int i = 0; i < sub_auth_count; ++i) | 97 for(int i = 0; i < sub_auth_count; ++i) |
| 98 base::StringAppendF(&sid_string, L"-%lu", *::GetSidSubAuthority(sid, i)); | 98 base::StringAppendF(&sid_string, L"-%lu", *::GetSidSubAuthority(sid, i)); |
| 99 #endif | 99 #endif |
| 100 | 100 |
| 101 return sid_string; | 101 return sid_string; |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace | 104 } // namespace |
| 105 | 105 |
| 106 bool GetRawMachineId(string16* sid_string, int* volume_id) { | 106 bool GetRawMachineId(base::string16* sid_string, int* volume_id) { |
| 107 // Calculate the Windows SID. | 107 // Calculate the Windows SID. |
| 108 | 108 |
| 109 wchar_t computer_name[MAX_COMPUTERNAME_LENGTH + 1] = {0}; | 109 wchar_t computer_name[MAX_COMPUTERNAME_LENGTH + 1] = {0}; |
| 110 DWORD size = arraysize(computer_name); | 110 DWORD size = arraysize(computer_name); |
| 111 | 111 |
| 112 if (GetComputerNameW(computer_name, &size)) { | 112 if (GetComputerNameW(computer_name, &size)) { |
| 113 char sid_buffer[SECURITY_MAX_SID_SIZE]; | 113 char sid_buffer[SECURITY_MAX_SID_SIZE]; |
| 114 SID* sid = reinterpret_cast<SID*>(sid_buffer); | 114 SID* sid = reinterpret_cast<SID*>(sid_buffer); |
| 115 if (GetComputerSid(computer_name, sid, SECURITY_MAX_SID_SIZE)) { | 115 if (GetComputerSid(computer_name, sid, SECURITY_MAX_SID_SIZE)) { |
| 116 *sid_string = ConvertSidToString(sid); | 116 *sid_string = ConvertSidToString(sid); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Get the system drive volume serial number. | 120 // Get the system drive volume serial number. |
| 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 |