[ros-diffs] [akorotaev] 31574: More merging. No progress with bugcheck.

akorotaev at svn.reactos.org akorotaev at svn.reactos.org
Wed Jan 2 23:43:00 CET 2008


Author: akorotaev
Date: Thu Jan  3 01:43:00 2008
New Revision: 31574

URL: http://svn.reactos.org/svn/reactos?rev=31574&view=rev
Log:
More merging. No progress with bugcheck.

Modified:
    branches/cache_manager_rewrite/mm/pageop.c
    branches/cache_manager_rewrite/mm/pe.c
    branches/cache_manager_rewrite/mm/rmap.c
    branches/cache_manager_rewrite/mm/rpoolmgr.h
    branches/cache_manager_rewrite/mm/section.c
    branches/cache_manager_rewrite/mm/sysldr.c

Modified: branches/cache_manager_rewrite/mm/pageop.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/pageop.c?rev=31574&r1=31573&r2=31574&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/pageop.c (original)
+++ branches/cache_manager_rewrite/mm/pageop.c Thu Jan  3 01:43:00 2008
@@ -17,7 +17,7 @@
 #if defined (ALLOC_PRAGMA)
 #pragma alloc_text(INIT, MmInitializePageOp)
 #endif
- 
+
 
 /* GLOBALS *******************************************************************/
 

Modified: branches/cache_manager_rewrite/mm/pe.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/pe.c?rev=31574&r1=31573&r2=31574&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/pe.c (original)
+++ branches/cache_manager_rewrite/mm/pe.c Thu Jan  3 01:43:00 2008
@@ -431,7 +431,7 @@
 
     if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, AddressOfEntryPoint))
     {
-	ImageSectionObject->EntryPoint = piohOptHeader->ImageBase + 
+	ImageSectionObject->EntryPoint = piohOptHeader->ImageBase +
                                          piohOptHeader->AddressOfEntryPoint;
     }
 
@@ -598,9 +598,9 @@
 	if(pishSectionHeaders[i].SizeOfRawData != 0)
 	{
 	    /* validate the alignment */
-#if 0	    
+#if 0
 	    /* Yes, this should be a multiple of FileAlignment, but there's
-	     * stuff out there that isn't. We can cope with that 
+	     * stuff out there that isn't. We can cope with that
 	     */
 	    if(!IsAligned(pishSectionHeaders[i].SizeOfRawData, nFileAlignment))
 		DIE(("SizeOfRawData[%u] is not aligned\n", i));
@@ -677,108 +677,4 @@
     return nStatus;
 }
 
-BOOLEAN
-NTAPI
-MmVerifyImageIsOkForMpUse(IN PVOID BaseAddress)
-{
-    PIMAGE_NT_HEADERS NtHeader;
-    PAGED_CODE();
-
-    /* Get NT Headers */
-    NtHeader = RtlImageNtHeader(BaseAddress);
-    if (NtHeader)
-    {
-        /* Check if this image is only safe for UP while we have 2+ CPUs */
-        if ((KeNumberProcessors > 1) &&
-            (NtHeader->FileHeader.Characteristics & IMAGE_FILE_UP_SYSTEM_ONLY))
-        {
-            /* Fail */
-            return FALSE;
-        }
-    }
-
-    /* Otherwise, it's safe */
-    return TRUE;
-}
-
-NTSTATUS
-NTAPI
-MmCheckSystemImage(IN HANDLE ImageHandle,
-                   IN BOOLEAN PurgeSection)
-{
-    NTSTATUS Status;
-    HANDLE SectionHandle;
-    PVOID ViewBase = NULL;
-    SIZE_T ViewSize = 0;
-    IO_STATUS_BLOCK IoStatusBlock;
-    FILE_STANDARD_INFORMATION FileStandardInfo;
-    KAPC_STATE ApcState;
-    PAGED_CODE();
-
-    /* Create a section for the DLL */
-    Status = ZwCreateSection(&SectionHandle,
-                             SECTION_MAP_EXECUTE,
-                             NULL,
-                             NULL,
-                             PAGE_EXECUTE,
-                             SEC_COMMIT,
-                             ImageHandle);
-    if (!NT_SUCCESS(Status)) return Status;
-
-    /* Make sure we're in the system process */
-    KeStackAttachProcess(&PsInitialSystemProcess->Pcb, &ApcState);
-
-    /* Map it */
-    Status = ZwMapViewOfSection(SectionHandle,
-                                NtCurrentProcess(),
-                                &ViewBase,
-                                0,
-                                0,
-                                NULL,
-                                &ViewSize,
-                                ViewShare,
-                                0,
-                                PAGE_EXECUTE);
-    if (!NT_SUCCESS(Status))
-    {
-        /* We failed, close the handle and return */
-        KeUnstackDetachProcess(&ApcState);
-        ZwClose(SectionHandle);
-        return Status;
-    }
-
-    /* Now query image information */
-    Status = ZwQueryInformationFile(ImageHandle,
-                                    &IoStatusBlock,
-                                    &FileStandardInfo,
-                                    sizeof(FileStandardInfo),
-                                    FileStandardInformation);
-    if ( NT_SUCCESS(Status) )
-    {
-        /* First, verify the checksum */
-        if (!LdrVerifyMappedImageMatchesChecksum(ViewBase,
-                                                 FileStandardInfo.
-                                                 EndOfFile.LowPart,
-                                                 FileStandardInfo.
-                                                 EndOfFile.LowPart))
-        {
-            /* Set checksum failure */
-            Status = STATUS_IMAGE_CHECKSUM_MISMATCH;
-        }
-
-        /* Check that it's a valid SMP image if we have more then one CPU */
-        if (!MmVerifyImageIsOkForMpUse(ViewBase))
-        {
-            /* Otherwise it's not the right image */
-            Status = STATUS_IMAGE_MP_UP_MISMATCH;
-        }
-    }
-
-    /* Unmap the section, close the handle, and return status */
-    ZwUnmapViewOfSection(NtCurrentProcess(), ViewBase);
-    KeUnstackDetachProcess(&ApcState);
-    ZwClose(SectionHandle);
-    return Status;
-}
-
 /* EOF */

Modified: branches/cache_manager_rewrite/mm/rmap.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/rmap.c?rev=31574&r1=31573&r2=31574&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/rmap.c (original)
+++ branches/cache_manager_rewrite/mm/rmap.c Thu Jan  3 01:43:00 2008
@@ -120,7 +120,7 @@
    Type = MemoryArea->Type;
    if (Type == MEMORY_AREA_SECTION_VIEW)
    {
-      Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress 
+      Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
                + MemoryArea->Data.SectionData.ViewOffset;
       /*
        * Get or create a pageop
@@ -245,7 +245,7 @@
    Type = MemoryArea->Type;
    if (Type == MEMORY_AREA_SECTION_VIEW)
    {
-      Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress 
+      Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
              + MemoryArea->Data.SectionData.ViewOffset;;
 
       /*
@@ -410,7 +410,7 @@
    new_entry->Process = (PEPROCESS)Process;
 #ifdef DBG
    new_entry->Caller = __builtin_return_address(0);
-#endif   
+#endif
 
    if (MmGetPfnForProcess(Process, Address) != Page)
    {
@@ -429,7 +429,7 @@
    {
       if (current_entry->Address == new_entry->Address && current_entry->Process == new_entry->Process)
       {
-          DbgPrint("MmInsertRmap tries to add a second rmap entry for address %p\n    current caller ", 
+          DbgPrint("MmInsertRmap tries to add a second rmap entry for address %p\n    current caller ",
                    current_entry->Address);
           KeRosPrintAddress(new_entry->Caller);
           DbgPrint("\n    previous caller ");

Modified: branches/cache_manager_rewrite/mm/rpoolmgr.h
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/rpoolmgr.h?rev=31574&r1=31573&r2=31574&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/rpoolmgr.h (original)
+++ branches/cache_manager_rewrite/mm/rpoolmgr.h Thu Jan  3 01:43:00 2008
@@ -143,7 +143,7 @@
 		if ( Block->LastOwnerStack[i] != 0xDEADBEEF )
 		{
 			R_DEBUG(" ");
-			if (!R_PRINT_ADDRESS ((PVOID)Block->LastOwnerStack[i]) )
+			//if (!R_PRINT_ADDRESS ((PVOID)Block->LastOwnerStack[i]) )
 			{
 				R_DEBUG("<%X>", Block->LastOwnerStack[i] );
 			}
@@ -427,12 +427,12 @@
 
 	ASSERT ( Addr >= (char*)pool->UserBase && Addr < ((char*)pool->UserBase + pool->UserSize - 16) );
 #ifdef R_MAGIC
-	if ( pUsed->UsedMagic == MM_PPOOL_FREEMAGIC )
+	if ( pUsed->UsedMagic == R_FREE_MAGIC )
 	{
 		pUsed->UserSize = 0; // just to keep from confusion, MmpBadBlock() doesn't return...
 		RiBadBlock ( pUsed, Addr, "double-free", file, line, 0 );
 	}
-	if ( pUsed->UsedMagic != MM_PPOOL_USEDMAGIC )
+	if ( pUsed->UsedMagic != R_USED_MAGIC )
 	{
 		RiBadBlock ( pUsed, Addr, "bad magic", file, line, 0 );
 	}
@@ -650,7 +650,7 @@
 {
 	Block->Status = 1;
 	RUsedFillStack ( Block );
-#if R_MAGIC
+#ifdef R_MAGIC
 	Block->UsedMagic = R_USED_MAGIC;
 #endif//R_MAGIC
 	//ASSERT_SIZE ( Block->Size );
@@ -978,7 +978,7 @@
 {
 	PR_USED Block = RBodyToHdr(Addr);
 	// TODO FIXME - should we validate params?
-#if R_MAGIC
+#ifdef R_MAGIC
 	if ( Block->UsedMagic != R_USED_MAGIC )
 		return 0xDEADBEEF;
 #endif//R_MAGIC

Modified: branches/cache_manager_rewrite/mm/section.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/section.c?rev=31574&r1=31573&r2=31574&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/section.c (original)
+++ branches/cache_manager_rewrite/mm/section.c Thu Jan  3 01:43:00 2008
@@ -32,7 +32,7 @@
  *                  Ge van Geldorp
  *                  Royce Mitchell III
  *                  Filip Navara
- *                  Aleksey Bragin 
+ *                  Aleksey Bragin
  *                  Jason Filby
  *                  Thomas Weidenmueller
  *                  Gunnar Andre' Dalsnes
@@ -182,7 +182,7 @@
     /*
      * FIXME: TODO.
      * Filip says to get the MADDRESS_SPACE from EPROCESS,
-     * then use the MmMarea routines to locate the Marea that 
+     * then use the MmMarea routines to locate the Marea that
      * corresponds to the address. Then make sure it's a section
      * view type (MEMORY_AREA_SECTION_VIEW) and use the marea's
      * per-type union to get the .u.SectionView.Section pointer to
@@ -1049,8 +1049,8 @@
            AddressSpace, MemoryArea, Address, Locked);
 
    PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
-   SegmentOffset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress 
-            + MemoryArea->Data.SectionData.ViewOffset;
+   SegmentOffset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress
+                 + MemoryArea->Data.SectionData.ViewOffset;
 
    Segment = MemoryArea->Data.SectionData.Segment;
    Section = MemoryArea->Data.SectionData.Section;
@@ -2281,7 +2281,7 @@
     * Find the offset of the page
     */
    PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
-   Offset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress 
+   Offset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress
             + MemoryArea->Data.SectionData.ViewOffset;
 
    Segment = MemoryArea->Data.SectionData.Segment;
@@ -2459,7 +2459,7 @@
    {
       MmUnlockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot);
    }
-   
+
    if (PageOutContext->Private)
    {
       MmReleasePageMemoryConsumer(PageOutContext->Consumer, Page);
@@ -2492,9 +2492,7 @@
    Context.Segment = MemoryArea->Data.SectionData.Segment;
    Context.Section = MemoryArea->Data.SectionData.Section;
 
-   Context.Consumer = MemoryArea->Type == MEMORY_AREA_CACHE_SEGMENT ? MC_CACHE : MC_USER;
-
-   Context.Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress 
+   Context.Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
                     + MemoryArea->Data.SectionData.ViewOffset;
    FileOffset = Context.Offset + Context.Segment->FileOffset;
 
@@ -2796,7 +2794,7 @@
 
    Address = (PVOID)PAGE_ROUND_DOWN(Address);
 
-   Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress 
+   Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
             + MemoryArea->Data.SectionData.ViewOffset;
 
    /*
@@ -2965,7 +2963,7 @@
             ULONG Entry;
             PFN_TYPE Page;
 
-            Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress 
+            Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
                      + MemoryArea->Data.SectionData.ViewOffset;
             Entry = MmGetPageEntrySectionSegment(Segment, Offset);
             Page = MmGetPfnForProcess(AddressSpace->Process, Address);
@@ -3272,7 +3270,7 @@
    UNICODE_STRING Name;
 
    DPRINT("Creating Section Object Type\n");
-  
+
    /* Initialize the Section object type  */
    RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
    RtlInitUnicodeString(&Name, L"Section");
@@ -3434,10 +3432,13 @@
    /*
     * Reference the file object
     */
-   Status = ObReferenceObjectByPointer(FileObject,
-                                       FileAccess,
-                                       IoFileObjectType,
-                                       UserMode);
+   Status = ObReferenceObjectByHandle(FileObject,
+                                      FileAccess,
+                                      IoFileObjectType,
+                                      ExGetPreviousMode(),
+                                      (PVOID*)(PVOID)&FileObject,
+                                      NULL);
+
    if (!NT_SUCCESS(Status))
    {
       ObDereferenceObject(Section);
@@ -4372,7 +4373,7 @@
          ObDereferenceObject(Section);
          return(STATUS_NO_MEMORY);
       }
-      
+
       RtlZeroMemory(ImageSectionObject, sizeof(MM_IMAGE_SECTION_OBJECT));
 
       StatusExeFmt = ExeFmtpCreateImageSection(FileObject, ImageSectionObject);
@@ -4987,7 +4988,7 @@
    ASSERT(Process);
 
    AddressSpace = (PMADDRESS_SPACE)&(Process)->VadRoot;
-   
+
    MmLockAddressSpace(AddressSpace);
    MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace,
                                             BaseAddress);

Modified: branches/cache_manager_rewrite/mm/sysldr.c
URL: http://svn.reactos.org/svn/reactos/branches/cache_manager_rewrite/mm/sysldr.c?rev=31574&r1=31573&r2=31574&view=diff
==============================================================================
--- branches/cache_manager_rewrite/mm/sysldr.c (original)
+++ branches/cache_manager_rewrite/mm/sysldr.c Thu Jan  3 01:43:00 2008
@@ -1353,8 +1353,6 @@
     return TRUE;
 }
 
-#if 0
-
 BOOLEAN
 NTAPI
 MmVerifyImageIsOkForMpUse(IN PVOID BaseAddress)
@@ -1458,8 +1456,6 @@
     ZwClose(SectionHandle);
     return Status;
 }
-
-#endif
 
 NTSTATUS
 NTAPI




More information about the Ros-diffs mailing list