OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sandbox/win/src/handle_policy.h" | 5 #include "sandbox/win/src/handle_policy.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/win/scoped_handle.h" | 9 #include "base/win/scoped_handle.h" |
10 #include "sandbox/win/src/broker_services.h" | 10 #include "sandbox/win/src/broker_services.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 remote_target_process.Set(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, | 72 remote_target_process.Set(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, |
73 target_process_id)); | 73 target_process_id)); |
74 if (!remote_target_process.IsValid()) | 74 if (!remote_target_process.IsValid()) |
75 return ::GetLastError(); | 75 return ::GetLastError(); |
76 } | 76 } |
77 | 77 |
78 // If the policy didn't block us and we have no valid target, then the broker | 78 // If the policy didn't block us and we have no valid target, then the broker |
79 // (this process) is the valid target. | 79 // (this process) is the valid target. |
80 HANDLE target_process = remote_target_process.IsValid() ? | 80 HANDLE target_process = remote_target_process.IsValid() ? |
81 remote_target_process.Get() : ::GetCurrentProcess(); | 81 remote_target_process.Get() : ::GetCurrentProcess(); |
82 DWORD result = ERROR_SUCCESS; | |
83 if (!::DuplicateHandle(::GetCurrentProcess(), source_handle, target_process, | 82 if (!::DuplicateHandle(::GetCurrentProcess(), source_handle, target_process, |
84 target_handle, desired_access, FALSE, | 83 target_handle, desired_access, FALSE, |
85 options)) { | 84 options)) { |
86 return ::GetLastError(); | 85 return ::GetLastError(); |
87 } | 86 } |
88 | 87 |
89 return ERROR_SUCCESS; | 88 return ERROR_SUCCESS; |
90 } | 89 } |
91 | 90 |
92 } // namespace sandbox | 91 } // namespace sandbox |
93 | 92 |
OLD | NEW |