| 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 "base/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "sandbox/win/src/sharedmem_ipc_server.h" | 8 #include "sandbox/win/src/sharedmem_ipc_server.h" |
| 9 #include "sandbox/win/src/sharedmem_ipc_client.h" | 9 #include "sandbox/win/src/sharedmem_ipc_client.h" |
| 10 #include "sandbox/win/src/sandbox.h" | 10 #include "sandbox/win/src/sandbox.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // This last setting indicates to the client all is setup. | 124 // This last setting indicates to the client all is setup. |
| 125 client_control_->channels_count = channel_count; | 125 client_control_->channels_count = channel_count; |
| 126 return true; | 126 return true; |
| 127 } | 127 } |
| 128 | 128 |
| 129 // Releases memory allocated for IPC arguments, if needed. | 129 // Releases memory allocated for IPC arguments, if needed. |
| 130 void ReleaseArgs(const IPCParams* ipc_params, void* args[kMaxIpcParams]) { | 130 void ReleaseArgs(const IPCParams* ipc_params, void* args[kMaxIpcParams]) { |
| 131 for (size_t i = 0; i < kMaxIpcParams; i++) { | 131 for (size_t i = 0; i < kMaxIpcParams; i++) { |
| 132 switch (ipc_params->args[i]) { | 132 switch (ipc_params->args[i]) { |
| 133 case WCHAR_TYPE: { | 133 case WCHAR_TYPE: { |
| 134 delete reinterpret_cast<std::wstring*>(args[i]); | 134 delete reinterpret_cast<base::string16*>(args[i]); |
| 135 args[i] = NULL; | 135 args[i] = NULL; |
| 136 break; | 136 break; |
| 137 } | 137 } |
| 138 case INOUTPTR_TYPE: { | 138 case INOUTPTR_TYPE: { |
| 139 delete reinterpret_cast<CountedBuffer*>(args[i]); | 139 delete reinterpret_cast<CountedBuffer*>(args[i]); |
| 140 args[i] = NULL; | 140 args[i] = NULL; |
| 141 break; | 141 break; |
| 142 } | 142 } |
| 143 default: break; | 143 default: break; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 // Fills up the list of arguments (args and ipc_params) for an IPC call. | 148 // Fills up the list of arguments (args and ipc_params) for an IPC call. |
| 149 bool GetArgs(CrossCallParamsEx* params, IPCParams* ipc_params, | 149 bool GetArgs(CrossCallParamsEx* params, IPCParams* ipc_params, |
| 150 void* args[kMaxIpcParams]) { | 150 void* args[kMaxIpcParams]) { |
| 151 if (kMaxIpcParams < params->GetParamsCount()) | 151 if (kMaxIpcParams < params->GetParamsCount()) |
| 152 return false; | 152 return false; |
| 153 | 153 |
| 154 for (uint32 i = 0; i < params->GetParamsCount(); i++) { | 154 for (uint32 i = 0; i < params->GetParamsCount(); i++) { |
| 155 uint32 size; | 155 uint32 size; |
| 156 ArgType type; | 156 ArgType type; |
| 157 args[i] = params->GetRawParameter(i, &size, &type); | 157 args[i] = params->GetRawParameter(i, &size, &type); |
| 158 if (args[i]) { | 158 if (args[i]) { |
| 159 ipc_params->args[i] = type; | 159 ipc_params->args[i] = type; |
| 160 switch (type) { | 160 switch (type) { |
| 161 case WCHAR_TYPE: { | 161 case WCHAR_TYPE: { |
| 162 scoped_ptr<std::wstring> data(new std::wstring); | 162 scoped_ptr<base::string16> data(new base::string16); |
| 163 if (!params->GetParameterStr(i, data.get())) { | 163 if (!params->GetParameterStr(i, data.get())) { |
| 164 args[i] = 0; | 164 args[i] = 0; |
| 165 ReleaseArgs(ipc_params, args); | 165 ReleaseArgs(ipc_params, args); |
| 166 return false; | 166 return false; |
| 167 } | 167 } |
| 168 args[i] = data.release(); | 168 args[i] = data.release(); |
| 169 break; | 169 break; |
| 170 } | 170 } |
| 171 case ULONG_TYPE: { | 171 case ULONG_TYPE: { |
| 172 uint32 data; | 172 uint32 data; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 } | 401 } |
| 402 *server_pong = ::CreateEventW(NULL, FALSE, FALSE, NULL); | 402 *server_pong = ::CreateEventW(NULL, FALSE, FALSE, NULL); |
| 403 if (!::DuplicateHandle(::GetCurrentProcess(), *server_pong, target_process_, | 403 if (!::DuplicateHandle(::GetCurrentProcess(), *server_pong, target_process_, |
| 404 client_pong, kDesiredAccess, FALSE, 0)) { | 404 client_pong, kDesiredAccess, FALSE, 0)) { |
| 405 return false; | 405 return false; |
| 406 } | 406 } |
| 407 return true; | 407 return true; |
| 408 } | 408 } |
| 409 | 409 |
| 410 } // namespace sandbox | 410 } // namespace sandbox |
| OLD | NEW |