[ros-diffs] [reactos] 02/02: [INCLUDE]: ntddrdsk.h: Fix "__cplusplus" and the ramdisk GUID definitions.
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3cd76b91b5790a1aae1a40d90a6b952334aee56f commit 3cd76b91b5790a1aae1a40d90a6b952334aee56f Author: Hermès Bélusca-Maïto AuthorDate: Fri Oct 6 01:07:54 2017 +0200 [INCLUDE]: ntddrdsk.h: Fix "__cplusplus" and the ramdisk GUID definitions. --- sdk/include/reactos/drivers/ntddrdsk.h | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk/include/reactos/drivers/ntddrdsk.h b/sdk/include/reactos/drivers/ntddrdsk.h index 8ae3731d31..c0623db73e 100644 --- a/sdk/include/reactos/drivers/ntddrdsk.h +++ b/sdk/include/reactos/drivers/ntddrdsk.h @@ -12,19 +12,21 @@ #pragma once #endif -#ifdef __cplusplus1 +#ifdef __cplusplus extern "C" { #endif // -// This guid identifies a RAM disk volume +// This guid identifies a RAM disk volume (RamdiskBootDiskGuid) +// {D9B257FC-684E-4DCB-AB79-03CFA2F6B750} // -DEFINE_GUID(RAMDISK_BOOTDISK_GUID, 0xd9b257fc, 0x684e, 0x4dcb, 0x79, 0xab, 0xf6, 0xa2, 0xcf, 0x03, 0x50, 0xb7); +DEFINE_GUID(RAMDISK_BOOTDISK_GUID, 0xD9B257FC, 0x684E, 0x4DCB, 0xAB, 0x79, 0x03, 0xCF, 0xA2, 0xF6, 0xB7, 0x50); // // This guid identifies a RAM disk bus +// {9D6D66A6-0B0C-4563-9077-A0E9A7955AE4} // -DEFINE_GUID(GUID_BUS_TYPE_RAMDISK, 0x9d6d66a6, 0x0b0c, 0x4563, 0x90, 0x77, 0xa0, 0xe9, 0xa7, 0x95, 0x5a, 0xe4); +DEFINE_GUID(GUID_BUS_TYPE_RAMDISK, 0x9D6D66A6, 0x0B0C, 0x4563, 0x90, 0x77, 0xA0, 0xE9, 0xA7, 0x95, 0x5A, 0xE4); // // Device Name - this string is the name of the device. It is the name -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[ros-diffs] [reactos] 01/02: [INCLUDE]: ntddrdsk.h: align defs on multiple of 4-space tab.
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fce8e1b595e56301e7eec375d40ac9f4fcd42809 commit fce8e1b595e56301e7eec375d40ac9f4fcd42809 Author: Hermès Bélusca-Maïto AuthorDate: Fri Oct 6 01:06:32 2017 +0200 [INCLUDE]: ntddrdsk.h: align defs on multiple of 4-space tab. --- sdk/include/reactos/drivers/ntddrdsk.h | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sdk/include/reactos/drivers/ntddrdsk.h b/sdk/include/reactos/drivers/ntddrdsk.h index b84358c447..8ae3731d31 100644 --- a/sdk/include/reactos/drivers/ntddrdsk.h +++ b/sdk/include/reactos/drivers/ntddrdsk.h @@ -33,21 +33,22 @@ DEFINE_GUID(GUID_BUS_TYPE_RAMDISK, 0x9d6d66a6, 0x0b0c, 0x4563, 0x90, 0x77, 0xa0, // Note: For devices that support multiple units, it should be suffixed //with the Ascii representation of the unit number. // -#define DD_RAMDISK_DEVICE_NAME"\\Device\\Ramdisk" +#define DD_RAMDISK_DEVICE_NAME "\\Device\\Ramdisk" +#define DD_RAMDISK_DEVICE_NAME_U L"\\Device\\Ramdisk" // // IoControlCode values for ramdisk devices. // -#define IOCTL_RAMDISK_BASEFILE_DEVICE_VIRTUAL_DISK -#define FSCTL_CREATE_RAM_DISK CTL_CODE(FILE_DEVICE_VIRTUAL_DISK, 0x, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_RAMDISK_BASE FILE_DEVICE_VIRTUAL_DISK +#define FSCTL_CREATE_RAM_DISK CTL_CODE(FILE_DEVICE_VIRTUAL_DISK, 0x, METHOD_BUFFERED, FILE_ANY_ACCESS) // // Disk Types // -#define RAMDISK_REGISTRY_DISK 1 // Loaded from the registry -#define RAMDISK_MEMORY_MAPPED_DISK2 // Loaded from the registry -#define RAMDISK_BOOT_DISK 3 // Used as a boot device -#define RAMDISK_WIM_DISK 4 // Used as an installation device +#define RAMDISK_REGISTRY_DISK 1 // Loaded from the registry +#define RAMDISK_MEMORY_MAPPED_DISK 2 // Loaded from a file and mapped in memory +#define RAMDISK_BOOT_DISK 3 // Used as a boot device "ramdisk(0)" +#define RAMDISK_WIM_DISK4 // Used as an installation device // // Options when creating a ramdisk -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[ros-diffs] [reactos] 01/01: [NTUSER] Fix rogue CR in a LF-only file.
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=aff6757284d64fb4d148c0cd0f7c1e325d746735 commit aff6757284d64fb4d148c0cd0f7c1e325d746735 Author: gigaherz AuthorDate: Fri Oct 6 00:04:29 2017 +0200 [NTUSER] Fix rogue CR in a LF-only file. --- win32ss/user/ntuser/desktop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32ss/user/ntuser/desktop.c b/win32ss/user/ntuser/desktop.c index 4d7f76bbdb..7129f58d60 100644 --- a/win32ss/user/ntuser/desktop.c +++ b/win32ss/user/ntuser/desktop.c @@ -932,7 +932,7 @@ UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd) PWND DesktopObject = 0; HDC DesktopHDC = 0; -/* This can be called from GDI/DX, so acquire the USER lock */ +/* This can be called from GDI/DX, so acquire the USER lock */ UserEnterExclusive(); if (DcType == DC_TYPE_DIRECT) -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[ros-diffs] [reactos] 01/01: [KERNEL32]: w2k3ify GetDriveTypeA()
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d7ee95b28ba5232027378e8918317118b1eac9f4 commit d7ee95b28ba5232027378e8918317118b1eac9f4 Author: Pierre Schweitzer AuthorDate: Thu Oct 5 23:43:10 2017 +0200 [KERNEL32]: w2k3ify GetDriveTypeA() --- dll/win32/kernel32/client/file/disk.c | 23 +-- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/dll/win32/kernel32/client/file/disk.c b/dll/win32/kernel32/client/file/disk.c index e7843067fc..041f4b197b 100644 --- a/dll/win32/kernel32/client/file/disk.c +++ b/dll/win32/kernel32/client/file/disk.c @@ -463,15 +463,26 @@ UINT WINAPI GetDriveTypeA(IN LPCSTR lpRootPathName) { -PWCHAR RootPathNameW; +PWSTR RootPathU; -if (!lpRootPathName) -return GetDriveTypeW(NULL); +if (lpRootPathName != NULL) +{ +PUNICODE_STRING RootPathUStr; -if (!(RootPathNameW = FilenameA2W(lpRootPathName, FALSE))) -return DRIVE_UNKNOWN; +RootPathUStr = Basep8BitStringToStaticUnicodeString(lpRootPathName); +if (RootPathUStr == NULL) +{ +return DRIVE_NO_ROOT_DIR; +} + +RootPathU = RootPathUStr->Buffer; +} +else +{ +RootPathU = NULL; +} -return GetDriveTypeW(RootPathNameW); +return GetDriveTypeW(RootPathU); } /* -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[ros-diffs] [reactos] 01/01: [KERNEL32]: Reimplement GetDriveTypeW(). This allows providing a quick path for DOS drives and fixes a few detection cases. It allows brings in support for mount points.
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cb17d5dba4a5e1cee30f47776821f52890b9b4e0 commit cb17d5dba4a5e1cee30f47776821f52890b9b4e0 Author: Pierre Schweitzer AuthorDate: Thu Oct 5 23:41:26 2017 +0200 [KERNEL32]: Reimplement GetDriveTypeW(). This allows providing a quick path for DOS drives and fixes a few detection cases. It allows brings in support for mount points. --- dll/win32/kernel32/client/file/disk.c | 244 +- dll/win32/kernel32/client/file/mntpoint.c | 2 +- dll/win32/kernel32/client/file/volume.c | 2 +- dll/win32/kernel32/include/kernel32.h | 14 ++ 4 files changed, 188 insertions(+), 74 deletions(-) diff --git a/dll/win32/kernel32/client/file/disk.c b/dll/win32/kernel32/client/file/disk.c index 74ca5713f0..e7843067fc 100644 --- a/dll/win32/kernel32/client/file/disk.c +++ b/dll/win32/kernel32/client/file/disk.c @@ -23,7 +23,6 @@ #define NDEBUG #include -DEBUG_CHANNEL(kernel32file); #define MAX_DOS_DRIVES 26 @@ -482,127 +481,228 @@ UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName) { -FILE_FS_DEVICE_INFORMATION FileFsDevice; -OBJECT_ATTRIBUTES ObjectAttributes; -IO_STATUS_BLOCK IoStatusBlock; -UNICODE_STRING PathName; -HANDLE FileHandle; +BOOL RetryOpen; +PCWSTR RootPath; NTSTATUS Status; -PWSTR CurrentDir = NULL; -PCWSTR lpRootPath; +WCHAR DriveLetter; +HANDLE RootHandle; +IO_STATUS_BLOCK IoStatusBlock; +OBJECT_ATTRIBUTES ObjectAttributes; +UNICODE_STRING PathName, VolumeString; +FILE_FS_DEVICE_INFORMATION FileFsDevice; +WCHAR Buffer[MAX_PATH], VolumeName[MAX_PATH]; -if (!lpRootPathName) +/* If no path, get one */ +if (lpRootPathName == NULL) { -/* If NULL is passed, use current directory path */ -DWORD BufferSize = GetCurrentDirectoryW(0, NULL); -CurrentDir = HeapAlloc(GetProcessHeap(), 0, BufferSize * sizeof(WCHAR)); -if (!CurrentDir) -return DRIVE_UNKNOWN; -if (!GetCurrentDirectoryW(BufferSize, CurrentDir)) +RootPath = Buffer; +/* This will be current drive (:\ - drop the rest)*/ +if (RtlGetCurrentDirectory_U(sizeof(Buffer), Buffer) > 3 * sizeof(WCHAR)) { -HeapFree(GetProcessHeap(), 0, CurrentDir); -return DRIVE_UNKNOWN; +Buffer[3] = UNICODE_NULL; } - -if (wcslen(CurrentDir) > 3) -CurrentDir[3] = 0; - -lpRootPath = CurrentDir; } else { -size_t Length = wcslen(lpRootPathName); - -TRACE("lpRootPathName: %S\n", lpRootPathName); - -lpRootPath = lpRootPathName; -if (Length == 2) +/* Handle broken value */ +if (lpRootPathName == (PVOID)-1) { -WCHAR DriveLetter = RtlUpcaseUnicodeChar(lpRootPathName[0]); +return DRIVE_UNKNOWN; +} +RootPath = lpRootPathName; +/* If provided path is 2-len, it might be a drive letter... */ +if (wcslen(lpRootPathName) == 2) +{ +/* Check it! */ +DriveLetter = RtlUpcaseUnicodeChar(lpRootPathName[0]); +/* That's a drive letter! */ if (DriveLetter >= L'A' && DriveLetter <= L'Z' && lpRootPathName[1] == L':') { -Length = (Length + 2) * sizeof(WCHAR); - -CurrentDir = HeapAlloc(GetProcessHeap(), 0, Length); -if (!CurrentDir) -return DRIVE_UNKNOWN; +/* Make it a volume */ +Buffer[0] = DriveLetter; +Buffer[1] = L':'; +Buffer[2] = L'\\'; +Buffer[3] = UNICODE_NULL; +RootPath = Buffer; +} +} +} -StringCbPrintfW(CurrentDir, Length, L"%s\\", lpRootPathName); +/* If the provided looks like a DOS device... Like :\<0> */ +DriveLetter = RtlUpcaseUnicodeChar(RootPath[0]); +/* We'll take the quick path! + * We'll find the device type looking at the device map (and types ;-)) + * associated with the current process + */ +if (DriveLetter >= L'A' && DriveLetter <= L'Z' && RootPath[1] == L':' && +RootPath[2] == L'\\' && RootPath[3] == UNICODE_NULL) +{ +USHORT Index; +PROCESS_DEVICEMAP_INFORMATION DeviceMap; + +/* Query the device map */ +Status = NtQueryInformationProcess(NtCurrentProcess(), ProcessDeviceMap, + &DeviceMap, + sizeof(PROCESS_DEVICEMAP_INFORMATION), + NULL); +/* Zero output if we failed */ +if (!NT_SUCCESS(Status)) +{ +RtlZeroMemory(&DeviceMap, sizeof(PROCESS_DEVICEMAP_INFO
[ros-diffs] [reactos] 05/05: [KERNEL32]: Finally get rid of no longer used function InternalOpenDirW()
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=676bd0cf37d1fd9c2ef2879b061358b512cf00a1 commit 676bd0cf37d1fd9c2ef2879b061358b512cf00a1 Author: Pierre Schweitzer AuthorDate: Wed Oct 4 23:03:07 2017 +0200 [KERNEL32]: Finally get rid of no longer used function InternalOpenDirW() --- dll/win32/kernel32/client/file/disk.c | 47 --- 1 file changed, 47 deletions(-) diff --git a/dll/win32/kernel32/client/file/disk.c b/dll/win32/kernel32/client/file/disk.c index 1b7d1e3a9d..74ca5713f0 100644 --- a/dll/win32/kernel32/client/file/disk.c +++ b/dll/win32/kernel32/client/file/disk.c @@ -27,53 +27,6 @@ DEBUG_CHANNEL(kernel32file); #define MAX_DOS_DRIVES 26 -HANDLE -WINAPI -InternalOpenDirW(IN LPCWSTR DirName, - IN BOOLEAN Write) -{ -UNICODE_STRING NtPathU; -OBJECT_ATTRIBUTES ObjectAttributes; -NTSTATUS errCode; -IO_STATUS_BLOCK IoStatusBlock; -HANDLE hFile; - -if (!RtlDosPathNameToNtPathName_U(DirName, &NtPathU, NULL, NULL)) -{ -WARN("Invalid path\n"); -SetLastError(ERROR_BAD_PATHNAME); -return INVALID_HANDLE_VALUE; -} - -InitializeObjectAttributes(&ObjectAttributes, - &NtPathU, - OBJ_CASE_INSENSITIVE, - 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); - -RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathU.Buffer); - -if (!NT_SUCCESS(errCode)) -{ -BaseSetLastNTError(errCode); -return INVALID_HANDLE_VALUE; -} - -return hFile; -} - /* * @implemented */ -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[ros-diffs] [reactos] 04/05: [KERNEL32]: Reimplement GetDiskFreeSpaceExA() to make it w2k3 compliant
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8b6518139db31655a395a1547dd475f06f79b934 commit 8b6518139db31655a395a1547dd475f06f79b934 Author: Pierre Schweitzer AuthorDate: Wed Oct 4 23:02:22 2017 +0200 [KERNEL32]: Reimplement GetDiskFreeSpaceExA() to make it w2k3 compliant --- dll/win32/kernel32/client/file/disk.c | 21 + 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/dll/win32/kernel32/client/file/disk.c b/dll/win32/kernel32/client/file/disk.c index 1ba1b73549..1b7d1e3a9d 100644 --- a/dll/win32/kernel32/client/file/disk.c +++ b/dll/win32/kernel32/client/file/disk.c @@ -359,18 +359,23 @@ GetDiskFreeSpaceExA(IN LPCSTR lpDirectoryName OPTIONAL, OUT PULARGE_INTEGER lpTotalNumberOfBytes, OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes) { -PWCHAR DirectoryNameW=NULL; +PCSTR RootPath; +PUNICODE_STRING RootPathU; -if (lpDirectoryName) +RootPath = lpDirectoryName; +if (RootPath == NULL) { -if (!(DirectoryNameW = FilenameA2W(lpDirectoryName, FALSE))) -return FALSE; +RootPath = "\\"; +} + +RootPathU = Basep8BitStringToStaticUnicodeString(RootPath); +if (RootPathU == NULL) +{ +return FALSE; } -return GetDiskFreeSpaceExW (DirectoryNameW , -lpFreeBytesAvailableToCaller, -lpTotalNumberOfBytes, -lpTotalNumberOfFreeBytes); +return GetDiskFreeSpaceExW(RootPathU->Buffer, lpFreeBytesAvailableToCaller, + lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes); } /* -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[ros-diffs] [reactos] 03/05: [KERNEL32]: Refactor a bit GetDiskFreeSpaceExW(), no ground breaking changes
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1e2424ee98bd12d6a5a7ebffdfa138546a5c7a5b commit 1e2424ee98bd12d6a5a7ebffdfa138546a5c7a5b Author: Pierre Schweitzer AuthorDate: Wed Oct 4 23:00:12 2017 +0200 [KERNEL32]: Refactor a bit GetDiskFreeSpaceExW(), no ground breaking changes --- dll/win32/kernel32/client/file/disk.c | 124 +++--- 1 file changed, 69 insertions(+), 55 deletions(-) diff --git a/dll/win32/kernel32/client/file/disk.c b/dll/win32/kernel32/client/file/disk.c index 5854b2320e..1ba1b73549 100644 --- a/dll/win32/kernel32/client/file/disk.c +++ b/dll/win32/kernel32/client/file/disk.c @@ -383,103 +383,117 @@ GetDiskFreeSpaceExW(IN LPCWSTR lpDirectoryName OPTIONAL, OUT PULARGE_INTEGER lpTotalNumberOfBytes, OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes) { -union -{ -FILE_FS_SIZE_INFORMATION FsSize; -FILE_FS_FULL_SIZE_INFORMATION FsFullSize; -} FsInfo; -IO_STATUS_BLOCK IoStatusBlock; -ULARGE_INTEGER BytesPerCluster; -HANDLE hFile; +PCWSTR RootPath; NTSTATUS Status; +HANDLE RootHandle; +UNICODE_STRING FileName; +DWORD BytesPerAllocationUnit; +IO_STATUS_BLOCK IoStatusBlock; +OBJECT_ATTRIBUTES ObjectAttributes; +FILE_FS_SIZE_INFORMATION FileFsSize; +/* If no path provided, get root path */ +RootPath = lpDirectoryName; if (lpDirectoryName == NULL) -lpDirectoryName = L"\\"; +{ +RootPath = L"\\"; +} -hFile = InternalOpenDirW(lpDirectoryName, FALSE); -if (INVALID_HANDLE_VALUE == hFile) +/* Convert the path to NT path */ +if (!RtlDosPathNameToNtPathName_U(RootPath, &FileName, NULL, NULL)) { +SetLastError(ERROR_PATH_NOT_FOUND); return FALSE; } -if (lpFreeBytesAvailableToCaller != NULL || lpTotalNumberOfBytes != NULL) +/* Open it for disk space query! */ +InitializeObjectAttributes(&ObjectAttributes, &FileName, + OBJ_CASE_INSENSITIVE, NULL, NULL); +Status = NtOpenFile(&RootHandle, SYNCHRONIZE, &ObjectAttributes, &IoStatusBlock, +FILE_SHARE_READ | FILE_SHARE_WRITE, +FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_OPEN_FOR_FREE_SPACE_QUERY); +if (!NT_SUCCESS(Status)) { -/* To get the free space available to the user associated with the - current thread, try FileFsFullSizeInformation. If this is not - supported by the file system, fall back to FileFsSize */ +BaseSetLastNTError(Status); +/* If error conversion lead to file not found, override to use path not found + * which is more accurate + */ +if (GetLastError() == ERROR_FILE_NOT_FOUND) +{ +SetLastError(ERROR_PATH_NOT_FOUND); +} -Status = NtQueryVolumeInformationFile(hFile, - &IoStatusBlock, - &FsInfo.FsFullSize, - sizeof(FsInfo.FsFullSize), - FileFsFullSizeInformation); +RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer); + +return FALSE; +} + +RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer); +/* If user asks for lpTotalNumberOfFreeBytes, try to use full size information */ +if (lpTotalNumberOfFreeBytes != NULL) +{ +FILE_FS_FULL_SIZE_INFORMATION FileFsFullSize; + +/* Issue the full fs size request */ +Status = NtQueryVolumeInformationFile(RootHandle, &IoStatusBlock, &FileFsFullSize, + sizeof(FILE_FS_FULL_SIZE_INFORMATION), + FileFsFullSizeInformation); +/* If it succeed, complete out buffers */ if (NT_SUCCESS(Status)) { -/* Close the handle before returning data - to avoid a handle leak in case of a fault! */ -CloseHandle(hFile); +/* We can close here, we'll return */ +NtClose(RootHandle); -BytesPerCluster.QuadPart = -FsInfo.FsFullSize.BytesPerSector * FsInfo.FsFullSize.SectorsPerAllocationUnit; +/* Compute the size of an AU */ +BytesPerAllocationUnit = FileFsFullSize.SectorsPerAllocationUnit * FileFsFullSize.BytesPerSector; +/* And then return what was asked */ if (lpFreeBytesAvailableToCaller != NULL) { -lpFreeBytesAvailableToCaller->QuadPart = -BytesPerCluster.QuadPart * FsInfo.FsFullSize.CallerAvailableAllocationUnits.QuadPart; +lpFreeBytesAvailableToCaller->QuadPart = Fil
[ros-diffs] [reactos] 02/05: [KERNEL32]: Reimplement GetDiskFreeSpaceA() to make it w2k3 compliant
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=87448f3d8b26a6696f143872874200ef5799565d commit 87448f3d8b26a6696f143872874200ef5799565d Author: Pierre Schweitzer AuthorDate: Wed Oct 4 22:30:18 2017 +0200 [KERNEL32]: Reimplement GetDiskFreeSpaceA() to make it w2k3 compliant --- dll/win32/kernel32/client/file/disk.c | 23 ++- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/dll/win32/kernel32/client/file/disk.c b/dll/win32/kernel32/client/file/disk.c index 7ff6e88f1a..5854b2320e 100644 --- a/dll/win32/kernel32/client/file/disk.c +++ b/dll/win32/kernel32/client/file/disk.c @@ -189,19 +189,24 @@ GetDiskFreeSpaceA(IN LPCSTR lpRootPathName, OUT LPDWORD lpNumberOfFreeClusters, OUT LPDWORD lpTotalNumberOfClusters) { -PWCHAR RootPathNameW=NULL; +PCSTR RootPath; +PUNICODE_STRING RootPathU; -if (lpRootPathName) +RootPath = lpRootPathName; +if (RootPath == NULL) { -if (!(RootPathNameW = FilenameA2W(lpRootPathName, FALSE))) -return FALSE; +RootPath = "\\"; +} + +RootPathU = Basep8BitStringToStaticUnicodeString(RootPath); +if (RootPathU == NULL) +{ +return FALSE; } -return GetDiskFreeSpaceW (RootPathNameW, - lpSectorsPerCluster, - lpBytesPerSector, - lpNumberOfFreeClusters, - lpTotalNumberOfClusters); +return GetDiskFreeSpaceW(RootPathU->Buffer, lpSectorsPerCluster, + lpBytesPerSector, lpNumberOfFreeClusters, + lpTotalNumberOfClusters); } /* -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[ros-diffs] [reactos] 01/05: [KERNEL32]: Reimplement GetDiskFreeSpaceW() to fix various issues in it. It also brings support for appcompat
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5bee374c82209d347088a42901e77d4d1a11b839 commit 5bee374c82209d347088a42901e77d4d1a11b839 Author: Pierre Schweitzer AuthorDate: Wed Oct 4 22:27:14 2017 +0200 [KERNEL32]: Reimplement GetDiskFreeSpaceW() to fix various issues in it. It also brings support for appcompat --- dll/win32/kernel32/client/file/disk.c | 135 +++--- 1 file changed, 108 insertions(+), 27 deletions(-) diff --git a/dll/win32/kernel32/client/file/disk.c b/dll/win32/kernel32/client/file/disk.c index fd97a0e3a8..7ff6e88f1a 100644 --- a/dll/win32/kernel32/client/file/disk.c +++ b/dll/win32/kernel32/client/file/disk.c @@ -215,50 +215,131 @@ GetDiskFreeSpaceW(IN LPCWSTR lpRootPathName, OUT LPDWORD lpNumberOfFreeClusters, OUT LPDWORD lpTotalNumberOfClusters) { -FILE_FS_SIZE_INFORMATION FileFsSize; +BOOL Below2GB; +PCWSTR RootPath; +NTSTATUS Status; +HANDLE RootHandle; +UNICODE_STRING FileName; IO_STATUS_BLOCK IoStatusBlock; -WCHAR RootPathName[MAX_PATH]; -HANDLE hFile; -NTSTATUS errCode; +OBJECT_ATTRIBUTES ObjectAttributes; +FILE_FS_SIZE_INFORMATION FileFsSize; -if (lpRootPathName) +/* If no path provided, get root path */ +RootPath = lpRootPathName; +if (lpRootPathName == NULL) { -wcsncpy (RootPathName, lpRootPathName, 3); +RootPath = L"\\"; } -else + +/* Convert the path to NT path */ +if (!RtlDosPathNameToNtPathName_U(RootPath, &FileName, NULL, NULL)) { -GetCurrentDirectoryW (MAX_PATH, RootPathName); +SetLastError(ERROR_PATH_NOT_FOUND); +return FALSE; } -RootPathName[3] = 0; -hFile = InternalOpenDirW(RootPathName, FALSE); -if (INVALID_HANDLE_VALUE == hFile) +/* Open it for disk space query! */ +InitializeObjectAttributes(&ObjectAttributes, &FileName, + OBJ_CASE_INSENSITIVE, NULL, NULL); +Status = NtOpenFile(&RootHandle, SYNCHRONIZE, &ObjectAttributes, &IoStatusBlock, +FILE_SHARE_READ | FILE_SHARE_WRITE, +FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_OPEN_FOR_FREE_SPACE_QUERY); +if (!NT_SUCCESS(Status)) { -SetLastError(ERROR_PATH_NOT_FOUND); +BaseSetLastNTError(Status); +RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer); +if (lpBytesPerSector != NULL) +{ +*lpBytesPerSector = 0; +} + return FALSE; } -errCode = NtQueryVolumeInformationFile(hFile, - &IoStatusBlock, - &FileFsSize, - sizeof(FILE_FS_SIZE_INFORMATION), - FileFsSizeInformation); -if (!NT_SUCCESS(errCode)) +/* We don't need the name any longer */ +RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer); + +/* Query disk space! */ +Status = NtQueryVolumeInformationFile(RootHandle, &IoStatusBlock, &FileFsSize, + sizeof(FILE_FS_SIZE_INFORMATION), + FileFsSizeInformation); +NtClose(RootHandle); +if (!NT_SUCCESS(Status)) { -CloseHandle(hFile); -BaseSetLastNTError (errCode); +BaseSetLastNTError(Status); return FALSE; } -if (lpSectorsPerCluster) +/* Are we in some compatibility mode where size must be below 2GB? */ +Below2GB = ((NtCurrentPeb()->AppCompatFlags.LowPart & GetDiskFreeSpace2GB) == GetDiskFreeSpace2GB); + +/* If we're to overflow output, make sure we return the maximum */ +if (FileFsSize.TotalAllocationUnits.HighPart != 0) +{ +FileFsSize.TotalAllocationUnits.LowPart = -1; +} + +if (FileFsSize.AvailableAllocationUnits.HighPart != 0) +{ +FileFsSize.AvailableAllocationUnits.LowPart = -1; +} + +/* Return what user asked for */ +if (lpSectorsPerCluster != NULL) +{ *lpSectorsPerCluster = FileFsSize.SectorsPerAllocationUnit; -if (lpBytesPerSector) +} + +if (lpBytesPerSector != NULL) +{ *lpBytesPerSector = FileFsSize.BytesPerSector; -if (lpNumberOfFreeClusters) -*lpNumberOfFreeClusters = FileFsSize.AvailableAllocationUnits.u.LowPart; -if (lpTotalNumberOfClusters) -*lpTotalNumberOfClusters = FileFsSize.TotalAllocationUnits.u.LowPart; -CloseHandle(hFile); +} + +if (lpNumberOfFreeClusters != NULL) +{ +if (!Below2GB) +{ +*lpNumberOfFreeClusters = FileFsSize.AvailableAllocationUnits.LowPart; +} +/* If we have to remain below 2GB... */ +else +{ +
[ros-diffs] [reactos] 03/03: [FREELDR] Properly check for end-of-memory-map entries when skipping ranges smaller than page size. CORE-12881
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=55ae20931f5a4b356055b139fab898fd3e361caf commit 55ae20931f5a4b356055b139fab898fd3e361caf Author: Serge Gautherie AuthorDate: Wed Oct 4 18:04:35 2017 +0200 [FREELDR] Properly check for end-of-memory-map entries when skipping ranges smaller than page size. CORE-12881 Signed-off-by: Timo Kreuzer --- boot/freeldr/freeldr/arch/i386/pcmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/freeldr/freeldr/arch/i386/pcmem.c b/boot/freeldr/freeldr/arch/i386/pcmem.c index 169070ee6f..61cd694070 100644 --- a/boot/freeldr/freeldr/arch/i386/pcmem.c +++ b/boot/freeldr/freeldr/arch/i386/pcmem.c @@ -318,7 +318,7 @@ PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSi PcBiosMapCount, PcBiosMemoryMap[PcBiosMapCount].BaseAddress, PcBiosMemoryMap[PcBiosMapCount].Length); -continue; +goto nextRange; } /* Calculate the length of the aligned range */ -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[ros-diffs] [reactos] 02/03: [FREELDR] Add 64 bit alignment macros (ULONGLONG_ALIGN_UP/DOWN_BY) for aligning physical addresses that can be larger than 4GB and the default macros truncate to ULONG_PTR
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=274ace05b2f5d5cded56345e95bc26ecaf013d32 commit 274ace05b2f5d5cded56345e95bc26ecaf013d32 Author: Serge Gautherie AuthorDate: Tue Oct 3 09:16:26 2017 +0200 [FREELDR] Add 64 bit alignment macros (ULONGLONG_ALIGN_UP/DOWN_BY) for aligning physical addresses that can be larger than 4GB and the default macros truncate to ULONG_PTR. CORE-12881 Signed-off-by: Timo Kreuzer --- boot/freeldr/freeldr/arch/i386/pcmem.c | 21 +++-- 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/boot/freeldr/freeldr/arch/i386/pcmem.c b/boot/freeldr/freeldr/arch/i386/pcmem.c index bb38762bc7..169070ee6f 100644 --- a/boot/freeldr/freeldr/arch/i386/pcmem.c +++ b/boot/freeldr/freeldr/arch/i386/pcmem.c @@ -27,6 +27,12 @@ DBG_DEFAULT_CHANNEL(MEMORY); +#define ULONGLONG_ALIGN_DOWN_BY(size, align) \ +((ULONGLONG)(size) & ~((ULONGLONG)(align) - 1)) + +#define ULONGLONG_ALIGN_UP_BY(size, align) \ +(ULONGLONG_ALIGN_DOWN_BY(((ULONGLONG)(size) + align - 1), align)) + #define MAX_BIOS_DESCRIPTORS 80 BIOS_MEMORY_MAP PcBiosMemoryMap[MAX_BIOS_DESCRIPTORS]; @@ -295,13 +301,14 @@ PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSi MemoryType = LoaderFree; /* Align up base of memory range */ -RealBaseAddress = ALIGN_UP_BY(PcBiosMemoryMap[PcBiosMapCount].BaseAddress, - PAGE_SIZE); +RealBaseAddress = ULONGLONG_ALIGN_UP_BY( +PcBiosMemoryMap[PcBiosMapCount].BaseAddress, +PAGE_SIZE); /* Calculate aligned EndAddress */ EndAddress = PcBiosMemoryMap[PcBiosMapCount].BaseAddress + PcBiosMemoryMap[PcBiosMapCount].Length; -EndAddress = ALIGN_DOWN_BY(EndAddress, PAGE_SIZE); +EndAddress = ULONGLONG_ALIGN_DOWN_BY(EndAddress, PAGE_SIZE); /* Check if there is anything left */ if (EndAddress <= RealBaseAddress) @@ -325,13 +332,14 @@ PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSi MemoryType = LoaderSpecialMemory; /* Align down base of memory area */ -RealBaseAddress = ALIGN_DOWN_BY(PcBiosMemoryMap[PcBiosMapCount].BaseAddress, -PAGE_SIZE); +RealBaseAddress = ULONGLONG_ALIGN_DOWN_BY( +PcBiosMemoryMap[PcBiosMapCount].BaseAddress, +PAGE_SIZE); /* Calculate the length after aligning the base */ RealSize = PcBiosMemoryMap[PcBiosMapCount].BaseAddress + PcBiosMemoryMap[PcBiosMapCount].Length - RealBaseAddress; -RealSize = ALIGN_UP_BY(RealSize, PAGE_SIZE); +RealSize = ULONGLONG_ALIGN_UP_BY(RealSize, PAGE_SIZE); } /* Check if we can add this descriptor */ @@ -359,6 +367,7 @@ PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSi PcBiosMapCount++; +nextRange: /* If the continuation value is zero, * then this was the last entry, so we're done. */ if (Regs.x.ebx == 0x) -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[ros-diffs] [reactos] 01/03: [FREELDR] Improve trace prints in pcmem.c, no logical changes CORE-12881
This is an automated email from the git hooks/post-receive script. www-data pushed a commit to branch master in repository reactos. View the commit online: https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f588de2e79e67fc7878e71dccb4ea67debdacf5e commit f588de2e79e67fc7878e71dccb4ea67debdacf5e Author: Serge Gautherie AuthorDate: Tue Oct 3 09:00:03 2017 +0200 [FREELDR] Improve trace prints in pcmem.c, no logical changes CORE-12881 Signed-off-by: Timo Kreuzer --- boot/freeldr/freeldr/arch/i386/pcmem.c | 60 -- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/boot/freeldr/freeldr/arch/i386/pcmem.c b/boot/freeldr/freeldr/arch/i386/pcmem.c index 3f15155fdb..bb38762bc7 100644 --- a/boot/freeldr/freeldr/arch/i386/pcmem.c +++ b/boot/freeldr/freeldr/arch/i386/pcmem.c @@ -129,7 +129,7 @@ GetExtendedMemoryConfiguration(ULONG* pMemoryAtOneMB /* in KB */, ULONG* pMemory *pMemoryAtOneMB = (*pMemoryAtOneMB << 8); TRACE("Int15h Failed\n"); -TRACE("CMOS reports: 0x%x\n", *pMemoryAtOneMB); +TRACE("CMOS reports: 0x%lx\n", *pMemoryAtOneMB); if (*pMemoryAtOneMB != 0) { @@ -144,7 +144,7 @@ PcMemGetConventionalMemorySize(VOID) { REGS Regs; -TRACE("GetConventionalMemorySize()\n"); +TRACE("PcMemGetConventionalMemorySize()\n"); /* Int 12h * BIOS - GET MEMORY SIZE @@ -204,9 +204,10 @@ PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSi ULONGLONG RealBaseAddress, EndAddress, RealSize; TYPE_OF_MEMORY MemoryType; ULONG Size, RequiredSize; + ASSERT(PcBiosMapCount == 0); -TRACE("GetBiosMemoryMap()\n"); +TRACE("PcMemGetBiosMemoryMap()\n"); /* Make sure the usable memory is large enough. To do this we check the 16 bit value at address 0x413 inside the BDA, which gives us the usable size @@ -219,8 +220,8 @@ PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSi MEMORY_INIT_FAILURE, __FILE__, __LINE__, -"The BIOS reported a usable memory range up to 0x%x, which is too small!\n" -"Required size is 0x%x\n\n" +"The BIOS reported a usable memory range up to 0x%lx, which is too small!\n" +"Required size is 0x%lx\n\n" "If you see this, please report to the ReactOS team!", Size, RequiredSize); } @@ -256,17 +257,26 @@ PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSi Regs.w.di = BIOSCALLBUFOFFSET; Int386(0x15, &Regs, &Regs); -TRACE("Memory Map Entry %d\n", PcBiosMapCount); +TRACE("Memory Map Entry %lu\n", PcBiosMapCount); TRACE("Int15h AX=E820h\n"); -TRACE("EAX = 0x%x\n", Regs.x.eax); -TRACE("EBX = 0x%x\n", Regs.x.ebx); -TRACE("ECX = 0x%x\n", Regs.x.ecx); +TRACE("EAX = 0x%lx\n", Regs.x.eax); +TRACE("EBX = 0x%lx\n", Regs.x.ebx); +TRACE("ECX = 0x%lx\n", Regs.x.ecx); TRACE("CF set = %s\n", (Regs.x.eflags & EFLAGS_CF) ? "TRUE" : "FALSE"); /* If the BIOS didn't return 'SMAP' in EAX then - * it doesn't support this call. If CF is set, we're done */ -if (Regs.x.eax != 0x534D4150 || !INT386_SUCCESS(Regs)) + * it doesn't support this call. */ +if (Regs.x.eax != 0x534D4150) +{ +WARN("BIOS doesn't support Int15h AX=E820h!\n\n"); +break; +} + +/* If the carry flag is set, + * then this call was past the last entry, so we're done. */ +if (!INT386_SUCCESS(Regs)) { +TRACE("End of System Memory Map! (Past last)\n\n"); break; } @@ -297,6 +307,10 @@ PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSi if (EndAddress <= RealBaseAddress) { /* This doesn't span any page, so continue with next range */ +TRACE("Skipping aligned range < PAGE_SIZE. (PcBiosMapCount = %lu, BaseAddress = %lu, Length = %lu)\n", + PcBiosMapCount, + PcBiosMemoryMap[PcBiosMapCount].BaseAddress, + PcBiosMemoryMap[PcBiosMapCount].Length); continue; } @@ -321,7 +335,19 @@ PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSi } /* Check if we can add this descriptor */ -if ((RealSize >= MM_PAGE_SIZE) && (PcMapCount < MaxMemoryMapSize)) +if (RealSize < MM_PAGE_SIZE) +{ +TRACE("Skipping aligned range < MM_PAGE_SIZE. (PcBiosMapCount = %lu, BaseAddress = %lu, Length = %lu)\n", + PcBiosMapCount, + PcBiosMemoryMap[PcBiosMapCount].BaseAddress, + PcBiosMemoryMap[PcBiosMapCount].Length); +} +else if (PcMapCount >= MaxMemoryMapSize) +{ +