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

Side by Side Diff: chrome_elf/blacklist/blacklist.cc

Issue 272213006: Switching the no-finch default behavior to enable the blacklist (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finch blacklist is now added to the hardcoded blacklist. Created 6 years, 6 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 | « chrome_elf/blacklist/blacklist.h ('k') | chrome_elf/chrome_elf.def » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome_elf/blacklist/blacklist.h" 5 #include "chrome_elf/blacklist/blacklist.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 delete thunk; 335 delete thunk;
336 336
337 // Mark the thunk storage as executable and prevent any future writes to it. 337 // Mark the thunk storage as executable and prevent any future writes to it.
338 page_executable = page_executable && VirtualProtect(&g_thunk_storage, 338 page_executable = page_executable && VirtualProtect(&g_thunk_storage,
339 sizeof(g_thunk_storage), 339 sizeof(g_thunk_storage),
340 PAGE_EXECUTE_READ, 340 PAGE_EXECUTE_READ,
341 &old_protect); 341 &old_protect);
342 342
343 RecordSuccessfulThunkSetup(&key); 343 RecordSuccessfulThunkSetup(&key);
344 344
345 AddDllsFromRegistryToBlacklist();
346
345 return NT_SUCCESS(ret) && page_executable; 347 return NT_SUCCESS(ret) && page_executable;
346 } 348 }
347 349
350 void AddDllsFromRegistryToBlacklist() {
351 HKEY key = NULL;
352 LONG result = ::RegOpenKeyEx(HKEY_CURRENT_USER,
353 kRegistryFinchListPath,
354 0,
355 KEY_QUERY_VALUE | KEY_SET_VALUE,
356 &key);
357
358 if (result != ERROR_SUCCESS)
359 return;
360
361 int num_dlls;
362 int longest_name;
363 ::RegQueryInfoKey(key, NULL, NULL, NULL, NULL, NULL, NULL,
364 (DWORD*) &num_dlls, (DWORD*) &longest_name, NULL, NULL, NULL);
365
366 // Collect dll so that we can delete them after the enumeration.
367 std::vector<wchar_t*> dll_names(num_dlls);
368
369 for (int i = 0; i < num_dlls; ++i) {
370 DWORD name_len(longest_name + 1);
371 DWORD value_len;
372 wchar_t* name_buffer = new wchar_t[name_len];
373 result = ::RegEnumValue(key, i, name_buffer, &name_len, NULL, NULL,
374 NULL, &value_len);
375 name_len = name_len + 1;
376 wchar_t* value_buffer = new wchar_t[value_len+1];
377 result = ::RegEnumValue(key, i, name_buffer, &name_len, NULL, NULL,
378 (BYTE*) value_buffer, &value_len);
379 value_buffer[value_len] = L'\0';
380
381 if (result == ERROR_SUCCESS) {
382 AddDllToBlacklist(value_buffer);
383 }
384
385 dll_names[i] = name_buffer;
386
387 delete[] value_buffer;
388 }
389
390 for (int i = 0; i < (int) dll_names.size(); ++i) {
391 ::RegDeleteValue(key, dll_names[i]);
392 delete[] dll_names[i];
393 }
394
395 ::RegCloseKey(key);
396 }
397
348 } // namespace blacklist 398 } // namespace blacklist
399
OLDNEW
« no previous file with comments | « chrome_elf/blacklist/blacklist.h ('k') | chrome_elf/chrome_elf.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698