mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:12:57 +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
|
#undef IsEqualGUID
|
||||||
#endif
|
#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_READ_PROPERTIES 0x00000008
|
||||||
#define FILE_WRITE_PROPERTIES 0x00000010
|
#define FILE_WRITE_PROPERTIES 0x00000010
|
||||||
|
|
|
@ -132,8 +132,8 @@ CreateNewDriveLetterName(OUT PUNICODE_STRING DriveLetter,
|
||||||
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
/* Allocate a big enough buffer to contain the symbolic link */
|
/* Allocate a big enough buffer to contain the symbolic link */
|
||||||
DriveLetter->MaximumLength = sizeof(DosDevices.Buffer) + 3 * sizeof(WCHAR);
|
DriveLetter->MaximumLength = DosDevices.Length + 3 * sizeof(WCHAR);
|
||||||
DriveLetter->Buffer = AllocatePool(sizeof(DosDevices.Buffer) + 3 * sizeof(WCHAR));
|
DriveLetter->Buffer = AllocatePool(DriveLetter->MaximumLength);
|
||||||
if (!DriveLetter->Buffer)
|
if (!DriveLetter->Buffer)
|
||||||
{
|
{
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
@ -143,9 +143,9 @@ CreateNewDriveLetterName(OUT PUNICODE_STRING DriveLetter,
|
||||||
RtlCopyUnicodeString(DriveLetter, &DosDevices);
|
RtlCopyUnicodeString(DriveLetter, &DosDevices);
|
||||||
|
|
||||||
/* Update string to reflect real contents */
|
/* Update string to reflect real contents */
|
||||||
DriveLetter->Length = sizeof(DosDevices.Buffer) + 2 * sizeof(WCHAR);
|
DriveLetter->Length = DosDevices.Length + 2 * sizeof(WCHAR);
|
||||||
DriveLetter->Buffer[(sizeof(DosDevices.Buffer) + 2 * sizeof(WCHAR)) / sizeof (WCHAR)] = UNICODE_NULL;
|
DriveLetter->Buffer[DosDevices.Length / sizeof(WCHAR) + 2] = UNICODE_NULL;
|
||||||
DriveLetter->Buffer[(sizeof(DosDevices.Buffer) + sizeof(WCHAR)) / sizeof (WCHAR)] = L':';
|
DriveLetter->Buffer[DosDevices.Length / sizeof(WCHAR) + 1] = L':';
|
||||||
|
|
||||||
/* If caller wants a no drive entry */
|
/* If caller wants a no drive entry */
|
||||||
if (Letter == (UCHAR)-1)
|
if (Letter == (UCHAR)-1)
|
||||||
|
@ -158,7 +158,7 @@ CreateNewDriveLetterName(OUT PUNICODE_STRING DriveLetter,
|
||||||
else if (Letter)
|
else if (Letter)
|
||||||
{
|
{
|
||||||
/* Use the letter given by the caller */
|
/* 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);
|
Status = GlobalCreateSymbolicLink(DriveLetter, DeviceName);
|
||||||
if (NT_SUCCESS(Status))
|
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 */
|
/* Try to affect a letter (up to Z, ofc) until it's possible */
|
||||||
for (; Letter <= 'Z'; Letter++)
|
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);
|
Status = GlobalCreateSymbolicLink(DriveLetter, DeviceName);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
DPRINT("Assigned drive %c: to %wZ\n", Letter, DeviceName);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We failed to allocate a letter */
|
/* We failed to allocate a letter */
|
||||||
FreePool(DriveLetter->Buffer);
|
FreePool(DriveLetter->Buffer);
|
||||||
|
DPRINT("Failed to create a drive letter for %wZ\n", DeviceName);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,7 +560,7 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
|
||||||
|
|
||||||
/* Query unique ID */
|
/* Query unique ID */
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
Irp = IoBuildDeviceIoControlRequest(IOCTL_MOUNTDEV_QUERY_DEVICE_NAME,
|
Irp = IoBuildDeviceIoControlRequest(IOCTL_MOUNTDEV_QUERY_UNIQUE_ID,
|
||||||
DeviceObject,
|
DeviceObject,
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
|
@ -1070,7 +1072,7 @@ MountMgrMountedDeviceArrival(IN PDEVICE_EXTENSION DeviceExtension,
|
||||||
{
|
{
|
||||||
CurrentDevice = CONTAINING_RECORD(NextEntry, DEVICE_INFORMATION, DeviceListEntry);
|
CurrentDevice = CONTAINING_RECORD(NextEntry, DEVICE_INFORMATION, DeviceListEntry);
|
||||||
|
|
||||||
if (RtlEqualUnicodeString(&(DeviceInformation->DeviceName), &TargetDeviceName, TRUE))
|
if (RtlEqualUnicodeString(&(CurrentDevice->DeviceName), &TargetDeviceName, TRUE))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1876,7 +1878,7 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
||||||
&MountedDevicesGuid,
|
&MountedDevicesGuid,
|
||||||
DriverObject,
|
DriverObject,
|
||||||
MountMgrMountedDeviceNotification,
|
MountMgrMountedDeviceNotification,
|
||||||
DeviceObject,
|
DeviceExtension,
|
||||||
&(DeviceExtension->NotificationEntry));
|
&(DeviceExtension->NotificationEntry));
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue