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

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 3. Created 3 years, 4 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
« no previous file with comments | « no previous file | chrome_elf/nt_registry/nt_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
122 // - Note: this function only returns the string up to the first end-of-string.
123 // Any string packed with embedded nulls can be accessed via the raw
124 // QueryRegKeyValue function.
124 bool QueryRegValueSZ(HANDLE key, 125 bool QueryRegValueSZ(HANDLE key,
125 const wchar_t* value_name, 126 const wchar_t* value_name,
126 std::wstring* out_sz); 127 std::wstring* out_sz);
127 128
128 // Query SZ (string) value. 129 // Query SZ (string) value.
129 // - WRAPPER: Function opens and closes the target key for caller, and works 130 // - WRAPPER: Function opens and closes the target key for caller, and works
130 // with SZ data type. 131 // with SZ or EXPAND_SZ data type.
131 // - Use |wow64_override| to force redirection behaviour, or pass nt::NONE. 132 // - Use |wow64_override| to force redirection behaviour, or pass nt::NONE.
133 // - Note: this function only returns the string up to the first end-of-string.
134 // Any string packed with embedded nulls can be accessed via the raw
135 // QueryRegKeyValue function.
132 bool QueryRegValueSZ(ROOT_KEY root, 136 bool QueryRegValueSZ(ROOT_KEY root,
133 WOW64_OVERRIDE wow64_override, 137 WOW64_OVERRIDE wow64_override,
134 const wchar_t* key_path, 138 const wchar_t* key_path,
135 const wchar_t* value_name, 139 const wchar_t* value_name,
136 std::wstring* out_sz); 140 std::wstring* out_sz);
137 141
138 // Query MULTI_SZ (multiple strings) value. 142 // Query MULTI_SZ (multiple strings) value.
139 // - WRAPPER: Function works with MULTI_SZ data type. 143 // - WRAPPER: Function works with MULTI_SZ data type.
140 // - Key handle should have been opened with CreateRegKey or OpenRegKey. 144 // - Key handle should have been opened with CreateRegKey or OpenRegKey.
141 // - Handle will be left open. Caller must still call CloseRegKey when done. 145 // - Handle will be left open. Caller must still call CloseRegKey when done.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 234
231 // Setter function for test suites that use reg redirection. 235 // Setter function for test suites that use reg redirection.
232 bool SetTestingOverride(ROOT_KEY root, const std::wstring& new_path); 236 bool SetTestingOverride(ROOT_KEY root, const std::wstring& new_path);
233 237
234 // Getter function for test suites that use reg redirection. 238 // Getter function for test suites that use reg redirection.
235 std::wstring GetTestingOverride(ROOT_KEY root); 239 std::wstring GetTestingOverride(ROOT_KEY root);
236 240
237 }; // namespace nt 241 }; // namespace nt
238 242
239 #endif // CHROME_ELF_NT_REGISTRY_NT_REGISTRY_H_ 243 #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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698