Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: content/ppapi_plugin/ppapi_thread.cc

Issue 1325843002: Added directwrite warmup for PPAPI processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_win32k_enable_policy
Patch Set: Made win32k lockdown check a lazy instance. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
« content/browser/ppapi_plugin_process_host.cc ('K') | « content/ppapi_plugin/ppapi_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698