Author: hpoussin Date: Sun Sep 14 07:53:46 2014 New Revision: 64140
URL: http://svn.reactos.org/svn/reactos?rev=64140&view=rev Log: [MOUNTMGR] Misc fixes
We're now able to do something and to not crash when receiving a device arrival notification.
Modified: trunk/reactos/drivers/filters/mountmgr/mntmgr.h trunk/reactos/drivers/filters/mountmgr/mountmgr.c
Modified: trunk/reactos/drivers/filters/mountmgr/mntmgr.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/mn... ============================================================================== --- trunk/reactos/drivers/filters/mountmgr/mntmgr.h [iso-8859-1] (original) +++ trunk/reactos/drivers/filters/mountmgr/mntmgr.h [iso-8859-1] Sun Sep 14 07:53:46 2014 @@ -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
Modified: trunk/reactos/drivers/filters/mountmgr/mountmgr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/mo... ============================================================================== --- trunk/reactos/drivers/filters/mountmgr/mountmgr.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filters/mountmgr/mountmgr.c [iso-8859-1] Sun Sep 14 07:53:46 2014 @@ -132,8 +132,8 @@ 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 @@ 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 @@ 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 @@ /* 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 @@
/* 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 @@ { CurrentDevice = CONTAINING_RECORD(NextEntry, DEVICE_INFORMATION, DeviceListEntry);
- if (RtlEqualUnicodeString(&(DeviceInformation->DeviceName), &TargetDeviceName, TRUE)) + if (RtlEqualUnicodeString(&(CurrentDevice->DeviceName), &TargetDeviceName, TRUE)) { break; } @@ -1876,7 +1878,7 @@ &MountedDevicesGuid, DriverObject, MountMgrMountedDeviceNotification, - DeviceObject, + DeviceExtension, &(DeviceExtension->NotificationEntry));
if (!NT_SUCCESS(Status))