summaryrefslogtreecommitdiffstats
path: root/ipc/handle_attachment_win.cc
diff options
context:
space:
mode:
authorerikchen <erikchen@chromium.org>2016-01-07 18:17:04 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-08 02:18:33 +0000
commit3d87ecf7392672dbd0aaabc042caf29cf63631cf (patch)
treeb418c31376bfdffcfde85acd73f6689a1f5bfc59 /ipc/handle_attachment_win.cc
parent8fa1a1003da4c2f085e3c0610a4dbaacf37f8f75 (diff)
downloadchromium_src-3d87ecf7392672dbd0aaabc042caf29cf63631cf.zip
chromium_src-3d87ecf7392672dbd0aaabc042caf29cf63631cf.tar.gz
chromium_src-3d87ecf7392672dbd0aaabc042caf29cf63631cf.tar.bz2
ipc: Implement attachment brokering for SharedMemoryHandle on Windows.
Each SharedMemoryHandle is backed by a HANDLE, and that HANDLE is associated with a specific process. If a SharedMemoryHandle passed to IPC is associated with the current process, the IPC stack will automatically broker the handle to the destination process. This functionality has been implemented and tested, but is not yet turned on, because there are a couple of Windows-specific Chrome IPC messages that intentionally pass a HANDLE associated with another process. I will write a follow-up CL that turns on this functionality, and removes those IPC messages. BUG=493414 Review URL: https://codereview.chromium.org/1493413004 Cr-Commit-Position: refs/heads/master@{#368244}
Diffstat (limited to 'ipc/handle_attachment_win.cc')
-rw-r--r--ipc/handle_attachment_win.cc22
1 files changed, 14 insertions, 8 deletions
diff --git a/ipc/handle_attachment_win.cc b/ipc/handle_attachment_win.cc
index 5afd7fa..39c4ef7 100644
--- a/ipc/handle_attachment_win.cc
+++ b/ipc/handle_attachment_win.cc
@@ -11,18 +11,24 @@ namespace internal {
HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle,
HandleWin::Permissions permissions)
- : handle_(handle), permissions_(permissions), owns_handle_(true) {}
+ : handle_(INVALID_HANDLE_VALUE),
+ permissions_(HandleWin::INVALID),
+ owns_handle_(true) {
+ HANDLE duplicated_handle;
+ BOOL result =
+ ::DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(),
+ &duplicated_handle, 0, FALSE, DUPLICATE_SAME_ACCESS);
+ if (result) {
+ handle_ = duplicated_handle;
+ permissions_ = permissions;
+ }
+}
HandleAttachmentWin::HandleAttachmentWin(const WireFormat& wire_format)
: BrokerableAttachment(wire_format.attachment_id),
handle_(LongToHandle(wire_format.handle)),
- permissions_(wire_format.permissions), owns_handle_(false) {}
-
-HandleAttachmentWin::HandleAttachmentWin(
- const BrokerableAttachment::AttachmentId& id)
- : BrokerableAttachment(id),
- handle_(INVALID_HANDLE_VALUE),
- permissions_(HandleWin::INVALID), owns_handle_(false) {}
+ permissions_(wire_format.permissions),
+ owns_handle_(true) {}
HandleAttachmentWin::~HandleAttachmentWin() {
if (handle_ != INVALID_HANDLE_VALUE && owns_handle_)