[USBPORT] Make unload work

This commit is contained in:
Timo Kreuzer 2020-10-05 15:43:47 +02:00
parent db0c59cbd4
commit e693d5ffc0
3 changed files with 30 additions and 2 deletions

View file

@ -490,7 +490,6 @@ NTAPI
USBPORT_StopDevice(IN PDEVICE_OBJECT FdoDevice)
{
DPRINT1("USBPORT_StopDevice: UNIMPLEMENTED. FIXME\n");
DbgBreakPoint();
return STATUS_SUCCESS;
}
@ -901,6 +900,7 @@ USBPORT_StartDevice(IN PDEVICE_OBJECT FdoDevice,
return Status;
ExitWithError:
USBPORT_StopWorkerThread(FdoDevice);
USBPORT_StopDevice(FdoDevice);
DPRINT1("USBPORT_StartDevice: ExitWithError Status - %lx\n", Status);

View file

@ -1390,6 +1390,11 @@ USBPORT_WorkerThread(IN PVOID StartContext)
FALSE,
NULL);
if (FdoExtension->Flags & USBPORT_FLAG_WORKER_THREAD_EXIT)
{
break;
}
KeQuerySystemTime(&NewTime);
KeAcquireSpinLock(&FdoExtension->WorkerThreadEventSpinLock, &OldIrql);
@ -1445,6 +1450,23 @@ USBPORT_CreateWorkerThread(IN PDEVICE_OBJECT FdoDevice)
return Status;
}
VOID
NTAPI
USBPORT_StopWorkerThread(IN PDEVICE_OBJECT FdoDevice)
{
PUSBPORT_DEVICE_EXTENSION FdoExtension;
NTSTATUS Status;
DPRINT("USBPORT_StopWorkerThread ... \n");
FdoExtension = FdoDevice->DeviceExtension;
FdoExtension->Flags |= USBPORT_FLAG_WORKER_THREAD_EXIT;
USBPORT_SignalWorkerThread(FdoDevice);
Status = ZwWaitForSingleObject(FdoExtension->WorkerThreadHandle, FALSE, NULL);
NT_ASSERT(Status == STATUS_SUCCESS);
}
VOID
NTAPI
USBPORT_SynchronizeControllersStart(IN PDEVICE_OBJECT FdoDevice)

View file

@ -8,7 +8,7 @@
#ifndef USBPORT_H__
#define USBPORT_H__
#include <ntddk.h>
#include <ntifs.h>
#include <windef.h>
#include <stdio.h>
#include <wdmguid.h>
@ -67,6 +67,7 @@
#define USBPORT_FLAG_HC_STARTED 0x00000002
#define USBPORT_FLAG_HC_POLLING 0x00000004
#define USBPORT_FLAG_WORKER_THREAD_ON 0x00000008
#define USBPORT_FLAG_WORKER_THREAD_EXIT 0x00000010
#define USBPORT_FLAG_HC_SUSPEND 0x00000100
#define USBPORT_FLAG_INTERRUPT_ENABLED 0x00000400
#define USBPORT_FLAG_SELECTIVE_SUSPEND 0x00000800
@ -595,6 +596,11 @@ NTAPI
USBPORT_CreateWorkerThread(
IN PDEVICE_OBJECT FdoDevice);
VOID
NTAPI
USBPORT_StopWorkerThread(
IN PDEVICE_OBJECT FdoDevice);
BOOLEAN
NTAPI
USBPORT_StartTimer(