BOOLEAN First = TRUE;
ULONG Count;
- DirectoryInfo = ExAllocatePool(PagedPool, 2 * PAGE_SIZE);
+ DirectoryInfo = ExAllocatePoolWithTag(PagedPool, 2 * PAGE_SIZE, TAG_FILE_SYSTEM);
if (DirectoryInfo == NULL)
{
return 0;
if (!NT_SUCCESS(Status))
{
DPRINT1("ZwOpenDirectoryObject for %wZ failed, status=%lx\n", &ArcName, Status);
- ExFreePool(DirectoryInfo);
+ ExFreePoolWithTag(DirectoryInfo, TAG_FILE_SYSTEM);
return 0;
}
}
}
}
- ExFreePool(DirectoryInfo);
+ ExFreePoolWithTag(DirectoryInfo, TAG_FILE_SYSTEM);
return RDiskCount;
}
PDRIVE_LAYOUT_INFORMATION Buffer;
/* Allocate a partition list for a single entry. */
- Buffer = ExAllocatePool(NonPagedPool,
- sizeof(DRIVE_LAYOUT_INFORMATION));
+ Buffer = ExAllocatePoolWithTag(NonPagedPool,
+ sizeof(DRIVE_LAYOUT_INFORMATION), TAG_FILE_SYSTEM);
if (Buffer != NULL)
{
RtlZeroMemory(Buffer,
/* Read the partition table */
Status = IoReadPartitionTable(DeviceObject,
DiskGeometry.BytesPerSector,
- FALSE,
+ TRUE,
LayoutInfo);
}
DPRINT("RDiskCount %d\n", RDiskCount);
- Buffer1 = (PWSTR)ExAllocatePool(PagedPool,
- 64 * sizeof(WCHAR));
- Buffer2 = (PWSTR)ExAllocatePool(PagedPool,
- 32 * sizeof(WCHAR));
+ Buffer1 = ExAllocatePoolWithTag(PagedPool,
+ 64 * sizeof(WCHAR),
+ TAG_FILE_SYSTEM);
+ if (!Buffer1) return;
- PartialInformation = (PKEY_VALUE_PARTIAL_INFORMATION)ExAllocatePool(PagedPool,
- sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(REG_DISK_MOUNT_INFO));
+ Buffer2 = ExAllocatePoolWithTag(PagedPool,
+ 32 * sizeof(WCHAR),
+ TAG_FILE_SYSTEM);
+ if (!Buffer2)
+ {
+ ExFreePoolWithTag(Buffer1, TAG_FILE_SYSTEM);
+ return;
+ }
- if (!Buffer1 || !Buffer2 || !PartialInformation) return;
+ PartialInformation = ExAllocatePoolWithTag(PagedPool,
+ sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(REG_DISK_MOUNT_INFO),
+ TAG_FILE_SYSTEM);
+ if (!PartialInformation)
+ {
+ ExFreePoolWithTag(Buffer2, TAG_FILE_SYSTEM);
+ ExFreePoolWithTag(Buffer1, TAG_FILE_SYSTEM);
+ return;
+ }
DiskMountInfo = (PREG_DISK_MOUNT_INFO) PartialInformation->Data;
- /* Open or Create the 'MountedDevices' key */
+ /* Create or open the 'MountedDevices' key */
RtlInitUnicodeString(&UnicodeString1, L"\\Registry\\Machine\\SYSTEM\\MountedDevices");
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeString1,
- OBJ_CASE_INSENSITIVE,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL);
- Status = ZwOpenKey(&hKey,
+ Status = ZwCreateKey(&hKey,
KEY_ALL_ACCESS,
- &ObjectAttributes);
- if (!NT_SUCCESS(Status))
- {
- Status = ZwCreateKey(&hKey,
- KEY_ALL_ACCESS,
- &ObjectAttributes,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- NULL);
- }
+ &ObjectAttributes,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ NULL);
if (!NT_SUCCESS(Status))
{
hKey = NULL;
/* Initialize layout array */
if (ConfigInfo->DiskCount == 0)
goto end_assign_disks;
- LayoutArray = ExAllocatePool(NonPagedPool,
- ConfigInfo->DiskCount * sizeof(PDRIVE_LAYOUT_INFORMATION));
+ LayoutArray = ExAllocatePoolWithTag(NonPagedPool,
+ ConfigInfo->DiskCount * sizeof(PDRIVE_LAYOUT_INFORMATION), TAG_FILE_SYSTEM);
if (!LayoutArray)
{
- ExFreePool(PartialInformation);
- ExFreePool(Buffer2);
- ExFreePool(Buffer1);
- if (hKey) ZwClose(hKey);
+ ExFreePoolWithTag(PartialInformation, TAG_FILE_SYSTEM);
+ ExFreePoolWithTag(Buffer2, TAG_FILE_SYSTEM);
+ ExFreePoolWithTag(Buffer1, TAG_FILE_SYSTEM);
+ if (hKey) ObCloseHandle(hKey, KernelMode);
+ return;
}
RtlZeroMemory(LayoutArray,
for (i = 0; i < ConfigInfo->DiskCount; i++)
{
if (LayoutArray[i] != NULL)
- ExFreePool(LayoutArray[i]);
+ ExFreePoolWithTag(LayoutArray[i], TAG_FILE_SYSTEM);
}
- ExFreePool(LayoutArray);
+ ExFreePoolWithTag(LayoutArray, TAG_FILE_SYSTEM);
end_assign_disks:
/* Assign floppy drives */
/* Anything else to do? */
- ExFreePool(PartialInformation);
- ExFreePool(Buffer2);
- ExFreePool(Buffer1);
- if (hKey)
- {
- ZwClose(hKey);
- }
+ ExFreePoolWithTag(PartialInformation, TAG_FILE_SYSTEM);
+ ExFreePoolWithTag(Buffer2, TAG_FILE_SYSTEM);
+ ExFreePoolWithTag(Buffer1, TAG_FILE_SYSTEM);
+ if (hKey) ObCloseHandle(hKey, KernelMode);
}
#endif
Cleanup:
/* Free all the pointers */
if (Event) ExFreePoolWithTag(Event, TAG_FILE_SYSTEM);
- if (IoStatusBlock) ExFreePool(IoStatusBlock);
- if (DiskGeometry) ExFreePool(DiskGeometry);
+ if (IoStatusBlock) ExFreePoolWithTag(IoStatusBlock, TAG_FILE_SYSTEM);
+ if (DiskGeometry) ExFreePoolWithTag(DiskGeometry, TAG_FILE_SYSTEM);
return;
}
FstubFixupEfiPartition(IN PPARTITION_DESCRIPTOR PartitionDescriptor,
IN ULONGLONG MaxOffset)
{
- ULONG PartitionLength;
+ ULONG PartitionMaxOffset, PartitionLength;
PAGED_CODE();
/* Compute partition length (according to MBR entry) */
- PartitionLength = PartitionDescriptor->StartingSectorLsb0 + PartitionDescriptor->PartitionLengthLsb0;
+ PartitionMaxOffset = GET_STARTING_SECTOR(PartitionDescriptor) + GET_PARTITION_LENGTH(PartitionDescriptor);
/* In case the partition length goes beyond disk size... */
- if (PartitionLength > MaxOffset)
+ if (PartitionMaxOffset > MaxOffset)
{
/* Resize partition to its maximum real length */
- PartitionDescriptor->PartitionLengthLsb0 = MaxOffset - PartitionDescriptor->StartingSectorLsb0;
+ PartitionLength = (ULONG)(PartitionMaxOffset - GET_STARTING_SECTOR(PartitionDescriptor));
+ SET_PARTITION_LENGTH(PartitionDescriptor, PartitionLength);
}
}
{
/* EZ Drive found, bias the offset */
IsEzDrive = TRUE;
- ExFreePool(MbrBuffer);
+ ExFreePoolWithTag(MbrBuffer, TAG_FILE_SYSTEM);
Offset.QuadPart = 512;
}
{
/* EZ Drive found, bias the offset */
IsEzDrive = TRUE;
- ExFreePool(MbrBuffer);
+ ExFreePoolWithTag(MbrBuffer, TAG_FILE_SYSTEM);
Offset.QuadPart = 512;
}
} while (i < PartitionNumber);
/* Everything done, cleanup */
- if (Buffer) ExFreePool(Buffer);
+ if (Buffer) ExFreePoolWithTag(Buffer, TAG_FILE_SYSTEM);
return Status;
}
{
/* EZ Drive found, bias the offset */
IsEzDrive = TRUE;
- ExFreePool(MbrBuffer);
+ ExFreePoolWithTag(MbrBuffer, TAG_FILE_SYSTEM);
Offset.QuadPart = 512;
}