Commit b496436e authored by Patrick Monette's avatar Patrick Monette Committed by Commit Bot

Log chrome_elf init status

Change-Id: I5e0c0bb4da22fb851b9869e89fcd540ec4d4e6a5
Reviewed-on: https://chromium-review.googlesource.com/c/1313390
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Reviewed-by: default avatarChris Hamilton <chrisha@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608577}
parent 7720b2bc
......@@ -16,9 +16,11 @@
#include "base/metrics/histogram_macros.h"
#include "base/path_service.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
#include "base/task_runner.h"
#include "base/task_runner_util.h"
#include "base/win/registry.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/conflicts/incompatible_applications_updater_win.h"
#include "chrome/browser/conflicts/installed_applications_win.h"
......@@ -28,6 +30,9 @@
#include "chrome/browser/conflicts/module_list_filter_win.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/install_static/install_util.h"
#include "chrome_elf/third_party_dlls/packed_list_format.h"
#include "chrome_elf/third_party_dlls/status_codes.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
......@@ -74,6 +79,53 @@ ReadInitialBlacklistedModules() {
return initial_blacklisted_modules;
}
// Log the initialization status of the chrome_elf component that is responsible
// for blocking third-party DLLs. The status is stored in the
// kStatusCodesRegValue registry key during chrome_elf's initialization.
void LogChromeElfThirdPartyStatus() {
base::win::RegKey registry_key(
HKEY_CURRENT_USER,
base::StringPrintf(L"%ls%ls", install_static::GetRegistryPath().c_str(),
third_party_dlls::kThirdPartyRegKeyName)
.c_str(),
KEY_QUERY_VALUE);
// Early return if the registry key can't be opened.
if (!registry_key.Valid())
return;
// Read the status code. Since the data is basically an array of integers, and
// resets every startups, a starting size of 128 should always be sufficient.
DWORD size = 128;
std::vector<uint8_t> buffer(size);
DWORD key_type;
DWORD result = registry_key.ReadValue(third_party_dlls::kStatusCodesRegValue,
buffer.data(), &size, &key_type);
if (result == ERROR_MORE_DATA) {
buffer.resize(size);
result = registry_key.ReadValue(third_party_dlls::kStatusCodesRegValue,
buffer.data(), &size, &key_type);
}
// Give up if it failed to retrieve the status codes.
if (result != ERROR_SUCCESS)
return;
// The real size of the data is most probably smaller than the initial size.
buffer.resize(size);
// Sanity check the type of data.
if (key_type != REG_BINARY)
return;
std::vector<third_party_dlls::ThirdPartyStatus> status_array;
third_party_dlls::ConvertBufferToStatusCodes(buffer, &status_array);
for (auto status : status_array)
UMA_HISTOGRAM_ENUMERATION("ChromeElf.ThirdPartyStatus", status);
}
} // namespace
ThirdPartyConflictsManager::ThirdPartyConflictsManager(
......@@ -89,6 +141,8 @@ ThirdPartyConflictsManager::ThirdPartyConflictsManager(
module_list_update_needed_(false),
component_update_service_observer_(this),
weak_ptr_factory_(this) {
LogChromeElfThirdPartyStatus();
module_database_event_source_->AddObserver(this);
base::PostTaskAndReplyWithResult(
background_sequence_.get(), FROM_HERE,
......
......@@ -49417,6 +49417,28 @@ would be helpful to identify which type is being sent.
<int value="1835109015" label="patts: Chrome OS Indian English"/>
</enum>
<enum name="ThirdPartyStatus">
<int value="0" label="Success"/>
<int value="1" label="FilePathNotFoundInRegistry"/>
<int value="2" label="FileNotFound"/>
<int value="3" label="FileEmpty"/>
<int value="4" label="FileArraySizeZero"/>
<int value="5" label="FileAccessDenied"/>
<int value="6" label="FileUnexpectedFailure"/>
<int value="7" label="FileMetadataReadFailure"/>
<int value="8" label="FileInvalidFormatVersion"/>
<int value="9" label="FileArrayTooBig"/>
<int value="10" label="FileArrayReadFailure"/>
<int value="11" label="FileArrayNotSorted"/>
<int value="12" label="LogsCreateMutexFailure"/>
<int value="13" label="HookInitImportsFailure"/>
<int value="14" label="HookUnsupportedOs"/>
<int value="15" label="HookVirtualProtectFailure"/>
<int value="16" label="HookApplyFailure"/>
<int value="17" label="HookCreateMutexFailure"/>
<int value="18" label="StatusCodeResetFailure"/>
</enum>
<enum name="ThreadType">
<int value="0" label="UI"/>
<int value="1" label="Blocking"/>
......@@ -13207,6 +13207,19 @@ uploading your change for review.
</summary>
</histogram>
<histogram name="ChromeElf.ThirdPartyStatus" enum="ThirdPartyStatus">
<owner>pmonette@chromium.org</owner>
<summary>
Records the different status codes that are emitted by chrome_elf.dll while
initializing the NtMapViewOfSection hook used to blocked third-party DLLs.
Multiple status codes can be emitted per initialization since some of those
status codes represent non-fatal failures. E.g. Failure to clear the
previous failure codes. This also means that duplicates are possible. This
is recorded shortly after Chrome launches, since chrome_elf.dll doesn't have
access to the //base API.
</summary>
</histogram>
<histogram name="ChromeGeneratedCustomTab.IntentToFirstCommitNavigationTime"
units="ms">
<obsolete>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment