Author: tfaber Date: Wed Apr 25 09:52:38 2012 New Revision: 56413
URL: http://svn.reactos.org/svn/reactos?rev=56413&view=rev Log: [NTDLL_APITEST] - Add a test for RtlGetFullPathName_Ustr (requires the function address to be known) - Various improvements to the other path tests
Added: trunk/rostests/apitests/ntdll/RtlGetFullPathName_Ustr.c (with props) Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c trunk/rostests/apitests/ntdll/RtlGetFullPathName_U.c trunk/rostests/apitests/ntdll/RtlGetFullPathName_UstrEx.c trunk/rostests/apitests/ntdll/testlist.c
Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/CMakeLists.... ============================================================================== --- trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -4,6 +4,7 @@ NtFreeVirtualMemory.c RtlDetermineDosPathNameType.c RtlGetFullPathName_U.c + RtlGetFullPathName_Ustr.c RtlGetFullPathName_UstrEx.c RtlGetLongestNtPathLength.c RtlInitializeBitMap.c
Modified: trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlDetermin... ============================================================================== --- trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -66,6 +66,28 @@ StartOfBuffer += Size - SizeRequested;
return StartOfBuffer; +} + +static +VOID +MakeReadOnly( + PVOID Pointer, + SIZE_T SizeRequested) +{ + NTSTATUS Status; + SIZE_T Size = PAGE_ROUND_UP(SizeRequested); + PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer); + + 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); + } + } }
static @@ -159,7 +181,7 @@ USHORT Length;
if (!RtlDetermineDosPathNameType_Ustr) - skip(0, "RtlDetermineDosPathNameType_Ustr unavailable\n"); + skip("RtlDetermineDosPathNameType_Ustr unavailable\n");
StartSeh() RtlDetermineDosPathNameType_U(NULL); EndSeh(STATUS_ACCESS_VIOLATION);
@@ -178,6 +200,7 @@ Length = (USHORT)wcslen(Tests[i].FileName) * sizeof(WCHAR); FileName = AllocateGuarded(Length + sizeof(UNICODE_NULL)); RtlCopyMemory(FileName, Tests[i].FileName, Length + sizeof(UNICODE_NULL)); + MakeReadOnly(FileName, Length + sizeof(UNICODE_NULL)); StartSeh() PathType = RtlDetermineDosPathNameType_U(FileName); ok(PathType == Tests[i].PathType, "PathType is %d, expected %d for '%S'\n", PathType, Tests[i].PathType, Tests[i].FileName); @@ -190,6 +213,7 @@
FileName = AllocateGuarded(Length); RtlCopyMemory(FileName, Tests[i].FileName, Length); + MakeReadOnly(FileName, Length); PathString.Buffer = FileName; PathString.Length = Length; PathString.MaximumLength = MAXUSHORT;
Modified: trunk/rostests/apitests/ntdll/RtlGetFullPathName_U.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlGetFullP... ============================================================================== --- trunk/rostests/apitests/ntdll/RtlGetFullPathName_U.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/RtlGetFullPathName_U.c [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -56,16 +56,16 @@ Result = FALSE; }
- /* the function nulls the rest of the buffer! */ + /* The function nulls the rest of the buffer! */ for (i = Length + sizeof(UNICODE_NULL); i < MaximumLength; i++) { UCHAR Char = ((PUCHAR)Buffer)[i]; if (Char != 0) { ok(0, "Found 0x%x at offset %lu, expected 0x%x\n", Char, (ULONG)i, 0); - /* don't count this as a failure unless the string was actually wrong */ + /* Don't count this as a failure unless the string was actually wrong */ //Result = FALSE; - /* don't flood the log */ + /* Don't flood the log */ break; } } @@ -73,7 +73,7 @@ return Result; }
-#define InvalidPointer ((PVOID)0x1234) +#define InvalidPointer ((PVOID)0x0123456789ABCDEFULL)
/* winetest_platform is "windows" for us, so broken() doesn't do what it should :( */ #undef broken @@ -172,11 +172,8 @@ &ShortName); EndSeh(STATUS_SUCCESS);
- /* TODO: remove SEH here */ - StartSeh() - ok(CheckStringBuffer(FullPathNameBuffer, Length, sizeof(FullPathNameBuffer), ExpectedPathName), - "Wrong path name '%S', expected '%S'\n", FullPathNameBuffer, ExpectedPathName); - EndSeh(STATUS_SUCCESS); + ok(CheckStringBuffer(FullPathNameBuffer, Length, sizeof(FullPathNameBuffer), ExpectedPathName), + "Wrong path name '%S', expected '%S'\n", FullPathNameBuffer, ExpectedPathName);
if (!ShortName) FilePartSize = 0; @@ -278,6 +275,6 @@ ok(ShortName == InvalidPointer || broken(ShortName == NULL) /* Win7 */, "ShortName = %p\n", ShortName);
- /* check the actual functionality with different paths */ + /* Check the actual functionality with different paths */ RunTestCases(); }
Added: trunk/rostests/apitests/ntdll/RtlGetFullPathName_Ustr.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlGetFullP... ============================================================================== --- trunk/rostests/apitests/ntdll/RtlGetFullPathName_Ustr.c (added) +++ trunk/rostests/apitests/ntdll/RtlGetFullPathName_Ustr.c [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -1,0 +1,392 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for RtlGetFullPathName_Ustr + * PROGRAMMER: Thomas Faber thfabba@gmx.de + */ + +#define WIN32_NO_STATUS +#include <wine/test.h> +#include <pseh/pseh2.h> +#include <ndk/rtlfuncs.h> + +/* +ULONG +NTAPI +RtlGetFullPathName_Ustr( + IN PCUNICODE_STRING FileName, + IN ULONG Size, + IN PWSTR Buffer, + OUT PCWSTR *ShortName, + OUT PBOOLEAN InvalidName, + OUT RTL_PATH_TYPE* PathType +); +*/ + +/* This seems to be a struct of some kind in Windows 7... returns 0 or 32 in the second member */ +typedef struct _PATH_TYPE_AND_UNKNOWN +{ + RTL_PATH_TYPE Type; + ULONG Unknown; +} PATH_TYPE_AND_UNKNOWN; + +static +ULONG +(NTAPI +*RtlGetFullPathName_Ustr)( + IN PCUNICODE_STRING FileName, + IN ULONG Size, + IN PWSTR Buffer, + OUT PCWSTR *ShortName, + OUT PBOOLEAN InvalidName, + OUT PATH_TYPE_AND_UNKNOWN* PathType +) +//= (PVOID)0x7c83086c // 2003 sp1 x86 +//= (PVOID)0x7769a3dd // win7 sp1 wow64 +; + +#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) + +#define ok_eq_ustr(str1, str2) do { \ + ok((str1)->Buffer == (str2)->Buffer, "Buffer modified\n"); \ + ok((str1)->Length == (str2)->Length, "Length modified\n"); \ + ok((str1)->MaximumLength == (str2)->MaximumLength, "MaximumLength modified\n"); \ + } while (0) + +static +BOOLEAN +CheckStringBuffer( + PCWSTR Buffer, + ULONG Length, + SIZE_T MaximumLength, + PCWSTR Expected) +{ + USHORT ExpectedLength = wcslen(Expected) * sizeof(WCHAR); + SIZE_T EqualLength; + BOOLEAN Result = TRUE; + SIZE_T i; + + if (Length != ExpectedLength) + { + ok(0, "String length is %u, expected %u\n", Length, ExpectedLength); + Result = FALSE; + } + + EqualLength = RtlCompareMemory(Buffer, Expected, Length); + if (EqualLength != Length) + { + ok(0, "String is '%S', expected '%S'\n", Buffer, Expected); + Result = FALSE; + } + + if (Buffer[Length / sizeof(WCHAR)] != UNICODE_NULL) + { + ok(0, "Not null terminated\n"); + Result = FALSE; + } + + /* The function nulls the rest of the buffer! */ + for (i = Length + sizeof(UNICODE_NULL); i < MaximumLength; i++) + { + UCHAR Char = ((PUCHAR)Buffer)[i]; + if (Char != 0) + { + ok(0, "Found 0x%x at offset %lu, expected 0x%x\n", Char, (ULONG)i, 0); + /* Don't count this as a failure unless the string was actually wrong */ + //Result = FALSE; + /* Don't flood the log */ + break; + } + } + + return Result; +} + +#define RtlPathTypeNotSet 123 +#define InvalidPointer ((PVOID)0x0123456789ABCDEFULL) + +/* winetest_platform is "windows" for us, so broken() doesn't do what it should :( */ +#undef broken +#define broken(x) 0 + +typedef enum +{ + PrefixNone, + PrefixCurrentDrive, + PrefixCurrentPath, + PrefixCurrentPathWithoutLastPart +} PREFIX_TYPE; + +static +VOID +RunTestCases(VOID) +{ + /* TODO: don't duplicate this here and in the RtlGetFullPathName_U test */ + struct + { + PCWSTR FileName; + PREFIX_TYPE PrefixType; + PCWSTR FullPathName; + RTL_PATH_TYPE PathType; + PREFIX_TYPE FilePartPrefixType; + SIZE_T FilePartSize; + } TestCases[] = + { + { L"C:", PrefixCurrentPath, L"", RtlPathTypeDriveRelative, PrefixCurrentPathWithoutLastPart }, + { L"C:\", PrefixNone, L"C:\", RtlPathTypeDriveAbsolute }, + { L"C:\test", PrefixNone, L"C:\test", RtlPathTypeDriveAbsolute, PrefixCurrentDrive }, + { L"C:\test\", PrefixNone, L"C:\test\", RtlPathTypeDriveAbsolute }, + { L"C:/test/", PrefixNone, L"C:\test\", RtlPathTypeDriveAbsolute }, + + { L"C:\\test", PrefixNone, L"C:\test", RtlPathTypeDriveAbsolute, PrefixCurrentDrive }, + { L"test", PrefixCurrentPath, L"\test", RtlPathTypeRelative, PrefixCurrentPath, sizeof(WCHAR) }, + { L"\test", PrefixCurrentDrive, L"test", RtlPathTypeRooted, PrefixCurrentDrive }, + { L"/test", PrefixCurrentDrive, L"test", RtlPathTypeRooted, PrefixCurrentDrive }, + { L".\test", PrefixCurrentPath, L"\test", RtlPathTypeRelative, PrefixCurrentPath, sizeof(WCHAR) }, + + { L"\.", PrefixCurrentDrive, L"", RtlPathTypeRooted }, + { L"\.\", PrefixCurrentDrive, L"", RtlPathTypeRooted }, + { L"\\.", PrefixNone, L"\\.\", RtlPathTypeRootLocalDevice }, + { L"\\.\", PrefixNone, L"\\.\", RtlPathTypeLocalDevice }, + { L"\\.\Something\", PrefixNone, L"\\.\Something\", RtlPathTypeLocalDevice }, + + { L"\??\", PrefixCurrentDrive, L"??\", RtlPathTypeRooted }, + { L"\??\C:", PrefixCurrentDrive, L"??\C:", RtlPathTypeRooted, PrefixCurrentDrive, 3 * sizeof(WCHAR) }, + { L"\??\C:\", PrefixCurrentDrive, L"??\C:\", RtlPathTypeRooted }, + { L"\??\C:\test", PrefixCurrentDrive, L"??\C:\test", RtlPathTypeRooted, PrefixCurrentDrive, 6 * sizeof(WCHAR) }, + { L"\??\C:\test\", PrefixCurrentDrive, L"??\C:\test\", RtlPathTypeRooted }, + + { L"\\??\", PrefixNone, L"\\??\", RtlPathTypeUncAbsolute }, + { L"\\??\C:", PrefixNone, L"\\??\C:", RtlPathTypeUncAbsolute }, + { L"\\??\C:\", PrefixNone, L"\\??\C:\", RtlPathTypeUncAbsolute }, + { L"\\??\C:\test", PrefixNone, L"\\??\C:\test", RtlPathTypeUncAbsolute, PrefixNone, sizeof(L"\\??\C:\") }, + { L"\\??\C:\test\", PrefixNone, L"\\??\C:\test\", RtlPathTypeUncAbsolute }, + }; + NTSTATUS ExceptionStatus; + ULONG Length; + UNICODE_STRING FileName; + WCHAR FullPathNameBuffer[MAX_PATH]; + UNICODE_STRING TempString; + const WCHAR *ShortName; + BOOLEAN NameInvalid; + PATH_TYPE_AND_UNKNOWN PathType; + WCHAR ExpectedPathName[MAX_PATH]; + SIZE_T ExpectedFilePartSize; + const WCHAR *ExpectedShortName; + const INT TestCount = sizeof(TestCases) / sizeof(TestCases[0]); + INT i; + + for (i = 0; i < TestCount; i++) + { + trace("i = %d\n", i); + switch (TestCases[i].PrefixType) + { + case PrefixNone: + ExpectedPathName[0] = UNICODE_NULL; + break; + case PrefixCurrentDrive: + GetCurrentDirectoryW(sizeof(ExpectedPathName) / sizeof(WCHAR), ExpectedPathName); + ExpectedPathName[3] = UNICODE_NULL; + break; + case PrefixCurrentPath: + { + ULONG Length; + Length = GetCurrentDirectoryW(sizeof(ExpectedPathName) / sizeof(WCHAR), ExpectedPathName); + if (Length == 3 && TestCases[i].FullPathName[0]) + ExpectedPathName[2] = UNICODE_NULL; + break; + } + default: + skip(0, "Invalid test!\n"); + continue; + } + wcscat(ExpectedPathName, TestCases[i].FullPathName); + RtlInitUnicodeString(&FileName, TestCases[i].FileName); + RtlFillMemory(FullPathNameBuffer, sizeof(FullPathNameBuffer), 0xAA); + TempString = FileName; + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + ShortName = InvalidPointer; + NameInvalid = (BOOLEAN)-1; + Length = 1234; + StartSeh() + Length = RtlGetFullPathName_Ustr(&FileName, + sizeof(FullPathNameBuffer), + FullPathNameBuffer, + &ShortName, + &NameInvalid, + &PathType); + EndSeh(STATUS_SUCCESS); + ok_eq_ustr(&FileName, &TempString); + ok(CheckStringBuffer(FullPathNameBuffer, Length, sizeof(FullPathNameBuffer), ExpectedPathName), + "Wrong path name '%S', expected '%S'\n", FullPathNameBuffer, ExpectedPathName); + switch (TestCases[i].FilePartPrefixType) + { + case PrefixNone: + ExpectedFilePartSize = 0; + break; + case PrefixCurrentDrive: + ExpectedFilePartSize = sizeof(L"C:\"); + break; + case PrefixCurrentPath: + ExpectedFilePartSize = GetCurrentDirectoryW(0, NULL) * sizeof(WCHAR); + if (ExpectedFilePartSize == sizeof(L"C:\")) + ExpectedFilePartSize -= sizeof(WCHAR); + break; + case PrefixCurrentPathWithoutLastPart: + { + WCHAR CurrentPath[MAX_PATH]; + PCWSTR BackSlash; + ExpectedFilePartSize = GetCurrentDirectoryW(sizeof(CurrentPath) / sizeof(WCHAR), CurrentPath) * sizeof(WCHAR) + sizeof(UNICODE_NULL); + if (ExpectedFilePartSize == sizeof(L"C:\")) + ExpectedFilePartSize = 0; + else + { + BackSlash = wcsrchr(CurrentPath, L'\'); + if (BackSlash) + ExpectedFilePartSize -= wcslen(BackSlash + 1) * sizeof(WCHAR); + else + ok(0, "GetCurrentDirectory returned %S\n", CurrentPath); + } + break; + } + default: + skip(0, "Invalid test!\n"); + continue; + } + ExpectedFilePartSize += TestCases[i].FilePartSize; + if (ExpectedFilePartSize == 0) + { + ExpectedShortName = NULL; + } + else + { + ExpectedFilePartSize = (ExpectedFilePartSize - sizeof(UNICODE_NULL)) / sizeof(WCHAR); + ExpectedShortName = FullPathNameBuffer + ExpectedFilePartSize; + } + ok(ShortName == ExpectedShortName, + "ShortName = %p, expected %p\n", ShortName, ExpectedShortName); + ok(NameInvalid == FALSE, "NameInvalid = %u\n", NameInvalid); + ok(PathType.Type == TestCases[i].PathType, "PathType = %d, expected %d\n", PathType.Type, TestCases[i].PathType); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) || + broken(PathType.Unknown == 32), "Unknown = %d\n", PathType.Unknown); + } +} + +START_TEST(RtlGetFullPathName_Ustr) +{ + NTSTATUS ExceptionStatus; + ULONG Length; + UNICODE_STRING FileName; + UNICODE_STRING TempString; + PCWSTR ShortName; + BOOLEAN NameInvalid; + PATH_TYPE_AND_UNKNOWN PathType; + + if (!RtlGetFullPathName_Ustr) + return; + + /* NULL parameters */ + StartSeh() + RtlGetFullPathName_Ustr(NULL, 0, NULL, NULL, NULL, NULL); + EndSeh(STATUS_ACCESS_VIOLATION); + + RtlInitUnicodeString(&FileName, NULL); + TempString = FileName; + StartSeh() + RtlGetFullPathName_Ustr(&FileName, 0, NULL, NULL, NULL, NULL); + EndSeh(STATUS_ACCESS_VIOLATION); + ok_eq_ustr(&FileName, &TempString); + + RtlInitUnicodeString(&FileName, L""); + TempString = FileName; + StartSeh() + RtlGetFullPathName_Ustr(&FileName, 0, NULL, NULL, NULL, NULL); + EndSeh(STATUS_ACCESS_VIOLATION); + ok_eq_ustr(&FileName, &TempString); + + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + StartSeh() + RtlGetFullPathName_Ustr(NULL, 0, NULL, NULL, NULL, &PathType); + EndSeh(STATUS_ACCESS_VIOLATION); + ok(PathType.Type == RtlPathTypeUnknown || + broken(PathType.Type == RtlPathTypeNotSet) /* Win7 */, "PathType = %d\n", PathType.Type); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) /* Win7 */, "Unknown = %d\n", PathType.Unknown); + + /* check what else is initialized before it crashes */ + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + ShortName = InvalidPointer; + NameInvalid = (BOOLEAN)-1; + StartSeh() + RtlGetFullPathName_Ustr(NULL, 0, NULL, &ShortName, &NameInvalid, &PathType); + EndSeh(STATUS_ACCESS_VIOLATION); + ok(NameInvalid == FALSE, "NameInvalid = %u\n", NameInvalid); + ok(ShortName == InvalidPointer || + broken(ShortName == NULL), "ShortName = %p\n", ShortName); + ok(PathType.Type == RtlPathTypeUnknown || + broken(PathType.Type == RtlPathTypeNotSet) /* Win7 */, "PathType = %d\n", PathType.Type); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) /* Win7 */, "Unknown = %d\n", PathType.Unknown); + + RtlInitUnicodeString(&FileName, L""); + TempString = FileName; + ShortName = InvalidPointer; + NameInvalid = (BOOLEAN)-1; + StartSeh() + RtlGetFullPathName_Ustr(&FileName, 0, NULL, &ShortName, &NameInvalid, NULL); + EndSeh(STATUS_ACCESS_VIOLATION); + ok_eq_ustr(&FileName, &TempString); + ok(ShortName == InvalidPointer || + broken(ShortName == NULL), "ShortName = %p\n", ShortName); + ok(NameInvalid == FALSE || + broken(NameInvalid == (BOOLEAN)-1) /* Win7 */, "NameInvalid = %u\n", NameInvalid); + + /* This is the first one that doesn't crash. FileName and PathType cannot be NULL */ + RtlInitUnicodeString(&FileName, NULL); + TempString = FileName; + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + StartSeh() + Length = RtlGetFullPathName_Ustr(&FileName, 0, NULL, NULL, NULL, &PathType); + ok(Length == 0, "Length = %lu\n", Length); + EndSeh(STATUS_SUCCESS); + ok_eq_ustr(&FileName, &TempString); + ok(PathType.Type == RtlPathTypeUnknown, "PathType = %d\n", PathType.Type); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) /* Win7 */, "Unknown = %d\n", PathType.Unknown); + + RtlInitUnicodeString(&FileName, L""); + TempString = FileName; + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + StartSeh() + Length = RtlGetFullPathName_Ustr(&FileName, 0, NULL, NULL, NULL, &PathType); + ok(Length == 0, "Length = %lu\n", Length); + EndSeh(STATUS_SUCCESS); + ok_eq_ustr(&FileName, &TempString); + ok(PathType.Type == RtlPathTypeUnknown, "PathType = %d\n", PathType.Type); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) /* Win7 */, "Unknown = %d\n", PathType.Unknown); + + /* Give it a valid path */ + RtlInitUnicodeString(&FileName, L"C:\test"); + TempString = FileName; + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + StartSeh() + Length = RtlGetFullPathName_Ustr(&FileName, 0, NULL, NULL, NULL, &PathType); + ok(Length == sizeof(L"C:\test"), "Length = %lu\n", Length); + EndSeh(STATUS_SUCCESS); + ok_eq_ustr(&FileName, &TempString); + ok(PathType.Type == RtlPathTypeDriveAbsolute, "PathType = %d\n", PathType.Type); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) /* Win7 */, "Unknown = %d\n", PathType.Unknown); + + /* check the actual functionality with different paths */ + RunTestCases(); +}
Propchange: trunk/rostests/apitests/ntdll/RtlGetFullPathName_Ustr.c ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/rostests/apitests/ntdll/RtlGetFullPathName_UstrEx.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlGetFullP... ============================================================================== --- trunk/rostests/apitests/ntdll/RtlGetFullPathName_UstrEx.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/RtlGetFullPathName_UstrEx.c [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -13,14 +13,16 @@ /* NTSTATUS NTAPI -RtlGetFullPathName_UstrEx(IN PUNICODE_STRING FileName, - IN PUNICODE_STRING StaticString, - IN PUNICODE_STRING DynamicString, - IN PUNICODE_STRING *StringUsed, - IN PSIZE_T FilePartSize OPTIONAL, - OUT PBOOLEAN NameInvalid, - OUT RTL_PATH_TYPE* PathType, - OUT PSIZE_T LengthNeeded OPTIONAL); +RtlGetFullPathName_UstrEx( + IN PUNICODE_STRING FileName, + IN PUNICODE_STRING StaticString, + IN PUNICODE_STRING DynamicString, + IN PUNICODE_STRING *StringUsed, + IN PSIZE_T FilePartSize OPTIONAL, + OUT PBOOLEAN NameInvalid, + OUT RTL_PATH_TYPE* PathType, + OUT PSIZE_T LengthNeeded OPTIONAL +); */
#define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY { @@ -80,7 +82,7 @@ }
#define RtlPathTypeNotSet 123 -#define InvalidPointer ((PVOID)0x1234) +#define InvalidPointer ((PVOID)0x0123456789ABCDEFULL)
/* winetest_platform is "windows" for us, so broken() doesn't do what it should :( */ #undef broken @@ -202,11 +204,8 @@ ok_eq_ustr(&FileName, &TempString); ok(FullPathName.Buffer == FullPathNameBuffer, "Buffer modified\n"); ok(FullPathName.MaximumLength == sizeof(FullPathNameBuffer), "MaximumLength modified\n"); - /* TODO: remove SEH here */ - StartSeh() - ok(CheckStringBuffer(&FullPathName, ExpectedPathName), - "Wrong path name '%wZ', expected '%S'\n", &FullPathName, ExpectedPathName); - EndSeh(STATUS_SUCCESS); + ok(CheckStringBuffer(&FullPathName, ExpectedPathName), + "Wrong path name '%wZ', expected '%S'\n", &FullPathName, ExpectedPathName); ok(StringUsed == &FullPathName, "StringUsed = %p, expected %p\n", StringUsed, &FullPathName); switch (TestCases[i].FilePartPrefixType) { @@ -270,6 +269,13 @@ RtlGetFullPathName_UstrEx(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); EndSeh(STATUS_ACCESS_VIOLATION);
+ RtlInitUnicodeString(&FileName, NULL); + TempString = FileName; + StartSeh() + RtlGetFullPathName_UstrEx(&FileName, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + EndSeh(STATUS_ACCESS_VIOLATION); + ok_eq_ustr(&FileName, &TempString); + RtlInitUnicodeString(&FileName, L""); TempString = FileName; StartSeh() @@ -284,7 +290,7 @@ ok(PathType == RtlPathTypeUnknown || broken(PathType == RtlPathTypeNotSet) /* Win7 */, "PathType = %d\n", PathType);
- /* check what else is initialized before it crashes */ + /* Check what else is initialized before it crashes */ PathType = RtlPathTypeNotSet; StringUsed = InvalidPointer; FilePartSize = 1234; @@ -317,7 +323,7 @@ ok(LengthNeeded == 0, "LengthNeeded = %lu\n", (ULONG)LengthNeeded);
/* This is the first one that doesn't crash. FileName and PathType cannot be NULL */ - RtlInitUnicodeString(&FileName, L""); + RtlInitUnicodeString(&FileName, NULL); TempString = FileName; PathType = RtlPathTypeNotSet; StartSeh() @@ -327,6 +333,16 @@ ok_eq_ustr(&FileName, &TempString); ok(PathType == RtlPathTypeUnknown, "PathType = %d\n", PathType);
+ RtlInitUnicodeString(&FileName, L""); + TempString = FileName; + PathType = RtlPathTypeNotSet; + StartSeh() + Status = RtlGetFullPathName_UstrEx(&FileName, NULL, NULL, NULL, NULL, NULL, &PathType, NULL); + ok(Status == STATUS_OBJECT_NAME_INVALID, "status = %lx\n", Status); + EndSeh(STATUS_SUCCESS); + ok_eq_ustr(&FileName, &TempString); + ok(PathType == RtlPathTypeUnknown, "PathType = %d\n", PathType); + /* Give it a valid path */ RtlInitUnicodeString(&FileName, L"C:\test"); TempString = FileName; @@ -352,6 +368,6 @@
/* TODO: play around with StaticString and DynamicString */
- /* check the actual functionality with different paths */ + /* Check the actual functionality with different paths */ RunTestCases(); }
Modified: trunk/rostests/apitests/ntdll/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/testlist.c?... ============================================================================== --- trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -10,6 +10,7 @@ extern void func_NtSystemInformation(void); extern void func_RtlDetermineDosPathNameType(void); extern void func_RtlGetFullPathName_U(void); +extern void func_RtlGetFullPathName_Ustr(void); extern void func_RtlGetFullPathName_UstrEx(void); extern void func_RtlGetLongestNtPathLength(void); extern void func_RtlInitializeBitMap(void); @@ -22,6 +23,7 @@ { "NtSystemInformation", func_NtSystemInformation }, { "RtlDetermineDosPathNameType", func_RtlDetermineDosPathNameType }, { "RtlGetFullPathName_U", func_RtlGetFullPathName_U }, + { "RtlGetFullPathName_Ustr", func_RtlGetFullPathName_Ustr }, { "RtlGetFullPathName_UstrEx", func_RtlGetFullPathName_UstrEx }, { "RtlGetLongestNtPathLength", func_RtlGetLongestNtPathLength }, { "RtlInitializeBitMap", func_RtlInitializeBitMap },