Index: sandbox/win/src/broker_services.cc |
=================================================================== |
--- sandbox/win/src/broker_services.cc (revision 154997) |
+++ sandbox/win/src/broker_services.cc (working copy) |
@@ -12,6 +12,7 @@ |
#include "base/win/startup_information.h" |
#include "base/win/windows_version.h" |
#include "sandbox/win/src/app_container.h" |
+#include "sandbox/win/src/process_mitigations.h" |
#include "sandbox/win/src/sandbox_policy_base.h" |
#include "sandbox/win/src/sandbox.h" |
#include "sandbox/win/src/target_process.h" |
@@ -320,14 +321,45 @@ |
const_cast<wchar_t*>(desktop.c_str()); |
} |
+ int attribute_count = 0; |
const AppContainerAttributes* app_container = policy_base->GetAppContainer(); |
+ if (app_container) |
+ ++attribute_count; |
+ |
+ DWORD64 mitigations = GetProcessMitigationPolicyFlags( |
+ policy->GetProcessMitigations()); |
+ if (mitigations) |
+ ++attribute_count; |
+ |
+ if (!startup_info.InitializeProcThreadAttributeList(attribute_count)) |
+ return SBOX_ERROR_GENERIC; |
+ |
if (app_container) { |
- startup_info.InitializeProcThreadAttributeList(1); |
result = app_container->ShareForStartup(&startup_info); |
if (SBOX_ALL_OK != result) |
return result; |
} |
+ if (mitigations) { |
+ size_t mitigation_size = sizeof(mitigations); |
+ void* mitigation_ptr = &mitigations; |
+ |
+#ifndef _WIN64 |
+ // A 64-bit flags attribute is illegal on 32-bit Win 7 and below. |
+ DWORD mitigations32 = static_cast<DWORD>(mitigations); |
+ if (base::win::GetVersion() < base::win::VERSION_WIN8) { |
+ mitigation_size = sizeof(mitigations32); |
+ mitigation_ptr = &mitigations32; |
+ } |
+#endif |
cpu_(ooo_6.6-7.5)
2012/09/06 19:46:15
this would be clearer to me if instead you have so
jschuh
2012/09/07 01:14:22
Done.
|
+ |
+ if (!startup_info.UpdateProcThreadAttribute( |
+ PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY, mitigation_ptr, |
+ mitigation_size)) { |
+ return SBOX_ERROR_GENERIC; |
+ } |
+ } |
+ |
// Construct the thread pool here in case it is expensive. |
// The thread pool is shared by all the targets |
if (NULL == thread_pool_) |