reactos/ntoskrnl/dbg
diff -u -r1.17 -r1.18
--- kdb_stabs.c 22 Oct 2004 20:16:46 -0000 1.17
+++ kdb_stabs.c 15 Dec 2004 01:49:37 -0000 1.18
@@ -88,12 +88,10 @@
if (RelativeAddress != NULL)
{
- if (StabEntry->n_value < (ULONG_PTR)SymbolInfo->ImageBase)
- continue;
- if (StabEntry->n_value >= ((ULONG_PTR)SymbolInfo->ImageBase + SymbolInfo->ImageSize))
+ if (StabEntry->n_value >= SymbolInfo->ImageSize)
continue;
- SymbolRelativeAddress = StabEntry->n_value - (ULONG_PTR)SymbolInfo->ImageBase;
+ SymbolRelativeAddress = StabEntry->n_value;
if ((SymbolRelativeAddress <= (ULONG_PTR)RelativeAddress) &&
(SymbolRelativeAddress > AddrFound))
{
@@ -109,9 +107,13 @@
}
if (BestStabEntry == NULL)
+ {
DPRINT("StabEntry not found!\n");
+ }
else
+ {
DPRINT("StabEntry found!\n");
+ }
return BestStabEntry;
}
reactos/tools
diff -u -r1.4 -r1.5
--- rsym.c 15 Mar 2004 21:31:45 -0000 1.4
+++ rsym.c 15 Dec 2004 01:49:37 -0000 1.5
@@ -125,7 +125,7 @@
#define N_SLINE 0x44
#define N_SO 0x64
-typedef struct
+typedef struct
{
unsigned long OldOffset;
unsigned long NewOffset;
@@ -137,9 +137,9 @@
{
char* newpath;
int i;
-
+
newpath = strdup(origpath);
-
+
i = 0;
while (newpath[i] != 0)
{
@@ -154,8 +154,8 @@
{
newpath[i] = '\\';
}
-#endif
-#endif
+#endif
+#endif
i++;
}
return(newpath);
@@ -168,7 +168,9 @@
SYMBOLFILE_HEADER SymbolFileHeader;
IMAGE_DOS_HEADER PEDosHeader;
IMAGE_FILE_HEADER PEFileHeader;
+ PIMAGE_OPTIONAL_HEADER PEOptHeader;
PIMAGE_SECTION_HEADER PESectionHeaders;
+ ULONG ImageBase;
PVOID SymbolsBase;
ULONG SymbolsLength;
PVOID SymbolStringsBase;
@@ -187,16 +189,16 @@
PSTR_ENTRY StrEntry;
ULONG StrCount;
ULONG j;
-
+
if (argc != 3)
{
fprintf(stderr, "Too many arguments\n");
exit(1);
}
-
+
path1 = convert_path(argv[1]);
path2 = convert_path(argv[2]);
-
+
in = fopen(path1, "rb");
if (in == NULL)
{
@@ -224,6 +226,11 @@
fseek(in, PEDosHeader.e_lfanew + sizeof(ULONG), SEEK_SET);
n_in = fread(&PEFileHeader, 1, sizeof(PEFileHeader), in);
+ /* Read optional header */
+ PEOptHeader = malloc(PEFileHeader.SizeOfOptionalHeader);
+ fread ( PEOptHeader, 1, PEFileHeader.SizeOfOptionalHeader, in );
+ ImageBase = PEOptHeader->ImageBase;
+
/* Read PE section headers */
PESectionHeaders = malloc(PEFileHeader.NumberOfSections * sizeof(IMAGE_SECTION_HEADER));
fseek(in, PEDosHeader.e_lfanew + sizeof(ULONG) + sizeof(IMAGE_FILE_HEADER)
@@ -242,7 +249,7 @@
if ((strncmp(PESectionHeaders[Idx].Name, ".stab", 5) == 0)
&& (PESectionHeaders[Idx].Name[5] == 0))
{
- //printf(".stab section found. Size %d\n",
+ //printf(".stab section found. Size %d\n",
// PESectionHeaders[Idx].SizeOfRawData);
SymbolsLength = PESectionHeaders[Idx].SizeOfRawData;
@@ -254,7 +261,7 @@
if (strncmp(PESectionHeaders[Idx].Name, ".stabstr", 8) == 0)
{
- //printf(".stabstr section found. Size %d\n",
+ //printf(".stabstr section found. Size %d\n",
// PESectionHeaders[Idx].SizeOfRawData);
SymbolStringsLength = PESectionHeaders[Idx].SizeOfRawData;
@@ -276,6 +283,8 @@
StabEntry[i].n_type == N_SO)
{
memmove(&StabEntry[Count], &StabEntry[i], sizeof(STAB_ENTRY));
+ if ( StabEntry[Count].n_value >= ImageBase )
+ StabEntry[Count].n_value -= ImageBase;
Count++;
}
}