IopLoadBootHotPatches

INT64 __stdcall IopLoadBootHotPatches(){
  unsigned int *PoolWithTag; 
  int v2; 
  unsigned int v3; 
  NTSTATUS v4; 
  unsigned int v5; 
  unsigned int v6; 
  __int64 v7; 
  int v8; 
  NTSTATUS v9; 
  UINT64 Length; 
  UINT64 ResultLength; 
  wchar_t *EndPtr; 
  void *KeyHandle; 
  UNICODE_STRING SourceString; 
  struct _OBJECT_ATTRIBUTES ObjectAttributes; 
  wchar_t Str[8]; 
  __int16 v17; 
  *(_QWORD *)&ObjectAttributes.Length = 48i64;
  KeyHandle = 0i64;
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.ObjectName = (_UNICODE_STRING *)L"vx";
  *(_QWORD *)&ObjectAttributes.Attributes = 576i64;
  LODWORD(ResultLength) = 0;
  SourceString = 0i64;
  EndPtr = 0i64;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  if( ZwOpenKey(&KeyHandle, 9u, &ObjectAttributes) < 0 )
    return 1i64;
  PoolWithTag = 0i64;
  v17 = 0;
  v2 = 0;
  v3 = 0;
  while( 1 )
  {
    while( 1 )
    {
      LODWORD(Length) = v2;
      v4 = ZwEnumerateValueKey(KeyHandle, v3, KeyValueFullInformation, PoolWithTag, Length, &ResultLength);
      v5 = v4;
      if( v4 < 0 )
        break;
      if( PoolWithTag[1] == 3 )
      {
        v6 = PoolWithTag[3];
        if( v6 >= 4 )
        {
          v7 = PoolWithTag[2];
          v8 = *(unsigned __int16 *)((char *)PoolWithTag + v7);
          if( (v8 & 1) == 0 && v8 + 2 == v6 && PoolWithTag[4] == 32 )
          {
            *(_OWORD *)Str = *(_OWORD *)(PoolWithTag + 5);
            wcstoul(Str, &EndPtr, 16i64);
            if( EndPtr == (wchar_t *)&v17 )
            {
              *(_OWORD *)Str = *(_OWORD *)(PoolWithTag + 9);
              wcstoul(Str, &EndPtr, 16i64);
              if( EndPtr == (wchar_t *)&v17 )
              {
                SourceString.Buffer = (wchar_t *)((char *)PoolWithTag + v7 + 2);
                SourceString.Length = *(_WORD *)((char *)PoolWithTag + v7);
                SourceString.MaximumLength = SourceString.Length;
                v9 = MmRegisterHotPatch(&SourceString);
                v5 = v9;
                if( v9 < 0 && v9 != -1073741515 && v9 != -1073741735 )
                  goto LABEL_25;
              }
            }
          }
        }
      }
      ++v3;
    }
    if( v4 != -1073741789 && v4 != -2147483643 )
      break;
    if( PoolWithTag )
      ExFreePoolWithTag(PoolWithTag, 0);
    PoolWithTag = (unsigned int *)ExAllocatePoolWithTag(PagedPool, (unsigned int)ResultLength, 0x70486F49ui64);
    if( !PoolWithTag )
    {
      v5 = -1073741670;
      goto LABEL_25;
    }
    v2 = ResultLength;
  }
  if( v4 == -2147483622 )
    v5 = 0;
LABEL_25:
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0);
  ZwClose(KeyHandle);
  return v5;
}

Referenced by:

IoInitSystemPreDrivers