VOID WINAPI WorkerThreadRoutineCope(_In_ PVOID Parameter)
{
WORK_CALL_ITEM lpCallItem;
memcpy(&lpCallItem, Parameter, sizeof(lpCallItem));
ExFreePool(Parameter);
/
/
这个释放内存很关键,如果太快释放那么蓝屏
lpCallItem.Routine(lpCallItem.Context);
}
void ExWorkItemCode(_In_opt_ PWORKER_THREAD_ROUTINE Routine, _In_opt_ PVOID Context, _In_opt_ WORK_QUEUE_TYPE QueueType)
{
NT_ASSERT(KeGetCurrentIrql() <
=
DISPATCH_LEVEL);
PWORK_CALL_ITEM lpCallQueue
=
(PWORK_CALL_ITEM)ExAllocatePool(NonPagedPool, sizeof(WORK_CALL_ITEM));
lpCallQueue
-
>Context
=
Context;
lpCallQueue
-
>Routine
=
Routine;
ExInitializeWorkItem(&lpCallQueue
-
>Queue, WorkerThreadRoutineCope, lpCallQueue);
ExQueueWorkItem(&lpCallQueue
-
>Queue, QueueType);
}