PopDirectedDripsDiagBroadcastTreeBegin

VOID __stdcall PopDirectedDripsDiagBroadcastTreeBegin(INT64 a1, CHAR a2, INT64 *a3){
  CHAR *DeviceDiagnostic; 
  int v7; 
  PVOID *v8; 
  INT64 v9; 
  VOID **PoolWithTag; 
  INT64 *v11; 
  __int64 v12; 

  *a3 = 0i64;
  ExAcquirePushLockExclusiveEx(&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(1ui64, 0xE8ui64, 1734960208i64);
      v9 = (INT64)PoolWithTag;
      if( !PoolWithTag )
        goto LABEL_14;
      memset(PoolWithTag, 0i64, 0xE8u);
      *(_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;
    }
    LODWORD(v12) = PopDirectedDripsDiagGetDeviceActiveStamp(*(_QWORD *)(a1 + 80));
    *(_QWORD *)(v9 + 48) = v12;
    *(_DWORD *)(v9 + 36) = dword_140C1EB88;
    LOBYTE(v12) = a2 ^ *(_DWORD *)(v9 + 40);
    *a3 = v9;
    *(_DWORD *)(v9 + 40) ^= v12 & 0xF;
    *((_DWORD *)DeviceDiagnostic + 38) |= 0x60000u;
  }
LABEL_14:
  if( (_InterlockedExchangeAdd64(&PopDirectedDripsDiagLock._bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
    ExfTryToWakePushLock(&PopDirectedDripsDiagLock);
  KeAbPostRelease(&PopDirectedDripsDiagLock);
}

Referenced by:

PopDirectedDripsBuildBroadcastTreePartial