Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: snapshot/win/pe_image_reader.cc

Issue 1355503005: win: Make reading CrashpadInfo work across bitness (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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", &section))
@@ -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

Powered by Google App Engine
This is Rietveld 408576698