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

Side by Side Diff: snapshot/win/process_subrange_reader.h

Issue 1475023004: Get module versions and types from in-memory images (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback (2) Created 5 years 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 unified diff | Download patch
« no previous file with comments | « snapshot/win/pe_image_resource_reader.cc ('k') | snapshot/win/process_subrange_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef CRASHPAD_SNAPSHOT_WIN_PROCESS_SUBRANGE_READER_WIN_H_
16 #define CRASHPAD_SNAPSHOT_WIN_PROCESS_SUBRANGE_READER_WIN_H_
17
18 #include <string>
19
20 #include "base/basictypes.h"
21 #include "util/misc/initialization_state_dcheck.h"
22 #include "util/win/address_types.h"
23 #include "util/win/checked_win_address_range.h"
24
25 namespace crashpad {
26
27 class ProcessReaderWin;
28
29 //! \brief A wrapper for ProcessReaderWin that only allows a specific subrange
30 //! to be read from.
31 //!
32 //! This class is useful to restrict reads to a specific address range, such as
33 //! the address range occupied by a loaded module, or a specific section within
34 //! a module.
35 class ProcessSubrangeReader {
36 public:
37 ProcessSubrangeReader();
38 ~ProcessSubrangeReader();
39
40 //! \brief Initializes the object.
41 //!
42 //! \param[in] process_reader A reader for a remote process.
43 //! \param[in] base The base address for the range that reads should be
44 //! restricted to.
45 //! \param[in] size The size of the range that reads should be restricted to.
46 //! \param[in] name The range’s name, a string to be used in logged messages.
47 //! This string is for diagnostic purposes.
48 //!
49 //! \return `true` on success, `false` on failure with a message logged. The
50 //! other methods in this class must not be called unless this method or
51 //! InitializeSubrange() has returned true.
52 bool Initialize(ProcessReaderWin* process_reader,
53 WinVMAddress base,
54 WinVMSize size,
55 const std::string& name);
56
57 //! \brief Initializes the object to a subrange of an existing
58 //! ProcessSubrangeReader.
59 //!
60 //! The subrange identified by \a base and \a size must be contained within
61 //! the subrange in \a that.
62 //!
63 //! \param[in] that The existing ProcessSubrangeReader to base the new object
64 //! on.
65 //! \param[in] base The base address for the range that reads should be
66 //! restricted to.
67 //! \param[in] size The size of the range that reads should be restricted to.
68 //! \param[in] sub_name A description of the subrange, which will be appended
69 //! to the \a name in \a that and used in logged messages. This string is
70 //! for diagnostic purposes.
71 //!
72 //! \return `true` on success, `false` on failure with a message logged. The
73 //! other methods in this class must not be called unless this method or
74 //! Initialize() has returned true.
75 bool InitializeSubrange(const ProcessSubrangeReader& that,
76 WinVMAddress base,
77 WinVMSize size,
78 const std::string& sub_name);
79
80 bool Is64Bit() const { return range_.Is64Bit(); }
81 WinVMAddress Base() const { return range_.Base(); }
82 WinVMAddress Size() const { return range_.Size(); }
83 const std::string& name() const { return name_; }
84
85 //! \brief Reads memory from the remote process.
86 //!
87 //! The range specified by \a address and \a size must be contained within
88 //! the range that this object is permitted to read.
89 //!
90 //! \param[in] address The address to read from.
91 //! \param[in] size The size of data to read, in bytes.
92 //! \param[out] into The buffer to read data into.
93 //!
94 //! \return `true` on success, `false` on failure with a message logged.
95 bool ReadMemory(WinVMAddress address, WinVMSize size, void* into) const;
96
97 private:
98 // Common helper for Initialize() and InitializeSubrange().
99 bool InitializeInternal(ProcessReaderWin* process_reader,
100 WinVMAddress base,
101 WinVMSize size,
102 const std::string& name);
103
104 std::string name_;
105 CheckedWinAddressRange range_;
106 ProcessReaderWin* process_reader_; // weak
107 InitializationStateDcheck initialized_;
108
109 DISALLOW_COPY_AND_ASSIGN(ProcessSubrangeReader);
110 };
111
112 } // namespace crashpad
113
114 #endif // CRASHPAD_SNAPSHOT_WIN_PROCESS_SUBRANGE_READER_WIN_H_
OLDNEW
« no previous file with comments | « snapshot/win/pe_image_resource_reader.cc ('k') | snapshot/win/process_subrange_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698