IopGetPersistedStateLocation

INT64 __fastcall IopGetPersistedStateLocation(INT64 a1, _WORD *a2, INT64 a3, CHAR **a4){
  UINT64 v6; 
  VOID *PoolWithTag; 
  int PersistedStateLocation; 
  INT64 result; 
  UINT64 v10; 
  UINT64 v11; 
  LODWORD(v11) = 0;
  v6 = 256i64;
  while( 1 )
  {
    PoolWithTag = ExAllocatePoolWithTag(PagedPool, v6, 0x63466F49ui64);
    if( !PoolWithTag )
    {
      PersistedStateLocation = -1073741670;
      goto LABEL_10;
    }
    LODWORD(v10) = v6;
    PersistedStateLocation = RtlGetPersistedStateLocation(
                               (WCHAR *)L"SecureDeviceClass",
                               0i64,
                               a2,
                               0i64,
                               PoolWithTag,
                               v10,
                               &v11);
    if( PersistedStateLocation != -2147483643 )
      break;
    if( (unsigned int)v11 <= (unsigned int)v6 )
    {
      PersistedStateLocation = -1073741595;
      break;
    }
    v6 = (unsigned int)v11;
    ExFreePoolWithTag(PoolWithTag, 0);
  }
  if( PersistedStateLocation >= 0 )
    goto LABEL_5;
LABEL_10:
  if( PoolWithTag )
  {
    ExFreePoolWithTag(PoolWithTag, 0);
    PoolWithTag = 0i64;
  }
LABEL_5:
  result = (unsigned int)PersistedStateLocation;
  *a4 = (CHAR *)PoolWithTag;
  return result;
}

Referenced by:

IopCreateSecureDeviceClassSettings