mirror of
https://github.com/reactos/reactos.git
synced 2025-04-09 23:37:40 +00:00
[MOUNTMGR] Misc fixes
We're now able to do something and to not crash when receiving a device arrival notification. svn path=/trunk/; revision=64140
This commit is contained in:
parent
782d9efde7
commit
ec1d1d6087
2 changed files with 13 additions and 11 deletions
|
@ -13,7 +13,7 @@
|
|||
#undef IsEqualGUID
|
||||
#endif
|
||||
|
||||
#define IsEqualGUID(rguid1, rguid2) (!RtlCompareMemory(rguid1, rguid2, sizeof(GUID)))
|
||||
#define IsEqualGUID(rguid1, rguid2) (RtlCompareMemory(rguid1, rguid2, sizeof(GUID)) == sizeof(GUID))
|
||||
|
||||
#define FILE_READ_PROPERTIES 0x00000008
|
||||
#define FILE_WRITE_PROPERTIES 0x00000010
|
||||
|
|
|
@ -132,8 +132,8 @@ CreateNewDriveLetterName(OUT PUNICODE_STRING DriveLetter,
|
|||
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
/* Allocate a big enough buffer to contain the symbolic link */
|
||||
DriveLetter->MaximumLength = sizeof(DosDevices.Buffer) + 3 * sizeof(WCHAR);
|
||||
DriveLetter->Buffer = AllocatePool(sizeof(DosDevices.Buffer) + 3 * sizeof(WCHAR));
|
||||
DriveLetter->MaximumLength = DosDevices.Length + 3 * sizeof(WCHAR);
|
||||
DriveLetter->Buffer = AllocatePool(DriveLetter->MaximumLength);
|
||||
if (!DriveLetter->Buffer)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -143,9 +143,9 @@ CreateNewDriveLetterName(OUT PUNICODE_STRING DriveLetter,
|
|||
RtlCopyUnicodeString(DriveLetter, &DosDevices);
|
||||
|
||||
/* Update string to reflect real contents */
|
||||
DriveLetter->Length = sizeof(DosDevices.Buffer) + 2 * sizeof(WCHAR);
|
||||
DriveLetter->Buffer[(sizeof(DosDevices.Buffer) + 2 * sizeof(WCHAR)) / sizeof (WCHAR)] = UNICODE_NULL;
|
||||
DriveLetter->Buffer[(sizeof(DosDevices.Buffer) + sizeof(WCHAR)) / sizeof (WCHAR)] = L':';
|
||||
DriveLetter->Length = DosDevices.Length + 2 * sizeof(WCHAR);
|
||||
DriveLetter->Buffer[DosDevices.Length / sizeof(WCHAR) + 2] = UNICODE_NULL;
|
||||
DriveLetter->Buffer[DosDevices.Length / sizeof(WCHAR) + 1] = L':';
|
||||
|
||||
/* If caller wants a no drive entry */
|
||||
if (Letter == (UCHAR)-1)
|
||||
|
@ -158,7 +158,7 @@ CreateNewDriveLetterName(OUT PUNICODE_STRING DriveLetter,
|
|||
else if (Letter)
|
||||
{
|
||||
/* Use the letter given by the caller */
|
||||
DriveLetter->Buffer[sizeof(DosDevices.Buffer) / sizeof(WCHAR)] = (WCHAR)Letter;
|
||||
DriveLetter->Buffer[DosDevices.Length / sizeof(WCHAR)] = (WCHAR)Letter;
|
||||
Status = GlobalCreateSymbolicLink(DriveLetter, DeviceName);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -187,16 +187,18 @@ CreateNewDriveLetterName(OUT PUNICODE_STRING DriveLetter,
|
|||
/* Try to affect a letter (up to Z, ofc) until it's possible */
|
||||
for (; Letter <= 'Z'; Letter++)
|
||||
{
|
||||
DriveLetter->Buffer[sizeof(DosDevices.Buffer) / sizeof(WCHAR)] = (WCHAR)Letter;
|
||||
DriveLetter->Buffer[DosDevices.Length / sizeof(WCHAR)] = (WCHAR)Letter;
|
||||
Status = GlobalCreateSymbolicLink(DriveLetter, DeviceName);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Assigned drive %c: to %wZ\n", Letter, DeviceName);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
/* We failed to allocate a letter */
|
||||
FreePool(DriveLetter->Buffer);
|
||||
DPRINT("Failed to create a drive letter for %wZ\n", DeviceName);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -558,7 +560,7 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
|
|||
|
||||
/* Query unique ID */
|
||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||
Irp = IoBuildDeviceIoControlRequest(IOCTL_MOUNTDEV_QUERY_DEVICE_NAME,
|
||||
Irp = IoBuildDeviceIoControlRequest(IOCTL_MOUNTDEV_QUERY_UNIQUE_ID,
|
||||
DeviceObject,
|
||||
NULL,
|
||||
0,
|
||||
|
@ -1070,7 +1072,7 @@ MountMgrMountedDeviceArrival(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
{
|
||||
CurrentDevice = CONTAINING_RECORD(NextEntry, DEVICE_INFORMATION, DeviceListEntry);
|
||||
|
||||
if (RtlEqualUnicodeString(&(DeviceInformation->DeviceName), &TargetDeviceName, TRUE))
|
||||
if (RtlEqualUnicodeString(&(CurrentDevice->DeviceName), &TargetDeviceName, TRUE))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -1876,7 +1878,7 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
|||
&MountedDevicesGuid,
|
||||
DriverObject,
|
||||
MountMgrMountedDeviceNotification,
|
||||
DeviceObject,
|
||||
DeviceExtension,
|
||||
&(DeviceExtension->NotificationEntry));
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
|
Loading…
Reference in a new issue