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_
9 #include "sandbox/win/src/sandbox_nt_types.h"
14 // Max size of the DLL blacklist.
15 const int kTroublesomeDllsMaxCount
= 64;
18 extern const wchar_t* g_troublesome_dlls
[kTroublesomeDllsMaxCount
];
20 // The registry path of the blacklist beacon.
21 extern const wchar_t kRegistryBeaconPath
[];
23 // The properties for the blacklist beacon.
24 extern const wchar_t kBeaconVersion
[];
25 extern const wchar_t kBeaconState
[];
27 // The states for the blacklist setup code.
29 BLACKLIST_DISABLED
= 0,
31 // The blacklist setup code is running. If this is still set at startup,
32 // it means the last setup crashed.
33 BLACKLIST_SETUP_RUNNING
,
34 // The blacklist thunk setup code is running. If this is still set at startup,
35 // it means the last setup crashed during thunk setup.
36 BLACKLIST_THUNK_SETUP
,
37 // The blacklist code is currently intercepting MapViewOfSection. If this is
38 // still set at startup, it means we crashed during interception.
39 BLACKLIST_INTERCEPTING
,
40 // Always keep this at the end.
45 extern NtMapViewOfSectionFunction g_nt_map_view_of_section_func
;
48 // Attempts to leave a beacon in the current user's registry hive.
49 // If the blacklist beacon doesn't say it is enabled or there are any other
50 // errors when creating the beacon, returns false. Otherwise returns true.
51 // The intent of the beacon is to act as an extra failure mode protection
52 // whereby if Chrome for some reason fails to start during blacklist setup,
53 // it will skip blacklisting on the subsequent run.
54 bool LeaveSetupBeacon();
56 // Looks for the beacon that LeaveSetupBeacon() creates and resets it to
57 // to show the setup was successful.
58 // Returns true if the beacon was successfully set to BLACKLIST_ENABLED.
61 // Return the size of the current blacklist.
64 // Adds the given dll name to the blacklist. Returns true if the dll name is in
65 // the blacklist when this returns, false on error. Note that this will copy
66 // |dll_name| and will leak it on exit if the string is not subsequently removed
67 // using RemoveDllFromBlacklist.
68 extern "C" bool AddDllToBlacklist(const wchar_t* dll_name
);
70 // Removes the given dll name from the blacklist. Returns true if it was
71 // removed, false on error.
72 extern "C" bool RemoveDllFromBlacklist(const wchar_t* dll_name
);
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
78 bool Initialize(bool force
);
80 } // namespace blacklist
82 #endif // CHROME_ELF_BLACKLIST_BLACKLIST_H_