PiDqGetRelativeObjectRegPath

INT64 __fastcall PiDqGetRelativeObjectRegPath(WCHAR *a1, INT64 a2, VOID **a3){
  int v4; 
  VOID *pszDest; 
  __int64 v7; 
  __int64 v8; 
  int v9; 
  int DeviceInterfaceRegKeyPath; 
  unsigned int v11; 
  int v13; 
  int v14; 
  int v15; 
  int v16; 
  __int16 v17; 
  int v18; 
  size_t cchDest; 
  v4 = a2;
  pszDest = ExAllocatePoolWithTag(PagedPool, 0x800ui64, 0x58706E50ui64);
  *a3 = pszDest;
  if( !pszDest )
  {
    v11 = -1073741670;
    goto LABEL_13;
  }
  v9 = v4 - 1;
  if( !v9 )
  {
    LODWORD(cchDest) = 1024;
    CmGetDeviceRegKeyPath(PiPnpRtlCtx, a1, 16, 0, 0, (NTSTRSAFE_PWSTR)pszDest, cchDest, 0i64);
    goto LABEL_4;
  }
  v13 = v9 - 1;
  if( !v13 )
  {
    v17 = 32;
    goto LABEL_20;
  }
  v14 = v13 - 1;
  if( !v14 )
  {
    LODWORD(cchDest) = 1024;
    DeviceInterfaceRegKeyPath = CmGetDeviceInterfaceRegKeyPath(v7, a1, 48, 0, v18, (__int64)pszDest, cchDest, 0i64);
    goto LABEL_4;
  }
  v15 = v14 - 1;
  if( !v15 )
  {
    v17 = 64;
LABEL_20:
    LODWORD(cchDest) = 1024;
    CmGetCommonClassRegKeyPath(v7, a1, v17, 0, v18, (NTSTRSAFE_PWSTR)pszDest, cchDest, 0i64);
LABEL_4:
    v11 = DeviceInterfaceRegKeyPath;
    if( DeviceInterfaceRegKeyPath >= 0 )
      return v11;
    goto LABEL_13;
  }
  v16 = v15 - 1;
  if( !v16 )
  {
    LODWORD(cchDest) = 1024;
    CmGetDeviceContainerRegKeyPath(v7, a1, 80, v8, v18, (NTSTRSAFE_PWSTR)pszDest, cchDest, 0i64);
    goto LABEL_4;
  }
  if( v16 == 1 )
  {
    LODWORD(cchDest) = 1024;
    CmGetDevicePanelRegKeyPath(v7, a1, 96, v8, v18, (NTSTRSAFE_PWSTR)pszDest, cchDest, 0i64);
    goto LABEL_4;
  }
  v11 = -1073741811;
LABEL_13:
  if( *a3 )
  {
    ExFreePoolWithTag(*a3, 0x58706E50u);
    *a3 = 0i64;
  }
  return v11;
}

Referenced by:

PiDqDeleteUserObject
PiDqOpenUserObjectRegKey