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

Side by Side Diff: snapshot/win/process_reader_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, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with 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 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 process_ = process; 206 process_ = process;
207 suspension_state_ = suspension_state; 207 suspension_state_ = suspension_state;
208 process_info_.Initialize(process); 208 process_info_.Initialize(process);
209 209
210 INITIALIZATION_STATE_SET_VALID(initialized_); 210 INITIALIZATION_STATE_SET_VALID(initialized_);
211 return true; 211 return true;
212 } 212 }
213 213
214 bool ProcessReaderWin::ReadMemory(WinVMAddress at, 214 bool ProcessReaderWin::ReadMemory(WinVMAddress at,
215 WinVMSize num_bytes, 215 WinVMSize num_bytes,
216 void* into) const { 216 void* into) const {
Mark Mentovai 2015/10/01 19:05:47 Possibly this and ReadAvailableMemory() should bot
scottmg 2015/10/01 20:17:01 Done.
217 SIZE_T bytes_read; 217 SIZE_T bytes_read;
218 if (!ReadProcessMemory(process_, 218 if (!ReadProcessMemory(process_,
219 reinterpret_cast<void*>(at), 219 reinterpret_cast<void*>(at),
220 into, 220 into,
221 base::checked_cast<SIZE_T>(num_bytes), 221 base::checked_cast<SIZE_T>(num_bytes),
222 &bytes_read) || 222 &bytes_read) ||
223 num_bytes != bytes_read) { 223 num_bytes != bytes_read) {
224 PLOG(ERROR) << "ReadMemory at 0x" << std::hex << at << std::dec << " of " 224 PLOG(ERROR) << "ReadMemory at 0x" << std::hex << at << std::dec << " of "
225 << num_bytes << " bytes failed"; 225 << num_bytes << " bytes failed";
226 return false; 226 return false;
227 } 227 }
228 return true; 228 return true;
229 } 229 }
230 230
231 WinVMSize ProcessReaderWin::ReadAvailableMemory(WinVMAddress at,
232 WinVMSize num_bytes,
233 void* into) const {
234 auto ranges = process_info_.GetReadableRanges(
235 CheckedRange<WinVMAddress, WinVMSize>(at, num_bytes));
236 // We only read up until the first unavailable block, so we only read from the
Mark Mentovai 2015/10/01 19:05:47 Put some blank lines before these comments that ap
scottmg 2015/10/01 20:17:01 Done.
237 // first range.
238 if (ranges.empty())
239 return 0;
Mark Mentovai 2015/10/01 19:05:47 LOG something on the return-0s that don’t pass thr
scottmg 2015/10/01 20:17:01 I was thinking since we're using this in a trial-a
Mark Mentovai 2015/10/01 22:00:52 scottmg wrote:
240 // If the start address was adjusted, we couldn't read even the first
241 // requested byte.
242 if (ranges.front().base() != at)
243 return 0;
244 // If we fail on a normal read, then something went very wrong.
245 if (!ReadMemory(ranges.front().base(), ranges.front().size(), into))
Mark Mentovai 2015/10/01 19:05:47 It’s not strictly necessary because the tests shou
scottmg 2015/10/01 20:17:01 Done.
246 return 0;
247 return ranges.front().size();
248 }
249
231 bool ProcessReaderWin::StartTime(timeval* start_time) const { 250 bool ProcessReaderWin::StartTime(timeval* start_time) const {
232 FILETIME creation, exit, kernel, user; 251 FILETIME creation, exit, kernel, user;
233 if (!GetProcessTimes(process_, &creation, &exit, &kernel, &user)) { 252 if (!GetProcessTimes(process_, &creation, &exit, &kernel, &user)) {
234 PLOG(ERROR) << "GetProcessTimes"; 253 PLOG(ERROR) << "GetProcessTimes";
235 return false; 254 return false;
236 } 255 }
237 *start_time = FiletimeToTimevalEpoch(creation); 256 *start_time = FiletimeToTimevalEpoch(creation);
238 return true; 257 return true;
239 } 258 }
240 259
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 thread.stack_region_size = 0; 381 thread.stack_region_size = 0;
363 } else { 382 } else {
364 thread.stack_region_size = base - limit; 383 thread.stack_region_size = base - limit;
365 } 384 }
366 } 385 }
367 threads_.push_back(thread); 386 threads_.push_back(thread);
368 } 387 }
369 } 388 }
370 389
371 } // namespace crashpad 390 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698