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

Unified Diff: util/win/process_info.h

Issue 1372183002: win: Add memory map range intersection helper (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: const 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: util/win/process_info.h
diff --git a/util/win/process_info.h b/util/win/process_info.h
index 5af28bd762bddabcc62f2f8be5e7cb88150f7ff0..58b10135669dbfa47b8d837ac521390a292fef52 100644
--- a/util/win/process_info.h
+++ b/util/win/process_info.h
@@ -23,6 +23,7 @@
#include "base/basictypes.h"
#include "util/misc/initialization_state_dcheck.h"
+#include "util/numeric/checked_range.h"
#include "util/win/address_types.h"
namespace crashpad {
@@ -52,6 +53,7 @@ class ProcessInfo {
// \brief Contains information about a range of pages in the virtual address
// space of a process.
struct MemoryInfo {
+ MemoryInfo();
Mark Mentovai 2015/10/01 17:38:59 We killed this in https://codereview.chromium.org/
scottmg 2015/10/01 18:10:02 Done.
explicit MemoryInfo(const MEMORY_BASIC_INFORMATION& mbi);
~MemoryInfo();
@@ -129,6 +131,16 @@ class ProcessInfo {
//! \brief Retrieves information about all pages mapped into the process.
const std::vector<MemoryInfo>& MemoryInformation() const;
+ //! \brief Given a range to be read from the target process, returns a vector
+ //! of ranges, representing the readable portions of the original range.
+ //!
+ //! \param[in] range The range being identified.
+ //!
+ //! \return A vector of ranges corresponding to the portion of the range
+ //! identified by \a range that are readable, based on the memory map.
+ std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges(
+ const CheckedRange<WinVMAddress, WinVMSize>& range) const;
+
private:
template <class Traits>
friend bool GetProcessBasicInformation(HANDLE process,
@@ -157,6 +169,18 @@ class ProcessInfo {
DISALLOW_COPY_AND_ASSIGN(ProcessInfo);
};
+//! \brief Given a memory map of a process, and a range to be read from the
+//! target process, returns a vector of ranges, representing the readable
+//! portions of the original range.
+//!
+//! This is a free function for testing, but prefer
+//! ProcessInfo::GetReadableRanges().
+//!
+//! \sa ProcessInfo::GetReadableRanges()
Mark Mentovai 2015/10/01 17:38:59 I don’t think you need to say \sa when you just ga
scottmg 2015/10/01 18:10:02 Done.
+std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap(
+ const CheckedRange<WinVMAddress, WinVMSize>& range,
+ const std::vector<ProcessInfo::MemoryInfo>& memory_info);
+
} // namespace crashpad
#endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_

Powered by Google App Engine
This is Rietveld 408576698