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

Side by Side Diff: sandbox/win/tests/validation_tests/commands.cc

Issue 319573006: Add sandbox support for process memory limits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 6 years, 6 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 | « sandbox/win/src/sandbox_types.h ('k') | sandbox/win/tests/validation_tests/suite.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) 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 #include <Aclapi.h> 5 #include <Aclapi.h>
6 #include <windows.h> 6 #include <windows.h>
7 #include <string> 7 #include <string>
8 8
9 #include "sandbox/win/tests/validation_tests/commands.h" 9 #include "sandbox/win/tests/validation_tests/commands.h"
10 10
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 303 }
304 304
305 SBOX_TESTS_COMMAND int SleepCmd(int argc, wchar_t **argv) { 305 SBOX_TESTS_COMMAND int SleepCmd(int argc, wchar_t **argv) {
306 if (1 != argc) 306 if (1 != argc)
307 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 307 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
308 308
309 ::Sleep(_wtoi(argv[0])); 309 ::Sleep(_wtoi(argv[0]));
310 return SBOX_TEST_SUCCEEDED; 310 return SBOX_TEST_SUCCEEDED;
311 } 311 }
312 312
313 SBOX_TESTS_COMMAND int AllocateCmd(int argc, wchar_t **argv) {
314 if (argc != 1)
315 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
316
317 size_t mem_size = static_cast<size_t>(_wtoll(argv[0]));
318 void* memory = ::VirtualAlloc(NULL, mem_size, MEM_COMMIT | MEM_RESERVE,
319 PAGE_READWRITE);
320 if (!memory) {
321 // We need to give the broker a chance to kill our process on failure.
322 ::Sleep(5000);
323 return SBOX_TEST_DENIED;
324 }
325
326 if (!::VirtualFree(memory, 0, MEM_RELEASE))
327 return SBOX_TEST_FAILED;
328
329 return SBOX_TEST_SUCCEEDED;
330 }
331
313 332
314 } // namespace sandbox 333 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/sandbox_types.h ('k') | sandbox/win/tests/validation_tests/suite.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698