OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ipc/attachment_broker_privileged_win.h" | 5 #include "ipc/attachment_broker_privileged_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/process/process.h" | 9 #include "base/process/process.h" |
10 #include "ipc/attachment_broker_messages.h" | 10 #include "ipc/attachment_broker_messages.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 if (wire_format.destination_process == base::Process::Current().Pid()) { | 77 if (wire_format.destination_process == base::Process::Current().Pid()) { |
78 scoped_refptr<BrokerableAttachment> attachment( | 78 scoped_refptr<BrokerableAttachment> attachment( |
79 new internal::HandleAttachmentWin(wire_format)); | 79 new internal::HandleAttachmentWin(wire_format)); |
80 HandleReceivedAttachment(attachment); | 80 HandleReceivedAttachment(attachment); |
81 return; | 81 return; |
82 } | 82 } |
83 | 83 |
84 // Another process is the destination. | 84 // Another process is the destination. |
85 base::ProcessId dest = wire_format.destination_process; | 85 base::ProcessId dest = wire_format.destination_process; |
86 base::AutoLock auto_lock(*get_lock()); | 86 base::AutoLock auto_lock(*get_lock()); |
87 Sender* sender = GetSenderWithProcessId(dest); | 87 AttachmentBrokerPrivileged::EndpointRunnerPair pair = |
88 if (!sender) { | 88 GetSenderWithProcessId(dest); |
| 89 if (!pair.first) { |
89 // Assuming that this message was not sent from a malicious process, the | 90 // Assuming that this message was not sent from a malicious process, the |
90 // channel endpoint that would have received this message will block | 91 // channel endpoint that would have received this message will block |
91 // forever. | 92 // forever. |
92 LOG(ERROR) << "Failed to deliver brokerable attachment to process with id: " | 93 LOG(ERROR) << "Failed to deliver brokerable attachment to process with id: " |
93 << dest; | 94 << dest; |
94 LogError(DESTINATION_NOT_FOUND); | 95 LogError(DESTINATION_NOT_FOUND); |
95 return; | 96 return; |
96 } | 97 } |
97 | 98 |
98 LogError(DESTINATION_FOUND); | 99 LogError(DESTINATION_FOUND); |
99 sender->Send(new AttachmentBrokerMsg_WinHandleHasBeenDuplicated(wire_format)); | 100 SendMessageToEndpoint( |
| 101 pair, new AttachmentBrokerMsg_WinHandleHasBeenDuplicated(wire_format)); |
100 } | 102 } |
101 | 103 |
102 AttachmentBrokerPrivilegedWin::HandleWireFormat | 104 AttachmentBrokerPrivilegedWin::HandleWireFormat |
103 AttachmentBrokerPrivilegedWin::DuplicateWinHandle( | 105 AttachmentBrokerPrivilegedWin::DuplicateWinHandle( |
104 const HandleWireFormat& wire_format, | 106 const HandleWireFormat& wire_format, |
105 base::ProcessId source_pid) { | 107 base::ProcessId source_pid) { |
106 // If the source process is the destination process, then no additional work | 108 // If the source process is the destination process, then no additional work |
107 // is required. | 109 // is required. |
108 if (source_pid == wire_format.destination_process) | 110 if (source_pid == wire_format.destination_process) |
109 return wire_format; | 111 return wire_format; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 149 |
148 AttachmentBrokerPrivilegedWin::HandleWireFormat | 150 AttachmentBrokerPrivilegedWin::HandleWireFormat |
149 AttachmentBrokerPrivilegedWin::CopyWireFormat( | 151 AttachmentBrokerPrivilegedWin::CopyWireFormat( |
150 const HandleWireFormat& wire_format, | 152 const HandleWireFormat& wire_format, |
151 int handle) { | 153 int handle) { |
152 return HandleWireFormat(handle, wire_format.destination_process, | 154 return HandleWireFormat(handle, wire_format.destination_process, |
153 wire_format.permissions, wire_format.attachment_id); | 155 wire_format.permissions, wire_format.attachment_id); |
154 } | 156 } |
155 | 157 |
156 } // namespace IPC | 158 } // namespace IPC |
OLD | NEW |