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

Unified Diff: snapshot/win/process_reader_win.cc

Issue 1052813002: win: make CrashpadInfo retrievable (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: more fixes Created 5 years, 8 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/process_reader_win.h ('k') | snapshot/win/process_reader_win_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: snapshot/win/process_reader_win.cc
diff --git a/snapshot/win/process_reader_win.cc b/snapshot/win/process_reader_win.cc
index 383a66464a113334dd593e004d0d733da4b543a4..c0a3c56b454207a1b4669a3e2de9ae0ddba8a429 100644
--- a/snapshot/win/process_reader_win.cc
+++ b/snapshot/win/process_reader_win.cc
@@ -14,9 +14,15 @@
#include "snapshot/win/process_reader_win.h"
+#include "base/numerics/safe_conversions.h"
+
namespace crashpad {
-ProcessReaderWin::ProcessReaderWin() : process_info_(), initialized_() {
+ProcessReaderWin::ProcessReaderWin()
+ : process_(INVALID_HANDLE_VALUE),
+ process_info_(),
+ modules_(),
+ initialized_() {
}
ProcessReaderWin::~ProcessReaderWin() {
@@ -25,10 +31,37 @@ ProcessReaderWin::~ProcessReaderWin() {
bool ProcessReaderWin::Initialize(HANDLE process) {
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
+ process_ = process;
process_info_.Initialize(process);
INITIALIZATION_STATE_SET_VALID(initialized_);
return true;
}
+bool ProcessReaderWin::ReadMemory(WinVMAddress at,
+ WinVMSize num_bytes,
+ void* into) {
+ SIZE_T bytes_read;
+ if (!ReadProcessMemory(process_,
+ reinterpret_cast<void*>(at),
+ into,
+ base::checked_cast<SIZE_T>(num_bytes),
+ &bytes_read) ||
+ num_bytes != bytes_read) {
+ PLOG(ERROR) << "ReadMemory at " << at << " of " << num_bytes << " failed";
+ return false;
+ }
+ return true;
+}
+
+const std::vector<ProcessInfo::Module>& ProcessReaderWin::Modules() {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+
+ if (!process_info_.Modules(&modules_)) {
+ LOG(ERROR) << "couldn't retrieve modules";
+ }
+
+ return modules_;
+}
+
} // namespace crashpad
« no previous file with comments | « snapshot/win/process_reader_win.h ('k') | snapshot/win/process_reader_win_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698