LONG Unloading;
static const WCHAR Cunc[] = L"\\??\\C:";
+#define Cunc_LETTER_POSITION 4
/*
* @implemented
PLIST_ENTRY NextEntry;
PSYMLINK_INFORMATION SymlinkInfo;
- /* To have a drive letter, a device must have symbolic links */
- if (IsListEmpty(&(DeviceInformation->SymbolicLinksListHead)))
- {
- return FALSE;
- }
-
- /* Browse all the links untill a drive letter is found */
- NextEntry = &(DeviceInformation->SymbolicLinksListHead);
- do
+ /* Browse all the symlinks to check if there is at least a drive letter */
+ for (NextEntry = DeviceInformation->SymbolicLinksListHead.Flink;
+ NextEntry != &DeviceInformation->SymbolicLinksListHead;
+ NextEntry = NextEntry->Flink)
{
SymlinkInfo = CONTAINING_RECORD(NextEntry, SYMLINK_INFORMATION, SymbolicLinksListEntry);
- if (SymlinkInfo->Online)
+ if (IsDriveLetter(&SymlinkInfo->Name) && SymlinkInfo->Online)
{
- if (IsDriveLetter(&(SymlinkInfo->Name)))
- {
- return TRUE;
- }
+ return TRUE;
}
-
- NextEntry = NextEntry->Flink;
- } while (NextEntry != &(DeviceInformation->SymbolicLinksListHead));
+ }
return FALSE;
}
KeInitializeEvent(&UnloadEvent, NotificationEvent, FALSE);
/* Wait for workers to finish */
- if (InterlockedIncrement(&DeviceExtension->WorkerReferences))
+ if (InterlockedIncrement(&DeviceExtension->WorkerReferences) > 0)
{
KeReleaseSemaphore(&(DeviceExtension->WorkerSemaphore),
IO_NO_INCREMENT, 1, FALSE);
/*
* @implemented
*/
-INIT_SECTION
+INIT_FUNCTION
BOOLEAN
MountmgrReadNoAutoMount(IN PUNICODE_STRING RegistryPath)
{
/* Start checking all letters that could have been associated */
for (Letter = L'D'; Letter <= L'Z'; Letter++)
{
- CSymLink.Buffer[LETTER_POSITION] = Letter;
+ CSymLink.Buffer[Cunc_LETTER_POSITION] = Letter;
InitializeObjectAttributes(&ObjectAttributes,
&CSymLink,
}
/* Otherwise, cancel all the IRPs */
- NextEntry = &(DeviceExtension->IrpListHead);
+ NextEntry = DeviceExtension->IrpListHead.Flink;
do
{
ListIrp = CONTAINING_RECORD(NextEntry, IRP, Tail.Overlay.ListEntry);
KeInitializeEvent(&UnloadEvent, NotificationEvent, FALSE);
/* Wait for workers */
- if (InterlockedIncrement(&(DeviceExtension->WorkerReferences)))
+ if (InterlockedIncrement(&(DeviceExtension->WorkerReferences)) > 0)
{
KeReleaseSemaphore(&(DeviceExtension->WorkerSemaphore),
IO_NO_INCREMENT,
/* FUNCTIONS ****************************************************************/
-INIT_SECTION
+INIT_FUNCTION
NTSTATUS
NTAPI
DriverEntry(IN PDRIVER_OBJECT DriverObject,