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 "chrome/browser/nacl_host/nacl_process_host.h" | 5 #include "chrome/browser/nacl_host/nacl_process_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 return false; | 972 return false; |
973 } | 973 } |
974 if (debug_exception_handler_requested_) { | 974 if (debug_exception_handler_requested_) { |
975 // The NaCl process should not request this multiple times. | 975 // The NaCl process should not request this multiple times. |
976 DLOG(ERROR) << "Multiple AttachDebugExceptionHandler requests received"; | 976 DLOG(ERROR) << "Multiple AttachDebugExceptionHandler requests received"; |
977 return false; | 977 return false; |
978 } | 978 } |
979 debug_exception_handler_requested_ = true; | 979 debug_exception_handler_requested_ = true; |
980 | 980 |
981 base::ProcessId nacl_pid = base::GetProcId(process_->GetData().handle); | 981 base::ProcessId nacl_pid = base::GetProcId(process_->GetData().handle); |
982 base::win::ScopedHandle process_handle; | 982 base::ProcessHandle temp_handle; |
983 // We cannot use process_->GetData().handle because it does not have | 983 // We cannot use process_->GetData().handle because it does not have |
984 // the necessary access rights. We open the new handle here rather | 984 // the necessary access rights. We open the new handle here rather |
985 // than in the NaCl broker process in case the NaCl loader process | 985 // than in the NaCl broker process in case the NaCl loader process |
986 // dies before the NaCl broker process receives the message we send. | 986 // dies before the NaCl broker process receives the message we send. |
987 // The debug exception handler uses DebugActiveProcess() to attach, | 987 // The debug exception handler uses DebugActiveProcess() to attach, |
988 // but this takes a PID. We need to prevent the NaCl loader's PID | 988 // but this takes a PID. We need to prevent the NaCl loader's PID |
989 // from being reused before DebugActiveProcess() is called, and | 989 // from being reused before DebugActiveProcess() is called, and |
990 // holding a process handle open achieves this. | 990 // holding a process handle open achieves this. |
991 if (!base::OpenProcessHandleWithAccess( | 991 if (!base::OpenProcessHandleWithAccess( |
992 nacl_pid, | 992 nacl_pid, |
993 base::kProcessAccessQueryInformation | | 993 base::kProcessAccessQueryInformation | |
994 base::kProcessAccessSuspendResume | | 994 base::kProcessAccessSuspendResume | |
995 base::kProcessAccessTerminate | | 995 base::kProcessAccessTerminate | |
996 base::kProcessAccessVMOperation | | 996 base::kProcessAccessVMOperation | |
997 base::kProcessAccessVMRead | | 997 base::kProcessAccessVMRead | |
998 base::kProcessAccessVMWrite | | 998 base::kProcessAccessVMWrite | |
999 base::kProcessAccessDuplicateHandle | | 999 base::kProcessAccessDuplicateHandle | |
1000 base::kProcessAccessWaitForTermination, | 1000 base::kProcessAccessWaitForTermination, |
1001 process_handle.Receive())) { | 1001 &temp_handle)) { |
1002 LOG(ERROR) << "Failed to get process handle"; | 1002 LOG(ERROR) << "Failed to get process handle"; |
1003 return false; | 1003 return false; |
1004 } | 1004 } |
| 1005 base::win::ScopedHandle process_handle; |
| 1006 process_handle.Set(temp_handle); |
1005 | 1007 |
1006 attach_debug_exception_handler_reply_msg_.reset(reply_msg); | 1008 attach_debug_exception_handler_reply_msg_.reset(reply_msg); |
1007 // If the NaCl loader is 64-bit, the process running its debug | 1009 // If the NaCl loader is 64-bit, the process running its debug |
1008 // exception handler must be 64-bit too, so we use the 64-bit NaCl | 1010 // exception handler must be 64-bit too, so we use the 64-bit NaCl |
1009 // broker process for this. Otherwise, on a 32-bit system, we use | 1011 // broker process for this. Otherwise, on a 32-bit system, we use |
1010 // the 32-bit browser process to run the debug exception handler. | 1012 // the 32-bit browser process to run the debug exception handler. |
1011 if (RunningOnWOW64()) { | 1013 if (RunningOnWOW64()) { |
1012 return NaClBrokerService::GetInstance()->LaunchDebugExceptionHandler( | 1014 return NaClBrokerService::GetInstance()->LaunchDebugExceptionHandler( |
1013 weak_factory_.GetWeakPtr(), nacl_pid, process_handle, info); | 1015 weak_factory_.GetWeakPtr(), nacl_pid, process_handle, info); |
1014 } else { | 1016 } else { |
1015 NaClStartDebugExceptionHandlerThread( | 1017 NaClStartDebugExceptionHandlerThread( |
1016 process_handle.Take(), info, | 1018 process_handle.Take(), info, |
1017 base::MessageLoopProxy::current(), | 1019 base::MessageLoopProxy::current(), |
1018 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1020 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1019 weak_factory_.GetWeakPtr())); | 1021 weak_factory_.GetWeakPtr())); |
1020 return true; | 1022 return true; |
1021 } | 1023 } |
1022 } | 1024 } |
1023 #endif | 1025 #endif |
OLD | NEW |