Bug 47500 - Need a way to pass HANDLEs between processes on Windows
Summary: Need a way to pass HANDLEs between processes on Windows
Status: RESOLVED DUPLICATE of bug 47499
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows XP
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar, PlatformOnly
Depends on:
Blocks: 47499
  Show dependency treegraph
 
Reported: 2010-10-11 12:16 PDT by Adam Roben (:aroben)
Modified: 2010-10-11 15:21 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Roben (:aroben) 2010-10-11 12:16:23 PDT
In order to implement WebKit2's SharedMemory class (bug 47499), we'll need a way to pass HANDLEs (specifically, those representing file-mapping objects) across processes.
Comment 1 Adam Roben (:aroben) 2010-10-11 12:25:14 PDT
In order to pass a HANDLE between processes, we'll need to call ::DuplicateHandle to copy the handle into the target process. But doing this requires knowing what the target process is, which is not known at argument-encoding time.

Anders suggests that we use CoreIPC::Attachment for this. Specifically, we'd:

A1) Make CoreIPC::Connection perform a handshake that exchanges process HANDLEs between the two ends of the connection (on Vista and newer we could perhaps use ::GetNamedPipeClientProcessId/::GetNamedPipeServerProcessId to simplify this)
A2) Use the process HANDLE received in the handshake to call ::DuplicateHandle when sending the message

I think another option that wouldn't require the handshake is:

B1) Call ::DuplicateHandle to duplicate the HANDLE in the source process at argument-encoding time
B2) Send both the HANDLE and the source process's PID in the message to the target process
B3) When the message is received in the target process, call ::DuplicateHandle to copy the handle into the target process and pass DUPLICATE_CLOSE_SOURCE to close the HANDLE the source process made in (B1)

I'm not positive that the ::DuplicateHandle call in (B3) will actually succeed, however. Maybe Windows doesn't allow it to be used like this.
Comment 2 Adam Roben (:aroben) 2010-10-11 12:26:02 PDT
<rdar://problem/8536804>
Comment 3 Adam Roben (:aroben) 2010-10-11 15:21:16 PDT

*** This bug has been marked as a duplicate of bug 47499 ***