mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Don't include NEVER_LOAD sections in image size.
Rename SizeOfImage to ResidentSize to avoid confusion svn path=/trunk/; revision=13477
This commit is contained in:
parent
22b2e24aea
commit
9d11fdcdac
7 changed files with 45 additions and 16 deletions
|
@ -59,7 +59,7 @@ typedef struct _LDR_MODULE
|
|||
LIST_ENTRY InInitializationOrderModuleList; /* not used */
|
||||
PVOID BaseAddress;
|
||||
ULONG EntryPoint;
|
||||
ULONG SizeOfImage;
|
||||
ULONG ResidentSize;
|
||||
UNICODE_STRING FullDllName;
|
||||
UNICODE_STRING BaseDllName;
|
||||
ULONG Flags;
|
||||
|
@ -92,6 +92,9 @@ LdrpLoadUserModuleSymbols(PLDR_MODULE LdrModule);
|
|||
|
||||
#endif
|
||||
|
||||
ULONG
|
||||
LdrpGetResidentSize(PIMAGE_NT_HEADERS NTHeaders);
|
||||
|
||||
PEPFUNC LdrPEStartup (PVOID ImageBase,
|
||||
HANDLE SectionHandle,
|
||||
PLDR_MODULE* Module,
|
||||
|
|
|
@ -222,7 +222,6 @@ finish:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID STDCALL
|
||||
|
@ -382,7 +381,7 @@ __true_LdrInitializeThunk (ULONG Unknown1,
|
|||
NtModule->CheckSum = 0;
|
||||
|
||||
NTHeaders = RtlImageNtHeader (NtModule->BaseAddress);
|
||||
NtModule->SizeOfImage = NTHeaders->OptionalHeader.SizeOfImage;
|
||||
NtModule->ResidentSize = LdrpGetResidentSize(NTHeaders);
|
||||
NtModule->TimeDateStamp = NTHeaders->FileHeader.TimeDateStamp;
|
||||
|
||||
InsertTailList(&Peb->Ldr->InLoadOrderModuleList,
|
||||
|
@ -430,7 +429,7 @@ __true_LdrInitializeThunk (ULONG Unknown1,
|
|||
ExeModule->CheckSum = 0;
|
||||
|
||||
NTHeaders = RtlImageNtHeader (ExeModule->BaseAddress);
|
||||
ExeModule->SizeOfImage = NTHeaders->OptionalHeader.SizeOfImage;
|
||||
ExeModule->ResidentSize = LdrpGetResidentSize(NTHeaders);
|
||||
ExeModule->TimeDateStamp = NTHeaders->FileHeader.TimeDateStamp;
|
||||
|
||||
InsertHeadList(&Peb->Ldr->InLoadOrderModuleList,
|
||||
|
|
|
@ -468,7 +468,7 @@ LdrAddModuleEntry(PVOID ImageBase,
|
|||
Module->EntryPoint = NTHeaders->OptionalHeader.AddressOfEntryPoint;
|
||||
if (Module->EntryPoint != 0)
|
||||
Module->EntryPoint += (ULONG)Module->BaseAddress;
|
||||
Module->SizeOfImage = NTHeaders->OptionalHeader.SizeOfImage;
|
||||
Module->ResidentSize = LdrpGetResidentSize(NTHeaders);
|
||||
if (NtCurrentPeb()->Ldr->Initialized == TRUE)
|
||||
{
|
||||
/* loading while app is running */
|
||||
|
@ -799,7 +799,7 @@ LdrFindEntryForAddress(PVOID Address,
|
|||
DPRINT("Scanning %wZ at %p\n", &ModulePtr->BaseDllName, ModulePtr->BaseAddress);
|
||||
|
||||
if ((Address >= ModulePtr->BaseAddress) &&
|
||||
(Address <= (ModulePtr->BaseAddress + ModulePtr->SizeOfImage)))
|
||||
(Address <= (ModulePtr->BaseAddress + ModulePtr->ResidentSize)))
|
||||
{
|
||||
*Module = ModulePtr;
|
||||
RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock);
|
||||
|
@ -1581,7 +1581,7 @@ LdrpAdjustImportDirectory(PLDR_MODULE Module,
|
|||
|
||||
NTHeaders = RtlImageNtHeader (ImportedModule->BaseAddress);
|
||||
Start = (PVOID)NTHeaders->OptionalHeader.ImageBase;
|
||||
End = Start + ImportedModule->SizeOfImage;
|
||||
End = Start + ImportedModule->ResidentSize;
|
||||
Offset = ImportedModule->BaseAddress - Start;
|
||||
|
||||
/* Walk through function list and fixup addresses. */
|
||||
|
@ -2708,7 +2708,7 @@ LdrQueryProcessModuleInformation(IN PMODULE_INFORMATION ModuleInformation OPTION
|
|||
{
|
||||
ModulePtr->Reserved[0] = ModulePtr->Reserved[1] = 0; // FIXME: ??
|
||||
ModulePtr->Base = Module->BaseAddress;
|
||||
ModulePtr->Size = Module->SizeOfImage;
|
||||
ModulePtr->Size = Module->ResidentSize;
|
||||
ModulePtr->Flags = Module->Flags;
|
||||
ModulePtr->Index = 0; // FIXME: index ??
|
||||
ModulePtr->Unknown = 0; // FIXME: ??
|
||||
|
@ -2814,6 +2814,33 @@ LdrpCheckImageChecksum (IN PVOID BaseAddress,
|
|||
return (BOOLEAN)(CalcSum == HeaderSum);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute size of an image as it is actually present in virt memory
|
||||
* (i.e. excluding NEVER_LOAD sections)
|
||||
*/
|
||||
ULONG
|
||||
LdrpGetResidentSize(PIMAGE_NT_HEADERS NTHeaders)
|
||||
{
|
||||
PIMAGE_SECTION_HEADER SectionHeader;
|
||||
unsigned SectionIndex;
|
||||
ULONG ResidentSize;
|
||||
|
||||
SectionHeader = (PIMAGE_SECTION_HEADER)((char *) &NTHeaders->OptionalHeader
|
||||
+ NTHeaders->FileHeader.SizeOfOptionalHeader);
|
||||
ResidentSize = 0;
|
||||
for (SectionIndex = 0; SectionIndex < NTHeaders->FileHeader.NumberOfSections; SectionIndex++)
|
||||
{
|
||||
if (0 == (SectionHeader->Characteristics & IMAGE_SCN_LNK_REMOVE)
|
||||
&& ResidentSize < SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize)
|
||||
{
|
||||
ResidentSize = SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize;
|
||||
}
|
||||
SectionHeader++;
|
||||
}
|
||||
|
||||
return ResidentSize;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* NAME EXPORTED
|
||||
|
|
|
@ -219,7 +219,7 @@ RtlpQueryRemoteProcessModules(HANDLE ProcessHandle,
|
|||
{
|
||||
ModulePtr->Reserved[0] = ModulePtr->Reserved[1] = 0; // FIXME: ??
|
||||
ModulePtr->Base = lmModule.BaseAddress;
|
||||
ModulePtr->Size = lmModule.SizeOfImage;
|
||||
ModulePtr->Size = lmModule.ResidentSize;
|
||||
ModulePtr->Flags = lmModule.Flags;
|
||||
ModulePtr->Index = 0; // FIXME: ??
|
||||
ModulePtr->Unknown = 0; // FIXME: ??
|
||||
|
|
|
@ -521,10 +521,10 @@ exitWithStatus:
|
|||
}
|
||||
|
||||
/* image size */
|
||||
if(nSize >= sizeof(CurrentModule->SizeOfImage))
|
||||
if(nSize >= sizeof(CurrentModule->ResidentSize))
|
||||
{
|
||||
Context->lpmodinfo->SizeOfImage = CurrentModule->SizeOfImage;
|
||||
nSize -= sizeof(CurrentModule->SizeOfImage);
|
||||
Context->lpmodinfo->SizeOfImage = CurrentModule->ResidentSize;
|
||||
nSize -= sizeof(CurrentModule->ResidentSize);
|
||||
}
|
||||
|
||||
/* entry point */
|
||||
|
|
|
@ -92,7 +92,7 @@ KdbpSymFindUserModule(IN PVOID Address OPTIONAL,
|
|||
current = CONTAINING_RECORD(current_entry, LDR_MODULE, InLoadOrderModuleList);
|
||||
|
||||
if ((Address != NULL && (Address >= (PVOID)current->BaseAddress &&
|
||||
Address < (PVOID)((char *)current->BaseAddress + current->SizeOfImage))) ||
|
||||
Address < (PVOID)((char *)current->BaseAddress + current->ResidentSize))) ||
|
||||
(Name != NULL && _wcsicmp(current->BaseDllName.Buffer, Name) == 0) ||
|
||||
(Index >= 0 && Count++ == Index))
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ KdbpSymFindUserModule(IN PVOID Address OPTIONAL,
|
|||
wcsncpy(pInfo->Name, current->BaseDllName.Buffer, Length);
|
||||
pInfo->Name[Length] = L'\0';
|
||||
pInfo->Base = (ULONG_PTR)current->BaseAddress;
|
||||
pInfo->Size = current->SizeOfImage;
|
||||
pInfo->Size = current->ResidentSize;
|
||||
pInfo->RosSymInfo = current->RosSymInfo;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id:$
|
||||
/* $Id$
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -54,7 +54,7 @@ print_user_address(PVOID address)
|
|||
CONTAINING_RECORD(current_entry, LDR_MODULE, InLoadOrderModuleList);
|
||||
|
||||
if (address >= (PVOID)current->BaseAddress &&
|
||||
address < (PVOID)((char*)current->BaseAddress + current->SizeOfImage))
|
||||
address < (PVOID)((char*)current->BaseAddress + current->ResidentSize))
|
||||
{
|
||||
RelativeAddress =
|
||||
(ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
|
||||
|
|
Loading…
Reference in a new issue