HalpDmaFindDeviceObjectByToken

LIST_ENTRY *__stdcall HalpDmaFindDeviceObjectByToken(UINT64 Token, INT64 Remove, INT64 VerifierQuery){
  __int64 *v4; 
  unsigned __int64 v5; 
  char v6; 
  char v7; 
  char v8; 
  __int64 *v9; 
  unsigned __int8 v10; 
  unsigned __int64 v11; 
  __int64 v12; 
  __int64 **v13; 
  bool v15; 
  v4 = 0i64;
  v5 = 0i64;
  v6 = 0;
  v7 = VerifierQuery;
  v8 = Remove;
  KeAcquireSpinLockRaiseToDpc(&HalpDmaPdoListLock, Remove);
  v9 = (__int64 *)HalpDmaPdoList;
  v11 = v10;
  while( v9 != &HalpDmaPdoList )
  {
    v4 = v9;
    if( v9[2] == Token )
    {
      v5 = v9[3];
      if( v8 )
      {
        v12 = *v9;
        v13 = (__int64 **)v9[1];
        if( *(__int64 **)(*v9 + 8) != v9 || *v13 != v9 )
          __fastfail(3u);
        *v13 = (__int64 *)v12;
        v6 = 1;
        *(_QWORD *)(v12 + 8) = v13;
      }
      if( v7 )
      {
        v15 = *((_BYTE *)v9 + 32) != 0;
        *((_BYTE *)v9 + 32) = 1;
        v5 &= -(__int64)v15;
      }
      break;
    }
    v9 = (__int64 *)*v9;
  }
  KxReleaseSpinLock(&HalpDmaPdoListLock);
  __writecr8(v11);
  if( v6 )
    ExFreePoolWithTag(v4, 0);
  return(LIST_ENTRY *)v5;
}

Referenced by:

HaliGetDmaAdapter
HalpDmaCheckAdapterToken
HalpDmaLinkDeviceObjectByToken