OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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/capture_context_memory.h" | |
16 | |
17 #include "snapshot/win/memory_snapshot_win.h" | |
18 #include "snapshot/win/process_reader_win.h" | |
19 | |
20 namespace crashpad { | |
21 namespace internal { | |
22 | |
23 namespace { | |
24 | |
25 void MaybeCaptureMemoryAround(ProcessReaderWin* process_reader, | |
26 WinVMAddress address, | |
27 PointerVector<MemorySnapshotWin>* into) { | |
28 if (address > 0x10000) { | |
Mark Mentovai
2016/01/08 22:05:42
-1 and other high numbers are valid register conte
scottmg
2016/01/08 22:23:28
Done.
| |
29 const WinVMSize kRegisterByteOffset = 32; | |
30 const WinVMAddress target = address - kRegisterByteOffset; | |
31 const WinVMSize size = 128; | |
32 auto ranges = process_reader->GetProcessInfo().GetReadableRanges( | |
33 CheckedRange<WinVMAddress, WinVMSize>(target, size)); | |
34 for (const auto& range : ranges) { | |
35 internal::MemorySnapshotWin* snapshot = new internal::MemorySnapshotWin(); | |
36 snapshot->Initialize(process_reader, range.base(), range.size()); | |
37 into->push_back(snapshot); | |
Mark Mentovai
2016/01/08 22:05:42
Interesting, so this might miss address but pick u
scottmg
2016/01/08 22:23:28
Yeah, I'm not sure how useful/likely it really is.
| |
38 } | |
39 } | |
40 } | |
41 | |
42 } // namespace | |
43 | |
44 void CaptureMemoryPointedToByContext(const CPUContext& context, | |
45 ProcessReaderWin* process_reader, | |
46 const ProcessReaderWin::Thread& thread, | |
47 PointerVector<MemorySnapshotWin>* into) { | |
48 #if defined(ARCH_CPU_X86_64) | |
49 if (context.architecture == kCPUArchitectureX86_64) { | |
50 MaybeCaptureMemoryAround(process_reader, context.x86_64->rax, into); | |
51 MaybeCaptureMemoryAround(process_reader, context.x86_64->rbx, into); | |
52 MaybeCaptureMemoryAround(process_reader, context.x86_64->rcx, into); | |
53 MaybeCaptureMemoryAround(process_reader, context.x86_64->rdx, into); | |
54 MaybeCaptureMemoryAround(process_reader, context.x86_64->rdi, into); | |
55 MaybeCaptureMemoryAround(process_reader, context.x86_64->rsi, into); | |
56 if (context.x86_64->rbp < thread.stack_region_address || | |
57 context.x86_64->rbp >= | |
58 thread.stack_region_address + thread.stack_region_size) { | |
59 MaybeCaptureMemoryAround(process_reader, context.x86_64->rbp, into); | |
60 } | |
61 MaybeCaptureMemoryAround(process_reader, context.x86_64->r8, into); | |
62 MaybeCaptureMemoryAround(process_reader, context.x86_64->r9, into); | |
63 MaybeCaptureMemoryAround(process_reader, context.x86_64->r10, into); | |
64 MaybeCaptureMemoryAround(process_reader, context.x86_64->r11, into); | |
65 MaybeCaptureMemoryAround(process_reader, context.x86_64->r12, into); | |
66 MaybeCaptureMemoryAround(process_reader, context.x86_64->r13, into); | |
67 MaybeCaptureMemoryAround(process_reader, context.x86_64->r14, into); | |
68 MaybeCaptureMemoryAround(process_reader, context.x86_64->r15, into); | |
69 MaybeCaptureMemoryAround(process_reader, context.x86_64->rip, into); | |
70 } else { | |
71 #endif | |
72 MaybeCaptureMemoryAround(process_reader, context.x86->eax, into); | |
73 MaybeCaptureMemoryAround(process_reader, context.x86->ebx, into); | |
74 MaybeCaptureMemoryAround(process_reader, context.x86->ecx, into); | |
75 MaybeCaptureMemoryAround(process_reader, context.x86->edx, into); | |
76 MaybeCaptureMemoryAround(process_reader, context.x86->edi, into); | |
77 MaybeCaptureMemoryAround(process_reader, context.x86->esi, into); | |
78 if (context.x86->ebp < thread.stack_region_address || | |
79 context.x86->ebp >= | |
80 thread.stack_region_address + thread.stack_region_size) { | |
81 MaybeCaptureMemoryAround(process_reader, context.x86->ebp, into); | |
82 } | |
83 MaybeCaptureMemoryAround(process_reader, context.x86->eip, into); | |
84 #if defined(ARCH_CPU_X86_64) | |
85 } | |
86 #endif | |
87 } | |
88 | |
89 } // namespace internal | |
90 } // namespace crashpad | |
OLD | NEW |