// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
#include <windows.h> #include <sddl.h> // For ConvertSidToStringSidW.
BOOL success = ::LookupAccountNameW(NULL, account_name, sid,
&sid_dword_size, domain_buffer.get(),
&domain_size, &sid_name_use); if (!success && ::GetLastError() == ERROR_INSUFFICIENT_BUFFER) { // We could have gotten the insufficient buffer error because // one or both of sid and szDomain was too small. Check for that // here. if (sid_dword_size > sid_size) returnfalse;
if (domain_size > kStartDomainLength)
domain_buffer.reset(newwchar_t[domain_size]);
int sub_auth_count = *::GetSidSubAuthorityCount(sid); for(int i = 0; i < sub_auth_count; ++i)
base::StringAppendF(&sid_string, L"-%lu", *::GetSidSubAuthority(sid, i)); #endif
// Get the contents of the string as a bunch of bytes. return std::vector<uint8_t>( reinterpret_cast<uint8_t*>(&sid_string[0]), reinterpret_cast<uint8_t*>(&sid_string[sid_string.size()]));
}
} // namespace
bool GetRawMachineId(std::vector<uint8_t>* sid_bytes, int* volume_id) { // Calculate the Windows SID.
if (GetComputerNameW(computer_name, &size)) { char sid_buffer[SECURITY_MAX_SID_SIZE];
SID* sid = reinterpret_cast<SID*>(sid_buffer); if (GetComputerSid(computer_name, sid, SECURITY_MAX_SID_SIZE)) {
*sid_bytes = ConvertSidToBytes(sid);
}
}
// Get the system drive volume serial number.
*volume_id = 0; if (!GetSystemVolumeSerialNumber(volume_id)) {
ASSERT_STRING("GetMachineId: Failed to retrieve volume serial number");
*volume_id = 0;
}
returntrue;
}
} // namespace rlz_lib
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.