Index: snapshot/win/pe_image_reader.cc |
diff --git a/snapshot/win/pe_image_reader.cc b/snapshot/win/pe_image_reader.cc |
index 3aba5b892e51ef129ccbfdb7d4e337576a581773..b39fb24b5b789663552c556ec7a23e76a4295119 100644 |
--- a/snapshot/win/pe_image_reader.cc |
+++ b/snapshot/win/pe_image_reader.cc |
@@ -22,6 +22,7 @@ |
#include "client/crashpad_info.h" |
#include "snapshot/win/process_reader_win.h" |
#include "util/misc/pdb_structures.h" |
+#include "util/win/process_structs.h" |
namespace crashpad { |
@@ -65,10 +66,13 @@ bool PEImageReader::Initialize(ProcessReaderWin* process_reader, |
return true; |
} |
+template <class Traits> |
bool PEImageReader::GetCrashpadInfo( |
- process_types::CrashpadInfo* crashpad_info) const { |
+ process_types::CrashpadInfo<Traits>* crashpad_info) const { |
INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
+ // TODO(scottmg): This could be simplified as we know what we're reading based |
+ // on Traits. |
IMAGE_SECTION_HEADER section; |
if (process_reader_->Is64Bit()) { |
if (!GetSectionByName<IMAGE_NT_HEADERS64>("CPADinfo", §ion)) |
@@ -78,7 +82,7 @@ bool PEImageReader::GetCrashpadInfo( |
return false; |
} |
- if (section.Misc.VirtualSize < sizeof(process_types::CrashpadInfo)) { |
+ if (section.Misc.VirtualSize < sizeof(process_types::CrashpadInfo<Traits>)) { |
LOG(WARNING) << "small crashpad info section size " |
<< section.Misc.VirtualSize << ", " << module_name_; |
return false; |
@@ -100,9 +104,8 @@ bool PEImageReader::GetCrashpadInfo( |
return false; |
} |
- // TODO(scottmg): process_types for cross-bitness. |
if (!process_reader_->ReadMemory(crashpad_info_address, |
- sizeof(process_types::CrashpadInfo), |
+ sizeof(process_types::CrashpadInfo<Traits>), |
crashpad_info)) { |
LOG(WARNING) << "could not read crashpad info " << module_name_; |
return false; |
@@ -270,4 +273,13 @@ bool PEImageReader::CheckedReadMemory(WinVMAddress address, |
return process_reader_->ReadMemory(address, size, into); |
} |
+// Explicit instantiations with the only 2 valid template arguments to avoid |
+// putting the body of the function in the header. |
+template bool PEImageReader::GetCrashpadInfo<process_types::internal::Traits32>( |
+ process_types::CrashpadInfo<process_types::internal::Traits32>* |
+ crashpad_info) const; |
+template bool PEImageReader::GetCrashpadInfo<process_types::internal::Traits64>( |
+ process_types::CrashpadInfo<process_types::internal::Traits64>* |
+ crashpad_info) const; |
+ |
} // namespace crashpad |