| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/heap_helper.h" | 5 #include "sandbox/win/src/heap_helper.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 std::unique_ptr<HANDLE[]> all_heaps(new HANDLE[number_of_heaps]); | 41 std::unique_ptr<HANDLE[]> all_heaps(new HANDLE[number_of_heaps]); |
| 42 if (::GetProcessHeaps(number_of_heaps, all_heaps.get()) != number_of_heaps) | 42 if (::GetProcessHeaps(number_of_heaps, all_heaps.get()) != number_of_heaps) |
| 43 return nullptr; | 43 return nullptr; |
| 44 | 44 |
| 45 // Search for the CSR port heap handle, identified purely based on flags. | 45 // Search for the CSR port heap handle, identified purely based on flags. |
| 46 HANDLE csr_port_heap = nullptr; | 46 HANDLE csr_port_heap = nullptr; |
| 47 for (size_t i = 0; i < number_of_heaps; ++i) { | 47 for (size_t i = 0; i < number_of_heaps; ++i) { |
| 48 HANDLE handle = all_heaps[i]; | 48 HANDLE handle = all_heaps[i]; |
| 49 DWORD flags = 0; | 49 DWORD flags = 0; |
| 50 if (!HeapFlags(handle, &flags)) { | 50 if (!HeapFlags(handle, &flags)) { |
| 51 LOG(ERROR) << "Unable to get flags for this heap"; | 51 DLOG(ERROR) << "Unable to get flags for this heap"; |
| 52 continue; | 52 continue; |
| 53 } | 53 } |
| 54 if ((flags & HEAP_CLASS_MASK) == HEAP_CLASS_8) { | 54 if ((flags & HEAP_CLASS_MASK) == HEAP_CLASS_8) { |
| 55 if (nullptr != csr_port_heap) { | 55 if (nullptr != csr_port_heap) { |
| 56 LOG(ERROR) << "Found multiple suitable CSR Port heaps"; | 56 DLOG(ERROR) << "Found multiple suitable CSR Port heaps"; |
| 57 return nullptr; | 57 return nullptr; |
| 58 } | 58 } |
| 59 csr_port_heap = handle; | 59 csr_port_heap = handle; |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 return csr_port_heap; | 62 return csr_port_heap; |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace sandbox | 65 } // namespace sandbox |
| OLD | NEW |