| 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 #include <malloc.h> | 5 #include <malloc.h> |
| 6 #include "sandbox/win/sandbox_poc/pocdll/exports.h" | 6 #include "sandbox/win/sandbox_poc/pocdll/exports.h" |
| 7 #include "sandbox/win/sandbox_poc/pocdll/utils.h" | 7 #include "sandbox/win/sandbox_poc/pocdll/utils.h" |
| 8 | 8 |
| 9 // This file contains the tests used to verify if it's possible to DOS or crash | 9 // This file contains the tests used to verify if it's possible to DOS or crash |
| 10 // the machine. All tests that can impact the stability of the machine should | 10 // the machine. All tests that can impact the stability of the machine should |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 for (int i = 0; i < 100000; ++i) { | 28 for (int i = 0; i < 100000; ++i) { |
| 29 DWORD tid; | 29 DWORD tid; |
| 30 // Create the thread and leak the handle. | 30 // Create the thread and leak the handle. |
| 31 HANDLE thread = ::CreateThread(NULL, // Default security attributes | 31 HANDLE thread = ::CreateThread(NULL, // Default security attributes |
| 32 NULL, // Stack size | 32 NULL, // Stack size |
| 33 MyThreadBombimgFunction, | 33 MyThreadBombimgFunction, |
| 34 NULL, // Parameter | 34 NULL, // Parameter |
| 35 0, // No creation flags | 35 0, // No creation flags |
| 36 &tid); | 36 &tid); |
| 37 if (thread) { | 37 if (thread) { |
| 38 fprintf(output, "[GRANTED] Creating thread with tid 0x%X\r\n", tid); | 38 fprintf(output, "[GRANTED] Creating thread with tid 0x%lX\r\n", tid); |
| 39 ::CloseHandle(thread); | 39 ::CloseHandle(thread); |
| 40 number_errors = 0; | 40 number_errors = 0; |
| 41 } else { | 41 } else { |
| 42 fprintf(output, "[BLOCKED] Creating thread. Error %d\r\n", | 42 fprintf(output, "[BLOCKED] Creating thread. Error %ld\r\n", |
| 43 ::GetLastError()); | 43 ::GetLastError()); |
| 44 number_errors++; | 44 number_errors++; |
| 45 } | 45 } |
| 46 | 46 |
| 47 if (number_errors >= 5) { | 47 if (number_errors >= 5) { |
| 48 break; | 48 break; |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 83 | 83 |
| 84 HANDLE thread = ::CreateThread(NULL, // Default security attributes. | 84 HANDLE thread = ::CreateThread(NULL, // Default security attributes. |
| 85 NULL, // Stack size. | 85 NULL, // Stack size. |
| 86 TakeAllCpu, | 86 TakeAllCpu, |
| 87 NULL, // Parameter. | 87 NULL, // Parameter. |
| 88 0, // No creation flags. | 88 0, // No creation flags. |
| 89 &tid); | 89 &tid); |
| 90 ::SetThreadAffinityMask(thread, affinity_mask); | 90 ::SetThreadAffinityMask(thread, affinity_mask); |
| 91 | 91 |
| 92 if (::SetThreadPriority(thread, REALTIME_PRIORITY_CLASS)) { | 92 if (::SetThreadPriority(thread, REALTIME_PRIORITY_CLASS)) { |
| 93 fprintf(output, "[GRANTED] Set thread(%d) priority to Realtime\r\n", | 93 fprintf(output, "[GRANTED] Set thread(%ld) priority to Realtime\r\n", |
| 94 tid); | 94 tid); |
| 95 } else { | 95 } else { |
| 96 fprintf(output, "[BLOCKED] Set thread(%d) priority to Realtime\r\n", | 96 fprintf(output, "[BLOCKED] Set thread(%ld) priority to Realtime\r\n", |
| 97 tid); | 97 tid); |
| 98 } | 98 } |
| 99 | 99 |
| 100 ::CloseHandle(thread); | 100 ::CloseHandle(thread); |
| 101 | 101 |
| 102 affinity_mask = affinity_mask << 1; | 102 affinity_mask = affinity_mask << 1; |
| 103 system_mask = system_mask >> 1; | 103 system_mask = system_mask >> 1; |
| 104 } | 104 } |
| 105 } else { | 105 } else { |
| 106 fprintf(output, "[ERROR] Cannot get affinity mask. Error %d\r\n", | 106 fprintf(output, "[ERROR] Cannot get affinity mask. Error %ld\r\n", |
| 107 ::GetLastError()); | 107 ::GetLastError()); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 void POCDLL_API TestUseAllMemory(HANDLE log) { | 111 void POCDLL_API TestUseAllMemory(HANDLE log) { |
| 112 HandleToFile handle2file; | 112 HandleToFile handle2file; |
| 113 FILE *output = handle2file.Translate(log, "w"); | 113 FILE *output = handle2file.Translate(log, "w"); |
| 114 | 114 |
| 115 int number_errors = 0; | 115 int number_errors = 0; |
| 116 unsigned long memory_size = 0; | 116 unsigned long memory_size = 0; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // "output" is the stream used for logging. | 187 // "output" is the stream used for logging. |
| 188 void POCDLL_API TestCloseHWND(HANDLE log) { | 188 void POCDLL_API TestCloseHWND(HANDLE log) { |
| 189 HandleToFile handle2file; | 189 HandleToFile handle2file; |
| 190 FILE *output = handle2file.Translate(log, "w"); | 190 FILE *output = handle2file.Translate(log, "w"); |
| 191 | 191 |
| 192 ::EnumWindows(EnumWindowCallback, PtrToLong(output)); | 192 ::EnumWindows(EnumWindowCallback, PtrToLong(output)); |
| 193 // TODO(nsylvain): find a way to know when the enum is finished | 193 // TODO(nsylvain): find a way to know when the enum is finished |
| 194 // before returning. | 194 // before returning. |
| 195 ::Sleep(3000); | 195 ::Sleep(3000); |
| 196 } | 196 } |
| OLD | NEW |