Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
4708bb74
Commit
4708bb74
authored
Dec 12, 2022
by
Eric Pouech
Committed by
Alexandre Julliard
Dec 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Add tests for RtlU(long|short)ByteSwap().
Signed-off-by:
Eric Pouech
<
eric.pouech@gmail.com
>
parent
495711c2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
3 deletions
+44
-3
rtl.c
dlls/ntdll/tests/rtl.c
+44
-3
No files found.
dlls/ntdll/tests/rtl.c
View file @
4708bb74
...
...
@@ -27,6 +27,7 @@
#include "in6addr.h"
#include "inaddr.h"
#include "ip2string.h"
#include "wine/asm.h"
#ifndef __WINE_WINTERNL_H
...
...
@@ -61,6 +62,18 @@ static inline USHORT __my_ushort_swap(USHORT s)
#endif
/* WORDS_BIGENDIAN */
#ifdef __ASM_USE_FASTCALL_WRAPPER
extern
ULONG
WINAPI
wrap_fastcall_func1
(
void
*
func
,
ULONG
a
);
__ASM_STDCALL_FUNC
(
wrap_fastcall_func1
,
8
,
"popl %ecx
\n\t
"
"popl %eax
\n\t
"
"xchgl (%esp),%ecx
\n\t
"
"jmp *%eax"
)
#define call_fastcall_func1(func,a) wrap_fastcall_func1(func,a)
#else
#define call_fastcall_func1(func,a) func(a)
#endif
/* Function ptrs for ntdll calls */
static
HMODULE
hntdll
=
0
;
...
...
@@ -68,6 +81,8 @@ static VOID (WINAPI *pRtlMoveMemory)(LPVOID,LPCVOID,SIZE_T);
static
VOID
(
WINAPI
*
pRtlFillMemory
)(
LPVOID
,
SIZE_T
,
BYTE
);
static
VOID
(
WINAPI
*
pRtlFillMemoryUlong
)(
LPVOID
,
SIZE_T
,
ULONG
);
static
VOID
(
WINAPI
*
pRtlZeroMemory
)(
LPVOID
,
SIZE_T
);
static
USHORT
(
FASTCALL
*
pRtlUshortByteSwap
)(
USHORT
source
);
static
ULONG
(
FASTCALL
*
pRtlUlongByteSwap
)(
ULONG
source
);
static
ULONGLONG
(
FASTCALL
*
pRtlUlonglongByteSwap
)(
ULONGLONG
source
);
static
DWORD
(
WINAPI
*
pRtlGetThreadErrorMode
)(
void
);
static
NTSTATUS
(
WINAPI
*
pRtlSetThreadErrorMode
)(
DWORD
,
LPDWORD
);
...
...
@@ -108,7 +123,9 @@ static void InitFunctionPtrs(void)
pRtlFillMemory
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlFillMemory"
);
pRtlFillMemoryUlong
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlFillMemoryUlong"
);
pRtlZeroMemory
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlZeroMemory"
);
pRtlUlonglongByteSwap
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlUlonglongByteSwap"
);
pRtlUshortByteSwap
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlUshortByteSwap"
);
pRtlUlongByteSwap
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlUlongByteSwap"
);
pRtlUlonglongByteSwap
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlUlonglongByteSwap"
);
pRtlGetThreadErrorMode
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlGetThreadErrorMode"
);
pRtlSetThreadErrorMode
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlSetThreadErrorMode"
);
pRtlIpv4AddressToStringExA
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlIpv4AddressToStringExA"
);
...
...
@@ -317,16 +334,40 @@ static void test_RtlZeroMemory(void)
ZERO
(
9
);
MCMP
(
"
\0\0\0\0\0\0\0\0\0
test!"
);
}
static
void
test_Rtl
Ulonglong
ByteSwap
(
void
)
static
void
test_RtlByteSwap
(
void
)
{
ULONGLONG
llresult
;
ULONG
lresult
;
USHORT
sresult
;
#ifdef _WIN64
/* the Rtl*ByteSwap() are always inlined and not exported from ntdll on 64bit */
sresult
=
RtlUshortByteSwap
(
0x1234
);
ok
(
0x3412
==
sresult
,
"inlined RtlUshortByteSwap() returns 0x%x
\n
"
,
sresult
);
lresult
=
RtlUlongByteSwap
(
0x87654321
);
ok
(
0x21436587
==
lresult
,
"inlined RtlUlongByteSwap() returns 0x%lx
\n
"
,
lresult
);
llresult
=
RtlUlonglongByteSwap
(
0x7654321087654321ull
);
ok
(
0x2143658710325476
==
llresult
,
"inlined RtlUlonglongByteSwap() returns %#I64x
\n
"
,
llresult
);
#else
ok
(
pRtlUshortByteSwap
!=
NULL
,
"RtlUshortByteSwap is not available
\n
"
);
if
(
pRtlUshortByteSwap
)
{
sresult
=
call_fastcall_func1
(
pRtlUshortByteSwap
,
0x1234u
);
ok
(
0x3412u
==
sresult
,
"ntdll.RtlUshortByteSwap() returns %#x
\n
"
,
sresult
);
}
ok
(
pRtlUlongByteSwap
!=
NULL
,
"RtlUlongByteSwap is not available
\n
"
);
if
(
pRtlUlongByteSwap
)
{
lresult
=
call_fastcall_func1
(
pRtlUlongByteSwap
,
0x87654321ul
);
ok
(
0x21436587ul
==
lresult
,
"ntdll.RtlUlongByteSwap() returns %#lx
\n
"
,
lresult
);
}
ok
(
pRtlUlonglongByteSwap
!=
NULL
,
"RtlUlonglongByteSwap is not available
\n
"
);
if
(
pRtlUlonglongByteSwap
)
{
...
...
@@ -3745,7 +3786,7 @@ START_TEST(rtl)
test_RtlFillMemory
();
test_RtlFillMemoryUlong
();
test_RtlZeroMemory
();
test_Rtl
Ulonglong
ByteSwap
();
test_RtlByteSwap
();
test_RtlUniform
();
test_RtlRandom
();
test_RtlAreAllAccessesGranted
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment