Chromium Code Reviews| Index: chrome_elf/blacklist/blacklist.cc |
| diff --git a/chrome_elf/blacklist/blacklist.cc b/chrome_elf/blacklist/blacklist.cc |
| index 958d7103b798ba5488b8d9857f7be6a06c20cecb..566a675c1172229de4b74236bfc45e406d1dfdd8 100644 |
| --- a/chrome_elf/blacklist/blacklist.cc |
| +++ b/chrome_elf/blacklist/blacklist.cc |
| @@ -28,6 +28,9 @@ const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount] = { |
| NULL, |
| }; |
| +bool g_blocked_dlls[kTroublesomeDllsMaxCount] = {false}; |
|
robertshield
2014/02/25 03:21:40
"= {}" works for bool arrays too.
csharp
2014/02/25 14:45:00
Done.
|
| +int g_num_blocked_dlls = 0; |
| + |
| const wchar_t kRegistryBeaconPath[] = L"SOFTWARE\\Google\\Chrome\\BLBeacon"; |
| const wchar_t kBeaconVersion[] = L"version"; |
| const wchar_t kBeaconState[] = L"state"; |
| @@ -298,6 +301,7 @@ bool AddDllToBlacklist(const wchar_t* dll_name) { |
| wcscpy(str_buffer, dll_name); |
| g_troublesome_dlls[blacklist_size] = str_buffer; |
| + g_blocked_dlls[blacklist_size] = false; |
| return true; |
| } |
| @@ -310,12 +314,48 @@ bool RemoveDllFromBlacklist(const wchar_t* dll_name) { |
| delete[] g_troublesome_dlls[i]; |
| g_troublesome_dlls[i] = g_troublesome_dlls[blacklist_size - 1]; |
| g_troublesome_dlls[blacklist_size - 1] = NULL; |
| + |
| + // Also update the stats recording if we have blocked this dll or not. |
| + if (g_blocked_dlls[i]) |
| + --g_num_blocked_dlls; |
| + g_blocked_dlls[i] = g_blocked_dlls[blacklist_size - 1]; |
| return true; |
| } |
| } |
| return false; |
| } |
| +// TODO(csharp): Maybe store these values in the registry so we can |
| +// still report them if Chrome crashes early. |
| +void SuccessfullyBlocked(const wchar_t** blocked_dlls, int* size) { |
| + if (size == NULL) |
| + return; |
| + |
| + // If the array isn't valid or big enough, just report the size it needs to |
| + // be and return. |
| + if (blocked_dlls == NULL && *size < g_num_blocked_dlls) { |
| + *size = g_num_blocked_dlls; |
|
robertshield
2014/02/25 03:21:40
The comment on this method states that |size| will
csharp
2014/02/25 14:45:00
Comment is correct, fixed code.
|
| + return; |
| + } |
| + |
| + int strings_to_fill = 0; |
| + for (int i = 0; |
| + strings_to_fill != g_num_blocked_dlls && g_troublesome_dlls[i]; |
|
robertshield
2014/02/25 03:21:40
|strings_to_fill| indexes into |blocked_dlls| and
csharp
2014/02/25 14:45:00
Replaced != with <, also |size| >= |g_num_blocked_
|
| + ++i) { |
|
robertshield
2014/02/25 03:21:40
I know I said to break here earlier, but if you c
csharp
2014/02/25 14:45:00
git cl format seems to like merging line 342 and 3
|
| + if (g_blocked_dlls[i]) { |
| + blocked_dlls[strings_to_fill] = g_troublesome_dlls[i]; |
| + ++strings_to_fill; |
| + } |
| + } |
| +} |
| + |
| +void BlockedDll(int blocked_index) { |
|
robertshield
2014/02/25 03:21:40
check |blocked_index| against kTroublesomeDllsMaxC
csharp
2014/02/25 14:45:00
Done.
|
| + if (!g_blocked_dlls[blocked_index]) { |
| + ++g_num_blocked_dlls; |
| + g_blocked_dlls[blocked_index] = true; |
| + } |
| +} |
| + |
| bool Initialize(bool force) { |
| // Check to see that we found the functions we need in ntdll. |
| if (!InitializeInterceptImports()) |