Index: content/ppapi_plugin/ppapi_thread.cc |
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc |
index 6b2dc122a0ede2a332736be5f645593cfd8f701b..907b12b0f5cdb6011e51969a429a0275aecbb18c 100644 |
--- a/content/ppapi_plugin/ppapi_thread.cc |
+++ b/content/ppapi_plugin/ppapi_thread.cc |
@@ -10,6 +10,7 @@ |
#include "base/cpu.h" |
#include "base/debug/crash_logging.h" |
#include "base/files/file_util.h" |
+#include "base/lazy_instance.h" |
#include "base/logging.h" |
#include "base/memory/discardable_memory_allocator.h" |
#include "base/metrics/histogram.h" |
@@ -97,8 +98,49 @@ static void WarmupWindowsLocales(const ppapi::PpapiPermissions& permissions) { |
#endif |
+typedef decltype(GetProcessMitigationPolicy)* GetProcessMitigationPolicyType; |
+ |
+// Get win32k lockdown policy using a lazy instance so it's only initialized |
palmer
2015/09/15 21:43:43
This is copied and pasted from another CL, right?
forshaw
2015/09/15 21:59:32
I'd love to. Initially I had it in base but wfh@ r
|
+// once and is thread-safe. |
+class LazyIsWin32kLockdownEnabled { |
+ public: |
+ LazyIsWin32kLockdownEnabled() : value_(IsWin32kLockdownEnabled()) {} |
+ |
+ ~LazyIsWin32kLockdownEnabled() {} |
+ |
+ bool value() { return value_; } |
+ |
+ private: |
+ static bool IsWin32kLockdownEnabled() { |
+ 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}; |
+ if (get_process_mitigation_policy_func(GetCurrentProcess(), |
+ ProcessSystemCallDisablePolicy, |
+ &policy, sizeof(policy))) |
+ return policy.DisallowWin32kSystemCalls != 0; |
+ |
+ return false; |
+ } |
+ |
+ const bool value_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(LazyIsWin32kLockdownEnabled); |
+}; |
+ |
namespace content { |
+bool IsWin32kLockdownEnabled() { |
+ static base::LazyInstance<LazyIsWin32kLockdownEnabled> win32k_lockdown = |
+ LAZY_INSTANCE_INITIALIZER; |
+ return win32k_lockdown.Get().value(); |
+} |
+ |
typedef int32_t (*InitializeBrokerFunc) |
(PP_ConnectInstance_Func* connect_instance_func); |