Chromium Code Reviews| Index: chrome_elf/blacklist/blacklist.cc |
| diff --git a/chrome_elf/blacklist/blacklist.cc b/chrome_elf/blacklist/blacklist.cc |
| index a168c9a044c4ff0a5a54efa57eeeb6556ddcab3b..4efe4f2e183032e11fbdc4e40804eddb213e6a31 100644 |
| --- a/chrome_elf/blacklist/blacklist.cc |
| +++ b/chrome_elf/blacklist/blacklist.cc |
| @@ -7,6 +7,8 @@ |
| #include <assert.h> |
| #include <string.h> |
| +#include <vector> |
| + |
| #include "base/basictypes.h" |
| #include "chrome_elf/blacklist/blacklist_interceptions.h" |
| #include "chrome_elf/chrome_elf_constants.h" |
| @@ -342,7 +344,58 @@ bool Initialize(bool force) { |
| RecordSuccessfulThunkSetup(&key); |
| + AddDllsFromRegistryToBlacklist(); |
| + |
| return NT_SUCCESS(ret) && page_executable; |
| } |
| +void AddDllsFromRegistryToBlacklist() { |
|
csharp
2014/05/29 20:51:52
Should this return a boolean to indicate failure o
krstnmnlsn
2014/05/30 14:09:13
Done.
|
| + HKEY key = NULL; |
| + LONG result = ::RegOpenKeyEx(HKEY_CURRENT_USER, |
| + kRegistryFinchListPath, |
| + 0, |
| + KEY_QUERY_VALUE | KEY_SET_VALUE, |
| + &key); |
| + |
| + if (result != ERROR_SUCCESS) |
| + return; |
| + |
| + int num_dlls; |
| + int longest_name; |
| + ::RegQueryInfoKey(key, NULL, NULL, NULL, NULL, NULL, NULL, |
| + reinterpret_cast<DWORD*>(&num_dlls), |
| + reinterpret_cast<DWORD*>(&longest_name), NULL, NULL, NULL); |
| + |
| + // Collect dlls so that we can delete them after the enumeration. |
| + std::vector<wchar_t*> dll_names(num_dlls); |
| + |
| + for (int i = 0; i < num_dlls; ++i) { |
| + DWORD name_len(longest_name + 1); |
| + DWORD value_len; |
| + wchar_t* name_buffer = new wchar_t[name_len]; |
| + result = ::RegEnumValue(key, i, name_buffer, &name_len, NULL, NULL, |
| + NULL, &value_len); |
| + name_len = name_len + 1; |
| + wchar_t* value_buffer = new wchar_t[value_len+1]; |
| + result = ::RegEnumValue(key, i, name_buffer, &name_len, NULL, NULL, |
| + reinterpret_cast<BYTE*>(value_buffer), &value_len); |
| + value_buffer[value_len] = L'\0'; |
| + |
| + if (result == ERROR_SUCCESS) { |
| + AddDllToBlacklist(value_buffer); |
| + } |
| + |
| + dll_names[i] = name_buffer; |
| + |
| + delete[] value_buffer; |
| + } |
| + |
| + for (int i = 0; i < num_dlls; ++i) { |
| + ::RegDeleteValue(key, dll_names[i]); |
| + delete[] dll_names[i]; |
| + } |
| + |
| + ::RegCloseKey(key); |
| +} |
| + |
| } // namespace blacklist |