On 2017-05-22 01:45, hbelusca(a)svn.reactos.org wrote:
+BOOLEAN
+NtPathToDiskPartComponents(
+ IN PCWSTR NtPath,
+ OUT PULONG pDiskNumber,
+ OUT PULONG pPartNumber,
+ OUT PCWSTR* PathComponent OPTIONAL)
+{
+ ULONG DiskNumber, PartNumber;
+ PCWSTR Path;
+
+ *pDiskNumber = 0;
+ *pPartNumber = 0;
+ if (PathComponent) *PathComponent = NULL;
+
+ Path = NtPath;
+
+ if (_wcsnicmp(Path, L"\\Device\\Harddisk", 16) != 0)
+ {
+ /* The NT path doesn't start with the prefix string, thus it cannot be a
hard disk device path */
+ DPRINT1("'%S' : Not a possible hard disk device.\n", NtPath);
+ return FALSE;
+ }
+
+ Path += 16;
Avoiding these magic numbers would be nice.
Options include:
* static string à la
static const WCHAR DeviceHarddiskPath[] = L"\\Device\\Harddisk";
_wcsnicmp(Path, DeviceHarddiskPath, ARRAYSIZE(DeviceHarddiskPath) - 1)
* simply using wcslen(L"\\Device\\Harddisk") (which should get optimized)
* making a "starts with" function
* using RtlPrefixUnicodeString
@@ -593,6 +705,31 @@
{
DPRINT1("Failed to open file %wZ, Status 0x%08lx\n", &Name,
Status);
return Status;
+ }
+
+ if (FileSize)
+ {
+ /* Query the file size */
+ FILE_STANDARD_INFORMATION FileInfo;
+ Status = NtQueryInformationFile(*FileHandle,
+ &IoStatusBlock,
+ &FileInfo,
+ sizeof(FileInfo),
+ FileStandardInformation);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("NtQueryInformationFile() failed (Status %lx)\n", Status);
+ NtClose(*FileHandle);
+ *FileHandle = NULL;
+ return Status;
+ }
+
+ if (FileInfo.EndOfFile.HighPart != 0)
+ DPRINT1("WARNING!! The file %wZ is too large!\n", Name);
Did you mean &Name?