MiObtainSectionForDriver
__int64 __fastcall MiObtainSectionForDriver(
PCUNICODE_STRING String1,
_UNICODE_STRING *a2,
__int64 a3,
int a4,
PVOID Object){
_QWORD *v5;
_ETHREAD *CurrentThread;
PVOID v9;
PVOID *v12;
NTSTATUS v13;
__int64 v14;
__int16 v15;
_QWORD *TempLoaderEntry;
int SystemRegionType;
v5 = Object;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
Object = 0i64;
v9 = 0i64;
*v5 = 0i64;
do
{
v12 = (PVOID *)PsLoadedModuleList;
if( PsLoadedModuleList != &PsLoadedModuleList )
{
while( !RtlEqualUnicodeString((UNICODE_STRING *)String1, (UNICODE_STRING *)(v12 + 9), 1u) )
{
v12 = (PVOID *)*v12;
if( v12 == &PsLoadedModuleList )
goto LABEL_5;
}
if( v9 )
ObDereferenceObjectDeferDelete(v9);
SystemRegionType = MiGetSystemRegionType((UINT64)v12[6]);
if( (a4 & 1) != 0 )
{
if( SystemRegionType == 1 )
{
LABEL_21:
*v5 = v12;
return 272i64;
}
}
else if( SystemRegionType != 1 )
{
goto LABEL_21;
}
return 3221225496i64;
}
LABEL_5:
if( v9 )
{
TempLoaderEntry = MiAllocateTempLoaderEntry((INT64)v9);
if( TempLoaderEntry )
{
*v5 = TempLoaderEntry;
return 0i64;
}
v13 = -1073741670;
goto LABEL_26;
}
if( !a3 )
MmReleaseLoadLock(CurrentThread);
v13 = MiCreateSectionForDriver(a2, (VOID *)a3, (unsigned int)a4, &Object);
if( !a3 )
MmAcquireLoadLock();
if( v13 < 0 )
return(unsigned int)v13;
v9 = Object;
v14 = *(_QWORD *)(*(_QWORD *)MiSectionControlArea((_SECTION *)Object) + 56i64);
}
while( *(__int16 *)(v14 + 46) >= v15 || *(_DWORD *)(v14 + 32) != 1 || (a4 & 1) != 0 );
v13 = -1073741800;
LABEL_26:
ObDereferenceObjectDeferDelete(v9);
return(unsigned int)v13;
}Referenced by:
MiApplyHotPatchToLoadedDriver
MmLoadSystemImageEx