OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
6 #include "base/win/scoped_handle.h" | 6 #include "base/win/scoped_handle.h" |
7 | 7 |
8 #include "base/win/windows_version.h" | 8 #include "base/win/windows_version.h" |
9 #include "sandbox/win/src/nt_internals.h" | 9 #include "sandbox/win/src/nt_internals.h" |
10 #include "sandbox/win/src/process_mitigations.h" | 10 #include "sandbox/win/src/process_mitigations.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 PBOOL permanent); | 23 PBOOL permanent); |
24 | 24 |
25 typedef BOOL (WINAPI *GetProcessMitigationPolicyFunction)( | 25 typedef BOOL (WINAPI *GetProcessMitigationPolicyFunction)( |
26 HANDLE process, | 26 HANDLE process, |
27 PROCESS_MITIGATION_POLICY mitigation_policy, | 27 PROCESS_MITIGATION_POLICY mitigation_policy, |
28 PVOID buffer, | 28 PVOID buffer, |
29 SIZE_T length); | 29 SIZE_T length); |
30 | 30 |
31 GetProcessMitigationPolicyFunction get_process_mitigation_policy; | 31 GetProcessMitigationPolicyFunction get_process_mitigation_policy; |
32 | 32 |
| 33 #if !defined(_WIN64) |
33 bool CheckWin8DepPolicy() { | 34 bool CheckWin8DepPolicy() { |
34 PROCESS_MITIGATION_DEP_POLICY policy = {}; | 35 PROCESS_MITIGATION_DEP_POLICY policy = {}; |
35 if (!get_process_mitigation_policy(::GetCurrentProcess(), ProcessDEPPolicy, | 36 if (!get_process_mitigation_policy(::GetCurrentProcess(), ProcessDEPPolicy, |
36 &policy, sizeof(policy))) { | 37 &policy, sizeof(policy))) { |
37 return false; | 38 return false; |
38 } | 39 } |
39 return policy.Enable && policy.Permanent; | 40 return policy.Enable && policy.Permanent; |
40 } | 41 } |
| 42 #endif // !defined(_WIN64) |
41 | 43 |
42 #if defined(NDEBUG) | 44 #if defined(NDEBUG) |
43 bool CheckWin8AslrPolicy() { | 45 bool CheckWin8AslrPolicy() { |
44 PROCESS_MITIGATION_ASLR_POLICY policy = {}; | 46 PROCESS_MITIGATION_ASLR_POLICY policy = {}; |
45 if (!get_process_mitigation_policy(::GetCurrentProcess(), ProcessASLRPolicy, | 47 if (!get_process_mitigation_policy(::GetCurrentProcess(), ProcessASLRPolicy, |
46 &policy, sizeof(policy))) { | 48 &policy, sizeof(policy))) { |
47 return false; | 49 return false; |
48 } | 50 } |
49 return policy.EnableForceRelocateImages && policy.DisallowStrippedImages; | 51 return policy.EnableForceRelocateImages && policy.DisallowStrippedImages; |
50 } | 52 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 EXPECT_EQ(policy->SetProcessMitigations(MITIGATION_WIN32K_DISABLE), | 243 EXPECT_EQ(policy->SetProcessMitigations(MITIGATION_WIN32K_DISABLE), |
242 SBOX_ALL_OK); | 244 SBOX_ALL_OK); |
243 EXPECT_EQ(policy->AddRule(sandbox::TargetPolicy::SUBSYS_WIN32K_LOCKDOWN, | 245 EXPECT_EQ(policy->AddRule(sandbox::TargetPolicy::SUBSYS_WIN32K_LOCKDOWN, |
244 sandbox::TargetPolicy::FAKE_USER_GDI_INIT, NULL), | 246 sandbox::TargetPolicy::FAKE_USER_GDI_INIT, NULL), |
245 sandbox::SBOX_ALL_OK); | 247 sandbox::SBOX_ALL_OK); |
246 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"CheckWin8Lockdown")); | 248 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"CheckWin8Lockdown")); |
247 } | 249 } |
248 | 250 |
249 } // namespace sandbox | 251 } // namespace sandbox |
250 | 252 |
OLD | NEW |