mirror of
https://github.com/reactos/reactos.git
synced 2025-05-03 21:00:15 +00:00
[NTDLL_APITEST]
- Add test for RtlGetLongestNtPathLength - Add test for RtlDetermineDosPathNameType_U (and RtlDetermineDosPathNameType_Ustr, if address is known) svn path=/trunk/; revision=56411
This commit is contained in:
parent
6eef1df19a
commit
fb43dc26f7
4 changed files with 240 additions and 7 deletions
|
@ -2,8 +2,10 @@
|
|||
list(APPEND SOURCE
|
||||
NtAllocateVirtualMemory.c
|
||||
NtFreeVirtualMemory.c
|
||||
RtlDetermineDosPathNameType.c
|
||||
RtlGetFullPathName_U.c
|
||||
RtlGetFullPathName_UstrEx.c
|
||||
RtlGetLongestNtPathLength.c
|
||||
RtlInitializeBitMap.c
|
||||
SystemInfo.c
|
||||
ZwContinue.c
|
||||
|
|
203
rostests/apitests/ntdll/RtlDetermineDosPathNameType.c
Normal file
203
rostests/apitests/ntdll/RtlDetermineDosPathNameType.c
Normal file
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
* PROJECT: ReactOS api tests
|
||||
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
||||
* PURPOSE: Test for RtlDetermineDosPathNameType_U/RtlDetermineDosPathNameType_Ustr
|
||||
* PROGRAMMER: Thomas Faber <thfabba@gmx.de>
|
||||
*/
|
||||
|
||||
#define WIN32_NO_STATUS
|
||||
#include <wine/test.h>
|
||||
#include <pseh/pseh2.h>
|
||||
#include <ndk/mmfuncs.h>
|
||||
#include <ndk/rtlfuncs.h>
|
||||
|
||||
/*
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlDetermineDosPathNameType_U(
|
||||
IN PCWSTR Path
|
||||
);
|
||||
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlDetermineDosPathNameType_Ustr(
|
||||
IN PCUNICODE_STRING Path
|
||||
);
|
||||
*/
|
||||
|
||||
static
|
||||
ULONG
|
||||
(NTAPI
|
||||
*RtlDetermineDosPathNameType_Ustr)(
|
||||
IN PCUNICODE_STRING Path
|
||||
)
|
||||
//= (PVOID)0x7c830669;
|
||||
;
|
||||
|
||||
static
|
||||
PVOID
|
||||
AllocateGuarded(
|
||||
SIZE_T SizeRequested)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
SIZE_T Size = PAGE_ROUND_UP(SizeRequested + PAGE_SIZE);
|
||||
PVOID VirtualMemory = NULL;
|
||||
PCHAR StartOfBuffer;
|
||||
|
||||
Status = NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory, 0, &Size, MEM_RESERVE, PAGE_NOACCESS);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
return NULL;
|
||||
|
||||
Size -= PAGE_SIZE;
|
||||
if (Size)
|
||||
{
|
||||
Status = NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory, 0, &Size, MEM_COMMIT, PAGE_READWRITE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
Size = 0;
|
||||
Status = NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE);
|
||||
ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
StartOfBuffer = VirtualMemory;
|
||||
StartOfBuffer += Size - SizeRequested;
|
||||
|
||||
return StartOfBuffer;
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
FreeGuarded(
|
||||
PVOID Pointer)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer);
|
||||
SIZE_T Size = 0;
|
||||
|
||||
Status = NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE);
|
||||
ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
|
||||
}
|
||||
|
||||
#define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY {
|
||||
#define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus)
|
||||
|
||||
START_TEST(RtlDetermineDosPathNameType)
|
||||
{
|
||||
NTSTATUS ExceptionStatus;
|
||||
RTL_PATH_TYPE PathType;
|
||||
struct
|
||||
{
|
||||
PCWSTR FileName;
|
||||
RTL_PATH_TYPE PathType;
|
||||
} Tests[] =
|
||||
{
|
||||
{ L"", RtlPathTypeRelative },
|
||||
{ L"xyz", RtlPathTypeRelative },
|
||||
{ L"CON", RtlPathTypeRelative },
|
||||
{ L"NUL", RtlPathTypeRelative },
|
||||
{ L":", RtlPathTypeRelative },
|
||||
{ L"::", RtlPathTypeDriveRelative },
|
||||
{ L":::", RtlPathTypeDriveRelative },
|
||||
{ L"::::", RtlPathTypeDriveRelative },
|
||||
{ L"\\", RtlPathTypeRooted },
|
||||
{ L"\\:", RtlPathTypeRooted },
|
||||
{ L"\\C:", RtlPathTypeRooted },
|
||||
{ L"\\C:\\", RtlPathTypeRooted },
|
||||
{ L"/", RtlPathTypeRooted },
|
||||
{ L"/:", RtlPathTypeRooted },
|
||||
{ L"/C:", RtlPathTypeRooted },
|
||||
{ L"/C:/", RtlPathTypeRooted },
|
||||
{ L"C", RtlPathTypeRelative },
|
||||
{ L"C:", RtlPathTypeDriveRelative },
|
||||
{ L"C:a", RtlPathTypeDriveRelative },
|
||||
{ L"C:a\\", RtlPathTypeDriveRelative },
|
||||
{ L"C:\\", RtlPathTypeDriveAbsolute },
|
||||
{ L"C:/", RtlPathTypeDriveAbsolute },
|
||||
{ L"C:\\a", RtlPathTypeDriveAbsolute },
|
||||
{ L"C:/a", RtlPathTypeDriveAbsolute },
|
||||
{ L"C:\\\\", RtlPathTypeDriveAbsolute },
|
||||
{ L"\\\\", RtlPathTypeUncAbsolute },
|
||||
{ L"\\\\\\", RtlPathTypeUncAbsolute },
|
||||
{ L"\\\\;", RtlPathTypeUncAbsolute },
|
||||
{ L"\\??\\", RtlPathTypeRooted },
|
||||
{ L"\\??\\UNC", RtlPathTypeRooted },
|
||||
{ L"\\??\\UNC\\", RtlPathTypeRooted },
|
||||
{ L"\\?", RtlPathTypeRooted },
|
||||
{ L"\\?\\", RtlPathTypeRooted },
|
||||
{ L"\\?\\UNC", RtlPathTypeRooted },
|
||||
{ L"\\?\\UNC\\", RtlPathTypeRooted },
|
||||
{ L"\\\\?\\UNC\\", RtlPathTypeLocalDevice },
|
||||
{ L"\\\\?", RtlPathTypeRootLocalDevice },
|
||||
{ L"\\\\??", RtlPathTypeUncAbsolute },
|
||||
{ L"\\\\??\\", RtlPathTypeUncAbsolute },
|
||||
{ L"\\\\??\\C:\\", RtlPathTypeUncAbsolute },
|
||||
{ L"\\\\.", RtlPathTypeRootLocalDevice },
|
||||
{ L"\\\\.\\", RtlPathTypeLocalDevice },
|
||||
{ L"\\\\.\\C:\\", RtlPathTypeLocalDevice },
|
||||
{ L"\\/", RtlPathTypeUncAbsolute },
|
||||
{ L"/\\", RtlPathTypeUncAbsolute },
|
||||
{ L"//", RtlPathTypeUncAbsolute },
|
||||
{ L"///", RtlPathTypeUncAbsolute },
|
||||
{ L"//;", RtlPathTypeUncAbsolute },
|
||||
{ L"//?", RtlPathTypeRootLocalDevice },
|
||||
{ L"/\\?", RtlPathTypeRootLocalDevice },
|
||||
{ L"\\/?", RtlPathTypeRootLocalDevice },
|
||||
{ L"//??", RtlPathTypeUncAbsolute },
|
||||
{ L"//??/", RtlPathTypeUncAbsolute },
|
||||
{ L"//??/C:/", RtlPathTypeUncAbsolute },
|
||||
{ L"//.", RtlPathTypeRootLocalDevice },
|
||||
{ L"\\/.", RtlPathTypeRootLocalDevice },
|
||||
{ L"/\\.", RtlPathTypeRootLocalDevice },
|
||||
{ L"//./", RtlPathTypeLocalDevice },
|
||||
{ L"//./C:/", RtlPathTypeLocalDevice },
|
||||
};
|
||||
ULONG i;
|
||||
PWSTR FileName;
|
||||
USHORT Length;
|
||||
|
||||
if (!RtlDetermineDosPathNameType_Ustr)
|
||||
skip(0, "RtlDetermineDosPathNameType_Ustr unavailable\n");
|
||||
|
||||
StartSeh() RtlDetermineDosPathNameType_U(NULL); EndSeh(STATUS_ACCESS_VIOLATION);
|
||||
|
||||
if (RtlDetermineDosPathNameType_Ustr)
|
||||
{
|
||||
UNICODE_STRING PathString;
|
||||
StartSeh() RtlDetermineDosPathNameType_Ustr(NULL); EndSeh(STATUS_ACCESS_VIOLATION);
|
||||
|
||||
RtlInitEmptyUnicodeString(&PathString, NULL, MAXUSHORT);
|
||||
PathType = RtlDetermineDosPathNameType_Ustr(&PathString);
|
||||
ok(PathType == RtlPathTypeRelative, "PathType = %d\n", PathType);
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(Tests) / sizeof(Tests[0]); i++)
|
||||
{
|
||||
Length = (USHORT)wcslen(Tests[i].FileName) * sizeof(WCHAR);
|
||||
FileName = AllocateGuarded(Length + sizeof(UNICODE_NULL));
|
||||
RtlCopyMemory(FileName, Tests[i].FileName, Length + sizeof(UNICODE_NULL));
|
||||
StartSeh()
|
||||
PathType = RtlDetermineDosPathNameType_U(FileName);
|
||||
EndSeh(STATUS_SUCCESS);
|
||||
ok(PathType == Tests[i].PathType, "PathType is %d, expected %d for '%S'\n", PathType, Tests[i].PathType, Tests[i].FileName);
|
||||
FreeGuarded(FileName);
|
||||
|
||||
if (RtlDetermineDosPathNameType_Ustr)
|
||||
{
|
||||
UNICODE_STRING PathString;
|
||||
|
||||
FileName = AllocateGuarded(Length);
|
||||
RtlCopyMemory(FileName, Tests[i].FileName, Length);
|
||||
PathString.Buffer = FileName;
|
||||
PathString.Length = Length;
|
||||
PathString.MaximumLength = MAXUSHORT;
|
||||
StartSeh()
|
||||
PathType = RtlDetermineDosPathNameType_Ustr(&PathString);
|
||||
EndSeh(STATUS_SUCCESS);
|
||||
ok(PathType == Tests[i].PathType, "PathType is %d, expected %d for '%S'\n", PathType, Tests[i].PathType, Tests[i].FileName);
|
||||
FreeGuarded(FileName);
|
||||
}
|
||||
}
|
||||
}
|
24
rostests/apitests/ntdll/RtlGetLongestNtPathLength.c
Normal file
24
rostests/apitests/ntdll/RtlGetLongestNtPathLength.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* PROJECT: ReactOS api tests
|
||||
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
||||
* PURPOSE: Test for RtlGetLongestNtPathLength
|
||||
* PROGRAMMER: Thomas Faber <thfabba@gmx.de>
|
||||
*/
|
||||
|
||||
#define WIN32_NO_STATUS
|
||||
#include <wine/test.h>
|
||||
#include <ndk/rtlfuncs.h>
|
||||
|
||||
/*
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlGetLongestNtPathLength(VOID);
|
||||
*/
|
||||
|
||||
START_TEST(RtlGetLongestNtPathLength)
|
||||
{
|
||||
ULONG Length;
|
||||
|
||||
Length = RtlGetLongestNtPathLength();
|
||||
ok(Length == 269, "Length = %lu\n", Length);
|
||||
}
|
|
@ -8,20 +8,24 @@
|
|||
extern void func_NtAllocateVirtualMemory(void);
|
||||
extern void func_NtFreeVirtualMemory(void);
|
||||
extern void func_NtSystemInformation(void);
|
||||
extern void func_RtlDetermineDosPathNameType(void);
|
||||
extern void func_RtlGetFullPathName_U(void);
|
||||
extern void func_RtlGetFullPathName_UstrEx(void);
|
||||
extern void func_RtlGetLongestNtPathLength(void);
|
||||
extern void func_RtlInitializeBitMap(void);
|
||||
extern void func_ZwContinue(void);
|
||||
|
||||
const struct test winetest_testlist[] =
|
||||
{
|
||||
{ "NtAllocateVirtualMemory", func_NtAllocateVirtualMemory },
|
||||
{ "NtFreeVirtualMemory", func_NtFreeVirtualMemory },
|
||||
{ "NtSystemInformation", func_NtSystemInformation },
|
||||
{ "RtlGetFullPathName_U", func_RtlGetFullPathName_U },
|
||||
{ "RtlGetFullPathName_UstrEx", func_RtlGetFullPathName_UstrEx },
|
||||
{ "RtlInitializeBitMap", func_RtlInitializeBitMap },
|
||||
{ "ZwContinue", func_ZwContinue },
|
||||
{ "NtAllocateVirtualMemory", func_NtAllocateVirtualMemory },
|
||||
{ "NtFreeVirtualMemory", func_NtFreeVirtualMemory },
|
||||
{ "NtSystemInformation", func_NtSystemInformation },
|
||||
{ "RtlDetermineDosPathNameType", func_RtlDetermineDosPathNameType },
|
||||
{ "RtlGetFullPathName_U", func_RtlGetFullPathName_U },
|
||||
{ "RtlGetFullPathName_UstrEx", func_RtlGetFullPathName_UstrEx },
|
||||
{ "RtlGetLongestNtPathLength", func_RtlGetLongestNtPathLength },
|
||||
{ "RtlInitializeBitMap", func_RtlInitializeBitMap },
|
||||
{ "ZwContinue", func_ZwContinue },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue