diff options
Diffstat (limited to 'sandbox/win/src/crosscall_params.h')
-rw-r--r-- | sandbox/win/src/crosscall_params.h | 77 |
1 files changed, 34 insertions, 43 deletions
diff --git a/sandbox/win/src/crosscall_params.h b/sandbox/win/src/crosscall_params.h index 6facb202da..eb59c44239 100644 --- a/sandbox/win/src/crosscall_params.h +++ b/sandbox/win/src/crosscall_params.h @@ -7,30 +7,29 @@ #include <windows.h> #include <lmaccess.h> +#include <stddef.h> +#include <stdint.h> #include <memory> -#include "base/basictypes.h" +#include "base/macros.h" #include "sandbox/win/src/internal_types.h" #include "sandbox/win/src/sandbox_types.h" -namespace { - -// Increases |value| until there is no need for padding given an int64 +// Increases |value| until there is no need for padding given an int64_t // alignment. Returns the increased value. -uint32 Align(uint32 value) { - uint32 alignment = sizeof(int64); +inline uint32_t Align(uint32_t value) { + uint32_t alignment = sizeof(int64_t); return ((value + alignment - 1) / alignment) * alignment; } -} // This header is part of CrossCall: the sandbox inter-process communication. // This header defines the basic types used both in the client IPC and in the // server IPC code. CrossCallParams and ActualCallParams model the input // parameters of an IPC call and CrossCallReturn models the output params and // the return value. // -// An IPC call is defined by its 'tag' which is a (uint32) unique identifier +// An IPC call is defined by its 'tag' which is a (uint32_t) unique identifier // that is used to route the IPC call to the proper server. Every tag implies // a complete call signature including the order and type of each parameter. // @@ -39,7 +38,7 @@ uint32 Align(uint32 value) { // them are not supported. // // Another limitation of CrossCall is that the return value and output -// parameters can only be uint32 integers. Returning complex structures or +// parameters can only be uint32_t integers. Returning complex structures or // strings is not supported. namespace sandbox { @@ -50,7 +49,7 @@ const size_t kExtendedReturnCount = 8; // Union of multiple types to be used as extended results // in the CrossCallReturn. union MultiType { - uint32 unsigned_int; + uint32_t unsigned_int; void* pointer; HANDLE handle; ULONG_PTR ulong_ptr; @@ -66,8 +65,8 @@ const int kMaxIpcParams = 9; // Contains the information about a parameter in the ipc buffer. struct ParamInfo { ArgType type_; - uint32 offset_; - uint32 size_; + uint32_t offset_; + uint32_t size_; }; // Models the return value and the return parameters of an IPC call @@ -76,7 +75,7 @@ struct ParamInfo { // might have to use other integer types. struct CrossCallReturn { // the IPC tag. It should match the original IPC tag. - uint32 tag; + uint32_t tag; // The result of the IPC operation itself. ResultCode call_outcome; // the result of the IPC call as executed in the server. The interpretation @@ -86,7 +85,7 @@ struct CrossCallReturn { DWORD win32_result; }; // Number of extended return values. - uint32 extended_count; + uint32_t extended_count; // for calls that should return a windows handle. It is found here. HANDLE handle; // The array of extended values. @@ -107,9 +106,7 @@ struct CrossCallReturn { class CrossCallParams { public: // Returns the tag (ipc unique id) associated with this IPC. - uint32 GetTag() const { - return tag_; - } + uint32_t GetTag() const { return tag_; } // Returns the beggining of the buffer where the IPC params can be stored. // prior to an IPC call @@ -118,9 +115,7 @@ class CrossCallParams { } // Returns how many parameter this IPC call should have. - const uint32 GetParamsCount() const { - return params_count_; - } + uint32_t GetParamsCount() const { return params_count_; } // Returns a pointer to the CrossCallReturn structure. CrossCallReturn* GetCallReturn() { @@ -128,9 +123,7 @@ class CrossCallParams { } // Returns TRUE if this call contains InOut parameters. - const bool IsInOut() const { - return (1 == is_in_out_); - } + bool IsInOut() const { return (1 == is_in_out_); } // Tells the CrossCall object if it contains InOut parameters. void SetIsInOut(bool value) { @@ -142,17 +135,14 @@ class CrossCallParams { protected: // constructs the IPC call params. Called only from the derived classes - CrossCallParams(uint32 tag, uint32 params_count) - : tag_(tag), - params_count_(params_count), - is_in_out_(0) { - } + CrossCallParams(uint32_t tag, uint32_t params_count) + : tag_(tag), is_in_out_(0), params_count_(params_count) {} private: - uint32 tag_; - uint32 is_in_out_; + uint32_t tag_; + uint32_t is_in_out_; CrossCallReturn call_return; - const uint32 params_count_; + const uint32_t params_count_; DISALLOW_COPY_AND_ASSIGN(CrossCallParams); }; @@ -198,37 +188,40 @@ template <size_t NUMBER_PARAMS, size_t BLOCK_SIZE> class ActualCallParams : public CrossCallParams { public: // constructor. Pass the ipc unique tag as input - explicit ActualCallParams(uint32 tag) + explicit ActualCallParams(uint32_t tag) : CrossCallParams(tag, NUMBER_PARAMS) { param_info_[0].offset_ = - static_cast<uint32>(parameters_ - reinterpret_cast<char*>(this)); + static_cast<uint32_t>(parameters_ - reinterpret_cast<char*>(this)); } // Testing-only constructor. Allows setting the |number_params| to a // wrong value. - ActualCallParams(uint32 tag, uint32 number_params) + ActualCallParams(uint32_t tag, uint32_t number_params) : CrossCallParams(tag, number_params) { param_info_[0].offset_ = - static_cast<uint32>(parameters_ - reinterpret_cast<char*>(this)); + static_cast<uint32_t>(parameters_ - reinterpret_cast<char*>(this)); } // Testing-only method. Allows setting the apparent size to a wrong value. // returns the previous size. - uint32 OverrideSize(uint32 new_size) { - uint32 previous_size = param_info_[NUMBER_PARAMS].offset_; + uint32_t OverrideSize(uint32_t new_size) { + uint32_t previous_size = param_info_[NUMBER_PARAMS].offset_; param_info_[NUMBER_PARAMS].offset_ = new_size; return previous_size; } // Copies each paramter into the internal buffer. For each you must supply: // index: 0 for the first param, 1 for the next an so on - bool CopyParamIn(uint32 index, const void* parameter_address, uint32 size, - bool is_in_out, ArgType type) { + bool CopyParamIn(uint32_t index, + const void* parameter_address, + uint32_t size, + bool is_in_out, + ArgType type) { if (index >= NUMBER_PARAMS) { return false; } - if (kuint32max == size) { + if (UINT32_MAX == size) { // Memory error while getting the size. return false; } @@ -273,9 +266,7 @@ class ActualCallParams : public CrossCallParams { // Returns the total size of the buffer. Only valid once all the paramters // have been copied in with CopyParamIn. - uint32 GetSize() const { - return param_info_[NUMBER_PARAMS].offset_; - } + uint32_t GetSize() const { return param_info_[NUMBER_PARAMS].offset_; } protected: ActualCallParams() : CrossCallParams(0, NUMBER_PARAMS) { } |