Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Unified Diff: ipc/attachment_broker_privileged_win.cc

Issue 1281083004: ipc: Add the class HandleWin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add logging. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/attachment_broker_privileged_win.h ('k') | ipc/attachment_broker_privileged_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/attachment_broker_privileged_win.cc
diff --git a/ipc/attachment_broker_privileged_win.cc b/ipc/attachment_broker_privileged_win.cc
index 77584cff1bd3380ce1fa7edccfd36c53edab7812..c8cc1d0aaf903b5926f20e954e0a823883ca4dfa 100644
--- a/ipc/attachment_broker_privileged_win.cc
+++ b/ipc/attachment_broker_privileged_win.cc
@@ -95,6 +95,8 @@ AttachmentBrokerPrivilegedWin::DuplicateWinHandle(
HandleWireFormat new_wire_format;
new_wire_format.destination_process = wire_format.destination_process;
new_wire_format.attachment_id = wire_format.attachment_id;
+ new_wire_format.permissions = wire_format.permissions;
+ new_wire_format.handle = 0;
HANDLE original_handle = LongToHandle(wire_format.handle);
@@ -103,15 +105,28 @@ AttachmentBrokerPrivilegedWin::DuplicateWinHandle(
base::Process dest_process =
base::Process::OpenWithExtraPrivileges(wire_format.destination_process);
if (source_process.Handle() && dest_process.Handle()) {
+ DWORD desired_access = 0;
+ DWORD options = 0;
+ switch (wire_format.permissions) {
+ case HandleWin::INVALID:
+ LOG(ERROR) << "Received invalid permissions for duplication.";
+ return new_wire_format;
+ case HandleWin::DUPLICATE:
+ options = DUPLICATE_SAME_ACCESS;
+ break;
+ case HandleWin::FILE_READ_WRITE:
+ desired_access = FILE_GENERIC_READ | FILE_GENERIC_WRITE;
+ break;
+ }
+
HANDLE new_handle;
DWORD result = ::DuplicateHandle(source_process.Handle(), original_handle,
- dest_process.Handle(), &new_handle, 0,
- FALSE, DUPLICATE_SAME_ACCESS);
+ dest_process.Handle(), &new_handle,
+ desired_access, FALSE, options);
new_wire_format.handle = (result != 0) ? HandleToLong(new_handle) : 0;
- } else {
- new_wire_format.handle = 0;
}
+
return new_wire_format;
}
« no previous file with comments | « ipc/attachment_broker_privileged_win.h ('k') | ipc/attachment_broker_privileged_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698