IopGetDriverNameFromKeyNode

NTSTATUS __stdcall IopGetDriverNameFromKeyNode(PVOID KeyHandle, _UNICODE_STRING *DriverName){
  _KEY_VALUE_FULL_INFORMATION *v4; 
  WCHAR *v5; 
  int v6; 
  unsigned int v7; 
  unsigned __int16 *Pool_1; 
  NTSTATUS v9; 
  int v10; 
  unsigned int v11; 
  VOID **v12; 
  _KEY_VALUE_FULL_INFORMATION *v14; 
  unsigned int v15; 
  __int16 *v16; 
  unsigned int i; 
  __int16 v18; 
  _UNICODE_STRING Source; 
  UINT64 Length; 
  _KEY_VALUE_FULL_INFORMATION *Information; 

  Information = 0i64;
  if( IopGetRegistryValue(KeyHandle, (PWCHAR)L"ObjectName", 0x40ui64, &Information) >= 0 )
  {
    v4 = Information;
    if( Information->DataLength > 2 && Information->Type == 1 )
    {
      v14 = Information;
      v15 = (unsigned __int16)(LOWORD(Information->DataLength) - 2);
      DriverName->Length = v15;
      DriverName->MaximumLength = v4->DataLength;
      v16 = (__int16 *)((char *)v4 + v4->DataOffset);
      for( i = v15 >> 1; i; --i )
      {
        v18 = *v16++;
        LOWORD(v14->TitleIndex) = v18;
        v14 = (_KEY_VALUE_FULL_INFORMATION *)((char *)v14 + 2);
      }
      DriverName->Buffer = (wchar_t *)v4;
      return 0;
    }
    v10 = -1073741472;
    goto LABEL_27;
  }
  Source = 0i64;
  if( IopGetRegistryValue(KeyHandle, (PWCHAR)L"Type", 0i64, &Information) >= 0 )
  {
    v4 = Information;
    if( Information->DataLength )
    {
      v5 = (WCHAR *)L"\\Driver\\";
      v6 = *(ULONG *)((char *)&Information->TitleIndex + Information->DataOffset);
      if( v6 == 2 || (v7 = 16, v6 == 8) )
      {
        v5 = L"\\FileSystem\\";
        v7 = 24;
      }
      LODWORD(Length) = 164;
      Pool_1 = (unsigned __int16 *)IopVerifierExAllocatePool_1(0x200ui64, 0xA4ui64);
      if( !Pool_1 )
        goto LABEL_22;
      v9 = ZwQueryKey(KeyHandle, KeyBasicInformation, Pool_1, (unsigned int)Length, &Length);
      v10 = v9;
      if( v9 == -2147483643 || v9 == -1073741789 )
      {
        ExFreePoolWithTag(Pool_1, 0);
        Pool_1 = (unsigned __int16 *)IopVerifierExAllocatePool_1(0x200ui64, (unsigned int)Length);
        if( !Pool_1 )
          goto LABEL_22;
        v10 = ZwQueryKey(KeyHandle, KeyBasicInformation, Pool_1, (unsigned int)Length, &Length);
      }
      if( v10 < 0 )
      {
        ExFreePoolWithTag(Pool_1, 0);
        goto LABEL_27;
      }
      v11 = v7 + *((_DWORD *)Pool_1 + 3);
      if( v11 < v7 )
      {
        ExFreePoolWithTag(Pool_1, 0);
        v10 = -1073741675;
        goto LABEL_27;
      }
      v12 = IopVerifierExAllocatePool_1(0x200ui64, (unsigned __int16)(v7 + Pool_1[6]));
      DriverName->Buffer = (wchar_t *)v12;
      if( v12 )
      {
        DriverName->Length = 0;
        DriverName->MaximumLength = v11;
        RtlAppendUnicodeToString(DriverName, v5);
        Source.Length = Pool_1[6];
        Source.MaximumLength = Source.Length;
        Source.Buffer = Pool_1 + 8;
        RtlAppendUnicodeStringToString(DriverName, &Source);
        ExFreePoolWithTag(Pool_1, 0);
        ExFreePoolWithTag(v4, 0);
        return 0;
      }
      ExFreePoolWithTag(Pool_1, 0);
LABEL_22:
      v10 = -1073741670;
LABEL_27:
      ExFreePoolWithTag(v4, 0);
      return v10;
    }
    ExFreePoolWithTag(Information, 0);
  }
  return -1073741472;
}

Referenced by:

IopInitializeBootDrivers
IopInitializeSystemDrivers
IopLoadDriver
IopUnloadDriver
PiGetDefaultMessageString
PipCallDriverAddDeviceQueryRoutine
PipInitializeCoreDriversByGroup
PipInitializeEarlyLaunchDrivers
PnpLoadBootFilterDriver