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/src/handle_closer_agent.h" | 5 #include "sandbox/src/handle_closer_agent.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "sandbox/src/nt_internals.h" | 8 #include "sandbox/src/nt_internals.h" |
9 #include "sandbox/src/win_utils.h" | 9 #include "sandbox/src/win_utils.h" |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // Keep incrementing until we hit the number of handles reported by | 75 // Keep incrementing until we hit the number of handles reported by |
76 // GetProcessHandleCount(). If we hit a very long sequence of invalid | 76 // GetProcessHandleCount(). If we hit a very long sequence of invalid |
77 // handles we assume that we've run past the end of the table. | 77 // handles we assume that we've run past the end of the table. |
78 while (handle_count && invalid_count < kInvalidHandleThreshold) { | 78 while (handle_count && invalid_count < kInvalidHandleThreshold) { |
79 reinterpret_cast<size_t&>(handle) += kHandleOffset; | 79 reinterpret_cast<size_t&>(handle) += kHandleOffset; |
80 NTSTATUS rc; | 80 NTSTATUS rc; |
81 | 81 |
82 // Get the type name, reusing the buffer. | 82 // Get the type name, reusing the buffer. |
83 ULONG size = static_cast<ULONG>(type_info_buffer.size()); | 83 ULONG size = static_cast<ULONG>(type_info_buffer.size()); |
84 rc = QueryObject(handle, ObjectTypeInformation, type_info, size, &size); | 84 rc = QueryObject(handle, ObjectTypeInformation, type_info, size, &size); |
85 while (rc == STATUS_INFO_LENGTH_MISMATCH) { | 85 while (rc == STATUS_INFO_LENGTH_MISMATCH || |
| 86 rc == STATUS_BUFFER_OVERFLOW) { |
86 type_info_buffer.resize(size + sizeof(wchar_t)); | 87 type_info_buffer.resize(size + sizeof(wchar_t)); |
87 type_info = reinterpret_cast<OBJECT_TYPE_INFORMATION*>( | 88 type_info = reinterpret_cast<OBJECT_TYPE_INFORMATION*>( |
88 &(type_info_buffer[0])); | 89 &(type_info_buffer[0])); |
89 rc = QueryObject(handle, ObjectTypeInformation, type_info, size, &size); | 90 rc = QueryObject(handle, ObjectTypeInformation, type_info, size, &size); |
90 // Leave padding for the nul terminator. | 91 // Leave padding for the nul terminator. |
91 if (NT_SUCCESS(0) && size == type_info_buffer.size()) | 92 if (NT_SUCCESS(0) && size == type_info_buffer.size()) |
92 rc = STATUS_INFO_LENGTH_MISMATCH; | 93 rc = STATUS_INFO_LENGTH_MISMATCH; |
93 } | 94 } |
94 if (!NT_SUCCESS(rc)) { | 95 if (!NT_SUCCESS(rc)) { |
95 ++invalid_count; | 96 ++invalid_count; |
(...skipping 19 matching lines...) Expand all Loading... |
115 return false; | 116 return false; |
116 if (!::CloseHandle(handle)) | 117 if (!::CloseHandle(handle)) |
117 return false; | 118 return false; |
118 } | 119 } |
119 } | 120 } |
120 | 121 |
121 return true; | 122 return true; |
122 } | 123 } |
123 | 124 |
124 } // namespace sandbox | 125 } // namespace sandbox |
OLD | NEW |