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/sandbox_policy_base.h" | 5 #include "sandbox/win/src/sandbox_policy_base.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 ui_exceptions_ = ui_exceptions; | 166 ui_exceptions_ = ui_exceptions; |
167 return SBOX_ALL_OK; | 167 return SBOX_ALL_OK; |
168 } | 168 } |
169 | 169 |
170 ResultCode PolicyBase::SetAlternateDesktop(bool alternate_winstation) { | 170 ResultCode PolicyBase::SetAlternateDesktop(bool alternate_winstation) { |
171 use_alternate_desktop_ = true; | 171 use_alternate_desktop_ = true; |
172 use_alternate_winstation_ = alternate_winstation; | 172 use_alternate_winstation_ = alternate_winstation; |
173 return CreateAlternateDesktop(alternate_winstation); | 173 return CreateAlternateDesktop(alternate_winstation); |
174 } | 174 } |
175 | 175 |
176 string16 PolicyBase::GetAlternateDesktop() const { | 176 base::string16 PolicyBase::GetAlternateDesktop() const { |
177 // No alternate desktop or winstation. Return an empty string. | 177 // No alternate desktop or winstation. Return an empty string. |
178 if (!use_alternate_desktop_ && !use_alternate_winstation_) { | 178 if (!use_alternate_desktop_ && !use_alternate_winstation_) { |
179 return string16(); | 179 return base::string16(); |
180 } | 180 } |
181 | 181 |
182 // The desktop and winstation should have been created by now. | 182 // The desktop and winstation should have been created by now. |
183 // If we hit this scenario, it means that the user ignored the failure | 183 // If we hit this scenario, it means that the user ignored the failure |
184 // during SetAlternateDesktop, so we ignore it here too. | 184 // during SetAlternateDesktop, so we ignore it here too. |
185 if (use_alternate_desktop_ && !alternate_desktop_handle_) { | 185 if (use_alternate_desktop_ && !alternate_desktop_handle_) { |
186 return string16(); | 186 return base::string16(); |
187 } | 187 } |
188 if (use_alternate_winstation_ && (!alternate_desktop_handle_ || | 188 if (use_alternate_winstation_ && (!alternate_desktop_handle_ || |
189 !alternate_winstation_handle_)) { | 189 !alternate_winstation_handle_)) { |
190 return string16(); | 190 return base::string16(); |
191 } | 191 } |
192 | 192 |
193 return GetFullDesktopName(alternate_winstation_handle_, | 193 return GetFullDesktopName(alternate_winstation_handle_, |
194 alternate_desktop_handle_); | 194 alternate_desktop_handle_); |
195 } | 195 } |
196 | 196 |
197 ResultCode PolicyBase::CreateAlternateDesktop(bool alternate_winstation) { | 197 ResultCode PolicyBase::CreateAlternateDesktop(bool alternate_winstation) { |
198 if (alternate_winstation) { | 198 if (alternate_winstation) { |
199 // Previously called with alternate_winstation = false? | 199 // Previously called with alternate_winstation = false? |
200 if (!alternate_winstation_handle_ && alternate_desktop_handle_) | 200 if (!alternate_winstation_handle_ && alternate_desktop_handle_) |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 InterceptionManager manager(target, relaxed_interceptions_); | 642 InterceptionManager manager(target, relaxed_interceptions_); |
643 | 643 |
644 if (policy_) { | 644 if (policy_) { |
645 for (int i = 0; i < IPC_LAST_TAG; i++) { | 645 for (int i = 0; i < IPC_LAST_TAG; i++) { |
646 if (policy_->entry[i] && !ipc_targets_[i]->SetupService(&manager, i)) | 646 if (policy_->entry[i] && !ipc_targets_[i]->SetupService(&manager, i)) |
647 return false; | 647 return false; |
648 } | 648 } |
649 } | 649 } |
650 | 650 |
651 if (!blacklisted_dlls_.empty()) { | 651 if (!blacklisted_dlls_.empty()) { |
652 std::vector<string16>::iterator it = blacklisted_dlls_.begin(); | 652 std::vector<base::string16>::iterator it = blacklisted_dlls_.begin(); |
653 for (; it != blacklisted_dlls_.end(); ++it) { | 653 for (; it != blacklisted_dlls_.end(); ++it) { |
654 manager.AddToUnloadModules(it->c_str()); | 654 manager.AddToUnloadModules(it->c_str()); |
655 } | 655 } |
656 } | 656 } |
657 | 657 |
658 if (!handle_closer_.SetupHandleInterceptions(&manager)) | 658 if (!handle_closer_.SetupHandleInterceptions(&manager)) |
659 return false; | 659 return false; |
660 | 660 |
661 if (!SetupBasicInterceptions(&manager)) | 661 if (!SetupBasicInterceptions(&manager)) |
662 return false; | 662 return false; |
663 | 663 |
664 if (!manager.InitializeInterceptions()) | 664 if (!manager.InitializeInterceptions()) |
665 return false; | 665 return false; |
666 | 666 |
667 // Finally, setup imports on the target so the interceptions can work. | 667 // Finally, setup imports on the target so the interceptions can work. |
668 return SetupNtdllImports(target); | 668 return SetupNtdllImports(target); |
669 } | 669 } |
670 | 670 |
671 bool PolicyBase::SetupHandleCloser(TargetProcess* target) { | 671 bool PolicyBase::SetupHandleCloser(TargetProcess* target) { |
672 return handle_closer_.InitializeTargetHandles(target); | 672 return handle_closer_.InitializeTargetHandles(target); |
673 } | 673 } |
674 | 674 |
675 } // namespace sandbox | 675 } // namespace sandbox |
OLD | NEW |