mirror of
https://github.com/reactos/reactos.git
synced 2025-07-23 17:23:44 +00:00
[FORMATTING]
Apply indentation of 4 spaces. svn path=/trunk/; revision=50091
This commit is contained in:
parent
10bab36870
commit
372bbf2a73
1 changed files with 2017 additions and 2006 deletions
|
@ -73,7 +73,7 @@ LdrMappedAsDataFile(PVOID *BaseAddress)
|
|||
{
|
||||
if (0 != ((DWORD_PTR) *BaseAddress & (PAGE_SIZE - 1)))
|
||||
{
|
||||
*BaseAddress = (PVOID) ((DWORD_PTR) *BaseAddress & ~ ((DWORD_PTR) PAGE_SIZE - 1));
|
||||
*BaseAddress = (PVOID)((DWORD_PTR)*BaseAddress & ~((DWORD_PTR) PAGE_SIZE - 1));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -570,7 +570,9 @@ LdrAddModuleEntry(PVOID ImageBase,
|
|||
{
|
||||
/* loading while app is running */
|
||||
Module->LoadCount = 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* loading while app is initializing
|
||||
* dll must not be unloaded
|
||||
|
@ -1051,7 +1053,7 @@ LdrFindEntryForName(PUNICODE_STRING Name,
|
|||
|
||||
if (LdrpLastModule)
|
||||
{
|
||||
if ((! ContainsPath &&
|
||||
if ((!ContainsPath &&
|
||||
0 == RtlCompareUnicodeString(&LdrpLastModule->BaseDllName, &AdjustedName, TRUE)) ||
|
||||
(ContainsPath &&
|
||||
0 == RtlCompareUnicodeString(&LdrpLastModule->FullDllName, &AdjustedName, TRUE)))
|
||||
|
@ -1072,7 +1074,7 @@ LdrFindEntryForName(PUNICODE_STRING Name,
|
|||
|
||||
DPRINT("Scanning %wZ %wZ\n", &ModulePtr->BaseDllName, &AdjustedName);
|
||||
|
||||
if ((! ContainsPath &&
|
||||
if ((!ContainsPath &&
|
||||
0 == RtlCompareUnicodeString(&ModulePtr->BaseDllName, &AdjustedName, TRUE)) ||
|
||||
(ContainsPath &&
|
||||
0 == RtlCompareUnicodeString(&ModulePtr->FullDllName, &AdjustedName, TRUE)))
|
||||
|
@ -1137,10 +1139,7 @@ LdrFixupForward(PCHAR ForwardName)
|
|||
*/
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
Status = LdrLoadDll(NULL,
|
||||
NULL,
|
||||
&DllName,
|
||||
&BaseAddress);
|
||||
Status = LdrLoadDll(NULL, NULL, &DllName, &BaseAddress);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = LdrFindEntryForName (&DllName, &Module, FALSE);
|
||||
|
@ -1181,7 +1180,7 @@ static PVOID
|
|||
LdrGetExportByOrdinal (
|
||||
PVOID BaseAddress,
|
||||
ULONG Ordinal
|
||||
)
|
||||
)
|
||||
{
|
||||
PIMAGE_EXPORT_DIRECTORY ExportDir;
|
||||
ULONG ExportDirSize;
|
||||
|
@ -1195,16 +1194,9 @@ LdrGetExportByOrdinal (
|
|||
&ExportDirSize);
|
||||
|
||||
|
||||
ExFunctions = (PDWORD *)
|
||||
RVA(
|
||||
BaseAddress,
|
||||
ExportDir->AddressOfFunctions
|
||||
);
|
||||
DPRINT(
|
||||
"LdrGetExportByOrdinal(Ordinal %lu) = %p\n",
|
||||
Ordinal,
|
||||
RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] )
|
||||
);
|
||||
ExFunctions = (PDWORD*)RVA(BaseAddress, ExportDir->AddressOfFunctions);
|
||||
DPRINT("LdrGetExportByOrdinal(Ordinal %lu) = %p\n",
|
||||
Ordinal, RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base]));
|
||||
|
||||
Function = (0 != ExFunctions[Ordinal - ExportDir->Base]
|
||||
? RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] )
|
||||
|
@ -1244,9 +1236,9 @@ LdrGetExportByName(PVOID BaseAddress,
|
|||
WORD Hint)
|
||||
{
|
||||
PIMAGE_EXPORT_DIRECTORY ExportDir;
|
||||
PDWORD * ExFunctions;
|
||||
PDWORD * ExNames;
|
||||
USHORT * ExOrdinals;
|
||||
PDWORD *ExFunctions;
|
||||
PDWORD *ExNames;
|
||||
USHORT *ExOrdinals;
|
||||
PVOID ExName;
|
||||
ULONG Ordinal;
|
||||
PVOID Function;
|
||||
|
@ -1278,12 +1270,9 @@ LdrGetExportByName(PVOID BaseAddress,
|
|||
/*
|
||||
* Get header pointers
|
||||
*/
|
||||
ExNames = (PDWORD *)RVA(BaseAddress,
|
||||
ExportDir->AddressOfNames);
|
||||
ExOrdinals = (USHORT *)RVA(BaseAddress,
|
||||
ExportDir->AddressOfNameOrdinals);
|
||||
ExFunctions = (PDWORD *)RVA(BaseAddress,
|
||||
ExportDir->AddressOfFunctions);
|
||||
ExNames = (PDWORD *)RVA(BaseAddress, ExportDir->AddressOfNames);
|
||||
ExOrdinals = (USHORT *)RVA(BaseAddress, ExportDir->AddressOfNameOrdinals);
|
||||
ExFunctions = (PDWORD *)RVA(BaseAddress, ExportDir->AddressOfFunctions);
|
||||
|
||||
/*
|
||||
* Check the hint first
|
||||
|
@ -1581,16 +1570,19 @@ LdrpProcessImportDirectoryEntry(PLDR_DATA_TABLE_ENTRY Module,
|
|||
}
|
||||
|
||||
/* Get the import address list. */
|
||||
ImportAddressList = (PVOID *)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
|
||||
ImportAddressList = (PVOID *)((ULONG_PTR)Module->DllBase +
|
||||
(ULONG_PTR)ImportModuleDirectory->FirstThunk);
|
||||
|
||||
/* Get the list of functions to import. */
|
||||
if (ImportModuleDirectory->OriginalFirstThunk != 0)
|
||||
{
|
||||
FunctionNameList = (PULONG) ((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk);
|
||||
FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase +
|
||||
(ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk);
|
||||
}
|
||||
else
|
||||
{
|
||||
FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
|
||||
FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase +
|
||||
(ULONG_PTR)ImportModuleDirectory->FirstThunk);
|
||||
}
|
||||
|
||||
/* Get the size of IAT. */
|
||||
|
@ -1623,10 +1615,12 @@ LdrpProcessImportDirectoryEntry(PLDR_DATA_TABLE_ENTRY Module,
|
|||
if ((*FunctionNameList) & 0x80000000)
|
||||
{
|
||||
Ordinal = (*FunctionNameList) & 0x7fffffff;
|
||||
*ImportAddressList = LdrGetExportByOrdinal(ImportedModule->DllBase, Ordinal);
|
||||
*ImportAddressList = LdrGetExportByOrdinal(ImportedModule->DllBase,
|
||||
Ordinal);
|
||||
if ((*ImportAddressList) == NULL)
|
||||
{
|
||||
DPRINT1("Failed to import #%ld from %wZ\n", Ordinal, &ImportedModule->FullDllName);
|
||||
DPRINT1("Failed to import #%ld from %wZ\n",
|
||||
Ordinal, &ImportedModule->FullDllName);
|
||||
RtlpRaiseImportNotFound(NULL, Ordinal, &ImportedModule->FullDllName);
|
||||
return STATUS_ENTRYPOINT_NOT_FOUND;
|
||||
}
|
||||
|
@ -1635,11 +1629,16 @@ LdrpProcessImportDirectoryEntry(PLDR_DATA_TABLE_ENTRY Module,
|
|||
{
|
||||
IMAGE_IMPORT_BY_NAME *pe_name;
|
||||
pe_name = RVA(Module->DllBase, *FunctionNameList);
|
||||
*ImportAddressList = LdrGetExportByName(ImportedModule->DllBase, pe_name->Name, pe_name->Hint);
|
||||
*ImportAddressList = LdrGetExportByName(ImportedModule->DllBase,
|
||||
pe_name->Name,
|
||||
pe_name->Hint);
|
||||
if ((*ImportAddressList) == NULL)
|
||||
{
|
||||
DPRINT1("Failed to import %s from %wZ\n", pe_name->Name, &ImportedModule->FullDllName);
|
||||
RtlpRaiseImportNotFound((CHAR*)pe_name->Name, 0, &ImportedModule->FullDllName);
|
||||
DPRINT1("Failed to import %s from %wZ\n",
|
||||
pe_name->Name, &ImportedModule->FullDllName);
|
||||
RtlpRaiseImportNotFound((CHAR*)pe_name->Name,
|
||||
0,
|
||||
&ImportedModule->FullDllName);
|
||||
return STATUS_ENTRYPOINT_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
@ -1747,16 +1746,19 @@ LdrpAdjustImportDirectory(PLDR_DATA_TABLE_ENTRY Module,
|
|||
{
|
||||
|
||||
/* Get the import address list. */
|
||||
ImportAddressList = (PVOID *)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
|
||||
ImportAddressList = (PVOID *)((ULONG_PTR)Module->DllBase +
|
||||
(ULONG_PTR)ImportModuleDirectory->FirstThunk);
|
||||
|
||||
/* Get the list of functions to import. */
|
||||
if (ImportModuleDirectory->OriginalFirstThunk != 0)
|
||||
{
|
||||
FunctionNameList = (PULONG) ((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk);
|
||||
FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase +
|
||||
(ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk);
|
||||
}
|
||||
else
|
||||
{
|
||||
FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
|
||||
FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase +
|
||||
(ULONG_PTR)ImportModuleDirectory->FirstThunk);
|
||||
}
|
||||
|
||||
/* Get the size of IAT. */
|
||||
|
@ -1907,7 +1909,8 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
|
|||
BoundImportDescriptorCurrent = BoundImportDescriptor;
|
||||
while (BoundImportDescriptorCurrent->OffsetModuleName)
|
||||
{
|
||||
ImportedName = (PCHAR)BoundImportDescriptor + BoundImportDescriptorCurrent->OffsetModuleName;
|
||||
ImportedName = (PCHAR)BoundImportDescriptor +
|
||||
BoundImportDescriptorCurrent->OffsetModuleName;
|
||||
TRACE_LDR("%wZ bound to %s\n", &Module->BaseDllName, ImportedName);
|
||||
Status = LdrpGetOrLoadModule(SearchPath, ImportedName, &ImportedModule, TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -1952,9 +1955,12 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
|
|||
PCHAR ForwarderName;
|
||||
|
||||
BoundForwarderRef = (PIMAGE_BOUND_FORWARDER_REF)(BoundImportDescriptorCurrent + 1);
|
||||
for (i = 0; i < BoundImportDescriptorCurrent->NumberOfModuleForwarderRefs; i++, BoundForwarderRef++)
|
||||
for (i = 0;
|
||||
i < BoundImportDescriptorCurrent->NumberOfModuleForwarderRefs;
|
||||
i++, BoundForwarderRef++)
|
||||
{
|
||||
ForwarderName = (PCHAR)BoundImportDescriptor + BoundForwarderRef->OffsetModuleName;
|
||||
ForwarderName = (PCHAR)BoundImportDescriptor +
|
||||
BoundForwarderRef->OffsetModuleName;
|
||||
TRACE_LDR("%wZ bound to %s via forwardes from %s\n",
|
||||
&Module->BaseDllName, ForwarderName, ImportedName);
|
||||
Status = LdrpGetOrLoadModule(SearchPath, ForwarderName, &ForwarderModule, TRUE);
|
||||
|
@ -2153,7 +2159,7 @@ PEPFUNC LdrPEStartup (PVOID ImageBase,
|
|||
* one the DLL is actually loaded, perform any
|
||||
* relocation.
|
||||
*/
|
||||
if (ImageBase != (PVOID) NTHeaders->OptionalHeader.ImageBase)
|
||||
if (ImageBase != (PVOID)NTHeaders->OptionalHeader.ImageBase)
|
||||
{
|
||||
DPRINT("LDR: Performing relocations\n");
|
||||
Status = LdrPerformRelocations(NTHeaders, ImageBase);
|
||||
|
@ -2291,7 +2297,8 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL,
|
|||
}
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Failed to create or open dll section of '%wZ' (Status %lx)\n", &AdjustedName, Status);
|
||||
DPRINT1("Failed to create or open dll section of '%wZ' (Status %lx)\n",
|
||||
&AdjustedName, Status);
|
||||
RtlFreeUnicodeString(&AdjustedName);
|
||||
return Status;
|
||||
}
|
||||
|
@ -2795,7 +2802,9 @@ LdrpDetachProcess(BOOLEAN UnloadAll)
|
|||
{
|
||||
TRACE_LDR("Unload %wZ - Calling entry point at %x\n",
|
||||
&Module->BaseDllName, Module->EntryPoint);
|
||||
LdrpCallDllEntry(Module, DLL_PROCESS_DETACH, (PVOID)(Module->LoadCount == LDRP_PROCESS_CREATION_TIME ? 1 : 0));
|
||||
LdrpCallDllEntry(Module,
|
||||
DLL_PROCESS_DETACH,
|
||||
(PVOID)(Module->LoadCount == LDRP_PROCESS_CREATION_TIME ? 1 : 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3050,7 +3059,7 @@ LdrQueryProcessModuleInformation(IN PRTL_PROCESS_MODULES ModuleInformation OPTIO
|
|||
PCHAR p;
|
||||
|
||||
DPRINT("LdrQueryProcessModuleInformation() called\n");
|
||||
// FIXME: This code is ultra-duplicated. see lib\rtl\dbgbuffer.c
|
||||
// FIXME: This code is ultra-duplicated. see lib\rtl\dbgbuffer.c
|
||||
RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock);
|
||||
|
||||
if (ModuleInformation == NULL || Size == 0)
|
||||
|
@ -3204,7 +3213,9 @@ LdrpGetResidentSize(PIMAGE_NT_HEADERS NTHeaders)
|
|||
SectionHeader = (PIMAGE_SECTION_HEADER)((char *) &NTHeaders->OptionalHeader
|
||||
+ NTHeaders->FileHeader.SizeOfOptionalHeader);
|
||||
ResidentSize = 0;
|
||||
for (SectionIndex = 0; SectionIndex < NTHeaders->FileHeader.NumberOfSections; SectionIndex++)
|
||||
for (SectionIndex = 0;
|
||||
SectionIndex < NTHeaders->FileHeader.NumberOfSections;
|
||||
SectionIndex++)
|
||||
{
|
||||
if (0 == (SectionHeader->Characteristics & IMAGE_SCN_LNK_REMOVE)
|
||||
&& ResidentSize < SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize)
|
||||
|
@ -3282,7 +3293,7 @@ LdrVerifyImageMatchesChecksum (IN HANDLE FileHandle,
|
|||
return Status;
|
||||
}
|
||||
|
||||
Status = NtQueryInformationFile (FileHandle,
|
||||
Status = NtQueryInformationFile(FileHandle,
|
||||
&IoStatusBlock,
|
||||
&FileInfo,
|
||||
sizeof (FILE_STANDARD_INFORMATION),
|
||||
|
@ -3290,23 +3301,23 @@ LdrVerifyImageMatchesChecksum (IN HANDLE FileHandle,
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1 ("NtMapViewOfSection() failed (Status %lx)\n", Status);
|
||||
NtUnmapViewOfSection (NtCurrentProcess (),
|
||||
NtUnmapViewOfSection (NtCurrentProcess(),
|
||||
BaseAddress);
|
||||
NtClose (SectionHandle);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Result = LdrpCheckImageChecksum (BaseAddress,
|
||||
Result = LdrpCheckImageChecksum(BaseAddress,
|
||||
FileInfo.EndOfFile.u.LowPart);
|
||||
if (Result == FALSE)
|
||||
{
|
||||
Status = STATUS_IMAGE_CHECKSUM_MISMATCH;
|
||||
}
|
||||
|
||||
NtUnmapViewOfSection (NtCurrentProcess (),
|
||||
NtUnmapViewOfSection (NtCurrentProcess(),
|
||||
BaseAddress);
|
||||
|
||||
NtClose (SectionHandle);
|
||||
NtClose(SectionHandle);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -3329,7 +3340,7 @@ LdrVerifyImageMatchesChecksum (IN HANDLE FileHandle,
|
|||
* @implemented
|
||||
*/
|
||||
NTSTATUS NTAPI
|
||||
LdrQueryImageFileExecutionOptions (IN PUNICODE_STRING SubKey,
|
||||
LdrQueryImageFileExecutionOptions(IN PUNICODE_STRING SubKey,
|
||||
IN PCWSTR ValueName,
|
||||
IN ULONG Type,
|
||||
OUT PVOID Buffer,
|
||||
|
@ -3363,13 +3374,13 @@ LdrQueryImageFileExecutionOptions (IN PUNICODE_STRING SubKey,
|
|||
RtlInitUnicodeString (&KeyName,
|
||||
NameBuffer);
|
||||
|
||||
InitializeObjectAttributes (&ObjectAttributes,
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenKey (&KeyHandle,
|
||||
Status = NtOpenKey(&KeyHandle,
|
||||
KEY_READ,
|
||||
&ObjectAttributes);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -3381,9 +3392,9 @@ LdrQueryImageFileExecutionOptions (IN PUNICODE_STRING SubKey,
|
|||
KeyInfoSize = sizeof(KeyInfoBuffer);
|
||||
KeyInfo = (PKEY_VALUE_PARTIAL_INFORMATION)KeyInfoBuffer;
|
||||
|
||||
RtlInitUnicodeString (&ValueNameString,
|
||||
RtlInitUnicodeString(&ValueNameString,
|
||||
(PWSTR)ValueName);
|
||||
Status = NtQueryValueKey (KeyHandle,
|
||||
Status = NtQueryValueKey(KeyHandle,
|
||||
&ValueNameString,
|
||||
KeyValuePartialInformation,
|
||||
KeyInfo,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue