Chromium Code Reviews| Index: chrome_elf/nt_registry/nt_registry.h |
| diff --git a/chrome_elf/nt_registry/nt_registry.h b/chrome_elf/nt_registry/nt_registry.h |
| index 0451fc536ec4fe4c266ccbb88b05f91f8f4c8104..71da6b73a749fb2f092c5d091adf669c556d92d6 100644 |
| --- a/chrome_elf/nt_registry/nt_registry.h |
| +++ b/chrome_elf/nt_registry/nt_registry.h |
| @@ -28,16 +28,26 @@ |
| namespace nt { |
| -// These globals are only used in test suites that use reg redirection |
| -// of HKLM and/or HKCU. |
| -extern const size_t g_kRegMaxPathLen; |
| -extern wchar_t HKLM_override[]; |
| -extern wchar_t HKCU_override[]; |
| +// Windows registry maximum lengths (in chars). Not including null char. |
| +constexpr size_t g_kRegMaxPathLen = 255; |
|
grt (UTC plus 2)
2016/09/30 09:32:16
this is max name for a single key, not for a full
penny
2016/10/01 01:44:25
No, this is actually the max for the absolute key
|
| +constexpr size_t g_kRegMaxValueName = 16383; |
| // AUTO will choose depending on system install or not. |
| // Use HKLM or HKCU to override. |
| typedef enum _ROOT_KEY { AUTO = 0, HKLM, HKCU } ROOT_KEY; |
| +// Used with wrapper functions to request registry redirection override. |
| +// Maps to KEY_WOW64_32KEY and KEY_WOW64_64KEY access flags. |
| +enum WOW64_OVERRIDE { |
| + NONE = 0L, |
| + WOW6432 = KEY_WOW64_32KEY, |
| + WOW6464 = KEY_WOW64_64KEY |
| +}; |
| + |
| +//------------------------------------------------------------------------------ |
| +// Create, open, delete, close functions |
| +//------------------------------------------------------------------------------ |
| + |
| // Create and/or open a registry key. |
| // - This function will recursively create multiple sub-keys if required for |
| // |key_path|. |
| @@ -66,7 +76,10 @@ bool DeleteRegKey(HANDLE key); |
| // Delete a registry key. |
| // - WRAPPER: Function opens and closes the target key for caller. |
| -bool DeleteRegKey(ROOT_KEY root, const wchar_t* key_path); |
| +// - Use |wow64_override| to force redirection behaviour, or pass 0/nt::NONE. |
| +bool DeleteRegKey(ROOT_KEY root, |
| + WOW64_OVERRIDE wow64_override, |
| + const wchar_t* key_path); |
| // Close a registry key handle that was opened with CreateRegKey or OpenRegKey. |
| void CloseRegKey(HANDLE key); |
| @@ -96,7 +109,9 @@ bool QueryRegValueDWORD(HANDLE key, |
| // Query DWORD value. |
| // - WRAPPER: Function opens and closes the target key for caller, and works |
| // with DWORD data type. |
| +// - Use |wow64_override| to force redirection behaviour, or pass 0/nt::NONE. |
| bool QueryRegValueDWORD(ROOT_KEY root, |
| + WOW64_OVERRIDE wow64_override, |
| const wchar_t* key_path, |
| const wchar_t* value_name, |
| DWORD* out_dword); |
| @@ -112,7 +127,9 @@ bool QueryRegValueSZ(HANDLE key, |
| // Query SZ (string) value. |
| // - WRAPPER: Function opens and closes the target key for caller, and works |
| // with SZ data type. |
| +// - Use |wow64_override| to force redirection behaviour, or pass 0/nt::NONE. |
| bool QueryRegValueSZ(ROOT_KEY root, |
| + WOW64_OVERRIDE wow64_override, |
| const wchar_t* key_path, |
| const wchar_t* value_name, |
| std::wstring* out_sz); |
| @@ -128,7 +145,9 @@ bool QueryRegValueMULTISZ(HANDLE key, |
| // Query MULTI_SZ (multiple strings) value. |
| // - WRAPPER: Function opens and closes the target key for caller, and works |
| // with MULTI_SZ data type. |
| +// - Use |wow64_override| to force redirection behaviour, or pass 0/nt::NONE. |
| bool QueryRegValueMULTISZ(ROOT_KEY root, |
| + WOW64_OVERRIDE wow64_override, |
| const wchar_t* key_path, |
| const wchar_t* value_name, |
| std::vector<std::wstring>* out_multi_sz); |
| @@ -155,7 +174,9 @@ bool SetRegValueDWORD(HANDLE key, const wchar_t* value_name, DWORD value); |
| // Set DWORD value. |
| // - WRAPPER: Function opens and closes the target key for caller, and works |
| // with DWORD data type. |
| +// - Use |wow64_override| to force redirection behaviour, or pass 0/nt::NONE. |
| bool SetRegValueDWORD(ROOT_KEY root, |
| + WOW64_OVERRIDE wow64_override, |
| const wchar_t* key_path, |
| const wchar_t* value_name, |
| DWORD value); |
| @@ -171,7 +192,9 @@ bool SetRegValueSZ(HANDLE key, |
| // Set SZ (string) value. |
| // - WRAPPER: Function opens and closes the target key for caller, and works |
| // with SZ data type. |
| +// - Use |wow64_override| to force redirection behaviour, or pass 0/nt::NONE. |
| bool SetRegValueSZ(ROOT_KEY root, |
| + WOW64_OVERRIDE wow64_override, |
| const wchar_t* key_path, |
| const wchar_t* value_name, |
| const std::wstring& value); |
| @@ -187,7 +210,9 @@ bool SetRegValueMULTISZ(HANDLE key, |
| // Set MULTI_SZ (multiple strings) value. |
| // - WRAPPER: Function opens and closes the target key for caller, and works |
| // with MULTI_SZ data type. |
| +// - Use |wow64_override| to force redirection behaviour, or pass 0/nt::NONE. |
| bool SetRegValueMULTISZ(ROOT_KEY root, |
| + WOW64_OVERRIDE wow64_override, |
| const wchar_t* key_path, |
| const wchar_t* value_name, |
| const std::vector<std::wstring>& values); |
| @@ -199,6 +224,17 @@ bool SetRegValueMULTISZ(ROOT_KEY root, |
| // Returns the current user SID in string form. |
| const wchar_t* GetCurrentUserSidString(); |
| +// Returns true if this process is WOW64. |
| +bool IsCurrentProcWow64(); |
| + |
| +// Setter function for test suites that use reg redirection |
| +// of HKLM and/or HKCU. |
| +bool SetTestingOverride(nt::ROOT_KEY root, const std::wstring& new_path); |
| + |
| +// Getter function for test suites that use reg redirection |
| +// of HKLM and/or HKCU. |
| +void GetTestingOverride(nt::ROOT_KEY root, std::wstring* out_path); |
|
grt (UTC plus 2)
2016/09/30 09:32:16
nit: we generally return strings as values rather
penny
2016/10/01 01:44:25
Good point, well made.
|
| + |
| }; // namespace nt |
| #endif // CHROME_ELF_NT_REGISTRY_NT_REGISTRY_H_ |