SMKM_STORE_MGR::SmPageWrite

__int64 __fastcall SMKM_STORE_MGR::SmPageWrite(
        __int64 a1,
        _DWORD *a2,
        int a3,
        __int64 a4,
        __int64 a5,
        __int64 *a6,
        int a7){
  __int64 *v7; 
  PSLIST_ENTRY PoolWithTag; 
  VOID *v9; 
  UINT64 v10; 
  _DWORD *v14; 
  _DWORD *v15; 
  __int64 v16; 
  _DWORD *v17; 
  unsigned int v18; 
  int v19; 
  int v20; 
  VOID *v21; 
  bool v22; 
  int v23; 
  UINT64 v25; 
  INT64 v26; 
  unsigned int v27; 
  int v28; 
  unsigned int v29; 
  _EX_RUNDOWN_REF *v30; 
  UINT64 v31; 
  UINT64 Priority; 
  __int64 *v34; 
  int v35; 

  v7 = a6;
  PoolWithTag = 0i64;
  v9 = 0i64;
  v34 = a6;
  v10 = a3 & 0x7FF;
  a6[1] = 0i64;
  *v7 = a5;
  v35 = *(_DWORD *)(a4 + 40) >> 12;
  if( (_DWORD)v10 == 1024 || (v14 = SmKmStoreReferenceEx((_SMKM_STORE_LIST *)a1, v10), (v15 = v14) == 0i64) )
  {
    v23 = -1073741811;
    goto LABEL_29;
  }
  LODWORD(a6) = 0;
  v16 = (unsigned __int16)a3 >> 13;
  ST_STORE::StDmGetSpaceStats((__int64)(v14 + 20), &a6, 0i64);
  if( v15[234] <= (unsigned int)a6 )
  {
    v27 = v15[2 * v16 + 477];
    v28 = v15[2 * v16 + 476];
    v29 = v28 * (v15[216] >> 4);
    if( v29 >= v27 && v29 - v27 < v28 << 8 )
    {
      v23 = -1073741110;
      goto LABEL_23;
    }
  }
  if( (a3 & 0x40000) != 0 && (unsigned int)(v16 - 5) <= 1 )
    LODWORD(v16) = 6;
  if( (_DWORD)v16 == 6 )
    SMKM_STORE_MGR::SmHighMemPriorityTimerStart(a1);
  if( (*(_DWORD *)(a1 + 1840) & 0x20) == 0 || (*v15 & 0x400) != 0 )
  {
    v25 = 40i64;
    v26 = 1767337331i64;
  }
  else
  {
    PoolWithTag = RtlpInterlockedPopEntrySList((PSLIST_HEADER)(a1 + 1408));
    if( PoolWithTag )
      goto LABEL_10;
    v25 = 4096i64;
    v26 = 2002218355i64;
  }
  PoolWithTag = (PSLIST_ENTRY)ExAllocatePoolWithTag(0x200ui64, v25, v26);
  if( !PoolWithTag )
  {
    v23 = -1073741670;
    goto LABEL_23;
  }
LABEL_10:
  v17 = a2;
  *PoolWithTag = 0i64;
  PoolWithTag[1] = 0i64;
  PoolWithTag[2].Next = 0i64;
  *((_DWORD *)&PoolWithTag[1].Next + 2) = *a2;
  v18 = *(_DWORD *)(&PoolWithTag->Next + 1) & 0xFFFFFFF8;
  PoolWithTag[1].Next = (_SLIST_ENTRY *)a4;
  v19 = v16 | v18;
  *((_DWORD *)&PoolWithTag->Next + 2) = v19;
  if( (a3 & 0x10000) != 0 )
  {
    v19 |= 0x40000000u;
    *((_DWORD *)&PoolWithTag->Next + 2) = v19;
  }
  if( (a3 & 0x20000) != 0 )
    *((_DWORD *)&PoolWithTag->Next + 2) = v19 | 0x40000000;
  PoolWithTag[2].Next = (_SLIST_ENTRY *)v7;
  v20 = v15[1504] & 0x3FF;
  if( (*(_DWORD *)(a1 + 1840) & 2) != 0 )
  {
    if( (*(_BYTE *)(a4 + 10) & 5) != 0 )
    {
      v9 = *(VOID **)(a4 + 24);
    }
    else
    {
      LODWORD(Priority) = 1073741856;
      LODWORD(v31) = 0;
      v21 = MmMapLockedPagesSpecifyCache((_MDL *)a4, 0, MmCached, 0i64, v31, Priority);
      v17 = a2;
      v9 = v21;
    }
    if( !v9 )
    {
      v23 = -1073741688;
      goto LABEL_23;
    }
  }
  if( (*(_DWORD *)(a1 + 1840) & 0x20) == 0 || (*v15 & 0x400) != 0 )
  {
    v23 = SMKM_STORE_MGR::SmFeAddInitiate(a1, v17, v35, v20, (unsigned __int64)PoolWithTag, v7, 0);
    if( v23 < 0 )
      goto LABEL_23;
    goto LABEL_22;
  }
  v22 = a7 != 0;
  a7 = -a7;
  v23 = SMKM_STORE_MGR::SmFeAddInitiate(a1, v17, v35, v20, 0i64, 0i64, v22 + 2);
  if( v23 >= 0 )
  {
    memset(&PoolWithTag[2].Next + 1, 0i64, 0x58u);
    *((_QWORD *)&PoolWithTag[7].Next + 1) = PoolWithTag;
    *((_QWORD *)&PoolWithTag[6].Next + 1) = v15;
    SMKM_STORE_MGR::SmCompressContextQueueEntry((INT64 *)(a1 + 1264), (__int64)(&PoolWithTag[2].Next + 1));
LABEL_22:
    v15 = 0i64;
    PoolWithTag = 0i64;
    v9 = 0i64;
    v23 = 259;
    v34 = 0i64;
  }
LABEL_23:
  if( v15 )
  {
    v30 = (_EX_RUNDOWN_REF *)SmKmStoreRefFromStoreIndex(a1, v15[1504] & 0x3FF);
    ExReleaseRundownProtection(v30 + 1);
  }
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0);
  if( v9 )
    MmUnmapLockedPages(v9, (_MDL *)a4);
LABEL_29:
  if( v34 )
  {
    *(_OWORD *)v7 = 0i64;
    *(_DWORD *)v7 = v23;
  }
  return(unsigned int)v23;
}

Referenced by:

No references.