Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome_elf/nt_registry/nt_registry.h" | 5 #include "chrome_elf/nt_registry/nt_registry.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 768 | 768 |
| 769 KEY_VALUE_FULL_INFORMATION* value_info = | 769 KEY_VALUE_FULL_INFORMATION* value_info = |
| 770 reinterpret_cast<KEY_VALUE_FULL_INFORMATION*>(new BYTE[size_needed]); | 770 reinterpret_cast<KEY_VALUE_FULL_INFORMATION*>(new BYTE[size_needed]); |
| 771 | 771 |
| 772 // Second call to get the value. | 772 // Second call to get the value. |
| 773 ntstatus = g_nt_query_value_key(key, &value_uni, KeyValueFullInformation, | 773 ntstatus = g_nt_query_value_key(key, &value_uni, KeyValueFullInformation, |
| 774 value_info, size_needed, &size_needed); | 774 value_info, size_needed, &size_needed); |
| 775 if (NT_SUCCESS(ntstatus)) { | 775 if (NT_SUCCESS(ntstatus)) { |
| 776 *out_type = value_info->Type; | 776 *out_type = value_info->Type; |
| 777 *out_size = value_info->DataLength; | 777 *out_size = value_info->DataLength; |
| 778 *out_buffer = new BYTE[*out_size]; | 778 *out_buffer = nullptr; |
| 779 ::memcpy(*out_buffer, | 779 if (*out_size) { |
| 780 (reinterpret_cast<BYTE*>(value_info) + value_info->DataOffset), | 780 *out_buffer = new BYTE[*out_size]; |
|
robertshield
2017/05/17 16:59:59
totally optional, as this looks right to me, but f
penny
2017/07/19 22:25:15
Done. For the query function, a vector of bytes i
| |
| 781 *out_size); | 781 ::memcpy(*out_buffer, |
| 782 (reinterpret_cast<BYTE*>(value_info) + value_info->DataOffset), | |
| 783 *out_size); | |
| 784 if (*out_type == REG_SZ || *out_type == REG_MULTI_SZ) | |
|
robertshield
2017/05/17 16:59:59
how about REG_EXPAND_SZ?
penny
2017/07/19 22:25:15
Done. Thanks for noting this Robert. Mine as well
| |
| 785 (*out_buffer)[(*out_size) - 1] = 0; | |
| 786 } | |
| 782 success = true; | 787 success = true; |
| 783 } | 788 } |
| 784 | 789 |
| 785 delete[] value_info; | 790 delete[] value_info; |
| 786 return success; | 791 return success; |
| 787 } | 792 } |
| 788 | 793 |
| 789 // wrapper function | 794 // wrapper function |
| 790 bool QueryRegValueDWORD(HANDLE key, | 795 bool QueryRegValueDWORD(HANDLE key, |
| 791 const wchar_t* value_name, | 796 const wchar_t* value_name, |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1089 if (!g_initialized) | 1094 if (!g_initialized) |
| 1090 InitNativeRegApi(); | 1095 InitNativeRegApi(); |
| 1091 | 1096 |
| 1092 if (root == HKCU || (root == AUTO && !g_system_install)) | 1097 if (root == HKCU || (root == AUTO && !g_system_install)) |
| 1093 return g_HKCU_override; | 1098 return g_HKCU_override; |
| 1094 | 1099 |
| 1095 return g_HKLM_override; | 1100 return g_HKLM_override; |
| 1096 } | 1101 } |
| 1097 | 1102 |
| 1098 }; // namespace nt | 1103 }; // namespace nt |
| OLD | NEW |