| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "sandbox/win/src/handle_table.h" | 5 #include "sandbox/win/src/handle_table.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "sandbox/win/src/win_utils.h" | 12 #include "sandbox/win/src/win_utils.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 bool CompareHandleEntries(const SYSTEM_HANDLE_INFORMATION& a, | 16 bool CompareHandleEntries(const SYSTEM_HANDLE_INFORMATION& a, |
| 17 const SYSTEM_HANDLE_INFORMATION& b) { | 17 const SYSTEM_HANDLE_INFORMATION& b) { |
| 18 return a.ProcessId < b.ProcessId; | 18 return a.ProcessId < b.ProcessId; |
| 19 } | 19 } |
| 20 | 20 |
| 21 } // namespace | 21 } // namespace |
| 22 | 22 |
| 23 namespace sandbox { | 23 namespace sandbox { |
| 24 | 24 |
| 25 const char16* HandleTable::kTypeProcess = L"Process"; | 25 const base::char16* HandleTable::kTypeProcess = L"Process"; |
| 26 const char16* HandleTable::kTypeThread = L"Thread"; | 26 const base::char16* HandleTable::kTypeThread = L"Thread"; |
| 27 const char16* HandleTable::kTypeFile = L"File"; | 27 const base::char16* HandleTable::kTypeFile = L"File"; |
| 28 const char16* HandleTable::kTypeDirectory = L"Directory"; | 28 const base::char16* HandleTable::kTypeDirectory = L"Directory"; |
| 29 const char16* HandleTable::kTypeKey = L"Key"; | 29 const base::char16* HandleTable::kTypeKey = L"Key"; |
| 30 const char16* HandleTable::kTypeWindowStation = L"WindowStation"; | 30 const base::char16* HandleTable::kTypeWindowStation = L"WindowStation"; |
| 31 const char16* HandleTable::kTypeDesktop = L"Desktop"; | 31 const base::char16* HandleTable::kTypeDesktop = L"Desktop"; |
| 32 const char16* HandleTable::kTypeService = L"Service"; | 32 const base::char16* HandleTable::kTypeService = L"Service"; |
| 33 const char16* HandleTable::kTypeMutex = L"Mutex"; | 33 const base::char16* HandleTable::kTypeMutex = L"Mutex"; |
| 34 const char16* HandleTable::kTypeSemaphore = L"Semaphore"; | 34 const base::char16* HandleTable::kTypeSemaphore = L"Semaphore"; |
| 35 const char16* HandleTable::kTypeEvent = L"Event"; | 35 const base::char16* HandleTable::kTypeEvent = L"Event"; |
| 36 const char16* HandleTable::kTypeTimer = L"Timer"; | 36 const base::char16* HandleTable::kTypeTimer = L"Timer"; |
| 37 const char16* HandleTable::kTypeNamedPipe = L"NamedPipe"; | 37 const base::char16* HandleTable::kTypeNamedPipe = L"NamedPipe"; |
| 38 const char16* HandleTable::kTypeJobObject = L"JobObject"; | 38 const base::char16* HandleTable::kTypeJobObject = L"JobObject"; |
| 39 const char16* HandleTable::kTypeFileMap = L"FileMap"; | 39 const base::char16* HandleTable::kTypeFileMap = L"FileMap"; |
| 40 const char16* HandleTable::kTypeAlpcPort = L"ALPC Port"; | 40 const base::char16* HandleTable::kTypeAlpcPort = L"ALPC Port"; |
| 41 | 41 |
| 42 HandleTable::HandleTable() { | 42 HandleTable::HandleTable() { |
| 43 static NtQuerySystemInformation QuerySystemInformation = NULL; | 43 static NtQuerySystemInformation QuerySystemInformation = NULL; |
| 44 if (!QuerySystemInformation) | 44 if (!QuerySystemInformation) |
| 45 ResolveNTFunctionPtr("NtQuerySystemInformation", &QuerySystemInformation); | 45 ResolveNTFunctionPtr("NtQuerySystemInformation", &QuerySystemInformation); |
| 46 | 46 |
| 47 ULONG size = 0x15000; | 47 ULONG size = 0x15000; |
| 48 NTSTATUS result; | 48 NTSTATUS result; |
| 49 do { | 49 do { |
| 50 handle_info_buffer_.resize(size); | 50 handle_info_buffer_.resize(size); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 const SYSTEM_HANDLE_INFORMATION* start, | 174 const SYSTEM_HANDLE_INFORMATION* start, |
| 175 const SYSTEM_HANDLE_INFORMATION* end) | 175 const SYSTEM_HANDLE_INFORMATION* end) |
| 176 : table_(table), current_(start), end_(end) { | 176 : table_(table), current_(start), end_(end) { |
| 177 } | 177 } |
| 178 | 178 |
| 179 HandleTable::Iterator::Iterator(const Iterator& it) | 179 HandleTable::Iterator::Iterator(const Iterator& it) |
| 180 : table_(it.table_), current_(it.current_.handle_entry_), end_(it.end_) { | 180 : table_(it.table_), current_(it.current_.handle_entry_), end_(it.end_) { |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace sandbox | 183 } // namespace sandbox |
| OLD | NEW |