VOID NTAPI InjpApcKernelRoutine( IN PKAPC Apc, IN OUT PKNORMAL_ROUTINE* NormalRoutine, IN OUT PVOID* NormalContext, IN OUT PVOID* SystemArgument1, IN OUT PVOID* SystemArgument2) { UNREFERENCED_PARAMETER(NormalRoutine); UNREFERENCED_PARAMETER(NormalContext); UNREFERENCED_PARAMETER(SystemArgument1); UNREFERENCED_PARAMETER(SystemArgument2); if (Apc) ExFreePool(Apc); }
NTSTATUS NTAPI InjpInsertQueueApc( IN KPROCESSOR_MODE ApcMode, IN PKNORMAL_ROUTINE NormalRoutine, IN PVOID NormalContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2) { PKAPC Apc = NULL; BOOLEAN Result = FALSE; Apc = ExAllocatePool(NonPagedPool, sizeof(KAPC)); if (!Apc) return STATUS_INSUFFICIENT_RESOURCES; KeInitializeApc(Apc, // Apc PsGetCurrentThread(), // Thread OriginalApcEnvironment, // Environment &InjpApcKernelRoutine, // KernelRoutine NULL, // RundownRoutine NormalRoutine, // NormalRoutine ApcMode, // ApcMode NormalContext); // NormalContext Result = KeInsertQueueApc(Apc, // Apc SystemArgument1, // SystemArgument1 SystemArgument2, // SystemArgument2 0); // Increment if (!Result) { ExFreePool(Apc); return STATUS_THREAD_IS_TERMINATING; } return STATUS_SUCCESS; }