[RTL]: Fix prototype of RtlDosPathNameToNtPathName_U and fix code to match the new prototype.

[NDK]: Add RTL_RELATIVE_NAME_U which is the Windows 2003+ structure used instead of CURDIR for all relative path APIs.

svn path=/trunk/; revision=52681
This commit is contained in:
Alex Ionescu 2011-07-14 15:33:29 +00:00
parent eaf86bb07c
commit 42cac56e9d
3 changed files with 25 additions and 29 deletions

View file

@ -2348,7 +2348,7 @@ RtlDosPathNameToNtPathName_U(
IN PCWSTR DosPathName, IN PCWSTR DosPathName,
OUT PUNICODE_STRING NtPathName, OUT PUNICODE_STRING NtPathName,
OUT PCWSTR *NtFileNamePart, OUT PCWSTR *NtFileNamePart,
OUT CURDIR *DirectoryInfo OUT PRTL_RELATIVE_NAME_U DirectoryInfo
); );
NTSYSAPI NTSYSAPI
@ -2379,18 +2379,6 @@ RtlGetFullPathName_U(
OUT PWSTR *ShortName OUT PWSTR *ShortName
); );
NTSYSAPI
ULONG
NTAPI
RtlGetFullPathName_Ustr(
IN PUNICODE_STRING FileName,
IN ULONG Size,
IN PWSTR Buffer,
OUT PWSTR *ShortName,
OUT PBOOLEAN InvalidName,
OUT RTL_PATH_TYPE *PathType
);
NTSYSAPI NTSYSAPI
ULONG ULONG
NTAPI NTAPI

View file

@ -1017,6 +1017,14 @@ typedef struct _CURDIR
HANDLE Handle; HANDLE Handle;
} CURDIR, *PCURDIR; } CURDIR, *PCURDIR;
typedef struct _RTLP_CURDIR_REF *PRTLP_CURDIR_REF;
typedef struct _RTL_RELATIVE_NAME_U
{
UNICODE_STRING RelativeName;
HANDLE ContainingDirectory;
PRTLP_CURDIR_REF CurDirRef;
} RTL_RELATIVE_NAME_U, *PRTL_RELATIVE_NAME_U;
typedef struct _RTL_DRIVE_LETTER_CURDIR typedef struct _RTL_DRIVE_LETTER_CURDIR
{ {
USHORT Flags; USHORT Flags;

View file

@ -669,7 +669,7 @@ BOOLEAN NTAPI
RtlDosPathNameToNtPathName_U(IN PCWSTR DosPathName, RtlDosPathNameToNtPathName_U(IN PCWSTR DosPathName,
OUT PUNICODE_STRING NtPathName, OUT PUNICODE_STRING NtPathName,
OUT PCWSTR *NtFileNamePart, OUT PCWSTR *NtFileNamePart,
OUT CURDIR *DirectoryInfo) OUT PRTL_RELATIVE_NAME_U DirectoryInfo)
{ {
UNICODE_STRING us; UNICODE_STRING us;
PCURDIR cd; PCURDIR cd;
@ -731,10 +731,10 @@ RtlDosPathNameToNtPathName_U(IN PCWSTR DosPathName,
if (DirectoryInfo != NULL) if (DirectoryInfo != NULL)
{ {
DirectoryInfo->DosPath.Length = 0; DirectoryInfo->RelativeName.Length = 0;
DirectoryInfo->DosPath.MaximumLength = 0; DirectoryInfo->RelativeName.MaximumLength = 0;
DirectoryInfo->DosPath.Buffer = NULL; DirectoryInfo->RelativeName.Buffer = NULL;
DirectoryInfo->Handle = NULL; DirectoryInfo->ContainingDirectory = NULL;
} }
return TRUE; return TRUE;
@ -804,7 +804,7 @@ RtlDosPathNameToNtPathName_U(IN PCWSTR DosPathName,
/* Set name and handle structure if possible */ /* Set name and handle structure if possible */
if (DirectoryInfo) if (DirectoryInfo)
{ {
memset (DirectoryInfo, 0, sizeof(CURDIR)); memset (DirectoryInfo, 0, sizeof(RTL_RELATIVE_NAME_U));
cd = (PCURDIR)&(NtCurrentPeb ()->ProcessParameters->CurrentDirectory.DosPath); cd = (PCURDIR)&(NtCurrentPeb ()->ProcessParameters->CurrentDirectory.DosPath);
if (Type == 5 && cd->Handle) if (Type == 5 && cd->Handle)
{ {
@ -812,10 +812,10 @@ RtlDosPathNameToNtPathName_U(IN PCWSTR DosPathName,
if (RtlEqualUnicodeString(&us, &cd->DosPath, TRUE)) if (RtlEqualUnicodeString(&us, &cd->DosPath, TRUE))
{ {
Length = ((cd->DosPath.Length / sizeof(WCHAR)) - Offset) + ((Type == 1) ? 8 : 4); Length = ((cd->DosPath.Length / sizeof(WCHAR)) - Offset) + ((Type == 1) ? 8 : 4);
DirectoryInfo->DosPath.Buffer = Buffer + Length; DirectoryInfo->RelativeName.Buffer = Buffer + Length;
DirectoryInfo->DosPath.Length = NtPathName->Length - (Length * sizeof(WCHAR)); DirectoryInfo->RelativeName.Length = NtPathName->Length - (Length * sizeof(WCHAR));
DirectoryInfo->DosPath.MaximumLength = DirectoryInfo->DosPath.Length; DirectoryInfo->RelativeName.MaximumLength = DirectoryInfo->RelativeName.Length;
DirectoryInfo->Handle = cd->Handle; DirectoryInfo->ContainingDirectory = cd->Handle;
} }
} }
} }
@ -914,23 +914,23 @@ RtlDoesFileExists_U(IN PCWSTR FileName)
OBJECT_ATTRIBUTES Attr; OBJECT_ATTRIBUTES Attr;
FILE_BASIC_INFORMATION Info; FILE_BASIC_INFORMATION Info;
NTSTATUS Status; NTSTATUS Status;
CURDIR CurDir; RTL_RELATIVE_NAME_U RelativeName;
if (!RtlDosPathNameToNtPathName_U (FileName, if (!RtlDosPathNameToNtPathName_U (FileName,
&NtFileName, &NtFileName,
NULL, NULL,
&CurDir)) &RelativeName))
return FALSE; return FALSE;
if (CurDir.DosPath.Length) if (RelativeName.RelativeName.Length)
NtFileName = CurDir.DosPath; NtFileName = RelativeName.RelativeName;
else else
CurDir.Handle = 0; RelativeName.ContainingDirectory = 0;
InitializeObjectAttributes (&Attr, InitializeObjectAttributes (&Attr,
&NtFileName, &NtFileName,
OBJ_CASE_INSENSITIVE, OBJ_CASE_INSENSITIVE,
CurDir.Handle, RelativeName.ContainingDirectory,
NULL); NULL);
Status = ZwQueryAttributesFile (&Attr, &Info); Status = ZwQueryAttributesFile (&Attr, &Info);