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 "sandbox/win/src/process_mitigations.h" | 5 #include "sandbox/win/src/process_mitigations.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "sandbox/win/src/nt_internals.h" | 10 #include "sandbox/win/src/nt_internals.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 reinterpret_cast<SetProcessDEPPolicyFunction>( | 80 reinterpret_cast<SetProcessDEPPolicyFunction>( |
81 ::GetProcAddress(module, "SetProcessDEPPolicy")); | 81 ::GetProcAddress(module, "SetProcessDEPPolicy")); |
82 if (set_process_dep_policy) { | 82 if (set_process_dep_policy) { |
83 if (!set_process_dep_policy(dep_flags) && | 83 if (!set_process_dep_policy(dep_flags) && |
84 ERROR_ACCESS_DENIED != ::GetLastError() && return_on_fail) { | 84 ERROR_ACCESS_DENIED != ::GetLastError() && return_on_fail) { |
85 return false; | 85 return false; |
86 } | 86 } |
87 } else { | 87 } else { |
88 // We're on XP sp2, so use the less standard approach. | 88 // We're on XP sp2, so use the less standard approach. |
89 // For reference: http://www.uninformed.org/?v=2&a=4 | 89 // For reference: http://www.uninformed.org/?v=2&a=4 |
90 static const int MEM_EXECUTE_OPTION_ENABLE = 1; | |
91 static const int MEM_EXECUTE_OPTION_DISABLE = 2; | 90 static const int MEM_EXECUTE_OPTION_DISABLE = 2; |
92 static const int MEM_EXECUTE_OPTION_ATL7_THUNK_EMULATION = 4; | 91 static const int MEM_EXECUTE_OPTION_ATL7_THUNK_EMULATION = 4; |
93 static const int MEM_EXECUTE_OPTION_PERMANENT = 8; | 92 static const int MEM_EXECUTE_OPTION_PERMANENT = 8; |
94 | 93 |
95 NtSetInformationProcessFunction set_information_process = NULL; | 94 NtSetInformationProcessFunction set_information_process = NULL; |
96 ResolveNTFunctionPtr("NtSetInformationProcess", | 95 ResolveNTFunctionPtr("NtSetInformationProcess", |
97 &set_information_process); | 96 &set_information_process); |
98 if (!set_information_process) | 97 if (!set_information_process) |
99 return false; | 98 return false; |
100 ULONG dep = MEM_EXECUTE_OPTION_DISABLE | MEM_EXECUTE_OPTION_PERMANENT; | 99 ULONG dep = MEM_EXECUTE_OPTION_DISABLE | MEM_EXECUTE_OPTION_PERMANENT; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } | 321 } |
323 | 322 |
324 bool CanSetProcessMitigationsPreStartup(MitigationFlags flags) { | 323 bool CanSetProcessMitigationsPreStartup(MitigationFlags flags) { |
325 // These mitigations cannot be enabled prior to startup. | 324 // These mitigations cannot be enabled prior to startup. |
326 return !(flags & (MITIGATION_STRICT_HANDLE_CHECKS | | 325 return !(flags & (MITIGATION_STRICT_HANDLE_CHECKS | |
327 MITIGATION_DLL_SEARCH_ORDER)); | 326 MITIGATION_DLL_SEARCH_ORDER)); |
328 } | 327 } |
329 | 328 |
330 } // namespace sandbox | 329 } // namespace sandbox |
331 | 330 |
OLD | NEW |