mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
{MOUNTMGR]
- Use portable KeXxxSpinLock, instead of fastcall variants - Fix usage of uninitialized variable - Fix typos in assignments - Fix several integer size bugs - Fix uninitialied variables (and those gcc couldn't identify as initialized) - Fix MSVC warnings svn path=/trunk/; revision=55651
This commit is contained in:
parent
9f969348ab
commit
ced3afac1d
5 changed files with 48 additions and 44 deletions
|
@ -175,7 +175,9 @@ GetRemoteDatabaseEntry(IN HANDLE Database,
|
|||
&ByteOffset,
|
||||
NULL);
|
||||
/* If it fails or returns inconsistent data, drop it (= truncate) */
|
||||
if (!NT_SUCCESS(Status) || IoStatusBlock.Information != EntrySize || EntrySize < sizeof(DATABASE_ENTRY))
|
||||
if (!NT_SUCCESS(Status) ||
|
||||
(IoStatusBlock.Information != EntrySize) ||
|
||||
(EntrySize < sizeof(DATABASE_ENTRY)) )
|
||||
{
|
||||
TruncateRemoteDatabase(Database, StartingOffset);
|
||||
FreePool(Entry);
|
||||
|
@ -184,7 +186,7 @@ GetRemoteDatabaseEntry(IN HANDLE Database,
|
|||
|
||||
/* Validate entry */
|
||||
if (MAX(Entry->SymbolicNameOffset + Entry->SymbolicNameLength,
|
||||
Entry->UniqueIdOffset + Entry->UniqueIdLength) > EntrySize)
|
||||
Entry->UniqueIdOffset + Entry->UniqueIdLength) > (LONG)EntrySize)
|
||||
{
|
||||
TruncateRemoteDatabase(Database, StartingOffset);
|
||||
FreePool(Entry);
|
||||
|
@ -201,10 +203,10 @@ NTSTATUS
|
|||
DeleteRemoteDatabaseEntry(IN HANDLE Database,
|
||||
IN LONG StartingOffset)
|
||||
{
|
||||
LONG EndSize;
|
||||
ULONG EndSize;
|
||||
PVOID TmpBuffer;
|
||||
NTSTATUS Status;
|
||||
LONG DatabaseSize;
|
||||
ULONG DatabaseSize;
|
||||
PDATABASE_ENTRY Entry;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
LARGE_INTEGER EndEntriesOffset;
|
||||
|
@ -423,7 +425,8 @@ WorkerThread(IN PDEVICE_OBJECT DeviceObject,
|
|||
/* Acquire workers lock */
|
||||
KeWaitForSingleObject(&(DeviceExtension->WorkerSemaphore), Executive, KernelMode, FALSE, NULL);
|
||||
|
||||
OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
|
||||
KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
|
||||
|
||||
/* Ensure there are workers */
|
||||
while (!IsListEmpty(&(DeviceExtension->WorkerQueueListHead)))
|
||||
{
|
||||
|
@ -433,7 +436,7 @@ WorkerThread(IN PDEVICE_OBJECT DeviceObject,
|
|||
RECONCILE_WORK_ITEM,
|
||||
WorkerQueueListEntry);
|
||||
|
||||
KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
|
||||
/* Call it */
|
||||
WorkItem->WorkerRoutine(WorkItem->Context);
|
||||
|
@ -447,9 +450,9 @@ WorkerThread(IN PDEVICE_OBJECT DeviceObject,
|
|||
}
|
||||
|
||||
KeWaitForSingleObject(&(DeviceExtension->WorkerSemaphore), Executive, KernelMode, FALSE, NULL);
|
||||
OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
|
||||
KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
|
||||
}
|
||||
KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
|
||||
InterlockedDecrement(&(DeviceExtension->WorkerReferences));
|
||||
|
||||
|
@ -478,10 +481,10 @@ QueueWorkItem(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
}
|
||||
|
||||
/* Otherwise queue worker for delayed execution */
|
||||
OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
|
||||
KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
|
||||
InsertTailList(&(DeviceExtension->WorkerQueueListHead),
|
||||
&(WorkItem->WorkerQueueListEntry));
|
||||
KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
|
||||
KeReleaseSemaphore(&(DeviceExtension->WorkerSemaphore), IO_NO_INCREMENT, 1, FALSE);
|
||||
|
||||
|
@ -638,8 +641,8 @@ QueryVolumeName(IN HANDLE RootDirectory,
|
|||
}
|
||||
|
||||
/* Return the volume name */
|
||||
VolumeName->Length = FileNameInfo->FileNameLength;
|
||||
VolumeName->MaximumLength = FileNameInfo->FileNameLength + sizeof(WCHAR);
|
||||
VolumeName->Length = (USHORT)FileNameInfo->FileNameLength;
|
||||
VolumeName->MaximumLength = (USHORT)FileNameInfo->FileNameLength + sizeof(WCHAR);
|
||||
VolumeName->Buffer = AllocatePool(VolumeName->MaximumLength);
|
||||
if (!VolumeName->Buffer)
|
||||
{
|
||||
|
@ -993,7 +996,7 @@ MigrateRemoteDatabaseWorker(IN PDEVICE_OBJECT DeviceObject,
|
|||
}
|
||||
if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||
{
|
||||
Status == STATUS_SUCCESS;
|
||||
Status = STATUS_SUCCESS;
|
||||
Complete = TRUE;
|
||||
}
|
||||
if (!NT_SUCCESS(Status) || Complete)
|
||||
|
@ -1022,7 +1025,7 @@ MigrateRemoteDatabaseWorker(IN PDEVICE_OBJECT DeviceObject,
|
|||
}
|
||||
|
||||
/* And write them into new database */
|
||||
Length = IoStatusBlock.Information;
|
||||
Length = (ULONG)IoStatusBlock.Information;
|
||||
Status = ZwWriteFile(Database,
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -1228,7 +1231,7 @@ QueryUniqueIdQueryRoutine(IN PWSTR ValueName,
|
|||
if (IntUniqueId)
|
||||
{
|
||||
/* Copy data & return */
|
||||
IntUniqueId->UniqueIdLength = ValueLength;
|
||||
IntUniqueId->UniqueIdLength = (USHORT)ValueLength;
|
||||
RtlCopyMemory(&(IntUniqueId->UniqueId), ValueData, ValueLength);
|
||||
|
||||
UniqueId = Context;
|
||||
|
|
|
@ -94,7 +94,7 @@ MountmgrWriteNoAutoMount(IN PDEVICE_EXTENSION DeviceExtension)
|
|||
REG_DWORD,
|
||||
&Value,
|
||||
sizeof(Value));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -221,10 +221,10 @@ NTSTATUS
|
|||
MountMgrScrubRegistry(IN PDEVICE_EXTENSION DeviceExtension)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
BOOLEAN Continue = TRUE;
|
||||
BOOLEAN Continue;
|
||||
RTL_QUERY_REGISTRY_TABLE QueryTable[2];
|
||||
|
||||
while (Continue)
|
||||
do
|
||||
{
|
||||
RtlZeroMemory(QueryTable, sizeof(QueryTable));
|
||||
QueryTable[0].QueryRoutine = ScrubRegistryRoutine;
|
||||
|
@ -237,6 +237,7 @@ MountMgrScrubRegistry(IN PDEVICE_EXTENSION DeviceExtension)
|
|||
DeviceExtension,
|
||||
NULL);
|
||||
}
|
||||
while (Continue);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -513,7 +514,7 @@ MountMgrNextDriveLetterWorker(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
if (IsDriveLetter(&(SymlinkInformation->Name)) && SymlinkInformation->Online)
|
||||
{
|
||||
DriveLetterInfo->DriveLetterWasAssigned = FALSE;
|
||||
DriveLetterInfo->CurrentDriveLetter = SymlinkInformation->Name.Buffer[LETTER_POSITION];
|
||||
DriveLetterInfo->CurrentDriveLetter = (CHAR)SymlinkInformation->Name.Buffer[LETTER_POSITION];
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -972,8 +973,8 @@ MountMgrQueryPoints(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
}
|
||||
|
||||
/* We can't go beyond */
|
||||
if (MountPoint->SymbolicLinkNameLength + MountPoint->UniqueIdLength +
|
||||
MountPoint->DeviceNameLength < Stack->Parameters.DeviceIoControl.InputBufferLength)
|
||||
if (((ULONG)MountPoint->SymbolicLinkNameLength + MountPoint->UniqueIdLength +
|
||||
MountPoint->DeviceNameLength) < Stack->Parameters.DeviceIoControl.InputBufferLength)
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
@ -1234,7 +1235,7 @@ MountMgrDeletePointsDbOnly(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
NTSTATUS
|
||||
MountMgrVolumeMountPointChanged(IN PDEVICE_EXTENSION DeviceExtension,
|
||||
IN PIRP Irp,
|
||||
IN NTSTATUS LockStatus,
|
||||
IN NTSTATUS LockStatus,
|
||||
OUT PUNICODE_STRING SourceDeviceName,
|
||||
OUT PUNICODE_STRING SourceSymbolicName,
|
||||
OUT PUNICODE_STRING TargetVolumeName)
|
||||
|
@ -1265,7 +1266,7 @@ MountMgrVolumeMountPointChanged(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
|
||||
VolumeMountPoint = (PMOUNTMGR_VOLUME_MOUNT_POINT)Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
if (VolumeMountPoint->SourceVolumeNameLength + VolumeMountPoint->TargetVolumeNameLength <
|
||||
if (((ULONG)VolumeMountPoint->SourceVolumeNameLength + VolumeMountPoint->TargetVolumeNameLength) <
|
||||
Stack->Parameters.DeviceIoControl.InputBufferLength)
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -1406,7 +1407,7 @@ MountMgrVolumeMountPointChanged(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
|
||||
/* Return symbolic name */
|
||||
SourceSymbolicName->Length =
|
||||
SourceSymbolicName->MaximumLength = FileNameInfo->FileNameLength;
|
||||
SourceSymbolicName->MaximumLength = (USHORT)FileNameInfo->FileNameLength;
|
||||
SourceSymbolicName->Buffer = (PWSTR)FileNameInfo;
|
||||
/* memmove allows memory overlap */
|
||||
RtlMoveMemory(SourceSymbolicName->Buffer, FileNameInfo->FileName, SourceSymbolicName->Length);
|
||||
|
|
|
@ -131,7 +131,7 @@ CreateNewDriveLetterName(OUT PUNICODE_STRING DriveLetter,
|
|||
IN UCHAR Letter,
|
||||
IN PMOUNTDEV_UNIQUE_ID UniqueId OPTIONAL)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
/* Allocate a big enough buffer to contain the symbolic link */
|
||||
DriveLetter->MaximumLength = sizeof(DosDevices.Buffer) + 3 * sizeof(WCHAR);
|
||||
|
@ -907,7 +907,7 @@ MountMgrUnload(IN struct _DRIVER_OBJECT *DriverObject)
|
|||
/*
|
||||
* @implemented
|
||||
*/
|
||||
ULONG
|
||||
BOOLEAN
|
||||
MountmgrReadNoAutoMount(IN PUNICODE_STRING RegistryPath)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
@ -931,10 +931,10 @@ MountmgrReadNoAutoMount(IN PUNICODE_STRING RegistryPath)
|
|||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Default;
|
||||
return (Default != 0);
|
||||
}
|
||||
|
||||
return Result;
|
||||
return (Result != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1009,7 +1009,7 @@ MountMgrMountedDeviceArrival(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
|
||||
if (RtlEqualUnicodeString(&(DeviceInformation->SymbolicName), &(CurrentDevice->SymbolicName), TRUE))
|
||||
{
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1054,7 +1054,7 @@ MountMgrMountedDeviceArrival(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
/* If it's OK, set it and save its letter (if any) */
|
||||
if (SuggestedLinkName.Buffer && IsDriveLetter(&SuggestedLinkName))
|
||||
{
|
||||
DeviceInformation->SuggestedDriveLetter = SuggestedLinkName.Buffer[LETTER_POSITION];
|
||||
DeviceInformation->SuggestedDriveLetter = (UCHAR)SuggestedLinkName.Buffer[LETTER_POSITION];
|
||||
}
|
||||
|
||||
/* Acquire driver exclusively */
|
||||
|
@ -1069,7 +1069,7 @@ MountMgrMountedDeviceArrival(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
|
||||
if (RtlEqualUnicodeString(&(DeviceInformation->DeviceName), &TargetDeviceName, TRUE))
|
||||
{
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ SendOnlineNotificationWorker(IN PVOID Parameter)
|
|||
/* First, send the notification */
|
||||
SendOnlineNotification(&(WorkItem->SymbolicName));
|
||||
|
||||
OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
|
||||
KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
|
||||
/* If there are no notifications running any longer, reset event */
|
||||
if (--DeviceExtension->OnlineNotificationCount == 0)
|
||||
{
|
||||
|
@ -120,7 +120,7 @@ SendOnlineNotificationWorker(IN PVOID Parameter)
|
|||
/* Queue a new one for execution */
|
||||
Head = RemoveHeadList(&(DeviceExtension->OnlineNotificationListHead));
|
||||
NewWorkItem = CONTAINING_RECORD(Head, ONLINE_NOTIFICATION_WORK_ITEM, List);
|
||||
KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
NewWorkItem->List.Blink = NULL;
|
||||
NewWorkItem->List.Flink = NULL;
|
||||
ExQueueWorkItem((PWORK_QUEUE_ITEM)NewWorkItem, DelayedWorkQueue);
|
||||
|
@ -129,7 +129,7 @@ SendOnlineNotificationWorker(IN PVOID Parameter)
|
|||
{
|
||||
/* Mark it's over */
|
||||
DeviceExtension->OnlineNotificationWorkerActive = 0;
|
||||
KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
}
|
||||
|
||||
FreePool(WorkItem->SymbolicName.Buffer);
|
||||
|
@ -171,14 +171,14 @@ PostOnlineNotification(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
RtlCopyMemory(WorkItem->SymbolicName.Buffer, SymbolicName->Buffer, SymbolicName->Length);
|
||||
WorkItem->SymbolicName.Buffer[SymbolicName->Length / sizeof(WCHAR)] = UNICODE_NULL;
|
||||
|
||||
OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
|
||||
KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
|
||||
DeviceExtension->OnlineNotificationCount++;
|
||||
|
||||
/* If no worker are active */
|
||||
if (DeviceExtension->OnlineNotificationWorkerActive == 0)
|
||||
{
|
||||
/* Queue that one for execution */
|
||||
DeviceExtension->OnlineNotificationWorkerActive == 1;
|
||||
DeviceExtension->OnlineNotificationWorkerActive = 1;
|
||||
ExQueueWorkItem((PWORK_QUEUE_ITEM)WorkItem, DelayedWorkQueue);
|
||||
}
|
||||
else
|
||||
|
@ -187,7 +187,7 @@ PostOnlineNotification(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
InsertTailList(&(DeviceExtension->OnlineNotificationListHead), &(WorkItem->List));
|
||||
}
|
||||
|
||||
KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -202,13 +202,13 @@ WaitForOnlinesToComplete(IN PDEVICE_EXTENSION DeviceExtension)
|
|||
|
||||
KeInitializeEvent(&(DeviceExtension->OnlineNotificationEvent), NotificationEvent, FALSE);
|
||||
|
||||
OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
|
||||
KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
|
||||
|
||||
/* Just wait all the worker are done */
|
||||
if (DeviceExtension->OnlineNotificationCount != 1)
|
||||
{
|
||||
DeviceExtension->OnlineNotificationCount--;
|
||||
KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
|
||||
KeWaitForSingleObject(&(DeviceExtension->OnlineNotificationEvent),
|
||||
Executive,
|
||||
|
@ -216,11 +216,11 @@ WaitForOnlinesToComplete(IN PDEVICE_EXTENSION DeviceExtension)
|
|||
FALSE,
|
||||
NULL);
|
||||
|
||||
OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
|
||||
KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
|
||||
DeviceExtension->OnlineNotificationCount++;
|
||||
}
|
||||
|
||||
KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -477,7 +477,7 @@ MountMgrNotifyNameChange(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
VOID
|
||||
RemoveWorkItem(IN PUNIQUE_ID_WORK_ITEM WorkItem)
|
||||
{
|
||||
PDEVICE_EXTENSION DeviceExtension;
|
||||
PDEVICE_EXTENSION DeviceExtension = WorkItem->DeviceExtension;
|
||||
|
||||
KeWaitForSingleObject(&(DeviceExtension->DeviceLock), Executive, KernelMode, FALSE, NULL);
|
||||
|
||||
|
@ -605,7 +605,7 @@ IssueUniqueIdChangeNotifyWorker(IN PUNIQUE_ID_WORK_ITEM WorkItem,
|
|||
|
||||
/* Initialize the IRP */
|
||||
Irp = WorkItem->Irp;
|
||||
IoInitializeIrp(Irp, IoSizeOfIrp(WorkItem->StackSize), WorkItem->StackSize);
|
||||
IoInitializeIrp(Irp, IoSizeOfIrp(WorkItem->StackSize), (CCHAR)WorkItem->StackSize);
|
||||
|
||||
if (InterlockedExchange((PLONG)&(WorkItem->Event), 0) != 0)
|
||||
{
|
||||
|
|
|
@ -852,7 +852,7 @@ RedirectSavedLink(IN PSAVED_LINK_INFORMATION SavedLinkInformation,
|
|||
RemoveEntryList(&(SymlinkInformation->SymbolicLinksListEntry));
|
||||
FreePool(SymlinkInformation->Name.Buffer);
|
||||
FreePool(SymlinkInformation);
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue