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..3310376f61df5a6226507e447301729d94b4942c 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 }; |
| +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,43 @@ 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) { |
|
robertshield
2014/02/24 15:24:05
null check the inputs
csharp
2014/02/24 21:37:16
Done.
|
| + // If the array isn't big enough, just report the size it needs to be and |
| + // return. |
| + if (*size < g_num_blocked_dlls) { |
| + *size = g_num_blocked_dlls; |
| + return; |
| + } |
| + |
| + int strings_to_fill = 0; |
| + for (int i = 0; strings_to_fill != g_num_blocked_dlls; ++i) { |
|
robertshield
2014/02/24 15:24:05
be paranoid: also bounds check the index |i| again
csharp
2014/02/24 21:37:16
Done.
|
| + if (g_blocked_dlls[i]) { |
| + blocked_dlls[strings_to_fill] = g_troublesome_dlls[i]; |
| + ++strings_to_fill; |
| + } |
| + } |
| +} |
| + |
| +void BlockedDll(int blocked_index) { |
| + 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()) |