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

Unified Diff: chrome_elf/blacklist/blacklist.cc

Issue 300933002: Finch Blacklist is now added to the Hardcoded blacklist. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Upgrading registry accessors to chrome's RegKey. Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome_elf/blacklist/blacklist.cc
diff --git a/chrome_elf/blacklist/blacklist.cc b/chrome_elf/blacklist/blacklist.cc
index a168c9a044c4ff0a5a54efa57eeeb6556ddcab3b..a2bfc2f6b953fcff5f750854f112996d7043cd49 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,61 @@ bool Initialize(bool force) {
RecordSuccessfulThunkSetup(&key);
+ AddDllsFromRegistryToBlacklist();
+
return NT_SUCCESS(ret) && page_executable;
}
+bool AddDllsFromRegistryToBlacklist() {
+ HKEY key = NULL;
+ LONG result = ::RegOpenKeyEx(HKEY_CURRENT_USER,
+ kRegistryFinchListPath,
+ 0,
+ KEY_QUERY_VALUE | KEY_SET_VALUE,
+ &key);
+
+ if (result != ERROR_SUCCESS)
+ return false;
+
+ int num_dlls;
robertshield 2014/05/30 21:07:08 = 0
krstnmnlsn 2014/06/02 14:00:37 Done.
+ int longest_name;
robertshield 2014/05/30 21:07:08 = 0
krstnmnlsn 2014/06/02 14:00:37 Done.
+ ::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);
robertshield 2014/05/30 21:07:08 using a std::vector<std::wstring> would save a bun
krstnmnlsn 2014/06/02 14:00:37 Done.
+
+ for (int i = 0; i < num_dlls; ++i) {
+ DWORD name_len(longest_name + 1);
robertshield 2014/05/30 21:07:08 prefer = syntax for POD types
krstnmnlsn 2014/06/02 14:00:37 Done.
+ DWORD value_len;
robertshield 2014/05/30 21:07:08 = 0
krstnmnlsn 2014/06/02 14:00:37 Done.
+ wchar_t* name_buffer = new wchar_t[name_len];
robertshield 2014/05/30 21:07:08 it looks like name_buffer is leaked on every itera
krstnmnlsn 2014/06/02 14:00:37 In my defense, I don't actually think this was lea
robertshield 2014/06/03 03:03:00 Indeed, not leaking! Sorry for misreading :( still
+ 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;
robertshield 2014/05/30 21:07:08 use push_back() instead
krstnmnlsn 2014/06/02 14:00:37 Done.
+
+ delete[] value_buffer;
+ }
+
+ for (int i = 0; i < num_dlls; ++i) {
+ ::RegDeleteValue(key, dll_names[i]);
robertshield 2014/05/30 21:07:08 Why do we delete the values from the registry here
krstnmnlsn 2014/06/02 14:00:37 I thought that deleting values from the registry w
robertshield 2014/06/03 03:03:00 I actually meant, why do we delete them at all? Do
+ delete[] dll_names[i];
+ }
+
+ ::RegCloseKey(key);
+ return true;
+}
+
} // namespace blacklist

Powered by Google App Engine
This is Rietveld 408576698