Index: base/win/win_util.cc |
diff --git a/base/win/win_util.cc b/base/win/win_util.cc |
index 96d646ad31f92dda082f3b5a20ac72f2ac144d30..c5cab97b9f3e1150c444605bcefa07fb8c3a4ba7 100644 |
--- a/base/win/win_util.cc |
+++ b/base/win/win_util.cc |
@@ -57,6 +57,43 @@ 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 = {0}; |
rvargas (doing something else)
2015/09/16 20:15:42
nit: {}
forshaw
2015/09/16 20:45:36
Done.
|
+ if (get_process_mitigation_policy_func(GetCurrentProcess(), |
+ ProcessSystemCallDisablePolicy, |
+ &policy, sizeof(policy))) |
rvargas (doing something else)
2015/09/16 20:15:42
nit: This requires {}
forshaw
2015/09/16 20:45:36
Done.
|
+ return policy.DisallowWin32kSystemCalls != 0; |
+ |
+ return false; |
+ } |
+ |
+ const bool value_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(LazyIsUser32AndGdi32Available); |
+}; |
+ |
const wchar_t kWindows8OSKRegPath[] = |
L"Software\\Classes\\CLSID\\{054AAE20-4BEA-4347-8A35-64A533254A9D}" |
L"\\LocalServer32"; |
@@ -537,5 +574,11 @@ bool MaybeHasSHA256Support() { |
return true; // New enough to have SHA-256 support. |
} |
+bool IsUser32AndGdi32Available() { |
+ static base::LazyInstance<LazyIsUser32AndGdi32Available>::Leaky available = |
+ LAZY_INSTANCE_INITIALIZER; |
+ return available.Get().value(); |
+} |
+ |
} // namespace win |
} // namespace base |