PnpOpenPropertiesKey

__int64 __fastcall PnpOpenPropertiesKey(__int64 a1, VOID *a2, wchar_t *a3, unsigned int a4, char a5, int a6, INT64 a7){
  NTSTATUS v7; 
  VOID **v9; 
  WCHAR *PoolWithTag; 
  VOID *v11; 
  unsigned int v12; 
  unsigned int v14; 
  __int64 v15; 
  NTSTATUS v16; 
  __int64 v18; 
  NTSTATUS Key; 
  VOID **PropertiesSecurityDescriptor; 
  VOID *v21; 
  NTSTATUS Tree; 
  UINT64 dwFlags; 
  UINT64 dwFlagsa; 
  VOID *hKey; 
  _SIZE_T pcchLength[2]; 
  _NTSTRSAFE_PWSTR pszDest[32]; 

  v7 = 0;
  *(_QWORD *)pcchLength = 0i64;
  v9 = 0i64;
  hKey = a2;
  PoolWithTag = 0i64;
  *(_QWORD *)a7 = 0i64;
  v11 = 0i64;
  v12 = a4;
  if( a3 )
  {
    v7 = RtlUnalignedStringCchLengthW(a3, 512, pcchLength);
    if( v7 < 0 )
      return(unsigned int)v7;
    if( *(_QWORD *)pcchLength >= 0x30ui64 )
    {
      v14 = pcchLength[0] + 12;
      PoolWithTag = (WCHAR *)ExAllocatePoolWithTag(1ui64, 2i64 * (unsigned int)(pcchLength[0] + 12), 1380994640i64);
      if( !PoolWithTag )
        return(unsigned int)-1073741801;
    }
    else
    {
      PoolWithTag = (WCHAR *)pszDest;
      v14 = 59;
    }
    LODWORD(dwFlags) = 2048;
    v7 = RtlStringCchPrintfExW(PoolWithTag, v14, 0i64, 0i64, dwFlags, (WCHAR *)L"%s\\%s");
    if( v7 < 0 )
      goto LABEL_11;
    if( a1 )
      v15 = *(_QWORD *)(a1 + 224);
    else
      v15 = 0i64;
    v16 = SysCtxRegOpenKey(v15, hKey, PoolWithTag, 0, a4, (VOID **)a7);
    if( v16 == -1073741444 )
    {
      v7 = -1073741772;
      goto LABEL_11;
    }
    if( !a5 || v16 != -1073741772 )
    {
      v7 = v16;
      goto LABEL_11;
    }
    v12 = a4;
    a2 = hKey;
  }
  if( a1 )
    v18 = *(_QWORD *)(a1 + 224);
  else
    v18 = 0i64;
  Key = SysCtxRegOpenKey(v18, a2, L"Properties", 0, v12, (VOID **)a7);
  if( Key != -1073741772 )
    goto LABEL_29;
  if( !a5 )
  {
LABEL_21:
    v7 = Key;
    goto LABEL_22;
  }
  PropertiesSecurityDescriptor = PnpGetPropertiesSecurityDescriptor();
  v9 = PropertiesSecurityDescriptor;
  if( PropertiesSecurityDescriptor )
  {
    if( !RtlValidSecurityDescriptor(PropertiesSecurityDescriptor) )
    {
      v7 = -1073741595;
      goto LABEL_22;
    }
    LODWORD(dwFlagsa) = a4;
    Key = PnpCtxRegCreateKey((HPNPCTX *)a1, hKey, (WCHAR *)L"Properties", 0i64, dwFlagsa, v9, (VOID **)a7, 0i64);
LABEL_29:
    if( Key != -1073741444 )
    {
      if( Key < 0 )
        goto LABEL_21;
      if( !a3 )
      {
LABEL_22:
        if( v9 )
          ExFreePoolWithTag(v9, 0);
        goto LABEL_11;
      }
      v11 = *(VOID **)a7;
      v21 = *(VOID **)a7;
      *(_QWORD *)a7 = 0i64;
      LODWORD(dwFlagsa) = a4;
      Tree = PnpCtxRegCreateTree((HPNPCTX *)a1, v21, a3, 0i64, dwFlagsa, 0i64, (VOID **)a7, 0i64);
      if( Tree != -1073741444 )
      {
        if( Tree < 0 )
          v7 = Tree;
        goto LABEL_22;
      }
    }
    v7 = -1073741772;
    goto LABEL_22;
  }
  v7 = -1073741595;
LABEL_11:
  if( PoolWithTag && PoolWithTag != (WCHAR *)pszDest )
    ExFreePoolWithTag(PoolWithTag, 0);
  if( v11 )
    ZwClose((_HANDLE)v11);
  return(unsigned int)v7;
}

Referenced by:

CmDeleteInstallerClassMappedPropertyFromRegValue
CmDeleteInterfaceClassMappedPropertyFromRegValue
CmGetInstallerClassMappedPropertyFromRegValue
CmGetInstallerClassRegPropWorker
CmGetInterfaceClassMappedPropertyFromRegValue
CmSetInstallerClassMappedPropertyFromRegValue
CmSetInstallerClassRegPropWorker
CmSetInterfaceClassMappedPropertyFromRegValue
PnpDeletePropertyWorker
PnpGetGenericStoreProperty
PnpGetGenericStorePropertyKeys
PnpGetGenericStorePropertyLocales
PnpSetPropertyWorker