| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 *peb_size = sizeof(process_types::PEB<process_types::internal::Traits32>); | 215 *peb_size = sizeof(process_types::PEB<process_types::internal::Traits32>); |
| 216 } | 216 } |
| 217 | 217 |
| 218 return true; | 218 return true; |
| 219 } | 219 } |
| 220 | 220 |
| 221 template <class Traits> | 221 template <class Traits> |
| 222 bool ReadProcessData(HANDLE process, | 222 bool ReadProcessData(HANDLE process, |
| 223 WinVMAddress peb_address_vmaddr, | 223 WinVMAddress peb_address_vmaddr, |
| 224 ProcessInfo* process_info) { | 224 ProcessInfo* process_info) { |
| 225 Traits::Pointer peb_address; | 225 typename Traits::Pointer peb_address; |
| 226 if (!AssignIfInRange(&peb_address, peb_address_vmaddr)) { | 226 if (!AssignIfInRange(&peb_address, peb_address_vmaddr)) { |
| 227 LOG(ERROR) << base::StringPrintf("peb address 0x%x out of range", | 227 LOG(ERROR) << base::StringPrintf("peb address 0x%x out of range", |
| 228 peb_address_vmaddr); | 228 peb_address_vmaddr); |
| 229 return false; | 229 return false; |
| 230 } | 230 } |
| 231 | 231 |
| 232 // Try to read the process environment block. | 232 // Try to read the process environment block. |
| 233 process_types::PEB<Traits> peb; | 233 process_types::PEB<Traits> peb; |
| 234 if (!ReadStruct(process, peb_address, &peb)) | 234 if (!ReadStruct(process, peb_address, &peb)) |
| 235 return false; | 235 return false; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 266 return false; | 266 return false; |
| 267 } | 267 } |
| 268 module.dll_base = ldr_data_table_entry.DllBase; | 268 module.dll_base = ldr_data_table_entry.DllBase; |
| 269 module.size = ldr_data_table_entry.SizeOfImage; | 269 module.size = ldr_data_table_entry.SizeOfImage; |
| 270 module.timestamp = ldr_data_table_entry.TimeDateStamp; | 270 module.timestamp = ldr_data_table_entry.TimeDateStamp; |
| 271 process_info->modules_.push_back(module); | 271 process_info->modules_.push_back(module); |
| 272 | 272 |
| 273 // Walk the PEB LDR structure (doubly-linked list) to get the list of loaded | 273 // Walk the PEB LDR structure (doubly-linked list) to get the list of loaded |
| 274 // modules. We use this method rather than EnumProcessModules to get the | 274 // modules. We use this method rather than EnumProcessModules to get the |
| 275 // modules in initialization order rather than memory order. | 275 // modules in initialization order rather than memory order. |
| 276 Traits::Pointer last = peb_ldr_data.InInitializationOrderModuleList.Blink; | 276 typename Traits::Pointer last = |
| 277 for (Traits::Pointer cur = peb_ldr_data.InInitializationOrderModuleList.Flink; | 277 peb_ldr_data.InInitializationOrderModuleList.Blink; |
| 278 for (typename Traits::Pointer cur = |
| 279 peb_ldr_data.InInitializationOrderModuleList.Flink; |
| 278 ; | 280 ; |
| 279 cur = ldr_data_table_entry.InInitializationOrderLinks.Flink) { | 281 cur = ldr_data_table_entry.InInitializationOrderLinks.Flink) { |
| 280 // |cur| is the pointer to the LIST_ENTRY embedded in the | 282 // |cur| is the pointer to the LIST_ENTRY embedded in the |
| 281 // LDR_DATA_TABLE_ENTRY, in the target process's address space. So we need | 283 // LDR_DATA_TABLE_ENTRY, in the target process's address space. So we need |
| 282 // to read from the target, and also offset back to the beginning of the | 284 // to read from the target, and also offset back to the beginning of the |
| 283 // structure. | 285 // structure. |
| 284 if (!ReadStruct(process, | 286 if (!ReadStruct(process, |
| 285 static_cast<WinVMAddress>(cur) - | 287 static_cast<WinVMAddress>(cur) - |
| 286 offsetof(process_types::LDR_DATA_TABLE_ENTRY<Traits>, | 288 offsetof(process_types::LDR_DATA_TABLE_ENTRY<Traits>, |
| 287 InInitializationOrderLinks), | 289 InInitializationOrderLinks), |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 } else { | 683 } else { |
| 682 result.push_back(as_ranges[i]); | 684 result.push_back(as_ranges[i]); |
| 683 } | 685 } |
| 684 DCHECK(result.back().IsValid()); | 686 DCHECK(result.back().IsValid()); |
| 685 } | 687 } |
| 686 | 688 |
| 687 return result; | 689 return result; |
| 688 } | 690 } |
| 689 | 691 |
| 690 } // namespace crashpad | 692 } // namespace crashpad |
| OLD | NEW |