| 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 #ifndef SANDBOX_SRC_CROSSCALL_CLIENT_H_ | 5 #ifndef SANDBOX_SRC_CROSSCALL_CLIENT_H_ |
| 6 #define SANDBOX_SRC_CROSSCALL_CLIENT_H_ | 6 #define SANDBOX_SRC_CROSSCALL_CLIENT_H_ |
| 7 | 7 |
| 8 #include "sandbox/win/src/crosscall_params.h" | 8 #include "sandbox/win/src/crosscall_params.h" |
| 9 #include "sandbox/win/src/sandbox.h" | 9 #include "sandbox/win/src/sandbox.h" |
| 10 | 10 |
| 11 // This header defines the CrossCall(..) family of templated functions | 11 // This header defines the CrossCall(..) family of templated functions |
| 12 // Their purpose is to simulate the syntax of regular call but to generate | 12 // Their purpose is to simulate the syntax of regular call but to generate |
| 13 // and IPC from the client-side. | 13 // and IPC from the client-side. |
| 14 // | 14 // |
| 15 // The basic pattern is to | 15 // The basic pattern is to |
| 16 // 1) use template argument deduction to compute the size of each | 16 // 1) use template argument deduction to compute the size of each |
| 17 // parameter and the appropriate copy method | 17 // parameter and the appropriate copy method |
| 18 // 2) pack the parameters in the appropriate ActualCallParams< > object | 18 // 2) pack the parameters in the appropriate ActualCallParams< > object |
| 19 // 3) call the IPC interface IPCProvider::DoCall( ) | 19 // 3) call the IPC interface IPCProvider::DoCall( ) |
| 20 // | 20 // |
| 21 // The general interface of CrossCall is: | 21 // The general interface of CrossCall is: |
| 22 // ResultCode CrossCall(IPCProvider& ipc_provider, | 22 // ResultCode CrossCall(IPCProvider& ipc_provider, |
| 23 // uint32 tag, | 23 // uint32_t tag, |
| 24 // const Par1& p1, const Par2& p2,...pn | 24 // const Par1& p1, const Par2& p2,...pn |
| 25 // CrossCallReturn* answer) | 25 // CrossCallReturn* answer) |
| 26 // | 26 // |
| 27 // where: | 27 // where: |
| 28 // ipc_provider: is a specific implementation of the ipc transport see | 28 // ipc_provider: is a specific implementation of the ipc transport see |
| 29 // sharedmem_ipc_server.h for an example. | 29 // sharedmem_ipc_server.h for an example. |
| 30 // tag : is the unique id for this IPC call. Is used to route the call to | 30 // tag : is the unique id for this IPC call. Is used to route the call to |
| 31 // the appropriate service. | 31 // the appropriate service. |
| 32 // p1, p2,.. pn : The input parameters of the IPC. Use only simple types | 32 // p1, p2,.. pn : The input parameters of the IPC. Use only simple types |
| 33 // and wide strings (can add support for others). | 33 // and wide strings (can add support for others). |
| 34 // answer : If the IPC was successful. The server-side answer is here. The | 34 // answer : If the IPC was successful. The server-side answer is here. The |
| 35 // interpretation of the answer is private to client and server. | 35 // interpretation of the answer is private to client and server. |
| 36 // | 36 // |
| 37 // The return value is ALL_OK if the IPC was delivered to the server, other | 37 // The return value is ALL_OK if the IPC was delivered to the server, other |
| 38 // return codes indicate that the IPC transport failed to deliver it. | 38 // return codes indicate that the IPC transport failed to deliver it. |
| 39 namespace sandbox { | 39 namespace sandbox { |
| 40 | 40 |
| 41 // this is the assumed channel size. This can be overridden in a given | 41 // this is the assumed channel size. This can be overridden in a given |
| 42 // IPC implementation. | 42 // IPC implementation. |
| 43 const uint32 kIPCChannelSize = 1024; | 43 const uint32_t kIPCChannelSize = 1024; |
| 44 | 44 |
| 45 // The copy helper uses templates to deduce the appropriate copy function to | 45 // The copy helper uses templates to deduce the appropriate copy function to |
| 46 // copy the input parameters in the buffer that is going to be send across the | 46 // copy the input parameters in the buffer that is going to be send across the |
| 47 // IPC. These template facility can be made more sophisticated as need arises. | 47 // IPC. These template facility can be made more sophisticated as need arises. |
| 48 | 48 |
| 49 // The default copy helper. It catches the general case where no other | 49 // The default copy helper. It catches the general case where no other |
| 50 // specialized template matches better. We set the type to UINT32_TYPE, so this | 50 // specialized template matches better. We set the type to UINT32_TYPE, so this |
| 51 // only works with objects whose size is 32 bits. | 51 // only works with objects whose size is 32 bits. |
| 52 template<typename T> | 52 template<typename T> |
| 53 class CopyHelper { | 53 class CopyHelper { |
| 54 public: | 54 public: |
| 55 CopyHelper(const T& t) : t_(t) {} | 55 CopyHelper(const T& t) : t_(t) {} |
| 56 | 56 |
| 57 // Returns the pointer to the start of the input. | 57 // Returns the pointer to the start of the input. |
| 58 const void* GetStart() const { | 58 const void* GetStart() const { |
| 59 return &t_; | 59 return &t_; |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Update the stored value with the value in the buffer. This is not | 62 // Update the stored value with the value in the buffer. This is not |
| 63 // supported for this type. | 63 // supported for this type. |
| 64 bool Update(void* buffer) { | 64 bool Update(void* buffer) { |
| 65 // Not supported; | 65 // Not supported; |
| 66 return true; | 66 return true; |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Returns the size of the input in bytes. | 69 // Returns the size of the input in bytes. |
| 70 uint32 GetSize() const { | 70 uint32_t GetSize() const { return sizeof(T); } |
| 71 return sizeof(T); | |
| 72 } | |
| 73 | 71 |
| 74 // Returns true if the current type is used as an In or InOut parameter. | 72 // Returns true if the current type is used as an In or InOut parameter. |
| 75 bool IsInOut() { | 73 bool IsInOut() { |
| 76 return false; | 74 return false; |
| 77 } | 75 } |
| 78 | 76 |
| 79 // Returns this object's type. | 77 // Returns this object's type. |
| 80 ArgType GetType() { | 78 ArgType GetType() { |
| 81 static_assert(sizeof(T) == sizeof(uint32), "specialization needed"); | 79 static_assert(sizeof(T) == sizeof(uint32_t), "specialization needed"); |
| 82 return UINT32_TYPE; | 80 return UINT32_TYPE; |
| 83 } | 81 } |
| 84 | 82 |
| 85 private: | 83 private: |
| 86 const T& t_; | 84 const T& t_; |
| 87 }; | 85 }; |
| 88 | 86 |
| 89 // This copy helper template specialization if for the void pointer | 87 // This copy helper template specialization if for the void pointer |
| 90 // case both 32 and 64 bit. | 88 // case both 32 and 64 bit. |
| 91 template<> | 89 template<> |
| 92 class CopyHelper<void*> { | 90 class CopyHelper<void*> { |
| 93 public: | 91 public: |
| 94 CopyHelper(void* t) : t_(t) {} | 92 CopyHelper(void* t) : t_(t) {} |
| 95 | 93 |
| 96 // Returns the pointer to the start of the input. | 94 // Returns the pointer to the start of the input. |
| 97 const void* GetStart() const { | 95 const void* GetStart() const { |
| 98 return &t_; | 96 return &t_; |
| 99 } | 97 } |
| 100 | 98 |
| 101 // Update the stored value with the value in the buffer. This is not | 99 // Update the stored value with the value in the buffer. This is not |
| 102 // supported for this type. | 100 // supported for this type. |
| 103 bool Update(void* buffer) { | 101 bool Update(void* buffer) { |
| 104 // Not supported; | 102 // Not supported; |
| 105 return true; | 103 return true; |
| 106 } | 104 } |
| 107 | 105 |
| 108 // Returns the size of the input in bytes. | 106 // Returns the size of the input in bytes. |
| 109 uint32 GetSize() const { | 107 uint32_t GetSize() const { return sizeof(t_); } |
| 110 return sizeof(t_); | |
| 111 } | |
| 112 | 108 |
| 113 // Returns true if the current type is used as an In or InOut parameter. | 109 // Returns true if the current type is used as an In or InOut parameter. |
| 114 bool IsInOut() { | 110 bool IsInOut() { |
| 115 return false; | 111 return false; |
| 116 } | 112 } |
| 117 | 113 |
| 118 // Returns this object's type. | 114 // Returns this object's type. |
| 119 ArgType GetType() { | 115 ArgType GetType() { |
| 120 return VOIDPTR_TYPE; | 116 return VOIDPTR_TYPE; |
| 121 } | 117 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 140 | 136 |
| 141 // Update the stored value with the value in the buffer. This is not | 137 // Update the stored value with the value in the buffer. This is not |
| 142 // supported for this type. | 138 // supported for this type. |
| 143 bool Update(void* buffer) { | 139 bool Update(void* buffer) { |
| 144 // Not supported; | 140 // Not supported; |
| 145 return true; | 141 return true; |
| 146 } | 142 } |
| 147 | 143 |
| 148 // Returns the size of the string in bytes. We define a NULL string to | 144 // Returns the size of the string in bytes. We define a NULL string to |
| 149 // be of zero length. | 145 // be of zero length. |
| 150 uint32 GetSize() const { | 146 uint32_t GetSize() const { |
| 151 __try { | 147 __try { |
| 152 return (!t_) ? 0 : static_cast<uint32>(StringLength(t_) * sizeof(t_[0])); | 148 return (!t_) ? 0 |
| 149 : static_cast<uint32_t>(StringLength(t_) * sizeof(t_[0])); |
| 153 } | 150 } |
| 154 __except(EXCEPTION_EXECUTE_HANDLER) { | 151 __except(EXCEPTION_EXECUTE_HANDLER) { |
| 155 return kuint32max; | 152 return UINT32_MAX; |
| 156 } | 153 } |
| 157 } | 154 } |
| 158 | 155 |
| 159 // Returns true if the current type is used as an In or InOut parameter. | 156 // Returns true if the current type is used as an In or InOut parameter. |
| 160 bool IsInOut() { | 157 bool IsInOut() { |
| 161 return false; | 158 return false; |
| 162 } | 159 } |
| 163 | 160 |
| 164 ArgType GetType() { | 161 ArgType GetType() { |
| 165 return WCHAR_TYPE; | 162 return WCHAR_TYPE; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 187 CopyHelper(wchar_t* t) : Base(t) {} | 184 CopyHelper(wchar_t* t) : Base(t) {} |
| 188 | 185 |
| 189 const void* GetStart() const { | 186 const void* GetStart() const { |
| 190 return Base::GetStart(); | 187 return Base::GetStart(); |
| 191 } | 188 } |
| 192 | 189 |
| 193 bool Update(void* buffer) { | 190 bool Update(void* buffer) { |
| 194 return Base::Update(buffer); | 191 return Base::Update(buffer); |
| 195 } | 192 } |
| 196 | 193 |
| 197 uint32 GetSize() const { | 194 uint32_t GetSize() const { return Base::GetSize(); } |
| 198 return Base::GetSize(); | |
| 199 } | |
| 200 | 195 |
| 201 bool IsInOut() { | 196 bool IsInOut() { |
| 202 return Base::IsInOut(); | 197 return Base::IsInOut(); |
| 203 } | 198 } |
| 204 | 199 |
| 205 ArgType GetType() { | 200 ArgType GetType() { |
| 206 return Base::GetType(); | 201 return Base::GetType(); |
| 207 } | 202 } |
| 208 }; | 203 }; |
| 209 | 204 |
| 210 // Specialization for wchar_t arrays strings. We just reuse the implementation | 205 // Specialization for wchar_t arrays strings. We just reuse the implementation |
| 211 // of the const string specialization. | 206 // of the const string specialization. |
| 212 template<size_t n> | 207 template<size_t n> |
| 213 class CopyHelper<const wchar_t[n]> : public CopyHelper<const wchar_t*> { | 208 class CopyHelper<const wchar_t[n]> : public CopyHelper<const wchar_t*> { |
| 214 public: | 209 public: |
| 215 typedef const wchar_t array[n]; | 210 typedef const wchar_t array[n]; |
| 216 typedef CopyHelper<const wchar_t*> Base; | 211 typedef CopyHelper<const wchar_t*> Base; |
| 217 CopyHelper(array t) : Base(t) {} | 212 CopyHelper(array t) : Base(t) {} |
| 218 | 213 |
| 219 const void* GetStart() const { | 214 const void* GetStart() const { |
| 220 return Base::GetStart(); | 215 return Base::GetStart(); |
| 221 } | 216 } |
| 222 | 217 |
| 223 bool Update(void* buffer) { | 218 bool Update(void* buffer) { |
| 224 return Base::Update(buffer); | 219 return Base::Update(buffer); |
| 225 } | 220 } |
| 226 | 221 |
| 227 uint32 GetSize() const { | 222 uint32_t GetSize() const { return Base::GetSize(); } |
| 228 return Base::GetSize(); | |
| 229 } | |
| 230 | 223 |
| 231 bool IsInOut() { | 224 bool IsInOut() { |
| 232 return Base::IsInOut(); | 225 return Base::IsInOut(); |
| 233 } | 226 } |
| 234 | 227 |
| 235 ArgType GetType() { | 228 ArgType GetType() { |
| 236 return Base::GetType(); | 229 return Base::GetType(); |
| 237 } | 230 } |
| 238 }; | 231 }; |
| 239 | 232 |
| 240 // Generic encapsulation class containing a pointer to a buffer and the | 233 // Generic encapsulation class containing a pointer to a buffer and the |
| 241 // size of the buffer. It is used by the IPC to be able to pass in/out | 234 // size of the buffer. It is used by the IPC to be able to pass in/out |
| 242 // parameters. | 235 // parameters. |
| 243 class InOutCountedBuffer : public CountedBuffer { | 236 class InOutCountedBuffer : public CountedBuffer { |
| 244 public: | 237 public: |
| 245 InOutCountedBuffer(void* buffer, uint32 size) : CountedBuffer(buffer, size) {} | 238 InOutCountedBuffer(void* buffer, uint32_t size) |
| 239 : CountedBuffer(buffer, size) {} |
| 246 }; | 240 }; |
| 247 | 241 |
| 248 // This copy helper template specialization catches the cases where the | 242 // This copy helper template specialization catches the cases where the |
| 249 // parameter is a an input/output buffer. | 243 // parameter is a an input/output buffer. |
| 250 template<> | 244 template<> |
| 251 class CopyHelper<InOutCountedBuffer> { | 245 class CopyHelper<InOutCountedBuffer> { |
| 252 public: | 246 public: |
| 253 CopyHelper(const InOutCountedBuffer t) : t_(t) {} | 247 CopyHelper(const InOutCountedBuffer t) : t_(t) {} |
| 254 | 248 |
| 255 // Returns the pointer to the start of the string. | 249 // Returns the pointer to the start of the string. |
| 256 const void* GetStart() const { | 250 const void* GetStart() const { |
| 257 return t_.Buffer(); | 251 return t_.Buffer(); |
| 258 } | 252 } |
| 259 | 253 |
| 260 // Updates the buffer with the value from the new buffer in parameter. | 254 // Updates the buffer with the value from the new buffer in parameter. |
| 261 bool Update(void* buffer) { | 255 bool Update(void* buffer) { |
| 262 // We are touching user memory, this has to be done from inside a try | 256 // We are touching user memory, this has to be done from inside a try |
| 263 // except. | 257 // except. |
| 264 __try { | 258 __try { |
| 265 memcpy(t_.Buffer(), buffer, t_.Size()); | 259 memcpy(t_.Buffer(), buffer, t_.Size()); |
| 266 } | 260 } |
| 267 __except(EXCEPTION_EXECUTE_HANDLER) { | 261 __except(EXCEPTION_EXECUTE_HANDLER) { |
| 268 return false; | 262 return false; |
| 269 } | 263 } |
| 270 return true; | 264 return true; |
| 271 } | 265 } |
| 272 | 266 |
| 273 // Returns the size of the string in bytes. We define a NULL string to | 267 // Returns the size of the string in bytes. We define a NULL string to |
| 274 // be of zero length. | 268 // be of zero length. |
| 275 uint32 GetSize() const { | 269 uint32_t GetSize() const { return t_.Size(); } |
| 276 return t_.Size(); | |
| 277 } | |
| 278 | 270 |
| 279 // Returns true if the current type is used as an In or InOut parameter. | 271 // Returns true if the current type is used as an In or InOut parameter. |
| 280 bool IsInOut() { | 272 bool IsInOut() { |
| 281 return true; | 273 return true; |
| 282 } | 274 } |
| 283 | 275 |
| 284 ArgType GetType() { | 276 ArgType GetType() { |
| 285 return INOUTPTR_TYPE; | 277 return INOUTPTR_TYPE; |
| 286 } | 278 } |
| 287 | 279 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 310 if (!ch##num.Update(params->GetParamPtr(num-1))) {\ | 302 if (!ch##num.Update(params->GetParamPtr(num-1))) {\ |
| 311 ipc_provider.FreeBuffer(raw_mem); \ | 303 ipc_provider.FreeBuffer(raw_mem); \ |
| 312 return SBOX_ERROR_BAD_PARAMS; \ | 304 return SBOX_ERROR_BAD_PARAMS; \ |
| 313 } | 305 } |
| 314 | 306 |
| 315 #define XCALL_GEN_FREE_CHANNEL() \ | 307 #define XCALL_GEN_FREE_CHANNEL() \ |
| 316 ipc_provider.FreeBuffer(raw_mem); | 308 ipc_provider.FreeBuffer(raw_mem); |
| 317 | 309 |
| 318 // CrossCall template with one input parameter | 310 // CrossCall template with one input parameter |
| 319 template <typename IPCProvider, typename Par1> | 311 template <typename IPCProvider, typename Par1> |
| 320 ResultCode CrossCall(IPCProvider& ipc_provider, uint32 tag, const Par1& p1, | 312 ResultCode CrossCall(IPCProvider& ipc_provider, |
| 313 uint32_t tag, |
| 314 const Par1& p1, |
| 321 CrossCallReturn* answer) { | 315 CrossCallReturn* answer) { |
| 322 XCALL_GEN_PARAMS_OBJ(1, call_params); | 316 XCALL_GEN_PARAMS_OBJ(1, call_params); |
| 323 XCALL_GEN_COPY_PARAM(1, call_params); | 317 XCALL_GEN_COPY_PARAM(1, call_params); |
| 324 | 318 |
| 325 ResultCode result = ipc_provider.DoCall(call_params, answer); | 319 ResultCode result = ipc_provider.DoCall(call_params, answer); |
| 326 | 320 |
| 327 if (SBOX_ERROR_CHANNEL_ERROR != result) { | 321 if (SBOX_ERROR_CHANNEL_ERROR != result) { |
| 328 XCALL_GEN_UPDATE_PARAM(1, call_params); | 322 XCALL_GEN_UPDATE_PARAM(1, call_params); |
| 329 XCALL_GEN_FREE_CHANNEL(); | 323 XCALL_GEN_FREE_CHANNEL(); |
| 330 } | 324 } |
| 331 | 325 |
| 332 return result; | 326 return result; |
| 333 } | 327 } |
| 334 | 328 |
| 335 // CrossCall template with two input parameters. | 329 // CrossCall template with two input parameters. |
| 336 template <typename IPCProvider, typename Par1, typename Par2> | 330 template <typename IPCProvider, typename Par1, typename Par2> |
| 337 ResultCode CrossCall(IPCProvider& ipc_provider, uint32 tag, const Par1& p1, | 331 ResultCode CrossCall(IPCProvider& ipc_provider, |
| 338 const Par2& p2, CrossCallReturn* answer) { | 332 uint32_t tag, |
| 333 const Par1& p1, |
| 334 const Par2& p2, |
| 335 CrossCallReturn* answer) { |
| 339 XCALL_GEN_PARAMS_OBJ(2, call_params); | 336 XCALL_GEN_PARAMS_OBJ(2, call_params); |
| 340 XCALL_GEN_COPY_PARAM(1, call_params); | 337 XCALL_GEN_COPY_PARAM(1, call_params); |
| 341 XCALL_GEN_COPY_PARAM(2, call_params); | 338 XCALL_GEN_COPY_PARAM(2, call_params); |
| 342 | 339 |
| 343 ResultCode result = ipc_provider.DoCall(call_params, answer); | 340 ResultCode result = ipc_provider.DoCall(call_params, answer); |
| 344 | 341 |
| 345 if (SBOX_ERROR_CHANNEL_ERROR != result) { | 342 if (SBOX_ERROR_CHANNEL_ERROR != result) { |
| 346 XCALL_GEN_UPDATE_PARAM(1, call_params); | 343 XCALL_GEN_UPDATE_PARAM(1, call_params); |
| 347 XCALL_GEN_UPDATE_PARAM(2, call_params); | 344 XCALL_GEN_UPDATE_PARAM(2, call_params); |
| 348 XCALL_GEN_FREE_CHANNEL(); | 345 XCALL_GEN_FREE_CHANNEL(); |
| 349 } | 346 } |
| 350 return result; | 347 return result; |
| 351 } | 348 } |
| 352 | 349 |
| 353 // CrossCall template with three input parameters. | 350 // CrossCall template with three input parameters. |
| 354 template <typename IPCProvider, typename Par1, typename Par2, typename Par3> | 351 template <typename IPCProvider, typename Par1, typename Par2, typename Par3> |
| 355 ResultCode CrossCall(IPCProvider& ipc_provider, uint32 tag, const Par1& p1, | 352 ResultCode CrossCall(IPCProvider& ipc_provider, |
| 356 const Par2& p2, const Par3& p3, CrossCallReturn* answer) { | 353 uint32_t tag, |
| 354 const Par1& p1, |
| 355 const Par2& p2, |
| 356 const Par3& p3, |
| 357 CrossCallReturn* answer) { |
| 357 XCALL_GEN_PARAMS_OBJ(3, call_params); | 358 XCALL_GEN_PARAMS_OBJ(3, call_params); |
| 358 XCALL_GEN_COPY_PARAM(1, call_params); | 359 XCALL_GEN_COPY_PARAM(1, call_params); |
| 359 XCALL_GEN_COPY_PARAM(2, call_params); | 360 XCALL_GEN_COPY_PARAM(2, call_params); |
| 360 XCALL_GEN_COPY_PARAM(3, call_params); | 361 XCALL_GEN_COPY_PARAM(3, call_params); |
| 361 | 362 |
| 362 ResultCode result = ipc_provider.DoCall(call_params, answer); | 363 ResultCode result = ipc_provider.DoCall(call_params, answer); |
| 363 | 364 |
| 364 if (SBOX_ERROR_CHANNEL_ERROR != result) { | 365 if (SBOX_ERROR_CHANNEL_ERROR != result) { |
| 365 XCALL_GEN_UPDATE_PARAM(1, call_params); | 366 XCALL_GEN_UPDATE_PARAM(1, call_params); |
| 366 XCALL_GEN_UPDATE_PARAM(2, call_params); | 367 XCALL_GEN_UPDATE_PARAM(2, call_params); |
| 367 XCALL_GEN_UPDATE_PARAM(3, call_params); | 368 XCALL_GEN_UPDATE_PARAM(3, call_params); |
| 368 XCALL_GEN_FREE_CHANNEL(); | 369 XCALL_GEN_FREE_CHANNEL(); |
| 369 } | 370 } |
| 370 return result; | 371 return result; |
| 371 } | 372 } |
| 372 | 373 |
| 373 // CrossCall template with four input parameters. | 374 // CrossCall template with four input parameters. |
| 374 template <typename IPCProvider, typename Par1, typename Par2, typename Par3, | 375 template <typename IPCProvider, |
| 376 typename Par1, |
| 377 typename Par2, |
| 378 typename Par3, |
| 375 typename Par4> | 379 typename Par4> |
| 376 ResultCode CrossCall(IPCProvider& ipc_provider, uint32 tag, const Par1& p1, | 380 ResultCode CrossCall(IPCProvider& ipc_provider, |
| 377 const Par2& p2, const Par3& p3, const Par4& p4, | 381 uint32_t tag, |
| 382 const Par1& p1, |
| 383 const Par2& p2, |
| 384 const Par3& p3, |
| 385 const Par4& p4, |
| 378 CrossCallReturn* answer) { | 386 CrossCallReturn* answer) { |
| 379 XCALL_GEN_PARAMS_OBJ(4, call_params); | 387 XCALL_GEN_PARAMS_OBJ(4, call_params); |
| 380 XCALL_GEN_COPY_PARAM(1, call_params); | 388 XCALL_GEN_COPY_PARAM(1, call_params); |
| 381 XCALL_GEN_COPY_PARAM(2, call_params); | 389 XCALL_GEN_COPY_PARAM(2, call_params); |
| 382 XCALL_GEN_COPY_PARAM(3, call_params); | 390 XCALL_GEN_COPY_PARAM(3, call_params); |
| 383 XCALL_GEN_COPY_PARAM(4, call_params); | 391 XCALL_GEN_COPY_PARAM(4, call_params); |
| 384 | 392 |
| 385 ResultCode result = ipc_provider.DoCall(call_params, answer); | 393 ResultCode result = ipc_provider.DoCall(call_params, answer); |
| 386 | 394 |
| 387 if (SBOX_ERROR_CHANNEL_ERROR != result) { | 395 if (SBOX_ERROR_CHANNEL_ERROR != result) { |
| 388 XCALL_GEN_UPDATE_PARAM(1, call_params); | 396 XCALL_GEN_UPDATE_PARAM(1, call_params); |
| 389 XCALL_GEN_UPDATE_PARAM(2, call_params); | 397 XCALL_GEN_UPDATE_PARAM(2, call_params); |
| 390 XCALL_GEN_UPDATE_PARAM(3, call_params); | 398 XCALL_GEN_UPDATE_PARAM(3, call_params); |
| 391 XCALL_GEN_UPDATE_PARAM(4, call_params); | 399 XCALL_GEN_UPDATE_PARAM(4, call_params); |
| 392 XCALL_GEN_FREE_CHANNEL(); | 400 XCALL_GEN_FREE_CHANNEL(); |
| 393 } | 401 } |
| 394 return result; | 402 return result; |
| 395 } | 403 } |
| 396 | 404 |
| 397 // CrossCall template with five input parameters. | 405 // CrossCall template with five input parameters. |
| 398 template <typename IPCProvider, typename Par1, typename Par2, typename Par3, | 406 template <typename IPCProvider, |
| 399 typename Par4, typename Par5> | 407 typename Par1, |
| 400 ResultCode CrossCall(IPCProvider& ipc_provider, uint32 tag, const Par1& p1, | 408 typename Par2, |
| 401 const Par2& p2, const Par3& p3, const Par4& p4, | 409 typename Par3, |
| 402 const Par5& p5, CrossCallReturn* answer) { | 410 typename Par4, |
| 411 typename Par5> |
| 412 ResultCode CrossCall(IPCProvider& ipc_provider, |
| 413 uint32_t tag, |
| 414 const Par1& p1, |
| 415 const Par2& p2, |
| 416 const Par3& p3, |
| 417 const Par4& p4, |
| 418 const Par5& p5, |
| 419 CrossCallReturn* answer) { |
| 403 XCALL_GEN_PARAMS_OBJ(5, call_params); | 420 XCALL_GEN_PARAMS_OBJ(5, call_params); |
| 404 XCALL_GEN_COPY_PARAM(1, call_params); | 421 XCALL_GEN_COPY_PARAM(1, call_params); |
| 405 XCALL_GEN_COPY_PARAM(2, call_params); | 422 XCALL_GEN_COPY_PARAM(2, call_params); |
| 406 XCALL_GEN_COPY_PARAM(3, call_params); | 423 XCALL_GEN_COPY_PARAM(3, call_params); |
| 407 XCALL_GEN_COPY_PARAM(4, call_params); | 424 XCALL_GEN_COPY_PARAM(4, call_params); |
| 408 XCALL_GEN_COPY_PARAM(5, call_params); | 425 XCALL_GEN_COPY_PARAM(5, call_params); |
| 409 | 426 |
| 410 ResultCode result = ipc_provider.DoCall(call_params, answer); | 427 ResultCode result = ipc_provider.DoCall(call_params, answer); |
| 411 | 428 |
| 412 if (SBOX_ERROR_CHANNEL_ERROR != result) { | 429 if (SBOX_ERROR_CHANNEL_ERROR != result) { |
| 413 XCALL_GEN_UPDATE_PARAM(1, call_params); | 430 XCALL_GEN_UPDATE_PARAM(1, call_params); |
| 414 XCALL_GEN_UPDATE_PARAM(2, call_params); | 431 XCALL_GEN_UPDATE_PARAM(2, call_params); |
| 415 XCALL_GEN_UPDATE_PARAM(3, call_params); | 432 XCALL_GEN_UPDATE_PARAM(3, call_params); |
| 416 XCALL_GEN_UPDATE_PARAM(4, call_params); | 433 XCALL_GEN_UPDATE_PARAM(4, call_params); |
| 417 XCALL_GEN_UPDATE_PARAM(5, call_params); | 434 XCALL_GEN_UPDATE_PARAM(5, call_params); |
| 418 XCALL_GEN_FREE_CHANNEL(); | 435 XCALL_GEN_FREE_CHANNEL(); |
| 419 } | 436 } |
| 420 return result; | 437 return result; |
| 421 } | 438 } |
| 422 | 439 |
| 423 // CrossCall template with six input parameters. | 440 // CrossCall template with six input parameters. |
| 424 template <typename IPCProvider, typename Par1, typename Par2, typename Par3, | 441 template <typename IPCProvider, |
| 425 typename Par4, typename Par5, typename Par6> | 442 typename Par1, |
| 426 ResultCode CrossCall(IPCProvider& ipc_provider, uint32 tag, const Par1& p1, | 443 typename Par2, |
| 427 const Par2& p2, const Par3& p3, const Par4& p4, | 444 typename Par3, |
| 428 const Par5& p5, const Par6& p6, CrossCallReturn* answer) { | 445 typename Par4, |
| 446 typename Par5, |
| 447 typename Par6> |
| 448 ResultCode CrossCall(IPCProvider& ipc_provider, |
| 449 uint32_t tag, |
| 450 const Par1& p1, |
| 451 const Par2& p2, |
| 452 const Par3& p3, |
| 453 const Par4& p4, |
| 454 const Par5& p5, |
| 455 const Par6& p6, |
| 456 CrossCallReturn* answer) { |
| 429 XCALL_GEN_PARAMS_OBJ(6, call_params); | 457 XCALL_GEN_PARAMS_OBJ(6, call_params); |
| 430 XCALL_GEN_COPY_PARAM(1, call_params); | 458 XCALL_GEN_COPY_PARAM(1, call_params); |
| 431 XCALL_GEN_COPY_PARAM(2, call_params); | 459 XCALL_GEN_COPY_PARAM(2, call_params); |
| 432 XCALL_GEN_COPY_PARAM(3, call_params); | 460 XCALL_GEN_COPY_PARAM(3, call_params); |
| 433 XCALL_GEN_COPY_PARAM(4, call_params); | 461 XCALL_GEN_COPY_PARAM(4, call_params); |
| 434 XCALL_GEN_COPY_PARAM(5, call_params); | 462 XCALL_GEN_COPY_PARAM(5, call_params); |
| 435 XCALL_GEN_COPY_PARAM(6, call_params); | 463 XCALL_GEN_COPY_PARAM(6, call_params); |
| 436 | 464 |
| 437 ResultCode result = ipc_provider.DoCall(call_params, answer); | 465 ResultCode result = ipc_provider.DoCall(call_params, answer); |
| 438 | 466 |
| 439 if (SBOX_ERROR_CHANNEL_ERROR != result) { | 467 if (SBOX_ERROR_CHANNEL_ERROR != result) { |
| 440 XCALL_GEN_UPDATE_PARAM(1, call_params); | 468 XCALL_GEN_UPDATE_PARAM(1, call_params); |
| 441 XCALL_GEN_UPDATE_PARAM(2, call_params); | 469 XCALL_GEN_UPDATE_PARAM(2, call_params); |
| 442 XCALL_GEN_UPDATE_PARAM(3, call_params); | 470 XCALL_GEN_UPDATE_PARAM(3, call_params); |
| 443 XCALL_GEN_UPDATE_PARAM(4, call_params); | 471 XCALL_GEN_UPDATE_PARAM(4, call_params); |
| 444 XCALL_GEN_UPDATE_PARAM(5, call_params); | 472 XCALL_GEN_UPDATE_PARAM(5, call_params); |
| 445 XCALL_GEN_UPDATE_PARAM(6, call_params); | 473 XCALL_GEN_UPDATE_PARAM(6, call_params); |
| 446 XCALL_GEN_FREE_CHANNEL(); | 474 XCALL_GEN_FREE_CHANNEL(); |
| 447 } | 475 } |
| 448 return result; | 476 return result; |
| 449 } | 477 } |
| 450 | 478 |
| 451 // CrossCall template with seven input parameters. | 479 // CrossCall template with seven input parameters. |
| 452 template <typename IPCProvider, typename Par1, typename Par2, typename Par3, | 480 template <typename IPCProvider, |
| 453 typename Par4, typename Par5, typename Par6, typename Par7> | 481 typename Par1, |
| 454 ResultCode CrossCall(IPCProvider& ipc_provider, uint32 tag, const Par1& p1, | 482 typename Par2, |
| 455 const Par2& p2, const Par3& p3, const Par4& p4, | 483 typename Par3, |
| 456 const Par5& p5, const Par6& p6, const Par7& p7, | 484 typename Par4, |
| 485 typename Par5, |
| 486 typename Par6, |
| 487 typename Par7> |
| 488 ResultCode CrossCall(IPCProvider& ipc_provider, |
| 489 uint32_t tag, |
| 490 const Par1& p1, |
| 491 const Par2& p2, |
| 492 const Par3& p3, |
| 493 const Par4& p4, |
| 494 const Par5& p5, |
| 495 const Par6& p6, |
| 496 const Par7& p7, |
| 457 CrossCallReturn* answer) { | 497 CrossCallReturn* answer) { |
| 458 XCALL_GEN_PARAMS_OBJ(7, call_params); | 498 XCALL_GEN_PARAMS_OBJ(7, call_params); |
| 459 XCALL_GEN_COPY_PARAM(1, call_params); | 499 XCALL_GEN_COPY_PARAM(1, call_params); |
| 460 XCALL_GEN_COPY_PARAM(2, call_params); | 500 XCALL_GEN_COPY_PARAM(2, call_params); |
| 461 XCALL_GEN_COPY_PARAM(3, call_params); | 501 XCALL_GEN_COPY_PARAM(3, call_params); |
| 462 XCALL_GEN_COPY_PARAM(4, call_params); | 502 XCALL_GEN_COPY_PARAM(4, call_params); |
| 463 XCALL_GEN_COPY_PARAM(5, call_params); | 503 XCALL_GEN_COPY_PARAM(5, call_params); |
| 464 XCALL_GEN_COPY_PARAM(6, call_params); | 504 XCALL_GEN_COPY_PARAM(6, call_params); |
| 465 XCALL_GEN_COPY_PARAM(7, call_params); | 505 XCALL_GEN_COPY_PARAM(7, call_params); |
| 466 | 506 |
| 467 ResultCode result = ipc_provider.DoCall(call_params, answer); | 507 ResultCode result = ipc_provider.DoCall(call_params, answer); |
| 468 | 508 |
| 469 if (SBOX_ERROR_CHANNEL_ERROR != result) { | 509 if (SBOX_ERROR_CHANNEL_ERROR != result) { |
| 470 XCALL_GEN_UPDATE_PARAM(1, call_params); | 510 XCALL_GEN_UPDATE_PARAM(1, call_params); |
| 471 XCALL_GEN_UPDATE_PARAM(2, call_params); | 511 XCALL_GEN_UPDATE_PARAM(2, call_params); |
| 472 XCALL_GEN_UPDATE_PARAM(3, call_params); | 512 XCALL_GEN_UPDATE_PARAM(3, call_params); |
| 473 XCALL_GEN_UPDATE_PARAM(4, call_params); | 513 XCALL_GEN_UPDATE_PARAM(4, call_params); |
| 474 XCALL_GEN_UPDATE_PARAM(5, call_params); | 514 XCALL_GEN_UPDATE_PARAM(5, call_params); |
| 475 XCALL_GEN_UPDATE_PARAM(6, call_params); | 515 XCALL_GEN_UPDATE_PARAM(6, call_params); |
| 476 XCALL_GEN_UPDATE_PARAM(7, call_params); | 516 XCALL_GEN_UPDATE_PARAM(7, call_params); |
| 477 XCALL_GEN_FREE_CHANNEL(); | 517 XCALL_GEN_FREE_CHANNEL(); |
| 478 } | 518 } |
| 479 return result; | 519 return result; |
| 480 } | 520 } |
| 481 } // namespace sandbox | 521 } // namespace sandbox |
| 482 | 522 |
| 483 #endif // SANDBOX_SRC_CROSSCALL_CLIENT_H__ | 523 #endif // SANDBOX_SRC_CROSSCALL_CLIENT_H__ |
| OLD | NEW |