summaryrefslogtreecommitdiffstats
path: root/src/stack_walk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stack_walk.c')
-rw-r--r--src/stack_walk.c199
1 files changed, 1 insertions, 198 deletions
diff --git a/src/stack_walk.c b/src/stack_walk.c
index 066b879..1cd97e4 100644
--- a/src/stack_walk.c
+++ b/src/stack_walk.c
@@ -2,6 +2,7 @@
#include "module.h"
#include "utils.h"
+#include "win_funcs.h"
// =======================
// ====== windows.h ======
@@ -25,201 +26,6 @@
#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x00000040L)
#define CONTEXT_KERNEL_CET (CONTEXT_AMD64 | 0x00000080L)
-//
-// Define 128-bit 16-byte aligned xmm register type.
-//
-
-typedef struct __declspec(align(16)) _M128A {
- u64 Low;
- i64 High;
-} M128A, *PM128A;
-
-//
-// Format of data for (F)XSAVE/(F)XRSTOR instruction
-//
-
-typedef struct __declspec(align(16)) _XSAVE_FORMAT {
- u16 ControlWord;
- u16 StatusWord;
- u8 TagWord;
- u8 Reserved1;
- u16 ErrorOpcode;
- u32 ErrorOffset;
- u16 ErrorSelector;
- u16 Reserved2;
- u32 DataOffset;
- u16 DataSelector;
- u16 Reserved3;
- u32 MxCsr;
- u32 MxCsr_Mask;
- M128A FloatRegisters[8];
-
-#if defined(_WIN64)
-
- M128A XmmRegisters[16];
- u8 Reserved4[96];
-
-#else
-
- M128A XmmRegisters[8];
- BYTE Reserved4[224];
-
-#endif
-
-} XSAVE_FORMAT, *PXSAVE_FORMAT;
-
-typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
-
-//
-// Context Frame
-//
-// This frame has a several purposes: 1) it is used as an argument to
-// NtContinue, 2) it is used to constuct a call frame for APC delivery,
-// and 3) it is used in the user level thread creation routines.
-//
-//
-// The flags field within this record controls the contents of a CONTEXT
-// record.
-//
-// If the context record is used as an input parameter, then for each
-// portion of the context record controlled by a flag whose value is
-// set, it is assumed that that portion of the context record contains
-// valid context. If the context record is being used to modify a threads
-// context, then only that portion of the threads context is modified.
-//
-// If the context record is used as an output parameter to capture the
-// context of a thread, then only those portions of the thread's context
-// corresponding to set flags will be returned.
-//
-// CONTEXT_CONTROL specifies SegSs, Rsp, SegCs, Rip, and EFlags.
-//
-// CONTEXT_INTEGER specifies Rax, Rcx, Rdx, Rbx, Rbp, Rsi, Rdi, and R8-R15.
-//
-// CONTEXT_SEGMENTS specifies SegDs, SegEs, SegFs, and SegGs.
-//
-// CONTEXT_FLOATING_POINT specifies Xmm0-Xmm15.
-//
-// CONTEXT_DEBUG_REGISTERS specifies Dr0-Dr3 and Dr6-Dr7.
-//
-
-typedef struct __declspec(align(16)) _CONTEXT {
-
- //
- // Register parameter home addresses.
- //
- // N.B. These fields are for convience - they could be used to extend the
- // context record in the future.
- //
-
- u64 P1Home;
- u64 P2Home;
- u64 P3Home;
- u64 P4Home;
- u64 P5Home;
- u64 P6Home;
-
- //
- // Control flags.
- //
-
- u32 ContextFlags;
- u32 MxCsr;
-
- //
- // Segment Registers and processor flags.
- //
-
- u16 SegCs;
- u16 SegDs;
- u16 SegEs;
- u16 SegFs;
- u16 SegGs;
- u16 SegSs;
- u32 EFlags;
-
- //
- // Debug registers
- //
-
- u64 Dr0;
- u64 Dr1;
- u64 Dr2;
- u64 Dr3;
- u64 Dr6;
- u64 Dr7;
-
- //
- // Integer registers.
- //
-
- u64 Rax;
- u64 Rcx;
- u64 Rdx;
- u64 Rbx;
- u64 Rsp;
- u64 Rbp;
- u64 Rsi;
- u64 Rdi;
- u64 R8;
- u64 R9;
- u64 R10;
- u64 R11;
- u64 R12;
- u64 R13;
- u64 R14;
- u64 R15;
-
- //
- // Program counter.
- //
-
- u64 Rip;
-
- //
- // Floating point state.
- //
-
- union {
- XMM_SAVE_AREA32 FltSave;
- struct {
- M128A Header[2];
- M128A Legacy[8];
- M128A Xmm0;
- M128A Xmm1;
- M128A Xmm2;
- M128A Xmm3;
- M128A Xmm4;
- M128A Xmm5;
- M128A Xmm6;
- M128A Xmm7;
- M128A Xmm8;
- M128A Xmm9;
- M128A Xmm10;
- M128A Xmm11;
- M128A Xmm12;
- M128A Xmm13;
- M128A Xmm14;
- M128A Xmm15;
- };
- };
-
- //
- // Vector registers.
- //
-
- M128A VectorRegister[26];
- u64 VectorControl;
-
- //
- // Special debug control registers.
- //
-
- u64 DebugControl;
- u64 LastBranchToRip;
- u64 LastBranchFromRip;
- u64 LastExceptionToRip;
- u64 LastExceptionFromRip;
-} CONTEXT, *PCONTEXT;
#define PAGE_NOACCESS 0x01
#define PAGE_READONLY 0x02
#define PAGE_READWRITE 0x04
@@ -277,9 +83,6 @@ typedef struct __declspec(align(16)) _CONTEXT {
#define MEM_EXTENDED_PARAMETER_EC_CODE 0x00000040
#define MEM_EXTENDED_PARAMETER_NUMA_NODE_MANDATORY MINLONG64
-extern void* VirtualAlloc(void* lpAddress, size_t dwSize, u32 flAllocationType, u32 flProtect);
-extern i32 VirtualFree(void* lpAddress, size_t dwSize, u32 dwFreeType);
-
// ========================
// ====== !windows.h ======
// ========================