Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Side by Side Diff: chrome_elf/nt_registry/nt_registry.h

Issue 2885243002: [NtRegistry] Ensure REG_SZ and REG_MULTI_SZ are null terminated. (Closed)
Patch Set: Code review fixes, part 1. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // This API is a usability layer for direct registry access via NTDLL. 5 // This API is a usability layer for direct registry access via NTDLL.
6 // It allows for "advapi32-free" registry access, which is especially 6 // It allows for "advapi32-free" registry access, which is especially
7 // useful for accessing registy from DllMain (holding loader lock), 7 // useful for accessing registy from DllMain (holding loader lock),
8 // or if a dependency on/linkage of ADVAPI32.dll is not desired. 8 // or if a dependency on/linkage of ADVAPI32.dll is not desired.
9 9
10 // The implementation of this API should only use ntdll and kernel32 system 10 // The implementation of this API should only use ntdll and kernel32 system
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // Close a registry key handle that was opened with CreateRegKey or OpenRegKey. 85 // Close a registry key handle that was opened with CreateRegKey or OpenRegKey.
86 void CloseRegKey(HANDLE key); 86 void CloseRegKey(HANDLE key);
87 87
88 //------------------------------------------------------------------------------ 88 //------------------------------------------------------------------------------
89 // Getter functions 89 // Getter functions
90 //------------------------------------------------------------------------------ 90 //------------------------------------------------------------------------------
91 91
92 // Main function to query a registry value. 92 // Main function to query a registry value.
93 // - Key handle should have been opened with CreateRegKey or OpenRegKey. 93 // - Key handle should have been opened with CreateRegKey or OpenRegKey.
94 // - Types defined in winnt.h. E.g.: REG_DWORD, REG_SZ. 94 // - Types defined in winnt.h. E.g.: REG_DWORD, REG_SZ.
95 // - Caller is responsible for calling "delete[] *out_buffer" (on success).
96 bool QueryRegKeyValue(HANDLE key, 95 bool QueryRegKeyValue(HANDLE key,
97 const wchar_t* value_name, 96 const wchar_t* value_name,
98 ULONG* out_type, 97 ULONG* out_type,
99 BYTE** out_buffer, 98 std::vector<BYTE>* out_buffer);
100 DWORD* out_size);
101 99
102 // Query DWORD value. 100 // Query DWORD value.
103 // - WRAPPER: Function works with DWORD data type. 101 // - WRAPPER: Function works with DWORD data type.
104 // - Key handle should have been opened with CreateRegKey or OpenRegKey. 102 // - Key handle should have been opened with CreateRegKey or OpenRegKey.
105 // - Handle will be left open. Caller must still call CloseRegKey when done. 103 // - Handle will be left open. Caller must still call CloseRegKey when done.
106 bool QueryRegValueDWORD(HANDLE key, 104 bool QueryRegValueDWORD(HANDLE key,
107 const wchar_t* value_name, 105 const wchar_t* value_name,
108 DWORD* out_dword); 106 DWORD* out_dword);
109 107
110 // Query DWORD value. 108 // Query DWORD value.
111 // - WRAPPER: Function opens and closes the target key for caller, and works 109 // - WRAPPER: Function opens and closes the target key for caller, and works
112 // with DWORD data type. 110 // with DWORD data type.
113 // - Use |wow64_override| to force redirection behaviour, or pass nt::NONE. 111 // - Use |wow64_override| to force redirection behaviour, or pass nt::NONE.
114 bool QueryRegValueDWORD(ROOT_KEY root, 112 bool QueryRegValueDWORD(ROOT_KEY root,
115 WOW64_OVERRIDE wow64_override, 113 WOW64_OVERRIDE wow64_override,
116 const wchar_t* key_path, 114 const wchar_t* key_path,
117 const wchar_t* value_name, 115 const wchar_t* value_name,
118 DWORD* out_dword); 116 DWORD* out_dword);
119 117
120 // Query SZ (string) value. 118 // Query SZ (string) value.
121 // - WRAPPER: Function works with SZ data type. 119 // - WRAPPER: Function works with SZ or EXPAND_SZ data type.
122 // - Key handle should have been opened with CreateRegKey or OpenRegKey. 120 // - Key handle should have been opened with CreateRegKey or OpenRegKey.
123 // - Handle will be left open. Caller must still call CloseRegKey when done. 121 // - Handle will be left open. Caller must still call CloseRegKey when done.
124 bool QueryRegValueSZ(HANDLE key, 122 bool QueryRegValueSZ(HANDLE key,
125 const wchar_t* value_name, 123 const wchar_t* value_name,
126 std::wstring* out_sz); 124 std::wstring* out_sz);
127 125
128 // Query SZ (string) value. 126 // Query SZ (string) value.
129 // - WRAPPER: Function opens and closes the target key for caller, and works 127 // - WRAPPER: Function opens and closes the target key for caller, and works
130 // with SZ data type. 128 // with SZ or EXPAND_SZ data type.
131 // - Use |wow64_override| to force redirection behaviour, or pass nt::NONE. 129 // - Use |wow64_override| to force redirection behaviour, or pass nt::NONE.
132 bool QueryRegValueSZ(ROOT_KEY root, 130 bool QueryRegValueSZ(ROOT_KEY root,
133 WOW64_OVERRIDE wow64_override, 131 WOW64_OVERRIDE wow64_override,
134 const wchar_t* key_path, 132 const wchar_t* key_path,
135 const wchar_t* value_name, 133 const wchar_t* value_name,
136 std::wstring* out_sz); 134 std::wstring* out_sz);
137 135
138 // Query MULTI_SZ (multiple strings) value. 136 // Query MULTI_SZ (multiple strings) value.
139 // - WRAPPER: Function works with MULTI_SZ data type. 137 // - WRAPPER: Function works with MULTI_SZ data type.
140 // - Key handle should have been opened with CreateRegKey or OpenRegKey. 138 // - Key handle should have been opened with CreateRegKey or OpenRegKey.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 228
231 // Setter function for test suites that use reg redirection. 229 // Setter function for test suites that use reg redirection.
232 bool SetTestingOverride(ROOT_KEY root, const std::wstring& new_path); 230 bool SetTestingOverride(ROOT_KEY root, const std::wstring& new_path);
233 231
234 // Getter function for test suites that use reg redirection. 232 // Getter function for test suites that use reg redirection.
235 std::wstring GetTestingOverride(ROOT_KEY root); 233 std::wstring GetTestingOverride(ROOT_KEY root);
236 234
237 }; // namespace nt 235 }; // namespace nt
238 236
239 #endif // CHROME_ELF_NT_REGISTRY_NT_REGISTRY_H_ 237 #endif // CHROME_ELF_NT_REGISTRY_NT_REGISTRY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome_elf/nt_registry/nt_registry.cc » ('j') | chrome_elf/nt_registry/nt_registry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698