Extension syncing: Introduce a NeedsSync pref
[chromium-blink-merge.git] / chrome_elf / blacklist / blacklist.h
blobbbcf0687ac00bdeae796ee368736418146ffa937
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
3 // found in the LICENSE file.
5 #ifndef CHROME_ELF_BLACKLIST_BLACKLIST_H_
6 #define CHROME_ELF_BLACKLIST_BLACKLIST_H_
8 #if defined(_WIN64)
9 #include "sandbox/win/src/sandbox_nt_types.h"
10 #endif
12 namespace blacklist {
14 // Max size of the DLL blacklist.
15 const size_t kTroublesomeDllsMaxCount = 64;
17 // The DLL blacklist.
18 extern const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount];
20 #if defined(_WIN64)
21 extern NtMapViewOfSectionFunction g_nt_map_view_of_section_func;
22 #endif
24 // Attempts to leave a beacon in the current user's registry hive. If the
25 // blacklist beacon doesn't say it is enabled or there are any other errors when
26 // creating the beacon, returns false. Otherwise returns true. The intent of the
27 // beacon is to act as an extra failure mode protection whereby if Chrome
28 // repeatedly fails to start during blacklist setup, it will skip blacklisting
29 // on the subsequent run.
30 bool LeaveSetupBeacon();
32 // Looks for the setup running beacon that LeaveSetupBeacon() creates and resets
33 // it to to show the setup was successful.
34 // Returns true if the beacon was successfully set to BLACKLIST_ENABLED.
35 bool ResetBeacon();
37 // Return the size of the current blacklist.
38 extern "C" int BlacklistSize();
40 // Returns if true if the blacklist has been initialized.
41 extern "C" bool IsBlacklistInitialized();
43 // Returns the index of the DLL named |dll_name| on the blacklist, or -1 if not
44 // found.
45 extern "C" int GetBlacklistIndex(const wchar_t* dll_name);
47 // Adds the given dll name to the blacklist. Returns true if the dll name is in
48 // the blacklist when this returns, false on error. Note that this will copy
49 // |dll_name| and will leak it on exit if the string is not subsequently removed
50 // using RemoveDllFromBlacklist.
51 // Exposed for testing only, this shouldn't be exported from chrome_elf.dll.
52 extern "C" bool AddDllToBlacklist(const wchar_t* dll_name);
54 // Removes the given dll name from the blacklist. Returns true if it was
55 // removed, false on error.
56 // Exposed for testing only, this shouldn't be exported from chrome_elf.dll.
57 extern "C" bool RemoveDllFromBlacklist(const wchar_t* dll_name);
59 // Returns a list of all the dlls that have been successfully blocked by the
60 // blacklist via blocked_dlls, if there is enough space (according to |size|).
61 // |size| will always be modified to be the number of dlls that were blocked.
62 // The caller doesn't own the strings and isn't expected to free them. These
63 // strings won't be hanging unless RemoveDllFromBlacklist is called, but it
64 // is only exposed in tests (and should stay that way).
65 extern "C" void SuccessfullyBlocked(const wchar_t** blocked_dlls, int* size);
67 // Add the dlls, originally passed in through finch, from the registry to the
68 // blacklist so that they will be blocked identically to those hard coded in.
69 extern "C" void AddDllsFromRegistryToBlacklist();
71 // Record that the dll at the given index was blocked.
72 extern "C" void BlockedDll(size_t blocked_index);
74 // Initializes the DLL blacklist in the current process. This should be called
75 // before any undesirable DLLs might be loaded. If |force| is set to true, then
76 // initialization will take place even if a beacon is present. This is useful
77 // for tests.
78 bool Initialize(bool force);
80 } // namespace blacklist
82 #endif // CHROME_ELF_BLACKLIST_BLACKLIST_H_