MiFindHotPatchRecord

INT64 __fastcall MiFindHotPatchRecord(_QWORD **a1, UINT64 a2, INT64 a3, INT64 a4, _UNICODE_STRING *StringOut, INT64 a6){
  int v6; 
  _ETHREAD *CurrentThread; 
  UNICODE_STRING *v9; 
  int v10; 
  NTSTATUS v11; 
  INT64 v13[2]; 
  __int64 v14; 
  int v15; 
  int v16; 
  __int128 v17; 
  v6 = a2;
  v14 = 0i64;
  *(_OWORD *)v13 = 0i64;
  v17 = 0i64;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  v15 = a3;
  v16 = a4;
  if( !(_DWORD)a2 )
  {
    --*((_WORD *)CurrentThread + 243);
    ExAcquirePushLockSharedEx((UINT64)&MiHotPatchListLock, a2);
  }
  v9 = (UNICODE_STRING *)*a1;
  if( !v9 )
  {
LABEL_8:
    v11 = -1073741275;
    goto LABEL_9;
  }
  while( 1 )
  {
    v10 = MiCompareHotPatchNodes((INT64)v13, (INT64)v9);
    if( v10 >= 0 )
      break;
    v9 = *(UNICODE_STRING **)&v9->Length;
LABEL_6:
    if( !v9 )
      goto LABEL_7;
  }
  if( v10 > 0 )
  {
    v9 = (UNICODE_STRING *)v9->Buffer;
    goto LABEL_6;
  }
LABEL_7:
  if( !v9 )
    goto LABEL_8;
  if( a6 )
    *(_DWORD *)a6 = MiHotPatchGeneration;
  if( !StringOut || (v11 = RtlDuplicateUnicodeString(0i64, v9 + 2, StringOut), v11 >= 0) )
    v11 = 0;
LABEL_9:
  if( !v6 )
  {
    if( _InterlockedCompareExchange64((volatile signed __int64 *)&MiHotPatchListLock, 0i64, 17i64) != 17 )
      ExfReleasePushLockShared((INT64 *)&MiHotPatchListLock);
    KeAbPostRelease(&MiHotPatchListLock);
    KiLeaveGuardedRegionUnsafe((__int64)CurrentThread);
  }
  return(unsigned int)v11;
}

Referenced by:

MiApplyRequiredDriverHotPatches
MiFindProcessImageHotPatchRecord