PfSnBeginAppLaunch

__int64 __fastcall PfSnBeginAppLaunch(_DWORD *a1, unsigned __int16 *a2, int a3){
  void *v6; 
  unsigned int v7; 
  int v8; 
  UINT8 *ImageFileName; 
  __int64 v10; 
  __int64 v11; 
  int v12; 
  UINT8 IsHostingApplication; 
  int v14; 
  int v16; 
  UINT64 HashId; 
  __int64 v18; 
  UINT64 NameNumCharsOut; 
  int v20; 
  __int128 v21; 
  wchar_t SubStr[30]; 
  int v23; 
  __int16 v24[128]; 
  v20 = 0;
  NameNumCharsOut = 0i64;
  v18 = 0i64;
  LODWORD(HashId) = 0;
  v6 = 0i64;
  memset((INT64)SubStr, 0i64);
  v7 = 0;
  v8 = PfSnCheckScenario(0, &v20);
  if( v8 < 0 )
    goto LABEL_17;
  if( !a2 )
  {
    v16 = PfCalculateProcessHash((__int64)a1, (unsigned __int64)&v18);
    v6 = (void *)v18;
    v8 = v16;
    if( v16 < 0 )
    {
LABEL_17:
      PfSnLogScenarioDecision((__int64)SubStr, 0, 0i64, 15, 15, v8, -1i64);
      goto LABEL_14;
    }
    a2 = (unsigned __int16 *)v18;
  }
  v21 = *(_OWORD *)a2;
  ImageFileName = (UINT8 *)PfSnFindImageFileName((UNICODE_STRING *)a2, &NameNumCharsOut);
  if( !ImageFileName )
  {
    v8 = -1073741811;
    goto LABEL_17;
  }
  v10 = (unsigned int)NameNumCharsOut;
  if( (unsigned int)NameNumCharsOut >= 0x1D )
    v10 = 29i64;
  v11 = v10;
  memmove((UINT8 *)SubStr, ImageFileName, 2 * v10);
  v12 = a1[381];
  SubStr[v11] = 0;
  v23 = v12;
  IsHostingApplication = PfSnIsHostingApplication(SubStr);
  v8 = PfSnScanCommandLine(&HashId, IsHostingApplication);
  if( v8 < 0 )
    goto LABEL_17;
  v23 += HashId;
  v18 = 256i64;
  v8 = PfSnCheckModernApp((UINT64 *)((char *)&NameNumCharsOut + 4), &HashId);
  if( v8 < 0 )
    goto LABEL_17;
  v14 = v23;
  if( HIDWORD(NameNumCharsOut) )
  {
    v14 = HashId + v23;
    *((_QWORD *)&v21 + 1) = v24;
    v7 = 8;
    LOWORD(v21) = v18;
    WORD1(v21) = v18;
  }
  v23 = a3 + v14;
  if( (dword_140C50290 & 0x20) != 0 || v20 == 2 )
    v7 |= 2u;
  v8 = PfSnBeginScenario(a1, (unsigned __int8 *)SubStr, 0, v7, (const void **)&v21);
  if( v8 >= 0 )
    v8 = 0;
LABEL_14:
  if( v6 )
    ExFreePoolWithTag(v6, 0);
  return(unsigned int)v8;
}

Referenced by:

PfProcessCreateNotification
PfSnAppLaunchScenarioControl