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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // This process is the destination. | 68 // This process is the destination. |
69 if (wire_format.destination_process == base::Process::Current().Pid()) { | 69 if (wire_format.destination_process == base::Process::Current().Pid()) { |
70 scoped_refptr<BrokerableAttachment> attachment( | 70 scoped_refptr<BrokerableAttachment> attachment( |
71 new internal::HandleAttachmentWin(wire_format)); | 71 new internal::HandleAttachmentWin(wire_format)); |
72 HandleReceivedAttachment(attachment); | 72 HandleReceivedAttachment(attachment); |
73 return; | 73 return; |
74 } | 74 } |
75 | 75 |
76 // Another process is the destination. | 76 // Another process is the destination. |
77 base::ProcessId dest = wire_format.destination_process; | 77 base::ProcessId dest = wire_format.destination_process; |
78 Channel* channel = GetChannelWithProcessId(dest); | 78 Sender* sender = GetSenderWithProcessId(dest); |
79 if (!channel) { | 79 if (!sender) { |
80 // Assuming that this message was not sent from a malicious process, the | 80 // Assuming that this message was not sent from a malicious process, the |
81 // channel endpoint that would have received this message will block | 81 // channel endpoint that would have received this message will block |
82 // forever. | 82 // forever. |
83 LOG(ERROR) << "Failed to deliver brokerable attachment to process with id: " | 83 LOG(ERROR) << "Failed to deliver brokerable attachment to process with id: " |
84 << dest; | 84 << dest; |
85 return; | 85 return; |
86 } | 86 } |
87 | 87 |
88 channel->Send( | 88 sender->Send(new AttachmentBrokerMsg_WinHandleHasBeenDuplicated(wire_format)); |
89 new AttachmentBrokerMsg_WinHandleHasBeenDuplicated(wire_format)); | |
90 } | 89 } |
91 | 90 |
92 AttachmentBrokerPrivilegedWin::HandleWireFormat | 91 AttachmentBrokerPrivilegedWin::HandleWireFormat |
93 AttachmentBrokerPrivilegedWin::DuplicateWinHandle( | 92 AttachmentBrokerPrivilegedWin::DuplicateWinHandle( |
94 const HandleWireFormat& wire_format, | 93 const HandleWireFormat& wire_format, |
95 base::ProcessId source_pid) { | 94 base::ProcessId source_pid) { |
96 HandleWireFormat new_wire_format; | 95 HandleWireFormat new_wire_format; |
97 new_wire_format.destination_process = wire_format.destination_process; | 96 new_wire_format.destination_process = wire_format.destination_process; |
98 new_wire_format.attachment_id = wire_format.attachment_id; | 97 new_wire_format.attachment_id = wire_format.attachment_id; |
99 | 98 |
(...skipping 10 matching lines...) Expand all Loading... |
110 FALSE, DUPLICATE_SAME_ACCESS); | 109 FALSE, DUPLICATE_SAME_ACCESS); |
111 | 110 |
112 new_wire_format.handle = (result != 0) ? HandleToLong(new_handle) : 0; | 111 new_wire_format.handle = (result != 0) ? HandleToLong(new_handle) : 0; |
113 } else { | 112 } else { |
114 new_wire_format.handle = 0; | 113 new_wire_format.handle = 0; |
115 } | 114 } |
116 return new_wire_format; | 115 return new_wire_format; |
117 } | 116 } |
118 | 117 |
119 } // namespace IPC | 118 } // namespace IPC |
OLD | NEW |