Author: hbelusca
Date: Fri Jun 7 01:25:57 2013
New Revision: 59183
URL:
http://svn.reactos.org/svn/reactos?rev=59183&view=rev
Log:
[KERNEL32-RTL]
Fix return type and usage of RtlDetermineDosPathNameType_U, and use the declaration of
RTL_PATH_TYPE in winternl.h instead of the wineism DOS_PATHNAME_TYPE.
[RTL:PATH]
- Make usage of the IS_PATH_SEPARATOR(...) macro instead of automatically checking for
L'\\' or L'/', and of OBJ_NAME_PATH_SEPARATOR when checking for
L'\\' only or setting the character L'\\' (just code consistency only).
<Test fixes:>
- Fix a search loop and a check in RtlpWin32NTNameToNtPathName_U (a problem of setting the
pointer *PartName via the variable p existed (always 1 character shift wrt. the expected
result, and now *PartName is set to NULL even if p == NewBuffer).
- Zero out an optional parameter (if present) in RtlDosSearchPath_Ustr.
- Zero out the return buffer in RtlGetFullPathName_U (function from Wine).
Those fixes ^ correct the following tests:
* ntdll:RtlDosPathNameToNtPathName_U (58 errors to 4 errors remaining due to UNC path
handling).
* ntdll:RtlDosSearchPath_U (9 errors to 6 errors remaining due to the fact that our
RtlDosSearchPath_U doesn't throw exception on bad arguments because it checks the
validity of its arguments (pointers especially), whereas on Windows it seems it
doesn't happen to be the case).
* ntdll:RtlDosSearchPath_Ustr (4 errors to full success).
* ntdll:RtlGetFullPathName_U (31 errors to 8 errors).
* ntdll:RtlGetFullPathName_UstrEx (29 errors to 6 errors).
Modified:
trunk/reactos/dll/win32/kernel32/wine/profile.c
trunk/reactos/include/ndk/rtlfuncs.h
trunk/reactos/include/psdk/winternl.h
trunk/reactos/lib/rtl/path.c
Modified: trunk/reactos/dll/win32/kernel32/wine/profile.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/wine/pr…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/wine/profile.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/wine/profile.c [iso-8859-1] Fri Jun 7 01:25:57
2013
@@ -762,7 +762,7 @@
if (!filename)
filename = wininiW;
- if ((RtlDetermineDosPathNameType_U(filename) == RELATIVE_PATH) &&
+ if ((RtlDetermineDosPathNameType_U(filename) == RtlPathTypeRelative) &&
!strchrW(filename, '\\') && !strchrW(filename, '/'))
{
static const WCHAR wszSeparator[] = {'\\', 0};
Modified: trunk/reactos/include/ndk/rtlfuncs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtlfuncs.h?rev…
==============================================================================
--- trunk/reactos/include/ndk/rtlfuncs.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/rtlfuncs.h [iso-8859-1] Fri Jun 7 01:25:57 2013
@@ -2617,7 +2617,7 @@
);
NTSYSAPI
-ULONG
+RTL_PATH_TYPE
NTAPI
RtlDetermineDosPathNameType_U(
_In_ PCWSTR Path
Modified: trunk/reactos/include/psdk/winternl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winternl.h?re…
==============================================================================
--- trunk/reactos/include/psdk/winternl.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/winternl.h [iso-8859-1] Fri Jun 7 01:25:57 2013
@@ -861,18 +861,18 @@
} TIMER_BASIC_INFORMATION, *PTIMER_BASIC_INFORMATION;
-/* return type of RtlDetermineDosPathNameType_U (FIXME: not the correct names) */
-typedef enum
-{
- INVALID_PATH = 0,
- UNC_PATH, /* "//foo" */
- ABSOLUTE_DRIVE_PATH, /* "c:/foo" */
- RELATIVE_DRIVE_PATH, /* "c:foo" */
- ABSOLUTE_PATH, /* "/foo" */
- RELATIVE_PATH, /* "foo" */
- DEVICE_PATH, /* "//./foo" */
- UNC_DOT_PATH /* "//." */
-} DOS_PATHNAME_TYPE;
+/* Return type of RtlDetermineDosPathNameType_U */
+typedef enum _RTL_PATH_TYPE
+{
+ RtlPathTypeUnknown,
+ RtlPathTypeUncAbsolute,
+ RtlPathTypeDriveAbsolute,
+ RtlPathTypeDriveRelative,
+ RtlPathTypeRooted,
+ RtlPathTypeRelative,
+ RtlPathTypeLocalDevice,
+ RtlPathTypeRootLocalDevice,
+} RTL_PATH_TYPE;
/***********************************************************************
* IA64 specific types and data structures
@@ -2130,7 +2130,7 @@
HANDLE WINAPI RtlDestroyHeap(HANDLE);
void WINAPI RtlDestroyProcessParameters(RTL_USER_PROCESS_PARAMETERS*);
NTSTATUS WINAPI RtlDestroyQueryDebugBuffer(PDEBUG_BUFFER);
-DOS_PATHNAME_TYPE WINAPI RtlDetermineDosPathNameType_U(PCWSTR);
+RTL_PATH_TYPE WINAPI RtlDetermineDosPathNameType_U(PCWSTR);
BOOLEAN WINAPI RtlDoesFileExists_U(LPCWSTR);
BOOLEAN WINAPI RtlDosPathNameToNtPathName_U(PCWSTR,PUNICODE_STRING,PCWSTR*,CURDIR*);
ULONG WINAPI RtlDosSearchPath_U(LPCWSTR, LPCWSTR, LPCWSTR, ULONG, LPWSTR, LPWSTR*);
Modified: trunk/reactos/lib/rtl/path.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/path.c?rev=59183&a…
==============================================================================
--- trunk/reactos/lib/rtl/path.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/path.c [iso-8859-1] Fri Jun 7 01:25:57 2013
@@ -160,7 +160,7 @@
{
/* Check if the character is a path or drive separator */
c = *End;
- if ((c == '\\') || (c == '/') || ((c == ':')
&& (End == PathCopy.Buffer + 1)))
+ if (IS_PATH_SEPARATOR(c) || ((c == ':') && (End ==
PathCopy.Buffer + 1)))
{
/* Get the next lower case character */
End++;
@@ -422,30 +422,33 @@
if (PartName)
{
/* Loop from the back until we find a path separator */
- p = &NewBuffer[(DosLength - 1) / sizeof (WCHAR)];
- while (p > NewBuffer) if (*p-- == '\\') break;
-
- /* Was one found? */
- if (p > NewBuffer)
- {
- /* Move past it -- anything left? */
- p++;
- if (!*p)
+ p = &NewBuffer[DosLength / sizeof (WCHAR)];
+ while (--p > NewBuffer)
+ {
+ /* We found a path separator, move past it */
+ if (*p == OBJ_NAME_PATH_SEPARATOR)
{
- /* The path ends with a path separator, no part name */
- *PartName = NULL;
+ ++p;
+ break;
}
- else
- {
- /* What follows the path separator is the part name */
- *PartName = p;
- }
+ }
+
+ /* Check whether a separator was found and if something remains */
+ if ((p > NewBuffer) && *p)
+ {
+ /* What follows the path separator is the partial name */
+ *PartName = p;
+ }
+ else
+ {
+ /* The path ends with a path separator, no partial name */
+ *PartName = NULL;
}
}
/* Build the final NT path string */
+ NtPath->Buffer = NewBuffer;
NtPath->Length = (USHORT)DosLength;
- NtPath->Buffer = NewBuffer;
NtPath->MaximumLength = (USHORT)DosLength + sizeof(UNICODE_NULL);
return STATUS_SUCCESS;
}
@@ -574,7 +577,6 @@
/* Nothing else is expected */
default:
ASSERT(FALSE);
-
}
/* Now copy the prefix and the buffer */
@@ -592,7 +594,7 @@
NtName->Length = (USHORT)Length;
NtName->MaximumLength = (USHORT)MaxLength;
NewBuffer[LengthChars] = UNICODE_NULL;
- DPRINT("new buffer: %S\n", NewBuffer);
+ DPRINT("New buffer: %S\n", NewBuffer);
DPRINT("NT Name: %wZ\n", NtName);
/* Check if a partial name was requested */
@@ -651,7 +653,7 @@
RelativeName->RelativeName.Buffer = (PWSTR)((ULONG_PTR)NewBuffer +
PrefixLength + FullPath.Length - PrefixCut * sizeof(WCHAR));
RelativeName->RelativeName.Length = (USHORT)(PathLength -
FullPath.Length);
/* If relative name starts with \, skip it */
- if (RelativeName->RelativeName.Buffer[0] == L'\\')
+ if (RelativeName->RelativeName.Buffer[0] ==
OBJ_NAME_PATH_SEPARATOR)
{
RelativeName->RelativeName.Buffer++;
RelativeName->RelativeName.Length -= sizeof(WCHAR);
@@ -867,7 +869,7 @@
/*
* @implemented
*/
-ULONG
+RTL_PATH_TYPE
NTAPI
RtlDetermineDosPathNameType_U(IN PCWSTR Path)
{
@@ -1121,7 +1123,7 @@
FullPath.Length = (USHORT)FullPathLength;
/* If full path isn't \ terminated, do it */
- if (FullPath.Buffer[CharLength - 1] != L'\\')
+ if (FullPath.Buffer[CharLength - 1] != OBJ_NAME_PATH_SEPARATOR)
{
if ((CharLength + 1) * sizeof(WCHAR) > SavedLength)
{
@@ -1129,7 +1131,7 @@
goto Leave;
}
- FullPath.Buffer[CharLength] = L'\\';
+ FullPath.Buffer[CharLength] = OBJ_NAME_PATH_SEPARATOR;
FullPath.Buffer[CharLength + 1] = UNICODE_NULL;
FullPath.Length += sizeof(WCHAR);
}
@@ -1500,6 +1502,8 @@
if (!name || !*name) return 0;
+ RtlZeroMemory(buffer, size);
+
if (file_part) *file_part = NULL;
/* check for DOS device name */
@@ -1733,9 +1737,9 @@
}
/* Add a terminating slash if needed */
- if ((BufferStart != NewBuffer) && (BufferStart[-1] != '\\'))
- {
- *BufferStart++ = '\\';
+ if ((BufferStart != NewBuffer) && (BufferStart[-1] !=
OBJ_NAME_PATH_SEPARATOR))
+ {
+ *BufferStart++ = OBJ_NAME_PATH_SEPARATOR;
}
/* Bail out if we reached the end */
@@ -2051,6 +2055,7 @@
/* Initialize optional arguments */
if (FullNameOut) *FullNameOut = NULL;
if (FilePartSize) *FilePartSize = 0;
+ if (LengthNeeded) *LengthNeeded = 0;
if (DynamicString)
{
DynamicString->Length = DynamicString->MaximumLength = 0;
@@ -2322,7 +2327,7 @@
&StaticCandidateString,
Status);
}
- DPRINT("STatus: %lx BUFFER: %S\n", Status,
CallerBuffer->Buffer);
+ DPRINT("Status: %lx BUFFER: %S\n", Status,
CallerBuffer->Buffer);
goto Quickie;
}
else