| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | // |
| 6 | |
| 7 | #ifndef __unwinder_amd64_h__ |
| 8 | #define __unwinder_amd64_h__ |
| 9 | |
| 10 | #include "unwinder.h" |
| 11 | |
| 12 | |
| 13 | //--------------------------------------------------------------------------------------- |
| 14 | // |
| 15 | // See the comment for the base class code:OOPStackUnwinder. |
| 16 | // |
| 17 | |
| 18 | class OOPStackUnwinderAMD64 : public OOPStackUnwinder |
| 19 | { |
| 20 | public: |
| 21 | // Unwind the given CONTEXT to the caller CONTEXT. The CONTEXT will be overwritten. |
| 22 | static BOOL Unwind(CONTEXT * pContext); |
| 23 | |
| 24 | // |
| 25 | // Everything below comes from dbghelp.dll. |
| 26 | // |
| 27 | |
| 28 | static HRESULT VirtualUnwind(__in DWORD HandlerType, |
| 29 | __in DWORD64 ImageBase, |
| 30 | __in DWORD64 ControlPc, |
| 31 | __in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry, |
| 32 | __inout PCONTEXT ContextRecord, |
| 33 | __out PVOID *HandlerData, |
| 34 | __out PDWORD64 EstablisherFrame, |
| 35 | __inout_opt PKNONVOLATILE_CONTEXT_POINTERS ContextPointers, |
| 36 | __deref_opt_out_opt PEXCEPTION_ROUTINE *HandlerRoutine); |
| 37 | |
| 38 | protected: |
| 39 | |
| 40 | static ULONG UnwindOpSlots(__in UNWIND_CODE UnwindCode); |
| 41 | |
| 42 | static HRESULT UnwindEpilogue(__in ULONG64 ImageBase, |
| 43 | __in ULONG64 ControlPc, |
| 44 | __in ULONG EpilogueOffset, |
| 45 | __in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry, |
| 46 | __inout PCONTEXT ContextRecord, |
| 47 | __inout_opt PKNONVOLATILE_CONTEXT_POINTERS ContextPointers); |
| 48 | |
| 49 | static HRESULT UnwindPrologue(__in DWORD64 ImageBase, |
| 50 | __in DWORD64 ControlPc, |
| 51 | __in DWORD64 FrameBase, |
| 52 | __in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry, |
| 53 | __inout PCONTEXT ContextRecord, |
| 54 | __inout_opt PKNONVOLATILE_CONTEXT_POINTERS ContextPointers, |
| 55 | __deref_out _PIMAGE_RUNTIME_FUNCTION_ENTRY *FinalFunctionEntry); |
| 56 | |
| 57 | static _PIMAGE_RUNTIME_FUNCTION_ENTRY LookupPrimaryFunctionEntry |
| 58 | (__in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry, |
| 59 | __in DWORD64 ImageBase); |
| 60 | |
| 61 | static _PIMAGE_RUNTIME_FUNCTION_ENTRY SameFunction |
| 62 | (__in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry, |
| 63 | __in DWORD64 ImageBase, |
| 64 | __in DWORD64 ControlPc); |
| 65 | |
| 66 | static UNWIND_INFO * GetUnwindInfo(TADDR taUnwindInfo); |
| 67 | }; |
| 68 | |
| 69 | #endif // __unwinder_amd64_h__ |
| 70 | |
| 71 | |