Commit fd8fe93c authored by Jesse McKenna's avatar Jesse McKenna Committed by Commit Bot

Use consistent DLL to detect Application Verifier

To detect whether Application Verifier is running,
sandbox/win/src/target_interceptions.cc checks if vrfcore.dll is loaded,
while sandbox/win/src/handle_closer_agent.cc checks for verifier.dll.

This change makes both use verifier.dll, to be consistent and remove any
confusion around whether these two are checking for the same thing (they
are).

      Open Application Verifier
      File > Add Application > chrome.exe (any chrome.exe binary works)
      Under 'Tests', uncheck everything but Basics > Handles, then Save
      Run chrome.exe with this change; it works normally
        (on versions without lines 176-177, no pages will load)
      Return to Application Verifier
      Right-click chrome.exe > Delete Application, then Save
        (so Chrome runs normally again)

Test: Manual
Change-Id: If97a1115373c394f0cbbf1d31d3ca7b60549bbee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1776781
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Reviewed-by: default avatarBruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700323}
parent 9c9397b6
......@@ -195,6 +195,8 @@ NativeLibrary PinUser32Internal(NativeLibraryLoadError* error) {
} // namespace
const char kApplicationVerifierDllName[] = "verifier.dll";
// Uses the Windows 10 WRL API's to query the current system state. The API's
// we are using in the function below are supported in Win32 apps as per msdn.
// It looks like the API implementation is buggy at least on Surface 4 causing
......
......@@ -43,6 +43,8 @@ struct NativeLibraryLoadError;
namespace win {
BASE_EXPORT extern const char kApplicationVerifierDllName[];
inline uint32_t HandleToUint32(HANDLE h) {
// Cast through uintptr_t and then unsigned int to make the truncation to
// 32 bits explicit. Handles are size of-pointer but are always 32-bit values.
......
......@@ -8,6 +8,7 @@
#include <stddef.h>
#include "base/logging.h"
#include "base/win/win_util.h"
#include "sandbox/win/src/nt_internals.h"
#include "sandbox/win/src/win_utils.h"
......@@ -173,7 +174,7 @@ bool HandleCloserAgent::CloseHandles() {
// Skip closing these handles when Application Verifier is in use in order to
// avoid invalid-handle exceptions.
if (GetModuleHandleW(L"vrfcore.dll"))
if (GetModuleHandleA(base::win::kApplicationVerifierDllName))
return true;
// Set up buffers for the type info and the name.
......
......@@ -4,6 +4,8 @@
#include "sandbox/win/src/target_interceptions.h"
#include "base/strings/char_traits.h"
#include "base/win/win_util.h"
#include "sandbox/win/src/interception_agent.h"
#include "sandbox/win/src/sandbox_factory.h"
#include "sandbox/win/src/sandbox_nt_util.h"
......@@ -12,7 +14,6 @@ namespace sandbox {
SANDBOX_INTERCEPT NtExports g_nt;
const char VERIFIER_DLL_NAME[] = "verifier.dll";
const char KERNEL32_DLL_NAME[] = "kernel32.dll";
enum SectionLoadState {
......@@ -60,8 +61,11 @@ TargetNtMapViewOfSection(NtMapViewOfSectionFunction orig_MapViewOfSection,
// indicates Application Verifier is enabled and we should wait until
// the next module is loaded.
if (ansi_module_name &&
(g_nt._strnicmp(ansi_module_name, VERIFIER_DLL_NAME,
sizeof(VERIFIER_DLL_NAME)) == 0))
(g_nt._strnicmp(ansi_module_name,
base::win::kApplicationVerifierDllName,
base::CharTraits<char>::length(
base::win::kApplicationVerifierDllName) +
1) == 0))
break;
if (ansi_module_name &&
......
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