PipGetDriverTagPriority

UINT16 __stdcall PipGetDriverTagPriority(VOID *ServiceHandle){
  UINT16 v2; 
  _KEY_VALUE_FULL_INFORMATION *v3; 
  unsigned int DataLength; 
  __int64 DataOffset; 
  int v6; 
  NTSTATUS RegistryValue; 
  NTSTATUS v9; 
  unsigned __int64 v10; 
  unsigned int *v11; 
  unsigned int v12; 
  _DWORD *v13; 
  PVOID v14; 
  _UNICODE_STRING KeyName; 
  _KEY_VALUE_FULL_INFORMATION *Information; 
  VOID *Handle; 
  PVOID P; 

  Information = 0i64;
  P = 0i64;
  v14 = 0i64;
  *(_DWORD *)(&KeyName.MaximumLength + 1) = 0;
  Handle = 0i64;
  KeyName.Buffer = L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\GroupOrderList";
  v2 = -1;
  *(_DWORD *)&KeyName.Length = 8650882;
  if( IopOpenRegistryKeyEx(&Handle, 0i64, &KeyName, 0x20019ui64) < 0 )
    return v2;
  if( IopGetRegistryValue(ServiceHandle, (PWCHAR)L"Group", 0i64, &Information) < 0 )
  {
LABEL_8:
    ZwClose((_HANDLE)Handle);
    return v2;
  }
  v3 = Information;
  if( Information->Type == 1 )
  {
    DataLength = Information->DataLength;
    if( DataLength )
    {
      DataOffset = Information->DataOffset;
      LODWORD(Information) = 0;
      PnpRegSzToString((_KEY_VALUE_FULL_INFORMATION *)((char *)v3 + DataOffset), DataLength, (int *)&Information);
      KeyName.Length = (unsigned __int16)Information;
      KeyName.MaximumLength = v3->DataLength;
      KeyName.Buffer = (wchar_t *)((char *)v3 + v3->DataOffset);
    }
  }
  v6 = 0;
  RegistryValue = IopGetRegistryValue(ServiceHandle, (PWCHAR)L"Tag", 0x50ui64, (_KEY_VALUE_FULL_INFORMATION **)&P);
  if( RegistryValue < 0
    || (*((_DWORD *)P + 1) != 4 || *((_DWORD *)P + 3) != 4 ? (RegistryValue = -1073741823) : (v6 = *(_DWORD *)((char *)P + *((unsigned int *)P + 2))),
        ExFreePoolWithTag(P, 0),
        RegistryValue < 0) )
  {
    ExFreePoolWithTag(v3, 0);
    goto LABEL_8;
  }
  v9 = IopGetRegistryValue(Handle, KeyName.Buffer, 0x50ui64, (_KEY_VALUE_FULL_INFORMATION **)&v14);
  ExFreePoolWithTag(v3, 0);
  ZwClose((_HANDLE)Handle);
  if( v9 >= 0 )
  {
    if( *((_DWORD *)v14 + 1) == 3 )
    {
      v10 = *((unsigned int *)v14 + 3);
      if( (unsigned int)v10 >= 4 )
      {
        v11 = (unsigned int *)((char *)v14 + *((unsigned int *)v14 + 2));
        v12 = *v11;
        if( 4 * (unsigned __int64)(*v11 + 1) <= v10 )
        {
          v13 = v11 + 1;
          v2 = 1;
          if( v12 )
          {
            do
            {
              if( v6 == *v13 )
                break;
              ++v2;
              ++v13;
            }
            while( v2 <= v12 );
          }
        }
      }
    }
    ExFreePoolWithTag(v14, 0);
  }
  return v2;
}

Referenced by:

IopInitializeBootDrivers