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

Unified Diff: snapshot/win/process_snapshot_win.cc

Issue 1360863006: win: Add more memory regions to gathering of PEB (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@save-peb
Patch Set: rebase 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
« snapshot/win/process_snapshot_win.h ('K') | « snapshot/win/process_snapshot_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: snapshot/win/process_snapshot_win.cc
diff --git a/snapshot/win/process_snapshot_win.cc b/snapshot/win/process_snapshot_win.cc
index b9df62c0ab4c011109ab9054f5b556141958d658..e64d783d5b1ab4ef2b78d7894448b376b1c52b78 100644
--- a/snapshot/win/process_snapshot_win.cc
+++ b/snapshot/win/process_snapshot_win.cc
@@ -48,10 +48,11 @@ bool ProcessSnapshotWin::Initialize(HANDLE process,
return false;
system_.Initialize(&process_reader_);
- WinVMAddress peb_address;
- WinVMSize peb_size;
- process_reader_.GetProcessInfo().Peb(&peb_address, &peb_size);
- peb_.Initialize(&process_reader_, peb_address, peb_size);
+
+ if (process_reader_.Is64Bit())
+ InitializePebData<process_types::internal::Traits64>();
+ else
+ InitializePebData<process_types::internal::Traits32>();
InitializeThreads();
InitializeModules();
@@ -186,7 +187,8 @@ const ExceptionSnapshot* ProcessSnapshotWin::Exception() const {
std::vector<const MemorySnapshot*> ProcessSnapshotWin::ExtraMemory() const {
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
std::vector<const MemorySnapshot*> extra_memory;
- extra_memory.push_back(&peb_);
+ for (const auto& peb_memory : peb_memory_)
+ extra_memory.push_back(peb_memory);
return extra_memory;
}
@@ -214,4 +216,51 @@ void ProcessSnapshotWin::InitializeModules() {
}
}
+template <class Traits>
+void ProcessSnapshotWin::InitializePebData() {
+ WinVMAddress peb_address;
+ WinVMSize peb_size;
+ process_reader_.GetProcessInfo().Peb(&peb_address, &peb_size);
+ peb_memory_.push_back(CreateMemorySnapshot(peb_address, peb_size));
+
+ process_types::PEB<Traits> peb_data;
+ if (!process_reader_.ReadMemory(peb_address, peb_size, &peb_data)) {
+ LOG(ERROR) << "ReadMemory PEB";
+ return;
+ }
+ peb_memory_.push_back(CreateMemorySnapshot(
+ peb_data.Ldr, sizeof(process_types::PEB_LDR_DATA<Traits>)));
+
+ process_types::RTL_USER_PROCESS_PARAMETERS<Traits> process_parameters;
+ if (!process_reader_.ReadMemory(peb_data.ProcessParameters,
+ sizeof(process_parameters),
+ &process_parameters)) {
+ LOG(ERROR) << "ReadMemory RTL_USER_PROCESS_PARAMETERS";
+ return;
+ }
+
+ peb_memory_.push_back(CreateMemorySnapshotForUNICODE_STRING(
+ process_parameters.CurrentDirectory.DosPath));
+ peb_memory_.push_back(
+ CreateMemorySnapshotForUNICODE_STRING(process_parameters.DllPath));
Mark Mentovai 2015/09/25 21:10:16 The “now” section of the CL description seems to i
scottmg 2015/09/25 22:52:25 Yes, it's often null in a live process too. It's t
+ peb_memory_.push_back(
+ CreateMemorySnapshotForUNICODE_STRING(process_parameters.ImagePathName));
+ peb_memory_.push_back(
+ CreateMemorySnapshotForUNICODE_STRING(process_parameters.CommandLine));
+ // http://blogs.msdn.com/b/oldnewthing/archive/2010/02/03/9957320.aspx On
+ // newer OSs there's no stated limit, but in practice grabbing 32k should be
+ // more than enough.
+ const int kMaxEnvironmentBlockSize = 32768;
+ peb_memory_.push_back(CreateMemorySnapshot(process_parameters.Environment,
+ kMaxEnvironmentBlockSize));
Mark Mentovai 2015/09/25 21:10:16 It might be worth trying to work out the actual si
scottmg 2015/09/25 22:52:25 I don't know of any way other than probing the tar
Mark Mentovai 2015/09/25 23:11:59 scottmg wrote:
scottmg 2015/09/26 00:07:38 Yeah, that was my thinking too. But then I was wor
+}
+
+internal::MemorySnapshotWin* ProcessSnapshotWin::CreateMemorySnapshot(
+ WinVMAddress address,
+ WinVMAddress size) {
Mark Mentovai 2015/09/25 21:10:16 If size is 0, it’s probably worth not creating any
scottmg 2015/09/25 22:52:25 Done.
+ internal::MemorySnapshotWin* ret = new internal::MemorySnapshotWin();
+ ret->Initialize(&process_reader_, address, size);
+ return ret;
+}
+
} // namespace crashpad
« snapshot/win/process_snapshot_win.h ('K') | « snapshot/win/process_snapshot_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698