MiCreateDataFileMap
NTSTATUS __stdcall MiCreateDataFileMap(
_FILE_OBJECT *File,
_SEGMENT **Segment,
UINT64 *MaximumSize,
UINT64 SectionPageProtection,
UINT64 AllocationAttributes,
UINT64 PreferredNode,
_MI_CREATE_SECTION_FLAGS CreateSectionFlags){
int v8;
UINT64 QuadPart;
unsigned __int64 v11;
_OWORD *Pool;
char *v13;
__int64 v14;
int v15;
_DWORD *v16;
unsigned __int64 v17;
unsigned int v18;
__int16 v19;
int v20;
__int16 v21;
_MSUBSECTION *v22;
char v23;
__int64 v24;
__int16 v25;
__int16 v26;
_MSUBSECTION **p_NextSubsection;
__int16 v28;
unsigned int PtesInSubsection;
bool v30;
__int16 bf_2;
unsigned int v32;
NTSTATUS result;
_LARGE_INTEGER *v34;
void *v35;
__int64 v36;
_QWORD *v37;
_QWORD *v38;
_LARGE_INTEGER FileSize;
int v42;
int v43;
FileSize.QuadPart = 0i64;
v8 = v42;
v43 = v42 & 1;
if( v43 )
{
QuadPart = SectionPageProtection;
goto LABEL_3;
}
result = FsRtlGetFileSize(File, &FileSize);
if( result == -1073741638 )
return -1073741792;
if( result >= 0 )
{
QuadPart = FileSize.QuadPart;
if( !FileSize.QuadPart && !SectionPageProtection )
return -1073741538;
if( SectionPageProtection > FileSize.QuadPart )
{
if( (AllocationAttributes & 0x44) == 0 )
return -1073741760;
FileSize.QuadPart = SectionPageProtection;
QuadPart = SectionPageProtection;
result = FsRtlSetFileSize(File, &FileSize, v34);
if( result < 0 )
return result;
}
LABEL_3:
if( QuadPart <= 0x3FFFFFFFFFF000i64 )
{
v11 = (QuadPart + 4095) >> 12;
Pool = MiAllocatePool(256i64, 0x30ui64, 0x6D536D4Dui64);
if( !Pool )
return -1073741670;
v13 = (char *)MiAllocatePool(64i64, 0x128ui64, 0x61436D4Dui64);
if( !v13 )
{
v35 = Pool;
goto LABEL_52;
}
v14 = 0i64;
v15 = v8 & 0x10000;
if( v15 && v11 > 0x200 )
{
MiComputeIdealFirstSubsection(File);
v14 = 8 * v36;
}
v16 = 0i64;
FileSize.QuadPart = 0i64;
v17 = 8 * v11;
if( !v14 )
LODWORD(v14) = v15 != 0 ? 0x200000 : 0x100000;
while( 1 )
{
v18 = v17;
if( v17 >= (unsigned int)v14 )
v18 = v14;
if( v16 )
{
v16 = MiAllocatePool(64i64, 0x90ui64, 0x63536D4Dui64);
if( !v16 )
{
ExFreePoolWithTag(Pool, 0);
v37 = (_QWORD *)*((_QWORD *)v13 + 18);
if( v37 )
{
do
{
v38 = (_QWORD *)v37[2];
ExFreePoolWithTag(v37, 0);
v37 = v38;
}
while( v38 );
}
v35 = v13;
LABEL_52:
ExFreePoolWithTag(v35, 0);
return -1073741670;
}
*(_QWORD *)(FileSize.QuadPart + 16) = v16;
}
else
{
v16 = v13 + 128;
}
FileSize.QuadPart = (LONGLONG)v16;
v16[11] = v18 >> 3;
v17 -= v18;
if( !v17 )
{
*Pool = 0i64;
Pool[1] = 0i64;
*MaximumSize = (UINT64)Pool;
Pool[2] = 0i64;
*((_QWORD *)v13 + 2) = v13 + 8;
*((_QWORD *)v13 + 1) = v13 + 8;
*(_QWORD *)v13 = Pool;
*((_QWORD *)v13 + 14) = 1i64;
*((_QWORD *)v13 + 3) = 1i64;
v19 = *((_WORD *)v13 + 30) ^ *(_WORD *)Segment;
*((_QWORD *)v13 + 13) = 0i64;
*((_WORD *)v13 + 30) ^= v19 & 0x3FF;
v20 = *((_DWORD *)v13 + 14);
if( v43 )
v20 |= 0x8000u;
else
*((_QWORD *)v13 + 6) = 1i64;
v21 = 6;
*((_DWORD *)v13 + 14) = v20 ^ (v20 ^ (CreateSectionFlags.EntireFlags << 20)) & 0x3F00000 | 0x82;
if( v15 )
{
*((_DWORD *)v13 + 14) = v20 ^ (v20 ^ (CreateSectionFlags.EntireFlags << 20)) & 0x3F00000 | 0x40000082;
}
else if( (PreferredNode & 0x10000000) != 0 )
{
*((_WORD *)Pool + 6) |= 0x8000u;
v21 = 14;
}
else if( (PreferredNode & 0x40000000) != 0 )
{
v21 = 30;
*((_WORD *)Pool + 6) |= 0x4000u;
}
v22 = (_MSUBSECTION *)(v13 + 128);
v23 = *((_BYTE *)Pool + 14) & 0xC1;
*(_QWORD *)Pool = v13;
*((_QWORD *)Pool + 3) = QuadPart;
v24 = 0i64;
v25 = (*((_WORD *)Pool + 6) ^ WORD2(v11)) & 0x3FF;
*((_DWORD *)Pool + 2) = v11;
*((_WORD *)Pool + 6) ^= v25;
*((_BYTE *)Pool + 14) = (2 * v21) | v23;
v26 = 2 * v21;
do
{
p_NextSubsection = (_MSUBSECTION **)&v22->Core.NextSubsection;
v28 = v22->Core.u.SubsectionFlags._bf_0 & 1;
v22->Core.ControlArea = (_CONTROL_AREA *)v13;
PtesInSubsection = v22->Core.PtesInSubsection;
v22->Core.StartingSector = v24;
v30 = v22->Core.NextSubsection == 0i64;
v22->Core.u.SubsectionFlags._bf_0 = v26 | v28 & 0xFFC1 | (WORD2(v24) << 6);
if( v30 )
{
bf_2 = v22->Core.u.SubsectionFlags._bf_2;
v22->Core._bf_34 ^= (v22->Core._bf_34 ^ (v24 + PtesInSubsection - v11)) & 0x3FFFFFFF;
v22->Core.u.SubsectionFlags._bf_2 = (16 * QuadPart) | bf_2 & 0xF;
v32 = (QuadPart >> 12) - v24;
}
else
{
v32 = PtesInSubsection;
}
v22->Core.NumberOfFullSectors = v32;
v24 += v22->Core.PtesInSubsection;
v22->DereferenceList.Blink = &v22->DereferenceList;
v22->DereferenceList.Flink = &v22->DereferenceList;
MiInsertSubsectionNode((_CONTROL_AREA *)v13, v22, 0i64);
v22 = *p_NextSubsection;
}
while( *p_NextSubsection );
return 0;
}
LODWORD(v14) = v15 != 0 ? 0x200000 : 0x100000;
if( v18 >= (unsigned int)v14 )
LODWORD(v14) = v18;
}
}
return -1073741760;
}
return result;
}Referenced by:
No references.