ViAllocateMapRegisterFile
_MAP_REGISTER_FILE *__stdcall ViAllocateMapRegisterFile(
_ADAPTER_INFORMATION *AdapterInformation,
UINT64 NumberOfMapRegisters){
unsigned int v3;
UINT64 v4;
VOID **PoolWithTag;
VOID **v6;
_MDL *Mdl;
VOID **v8;
_MDL *v9;
VOID **v10;
VOID *v11;
__int64 v12;
VOID **v13;
unsigned __int64 v14;
VOID *v15;
int v17;
PVOID *v18;
void *v19;
UINT64 v20;
UINT64 Priority;
v3 = NumberOfMapRegisters;
if( (unsigned int)(NumberOfMapRegisters + AdapterInformation[40]) <= 0x20 )
{
if( (_DWORD)NumberOfMapRegisters )
{
v4 = (unsigned int)(32 * (NumberOfMapRegisters - 1) + 120);
PoolWithTag = ExAllocatePoolWithTag(0x200ui64, v4, 1449943368i64);
v6 = PoolWithTag;
if( PoolWithTag )
{
memset(PoolWithTag, 0i64, v4);
*((_DWORD *)v6 + 7) = v3;
Mdl = IoAllocateMdl(0i64, v3 << 12, 0, 0, 0i64);
if( Mdl )
{
v8 = ExAllocatePoolWithTag(0x200ui64, (unsigned __int64)v3 << 12, 1449943368i64);
v6[9] = v8;
if( v8 )
{
v9 = Mdl + 1;
v10 = v6 + 13;
do
{
v11 = ViAllocateFromContiguousMemory(AdapterInformation, *((_DWORD *)v6 + 7) - v3);
*v10 = v11;
if( v11 )
{
v12 = 78i64;
}
else
{
v13 = ExAllocatePoolWithTag(0x204ui64, 0x3000ui64, 1449943368i64);
*v10 = v13;
if( !v13 )
goto LABEL_14;
v12 = 79i64;
}
_InterlockedIncrement(&AdapterInformation[v12]);
ViInitializePadding(*v10, 0x3000ui64, 0i64, 0i64);
LODWORD(v14) = MmGetPhysicalAddress((UINT64)*v10 + 4096);
v10 += 4;
v9->Next = (_MDL *)(v14 >> 12);
v9 = (_MDL *)((char *)v9 + 8);
--v3;
}
while( v3 );
Mdl->MdlFlags |= 2u;
LODWORD(Priority) = 1073741840;
LODWORD(v20) = 0;
v15 = MmMapLockedPagesSpecifyCache(Mdl, 0, MmCached, 0i64, v20, Priority);
v6[8] = v15;
if( v15 )
{
v6[10] = 0i64;
v6[7] = Mdl;
*(_DWORD *)v6 = -1393569779;
ExInterlockedInsertHeadList(
(PLIST_ENTRY)(AdapterInformation + 26),
(PLIST_ENTRY)(v6 + 1),
(PKSPIN_LOCK)AdapterInformation + 15);
return(_MAP_REGISTER_FILE *)v6;
}
}
}
LABEL_14:
v17 = *((_DWORD *)v6 + 7);
if( v17 )
{
v18 = v6 + 13;
do
{
if( !*v18 )
break;
if( !(unsigned int)ViFreeToContiguousMemory(
AdapterInformation,
*v18,
(unsigned int)(*((_DWORD *)v6 + 7) - v17)) )
ExFreePoolWithTag(*v18, 0);
v18 += 4;
--v17;
}
while( v17 );
}
if( Mdl )
IoFreeMdl(Mdl);
v19 = v6[9];
if( v19 )
ExFreePoolWithTag(v19, 0);
ExFreePoolWithTag(v6, 0);
}
}
}
return 0i64;
}Referenced by:
VfAllocateAdapterChannel
VfBuildScatterGatherList
VfGetScatterGatherList
VfHalAllocateMapRegisters