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

Side by Side 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: Final changes? 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/blacklist/test/blacklist_test.cc » ('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 <vector>
11
10 #include "base/basictypes.h" 12 #include "base/basictypes.h"
11 #include "chrome_elf/blacklist/blacklist_interceptions.h" 13 #include "chrome_elf/blacklist/blacklist_interceptions.h"
12 #include "chrome_elf/chrome_elf_constants.h" 14 #include "chrome_elf/chrome_elf_constants.h"
13 #include "chrome_elf/chrome_elf_util.h" 15 #include "chrome_elf/chrome_elf_util.h"
14 #include "chrome_elf/thunk_getter.h" 16 #include "chrome_elf/thunk_getter.h"
15 #include "sandbox/win/src/interception_internal.h" 17 #include "sandbox/win/src/interception_internal.h"
16 #include "sandbox/win/src/internal_types.h" 18 #include "sandbox/win/src/internal_types.h"
17 #include "sandbox/win/src/service_resolver.h" 19 #include "sandbox/win/src/service_resolver.h"
18 20
19 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx 21 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 g_blacklist_initialized = NT_SUCCESS(ret); 337 g_blacklist_initialized = NT_SUCCESS(ret);
336 338
337 // Mark the thunk storage as executable and prevent any future writes to it. 339 // Mark the thunk storage as executable and prevent any future writes to it.
338 page_executable = page_executable && VirtualProtect(&g_thunk_storage, 340 page_executable = page_executable && VirtualProtect(&g_thunk_storage,
339 sizeof(g_thunk_storage), 341 sizeof(g_thunk_storage),
340 PAGE_EXECUTE_READ, 342 PAGE_EXECUTE_READ,
341 &old_protect); 343 &old_protect);
342 344
343 RecordSuccessfulThunkSetup(&key); 345 RecordSuccessfulThunkSetup(&key);
344 346
347 AddDllsFromRegistryToBlacklist();
348
345 return NT_SUCCESS(ret) && page_executable; 349 return NT_SUCCESS(ret) && page_executable;
346 } 350 }
347 351
352 bool AddDllsFromRegistryToBlacklist() {
353 HKEY key = NULL;
354 LONG result = ::RegOpenKeyEx(HKEY_CURRENT_USER,
355 kRegistryFinchListPath,
356 0,
357 KEY_QUERY_VALUE | KEY_SET_VALUE,
358 &key);
359
360 if (result != ERROR_SUCCESS)
361 return false;
362
363 // We add dlls from the registry to the blacklist, and then clear registry.
364 DWORD value_len;
365 DWORD name_len = MAX_PATH;
366 std::vector<wchar_t> name_buffer(name_len);
367 for (int i = 0; result == ERROR_SUCCESS; ++i) {
368 name_len = MAX_PATH;
369 value_len = 0;
370 result = ::RegEnumValue(
371 key, i, &name_buffer[0], &name_len, NULL, NULL, NULL, &value_len);
372 name_len = name_len + 1;
373 value_len = value_len + 1;
374 std::vector<wchar_t> value_buffer(value_len);
375 result = ::RegEnumValue(key, i, &name_buffer[0], &name_len, NULL, NULL,
376 reinterpret_cast<BYTE*>(&value_buffer[0]),
377 &value_len);
378 value_buffer[value_len - 1] = L'\0';
379
380 if (result == ERROR_SUCCESS) {
381 AddDllToBlacklist(&value_buffer[0]);
382 }
383 }
384
385 // Delete the finch registry key to clear the values.
386 result = ::RegDeleteKey(key, L"");
387
388 ::RegCloseKey(key);
389 return result == ERROR_SUCCESS;
390 }
391
348 } // namespace blacklist 392 } // namespace blacklist
OLDNEW
« no previous file with comments | « chrome_elf/blacklist/blacklist.h ('k') | chrome_elf/blacklist/test/blacklist_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698