Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: sandbox/src/crosscall_params.h

Issue 3122031: Revert 56796 - Sbox IPC fix... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sandbox/src/crosscall_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_PARAMS_H__ 5 #ifndef SANDBOX_SRC_CROSSCALL_PARAMS_H__
6 #define SANDBOX_SRC_CROSSCALL_PARAMS_H__ 6 #define SANDBOX_SRC_CROSSCALL_PARAMS_H__
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <lmaccess.h> 9 #include <lmaccess.h>
10 10
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // storage allocation that the packed parameters should need. 162 // storage allocation that the packed parameters should need.
163 // NUMBER_PARAMS: the number of parameters, valid from 1 to N 163 // NUMBER_PARAMS: the number of parameters, valid from 1 to N
164 // BLOCK_SIZE: the total storage that the NUMBER_PARAMS parameters can take, 164 // BLOCK_SIZE: the total storage that the NUMBER_PARAMS parameters can take,
165 // typically the block size is defined by the channel size of the underlying 165 // typically the block size is defined by the channel size of the underlying
166 // ipc mechanism. 166 // ipc mechanism.
167 // In practice this class is used to levergage C++ capacity to properly 167 // In practice this class is used to levergage C++ capacity to properly
168 // calculate sizes and displacements given the possibility of the packed params 168 // calculate sizes and displacements given the possibility of the packed params
169 // blob to be complex. 169 // blob to be complex.
170 // 170 //
171 // As is, this class assumes that the layout of the blob is as follows. Assume 171 // As is, this class assumes that the layout of the blob is as follows. Assume
172 // that NUMBER_PARAMS = 2 and a 32-bit build: 172 // that NUMBER_PARAMS = 2:
173 // 173 //
174 // [ tag 4 bytes] 174 // [ tag 4 bytes]
175 // [ IsOnOut 4 bytes] 175 // [ IsOnOut 4 bytes]
176 // [ call return 52 bytes] 176 // [ call return 52 bytes]
177 // [ params count 4 bytes] 177 // [ params count 4 bytes]
178 // [ parameter 0 type 4 bytes] 178 // [ parameter 0 type 4 bytes]
179 // [ parameter 0 offset 4 bytes] ---delta to ---\ 179 // [ parameter 0 /\ 4 bytes] ---delta to ---\
180 // [ parameter 0 size 4 bytes] | 180 // [ parameter 0 size 4 bytes] |
181 // [ parameter 1 type 4 bytes] | 181 // [ parameter 1 type 4 bytes] |
182 // [ parameter 1 offset 4 bytes] ---------------|--\ 182 // [ parameter 1 /\ 4 bytes] |
183 // [ parameter 1 size 4 bytes] | | 183 // [ parameter 1 size 4 bytes] |
184 // [ parameter 2 type 4 bytes] | | 184 // [ parameter 2 type 4 bytes] |
185 // [ parameter 2 offset 4 bytes] ----------------------\ 185 // [ parameter 2 /\ 4 bytes] ----------------------\
186 // [ parameter 2 size 4 bytes] | | | 186 // [ parameter 2 size 4 bytes] | |
187 // |---------------------------| | | | 187 // |-------------------------| | |
188 // | value 0 (x bytes) | <--------------/ | | 188 // | | <--------------/ |
189 // | value 1 (y bytes) | <-----------------/ | 189 // | | |
190 // | | | 190 // | | <---------------------/
191 // | end of buffer | <---------------------/ 191 // |-------------------------|
192 // |---------------------------|
193 // 192 //
194 // Note that the actual number of params is NUMBER_PARAMS + 1 193 // Note that the actual number of params is NUMBER_PARAMS + 1
195 // so that the size of each actual param can be computed from the difference 194 // so that the size of each actual param can be computed from the difference
196 // between one parameter and the next down. The offset of the last param 195 // between one parameter and the next down
197 // points to the end of the buffer and the type and size are undefined.
198 //
199 template <size_t NUMBER_PARAMS, size_t BLOCK_SIZE> 196 template <size_t NUMBER_PARAMS, size_t BLOCK_SIZE>
200 class ActualCallParams : public CrossCallParams { 197 class ActualCallParams : public CrossCallParams {
201 public: 198 public:
202 // constructor. Pass the ipc unique tag as input 199 // constructor. Pass the ipc unique tag as input
203 explicit ActualCallParams(uint32 tag) 200 explicit ActualCallParams(uint32 tag)
204 : CrossCallParams(tag, NUMBER_PARAMS) { 201 : CrossCallParams(tag, NUMBER_PARAMS) {
205 param_info_[0].offset_ = parameters_ - reinterpret_cast<char*>(this); 202 param_info_[0].offset_ = parameters_ - reinterpret_cast<char*>(this);
206 } 203 }
207 204
208 // Testing-only constructor. Allows setting the |number_params| to a 205 // Testing-only constructor. Allows setting the |number_params| to a
209 // wrong value. 206 // wrong value.
210 ActualCallParams(uint32 tag, uint32 number_params) 207 ActualCallParams(uint32 tag, uint32 number_params)
211 : CrossCallParams(tag, number_params) { 208 : CrossCallParams(tag, number_params) {
212 param_info_[0].offset_ = parameters_ - reinterpret_cast<char*>(this); 209 param_info_[0].offset_ = parameters_ - reinterpret_cast<char*>(this);
213 } 210 }
214 211
215 // Testing-only method. Allows setting the apparent size to a wrong value.
216 // returns the previous size.
217 size_t OverrideSize(size_t new_size) {
218 size_t previous_size = param_info_[NUMBER_PARAMS].offset_;
219 param_info_[NUMBER_PARAMS].offset_ = new_size;
220 return previous_size;
221 }
222
223 // Copies each paramter into the internal buffer. For each you must supply: 212 // Copies each paramter into the internal buffer. For each you must supply:
224 // index: 0 for the first param, 1 for the next an so on 213 // index: 0 for the first param, 1 for the next an so on
225 bool CopyParamIn(size_t index, const void* parameter_address, size_t size, 214 bool CopyParamIn(size_t index, const void* parameter_address, size_t size,
226 bool is_in_out, ArgType type) { 215 bool is_in_out, ArgType type) {
227 if (index >= NUMBER_PARAMS) { 216 if (index >= NUMBER_PARAMS) {
228 return false; 217 return false;
229 } 218 }
230 219
231 if (kuint32max == size) { 220 if (kuint32max == size) {
232 // Memory error while getting the size. 221 // Memory error while getting the size.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 DISALLOW_COPY_AND_ASSIGN(ActualCallParams); 275 DISALLOW_COPY_AND_ASSIGN(ActualCallParams);
287 }; 276 };
288 277
289 COMPILE_ASSERT(sizeof(ActualCallParams<1, 1024>) == 1024, bad_size_buffer); 278 COMPILE_ASSERT(sizeof(ActualCallParams<1, 1024>) == 1024, bad_size_buffer);
290 COMPILE_ASSERT(sizeof(ActualCallParams<2, 1024>) == 1024, bad_size_buffer); 279 COMPILE_ASSERT(sizeof(ActualCallParams<2, 1024>) == 1024, bad_size_buffer);
291 COMPILE_ASSERT(sizeof(ActualCallParams<3, 1024>) == 1024, bad_size_buffer); 280 COMPILE_ASSERT(sizeof(ActualCallParams<3, 1024>) == 1024, bad_size_buffer);
292 281
293 } // namespace sandbox 282 } // namespace sandbox
294 283
295 #endif // SANDBOX_SRC_CROSSCALL_PARAMS_H__ 284 #endif // SANDBOX_SRC_CROSSCALL_PARAMS_H__
OLDNEW
« no previous file with comments | « no previous file | sandbox/src/crosscall_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698