Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome_elf / blacklist / blacklist.h
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.
4
5 #ifndef CHROME_ELF_BLACKLIST_BLACKLIST_H_
6 #define CHROME_ELF_BLACKLIST_BLACKLIST_H_
7
8 #if defined(_WIN64)
9 #include "sandbox/win/src/sandbox_nt_types.h"
10 #endif
11
12 namespace blacklist {
13
14 // Max size of the DLL blacklist.
15 const int kTroublesomeDllsMaxCount = 64;
16
17 // The DLL blacklist.
18 extern const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount];
19
20 // The registry path of the blacklist beacon.
21 extern const wchar_t kRegistryBeaconPath[];
22
23 // The properties for the blacklist beacon.
24 extern const wchar_t kBeaconVersion[];
25 extern const wchar_t kBeaconState[];
26
27 // The states for the blacklist setup code.
28 enum BlacklistState {
29   BLACKLIST_DISABLED = 0,
30   BLACKLIST_ENABLED,
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.
41   BLACKLIST_STATE_MAX,
42 };
43
44 #if defined(_WIN64)
45 extern NtMapViewOfSectionFunction g_nt_map_view_of_section_func;
46 #endif
47
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();
55
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.
59 bool ResetBeacon();
60
61 // Return the size of the current blacklist.
62 int BlacklistSize();
63
64 // Returns if true if the blacklist has been initialized.
65 extern "C" bool IsBlacklistInitialized();
66
67 // Adds the given dll name to the blacklist. Returns true if the dll name is in
68 // the blacklist when this returns, false on error. Note that this will copy
69 // |dll_name| and will leak it on exit if the string is not subsequently removed
70 // using RemoveDllFromBlacklist.
71 extern "C" bool AddDllToBlacklist(const wchar_t* dll_name);
72
73 // Removes the given dll name from the blacklist. Returns true if it was
74 // removed, false on error.
75 extern "C" bool RemoveDllFromBlacklist(const wchar_t* dll_name);
76
77 // Initializes the DLL blacklist in the current process. This should be called
78 // before any undesirable DLLs might be loaded. If |force| is set to true, then
79 // initialization will take place even if a beacon is present. This is useful
80 // for tests.
81 bool Initialize(bool force);
82
83 }  // namespace blacklist
84
85 #endif  // CHROME_ELF_BLACKLIST_BLACKLIST_H_