SleepstudyHelperBuildBlocker

INT64 __fastcall SleepstudyHelperBuildBlocker(PVOID P, _QWORD *a2){
  __int64 v2; 
  _QWORD *NonPaged; 
  _QWORD *v4; 
  UINT32 v7; 
  _QWORD *PoolWithTag; 
  __int64 v9; 
  ULONG_PTR *v10; 
  void *v11; 
  _QWORD *v12; 
  __int64 v13; 
  ULONG_PTR *v14; 
  ULONG_PTR **v15; 
  unsigned int v16; 
  v2 = *(_QWORD *)P;
  NonPaged = 0i64;
  v4 = 0i64;
  v7 = *(_DWORD *)(*(_QWORD *)P + 24i64);
  if( a2 )
  {
    NonPaged = (_QWORD *)SSHSupportAllocateNonPaged(0x128ui64, v7);
    PoolWithTag = ExAllocatePoolWithTag(PagedPool, 0x70ui64, v7);
    v4 = PoolWithTag;
    if( NonPaged && PoolWithTag )
    {
      memset((INT64)(NonPaged + 1), 0i64);
      memset((INT64)v4, 0i64);
      NonPaged[36] = v4;
      v4[13] = NonPaged;
      *NonPaged = 0i64;
      *((_DWORD *)v4 + 24) = 1;
      if( *((_BYTE *)P + 72) )
        *((_DWORD *)NonPaged + 2) |= 4u;
      v9 = *((_QWORD *)P + 8);
      if( v9 )
      {
        NonPaged[35] = v9;
        _InterlockedAdd((volatile signed __int32 *)(*(_QWORD *)(v9 + 288) + 96i64), 1u);
      }
      v4[1] = v4;
      v10 = v4 + 2;
      v4[3] = v4 + 2;
      v11 = (void *)(v2 + 16);
      v4[2] = v4 + 2;
      *v4 = v4;
      v4[4] = v2;
      *((_DWORD *)v4 + 10) = *((_DWORD *)P + 2);
      *((_OWORD *)v4 + 3) = *((_OWORD *)P + 1);
      *((_OWORD *)v4 + 4) = *((_OWORD *)P + 2);
      *((_OWORD *)v4 + 5) = *((_OWORD *)P + 3);
      *((_OWORD *)P + 3) = 0i64;
      ExAcquirePushLockExclusiveEx(v2 + 16, 0i64);
      v12 = *(_QWORD **)(v2 + 48);
      v13 = v2 + 40;
      if( *v12 != v13 )
        goto LABEL_14;
      *v4 = v13;
      v4[1] = v12;
      *v12 = v4;
      *(_QWORD *)(v13 + 8) = v4;
      SSHSupportReleasePushLockExclusive(v11);
      v14 = &SshpBlockerCollections + 4 * *((int *)v4 + 10);
      ExAcquirePushLockExclusiveEx((UINT64)v14, 0i64);
      v15 = (ULONG_PTR **)v14[3];
      if( *v15 != v14 + 2 )
LABEL_14:
        __fastfail(3u);
      *v10 = (ULONG_PTR)(v14 + 2);
      v10[1] = (ULONG_PTR)v15;
      *v15 = v10;
      v14[3] = (ULONG_PTR)v10;
      if( *((_BYTE *)v14 + 8) )
      {
        *((_DWORD *)NonPaged + 2) |= 2u;
        NonPaged[2] = SSHSupportQueryInterruptTime();
      }
      SSHSupportReleasePushLockExclusive(v14);
      SleepstudyHelperDestroyBlockerBuilder(P);
      v16 = 0;
      *a2 = NonPaged;
      return v16;
    }
    v16 = -1073741670;
  }
  else
  {
    v16 = 0;
  }
  if( NonPaged )
    CmpFreeTransientPoolWithTag(NonPaged, v7);
  if( v4 )
    CmpFreeTransientPoolWithTag(v4, v7);
  return v16;
}

Referenced by:

SleepstudyHelper_RegisterComponentEx
SleepstudyHelper_RegisterPdoWithParentGuid
SleepstudyHelper_RegisterPdoWithParentHandle
SleepstudyHelper_RegisterPdoWithParentPdo