CcMapAndRead

UINT8 __stdcall CcMapAndRead(UINT64 Length, UINT64 ZeroFlags, UINT8 Wait, VOID *BaseAddress){
  UINT8 v4; 
  int v5; 
  _ETHREAD *CurrentThread; 
  int v7; 
  int v8; 
  int v9; 
  NTSTATUS v10; 
  char *v11; 
  unsigned __int64 v12; 
  unsigned int v13; 
  unsigned int v14; 
  int v15; 
  int v16; 
  bool v17; 
  int v19; 
  UINT8 ReturnResult; 
  UINT8 v21; 
  int v22; 
  v21 = Wait;
  v4 = 0;
  v5 = 1;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  v7 = ZeroFlags;
  v8 = 2;
  ReturnResult = 1;
  v9 = *((unsigned __int8 *)CurrentThread + 1308);
  v10 = 0;
  if( Wait )
    v8 = 0;
  v22 = v8;
  v11 = (char *)((unsigned __int64)BaseAddress & 0xFFFFFFFFFFFFF000ui64);
  v12 = (((unsigned __int16)BaseAddress & 0xFFF) + (unsigned __int64)(unsigned int)Length + 4095) >> 12;
  v13 = v9 + 4 * *((_DWORD *)CurrentThread + 322);
  if( (_DWORD)v12 )
  {
    while( 1 )
    {
      *((_BYTE *)CurrentThread + 1308) = 1;
      if( (unsigned int)(v12 - 1) > *((_DWORD *)CurrentThread + 322) )
      {
        v19 = v12 - 1;
        if( (unsigned int)(v12 - 1) > 0xF )
          v19 = 15;
        *((_DWORD *)CurrentThread + 322) = v19;
      }
      v14 = 0;
      if( v7 )
      {
        v15 = 1;
        if( v5 == 2 )
          v15 = v12 - 1;
      }
      else
      {
        v15 = v12;
      }
      LOBYTE(v14) = (v5 & v7) != 0;
      MmCheckCachedPageStates(v11, (unsigned int)(v15 << 12), v8 | v14, &ReturnResult);
      v10 = v16;
      if( !ReturnResult && !v21 )
        break;
      if( v16 < 0 )
        break;
      v8 = v22;
      v11 += (unsigned int)(v15 << 12);
      LODWORD(v12) = v12 - v15;
      v5 = 4;
      if( (_DWORD)v12 != 1 )
        v5 = 2;
      if( !(_DWORD)v12 )
        goto LABEL_12;
    }
  }
  else
  {
LABEL_12:
    v4 = 1;
  }
  v17 = v21 == 0;
  *((_DWORD *)CurrentThread + 322) = v13 >> 2;
  *((_BYTE *)CurrentThread + 1308) = v13 & 3;
  if( !v17 && v10 < 0 )
    RtlRaiseStatus(v10);
  return v4;
}

Referenced by:

CcMapData
CcPinFileData
CcPrepareMdlWrite