OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/win/win_util.h" | 5 #include "base/win/win_util.h" |
6 | 6 |
7 #include <aclapi.h> | 7 #include <aclapi.h> |
8 #include <cfgmgr32.h> | 8 #include <cfgmgr32.h> |
9 #include <lm.h> | 9 #include <lm.h> |
10 #include <powrprof.h> | 10 #include <powrprof.h> |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 HRESULT result = property_store->SetValue(property_key, property_value.get()); | 50 HRESULT result = property_store->SetValue(property_key, property_value.get()); |
51 if (result == S_OK) | 51 if (result == S_OK) |
52 result = property_store->Commit(); | 52 result = property_store->Commit(); |
53 return SUCCEEDED(result); | 53 return SUCCEEDED(result); |
54 } | 54 } |
55 | 55 |
56 void __cdecl ForceCrashOnSigAbort(int) { | 56 void __cdecl ForceCrashOnSigAbort(int) { |
57 *((volatile int*)0) = 0x1337; | 57 *((volatile int*)0) = 0x1337; |
58 } | 58 } |
59 | 59 |
60 typedef decltype(GetProcessMitigationPolicy)* GetProcessMitigationPolicyType; | |
61 | |
62 class LazyIsUser32AndGdi32Available { | |
63 public: | |
64 LazyIsUser32AndGdi32Available() : value_(!IsWin32kSyscallsDisabled()) {} | |
65 | |
66 ~LazyIsUser32AndGdi32Available() {} | |
67 | |
68 bool value() { return value_; } | |
69 | |
70 private: | |
71 static bool IsWin32kSyscallsDisabled() { | |
72 // Can't disable win32k prior to windows 8. | |
73 if (base::win::GetVersion() < base::win::VERSION_WIN8) | |
74 return false; | |
75 | |
76 GetProcessMitigationPolicyType get_process_mitigation_policy_func = | |
77 reinterpret_cast<GetProcessMitigationPolicyType>(GetProcAddress( | |
78 GetModuleHandle(L"kernel32.dll"), "GetProcessMitigationPolicy")); | |
79 | |
80 if (!get_process_mitigation_policy_func) | |
81 return false; | |
82 | |
83 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.
| |
84 if (get_process_mitigation_policy_func(GetCurrentProcess(), | |
85 ProcessSystemCallDisablePolicy, | |
86 &policy, sizeof(policy))) | |
rvargas (doing something else)
2015/09/16 20:15:42
nit: This requires {}
forshaw
2015/09/16 20:45:36
Done.
| |
87 return policy.DisallowWin32kSystemCalls != 0; | |
88 | |
89 return false; | |
90 } | |
91 | |
92 const bool value_; | |
93 | |
94 DISALLOW_COPY_AND_ASSIGN(LazyIsUser32AndGdi32Available); | |
95 }; | |
96 | |
60 const wchar_t kWindows8OSKRegPath[] = | 97 const wchar_t kWindows8OSKRegPath[] = |
61 L"Software\\Classes\\CLSID\\{054AAE20-4BEA-4347-8A35-64A533254A9D}" | 98 L"Software\\Classes\\CLSID\\{054AAE20-4BEA-4347-8A35-64A533254A9D}" |
62 L"\\LocalServer32"; | 99 L"\\LocalServer32"; |
63 | 100 |
64 } // namespace | 101 } // namespace |
65 | 102 |
66 // Returns true if a physical keyboard is detected on Windows 8 and up. | 103 // Returns true if a physical keyboard is detected on Windows 8 and up. |
67 // Uses the Setup APIs to enumerate the attached keyboards and returns true | 104 // Uses the Setup APIs to enumerate the attached keyboards and returns true |
68 // if the keyboard count is 1 or more.. While this will work in most cases | 105 // if the keyboard count is 1 or more.. While this will work in most cases |
69 // it won't work if there are devices which expose keyboard interfaces which | 106 // it won't work if there are devices which expose keyboard interfaces which |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 // Assume it is missing in this case, although it may not be. This category | 567 // Assume it is missing in this case, although it may not be. This category |
531 // includes Windows XP x64, and Windows Server, where a hotfix could be | 568 // includes Windows XP x64, and Windows Server, where a hotfix could be |
532 // deployed. | 569 // deployed. |
533 if (os_info->version() == VERSION_SERVER_2003) | 570 if (os_info->version() == VERSION_SERVER_2003) |
534 return false; | 571 return false; |
535 | 572 |
536 DCHECK(os_info->version() >= VERSION_VISTA); | 573 DCHECK(os_info->version() >= VERSION_VISTA); |
537 return true; // New enough to have SHA-256 support. | 574 return true; // New enough to have SHA-256 support. |
538 } | 575 } |
539 | 576 |
577 bool IsUser32AndGdi32Available() { | |
578 static base::LazyInstance<LazyIsUser32AndGdi32Available>::Leaky available = | |
579 LAZY_INSTANCE_INITIALIZER; | |
580 return available.Get().value(); | |
581 } | |
582 | |
540 } // namespace win | 583 } // namespace win |
541 } // namespace base | 584 } // namespace base |
OLD | NEW |