Don't map NOLOAD sections
authorDavid Welch <welch@cwcom.net>
Fri, 30 Mar 2001 15:14:53 +0000 (15:14 +0000)
committerDavid Welch <welch@cwcom.net>
Fri, 30 Mar 2001 15:14:53 +0000 (15:14 +0000)
svn path=/trunk/; revision=1748

reactos/drivers/net/dd/ne2000/.cvsignore
reactos/include/pe.h
reactos/lib/kernel32/makefile
reactos/ntoskrnl/ke/i386/exp.c
reactos/ntoskrnl/mm/section.c
reactos/ntoskrnl/ntoskrnl.lnk

index 418f399..9237ac3 100644 (file)
@@ -1,2 +1,2 @@
 ne2000.coff
-objects
\ No newline at end of file
+objects
index 3d74de8..14004ae 100644 (file)
@@ -12,7 +12,7 @@
 #define IMAGE_SECTION_CHAR_EXECUTABLE    0x20000000
 #define IMAGE_SECTION_CHAR_READABLE      0x40000000
 #define IMAGE_SECTION_CHAR_WRITABLE      0x80000000
-
+#define IMAGE_SECTION_NOLOAD             0x00000002
 
 #define IMAGE_DOS_MAGIC  0x5a4d
 #define IMAGE_PE_MAGIC   0x00004550
index 9e3c327..9d3a613 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.44 2001/02/17 17:41:17 ekohl Exp $
+# $Id: makefile,v 1.45 2001/03/30 15:14:52 dwelch Exp $
 #
 # ReactOS Operating System
 #
@@ -8,7 +8,7 @@ TARGET = kernel32
 
 KERNEL32_BASE = 0x77f00000
 
-CFLAGS = -DKERNEL32_BASE=$(KERNEL32_BASE)
+CFLAGS := -DKERNEL32_BASE=$(KERNEL32_BASE) -g
 
 DLLTARGET=$(TARGET).dll
 
index a26c75b..532340e 100644 (file)
@@ -313,6 +313,7 @@ KiTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr)
    PULONG stack;
    NTSTATUS Status;
    ULONG Esp0;
+   ULONG StackLimit;
    static char *TypeStrings[] = 
      {
        "Divide Error",
@@ -437,6 +438,15 @@ KiTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr)
        stack = (PULONG)(((ULONG)stack) & (~0x3));
        
        DbgPrint("stack<%p>: ", stack);
+
+       if (PsGetCurrentThread() != NULL)
+        {
+          StackLimit = (ULONG)PsGetCurrentThread()->Tcb.StackBase;
+        }
+       else
+        {
+          StackLimit = (ULONG)&init_stack_top;
+        }
         
        for (i = 0; i < 18; i = i + 6)
         {
@@ -446,7 +456,7 @@ KiTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr)
                     stack[i+4], stack[i+5]);
         }
        DbgPrint("Frames:\n");
-       for (i = 0; i < 32; i++)
+       for (i = 0; i < 32 && ((ULONG)&stack[i] < StackLimit); i++)
         {
            if (stack[i] > ((unsigned int) &_text_start__) &&
              !(stack[i] >= ((ULONG)&init_stack) &&
@@ -508,10 +518,12 @@ KiTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr)
    for(;;);
 }
 
-VOID KeDumpStackFrames(PVOID _Stack, ULONG NrFrames)
+VOID 
+KeDumpStackFrames(PVOID _Stack, ULONG NrFrames)
 {
    PULONG Stack = (PULONG)_Stack;
    ULONG i;
+   ULONG StackLimit;
    
    Stack = (PVOID)(((ULONG)Stack) & (~0x3));
    DbgPrint("Stack: %x\n", Stack);
@@ -520,14 +532,21 @@ VOID KeDumpStackFrames(PVOID _Stack, ULONG NrFrames)
        DbgPrint("kernel stack base %x\n",
                 PsGetCurrentThread()->Tcb.StackLimit);
      }
+
+   if (PsGetCurrentThread() != NULL)
+     {
+       StackLimit = (ULONG)PsGetCurrentThread()->Tcb.StackBase;
+     }
+   else
+     {
+       StackLimit = (ULONG)&init_stack_top;
+     }
    
    DbgPrint("Frames:\n");
-   for (i=0; i<NrFrames; i++)
+   for (i=0; i<NrFrames && ((ULONG)&Stack[i] < StackLimit); i++)
      {
-//     if (Stack[i] > KERNEL_BASE && Stack[i] < ((ULONG)&etext))
        if (Stack[i] > KERNEL_BASE)
          {
-//          DbgPrint("%.8x  ",Stack[i]);
             print_address((PVOID)Stack[i]);
             DbgPrint(" ");
          }
index 592fe7b..679c42a 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: section.c,v 1.53 2001/03/29 17:24:43 dwelch Exp $
+/* $Id: section.c,v 1.54 2001/03/30 15:14:53 dwelch Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/mm/section.c
@@ -1557,7 +1557,6 @@ MmMapViewOfSegment(PEPROCESS Process,
                              FALSE);
    if (!NT_SUCCESS(Status))
      {
-       MmUnlockAddressSpace(AddressSpace);
        return(Status);
      }
    
@@ -1680,27 +1679,30 @@ NtMapViewOfSection(HANDLE SectionHandle,
         {
           PVOID SBaseAddress;
 
-          SBaseAddress = (PVOID)
-            ((ULONG)Section->ImageBase + 
-             (ULONG)Section->Segments[i].VirtualAddress);
-
-          MmLockSectionSegment(&Section->Segments[i]);
-          Status = MmMapViewOfSegment(Process,
-                                      &Process->AddressSpace,
-                                      Section,
-                                      &Section->Segments[i],
-                                      &SBaseAddress,
-                                      Section->Segments[i].Length,
-                                      Section->Segments[i].Protection,
-                                      Section->Segments[i].FileOffset);
-          MmUnlockSectionSegment(&Section->Segments[i]);
-          if (!NT_SUCCESS(Status))
+          if (!(Section->Segments[i].Characteristics & IMAGE_SECTION_NOLOAD))
             {
-              MmUnlockSection(Section);
-              MmUnlockAddressSpace(AddressSpace);             
-              ObDereferenceObject(Section);
-              ObDereferenceObject(Process);
-              return(Status);
+              SBaseAddress = (PVOID)
+                ((ULONG)Section->ImageBase + 
+                 (ULONG)Section->Segments[i].VirtualAddress);
+
+              MmLockSectionSegment(&Section->Segments[i]);
+              Status = MmMapViewOfSegment(Process,
+                                          &Process->AddressSpace,
+                                          Section,
+                                          &Section->Segments[i],
+                                          &SBaseAddress,
+                                          Section->Segments[i].Length,
+                                          Section->Segments[i].Protection,
+                                          Section->Segments[i].FileOffset);
+              MmUnlockSectionSegment(&Section->Segments[i]);
+              if (!NT_SUCCESS(Status))
+                {
+                  MmUnlockSection(Section);
+                  MmUnlockAddressSpace(AddressSpace);         
+                  ObDereferenceObject(Section);
+                  ObDereferenceObject(Process);
+                  return(Status);
+                }
             }
         }
        *BaseAddress = Section->ImageBase;
index 1a234da..5406695 100644 (file)
@@ -80,10 +80,12 @@ SECTIONS
     *(COMMON)
     __bss_end__ = . ;
   }
+/*
   .reloc BLOCK(__section_alignment__) :
   {                                    
     *(.reloc) 
   }
+*/
   .stab BLOCK(__section_alignment__) (NOLOAD) :
   {
     [ .stab ]