mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +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 */
|
LIST_ENTRY InInitializationOrderModuleList; /* not used */
|
||||||
PVOID BaseAddress;
|
PVOID BaseAddress;
|
||||||
ULONG EntryPoint;
|
ULONG EntryPoint;
|
||||||
ULONG SizeOfImage;
|
ULONG ResidentSize;
|
||||||
UNICODE_STRING FullDllName;
|
UNICODE_STRING FullDllName;
|
||||||
UNICODE_STRING BaseDllName;
|
UNICODE_STRING BaseDllName;
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
|
@ -92,6 +92,9 @@ LdrpLoadUserModuleSymbols(PLDR_MODULE LdrModule);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
LdrpGetResidentSize(PIMAGE_NT_HEADERS NTHeaders);
|
||||||
|
|
||||||
PEPFUNC LdrPEStartup (PVOID ImageBase,
|
PEPFUNC LdrPEStartup (PVOID ImageBase,
|
||||||
HANDLE SectionHandle,
|
HANDLE SectionHandle,
|
||||||
PLDR_MODULE* Module,
|
PLDR_MODULE* Module,
|
||||||
|
|
|
@ -222,7 +222,6 @@ finish:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
|
@ -382,7 +381,7 @@ __true_LdrInitializeThunk (ULONG Unknown1,
|
||||||
NtModule->CheckSum = 0;
|
NtModule->CheckSum = 0;
|
||||||
|
|
||||||
NTHeaders = RtlImageNtHeader (NtModule->BaseAddress);
|
NTHeaders = RtlImageNtHeader (NtModule->BaseAddress);
|
||||||
NtModule->SizeOfImage = NTHeaders->OptionalHeader.SizeOfImage;
|
NtModule->ResidentSize = LdrpGetResidentSize(NTHeaders);
|
||||||
NtModule->TimeDateStamp = NTHeaders->FileHeader.TimeDateStamp;
|
NtModule->TimeDateStamp = NTHeaders->FileHeader.TimeDateStamp;
|
||||||
|
|
||||||
InsertTailList(&Peb->Ldr->InLoadOrderModuleList,
|
InsertTailList(&Peb->Ldr->InLoadOrderModuleList,
|
||||||
|
@ -430,7 +429,7 @@ __true_LdrInitializeThunk (ULONG Unknown1,
|
||||||
ExeModule->CheckSum = 0;
|
ExeModule->CheckSum = 0;
|
||||||
|
|
||||||
NTHeaders = RtlImageNtHeader (ExeModule->BaseAddress);
|
NTHeaders = RtlImageNtHeader (ExeModule->BaseAddress);
|
||||||
ExeModule->SizeOfImage = NTHeaders->OptionalHeader.SizeOfImage;
|
ExeModule->ResidentSize = LdrpGetResidentSize(NTHeaders);
|
||||||
ExeModule->TimeDateStamp = NTHeaders->FileHeader.TimeDateStamp;
|
ExeModule->TimeDateStamp = NTHeaders->FileHeader.TimeDateStamp;
|
||||||
|
|
||||||
InsertHeadList(&Peb->Ldr->InLoadOrderModuleList,
|
InsertHeadList(&Peb->Ldr->InLoadOrderModuleList,
|
||||||
|
|
|
@ -468,7 +468,7 @@ LdrAddModuleEntry(PVOID ImageBase,
|
||||||
Module->EntryPoint = NTHeaders->OptionalHeader.AddressOfEntryPoint;
|
Module->EntryPoint = NTHeaders->OptionalHeader.AddressOfEntryPoint;
|
||||||
if (Module->EntryPoint != 0)
|
if (Module->EntryPoint != 0)
|
||||||
Module->EntryPoint += (ULONG)Module->BaseAddress;
|
Module->EntryPoint += (ULONG)Module->BaseAddress;
|
||||||
Module->SizeOfImage = NTHeaders->OptionalHeader.SizeOfImage;
|
Module->ResidentSize = LdrpGetResidentSize(NTHeaders);
|
||||||
if (NtCurrentPeb()->Ldr->Initialized == TRUE)
|
if (NtCurrentPeb()->Ldr->Initialized == TRUE)
|
||||||
{
|
{
|
||||||
/* loading while app is running */
|
/* loading while app is running */
|
||||||
|
@ -799,7 +799,7 @@ LdrFindEntryForAddress(PVOID Address,
|
||||||
DPRINT("Scanning %wZ at %p\n", &ModulePtr->BaseDllName, ModulePtr->BaseAddress);
|
DPRINT("Scanning %wZ at %p\n", &ModulePtr->BaseDllName, ModulePtr->BaseAddress);
|
||||||
|
|
||||||
if ((Address >= ModulePtr->BaseAddress) &&
|
if ((Address >= ModulePtr->BaseAddress) &&
|
||||||
(Address <= (ModulePtr->BaseAddress + ModulePtr->SizeOfImage)))
|
(Address <= (ModulePtr->BaseAddress + ModulePtr->ResidentSize)))
|
||||||
{
|
{
|
||||||
*Module = ModulePtr;
|
*Module = ModulePtr;
|
||||||
RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock);
|
RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock);
|
||||||
|
@ -1581,7 +1581,7 @@ LdrpAdjustImportDirectory(PLDR_MODULE Module,
|
||||||
|
|
||||||
NTHeaders = RtlImageNtHeader (ImportedModule->BaseAddress);
|
NTHeaders = RtlImageNtHeader (ImportedModule->BaseAddress);
|
||||||
Start = (PVOID)NTHeaders->OptionalHeader.ImageBase;
|
Start = (PVOID)NTHeaders->OptionalHeader.ImageBase;
|
||||||
End = Start + ImportedModule->SizeOfImage;
|
End = Start + ImportedModule->ResidentSize;
|
||||||
Offset = ImportedModule->BaseAddress - Start;
|
Offset = ImportedModule->BaseAddress - Start;
|
||||||
|
|
||||||
/* Walk through function list and fixup addresses. */
|
/* 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->Reserved[0] = ModulePtr->Reserved[1] = 0; // FIXME: ??
|
||||||
ModulePtr->Base = Module->BaseAddress;
|
ModulePtr->Base = Module->BaseAddress;
|
||||||
ModulePtr->Size = Module->SizeOfImage;
|
ModulePtr->Size = Module->ResidentSize;
|
||||||
ModulePtr->Flags = Module->Flags;
|
ModulePtr->Flags = Module->Flags;
|
||||||
ModulePtr->Index = 0; // FIXME: index ??
|
ModulePtr->Index = 0; // FIXME: index ??
|
||||||
ModulePtr->Unknown = 0; // FIXME: ??
|
ModulePtr->Unknown = 0; // FIXME: ??
|
||||||
|
@ -2814,6 +2814,33 @@ LdrpCheckImageChecksum (IN PVOID BaseAddress,
|
||||||
return (BOOLEAN)(CalcSum == HeaderSum);
|
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
|
* NAME EXPORTED
|
||||||
|
|
|
@ -219,7 +219,7 @@ RtlpQueryRemoteProcessModules(HANDLE ProcessHandle,
|
||||||
{
|
{
|
||||||
ModulePtr->Reserved[0] = ModulePtr->Reserved[1] = 0; // FIXME: ??
|
ModulePtr->Reserved[0] = ModulePtr->Reserved[1] = 0; // FIXME: ??
|
||||||
ModulePtr->Base = lmModule.BaseAddress;
|
ModulePtr->Base = lmModule.BaseAddress;
|
||||||
ModulePtr->Size = lmModule.SizeOfImage;
|
ModulePtr->Size = lmModule.ResidentSize;
|
||||||
ModulePtr->Flags = lmModule.Flags;
|
ModulePtr->Flags = lmModule.Flags;
|
||||||
ModulePtr->Index = 0; // FIXME: ??
|
ModulePtr->Index = 0; // FIXME: ??
|
||||||
ModulePtr->Unknown = 0; // FIXME: ??
|
ModulePtr->Unknown = 0; // FIXME: ??
|
||||||
|
|
|
@ -521,10 +521,10 @@ exitWithStatus:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* image size */
|
/* image size */
|
||||||
if(nSize >= sizeof(CurrentModule->SizeOfImage))
|
if(nSize >= sizeof(CurrentModule->ResidentSize))
|
||||||
{
|
{
|
||||||
Context->lpmodinfo->SizeOfImage = CurrentModule->SizeOfImage;
|
Context->lpmodinfo->SizeOfImage = CurrentModule->ResidentSize;
|
||||||
nSize -= sizeof(CurrentModule->SizeOfImage);
|
nSize -= sizeof(CurrentModule->ResidentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* entry point */
|
/* entry point */
|
||||||
|
|
|
@ -92,7 +92,7 @@ KdbpSymFindUserModule(IN PVOID Address OPTIONAL,
|
||||||
current = CONTAINING_RECORD(current_entry, LDR_MODULE, InLoadOrderModuleList);
|
current = CONTAINING_RECORD(current_entry, LDR_MODULE, InLoadOrderModuleList);
|
||||||
|
|
||||||
if ((Address != NULL && (Address >= (PVOID)current->BaseAddress &&
|
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) ||
|
(Name != NULL && _wcsicmp(current->BaseDllName.Buffer, Name) == 0) ||
|
||||||
(Index >= 0 && Count++ == Index))
|
(Index >= 0 && Count++ == Index))
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,7 @@ KdbpSymFindUserModule(IN PVOID Address OPTIONAL,
|
||||||
wcsncpy(pInfo->Name, current->BaseDllName.Buffer, Length);
|
wcsncpy(pInfo->Name, current->BaseDllName.Buffer, Length);
|
||||||
pInfo->Name[Length] = L'\0';
|
pInfo->Name[Length] = L'\0';
|
||||||
pInfo->Base = (ULONG_PTR)current->BaseAddress;
|
pInfo->Base = (ULONG_PTR)current->BaseAddress;
|
||||||
pInfo->Size = current->SizeOfImage;
|
pInfo->Size = current->ResidentSize;
|
||||||
pInfo->RosSymInfo = current->RosSymInfo;
|
pInfo->RosSymInfo = current->RosSymInfo;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id:$
|
/* $Id$
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -54,7 +54,7 @@ print_user_address(PVOID address)
|
||||||
CONTAINING_RECORD(current_entry, LDR_MODULE, InLoadOrderModuleList);
|
CONTAINING_RECORD(current_entry, LDR_MODULE, InLoadOrderModuleList);
|
||||||
|
|
||||||
if (address >= (PVOID)current->BaseAddress &&
|
if (address >= (PVOID)current->BaseAddress &&
|
||||||
address < (PVOID)((char*)current->BaseAddress + current->SizeOfImage))
|
address < (PVOID)((char*)current->BaseAddress + current->ResidentSize))
|
||||||
{
|
{
|
||||||
RelativeAddress =
|
RelativeAddress =
|
||||||
(ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
|
(ULONG_PTR) address - (ULONG_PTR)current->BaseAddress;
|
||||||
|
|
Loading…
Reference in a new issue