| 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/sandbox_poc/pocdll/exports.h" | 6 #include "sandbox/sandbox_poc/pocdll/exports.h" |
| 7 #include "sandbox/sandbox_poc/pocdll/utils.h" | 7 #include "sandbox/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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 events, mutexes + jobs + events); | 165 events, mutexes + jobs + events); |
| 166 } | 166 } |
| 167 | 167 |
| 168 BOOL CALLBACK EnumWindowCallback(HWND hwnd, LPARAM output) { | 168 BOOL CALLBACK EnumWindowCallback(HWND hwnd, LPARAM output) { |
| 169 DWORD pid; | 169 DWORD pid; |
| 170 ::GetWindowThreadProcessId(hwnd, &pid); | 170 ::GetWindowThreadProcessId(hwnd, &pid); |
| 171 if (pid != ::GetCurrentProcessId()) { | 171 if (pid != ::GetCurrentProcessId()) { |
| 172 wchar_t window_title[100 + 1] = {0}; | 172 wchar_t window_title[100 + 1] = {0}; |
| 173 ::GetWindowText(hwnd, window_title, 100); | 173 ::GetWindowText(hwnd, window_title, 100); |
| 174 fprintf(reinterpret_cast<FILE*>(output), | 174 fprintf(reinterpret_cast<FILE*>(output), |
| 175 "[GRANTED] Found window 0x%p with title %S\r\n", hwnd, window_title)
; | 175 "[GRANTED] Found window 0x%p with title %S\r\n", |
| 176 hwnd, |
| 177 window_title); |
| 176 ::CloseWindow(hwnd); | 178 ::CloseWindow(hwnd); |
| 177 } | 179 } |
| 178 | 180 |
| 179 return TRUE; | 181 return TRUE; |
| 180 } | 182 } |
| 181 | 183 |
| 182 // Enumerates all the windows on the system and call the function to try to | 184 // Enumerates all the windows on the system and call the function to try to |
| 183 // close them. The goal of this function is to try to kill the system by | 185 // close them. The goal of this function is to try to kill the system by |
| 184 // closing all windows. | 186 // closing all windows. |
| 185 // "output" is the stream used for logging. | 187 // "output" is the stream used for logging. |
| 186 void POCDLL_API TestCloseHWND(HANDLE log) { | 188 void POCDLL_API TestCloseHWND(HANDLE log) { |
| 187 HandleToFile handle2file; | 189 HandleToFile handle2file; |
| 188 FILE *output = handle2file.Translate(log, "w"); | 190 FILE *output = handle2file.Translate(log, "w"); |
| 189 | 191 |
| 190 ::EnumWindows(EnumWindowCallback, PtrToLong(output)); | 192 ::EnumWindows(EnumWindowCallback, PtrToLong(output)); |
| 191 // 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 |
| 192 // before returning. | 194 // before returning. |
| 193 ::Sleep(3000); | 195 ::Sleep(3000); |
| 194 } | 196 } |
| 195 | 197 |
| OLD | NEW |