ReactOS
0.4.16-dev-1946-g52006dd
RtlUnwind.c
Go to the documentation of this file.
1
/*
2
* PROJECT: ReactOS api tests
3
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4
* PURPOSE: Test for x86 RtlUnwind
5
* COPYRIGHT: Copyright 2024 Timo Kreuzer <timo.kreuzer@reactos.org>
6
*/
7
8
#include <rtltests.h>
9
10
CONTEXT
g_InContext
;
11
CONTEXT
g_OutContext
;
12
13
VOID
14
WINAPI
15
RtlUnwindWrapper
(
16
_In_
PVOID
TargetFrame,
17
_In_
PVOID
TargetIp,
18
_In_
PEXCEPTION_RECORD
ExceptionRecord,
19
_In_
PVOID
ReturnValue
);
20
21
START_TEST
(
RtlUnwind
)
22
{
23
BOOL
IsWow64
;
24
25
RtlZeroMemory
(&
g_InContext
,
sizeof
(
g_InContext
));
26
RtlZeroMemory
(&
g_OutContext
,
sizeof
(
g_OutContext
));
27
28
PEXCEPTION_REGISTRATION_RECORD
ExcptReg = (
PEXCEPTION_REGISTRATION_RECORD
)
__readfsdword
(0);
29
ok
(ExcptReg !=
NULL
,
"ExcpReg is NULL\n"
);
30
31
g_InContext
.
Eax
= 0xabcd0001;
32
g_InContext
.
Ebx
= 0xabcd0002;
33
g_InContext
.
Ecx
= 0xabcd0003;
34
g_InContext
.
Edx
= 0xabcd0004;
35
g_InContext
.
Esi
= 0xabcd0005;
36
g_InContext
.
Edi
= 0xabcd0006;
37
RtlUnwindWrapper
(ExcptReg,
NULL
,
NULL
, (
PVOID
)0x12345678);
38
ok_eq_hex
(
g_OutContext
.
Eax
, 0x12345678ul);
39
ok_eq_hex
(
g_OutContext
.
Ebx
, 0ul);
40
ok_eq_hex
(
g_OutContext
.
Ecx
, 0ul);
41
ok_eq_hex
(
g_OutContext
.
Edx
, 0ul);
42
ok_eq_hex
(
g_OutContext
.
Esi
, 0ul);
43
ok_eq_hex
(
g_OutContext
.
Edi
, 0ul);
44
if
(
IsWow64Process
(
NtCurrentProcess
(), &
IsWow64
) &&
IsWow64
)
45
{
46
ok_eq_hex
(
g_OutContext
.
SegCs
, 0x23ul);
47
ok_eq_hex
(
g_OutContext
.
SegDs
, 0x2bul);
48
ok_eq_hex
(
g_OutContext
.
SegEs
, 0x2bul);
49
ok_eq_hex
(
g_OutContext
.
SegFs
, 0x53ul);
50
}
51
else
52
{
53
ok_eq_hex
(
g_OutContext
.
SegCs
, 0x1bul);
54
ok_eq_hex
(
g_OutContext
.
SegDs
, 0x23ul);
55
ok_eq_hex
(
g_OutContext
.
SegEs
, 0x23ul);
56
ok_eq_hex
(
g_OutContext
.
SegFs
, 0x3bul);
57
}
58
}
IsWow64
static BOOL IsWow64
Definition:
NtCreateProfile.c:17
g_InContext
CONTEXT g_InContext
Definition:
RtlUnwind.c:10
RtlUnwindWrapper
VOID WINAPI RtlUnwindWrapper(_In_ PVOID TargetFrame, _In_ PVOID TargetIp, _In_ PEXCEPTION_RECORD ExceptionRecord, _In_ PVOID ReturnValue)
g_OutContext
CONTEXT g_OutContext
Definition:
RtlUnwind.c:11
ReturnValue
UINT32 void void ** ReturnValue
Definition:
acevents.h:216
ok_eq_hex
#define ok_eq_hex(value, expected)
Definition:
apitest.h:134
RtlUnwind
#define RtlUnwind
Definition:
longjmp.c:9
ok
#define ok(value,...)
Definition:
atltest.h:57
START_TEST
#define START_TEST(x)
Definition:
atltest.h:75
NULL
#define NULL
Definition:
types.h:112
PEXCEPTION_REGISTRATION_RECORD
struct _EXCEPTION_REGISTRATION_RECORD * PEXCEPTION_REGISTRATION_RECORD
IsWow64Process
#define IsWow64Process
Definition:
compat.h:760
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
void
Definition:
nsiface.idl:2307
__readfsdword
PPC_QUAL unsigned long __readfsdword(const unsigned long Offset)
Definition:
intrin_ppc.h:382
_In_
#define _In_
Definition:
no_sal2.h:158
NtCurrentProcess
#define NtCurrentProcess()
Definition:
nt_native.h:1660
_CONTEXT
Definition:
nt_native.h:1409
_CONTEXT::SegFs
ULONG SegFs
Definition:
nt_native.h:1457
_CONTEXT::Edx
ULONG Edx
Definition:
nt_native.h:1469
_CONTEXT::Esi
ULONG Esi
Definition:
nt_native.h:1467
_CONTEXT::Ecx
ULONG Ecx
Definition:
nt_native.h:1470
_CONTEXT::SegCs
ULONG SegCs
Definition:
nt_native.h:1480
_CONTEXT::SegDs
ULONG SegDs
Definition:
nt_native.h:1459
_CONTEXT::Eax
ULONG Eax
Definition:
nt_native.h:1471
_CONTEXT::SegEs
ULONG SegEs
Definition:
nt_native.h:1458
_CONTEXT::Ebx
ULONG Ebx
Definition:
nt_native.h:1468
_CONTEXT::Edi
ULONG Edi
Definition:
nt_native.h:1466
_EXCEPTION_RECORD
Definition:
compat.h:207
_EXCEPTION_REGISTRATION_RECORD
Definition:
compat.h:725
RtlZeroMemory
#define RtlZeroMemory(Destination, Length)
Definition:
typedefs.h:262
WINAPI
#define WINAPI
Definition:
msvc.h:6
modules
rostests
apitests
rtl
i386
RtlUnwind.c
Generated on Thu Dec 4 2025 06:08:32 for ReactOS by
1.9.6