0

[Windows] Remove unused ResolveRegistryName utility.

This CL removes an unused utility method from the sandbox during more
general cleanup of the sandbox policy and utility code.

Bug: 339497724
Change-Id: I847be8712b118f484d1372456790d243f803e56b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5547792
Reviewed-by: Alex Gough <ajgo@chromium.org>
Commit-Queue: James Forshaw <forshaw@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1305087}
This commit is contained in:
James Forshaw
2024-05-23 15:10:34 +00:00
committed by Chromium LUCI CQ
parent 3390a0d049
commit 2a533854c8
2 changed files with 0 additions and 48 deletions

@ -33,24 +33,6 @@ const size_t kDriveLetterLen = 3;
constexpr wchar_t kNTDotPrefix[] = L"\\\\.\\";
const size_t kNTDotPrefixLen = std::size(kNTDotPrefix) - 1;
// Holds the information about a known registry key.
struct KnownReservedKey {
const wchar_t* name;
HKEY key;
};
// Contains all the known registry key by name and by handle.
const KnownReservedKey kKnownKey[] = {
{L"HKEY_CLASSES_ROOT", HKEY_CLASSES_ROOT},
{L"HKEY_CURRENT_USER", HKEY_CURRENT_USER},
{L"HKEY_LOCAL_MACHINE", HKEY_LOCAL_MACHINE},
{L"HKEY_USERS", HKEY_USERS},
{L"HKEY_PERFORMANCE_DATA", HKEY_PERFORMANCE_DATA},
{L"HKEY_PERFORMANCE_TEXT", HKEY_PERFORMANCE_TEXT},
{L"HKEY_PERFORMANCE_NLSTEXT", HKEY_PERFORMANCE_NLSTEXT},
{L"HKEY_CURRENT_CONFIG", HKEY_CURRENT_CONFIG},
{L"HKEY_DYN_DATA", HKEY_DYN_DATA}};
// These functions perform case independent path comparisons.
bool EqualPath(const std::wstring& first, const std::wstring& second) {
return _wcsicmp(first.c_str(), second.c_str()) == 0;
@ -205,30 +187,6 @@ bool IsPipe(const std::wstring& path) {
return EqualPath(path, start, kPipe, std::size(kPipe) - 1);
}
std::optional<std::wstring> ResolveRegistryName(std::wstring name) {
for (size_t i = 0; i < std::size(kKnownKey); ++i) {
if (name.find(kKnownKey[i].name) == 0) {
HKEY key;
DWORD disposition;
if (ERROR_SUCCESS != ::RegCreateKeyEx(kKnownKey[i].key, L"", 0, nullptr,
0, MAXIMUM_ALLOWED, nullptr, &key,
&disposition)) {
return std::nullopt;
}
auto result = GetPathFromHandle(key);
::RegCloseKey(key);
if (!result)
return std::nullopt;
result->append(name.substr(wcslen(kKnownKey[i].name)));
return result;
}
}
return std::nullopt;
}
// |full_path| can have any of the following forms:
// \??\c:\some\foo\bar
// \Device\HarddiskVolume0\some\foo\bar

@ -80,12 +80,6 @@ std::optional<std::wstring> GetNtPathFromWin32Path(const std::wstring& path);
// Resolves a handle to its type name. Returns the typename if successful.
std::optional<std::wstring> GetTypeNameFromHandle(HANDLE handle);
// Resolves a user-readable registry path to a system-readable registry path.
// For example, HKEY_LOCAL_MACHINE\\Software\\microsoft is translated to
// \\registry\\machine\\software\\microsoft. Returns nullopt if the path
// cannot be resolved.
std::optional<std::wstring> ResolveRegistryName(std::wstring name);
// Allocates |buffer_bytes| in child (PAGE_READWRITE) and copies data
// from |local_buffer| in this process into |child|. |remote_buffer|
// contains the address in the chile. If a zero byte copy is