| OLD | NEW |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 OBJECT_INFORMATION_CLASS object_information_class, | 150 OBJECT_INFORMATION_CLASS object_information_class, |
| 151 ULONG minimum_size) { | 151 ULONG minimum_size) { |
| 152 ULONG size = minimum_size; | 152 ULONG size = minimum_size; |
| 153 ULONG return_length; | 153 ULONG return_length; |
| 154 std::unique_ptr<uint8_t[]> buffer(new uint8_t[size]); | 154 std::unique_ptr<uint8_t[]> buffer(new uint8_t[size]); |
| 155 NTSTATUS status = crashpad::NtQueryObject( | 155 NTSTATUS status = crashpad::NtQueryObject( |
| 156 handle, object_information_class, buffer.get(), size, &return_length); | 156 handle, object_information_class, buffer.get(), size, &return_length); |
| 157 if (status == STATUS_INFO_LENGTH_MISMATCH) { | 157 if (status == STATUS_INFO_LENGTH_MISMATCH) { |
| 158 DCHECK_GT(return_length, size); | 158 DCHECK_GT(return_length, size); |
| 159 size = return_length; | 159 size = return_length; |
| 160 |
| 161 // Free the old buffer before attempting to allocate a new one. |
| 162 buffer.reset(); |
| 163 |
| 160 buffer.reset(new uint8_t[size]); | 164 buffer.reset(new uint8_t[size]); |
| 161 status = crashpad::NtQueryObject( | 165 status = crashpad::NtQueryObject( |
| 162 handle, object_information_class, buffer.get(), size, &return_length); | 166 handle, object_information_class, buffer.get(), size, &return_length); |
| 163 } | 167 } |
| 164 | 168 |
| 165 if (!NT_SUCCESS(status)) { | 169 if (!NT_SUCCESS(status)) { |
| 166 NTSTATUS_LOG(ERROR, status) << "NtQueryObject"; | 170 NTSTATUS_LOG(ERROR, status) << "NtQueryObject"; |
| 167 return nullptr; | 171 return nullptr; |
| 168 } | 172 } |
| 169 | 173 |
| 174 DCHECK_LE(return_length, size); |
| 170 DCHECK_GE(return_length, minimum_size); | 175 DCHECK_GE(return_length, minimum_size); |
| 171 return buffer; | 176 return buffer; |
| 172 } | 177 } |
| 173 | 178 |
| 174 } // namespace | 179 } // namespace |
| 175 | 180 |
| 176 template <class Traits> | 181 template <class Traits> |
| 177 bool GetProcessBasicInformation(HANDLE process, | 182 bool GetProcessBasicInformation(HANDLE process, |
| 178 bool is_wow64, | 183 bool is_wow64, |
| 179 ProcessInfo* process_info, | 184 ProcessInfo* process_info, |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 } else { | 720 } else { |
| 716 result.push_back(as_ranges[i]); | 721 result.push_back(as_ranges[i]); |
| 717 } | 722 } |
| 718 DCHECK(result.back().IsValid()); | 723 DCHECK(result.back().IsValid()); |
| 719 } | 724 } |
| 720 | 725 |
| 721 return result; | 726 return result; |
| 722 } | 727 } |
| 723 | 728 |
| 724 } // namespace crashpad | 729 } // namespace crashpad |
| OLD | NEW |