OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_POLICY_ENGINE_PARAMS_H__ | 5 #ifndef SANDBOX_SRC_POLICY_ENGINE_PARAMS_H__ |
6 #define SANDBOX_SRC_POLICY_ENGINE_PARAMS_H__ | 6 #define SANDBOX_SRC_POLICY_ENGINE_PARAMS_H__ |
7 | 7 |
8 #include <stdint.h> | 8 #include "base/basictypes.h" |
9 | |
10 #include "sandbox/win/src/internal_types.h" | 9 #include "sandbox/win/src/internal_types.h" |
11 #include "sandbox/win/src/nt_internals.h" | 10 #include "sandbox/win/src/nt_internals.h" |
12 #include "sandbox/win/src/sandbox_nt_util.h" | 11 #include "sandbox/win/src/sandbox_nt_util.h" |
13 | 12 |
14 // This header defines the classes that allow the low level policy to select | 13 // This header defines the classes that allow the low level policy to select |
15 // the input parameters. In order to better make sense of this header is | 14 // the input parameters. In order to better make sense of this header is |
16 // recommended that you check policy_engine_opcodes.h first. | 15 // recommended that you check policy_engine_opcodes.h first. |
17 | 16 |
18 namespace sandbox { | 17 namespace sandbox { |
19 | 18 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // original C++ type. This allows the policy to treat any set of supported | 54 // original C++ type. This allows the policy to treat any set of supported |
56 // argument types uniformily and with some type safety. | 55 // argument types uniformily and with some type safety. |
57 // | 56 // |
58 // TODO(cpu): support not fully implemented yet for unicode string and will | 57 // TODO(cpu): support not fully implemented yet for unicode string and will |
59 // probably add other types as well. | 58 // probably add other types as well. |
60 class ParameterSet { | 59 class ParameterSet { |
61 public: | 60 public: |
62 ParameterSet() : real_type_(INVALID_TYPE), address_(NULL) {} | 61 ParameterSet() : real_type_(INVALID_TYPE), address_(NULL) {} |
63 | 62 |
64 // Retrieve the stored parameter. If the type does not match ulong fail. | 63 // Retrieve the stored parameter. If the type does not match ulong fail. |
65 bool Get(uint32_t* destination) const { | 64 bool Get(uint32* destination) const { |
66 if (real_type_ != UINT32_TYPE) { | 65 if (real_type_ != UINT32_TYPE) { |
67 return false; | 66 return false; |
68 } | 67 } |
69 *destination = Void2TypePointerCopy<uint32_t>(); | 68 *destination = Void2TypePointerCopy<uint32>(); |
70 return true; | 69 return true; |
71 } | 70 } |
72 | 71 |
73 // Retrieve the stored parameter. If the type does not match void* fail. | 72 // Retrieve the stored parameter. If the type does not match void* fail. |
74 bool Get(const void** destination) const { | 73 bool Get(const void** destination) const { |
75 if (real_type_ != VOIDPTR_TYPE) { | 74 if (real_type_ != VOIDPTR_TYPE) { |
76 return false; | 75 return false; |
77 } | 76 } |
78 *destination = Void2TypePointerCopy<void*>(); | 77 *destination = Void2TypePointerCopy<void*>(); |
79 return true; | 78 return true; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 : ParameterSet(WCHAR_TYPE, address) {} | 145 : ParameterSet(WCHAR_TYPE, address) {} |
147 }; | 146 }; |
148 | 147 |
149 template<> | 148 template<> |
150 class ParameterSetEx<wchar_t const*> : public ParameterSet { | 149 class ParameterSetEx<wchar_t const*> : public ParameterSet { |
151 public: | 150 public: |
152 ParameterSetEx(const void* address) | 151 ParameterSetEx(const void* address) |
153 : ParameterSet(WCHAR_TYPE, address) {} | 152 : ParameterSet(WCHAR_TYPE, address) {} |
154 }; | 153 }; |
155 | 154 |
156 template <> | 155 |
157 class ParameterSetEx<uint32_t> : public ParameterSet { | 156 template<> |
| 157 class ParameterSetEx<uint32> : public ParameterSet { |
158 public: | 158 public: |
159 ParameterSetEx(const void* address) | 159 ParameterSetEx(const void* address) |
160 : ParameterSet(UINT32_TYPE, address) {} | 160 : ParameterSet(UINT32_TYPE, address) {} |
161 }; | 161 }; |
162 | 162 |
163 template<> | 163 template<> |
164 class ParameterSetEx<UNICODE_STRING> : public ParameterSet { | 164 class ParameterSetEx<UNICODE_STRING> : public ParameterSet { |
165 public: | 165 public: |
166 ParameterSetEx(const void* address) | 166 ParameterSetEx(const void* address) |
167 : ParameterSet(UNISTR_TYPE, address) {} | 167 : ParameterSet(UNISTR_TYPE, address) {} |
(...skipping 25 matching lines...) Expand all Loading... |
193 return reinterpret_cast<CountedParameterSetBase*>(this); | 193 return reinterpret_cast<CountedParameterSetBase*>(this); |
194 } | 194 } |
195 | 195 |
196 int count; | 196 int count; |
197 ParameterSet parameters[T::PolParamLast]; | 197 ParameterSet parameters[T::PolParamLast]; |
198 }; | 198 }; |
199 | 199 |
200 } // namespace sandbox | 200 } // namespace sandbox |
201 | 201 |
202 #endif // SANDBOX_SRC_POLICY_ENGINE_PARAMS_H__ | 202 #endif // SANDBOX_SRC_POLICY_ENGINE_PARAMS_H__ |
OLD | NEW |