| 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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "sandbox/win/src/win_utils.h" | 12 #include "sandbox/win/src/win_utils.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 bool CompareHandleEntries(const SYSTEM_HANDLE_INFORMATION& a, | 16 bool CompareHandleEntries(const SYSTEM_HANDLE_INFORMATION& a, |
| 16 const SYSTEM_HANDLE_INFORMATION& b) { | 17 const SYSTEM_HANDLE_INFORMATION& b) { |
| 17 return a.ProcessId < b.ProcessId; | 18 return a.ProcessId < b.ProcessId; |
| 18 } | 19 } |
| 19 | 20 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 type_info_buffer_.clear(); | 114 type_info_buffer_.clear(); |
| 114 return; | 115 return; |
| 115 } | 116 } |
| 116 } | 117 } |
| 117 | 118 |
| 118 // Don't bother copying out names until we ask for them, and then cache them. | 119 // Don't bother copying out names until we ask for them, and then cache them. |
| 119 switch (flag) { | 120 switch (flag) { |
| 120 case UPDATE_INFO_AND_NAME: | 121 case UPDATE_INFO_AND_NAME: |
| 121 if (type_info_buffer_.size() && handle_name_.empty()) { | 122 if (type_info_buffer_.size() && handle_name_.empty()) { |
| 122 ULONG size = MAX_PATH; | 123 ULONG size = MAX_PATH; |
| 123 scoped_ptr<UNICODE_STRING> name; | 124 scoped_ptr<UNICODE_STRING, base::FreeDeleter> name; |
| 124 do { | 125 do { |
| 125 name.reset(reinterpret_cast<UNICODE_STRING*>(new BYTE[size])); | 126 name.reset(static_cast<UNICODE_STRING*>(malloc(size))); |
| 127 DCHECK(name.get()); |
| 126 result = QueryObject(reinterpret_cast<HANDLE>( | 128 result = QueryObject(reinterpret_cast<HANDLE>( |
| 127 handle_entry_->Handle), ObjectNameInformation, name.get(), | 129 handle_entry_->Handle), ObjectNameInformation, name.get(), |
| 128 size, &size); | 130 size, &size); |
| 129 } while (result == STATUS_INFO_LENGTH_MISMATCH); | 131 } while (result == STATUS_INFO_LENGTH_MISMATCH); |
| 130 | 132 |
| 131 if (NT_SUCCESS(result)) { | 133 if (NT_SUCCESS(result)) { |
| 132 handle_name_.assign(name->Buffer, name->Length / sizeof(wchar_t)); | 134 handle_name_.assign(name->Buffer, name->Length / sizeof(wchar_t)); |
| 133 } | 135 } |
| 134 } | 136 } |
| 135 break; | 137 break; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 const SYSTEM_HANDLE_INFORMATION* start, | 174 const SYSTEM_HANDLE_INFORMATION* start, |
| 173 const SYSTEM_HANDLE_INFORMATION* end) | 175 const SYSTEM_HANDLE_INFORMATION* end) |
| 174 : table_(table), current_(start), end_(end) { | 176 : table_(table), current_(start), end_(end) { |
| 175 } | 177 } |
| 176 | 178 |
| 177 HandleTable::Iterator::Iterator(const Iterator& it) | 179 HandleTable::Iterator::Iterator(const Iterator& it) |
| 178 : table_(it.table_), current_(it.current_.handle_entry_), end_(it.end_) { | 180 : table_(it.table_), current_(it.current_.handle_entry_), end_(it.end_) { |
| 179 } | 181 } |
| 180 | 182 |
| 181 } // namespace sandbox | 183 } // namespace sandbox |
| OLD | NEW |