| 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 = {}; |
| 84 if (get_process_mitigation_policy_func(GetCurrentProcess(), |
| 85 ProcessSystemCallDisablePolicy, |
| 86 &policy, sizeof(policy))) { |
| 87 return policy.DisallowWin32kSystemCalls != 0; |
| 88 } |
| 89 |
| 90 return false; |
| 91 } |
| 92 |
| 93 const bool value_; |
| 94 |
| 95 DISALLOW_COPY_AND_ASSIGN(LazyIsUser32AndGdi32Available); |
| 96 }; |
| 97 |
| 60 const wchar_t kWindows8OSKRegPath[] = | 98 const wchar_t kWindows8OSKRegPath[] = |
| 61 L"Software\\Classes\\CLSID\\{054AAE20-4BEA-4347-8A35-64A533254A9D}" | 99 L"Software\\Classes\\CLSID\\{054AAE20-4BEA-4347-8A35-64A533254A9D}" |
| 62 L"\\LocalServer32"; | 100 L"\\LocalServer32"; |
| 63 | 101 |
| 64 } // namespace | 102 } // namespace |
| 65 | 103 |
| 66 // Returns true if a physical keyboard is detected on Windows 8 and up. | 104 // 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 | 105 // 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 | 106 // 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 | 107 // 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 | 568 // 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 | 569 // includes Windows XP x64, and Windows Server, where a hotfix could be |
| 532 // deployed. | 570 // deployed. |
| 533 if (os_info->version() == VERSION_SERVER_2003) | 571 if (os_info->version() == VERSION_SERVER_2003) |
| 534 return false; | 572 return false; |
| 535 | 573 |
| 536 DCHECK(os_info->version() >= VERSION_VISTA); | 574 DCHECK(os_info->version() >= VERSION_VISTA); |
| 537 return true; // New enough to have SHA-256 support. | 575 return true; // New enough to have SHA-256 support. |
| 538 } | 576 } |
| 539 | 577 |
| 578 bool IsUser32AndGdi32Available() { |
| 579 static base::LazyInstance<LazyIsUser32AndGdi32Available>::Leaky available = |
| 580 LAZY_INSTANCE_INITIALIZER; |
| 581 return available.Get().value(); |
| 582 } |
| 583 |
| 540 } // namespace win | 584 } // namespace win |
| 541 } // namespace base | 585 } // namespace base |
| OLD | NEW |