SleepstudyHelperBuildBlocker

NTSTATUS __fastcall SleepstudyHelperBuildBlocker(PVOID P, _EX_PUSH_LOCK **a2){
  _EX_PUSH_LOCK *v2; 
  _EX_PUSH_LOCK *v3; 
  VOID **v4; 
  ULONG v7; 
  _EX_PUSH_LOCK *v8; 
  VOID **PoolWithTag; 
  __int64 v10; 
  char *v11; 
  ULONG_PTR v12; 
  _EX_PUSH_LOCK **bf_0; 
  _EX_PUSH_LOCK *v14; 
  _EX_PUSH_LOCK *v15; 
  char **v16; 
  NTSTATUS v17; 
  __int64 v19; 

  v2 = *(_EX_PUSH_LOCK **)P;
  v3 = 0i64;
  v4 = 0i64;
  v7 = *(_DWORD *)(*(_QWORD *)P + 24i64);
  if( a2 )
  {
    LODWORD(v8) = SSHSupportAllocateNonPaged(296, v7);
    v3 = v8;
    PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x70ui64, v7);
    v4 = PoolWithTag;
    if( v3 && PoolWithTag )
    {
      memset(&v3[1], 0i64, 0x118u);
      memset(v4, 0i64, 0x68u);
      v3[36]._bf_0 = (__int64)v4;
      v4[13] = v3;
      v3->_bf_0 = 0i64;
      *((_DWORD *)v4 + 24) = 1;
      if( *((_BYTE *)P + 72) )
        LODWORD(v3[1]._bf_0) |= 4u;
      v10 = *((_QWORD *)P + 8);
      if( v10 )
      {
        v3[35]._bf_0 = v10;
        _InterlockedAdd((volatile signed __int32 *)(*(_QWORD *)(v10 + 288) + 96i64), 1u);
      }
      v4[1] = v4;
      v11 = (char *)(v4 + 2);
      v4[3] = v4 + 2;
      v12 = (_DWORD)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 + 2, 0i64);
      bf_0 = (_EX_PUSH_LOCK **)v2[6]._bf_0;
      v14 = v2 + 5;
      if( *bf_0 != v14 )
        goto LABEL_14;
      *v4 = v14;
      v4[1] = bf_0;
      *bf_0 = (_EX_PUSH_LOCK *)v4;
      v14[1]._bf_0 = (__int64)v4;
      SSHSupportReleasePushLockExclusive(v12);
      v15 = (_EX_PUSH_LOCK *)((char *)&SshpBlockerCollections + 32 * *((int *)v4 + 10));
      ExAcquirePushLockExclusiveEx(v15, 0i64);
      v16 = (char **)v15[3]._bf_0;
      if( *v16 != (char *)&v15[2] )
LABEL_14:
        __fastfail(3u);
      *(_QWORD *)v11 = v15 + 2;
      *((_QWORD *)v11 + 1) = v16;
      *v16 = v11;
      v15[3]._bf_0 = (__int64)v11;
      if( LOBYTE(v15[1]._bf_0) )
      {
        LODWORD(v3[1]._bf_0) |= 2u;
        LODWORD(v19) = SSHSupportQueryInterruptTime();
        v3[2]._bf_0 = v19;
      }
      SSHSupportReleasePushLockExclusive((ULONG_PTR)v15);
      SleepstudyHelperDestroyBlockerBuilder(P);
      v17 = 0;
      *a2 = v3;
      return v17;
    }
    v17 = -1073741670;
  }
  else
  {
    v17 = 0;
  }
  if( v3 )
    CmpFreeTransientPoolWithTag(v3, v7);
  if( v4 )
    CmpFreeTransientPoolWithTag(v4, v7);
  return v17;
}

Referenced by:

SleepstudyHelper_RegisterComponentEx
SleepstudyHelper_RegisterPdoWithParentGuid
SleepstudyHelper_RegisterPdoWithParentHandle
SleepstudyHelper_RegisterPdoWithParentPdo