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

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

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/process_subrange_reader.h ('k') | snapshot/win/system_snapshot_win.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 #include "snapshot/win/process_subrange_reader.h"
16
17 #include "base/logging.h"
18 #include "snapshot/win/process_reader_win.h"
19
20 namespace crashpad {
21
22 ProcessSubrangeReader::ProcessSubrangeReader()
23 : name_(),
24 range_(),
25 process_reader_(nullptr) {
26 }
27
28 ProcessSubrangeReader::~ProcessSubrangeReader() {
29 }
30
31 bool ProcessSubrangeReader::Initialize(ProcessReaderWin* process_reader,
32 WinVMAddress base,
33 WinVMSize size,
34 const std::string& name) {
35 INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
36
37 if (!InitializeInternal(process_reader, base, size, name)) {
38 return false;
39 }
40
41 INITIALIZATION_STATE_SET_VALID(initialized_);
42 return true;
43 }
44
45 bool ProcessSubrangeReader::InitializeSubrange(
46 const ProcessSubrangeReader& that,
47 WinVMAddress base,
48 WinVMSize size,
49 const std::string& sub_name) {
50 INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
51 INITIALIZATION_STATE_DCHECK_VALID(that.initialized_);
52
53 if (!InitializeInternal(
54 that.process_reader_, base, size, that.name_ + " " + sub_name)) {
55 return false;
56 }
57
58 if (!that.range_.ContainsRange(range_)) {
59 LOG(WARNING) << "range " << range_.AsString() << " outside of range "
60 << that.range_.AsString() << " for " << name_;
61 return false;
62 }
63
64 INITIALIZATION_STATE_SET_VALID(initialized_);
65 return true;
66 }
67
68 bool ProcessSubrangeReader::ReadMemory(WinVMAddress address,
69 WinVMSize size,
70 void* into) const {
71 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
72
73 CheckedWinAddressRange read_range(process_reader_->Is64Bit(), address, size);
74 if (!read_range.IsValid()) {
75 LOG(WARNING) << "invalid read range " << read_range.AsString();
76 return false;
77 }
78
79 if (!range_.ContainsRange(read_range)) {
80 LOG(WARNING) << "attempt to read outside of " << name_ << " range "
81 << range_.AsString() << " at range " << read_range.AsString();
82 return false;
83 }
84
85 return process_reader_->ReadMemory(address, size, into);
86 }
87
88 bool ProcessSubrangeReader::InitializeInternal(ProcessReaderWin* process_reader,
89 WinVMAddress base,
90 WinVMSize size,
91 const std::string& name) {
92 range_.SetRange(process_reader->Is64Bit(), base, size);
93 if (!range_.IsValid()) {
94 LOG(WARNING) << "invalid range " << range_.AsString() << " for " << name;
95 return false;
96 }
97
98 name_ = name;
99 process_reader_ = process_reader;
100
101 return true;
102 }
103
104 } // namespace crashpad
OLDNEW
« no previous file with comments | « snapshot/win/process_subrange_reader.h ('k') | snapshot/win/system_snapshot_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698