ReactOS 0.4.15-dev-8231-g29a56f3
RtlStack.c File Reference
#include <kmt_test.h>
Include dependency graph for RtlStack.c:

Go to the source code of this file.

Macros

#define KMT_EMULATE_KERNEL
 

Functions

static VOID TestStackWalk3 (VOID)
 
static DECLSPEC_NOINLINE VOID TestStackWalk4 (VOID)
 
static DECLSPEC_NOINLINE VOID TestStackWalk2 (VOID)
 
static DECLSPEC_NOINLINE VOID TestStackWalk1 (VOID)
 
 START_TEST (RtlStack)
 

Variables

static PVOID ReturnAddresses [4]
 

Macro Definition Documentation

◆ KMT_EMULATE_KERNEL

#define KMT_EMULATE_KERNEL

Definition at line 8 of file RtlStack.c.

Function Documentation

◆ START_TEST()

START_TEST ( RtlStack  )

Definition at line 194 of file RtlStack.c.

195{
197#ifdef _M_AMD64
198 TestRtlPcToFileHeader();
199#endif // _M_AMD64
200}
static DECLSPEC_NOINLINE VOID TestStackWalk1(VOID)
Definition: RtlStack.c:127

◆ TestStackWalk1()

static DECLSPEC_NOINLINE VOID TestStackWalk1 ( VOID  )
static

Definition at line 127 of file RtlStack.c.

128{
131}
static PVOID ReturnAddresses[4]
Definition: RtlStack.c:11
static DECLSPEC_NOINLINE VOID TestStackWalk2(VOID)
Definition: RtlStack.c:118
#define _ReturnAddress()
Definition: intrin_arm.h:35

Referenced by START_TEST().

◆ TestStackWalk2()

static DECLSPEC_NOINLINE VOID TestStackWalk2 ( VOID  )
static

Definition at line 118 of file RtlStack.c.

119{
122}
static VOID TestStackWalk3(VOID)
Definition: RtlStack.c:109

Referenced by TestStackWalk1().

◆ TestStackWalk3()

static DECLSPEC_NOINLINE VOID TestStackWalk3 ( VOID  )
static

Definition at line 109 of file RtlStack.c.

110{
113}
static DECLSPEC_NOINLINE VOID TestStackWalk4(VOID)
Definition: RtlStack.c:20

Referenced by TestStackWalk2().

◆ TestStackWalk4()

static DECLSPEC_NOINLINE VOID TestStackWalk4 ( VOID  )
static

Definition at line 20 of file RtlStack.c.

21{
22 PVOID Frames[5];
23 ULONG Ret;
24 ULONG Hash;
25 ULONG ExpectedHash;
26 ULONG i;
27 const ULONG FunctionSizeGuess = 0x1000;
28
30
31 Ret = RtlWalkFrameChain(NULL, 5, 0);
32 ok_eq_ulong(Ret, 0);
33
34 RtlFillMemory(Frames, sizeof(Frames), 0x55);
35 Ret = RtlWalkFrameChain(Frames, 0, 0);
36 ok_eq_ulong(Ret, 0);
37 ok_eq_pointer(Frames[0], (PVOID)(ULONG_PTR)0x5555555555555555);
38
39 RtlFillMemory(Frames, sizeof(Frames), 0x55);
40 Ret = RtlWalkFrameChain(Frames, 5, 0);
41 ok_eq_ulong(Ret, 5);
42 ok((ULONG_PTR)Frames[0] > (ULONG_PTR)TestStackWalk4, "Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
43 ok((ULONG_PTR)Frames[0] < (ULONG_PTR)TestStackWalk4 + FunctionSizeGuess, "Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
44 ok_eq_pointer(Frames[1], ReturnAddresses[3]);
45 ok_eq_pointer(Frames[2], ReturnAddresses[2]);
46 ok_eq_pointer(Frames[3], ReturnAddresses[1]);
47 ok_eq_pointer(Frames[4], ReturnAddresses[0]);
48
49 RtlFillMemory(Frames, sizeof(Frames), 0x55);
50 Ret = RtlWalkFrameChain(Frames, 4, 0);
51 ok_eq_ulong(Ret, 4);
52 ok((ULONG_PTR)Frames[0] > (ULONG_PTR)TestStackWalk4, "Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
53 ok((ULONG_PTR)Frames[0] < (ULONG_PTR)TestStackWalk4 + FunctionSizeGuess, "Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
54 ok_eq_pointer(Frames[1], ReturnAddresses[3]);
55 ok_eq_pointer(Frames[2], ReturnAddresses[2]);
56 ok_eq_pointer(Frames[3], ReturnAddresses[1]);
57 ok_eq_pointer(Frames[4], (PVOID)(ULONG_PTR)0x5555555555555555);
58
62
63 RtlFillMemory(Frames, sizeof(Frames), 0x55);
64 Hash = 0x55555555;
65 Ret = RtlCaptureStackBackTrace(0, 0, Frames, &Hash);
66 ok_eq_ulong(Ret, 0);
67 ok_eq_hex(Hash, 0x55555555);
68 ok_eq_pointer(Frames[0], (PVOID)(ULONG_PTR)0x5555555555555555);
69
70 RtlFillMemory(Frames, sizeof(Frames), 0x55);
71 Hash = 0x55555555;
72 Ret = RtlCaptureStackBackTrace(0, 1, Frames, NULL);
73 ok_eq_ulong(Ret, 1);
74 ok((ULONG_PTR)Frames[0] > (ULONG_PTR)TestStackWalk4, "Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
75 ok((ULONG_PTR)Frames[0] < (ULONG_PTR)TestStackWalk4 + FunctionSizeGuess, "Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
76 ok_eq_pointer(Frames[1], (PVOID)(ULONG_PTR)0x5555555555555555);
77
78 RtlFillMemory(Frames, sizeof(Frames), 0x55);
79 Ret = RtlCaptureStackBackTrace(0, 5, Frames, &Hash);
80 ok_eq_ulong(Ret, 5);
81 ExpectedHash = 0;
82 for (i = 0; i < 5; i++)
83 ExpectedHash += (ULONG)(ULONG_PTR)Frames[i];
84 ok_eq_hex(Hash, ExpectedHash);
85 ok((ULONG_PTR)Frames[0] > (ULONG_PTR)TestStackWalk4, "Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
86 ok((ULONG_PTR)Frames[0] < (ULONG_PTR)TestStackWalk4 + FunctionSizeGuess, "Frame is %p, function is %p\n", Frames[0], TestStackWalk4);
87 ok_eq_pointer(Frames[1], ReturnAddresses[3]);
88 ok_eq_pointer(Frames[2], ReturnAddresses[2]);
89 ok_eq_pointer(Frames[3], ReturnAddresses[1]);
90 ok_eq_pointer(Frames[4], ReturnAddresses[0]);
91
92 RtlFillMemory(Frames, sizeof(Frames), 0x55);
93 Ret = RtlCaptureStackBackTrace(1, 4, Frames, &Hash);
94 ok_eq_ulong(Ret, 4);
95 ExpectedHash = 0;
96 for (i = 0; i < 4; i++)
97 ExpectedHash += (ULONG)(ULONG_PTR)Frames[i];
98 ok_eq_hex(Hash, ExpectedHash);
99 ok_eq_pointer(Frames[0], ReturnAddresses[3]);
100 ok_eq_pointer(Frames[1], ReturnAddresses[2]);
101 ok_eq_pointer(Frames[2], ReturnAddresses[1]);
102 ok_eq_pointer(Frames[3], ReturnAddresses[0]);
103 ok_eq_pointer(Frames[4], (PVOID)(ULONG_PTR)0x5555555555555555);
104}
#define ok_eq_pointer(value, expected)
Definition: apitest.h:59
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
ULONG NTAPI RtlWalkFrameChain(OUT PVOID *Callers, IN ULONG Count, IN ULONG Flags)
Definition: libsupp.c:229
static int Hash(const char *)
Definition: reader.c:2257
GLdouble n
Definition: glext.h:7729
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
#define KmtStartSeh()
Definition: kmt_test.h:282
#define KmtEndSeh(ExpectedStatus)
Definition: kmt_test.h:288
#define for
Definition: utility.h:88
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
NTSYSAPI USHORT NTAPI RtlCaptureStackBackTrace(_In_ ULONG FramesToSkip, _In_ ULONG FramesToCapture, _Out_writes_to_(FramesToCapture, return) PVOID *BackTrace, _Out_opt_ PULONG BackTraceHash)

Referenced by TestStackWalk3(), and TestStackWalk4().

Variable Documentation

◆ ReturnAddresses

PVOID ReturnAddresses[4]
static

Definition at line 11 of file RtlStack.c.

Referenced by TestStackWalk1(), TestStackWalk2(), TestStackWalk3(), and TestStackWalk4().