ExpRegisterFirmwareTableInformationHandler

INT64 __fastcall ExpRegisterFirmwareTableInformationHandler(
        VOID *SystemInformation,
        UINT64 SystemInformationLength,
        CHAR PreviousMode){
  unsigned int v3; 
  _ETHREAD *CurrentThread; 
  __int64 *v6; 
  __int64 *v7; 
  _QWORD *PoolWithTag; 
  void *v9; 
  _QWORD *v10; 
  _QWORD *v11; 
  __int64 v13; 
  __int64 **v14; 
  v3 = 0;
  if( PreviousMode )
    return(unsigned int)-1073741727;
  if( !SystemInformation || (unsigned int)SystemInformationLength < 0x18 )
    return(unsigned int)-1073741820;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  --*((_WORD *)CurrentThread + 242);
  ExAcquireResourceExclusiveLite(&ExpFirmwareTableResource, 1u);
  v6 = (__int64 *)(ExpFirmwareTableProviderListHead - 24);
  if( &ExpFirmwareTableProviderListHead != (__int64 *)ExpFirmwareTableProviderListHead )
  {
    while( *(_DWORD *)v6 != *(_DWORD *)SystemInformation )
    {
      v7 = (__int64 *)v6[3];
      v6 = v7 - 3;
      if( &ExpFirmwareTableProviderListHead == v7 )
        goto LABEL_7;
    }
    if( *((_BYTE *)SystemInformation + 4) )
    {
      v3 = 0x40000000;
      goto LABEL_11;
    }
    if( v6[2] == *((_QWORD *)SystemInformation + 2) )
    {
      v13 = v6[3];
      if( *(__int64 **)(v13 + 8) == v6 + 3 )
      {
        v14 = (__int64 **)v6[4];
        if( *v14 == v6 + 3 )
        {
          *v14 = (__int64 *)v13;
          *(_QWORD *)(v13 + 8) = v14;
          HalPutDmaAdapter((PADAPTER_OBJECT)v6[2]);
          ExFreePoolWithTag(v6, 0x54465241u);
          goto LABEL_11;
        }
      }
LABEL_21:
      __fastfail(3u);
    }
LABEL_22:
    v3 = -1073741811;
    goto LABEL_11;
  }
LABEL_7:
  if( !*((_BYTE *)SystemInformation + 4) )
    goto LABEL_22;
  PoolWithTag = ExAllocatePoolWithTag(PagedPool, 0x28ui64, 0x54465241ui64);
  if( PoolWithTag )
  {
    *(_DWORD *)PoolWithTag = *(_DWORD *)SystemInformation;
    PoolWithTag[1] = *((_QWORD *)SystemInformation + 1);
    v9 = (void *)*((_QWORD *)SystemInformation + 2);
    v10 = PoolWithTag + 3;
    PoolWithTag[4] = PoolWithTag + 3;
    PoolWithTag[3] = PoolWithTag + 3;
    PoolWithTag[2] = v9;
    ObfReferenceObject(v9);
    v11 = (_QWORD *)qword_140C19618;
    if( *(__int64 **)qword_140C19618 != &ExpFirmwareTableProviderListHead )
      goto LABEL_21;
    *v10 = &ExpFirmwareTableProviderListHead;
    v10[1] = v11;
    *v11 = v10;
    qword_140C19618 = (__int64)v10;
  }
  else
  {
    v3 = -1073741670;
  }
LABEL_11:
  ExReleaseResourceLite(&ExpFirmwareTableResource);
  KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
  return v3;
}

Referenced by:

NtSetSystemInformation