DbgkpLkmdLaunchSnapApc

__int64 __fastcall DbgkpLkmdLaunchSnapApc(__int64 a1, __int64 a2, INT64 a3, __int64 a4){
  VOID **PoolWithTag; 
  VOID **v9; 
  volatile signed __int32 *v11; 
  UINT64 v12; 
  unsigned int v13; 
  _LARGE_INTEGER v14; 

  PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 0x90ui64, 1884181323i64);
  v9 = PoolWithTag;
  if( !PoolWithTag )
    return 3221225495i64;
  PoolWithTag[13] = (VOID *)a2;
  v11 = (volatile signed __int32 *)(PoolWithTag + 11);
  *((_DWORD *)PoolWithTag + 22) = 0;
  v12 = (UINT64)(PoolWithTag + 15);
  PoolWithTag[12] = (VOID *)a1;
  PoolWithTag[14] = (VOID *)a4;
  KeInitializeEvent((INT64)(PoolWithTag + 15), 0, 0);
  KeInitializeApc((INT64)v9, a3, 0i64, (INT64)DbgkpLkmdSnapThreadApc, 0i64, 0i64, 0, 0i64);
  if( KeInsertQueueApc((INT64)v9, (INT64)v9, (INT64)v11, 2i64) )
  {
    v14.QuadPart = -50000000i64;
    while( 1 )
    {
      v13 = KeWaitForSingleObject(v12, 0, 0, 0, (INT64)&v14);
      if( !v13 )
        break;
      if( v13 == 258 )
        *(_DWORD *)(a4 + 4) |= 0x8000u;
      if( !_InterlockedCompareExchange(v11, 1, 0) )
        return v13;
    }
    ExFreePoolWithTag(v9, 0x704E534Bu);
    return v13;
  }
  else
  {
    ExFreePoolWithTag(v9, 0x704E534Bu);
    *(_DWORD *)(a4 + 4) |= 0x4000u;
    return 3221225473i64;
  }
}

Referenced by:

DbgkpLkmdSnapThread