MmGetSectionRange

INT64 __stdcall MmGetSectionRange(PVOID AddressWithinSection, PVOID *StartingSectionAddress, UINT64 *SizeofSection){
  _ETHREAD *CurrentThread; 
  PVOID *v5; 
  unsigned int v7; 
  INT64 v8; 
  __int64 v9; 
  __int64 v10; 
  _BYTE *v11; 
  char *v12; 
  IMAGE_NT_HEADERS *v13; 
  int v14; 
  unsigned int *v15; 
  unsigned int v16; 
  unsigned __int64 v17; 
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  v5 = StartingSectionAddress;
  v7 = -1073741275;
  --*((_WORD *)CurrentThread + 242);
  LOBYTE(StartingSectionAddress) = 1;
  ExAcquireResourceSharedLite(&PsLoadedModuleResource, (BOOL)StartingSectionAddress);
  v9 = MiLookupDataTableEntry((unsigned __int64)AddressWithinSection, 0i64, v8);
  v10 = v9;
  if( v9 )
  {
    v11 = *(_BYTE **)(v9 + 48);
    v12 = (char *)((_BYTE *)AddressWithinSection - v11);
    v13 = RtlImageNtHeader(v11);
    v14 = 0;
    if( v13->FileHeader.NumberOfSections )
    {
      v15 = (unsigned int *)((char *)&v13->OptionalHeader.SizeOfInitializedData + v13->FileHeader.SizeOfOptionalHeader);
      while( 1 )
      {
        v16 = v15[2];
        v17 = v15[1];
        if( v16 < *v15 )
          v16 = *v15;
        if( (unsigned __int64)v12 >= v17 && (unsigned __int64)v12 < v16 + (unsigned int)v17 )
          break;
        v15 += 10;
        if( ++v14 >= (unsigned int)v13->FileHeader.NumberOfSections )
          goto LABEL_11;
      }
      *(_DWORD *)SizeofSection = v16;
      *v5 = (PVOID)(*(_QWORD *)(v10 + 48) + v17);
      v7 = 0;
    }
  }
LABEL_11:
  ExReleaseResourceLite(&PsLoadedModuleResource);
  KeLeaveCriticalRegionThread((__int64)CurrentThread);
  return v7;
}

Referenced by:

PoSetHiberRange