From: Hartmut Birr Date: Wed, 17 Aug 2005 20:41:15 +0000 (+0000) Subject: Load the symbols from ntoskrn.exe from the boot cd, if it is possible. X-Git-Tag: ReactOS-0.2.8~975 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=f8cf29f8d00d25728508e175ba3cf536d9cc0910 Load the symbols from ntoskrn.exe from the boot cd, if it is possible. svn path=/trunk/; revision=17425 --- diff --git a/reactos/boot/freeldr/freeldr/reactos/setupldr.c b/reactos/boot/freeldr/freeldr/reactos/setupldr.c index 319ba3a2ccb..7d27ce4563e 100644 --- a/reactos/boot/freeldr/freeldr/reactos/setupldr.c +++ b/reactos/boot/freeldr/freeldr/reactos/setupldr.c @@ -19,6 +19,7 @@ */ #include +#include #include #include #include @@ -42,6 +43,21 @@ memory_map_t reactos_memory_map[32]; // Memory map #define USE_UI +static BOOLEAN +FreeldrReadFile(PVOID FileContext, PVOID Buffer, ULONG Size) +{ + ULONG BytesRead; + + return FsReadFile((PFILE) FileContext, (ULONG) Size, &BytesRead, Buffer) + && Size == BytesRead; +} + +static BOOLEAN +FreeldrSeekFile(PVOID FileContext, ULONG_PTR Position) +{ + FsSetFilePointer((PFILE) FileContext, (ULONG) Position); + return TRUE; +} static BOOL LoadKernel(PCHAR szSourcePath, PCHAR szFileName) @@ -108,6 +124,60 @@ LoadKernel(PCHAR szSourcePath, PCHAR szFileName) return(TRUE); } +static BOOL +LoadKernelSymbols(PCHAR szSourcePath, PCHAR szFileName) +{ + static ROSSYM_CALLBACKS FreeldrCallbacks = + { + MmAllocateMemory, + MmFreeMemory, + FreeldrReadFile, + FreeldrSeekFile + }; + CHAR szFullName[256]; + PFILE FilePointer; + PROSSYM_INFO RosSymInfo; + ULONG Size; + ULONG_PTR Base; + + if (szSourcePath[0] != '\\') + { + strcpy(szFullName, "\\"); + strcat(szFullName, szSourcePath); + } + else + { + strcpy(szFullName, szSourcePath); + } + + if (szFullName[strlen(szFullName)] != '\\') + { + strcat(szFullName, "\\"); + } + + if (szFileName[0] != '\\') + { + strcat(szFullName, szFileName); + } + else + { + strcat(szFullName, szFileName + 1); + } + + RosSymInit(&FreeldrCallbacks); + + FilePointer = FsOpenFile(szFullName); + if (FilePointer && RosSymCreateFromFile(FilePointer, &RosSymInfo)) + { + Base = FrLdrCreateModule("NTOSKRNL.SYM"); + Size = RosSymGetRawDataLength(RosSymInfo); + RosSymGetRawData(RosSymInfo, (PVOID)Base); + FrLdrCloseModule(Base, Size); + RosSymDelete(RosSymInfo); + return TRUE; + } + return FALSE; +} static BOOL LoadDriver(PCHAR szSourcePath, PCHAR szFileName) @@ -388,6 +458,8 @@ VOID RunLoader(VOID) if (!LoadDriver(SourcePath, "hal.dll")) return; + /* Create ntoskrnl.sym */ + LoadKernelSymbols(SourcePath, "ntoskrnl.exe"); /* Export the hardware hive */ Base = FrLdrCreateModule ("HARDWARE");