| 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 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 return sizeof(T); | 71 return sizeof(T); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Returns true if the current type is used as an In or InOut parameter. | 74 // Returns true if the current type is used as an In or InOut parameter. |
| 75 bool IsInOut() { | 75 bool IsInOut() { |
| 76 return false; | 76 return false; |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Returns this object's type. | 79 // Returns this object's type. |
| 80 ArgType GetType() { | 80 ArgType GetType() { |
| 81 COMPILE_ASSERT(sizeof(T) == sizeof(uint32), need_specialization); | 81 static_assert(sizeof(T) == sizeof(uint32), "specialization needed"); |
| 82 return UINT32_TYPE; | 82 return UINT32_TYPE; |
| 83 } | 83 } |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 const T& t_; | 86 const T& t_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 // This copy helper template specialization if for the void pointer | 89 // This copy helper template specialization if for the void pointer |
| 90 // case both 32 and 64 bit. | 90 // case both 32 and 64 bit. |
| 91 template<> | 91 template<> |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // of CrossCall functions with ever more input parameters. | 293 // of CrossCall functions with ever more input parameters. |
| 294 | 294 |
| 295 #define XCALL_GEN_PARAMS_OBJ(num, params) \ | 295 #define XCALL_GEN_PARAMS_OBJ(num, params) \ |
| 296 typedef ActualCallParams<num, kIPCChannelSize> ActualParams; \ | 296 typedef ActualCallParams<num, kIPCChannelSize> ActualParams; \ |
| 297 void* raw_mem = ipc_provider.GetBuffer(); \ | 297 void* raw_mem = ipc_provider.GetBuffer(); \ |
| 298 if (NULL == raw_mem) \ | 298 if (NULL == raw_mem) \ |
| 299 return SBOX_ERROR_NO_SPACE; \ | 299 return SBOX_ERROR_NO_SPACE; \ |
| 300 ActualParams* params = new(raw_mem) ActualParams(tag); | 300 ActualParams* params = new(raw_mem) ActualParams(tag); |
| 301 | 301 |
| 302 #define XCALL_GEN_COPY_PARAM(num, params) \ | 302 #define XCALL_GEN_COPY_PARAM(num, params) \ |
| 303 COMPILE_ASSERT(kMaxIpcParams >= num, too_many_parameters); \ | 303 static_assert(kMaxIpcParams >= num, "too many parameters"); \ |
| 304 CopyHelper<Par##num> ch##num(p##num); \ | 304 CopyHelper<Par##num> ch##num(p##num); \ |
| 305 if (!params->CopyParamIn(num - 1, ch##num.GetStart(), ch##num.GetSize(), \ | 305 if (!params->CopyParamIn(num - 1, ch##num.GetStart(), ch##num.GetSize(), \ |
| 306 ch##num.IsInOut(), ch##num.GetType())) \ | 306 ch##num.IsInOut(), ch##num.GetType())) \ |
| 307 return SBOX_ERROR_NO_SPACE; | 307 return SBOX_ERROR_NO_SPACE; |
| 308 | 308 |
| 309 #define XCALL_GEN_UPDATE_PARAM(num, params) \ | 309 #define XCALL_GEN_UPDATE_PARAM(num, params) \ |
| 310 if (!ch##num.Update(params->GetParamPtr(num-1))) {\ | 310 if (!ch##num.Update(params->GetParamPtr(num-1))) {\ |
| 311 ipc_provider.FreeBuffer(raw_mem); \ | 311 ipc_provider.FreeBuffer(raw_mem); \ |
| 312 return SBOX_ERROR_BAD_PARAMS; \ | 312 return SBOX_ERROR_BAD_PARAMS; \ |
| 313 } | 313 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 XCALL_GEN_UPDATE_PARAM(5, call_params); | 474 XCALL_GEN_UPDATE_PARAM(5, call_params); |
| 475 XCALL_GEN_UPDATE_PARAM(6, call_params); | 475 XCALL_GEN_UPDATE_PARAM(6, call_params); |
| 476 XCALL_GEN_UPDATE_PARAM(7, call_params); | 476 XCALL_GEN_UPDATE_PARAM(7, call_params); |
| 477 XCALL_GEN_FREE_CHANNEL(); | 477 XCALL_GEN_FREE_CHANNEL(); |
| 478 } | 478 } |
| 479 return result; | 479 return result; |
| 480 } | 480 } |
| 481 } // namespace sandbox | 481 } // namespace sandbox |
| 482 | 482 |
| 483 #endif // SANDBOX_SRC_CROSSCALL_CLIENT_H__ | 483 #endif // SANDBOX_SRC_CROSSCALL_CLIENT_H__ |
| OLD | NEW |