| Index: base/win/win_util.cc
|
| diff --git a/base/win/win_util.cc b/base/win/win_util.cc
|
| index 3b7d3195ac6c0b2622ef39c263cf2479d6c4606f..a1b7f8985590dd709c89ba6cb1b579e14222e0ce 100644
|
| --- a/base/win/win_util.cc
|
| +++ b/base/win/win_util.cc
|
| @@ -32,7 +32,6 @@
|
|
|
| #include "base/base_switches.h"
|
| #include "base/command_line.h"
|
| -#include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| #include "base/macros.h"
|
| #include "base/strings/string_util.h"
|
| @@ -67,44 +66,6 @@ void __cdecl ForceCrashOnSigAbort(int) {
|
| *((volatile int*)0) = 0x1337;
|
| }
|
|
|
| -typedef decltype(GetProcessMitigationPolicy)* GetProcessMitigationPolicyType;
|
| -
|
| -class LazyIsUser32AndGdi32Available {
|
| - public:
|
| - LazyIsUser32AndGdi32Available() : value_(!IsWin32kSyscallsDisabled()) {}
|
| -
|
| - ~LazyIsUser32AndGdi32Available() {}
|
| -
|
| - bool value() { return value_; }
|
| -
|
| - private:
|
| - static bool IsWin32kSyscallsDisabled() {
|
| - // Can't disable win32k prior to windows 8.
|
| - if (base::win::GetVersion() < base::win::VERSION_WIN8)
|
| - return false;
|
| -
|
| - GetProcessMitigationPolicyType get_process_mitigation_policy_func =
|
| - reinterpret_cast<GetProcessMitigationPolicyType>(GetProcAddress(
|
| - GetModuleHandle(L"kernel32.dll"), "GetProcessMitigationPolicy"));
|
| -
|
| - if (!get_process_mitigation_policy_func)
|
| - return false;
|
| -
|
| - PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY policy = {};
|
| - if (get_process_mitigation_policy_func(GetCurrentProcess(),
|
| - ProcessSystemCallDisablePolicy,
|
| - &policy, sizeof(policy))) {
|
| - return policy.DisallowWin32kSystemCalls != 0;
|
| - }
|
| -
|
| - return false;
|
| - }
|
| -
|
| - const bool value_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(LazyIsUser32AndGdi32Available);
|
| -};
|
| -
|
| // Returns the current platform role. We use the PowerDeterminePlatformRoleEx
|
| // API for that.
|
| POWER_PLATFORM_ROLE GetPlatformRole() {
|
| @@ -540,9 +501,32 @@ void SetDomainStateForTesting(bool state) {
|
| }
|
|
|
| bool IsUser32AndGdi32Available() {
|
| - static base::LazyInstance<LazyIsUser32AndGdi32Available>::Leaky available =
|
| - LAZY_INSTANCE_INITIALIZER;
|
| - return available.Get().value();
|
| + static auto is_user32_and_gdi32_available = []() {
|
| + // If win32k syscalls aren't disabled, then user32 and gdi32 are available.
|
| +
|
| + // Can't disable win32k prior to windows 8.
|
| + if (base::win::GetVersion() < base::win::VERSION_WIN8)
|
| + return true;
|
| +
|
| + typedef decltype(
|
| + GetProcessMitigationPolicy)* GetProcessMitigationPolicyType;
|
| + GetProcessMitigationPolicyType get_process_mitigation_policy_func =
|
| + reinterpret_cast<GetProcessMitigationPolicyType>(GetProcAddress(
|
| + GetModuleHandle(L"kernel32.dll"), "GetProcessMitigationPolicy"));
|
| +
|
| + if (!get_process_mitigation_policy_func)
|
| + return true;
|
| +
|
| + PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY policy = {};
|
| + if (get_process_mitigation_policy_func(GetCurrentProcess(),
|
| + ProcessSystemCallDisablePolicy,
|
| + &policy, sizeof(policy))) {
|
| + return policy.DisallowWin32kSystemCalls == 0;
|
| + }
|
| +
|
| + return true;
|
| + }();
|
| + return is_user32_and_gdi32_available;
|
| }
|
|
|
| bool GetLoadedModulesSnapshot(HANDLE process, std::vector<HMODULE>* snapshot) {
|
|
|