PnpBootDeviceWait

__int64 __fastcall PnpBootDeviceWait(
        __int64 a1,
        int a2,
        __int64 (__fastcall *a3)(__int64, __int64, _UNICODE_STRING *),
        __int64 a4){
  int v4; 
  unsigned int v8; 
  NTSTATUS RegistryValue; 
  int v10; 
  _KEY_VALUE_FULL_INFORMATION *Information; 
  _UNICODE_STRING UnicodeString; 
  _UNICODE_STRING KeyName; 
  VOID *Handle; 

  v4 = 0;
  *(_QWORD *)&KeyName.Length = 7209068i64;
  Information = 0i64;
  Handle = 0i64;
  *(_QWORD *)&UnicodeString.Length = 0i64;
  UnicodeString.Buffer = 0i64;
  KeyName.Buffer = L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\PnP";
  v8 = 0;
  RegistryValue = IopOpenRegistryKeyEx(&Handle, 0i64, &KeyName, 0x20019ui64);
  if( RegistryValue >= 0 )
  {
    RegistryValue = IopGetRegistryValue(Handle, (PWCHAR)L"PollBootPartitionTimeout", 0i64, &Information);
    if( RegistryValue >= 0 )
    {
      if( Information->DataLength == 4 )
      {
        v8 = *(ULONG *)((char *)&Information->TitleIndex + Information->DataOffset);
        if( v8 >= 0xC8 )
        {
          if( v8 > 0x2BF20 )
            v8 = 180000;
        }
        else
        {
          v8 = 0;
        }
      }
      else
      {
        RegistryValue = -1073741823;
      }
      ExFreePoolWithTag(Information, 0);
    }
    ZwClose((_HANDLE)Handle);
  }
  Information = (_KEY_VALUE_FULL_INFORMATION *)-2000000i64;
  RtlFreeAnsiString(&UnicodeString);
  v10 = a3(a1, a4, &UnicodeString);
  if( v10 < 0 )
  {
    if( RegistryValue >= 0 )
      v4 = v8;
    do
    {
      if( v4 <= 0 )
        break;
      KeDelayExecutionThread(0, 0, (_LARGE_INTEGER *)&Information);
      v4 -= 200;
      RtlFreeAnsiString(&UnicodeString);
      v10 = a3(a1, a4, &UnicodeString);
    }
    while( v10 < 0 );
    if( v10 < 0 )
    {
      HeadlessKernelAddLogEntry(0x15ui64, 0i64);
      KeBugCheckEx(0x7Bu, &UnicodeString, (PVOID)v10, 0i64, (PVOID)a2);
    }
  }
  RtlFreeAnsiString(&UnicodeString);
  return 0i64;
}

Referenced by:

IopInitializeBootDrivers
VhdInitialize