[FORMATTING]

Apply indentation of 4 spaces.

svn path=/trunk/; revision=50091
This commit is contained in:
Timo Kreuzer 2010-12-22 13:00:47 +00:00
parent 10bab36870
commit 372bbf2a73

View file

@ -570,7 +570,9 @@ LdrAddModuleEntry(PVOID ImageBase,
{ {
/* loading while app is running */ /* loading while app is running */
Module->LoadCount = 1; Module->LoadCount = 1;
} else { }
else
{
/* /*
* loading while app is initializing * loading while app is initializing
* dll must not be unloaded * dll must not be unloaded
@ -1137,10 +1139,7 @@ LdrFixupForward(PCHAR ForwardName)
*/ */
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
Status = LdrLoadDll(NULL, Status = LdrLoadDll(NULL, NULL, &DllName, &BaseAddress);
NULL,
&DllName,
&BaseAddress);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
Status = LdrFindEntryForName (&DllName, &Module, FALSE); Status = LdrFindEntryForName (&DllName, &Module, FALSE);
@ -1195,16 +1194,9 @@ LdrGetExportByOrdinal (
&ExportDirSize); &ExportDirSize);
ExFunctions = (PDWORD *) ExFunctions = (PDWORD*)RVA(BaseAddress, ExportDir->AddressOfFunctions);
RVA( DPRINT("LdrGetExportByOrdinal(Ordinal %lu) = %p\n",
BaseAddress, Ordinal, RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base]));
ExportDir->AddressOfFunctions
);
DPRINT(
"LdrGetExportByOrdinal(Ordinal %lu) = %p\n",
Ordinal,
RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] )
);
Function = (0 != ExFunctions[Ordinal - ExportDir->Base] Function = (0 != ExFunctions[Ordinal - ExportDir->Base]
? RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] ) ? RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] )
@ -1278,12 +1270,9 @@ LdrGetExportByName(PVOID BaseAddress,
/* /*
* Get header pointers * Get header pointers
*/ */
ExNames = (PDWORD *)RVA(BaseAddress, ExNames = (PDWORD *)RVA(BaseAddress, ExportDir->AddressOfNames);
ExportDir->AddressOfNames); ExOrdinals = (USHORT *)RVA(BaseAddress, ExportDir->AddressOfNameOrdinals);
ExOrdinals = (USHORT *)RVA(BaseAddress, ExFunctions = (PDWORD *)RVA(BaseAddress, ExportDir->AddressOfFunctions);
ExportDir->AddressOfNameOrdinals);
ExFunctions = (PDWORD *)RVA(BaseAddress,
ExportDir->AddressOfFunctions);
/* /*
* Check the hint first * Check the hint first
@ -1581,16 +1570,19 @@ LdrpProcessImportDirectoryEntry(PLDR_DATA_TABLE_ENTRY Module,
} }
/* Get the import address list. */ /* 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. */ /* Get the list of functions to import. */
if (ImportModuleDirectory->OriginalFirstThunk != 0) 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 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. */ /* Get the size of IAT. */
@ -1623,10 +1615,12 @@ LdrpProcessImportDirectoryEntry(PLDR_DATA_TABLE_ENTRY Module,
if ((*FunctionNameList) & 0x80000000) if ((*FunctionNameList) & 0x80000000)
{ {
Ordinal = (*FunctionNameList) & 0x7fffffff; Ordinal = (*FunctionNameList) & 0x7fffffff;
*ImportAddressList = LdrGetExportByOrdinal(ImportedModule->DllBase, Ordinal); *ImportAddressList = LdrGetExportByOrdinal(ImportedModule->DllBase,
Ordinal);
if ((*ImportAddressList) == NULL) 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); RtlpRaiseImportNotFound(NULL, Ordinal, &ImportedModule->FullDllName);
return STATUS_ENTRYPOINT_NOT_FOUND; return STATUS_ENTRYPOINT_NOT_FOUND;
} }
@ -1635,11 +1629,16 @@ LdrpProcessImportDirectoryEntry(PLDR_DATA_TABLE_ENTRY Module,
{ {
IMAGE_IMPORT_BY_NAME *pe_name; IMAGE_IMPORT_BY_NAME *pe_name;
pe_name = RVA(Module->DllBase, *FunctionNameList); 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) if ((*ImportAddressList) == NULL)
{ {
DPRINT1("Failed to import %s from %wZ\n", pe_name->Name, &ImportedModule->FullDllName); DPRINT1("Failed to import %s from %wZ\n",
RtlpRaiseImportNotFound((CHAR*)pe_name->Name, 0, &ImportedModule->FullDllName); pe_name->Name, &ImportedModule->FullDllName);
RtlpRaiseImportNotFound((CHAR*)pe_name->Name,
0,
&ImportedModule->FullDllName);
return STATUS_ENTRYPOINT_NOT_FOUND; return STATUS_ENTRYPOINT_NOT_FOUND;
} }
} }
@ -1747,16 +1746,19 @@ LdrpAdjustImportDirectory(PLDR_DATA_TABLE_ENTRY Module,
{ {
/* Get the import address list. */ /* 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. */ /* Get the list of functions to import. */
if (ImportModuleDirectory->OriginalFirstThunk != 0) 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 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. */ /* Get the size of IAT. */
@ -1907,7 +1909,8 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
BoundImportDescriptorCurrent = BoundImportDescriptor; BoundImportDescriptorCurrent = BoundImportDescriptor;
while (BoundImportDescriptorCurrent->OffsetModuleName) while (BoundImportDescriptorCurrent->OffsetModuleName)
{ {
ImportedName = (PCHAR)BoundImportDescriptor + BoundImportDescriptorCurrent->OffsetModuleName; ImportedName = (PCHAR)BoundImportDescriptor +
BoundImportDescriptorCurrent->OffsetModuleName;
TRACE_LDR("%wZ bound to %s\n", &Module->BaseDllName, ImportedName); TRACE_LDR("%wZ bound to %s\n", &Module->BaseDllName, ImportedName);
Status = LdrpGetOrLoadModule(SearchPath, ImportedName, &ImportedModule, TRUE); Status = LdrpGetOrLoadModule(SearchPath, ImportedName, &ImportedModule, TRUE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -1952,9 +1955,12 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
PCHAR ForwarderName; PCHAR ForwarderName;
BoundForwarderRef = (PIMAGE_BOUND_FORWARDER_REF)(BoundImportDescriptorCurrent + 1); 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", TRACE_LDR("%wZ bound to %s via forwardes from %s\n",
&Module->BaseDllName, ForwarderName, ImportedName); &Module->BaseDllName, ForwarderName, ImportedName);
Status = LdrpGetOrLoadModule(SearchPath, ForwarderName, &ForwarderModule, TRUE); Status = LdrpGetOrLoadModule(SearchPath, ForwarderName, &ForwarderModule, TRUE);
@ -2291,7 +2297,8 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL,
} }
if (!NT_SUCCESS(Status)) 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); RtlFreeUnicodeString(&AdjustedName);
return Status; return Status;
} }
@ -2795,7 +2802,9 @@ LdrpDetachProcess(BOOLEAN UnloadAll)
{ {
TRACE_LDR("Unload %wZ - Calling entry point at %x\n", TRACE_LDR("Unload %wZ - Calling entry point at %x\n",
&Module->BaseDllName, Module->EntryPoint); &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 else
{ {
@ -3204,7 +3213,9 @@ LdrpGetResidentSize(PIMAGE_NT_HEADERS NTHeaders)
SectionHeader = (PIMAGE_SECTION_HEADER)((char *) &NTHeaders->OptionalHeader SectionHeader = (PIMAGE_SECTION_HEADER)((char *) &NTHeaders->OptionalHeader
+ NTHeaders->FileHeader.SizeOfOptionalHeader); + NTHeaders->FileHeader.SizeOfOptionalHeader);
ResidentSize = 0; 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) if (0 == (SectionHeader->Characteristics & IMAGE_SCN_LNK_REMOVE)
&& ResidentSize < SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize) && ResidentSize < SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize)