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 3// found in the LICENSE file. 4 5#ifndef SANDBOX_WIN_SRC_INTERNAL_TYPES_H_ 6#define SANDBOX_WIN_SRC_INTERNAL_TYPES_H_ 7 8namespace sandbox { 9 10const wchar_t kNtdllName[] = L"ntdll.dll"; 11const wchar_t kKerneldllName[] = L"kernel32.dll"; 12const wchar_t kKernelBasedllName[] = L"kernelbase.dll"; 13 14// Defines the supported C++ types encoding to numeric id. Like a poor's man 15// RTTI. Note that true C++ RTTI will not work because the types are not 16// polymorphic anyway. 17enum ArgType { 18 INVALID_TYPE = 0, 19 WCHAR_TYPE, 20 ULONG_TYPE, 21 UNISTR_TYPE, 22 VOIDPTR_TYPE, 23 INPTR_TYPE, 24 INOUTPTR_TYPE, 25 LAST_TYPE 26}; 27 28// Encapsulates a pointer to a buffer and the size of the buffer. 29class CountedBuffer { 30 public: 31 CountedBuffer(void* buffer, uint32 size) : size_(size), buffer_(buffer) {} 32 33 uint32 Size() const { 34 return size_; 35 } 36 37 void* Buffer() const { 38 return buffer_; 39 } 40 41 private: 42 uint32 size_; 43 void* buffer_; 44}; 45 46// Helper class to convert void-pointer packed ints for both 47// 32 and 64 bit builds. This construct is non-portable. 48class IPCInt { 49 public: 50 explicit IPCInt(void* buffer) { 51 buffer_.vp = buffer; 52 } 53 54 explicit IPCInt(unsigned __int32 i32) { 55 buffer_.vp = NULL; 56 buffer_.i32 = i32; 57 } 58 59 unsigned __int32 As32Bit() const { 60 return buffer_.i32; 61 } 62 63 void* AsVoidPtr() const { 64 return buffer_.vp; 65 } 66 67 private: 68 union U { 69 void* vp; 70 unsigned __int32 i32; 71 } buffer_; 72}; 73 74} // namespace sandbox 75 76#endif // SANDBOX_WIN_SRC_INTERNAL_TYPES_H_ 77