Author: tkreuzer Date: Wed Dec 22 13:33:09 2010 New Revision: 50093
URL: http://svn.reactos.org/svn/reactos?rev=50093&view=rev Log: [FORMATTING] Apply indentation of 4 spaces.
Modified: trunk/reactos/lib/rtl/image.c
Modified: trunk/reactos/lib/rtl/image.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/image.c?rev=50093&a... ============================================================================== --- trunk/reactos/lib/rtl/image.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/image.c [iso-8859-1] Wed Dec 22 13:33:09 2010 @@ -22,9 +22,10 @@
BOOLEAN NTAPI -LdrVerifyMappedImageMatchesChecksum(IN PVOID BaseAddress, - IN ULONG NumberOfBytes, - IN ULONG FileLength) +LdrVerifyMappedImageMatchesChecksum( + IN PVOID BaseAddress, + IN ULONG NumberOfBytes, + IN ULONG FileLength) { /* FIXME: TODO */ return TRUE; @@ -33,26 +34,26 @@ /* * @implemented */ -PIMAGE_NT_HEADERS NTAPI -RtlImageNtHeader (IN PVOID BaseAddress) -{ - PIMAGE_NT_HEADERS NtHeader; - PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)BaseAddress; - - if (DosHeader && SWAPW(DosHeader->e_magic) != IMAGE_DOS_SIGNATURE) - { - DPRINT1("DosHeader->e_magic %x\n", SWAPW(DosHeader->e_magic)); - DPRINT1("NtHeader 0x%lx\n", ((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew))); - } - - if (DosHeader && SWAPW(DosHeader->e_magic) == IMAGE_DOS_SIGNATURE) - { - NtHeader = (PIMAGE_NT_HEADERS)((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew)); - if (SWAPD(NtHeader->Signature) == IMAGE_NT_SIGNATURE) - return NtHeader; - } - - return NULL; +PIMAGE_NT_HEADERS +NTAPI +RtlImageNtHeader(IN PVOID BaseAddress) +{ + PIMAGE_NT_HEADERS NtHeader; + PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)BaseAddress; + + if (DosHeader && SWAPW(DosHeader->e_magic) != IMAGE_DOS_SIGNATURE) + { + DPRINT1("DosHeader->e_magic %x\n", SWAPW(DosHeader->e_magic)); + DPRINT1("NtHeader 0x%lx\n", ((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew))); + } + else + { + NtHeader = (PIMAGE_NT_HEADERS)((ULONG_PTR)BaseAddress + SWAPD(DosHeader->e_lfanew)); + if (SWAPD(NtHeader->Signature) == IMAGE_NT_SIGNATURE) + return NtHeader; + } + + return NULL; }
@@ -61,40 +62,41 @@ */ PVOID NTAPI -RtlImageDirectoryEntryToData(PVOID BaseAddress, - BOOLEAN MappedAsImage, - USHORT Directory, - PULONG Size) -{ - PIMAGE_NT_HEADERS NtHeader; - ULONG Va; - - /* Magic flag for non-mapped images. */ - if ((ULONG_PTR)BaseAddress & 1) - { - BaseAddress = (PVOID)((ULONG_PTR)BaseAddress & ~1); - MappedAsImage = FALSE; - } - - - NtHeader = RtlImageNtHeader (BaseAddress); - if (NtHeader == NULL) - return NULL; - - if (Directory >= SWAPD(NtHeader->OptionalHeader.NumberOfRvaAndSizes)) - return NULL; - - Va = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress); - if (Va == 0) - return NULL; - - *Size = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].Size); - - if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders)) - return (PVOID)((ULONG_PTR)BaseAddress + Va); - - /* image mapped as ordinary file, we must find raw pointer */ - return RtlImageRvaToVa (NtHeader, BaseAddress, Va, NULL); +RtlImageDirectoryEntryToData( + PVOID BaseAddress, + BOOLEAN MappedAsImage, + USHORT Directory, + PULONG Size) +{ + PIMAGE_NT_HEADERS NtHeader; + ULONG Va; + + /* Magic flag for non-mapped images. */ + if ((ULONG_PTR)BaseAddress & 1) + { + BaseAddress = (PVOID)((ULONG_PTR)BaseAddress & ~1); + MappedAsImage = FALSE; + } + + + NtHeader = RtlImageNtHeader (BaseAddress); + if (NtHeader == NULL) + return NULL; + + if (Directory >= SWAPD(NtHeader->OptionalHeader.NumberOfRvaAndSizes)) + return NULL; + + Va = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress); + if (Va == 0) + return NULL; + + *Size = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].Size); + + if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders)) + return (PVOID)((ULONG_PTR)BaseAddress + Va); + + /* image mapped as ordinary file, we must find raw pointer */ + return RtlImageRvaToVa (NtHeader, BaseAddress, Va, NULL); }
@@ -103,28 +105,27 @@ */ PIMAGE_SECTION_HEADER NTAPI -RtlImageRvaToSection ( - PIMAGE_NT_HEADERS NtHeader, - PVOID BaseAddress, - ULONG Rva - ) -{ - PIMAGE_SECTION_HEADER Section; - ULONG Va; - ULONG Count; - - Count = SWAPW(NtHeader->FileHeader.NumberOfSections); - Section = IMAGE_FIRST_SECTION(NtHeader); - - while (Count--) - { - Va = SWAPD(Section->VirtualAddress); - if ((Va <= Rva) && - (Rva < Va + SWAPD(Section->Misc.VirtualSize))) - return Section; - Section++; - } - return NULL; +RtlImageRvaToSection( + PIMAGE_NT_HEADERS NtHeader, + PVOID BaseAddress, + ULONG Rva) +{ + PIMAGE_SECTION_HEADER Section; + ULONG Va; + ULONG Count; + + Count = SWAPW(NtHeader->FileHeader.NumberOfSections); + Section = IMAGE_FIRST_SECTION(NtHeader); + + while (Count--) + { + Va = SWAPD(Section->VirtualAddress); + if ((Va <= Rva) && + (Rva < Va + SWAPD(Section->Misc.VirtualSize))) + return Section; + Section++; + } + return NULL; }
@@ -133,34 +134,33 @@ */ PVOID NTAPI -RtlImageRvaToVa ( - PIMAGE_NT_HEADERS NtHeader, - PVOID BaseAddress, - ULONG Rva, - PIMAGE_SECTION_HEADER *SectionHeader - ) -{ - PIMAGE_SECTION_HEADER Section = NULL; - - if (SectionHeader) - Section = *SectionHeader; - - if (Section == NULL || - Rva < SWAPD(Section->VirtualAddress) || - Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize)) - { - Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva); - if (Section == NULL) - return 0; - - if (SectionHeader) - *SectionHeader = Section; - } - - return (PVOID)((ULONG_PTR)BaseAddress + - Rva + - SWAPD(Section->PointerToRawData) - - (ULONG_PTR)SWAPD(Section->VirtualAddress)); +RtlImageRvaToVa( + PIMAGE_NT_HEADERS NtHeader, + PVOID BaseAddress, + ULONG Rva, + PIMAGE_SECTION_HEADER *SectionHeader) +{ + PIMAGE_SECTION_HEADER Section = NULL; + + if (SectionHeader) + Section = *SectionHeader; + + if (Section == NULL || + Rva < SWAPD(Section->VirtualAddress) || + Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize)) + { + Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva); + if (Section == NULL) + return 0; + + if (SectionHeader) + *SectionHeader = Section; + } + + return (PVOID)((ULONG_PTR)BaseAddress + + Rva + + SWAPD(Section->PointerToRawData) - + (ULONG_PTR)SWAPD(Section->VirtualAddress)); }
PIMAGE_BASE_RELOCATION @@ -169,8 +169,7 @@ IN ULONG_PTR Address, IN ULONG Count, IN PUSHORT TypeOffset, - IN LONGLONG Delta - ) + IN LONGLONG Delta) { SHORT Offset; USHORT Type; @@ -197,8 +196,8 @@ {*/ switch (Type) { - /* case IMAGE_REL_BASED_SECTION : */ - /* case IMAGE_REL_BASED_REL32 : */ + /* case IMAGE_REL_BASED_SECTION : */ + /* case IMAGE_REL_BASED_REL32 : */ case IMAGE_REL_BASED_ABSOLUTE: break;
@@ -242,8 +241,7 @@ IN PCCH LoaderName, IN ULONG Success, IN ULONG Conflict, - IN ULONG Invalid - ) + IN ULONG Invalid) { PIMAGE_NT_HEADERS NtHeaders; PIMAGE_DATA_DIRECTORY RelocationDDir; @@ -275,16 +273,16 @@ RelocationEnd = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)RelocationDir + SWAPD(RelocationDDir->Size));
while (RelocationDir < RelocationEnd && - SWAPW(RelocationDir->SizeOfBlock) > 0) + SWAPW(RelocationDir->SizeOfBlock) > 0) { Count = (SWAPW(RelocationDir->SizeOfBlock) - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(USHORT); Address = (ULONG_PTR)RVA(BaseAddress, SWAPD(RelocationDir->VirtualAddress)); TypeOffset = (PUSHORT)(RelocationDir + 1);
RelocationDir = LdrProcessRelocationBlockLongLong(Address, - Count, - TypeOffset, - Delta); + Count, + TypeOffset, + Delta);
if (RelocationDir == NULL) { @@ -295,4 +293,5 @@
return Success; } + /* EOF */