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

Unified Diff: snapshot/win/pe_image_reader.cc

Issue 1430773003: win: Handle binary with embedded CodeView debug record (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: rebase Created 5 years, 2 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
« no previous file with comments | « snapshot/win/module_snapshot_win.cc ('k') | util/win/process_info.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: snapshot/win/pe_image_reader.cc
diff --git a/snapshot/win/pe_image_reader.cc b/snapshot/win/pe_image_reader.cc
index b6bb7aa6ef076478536a1c0bd84f96ef5c49a9ed..82bce0645ad57f82fcf6dc6f69b073660b20f9c1 100644
--- a/snapshot/win/pe_image_reader.cc
+++ b/snapshot/win/pe_image_reader.cc
@@ -176,35 +176,41 @@ bool PEImageReader::ReadDebugDirectoryInformation(UUID* uuid,
if (debug_directory.Type != IMAGE_DEBUG_TYPE_CODEVIEW)
continue;
- if (debug_directory.SizeOfData < sizeof(CodeViewRecordPDB70)) {
- LOG(WARNING) << "CodeView debug entry of unexpected size";
- continue;
- }
- scoped_ptr<char[]> data(new char[debug_directory.SizeOfData]);
- if (!CheckedReadMemory(Address() + debug_directory.AddressOfRawData,
- debug_directory.SizeOfData,
- data.get())) {
- LOG(WARNING) << "could not read debug directory";
- return false;
- }
-
- if (*reinterpret_cast<DWORD*>(data.get()) !=
- CodeViewRecordPDB70::kSignature) {
- // TODO(scottmg): Consider supporting other record types, see
+ if (debug_directory.AddressOfRawData) {
+ if (debug_directory.SizeOfData < sizeof(CodeViewRecordPDB70)) {
+ LOG(WARNING) << "CodeView debug entry of unexpected size";
+ continue;
+ }
+
+ scoped_ptr<char[]> data(new char[debug_directory.SizeOfData]);
+ if (!CheckedReadMemory(Address() + debug_directory.AddressOfRawData,
+ debug_directory.SizeOfData,
+ data.get())) {
+ LOG(WARNING) << "could not read debug directory";
+ return false;
+ }
+
+ if (*reinterpret_cast<DWORD*>(data.get()) !=
+ CodeViewRecordPDB70::kSignature) {
+ LOG(WARNING) << "encountered non-7.0 CodeView debug record";
+ continue;
+ }
+
+ CodeViewRecordPDB70* codeview =
+ reinterpret_cast<CodeViewRecordPDB70*>(data.get());
+ *uuid = codeview->uuid;
+ *age = codeview->age;
+ // This is a NUL-terminated string encoded in the codepage of the system
+ // where the binary was linked. We have no idea what that was, so we just
+ // assume ASCII.
+ *pdbname = std::string(reinterpret_cast<char*>(&codeview->pdb_name[0]));
+ return true;
+ } else if (debug_directory.PointerToRawData) {
+ // This occurs for non-PDB based debug information. We simply ignore these
+ // as we don't expect to encounter modules that will be in this format
+ // for which we'll actually have symbols. See
// https://crashpad.chromium.org/bug/47.
- LOG(WARNING) << "encountered non-7.0 CodeView debug record";
- continue;
}
-
- CodeViewRecordPDB70* codeview =
- reinterpret_cast<CodeViewRecordPDB70*>(data.get());
- *uuid = codeview->uuid;
- *age = codeview->age;
- // This is a NUL-terminated string encoded in the codepage of the system
- // where the binary was linked. We have no idea what that was, so we just
- // assume ASCII.
- *pdbname = std::string(reinterpret_cast<char*>(&codeview->pdb_name[0]));
- return true;
}
return false;
« no previous file with comments | « snapshot/win/module_snapshot_win.cc ('k') | util/win/process_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698