OLD | NEW |
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 Loading... |
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 |
OLD | NEW |