Avi Drissman | ea1be23 | 2022-09-14 23:29:06 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors |
erikchen | eece6c3 | 2015-07-07 22:13:11 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ipc/handle_attachment_win.h" |
| 6 | |
| 7 | #include <windows.h> |
| 8 | |
| 9 | namespace IPC { |
| 10 | namespace internal { |
| 11 | |
Wez | 51eaaad | 2017-08-09 05:51:38 | [diff] [blame] | 12 | HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle) { |
erikchen | 3d87ecf7 | 2016-01-08 02:17:04 | [diff] [blame] | 13 | HANDLE duplicated_handle; |
| 14 | BOOL result = |
| 15 | ::DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(), |
| 16 | &duplicated_handle, 0, FALSE, DUPLICATE_SAME_ACCESS); |
| 17 | if (result) { |
Wez | 51eaaad | 2017-08-09 05:51:38 | [diff] [blame] | 18 | handle_.Set(duplicated_handle); |
erikchen | 3d87ecf7 | 2016-01-08 02:17:04 | [diff] [blame] | 19 | } |
| 20 | } |
erikchen | eece6c3 | 2015-07-07 22:13:11 | [diff] [blame] | 21 | |
sammc | 57ed9f98 | 2016-03-10 06:28:35 | [diff] [blame] | 22 | HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle, |
| 23 | FromWire from_wire) |
Wez | 51eaaad | 2017-08-09 05:51:38 | [diff] [blame] | 24 | : handle_(handle) {} |
sammc | 57ed9f98 | 2016-03-10 06:28:35 | [diff] [blame] | 25 | |
Wez | 51eaaad | 2017-08-09 05:51:38 | [diff] [blame] | 26 | HandleAttachmentWin::~HandleAttachmentWin() {} |
erikchen | eece6c3 | 2015-07-07 22:13:11 | [diff] [blame] | 27 | |
sammc | 6ed3efb | 2016-11-23 03:17:35 | [diff] [blame] | 28 | MessageAttachment::Type HandleAttachmentWin::GetType() const { |
| 29 | return Type::WIN_HANDLE; |
erikchen | eece6c3 | 2015-07-07 22:13:11 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | } // namespace internal |
| 33 | } // namespace IPC |