PopDirectedDripsDiagBroadcastTreeBegin

VOID __fastcall PopDirectedDripsDiagBroadcastTreeBegin(INT64 a1, CHAR a2, INT64 *a3){
  CHAR *DeviceDiagnostic; 
  int v7; 
  PVOID *v8; 
  INT64 v9; 
  VOID *PoolWithTag; 
  INT64 *v11; 
  char v12; 
  *a3 = 0i64;
  ExAcquirePushLockExclusiveEx((UINT64)&PopDirectedDripsDiagLock, 0i64);
  DeviceDiagnostic = *(CHAR **)(a1 + 776);
  if( DeviceDiagnostic || (DeviceDiagnostic = PopDirectedDripsDiagCreateDeviceDiagnostic(a1)) != 0i64 )
  {
    v7 = *((_DWORD *)DeviceDiagnostic + 37);
    if( v7 == -1 )
    {
      *((_DWORD *)DeviceDiagnostic + 37) = dword_140C1EB84++;
      v7 = *((_DWORD *)DeviceDiagnostic + 37);
    }
    v8 = (PVOID *)PopDirectedDripsDiagSessionContext;
    if( PopDirectedDripsDiagSessionContext == &PopDirectedDripsDiagSessionContext )
      goto LABEL_9;
    do
    {
      v9 = (INT64)v8;
      if( *((_DWORD *)v8 + 8) == v7 )
        break;
      v8 = (PVOID *)*v8;
      v9 = 0i64;
    }
    while( v8 != &PopDirectedDripsDiagSessionContext );
    if( !v9 )
    {
LABEL_9:
      PoolWithTag = ExAllocatePoolWithTag(PagedPool, 0xE8ui64, 0x67696450ui64);
      v9 = (INT64)PoolWithTag;
      if( !PoolWithTag )
        goto LABEL_14;
      memset((INT64)PoolWithTag, 0i64);
      *(_DWORD *)(v9 + 32) = v7;
      *(_QWORD *)(v9 + 16) = DeviceDiagnostic;
      v11 = (INT64 *)qword_140C1E988;
      if( *(PVOID **)qword_140C1E988 != &PopDirectedDripsDiagSessionContext )
        __fastfail(3u);
      *(_QWORD *)v9 = &PopDirectedDripsDiagSessionContext;
      *(_QWORD *)(v9 + 8) = v11;
      *v11 = v9;
      qword_140C1E988 = v9;
    }
    *(_QWORD *)(v9 + 48) = PopDirectedDripsDiagGetDeviceActiveStamp(*(_QWORD *)(a1 + 80));
    *(_DWORD *)(v9 + 36) = dword_140C1EB88;
    v12 = a2 ^ *(_DWORD *)(v9 + 40);
    *a3 = v9;
    *(_DWORD *)(v9 + 40) ^= v12 & 0xF;
    *((_DWORD *)DeviceDiagnostic + 38) |= 0x60000u;
  }
LABEL_14:
  if( (_InterlockedExchangeAdd64((volatile signed __int64 *)&PopDirectedDripsDiagLock, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
    ExfTryToWakePushLock((volatile INT64 *)&PopDirectedDripsDiagLock);
  KeAbPostRelease(&PopDirectedDripsDiagLock);
}

Referenced by:

PopDirectedDripsBuildBroadcastTreePartial