mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Changed from CreateFileW for opening a directory to the new
function InternalOpenDirectoryW. InternalOpenDirectory uses NtCreateFile instead of CreateFileW. svn path=/trunk/; revision=3404
This commit is contained in:
parent
efcf4c3d7f
commit
69b3035df8
1 changed files with 67 additions and 65 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: volume.c,v 1.23 2002/08/18 21:07:59 hbirr Exp $
|
/* $Id: volume.c,v 1.24 2002/08/27 06:38:23 hbirr Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -30,6 +30,51 @@
|
||||||
|
|
||||||
#define MAX_DOS_DRIVES 26
|
#define MAX_DOS_DRIVES 26
|
||||||
|
|
||||||
|
HANDLE InternalOpenDirW(PWCHAR DirName, BOOLEAN Write)
|
||||||
|
{
|
||||||
|
UNICODE_STRING NtPathU;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
NTSTATUS errCode;
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
HANDLE hFile;
|
||||||
|
|
||||||
|
if (!RtlDosPathNameToNtPathName_U ((LPWSTR)DirName,
|
||||||
|
&NtPathU,
|
||||||
|
NULL,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
DPRINT("Invalid path\n");
|
||||||
|
SetLastError(ERROR_BAD_PATHNAME);
|
||||||
|
return INVALID_HANDLE_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&NtPathU,
|
||||||
|
Write ? FILE_WRITE_ATTRIBUTES : FILE_READ_ATTRIBUTES,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
errCode = NtCreateFile (&hFile,
|
||||||
|
Write ? FILE_GENERIC_WRITE : FILE_GENERIC_READ,
|
||||||
|
&ObjectAttributes,
|
||||||
|
&IoStatusBlock,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||||
|
FILE_OPEN,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
|
||||||
|
RtlFreeUnicodeString(&NtPathU);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(errCode))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus (errCode);
|
||||||
|
return INVALID_HANDLE_VALUE;
|
||||||
|
}
|
||||||
|
return hFile;
|
||||||
|
}
|
||||||
|
|
||||||
DWORD STDCALL
|
DWORD STDCALL
|
||||||
GetLogicalDriveStringsA(DWORD nBufferLength,
|
GetLogicalDriveStringsA(DWORD nBufferLength,
|
||||||
|
@ -178,13 +223,11 @@ GetDiskFreeSpaceW(
|
||||||
RootPathName[3] = 0;
|
RootPathName[3] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hFile = CreateFileW(RootPathName,
|
if (INVALID_HANDLE_VALUE == (hFile = InternalOpenDirW((PWCHAR)lpRootPathName, FALSE)))
|
||||||
FILE_READ_ATTRIBUTES,
|
{
|
||||||
FILE_SHARE_READ,
|
return FALSE;
|
||||||
NULL,
|
}
|
||||||
OPEN_EXISTING,
|
|
||||||
FILE_ATTRIBUTE_NORMAL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
errCode = NtQueryVolumeInformationFile(hFile,
|
errCode = NtQueryVolumeInformationFile(hFile,
|
||||||
&IoStatusBlock,
|
&IoStatusBlock,
|
||||||
|
@ -279,13 +322,10 @@ GetDiskFreeSpaceExW(
|
||||||
RootPathName[3] = 0;
|
RootPathName[3] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hFile = CreateFileW(RootPathName,
|
if (INVALID_HANDLE_VALUE == (hFile = InternalOpenDirW(lpDirectoryName, FALSE)))
|
||||||
FILE_READ_ATTRIBUTES,
|
{
|
||||||
FILE_SHARE_READ,
|
return FALSE;
|
||||||
NULL,
|
}
|
||||||
OPEN_EXISTING,
|
|
||||||
FILE_ATTRIBUTE_NORMAL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
errCode = NtQueryVolumeInformationFile(hFile,
|
errCode = NtQueryVolumeInformationFile(hFile,
|
||||||
&IoStatusBlock,
|
&IoStatusBlock,
|
||||||
|
@ -348,7 +388,6 @@ GetDriveTypeA(LPCSTR lpRootPathName)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UINT STDCALL
|
UINT STDCALL
|
||||||
GetDriveTypeW(LPCWSTR lpRootPathName)
|
GetDriveTypeW(LPCWSTR lpRootPathName)
|
||||||
{
|
{
|
||||||
|
@ -358,13 +397,11 @@ GetDriveTypeW(LPCWSTR lpRootPathName)
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
NTSTATUS errCode;
|
NTSTATUS errCode;
|
||||||
|
|
||||||
hFile = CreateFileW (lpRootPathName,
|
hFile = InternalOpenDirW(lpRootPathName, FALSE);
|
||||||
GENERIC_ALL,
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
{
|
||||||
NULL,
|
return 0;
|
||||||
OPEN_EXISTING,
|
}
|
||||||
FILE_ATTRIBUTE_NORMAL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
errCode = NtQueryVolumeInformationFile (hFile,
|
errCode = NtQueryVolumeInformationFile (hFile,
|
||||||
&IoStatusBlock,
|
&IoStatusBlock,
|
||||||
|
@ -506,7 +543,6 @@ GetVolumeInformationW(
|
||||||
PFILE_FS_ATTRIBUTE_INFORMATION FileFsAttribute;
|
PFILE_FS_ATTRIBUTE_INFORMATION FileFsAttribute;
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
UNICODE_STRING NtPathU;
|
|
||||||
USHORT Buffer[FS_VOLUME_BUFFER_SIZE];
|
USHORT Buffer[FS_VOLUME_BUFFER_SIZE];
|
||||||
USHORT Buffer2[FS_ATTRIBUTE_BUFFER_SIZE];
|
USHORT Buffer2[FS_ATTRIBUTE_BUFFER_SIZE];
|
||||||
|
|
||||||
|
@ -519,39 +555,9 @@ GetVolumeInformationW(
|
||||||
DPRINT("FileFsVolume %p\n", FileFsVolume);
|
DPRINT("FileFsVolume %p\n", FileFsVolume);
|
||||||
DPRINT("FileFsAttribute %p\n", FileFsAttribute);
|
DPRINT("FileFsAttribute %p\n", FileFsAttribute);
|
||||||
|
|
||||||
if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpRootPathName,
|
hFile = InternalOpenDirW(lpRootPathName, FALSE);
|
||||||
&NtPathU,
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
NULL,
|
|
||||||
NULL))
|
|
||||||
{
|
{
|
||||||
DPRINT("Invalid path\n");
|
|
||||||
SetLastError(ERROR_BAD_PATHNAME);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&NtPathU,
|
|
||||||
FILE_READ_ATTRIBUTES,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
errCode = NtCreateFile (&hFile,
|
|
||||||
FILE_GENERIC_READ,
|
|
||||||
&ObjectAttributes,
|
|
||||||
&IoStatusBlock,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
|
||||||
FILE_OPEN,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
0);
|
|
||||||
|
|
||||||
RtlFreeUnicodeString(&NtPathU);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(errCode))
|
|
||||||
{
|
|
||||||
SetLastErrorByStatus (errCode);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,14 +678,10 @@ SetVolumeLabelW(LPCWSTR lpRootPathName,
|
||||||
wcscpy(LabelInfo->VolumeLabel,
|
wcscpy(LabelInfo->VolumeLabel,
|
||||||
lpVolumeName);
|
lpVolumeName);
|
||||||
|
|
||||||
hFile = CreateFileW(lpRootPathName,
|
if (INVALID_HANDLE_VALUE == (hFile = InternalOpenDirW(lpRootPathName, TRUE)))
|
||||||
FILE_WRITE_ATTRIBUTES,
|
{
|
||||||
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
return FALSE;
|
||||||
NULL,
|
}
|
||||||
OPEN_EXISTING,
|
|
||||||
FILE_ATTRIBUTE_NORMAL,
|
|
||||||
NULL);
|
|
||||||
DPRINT("hFile: %x\n", hFile);
|
|
||||||
|
|
||||||
Status = NtSetVolumeInformationFile(hFile,
|
Status = NtSetVolumeInformationFile(hFile,
|
||||||
&IoStatusBlock,
|
&IoStatusBlock,
|
||||||
|
|
Loading…
Reference in a new issue