Author: arty Date: Mon Jan 8 13:12:22 2007 New Revision: 25377
URL: http://svn.reactos.org/svn/reactos?rev=25377&view=rev Log: Update address of hal before performing imports, add page.c
Modified: branches/powerpc/reactos/ntoskrnl/ke/freeldr.c branches/powerpc/reactos/ntoskrnl/ldr/loader.c branches/powerpc/reactos/ntoskrnl/ntoskrnl.rbuild
Modified: branches/powerpc/reactos/ntoskrnl/ke/freeldr.c URL: http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/ntoskrnl/ke/free... ============================================================================== --- branches/powerpc/reactos/ntoskrnl/ke/freeldr.c (original) +++ branches/powerpc/reactos/ntoskrnl/ke/freeldr.c Mon Jan 8 13:12:22 2007 @@ -295,6 +295,11 @@ BootPath = LoaderBlock->LoadOptions; do {if (*BootPath == '/') *BootPath = ' ';} while (*BootPath++); } + +VOID +INIT_FUNCTION +NTAPI +LdrpSettleHal(PVOID NewHalBase);
VOID FASTCALL @@ -467,18 +472,9 @@ (PVOID)KeLoaderModules[0].ModStart, &DriverSize);
- // - // - // HACK HACK HACK WHEN WILL YOU PEOPLE FIX FREELDR?!?!?! - // FREELDR SENDS US AN ***INVALID*** HAL PE HEADER!!! - // WE READ IT IN LdrInitModuleManagement ABOVE!!! - // WE SET .SizeOfImage TO A *GARBAGE* VALUE!!! - // - // This dirty hack fixes it, and should make symbol lookup work too. - // - HalModuleObject.SizeOfImage = RtlImageNtHeader((PVOID)HalModuleObject. - DllBase)-> - OptionalHeader.SizeOfImage; +#ifdef _M_PPC + LdrpSettleHal((PVOID)DriverBase); +#endif
/* Increase the last kernel address with the size of HAL */ MmFreeLdrLastKernelAddress += PAGE_ROUND_UP(DriverSize);
Modified: branches/powerpc/reactos/ntoskrnl/ldr/loader.c URL: http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/ntoskrnl/ldr/loa... ============================================================================== --- branches/powerpc/reactos/ntoskrnl/ldr/loader.c (original) +++ branches/powerpc/reactos/ntoskrnl/ldr/loader.c Mon Jan 8 13:12:22 2007 @@ -26,7 +26,7 @@ #endif /* __GNUC__ */ #endif
-#if 0 +#if 1 #undef ps #define ps(args...) DPRINT1(args) #endif @@ -102,6 +102,14 @@ { /* Hook for KDB on initialization of the loader. */ KDB_LOADERINIT_HOOK(&NtoskrnlModuleObject, &HalModuleObject); +} + +VOID +INIT_FUNCTION +NTAPI +LdrpSettleHal (PVOID NewHalBase) +{ + HalModuleObject.DllBase = (PVOID) NewHalBase; }
VOID @@ -994,9 +1002,9 @@ // Copy current section into current offset of virtual section if (Section->SizeOfRawData) { - // ps("PESectionHeaders[Idx].VirtualAddress (%X) + DriverBase %x\n", - // PESectionHeaders[Idx].VirtualAddress, PESectionHeaders[Idx].VirtualAddress + DriverBase); - memcpy(Section->VirtualAddress + (char*)DriverBase, + ps("PESectionHeaders[Idx].VirtualAddress (%X) + DriverBase %x\n", + PESectionHeaders[Idx].VirtualAddress, PESectionHeaders[Idx].VirtualAddress + DriverBase); + memmove(Section->VirtualAddress + (char*)DriverBase, Section->PointerToRawData + (char*)ModuleLoadBase, Section->Misc.VirtualSize > Section->SizeOfRawData ? Section->SizeOfRawData : Section->Misc.VirtualSize); } @@ -1010,6 +1018,17 @@ PENtHeaders->OptionalHeader.SectionAlignment); }
+ /* Perform relocation fixups */ + Status = LdrRelocateImageWithBias(DriverBase, 0, "", STATUS_SUCCESS, + STATUS_CONFLICTING_ADDRESSES, STATUS_INVALID_IMAGE_FORMAT); + + if (!NT_SUCCESS(Status)) + { + return NULL; + } + } + else if(ModuleLoadBase != (PVOID)PENtHeaders->OptionalHeader.ImageBase) + { /* Perform relocation fixups */ Status = LdrRelocateImageWithBias(DriverBase, 0, "", STATUS_SUCCESS, STATUS_CONFLICTING_ADDRESSES, STATUS_INVALID_IMAGE_FORMAT); @@ -1392,6 +1411,7 @@ DPRINT1("Failed to import %s from %wZ\n", pe_name->Name, &ImportedModule->FullDllName); return STATUS_UNSUCCESSFUL; } + DbgPrint("Function %08x: %s\n", *ImportAddressList, pe_name->Name); } ImportAddressList++; FunctionNameList++;
Modified: branches/powerpc/reactos/ntoskrnl/ntoskrnl.rbuild URL: http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/ntoskrnl/ntoskrn... ============================================================================== --- branches/powerpc/reactos/ntoskrnl/ntoskrnl.rbuild (original) +++ branches/powerpc/reactos/ntoskrnl/ntoskrnl.rbuild Mon Jan 8 13:12:22 2007 @@ -253,6 +253,11 @@ <file>pfault.c</file> </directory> </if> + <if property="ARCH" value="powerpc"> + <directory name="powerpc"> + <file>page.c</file> + </directory> + </if> <file>anonmem.c</file> <file>aspace.c</file> <file>balance.c</file>