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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 void AttachmentBrokerPrivilegedWin::OnDuplicateWinHandle( | 54 void AttachmentBrokerPrivilegedWin::OnDuplicateWinHandle( |
55 const IPC::Message& message) { | 55 const IPC::Message& message) { |
56 AttachmentBrokerMsg_DuplicateWinHandle::Param param; | 56 AttachmentBrokerMsg_DuplicateWinHandle::Param param; |
57 if (!AttachmentBrokerMsg_DuplicateWinHandle::Read(&message, ¶m)) | 57 if (!AttachmentBrokerMsg_DuplicateWinHandle::Read(&message, ¶m)) |
58 return; | 58 return; |
59 IPC::internal::HandleAttachmentWin::WireFormat wire_format = | 59 IPC::internal::HandleAttachmentWin::WireFormat wire_format = |
60 base::get<0>(param); | 60 base::get<0>(param); |
61 | 61 |
62 if (wire_format.destination_process == base::kNullProcessId) | 62 if (wire_format.destination_process == base::kNullProcessId) { |
| 63 LogError(NO_DESTINATION); |
63 return; | 64 return; |
| 65 } |
64 | 66 |
65 HandleWireFormat new_wire_format = | 67 HandleWireFormat new_wire_format = |
66 DuplicateWinHandle(wire_format, message.get_sender_pid()); | 68 DuplicateWinHandle(wire_format, message.get_sender_pid()); |
67 RouteDuplicatedHandle(new_wire_format); | 69 RouteDuplicatedHandle(new_wire_format); |
68 } | 70 } |
69 | 71 |
70 void AttachmentBrokerPrivilegedWin::RouteDuplicatedHandle( | 72 void AttachmentBrokerPrivilegedWin::RouteDuplicatedHandle( |
71 const HandleWireFormat& wire_format) { | 73 const HandleWireFormat& wire_format) { |
72 // This process is the destination. | 74 // This process is the destination. |
73 if (wire_format.destination_process == base::Process::Current().Pid()) { | 75 if (wire_format.destination_process == base::Process::Current().Pid()) { |
74 scoped_refptr<BrokerableAttachment> attachment( | 76 scoped_refptr<BrokerableAttachment> attachment( |
75 new internal::HandleAttachmentWin(wire_format)); | 77 new internal::HandleAttachmentWin(wire_format)); |
76 HandleReceivedAttachment(attachment); | 78 HandleReceivedAttachment(attachment); |
77 return; | 79 return; |
78 } | 80 } |
79 | 81 |
80 // Another process is the destination. | 82 // Another process is the destination. |
81 base::ProcessId dest = wire_format.destination_process; | 83 base::ProcessId dest = wire_format.destination_process; |
82 Sender* sender = GetSenderWithProcessId(dest); | 84 Sender* sender = GetSenderWithProcessId(dest); |
83 if (!sender) { | 85 if (!sender) { |
84 // Assuming that this message was not sent from a malicious process, the | 86 // Assuming that this message was not sent from a malicious process, the |
85 // channel endpoint that would have received this message will block | 87 // channel endpoint that would have received this message will block |
86 // forever. | 88 // forever. |
87 LOG(ERROR) << "Failed to deliver brokerable attachment to process with id: " | 89 LOG(ERROR) << "Failed to deliver brokerable attachment to process with id: " |
88 << dest; | 90 << dest; |
| 91 LogError(DESTINATION_NOT_FOUND); |
89 return; | 92 return; |
90 } | 93 } |
91 | 94 |
| 95 LogError(DESTINATION_FOUND); |
92 sender->Send(new AttachmentBrokerMsg_WinHandleHasBeenDuplicated(wire_format)); | 96 sender->Send(new AttachmentBrokerMsg_WinHandleHasBeenDuplicated(wire_format)); |
93 } | 97 } |
94 | 98 |
95 AttachmentBrokerPrivilegedWin::HandleWireFormat | 99 AttachmentBrokerPrivilegedWin::HandleWireFormat |
96 AttachmentBrokerPrivilegedWin::DuplicateWinHandle( | 100 AttachmentBrokerPrivilegedWin::DuplicateWinHandle( |
97 const HandleWireFormat& wire_format, | 101 const HandleWireFormat& wire_format, |
98 base::ProcessId source_pid) { | 102 base::ProcessId source_pid) { |
99 HandleWireFormat new_wire_format; | 103 HandleWireFormat new_wire_format; |
100 new_wire_format.destination_process = wire_format.destination_process; | 104 new_wire_format.destination_process = wire_format.destination_process; |
101 new_wire_format.attachment_id = wire_format.attachment_id; | 105 new_wire_format.attachment_id = wire_format.attachment_id; |
(...skipping 26 matching lines...) Expand all Loading... |
128 dest_process.Handle(), &new_handle, | 132 dest_process.Handle(), &new_handle, |
129 desired_access, FALSE, options); | 133 desired_access, FALSE, options); |
130 | 134 |
131 new_wire_format.handle = (result != 0) ? HandleToLong(new_handle) : 0; | 135 new_wire_format.handle = (result != 0) ? HandleToLong(new_handle) : 0; |
132 } | 136 } |
133 | 137 |
134 return new_wire_format; | 138 return new_wire_format; |
135 } | 139 } |
136 | 140 |
137 } // namespace IPC | 141 } // namespace IPC |
OLD | NEW |