forked from xiaobfly/DisPg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stack.h
98 lines (81 loc) · 2.48 KB
/
Stack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
*
* Copyright (c) 2015-2018 by blindtiger ( [email protected] )
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* https://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. SEe the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original e is blindtiger.
*
*/
#ifndef _STACK_H_
#define _STACK_H_
#ifdef __cplusplus
/* Assume C declarations for C++ */
extern "C" {
#endif /* __cplusplus */
#ifndef _WIN64
#define STACK_ALIGN (8UI32)
#define STACK_ROUND (STACK_ALIGN - 1)
#define PSPALIGN_DOWN(address,amt) ((ULONG)(address) & ~(( amt ) - 1))
#define PSPALIGN_UP(address,amt) (PSPALIGN_DOWN( (address + (amt) - 1), (amt) ))
#define GetBaseExceptionFrame(Thread) (NULL)
#else
typedef struct _KSTACK_SEGMENT_SPECIAL {
ULONG_PTR StackBase;
ULONG_PTR StackLimit;
ULONG_PTR KernelStack;
ULONG_PTR InitialStack;
ULONG_PTR ActualLimit;
} KSTACK_SEGMENT_SPECIAL, *PKSTACK_SEGMENT_SPECIAL;
typedef struct _KSTACK_CONTROL_SPECIAL {
KSTACK_SEGMENT_SPECIAL Current;
KSTACK_SEGMENT_SPECIAL Previous;
} KSTACK_CONTROL_SPECIAL, *PKSTACK_CONTROL_SPECIAL;
typedef struct _KSTACK_SEGMENT {
ULONG_PTR StackBase;
ULONG_PTR StackLimit;
ULONG_PTR KernelStack;
ULONG_PTR InitialStack;
} KSTACK_SEGMENT, *PKSTACK_SEGMENT;
typedef struct _KSTACK_CONTROL {
ULONG_PTR StackBase;
union {
ULONG_PTR ActualLimit;
BOOLEAN StackExpansion : 1;
};
KSTACK_SEGMENT Previous;
}KSTACK_CONTROL, *PKSTACK_CONTROL;
#define GetBaseExceptionFrame(Thread) \
((PKEXCEPTION_FRAME)((ULONG_PTR)GetBaseTrapFrame(Thread) - KEXCEPTION_FRAME_LENGTH))
#endif // !_WIN64
typedef struct _CALLERS {
PVOID * EstablisherFrame;
PVOID Establisher;
}CALLERS, *PCALLERS;
PKTRAP_FRAME
NTAPI
GetBaseTrapFrame(
__in PETHREAD Thread
);
VOID
NTAPI
PrintSymbol(
__in PVOID Address
);
VOID
NTAPI
PrintFrameChain(
__in_opt ULONG FramesToSkip
);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // !_STACK_H_