PnpConcatPWSTR

__int64 __fastcall PnpConcatPWSTR(UINT64 cchMax, UINT32 Tag, PVOID *a3, unsigned __int64 a4){
  UINT64 v7; 
  unsigned __int64 v8; 
  WCHAR **v9; 
  NTSTATUS v10; 
  __int64 v11; 
  VOID **PoolWithTag; 
  unsigned __int64 v13; 
  unsigned __int64 v14; 
  WCHAR **v15; 
  UINT64 pullResult; 
  __int64 pcchLength[2]; 
  unsigned __int64 v19; 

  v19 = a4;
  pcchLength[0] = 0i64;
  pullResult = 0i64;
  *a3 = 0i64;
  v7 = 1i64;
  v8 = 0i64;
  if( a4 )
  {
    v9 = (WCHAR **)&v19;
    do
    {
      if( *++v9 )
      {
        v10 = RtlStringCchLengthW(*v9, cchMax, (UINT64 *)pcchLength);
        if( v10 < 0 )
          goto LABEL_19;
        v7 = pcchLength[0] + v11;
        a4 = v19;
      }
      ++v8;
    }
    while( v8 < a4 );
  }
  if( v7 > cchMax )
  {
    v10 = -1073741811;
    goto LABEL_19;
  }
  v10 = RtlULongLongMult(v7, 2ui64, &pullResult);
  if( v10 < 0 )
    goto LABEL_19;
  PoolWithTag = ExAllocatePoolWithTag(1ui64, pullResult, Tag);
  *a3 = PoolWithTag;
  if( !PoolWithTag )
  {
    v10 = -1073741670;
LABEL_19:
    if( *a3 )
    {
      ExFreePoolWithTag(*a3, Tag);
      *a3 = 0i64;
    }
    return(unsigned int)v10;
  }
  *(_WORD *)PoolWithTag = 0;
  v13 = v19;
  v14 = 0i64;
  if( v19 )
  {
    v15 = (WCHAR **)&v19;
    do
    {
      if( *++v15 )
      {
        v10 = RtlStringCbCatW((WCHAR *)*a3, pullResult, *v15);
        if( v10 < 0 )
          goto LABEL_19;
        v13 = v19;
      }
      ++v14;
    }
    while( v14 < v13 );
  }
  return(unsigned int)v10;
}

Referenced by:

PiDqOpenUserObjectRegKey
PiSwGetChildPdo
PiSwInstanceInfoInit
PiSwStopDestroy
PipCheckForDenyExecute