PopIrpWorker

VOID __stdcall PopIrpWorker(UINT64 Arg){
  unsigned __int8 CurrentIrql; 
  _KSEMAPHORE *v3; 
  union _LARGE_INTEGER *Timeout; 
  __int64 v5; 
  __int64 v6; 
  int v7; 
  ULONG_PTR v8; 
  __int64 v9; 
  __int64 v10; 
  __int64 v11; 
  __int64 v12; 
  char v13; 
  __int64 v14; 
  INT64 v15; 
  __int64 v16; 
  int v17; 
  int DeviceDStateReason; 
  __int64 v19; 
  __int64 v20; 
  _DEVICE_POWER_STATE v21; 
  int v22; 
  __int128 v23; 
  char v24; 
  struct _KLOCK_QUEUE_HANDLE LockHandle; 
  __int128 v26; 
  __m256i v27; 
  union _LARGE_INTEGER v28; 
  v28.QuadPart = 0i64;
  CurrentIrql = 0;
  memset(&LockHandle, 0, sizeof(LockHandle));
  v26 = 0i64;
  *(_OWORD *)&v27.m256i_u64[2] = 0i64;
  *(_OWORD *)v27.m256i_i8 = (unsigned __int64)KeGetCurrentThread();
  if( Arg )
  {
    v3 = *(_KSEMAPHORE **)Arg;
    if( v3 )
      KeReleaseSemaphore(v3, 0i64, 1i64, 0);
    ExFreeToNPagedLookasideList((NPAGED_LOOKASIDE_LIST *)PopDynamicIrpWorkerLookaside, (PVOID)Arg);
    v28.QuadPart = -100000000i64;
    Timeout = &v28;
    v27.m256i_i8[24] = 0;
  }
  else
  {
    Timeout = 0i64;
    v27.m256i_i8[24] = 1;
  }
  PopAcquireIrpWorkerLock();
  --PopIrpWorkerPendingCount;
  ++PopIrpWorkerCount;
  if( *(__int64 **)qword_140C20A68 != &PopIrpThreadList )
LABEL_49:
    __fastfail(3u);
  *(_QWORD *)&v26 = &PopIrpThreadList;
  *((_QWORD *)&v26 + 1) = qword_140C20A68;
  *(_QWORD *)qword_140C20A68 = &v26;
  qword_140C20A68 = (__int64)&v26;
LABEL_7:
  PopReleaseIrpWorkerLock();
  do
  {
    if( KeWaitForSingleObject(&PopIrpWorkerSemaphore, Executive, 0, 0, Timeout) != 258 )
    {
      KeAcquireInStackQueuedSpinLock(&PopIrpLock, &LockHandle);
      v5 = PopIrpWorkerList;
      v6 = *(_QWORD *)PopIrpWorkerList;
      if( *(__int64 **)(PopIrpWorkerList + 8) != &PopIrpWorkerList || *(_QWORD *)(v6 + 8) != PopIrpWorkerList )
        goto LABEL_49;
      PopIrpWorkerList = *(_QWORD *)PopIrpWorkerList;
      *(_QWORD *)(v6 + 8) = &PopIrpWorkerList;
      KeReleaseInStackQueuedSpinLock(&LockHandle);
      PopAcquireIrpWorkerLock();
      v7 = ++PopIrpWorkerInFlightCount;
      if( PopCreateIrpWorkerAllowed
        && v7 == PopIrpWorkerCount
        && !PopIrpWorkerPendingCount
        && (unsigned int)PopIrpWorkerCount < 0xF
        && !PopIrpWorkerRequested )
      {
        PopIrpWorkerRequested = 1;
        KeSetEvent(&PopIrpWorkerControlEvent, 0);
      }
      PopReleaseIrpWorkerLock();
      v8 = v5 - 168;
      v9 = *(_QWORD *)(v5 - 168 + 184);
      v10 = v5 - 168;
      v11 = *(_QWORD *)(v9 + 40);
      PoDeviceAcquireIrp(v10, *(_BYTE *)(v9 + 1), v11);
      v12 = *(_QWORD *)(v8 + 72i64 * *(char *)(v8 + 66) + 200);
      if( *(_BYTE *)(v12 + 184) == 2 && *(_DWORD *)(v12 + 188) == 1 && *(_QWORD *)(v12 + 32) == v11 )
      {
        v14 = *(_QWORD *)(v12 + 24);
        v15 = *(_QWORD *)(v12 + 200);
        v16 = v14 ? *(_QWORD *)(*(_QWORD *)(v14 + 312) + 40i64) : 0i64;
        v17 = *(_DWORD *)(v16 + 156);
        *(_DWORD *)(v16 + 156) = *(_DWORD *)(v12 + 192);
        if( v15 )
        {
          DeviceDStateReason = PopFxGetDeviceDStateReason(v15);
          *(_DWORD *)(v19 + 248) = DeviceDStateReason;
          *(_BYTE *)(v19 + 208) = 0;
          if( DeviceDStateReason == 1 )
            *(_BYTE *)(v19 + 208) = 1;
          v21 = *(_DWORD *)(v19 + 192);
          *(_BYTE *)(v19 + 209) = v21 != v17;
          if( v21 != v17 )
          {
            if( v21 == PowerDeviceD0 )
            {
              _InterlockedOr((volatile signed __int32 *)(v20 + 32), 2u);
              v21 = *(_DWORD *)(v19 + 192);
            }
            PopPepDeviceDState(*(PEPHANDLE__ **)(v20 + 56), v21, 0i64, *(unsigned int *)(v19 + 248));
          }
        }
      }
      v13 = 0;
      v27.m256i_i64[1] = v8;
      v27.m256i_i64[2] = v11;
      if( (*(_DWORD *)(v11 + 48) & 0x2000) == 0 && v8 == PopInrushIrp )
      {
        CurrentIrql = KeGetCurrentIrql();
        __writecr8(2ui64);
        v13 = 1;
      }
      (*(void(__fastcall **)(__int64, ULONG_PTR))(*(_QWORD *)(v11 + 8) + 288i64))(v11, v8);
      if( v13 )
        __writecr8(CurrentIrql);
      if( *((_DWORD *)KeGetCurrentThread() + 121) )
        KeBugCheckEx(0xA0u, 0x901ui64, v11, v8, *((unsigned int *)KeGetCurrentThread() + 121));
      *(_OWORD *)&v27.m256i_u64[1] = 0i64;
      ObfDereferenceObjectWithTag((PVOID)v11, 0x72496F50ui64);
      PopAcquireIrpWorkerLock();
      --PopIrpWorkerInFlightCount;
      goto LABEL_7;
    }
    PopAcquireIrpWorkerLock();
    if( PopCreateIrpWorkerAllowed
      && ((v22 = PopIrpWorkerCount - 1, PopIrpWorkerInFlightCount != PopIrpWorkerCount - 1) || PopIrpWorkerPendingCount) )
    {
      v23 = v26;
      v24 = 0;
      if( *(__int128 **)(v26 + 8) != &v26 || **((__int128 ***)&v26 + 1) != &v26 )
        goto LABEL_49;
      **((_QWORD **)&v26 + 1) = v26;
      *(_QWORD *)(v23 + 8) = *((_QWORD *)&v23 + 1);
      PopIrpWorkerCount = v22;
    }
    else
    {
      v24 = 1;
    }
    PopReleaseIrpWorkerLock();
  }
  while( v24 );
  PsTerminateSystemThread(0i64);
}

Referenced by:

No references.