#undef MmSetPageEntrySectionSegment
#define MmSetPageEntrySectionSegment(S,O,E) do { \
- DPRINT("SetPageEntrySectionSegment(old,%x,%x,%x)\n",(S),(O)->LowPart,E); \
+ DPRINT("SetPageEntrySectionSegment(old,%p,%x,%x)\n",(S),(O)->LowPart,E); \
_MmSetPageEntrySectionSegment((S),(O),(E),__FILE__,__LINE__); \
} while (0)
PAGE_EXECUTE_READWRITE, /* 15 = WRITABLE, READABLE, EXECUTABLE, SHARED */
};
+extern ULONG MmMakeFileAccess [];
ACCESS_MASK NTAPI MiArm3GetCorrectFileAccessMask(IN ACCESS_MASK SectionPageProtection);
static GENERIC_MAPPING MmpSectionMapping = {
STANDARD_RIGHTS_READ | SECTION_MAP_READ | SECTION_QUERY,
ULONG cbHeadersSize = 0;
ULONG nSectionAlignment;
ULONG nFileAlignment;
+ ULONG_PTR ImageBase;
const IMAGE_DOS_HEADER * pidhDosHeader;
const IMAGE_NT_HEADERS32 * pinhNtHeader;
const IMAGE_OPTIONAL_HEADER32 * piohOptHeader;
nStatus = ReadFileCb(File, &lnOffset, sizeof(IMAGE_NT_HEADERS64), &pData, &pBuffer, &cbReadSize);
if(!NT_SUCCESS(nStatus))
- DIE(("ReadFile failed, status %08X\n", nStatus));
+ {
+ NTSTATUS ReturnedStatus = nStatus;
+
+ /* If it attempted to read past the end of the file, it means e_lfanew is invalid */
+ if (ReturnedStatus == STATUS_END_OF_FILE) nStatus = STATUS_ROS_EXEFMT_UNKNOWN_FORMAT;
+
+ DIE(("ReadFile failed, status %08X\n", ReturnedStatus));
+ }
ASSERT(pData);
ASSERT(pBuffer);
/* PE32 */
case IMAGE_NT_OPTIONAL_HDR32_MAGIC:
{
- if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, ImageBase))
- ImageSectionObject->ImageBase = piohOptHeader->ImageBase;
+ if (RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, ImageBase))
+ ImageBase = piohOptHeader->ImageBase;
if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, SizeOfImage))
- ImageSectionObject->ImageSize = piohOptHeader->SizeOfImage;
+ ImageSectionObject->ImageInformation.ImageFileSize = piohOptHeader->SizeOfImage;
if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, SizeOfStackReserve))
- ImageSectionObject->StackReserve = piohOptHeader->SizeOfStackReserve;
+ ImageSectionObject->ImageInformation.MaximumStackSize = piohOptHeader->SizeOfStackReserve;
if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, SizeOfStackCommit))
- ImageSectionObject->StackCommit = piohOptHeader->SizeOfStackCommit;
+ ImageSectionObject->ImageInformation.CommittedStackSize = piohOptHeader->SizeOfStackCommit;
+
+ if (RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, Subsystem))
+ {
+ ImageSectionObject->ImageInformation.SubSystemType = piohOptHeader->Subsystem;
+
+ if (RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, MinorSubsystemVersion) &&
+ RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, MajorSubsystemVersion))
+ {
+ ImageSectionObject->ImageInformation.SubSystemMinorVersion = piohOptHeader->MinorSubsystemVersion;
+ ImageSectionObject->ImageInformation.SubSystemMajorVersion = piohOptHeader->MajorSubsystemVersion;
+ }
+ }
+
+ if (RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, AddressOfEntryPoint))
+ {
+ ImageSectionObject->ImageInformation.TransferAddress = (PVOID) (ImageBase +
+ piohOptHeader->AddressOfEntryPoint);
+ }
+
+ if (RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, SizeOfCode))
+ ImageSectionObject->ImageInformation.ImageContainsCode = piohOptHeader->SizeOfCode != 0;
+ else
+ ImageSectionObject->ImageInformation.ImageContainsCode = TRUE;
+
+ if (RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, AddressOfEntryPoint))
+ {
+ if (piohOptHeader->AddressOfEntryPoint == 0)
+ {
+ ImageSectionObject->ImageInformation.ImageContainsCode = FALSE;
+ }
+ }
+
+ if (RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, LoaderFlags))
+ ImageSectionObject->ImageInformation.LoaderFlags = piohOptHeader->LoaderFlags;
+
+ if (RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, DllCharacteristics))
+ {
+ ImageSectionObject->ImageInformation.DllCharacteristics = piohOptHeader->DllCharacteristics;
+
+ /*
+ * Since we don't really implement SxS yet and LD doesn't supoprt /ALLOWISOLATION:NO, hard-code
+ * this flag here, which will prevent the loader and other code from doing any .manifest or SxS
+ * magic to any binary.
+ *
+ * This will break applications that depend on SxS when running with real Windows Kernel32/SxS/etc
+ * but honestly that's not tested. It will also break them when running no ReactOS once we implement
+ * the SxS support -- at which point, duh, this should be removed.
+ *
+ * But right now, any app depending on SxS is already broken anyway, so this flag only helps.
+ */
+ ImageSectionObject->ImageInformation.DllCharacteristics |= IMAGE_DLLCHARACTERISTICS_NO_ISOLATION;
+ }
break;
}
-
+#ifdef _WIN64
/* PE64 */
case IMAGE_NT_OPTIONAL_HDR64_MAGIC:
{
if(RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, ImageBase))
{
+ ImageBase = pioh64OptHeader->ImageBase;
if(pioh64OptHeader->ImageBase > MAXULONG_PTR)
DIE(("ImageBase exceeds the address space\n"));
-
- ImageSectionObject->ImageBase = (ULONG_PTR)pioh64OptHeader->ImageBase;
}
if(RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, SizeOfImage))
if(pioh64OptHeader->SizeOfImage > MAXULONG_PTR)
DIE(("SizeOfImage exceeds the address space\n"));
- ImageSectionObject->ImageSize = pioh64OptHeader->SizeOfImage;
+ ImageSectionObject->ImageInformation.ImageFileSize = pioh64OptHeader->SizeOfImage;
}
if(RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, SizeOfStackReserve))
if(pioh64OptHeader->SizeOfStackReserve > MAXULONG_PTR)
DIE(("SizeOfStackReserve exceeds the address space\n"));
- ImageSectionObject->StackReserve = (ULONG_PTR)pioh64OptHeader->SizeOfStackReserve;
+ ImageSectionObject->ImageInformation.MaximumStackSize = (ULONG_PTR) pioh64OptHeader->SizeOfStackReserve;
}
if(RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, SizeOfStackCommit))
if(pioh64OptHeader->SizeOfStackCommit > MAXULONG_PTR)
DIE(("SizeOfStackCommit exceeds the address space\n"));
- ImageSectionObject->StackCommit = (ULONG_PTR)pioh64OptHeader->SizeOfStackCommit;
+ ImageSectionObject->ImageInformation.CommittedStackSize = (ULONG_PTR) pioh64OptHeader->SizeOfStackCommit;
}
- break;
- }
- }
+ if (RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, Subsystem))
+ {
+ ImageSectionObject->ImageInformation.SubSystemType = pioh64OptHeader->Subsystem;
+
+ if (RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, MinorSubsystemVersion) &&
+ RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, MajorSubsystemVersion))
+ {
+ ImageSectionObject->ImageInformation.SubSystemMinorVersion = pioh64OptHeader->MinorSubsystemVersion;
+ ImageSectionObject->ImageInformation.SubSystemMajorVersion = pioh64OptHeader->MajorSubsystemVersion;
+ }
+ }
- /* [1], section 3.4.2 */
- if((ULONG_PTR)ImageSectionObject->ImageBase % 0x10000)
- DIE(("ImageBase is not aligned on a 64KB boundary"));
+ if (RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, AddressOfEntryPoint))
+ {
+ ImageSectionObject->ImageInformation.TransferAddress = (PVOID) (ImageBase +
+ pioh64OptHeader->AddressOfEntryPoint);
+ }
- if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, Subsystem))
- {
- ImageSectionObject->Subsystem = piohOptHeader->Subsystem;
+ if (RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, SizeOfCode))
+ ImageSectionObject->ImageInformation.ImageContainsCode = pioh64OptHeader->SizeOfCode != 0;
+ else
+ ImageSectionObject->ImageInformation.ImageContainsCode = TRUE;
- if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, MinorSubsystemVersion) &&
- RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, MajorSubsystemVersion))
- {
- ImageSectionObject->MinorSubsystemVersion = piohOptHeader->MinorSubsystemVersion;
- ImageSectionObject->MajorSubsystemVersion = piohOptHeader->MajorSubsystemVersion;
- }
- }
+ if (RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, AddressOfEntryPoint))
+ {
+ if (pioh64OptHeader->AddressOfEntryPoint == 0)
+ {
+ ImageSectionObject->ImageInformation.ImageContainsCode = FALSE;
+ }
+ }
- if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, AddressOfEntryPoint))
- {
- ImageSectionObject->EntryPoint = ImageSectionObject->ImageBase +
- piohOptHeader->AddressOfEntryPoint;
+ if (RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, LoaderFlags))
+ ImageSectionObject->ImageInformation.LoaderFlags = pioh64OptHeader->LoaderFlags;
+
+ if (RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, DllCharacteristics))
+ ImageSectionObject->ImageInformation.DllCharacteristics = pioh64OptHeader->DllCharacteristics;
+
+ break;
+ }
+#endif // _WIN64
}
- if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, SizeOfCode))
- ImageSectionObject->Executable = piohOptHeader->SizeOfCode != 0;
- else
- ImageSectionObject->Executable = TRUE;
+ /* [1], section 3.4.2 */
+ if((ULONG_PTR)ImageBase % 0x10000)
+ DIE(("ImageBase is not aligned on a 64KB boundary"));
- ImageSectionObject->ImageCharacteristics = pinhNtHeader->FileHeader.Characteristics;
- ImageSectionObject->Machine = pinhNtHeader->FileHeader.Machine;
+ ImageSectionObject->ImageInformation.ImageCharacteristics = pinhNtHeader->FileHeader.Characteristics;
+ ImageSectionObject->ImageInformation.Machine = pinhNtHeader->FileHeader.Machine;
+ ImageSectionObject->ImageInformation.GpValue = 0;
+ ImageSectionObject->ImageInformation.ZeroBits = 0;
+ ImageSectionObject->BasedAddress = (PVOID)ImageBase;
/* SECTION HEADERS */
nStatus = STATUS_INVALID_IMAGE_FORMAT;
pssSegments[i].Length.QuadPart = pishSectionHeaders[i].Misc.VirtualSize;
pssSegments[i].Length.LowPart = ALIGN_UP_BY(pssSegments[i].Length.LowPart, nSectionAlignment);
+ /* FIXME: always false */
if (pssSegments[i].Length.QuadPart < pssSegments[i].Length.QuadPart)
DIE(("Cannot align the virtual size of section %u\n", i));
*Flags |= EXEFMT_LOAD_ASSUME_SEGMENTS_PAGE_ALIGNED;
/* Success */
- nStatus = STATUS_ROS_EXEFMT_LOADED_FORMAT | EXEFMT_LOADED_PE32;
+ nStatus = STATUS_SUCCESS;// STATUS_ROS_EXEFMT_LOADED_FORMAT | EXEFMT_LOADED_PE32;
l_Return:
if(pBuffer)
{
if (SectionSegments[i].ReferenceCount != 0)
{
- DPRINT1("Image segment %d still referenced (was %d)\n", i,
+ DPRINT1("Image segment %lu still referenced (was %lu)\n", i,
SectionSegments[i].ReferenceCount);
KeBugCheck(MEMORY_MANAGEMENT);
}
{
PFILE_OBJECT FileObject;
#ifndef NEWCC
- PBCB Bcb;
+ PROS_SHARED_CACHE_MAP SharedCacheMap;
#endif
SWAPENTRY SavedSwapEntry;
PFN_NUMBER Page;
(Offset->QuadPart + PAGE_SIZE <= Segment->RawLength.QuadPart || !IsImageSection))
{
NTSTATUS Status;
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+ SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
IsDirectMapped = TRUE;
#ifndef NEWCC
- Status = CcRosUnmapCacheSegment(Bcb, FileOffset.LowPart, Dirty);
+ Status = CcRosUnmapVacb(SharedCacheMap, FileOffset.LowPart, Dirty);
#else
Status = STATUS_SUCCESS;
#endif
if (!NT_SUCCESS(Status))
{
- DPRINT1("CcRosUnmapCacheSegment failed, status = %x\n", Status);
+ DPRINT1("CcRosUnmapVacb failed, status = %x\n", Status);
KeBugCheck(MEMORY_MANAGEMENT);
}
}
#ifndef NEWCC
if (!(MemoryArea->Data.SectionData.Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED))
{
- PBCB Bcb;
- PCACHE_SEGMENT CacheSeg;
- Bcb = MemoryArea->Data.SectionData.Section->FileObject->SectionObjectPointer->SharedCacheMap;
- CacheSeg = CcRosLookupCacheSegment(Bcb, (ULONG)(SegOffset + MemoryArea->Data.SectionData.Segment->Image.FileOffset));
- if (CacheSeg)
+ PROS_SHARED_CACHE_MAP SharedCacheMap;
+ PROS_VACB Vacb;
+ SharedCacheMap = MemoryArea->Data.SectionData.Section->FileObject->SectionObjectPointer->SharedCacheMap;
+ Vacb = CcRosLookupVacb(SharedCacheMap, (ULONG)(SegOffset + MemoryArea->Data.SectionData.Segment->Image.FileOffset));
+ if (Vacb)
{
- CcRosReleaseCacheSegment(Bcb, CacheSeg, CacheSeg->Valid, FALSE, TRUE);
+ CcRosReleaseVacb(SharedCacheMap, Vacb, Vacb->Valid, FALSE, TRUE);
return TRUE;
}
}
* Page - Variable that receives a page contains the read data.
*/
{
- ULONG BaseOffset;
+ ULONGLONG BaseOffset;
ULONGLONG FileOffset;
PVOID BaseAddress;
BOOLEAN UptoDate;
- PCACHE_SEGMENT CacheSeg;
+ PROS_VACB Vacb;
PFILE_OBJECT FileObject;
NTSTATUS Status;
ULONG_PTR RawLength;
- PBCB Bcb;
+ PROS_SHARED_CACHE_MAP SharedCacheMap;
BOOLEAN IsImageSection;
ULONG_PTR Length;
FileObject = MemoryArea->Data.SectionData.Section->FileObject;
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+ SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
RawLength = (ULONG_PTR)(MemoryArea->Data.SectionData.Segment->RawLength.QuadPart);
FileOffset = SegOffset + MemoryArea->Data.SectionData.Segment->Image.FileOffset;
IsImageSection = MemoryArea->Data.SectionData.Section->AllocationAttributes & SEC_IMAGE ? TRUE : FALSE;
- ASSERT(Bcb);
+ ASSERT(SharedCacheMap);
- DPRINT("%S %x\n", FileObject->FileName.Buffer, FileOffset);
+ DPRINT("%S %I64x\n", FileObject->FileName.Buffer, FileOffset);
/*
* If the file system is letting us go directly to the cache and the
* memory area was mapped at an offset in the file which is page aligned
- * then get the related cache segment.
+ * then get the related VACB.
*/
if (((FileOffset % PAGE_SIZE) == 0) &&
((SegOffset + PAGE_SIZE <= RawLength) || !IsImageSection) &&
{
/*
- * Get the related cache segment; we use a lower level interface than
- * filesystems do because it is safe for us to use an offset with a
+ * Get the related VACB; we use a lower level interface than
+ * filesystems do because it is safe for us to use an offset with an
* alignment less than the file system block size.
*/
- Status = CcRosGetCacheSegment(Bcb,
- (ULONG)FileOffset,
- &BaseOffset,
- &BaseAddress,
- &UptoDate,
- &CacheSeg);
+ Status = CcRosGetVacb(SharedCacheMap,
+ (ULONG)FileOffset,
+ &BaseOffset,
+ &BaseAddress,
+ &UptoDate,
+ &Vacb);
if (!NT_SUCCESS(Status))
{
return(Status);
if (!UptoDate)
{
/*
- * If the cache segment isn't up to date then call the file
+ * If the VACB isn't up to date then call the file
* system to read in the data.
*/
- Status = ReadCacheSegment(CacheSeg);
+ Status = CcReadVirtualAddress(Vacb);
if (!NT_SUCCESS(Status))
{
- CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE);
+ CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
return Status;
}
}
+
+ /* Probe the page, since it's PDE might not be synced */
+ (void)*((volatile char*)BaseAddress + FileOffset - BaseOffset);
+
/*
- * Retrieve the page from the cache segment that we actually want.
+ * Retrieve the page from the view that we actually want.
*/
(*Page) = MmGetPhysicalAddress((char*)BaseAddress +
FileOffset - BaseOffset).LowPart >> PAGE_SHIFT;
- CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, TRUE);
+ CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, TRUE);
}
else
{
PEPROCESS Process;
KIRQL Irql;
PVOID PageAddr;
- ULONG_PTR CacheSegOffset;
+ ULONG_PTR VacbOffset;
/*
* Allocate a page, this is rather complicated by the possibility
{
return(Status);
}
- Status = CcRosGetCacheSegment(Bcb,
- (ULONG)FileOffset,
- &BaseOffset,
- &BaseAddress,
- &UptoDate,
- &CacheSeg);
+ Status = CcRosGetVacb(SharedCacheMap,
+ (ULONG)FileOffset,
+ &BaseOffset,
+ &BaseAddress,
+ &UptoDate,
+ &Vacb);
if (!NT_SUCCESS(Status))
{
return(Status);
if (!UptoDate)
{
/*
- * If the cache segment isn't up to date then call the file
+ * If the VACB isn't up to date then call the file
* system to read in the data.
*/
- Status = ReadCacheSegment(CacheSeg);
+ Status = CcReadVirtualAddress(Vacb);
if (!NT_SUCCESS(Status))
{
- CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE);
+ CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
return Status;
}
}
Process = PsGetCurrentProcess();
PageAddr = MiMapPageInHyperSpace(Process, *Page, &Irql);
- CacheSegOffset = (ULONG_PTR)(BaseOffset + CacheSeg->Bcb->CacheSegmentSize - FileOffset);
+ VacbOffset = (ULONG_PTR)(BaseOffset + VACB_MAPPING_GRANULARITY - FileOffset);
Length = RawLength - SegOffset;
- if (Length <= CacheSegOffset && Length <= PAGE_SIZE)
+ if (Length <= VacbOffset && Length <= PAGE_SIZE)
{
memcpy(PageAddr, (char*)BaseAddress + FileOffset - BaseOffset, Length);
}
- else if (CacheSegOffset >= PAGE_SIZE)
+ else if (VacbOffset >= PAGE_SIZE)
{
memcpy(PageAddr, (char*)BaseAddress + FileOffset - BaseOffset, PAGE_SIZE);
}
else
{
- memcpy(PageAddr, (char*)BaseAddress + FileOffset - BaseOffset, CacheSegOffset);
+ memcpy(PageAddr, (char*)BaseAddress + FileOffset - BaseOffset, VacbOffset);
MiUnmapPageInHyperSpace(Process, PageAddr, Irql);
- CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
- Status = CcRosGetCacheSegment(Bcb,
- (ULONG)(FileOffset + CacheSegOffset),
- &BaseOffset,
- &BaseAddress,
- &UptoDate,
- &CacheSeg);
+ CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE);
+ Status = CcRosGetVacb(SharedCacheMap,
+ (ULONG)(FileOffset + VacbOffset),
+ &BaseOffset,
+ &BaseAddress,
+ &UptoDate,
+ &Vacb);
if (!NT_SUCCESS(Status))
{
return(Status);
if (!UptoDate)
{
/*
- * If the cache segment isn't up to date then call the file
+ * If the VACB isn't up to date then call the file
* system to read in the data.
*/
- Status = ReadCacheSegment(CacheSeg);
+ Status = CcReadVirtualAddress(Vacb);
if (!NT_SUCCESS(Status))
{
- CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE);
+ CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
return Status;
}
}
PageAddr = MiMapPageInHyperSpace(Process, *Page, &Irql);
if (Length < PAGE_SIZE)
{
- memcpy((char*)PageAddr + CacheSegOffset, BaseAddress, Length - CacheSegOffset);
+ memcpy((char*)PageAddr + VacbOffset, BaseAddress, Length - VacbOffset);
}
else
{
- memcpy((char*)PageAddr + CacheSegOffset, BaseAddress, PAGE_SIZE - CacheSegOffset);
+ memcpy((char*)PageAddr + VacbOffset, BaseAddress, PAGE_SIZE - VacbOffset);
}
}
MiUnmapPageInHyperSpace(Process, PageAddr, Irql);
- CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
+ CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE);
}
return(STATUS_SUCCESS);
}
MmUnlockAddressSpace(AddressSpace);
MiWaitForPageEvent(NULL, NULL);
MmLockAddressSpace(AddressSpace);
- DPRINT("Address 0x%.8X\n", Address);
+ DPRINT("Address 0x%p\n", Address);
return(STATUS_MM_RESTART_OPERATION);
}
* Finish the operation
*/
MiSetPageEvent(Process, Address);
- DPRINT("Address 0x%.8X\n", Address);
+ DPRINT("Address 0x%p\n", Address);
return(STATUS_SUCCESS);
}
* Cleanup and release locks
*/
MiSetPageEvent(Process, Address);
- DPRINT("Address 0x%.8X\n", Address);
- return(STATUS_SUCCESS);
- }
-
- /*
- * Map anonymous memory for BSS sections
- */
- if (Segment->Image.Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
- {
- /* We'll be unlocking the address space below. Prevent us from being preempted
- * in faulting in the page. */
- MmCreatePageFileMapping(Process, Address, MM_WAIT_ENTRY);
- MmUnlockSectionSegment(Segment);
- MI_SET_USAGE(MI_USAGE_SECTION);
- if (Process) MI_SET_PROCESS2(Process->ImageFileName);
- if (!Process) MI_SET_PROCESS2("Kernel Section");
- Status = MmRequestPageMemoryConsumer(MC_USER, FALSE, &Page);
- if (!NT_SUCCESS(Status))
- {
- MmUnlockAddressSpace(AddressSpace);
- Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
- MmLockAddressSpace(AddressSpace);
- }
- if (!NT_SUCCESS(Status))
- {
- KeBugCheck(MEMORY_MANAGEMENT);
- }
- /* Remove the wait entry we placed, so that we can map the page */
- MmDeletePageFileMapping(Process, PAddress, &SwapEntry);
- Status = MmCreateVirtualMapping(Process,
- PAddress,
- Region->Protect,
- &Page,
- 1);
- if (!NT_SUCCESS(Status))
- {
- DPRINT("MmCreateVirtualMapping failed, not out of memory\n");
- KeBugCheck(MEMORY_MANAGEMENT);
- return(Status);
- }
- MmInsertRmap(Page, Process, Address);
-
- /*
- * Cleanup and release locks
- */
- MiSetPageEvent(Process, Address);
- DPRINT("Address 0x%.8X\n", Address);
+ DPRINT("Address 0x%p\n", Address);
return(STATUS_SUCCESS);
}
*/
MmLockAddressSpace(AddressSpace);
MiSetPageEvent(Process, Address);
- DPRINT("Address 0x%.8X\n", Address);
+ DPRINT("Address 0x%p\n", Address);
return(Status);
}
MmUnlockSectionSegment(Segment);
MmDeletePageFileMapping(Process, PAddress, &FakeSwapEntry);
- DPRINT("CreateVirtualMapping Page %x Process %p PAddress %p Attributes %x\n",
+ DPRINT("CreateVirtualMapping Page %x Process %p PAddress %p Attributes %x\n",
Page, Process, PAddress, Attributes);
Status = MmCreateVirtualMapping(Process,
PAddress,
MmInsertRmap(Page, Process, Address);
MiSetPageEvent(Process, Address);
- DPRINT("Address 0x%.8X\n", Address);
+ DPRINT("Address 0x%p\n", Address);
return(STATUS_SUCCESS);
}
else if (IS_SWAP_FROM_SSE(Entry))
}
MmInsertRmap(Page, Process, Address);
MiSetPageEvent(Process, Address);
- DPRINT("Address 0x%.8X\n", Address);
+ DPRINT("Address 0x%p\n", Address);
return(STATUS_SUCCESS);
}
else
}
MmInsertRmap(Page, Process, Address);
MiSetPageEvent(Process, Address);
- DPRINT("Address 0x%.8X\n", Address);
+ DPRINT("Address 0x%p\n", Address);
return(STATUS_SUCCESS);
}
}
PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
SWAPENTRY SwapEntry;
- DPRINT("MmAccessFaultSectionView(%x, %x, %x, %x)\n", AddressSpace, MemoryArea, Address);
+ DPRINT("MmAccessFaultSectionView(%p, %p, %p)\n", AddressSpace, MemoryArea, Address);
/*
* Check if the page has already been set readwrite
*/
if (MmGetPageProtect(Process, Address) & PAGE_READWRITE)
{
- DPRINT("Address 0x%.8X\n", Address);
+ DPRINT("Address 0x%p\n", Address);
return(STATUS_SUCCESS);
}
(Region->Protect == PAGE_READWRITE ||
Region->Protect == PAGE_EXECUTE_READWRITE)))
{
- DPRINT("Address 0x%.8X\n", Address);
+ DPRINT("Address 0x%p\n", Address);
return(STATUS_ACCESS_VIOLATION);
}
* Restart the operation
*/
MmLockAddressSpace(AddressSpace);
- DPRINT("Address 0x%.8X\n", Address);
+ DPRINT("Address 0x%p\n", Address);
return(STATUS_MM_RESTART_OPERATION);
}
MmUnlockSectionSegment(Segment);
MiSetPageEvent(Process, Address);
- DPRINT("Address 0x%.8X\n", Address);
+ DPRINT("Address 0x%p\n", Address);
return(STATUS_SUCCESS);
}
NTSTATUS Status;
PFILE_OBJECT FileObject;
#ifndef NEWCC
- PBCB Bcb = NULL;
+ PROS_SHARED_CACHE_MAP SharedCacheMap = NULL;
#endif
BOOLEAN DirectMapped;
BOOLEAN IsImageSection;
if (FileObject != NULL &&
!(Context.Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED))
{
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+ SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
/*
* If the file system is letting us go directly to the cache and the
*/
if (Context.Section->AllocationAttributes & SEC_PHYSICALMEMORY)
{
- DPRINT1("Trying to page out from physical memory section address 0x%X "
- "process %d\n", Address,
+ DPRINT1("Trying to page out from physical memory section address 0x%p "
+ "process %p\n", Address,
Process ? Process->UniqueProcessId : 0);
KeBugCheck(MEMORY_MANAGEMENT);
}
*/
if (!MmIsPagePresent(Process, Address))
{
- DPRINT1("Trying to page out not-present page at (%d,0x%.8X).\n",
+ DPRINT1("Trying to page out not-present page at (%p,0x%p).\n",
Process ? Process->UniqueProcessId : 0, Address);
KeBugCheck(MEMORY_MANAGEMENT);
}
*/
if (MmGetReferenceCountPage(Page) != 1)
{
- DPRINT("Cannot page out locked section page: 0x%p (RefCount: %d)\n",
+ DPRINT("Cannot page out locked section page: 0x%lu (RefCount: %lu)\n",
Page, MmGetReferenceCountPage(Page));
MmSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
MmUnlockSectionSegment(Context.Segment);
}
/*
- * Take an additional reference to the page or the cache segment.
+ * Take an additional reference to the page or the VACB.
*/
if (DirectMapped && !Context.Private)
{
{
if (Context.Private)
{
- DPRINT1("Found a %s private page (address %x) in a pagefile segment.\n",
+ DPRINT1("Found a %s private page (address %p) in a pagefile segment.\n",
Context.WasDirty ? "dirty" : "clean", Address);
KeBugCheckEx(MEMORY_MANAGEMENT, SwapEntry, (ULONG_PTR)Process, (ULONG_PTR)Address, 0);
}
{
if (Context.Private)
{
- DPRINT1("Found a %s private page (address %x) in a shared section segment.\n",
+ DPRINT1("Found a %s private page (address %p) in a shared section segment.\n",
Context.WasDirty ? "dirty" : "clean", Address);
KeBugCheckEx(MEMORY_MANAGEMENT, Page, (ULONG_PTR)Process, (ULONG_PTR)Address, 0);
}
{
if (SwapEntry != 0)
{
- DPRINT1("Found a swapentry for a non private and direct mapped page (address %x)\n",
+ DPRINT1("Found a swapentry for a non private and direct mapped page (address %p)\n",
Address);
KeBugCheckEx(MEMORY_MANAGEMENT, STATUS_UNSUCCESSFUL, SwapEntry, (ULONG_PTR)Process, (ULONG_PTR)Address);
}
#ifndef NEWCC
- Status = CcRosUnmapCacheSegment(Bcb, (ULONG)FileOffset, FALSE);
+ Status = CcRosUnmapVacb(SharedCacheMap, (ULONG)FileOffset, FALSE);
#else
Status = STATUS_SUCCESS;
#endif
#ifndef NEWCC
if (!NT_SUCCESS(Status))
{
- DPRINT1("CCRosUnmapCacheSegment failed, status = %x\n", Status);
- KeBugCheckEx(MEMORY_MANAGEMENT, Status, (ULONG_PTR)Bcb, (ULONG_PTR)FileOffset, (ULONG_PTR)Address);
+ DPRINT1("CcRosUnmapVacb failed, status = %x\n", Status);
+ KeBugCheckEx(MEMORY_MANAGEMENT, Status, (ULONG_PTR)SharedCacheMap, (ULONG_PTR)FileOffset, (ULONG_PTR)Address);
}
#endif
MiSetPageEvent(NULL, NULL);
{
if (SwapEntry != 0)
{
- DPRINT1("Found a swap entry for a non dirty, non private and not direct mapped page (address %x)\n",
+ DPRINT1("Found a swap entry for a non dirty, non private and not direct mapped page (address %p)\n",
Address);
KeBugCheckEx(MEMORY_MANAGEMENT, SwapEntry, Page, (ULONG_PTR)Process, (ULONG_PTR)Address);
}
- MmReleasePageMemoryConsumer(MC_USER, Page);
+ MmReleasePageMemoryConsumer(MC_USER, Page);
MiSetPageEvent(NULL, NULL);
return(STATUS_SUCCESS);
}
BOOLEAN Private;
NTSTATUS Status;
PFILE_OBJECT FileObject;
- PBCB Bcb = NULL;
+ PROS_SHARED_CACHE_MAP SharedCacheMap = NULL;
BOOLEAN DirectMapped;
BOOLEAN IsImageSection;
PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
if (FileObject != NULL &&
!(Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED))
{
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+ SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
/*
* If the file system is letting us go directly to the cache and the
*/
if (Section->AllocationAttributes & SEC_PHYSICALMEMORY)
{
- DPRINT1("Trying to write back page from physical memory mapped at %X "
- "process %d\n", Address,
+ DPRINT1("Trying to write back page from physical memory mapped at %p "
+ "process %p\n", Address,
Process ? Process->UniqueProcessId : 0);
KeBugCheck(MEMORY_MANAGEMENT);
}
Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
if (!MmIsPagePresent(Process, Address))
{
- DPRINT1("Trying to page out not-present page at (%d,0x%.8X).\n",
+ DPRINT1("Trying to page out not-present page at (%p,0x%p).\n",
Process ? Process->UniqueProcessId : 0, Address);
KeBugCheck(MEMORY_MANAGEMENT);
}
*/
if (DirectMapped && !Private)
{
- LARGE_INTEGER SOffset;
+ //LARGE_INTEGER SOffset;
ASSERT(SwapEntry == 0);
- SOffset.QuadPart = Offset.QuadPart + Segment->Image.FileOffset;
+ //SOffset.QuadPart = Offset.QuadPart + Segment->Image.FileOffset;
#ifndef NEWCC
- CcRosMarkDirtyCacheSegment(Bcb, Offset.LowPart);
+ CcRosMarkDirtyVacb(SharedCacheMap, Offset.LowPart);
#endif
MmLockSectionSegment(Segment);
MmSetPageEntrySectionSegment(Segment, &Offset, PageEntry);
IN ULONG ProcessHandleCount,
IN ULONG SystemHandleCount)
{
- DPRINT("MmpCloseSection(OB %x, HC %d)\n",
- Object, ProcessHandleCount);
+ DPRINT("MmpCloseSection(OB %p, HC %lu)\n", Object, ProcessHandleCount);
}
NTSTATUS
if (UMaximumSize == NULL)
{
- return(STATUS_UNSUCCESSFUL);
+ DPRINT1("MmCreatePageFileSection: (UMaximumSize == NULL)\n");
+ return(STATUS_INVALID_PARAMETER);
}
MaximumSize = *UMaximumSize;
(PVOID*)(PVOID)&Section);
if (!NT_SUCCESS(Status))
{
+ DPRINT1("MmCreatePageFileSection: failed to create object (0x%lx)\n", Status);
return(Status);
}
* Some defaults
*/
/* FIXME? are these values platform-dependent? */
- if(ImageSectionObject->StackReserve == 0)
- ImageSectionObject->StackReserve = 0x40000;
+ if (ImageSectionObject->ImageInformation.MaximumStackSize == 0)
+ ImageSectionObject->ImageInformation.MaximumStackSize = 0x40000;
- if(ImageSectionObject->StackCommit == 0)
- ImageSectionObject->StackCommit = 0x1000;
+ if(ImageSectionObject->ImageInformation.CommittedStackSize == 0)
+ ImageSectionObject->ImageInformation.CommittedStackSize = 0x1000;
- if(ImageSectionObject->ImageBase == 0)
+ if(ImageSectionObject->BasedAddress == NULL)
{
- if(ImageSectionObject->ImageCharacteristics & IMAGE_FILE_DLL)
- ImageSectionObject->ImageBase = 0x10000000;
+ if(ImageSectionObject->ImageInformation.ImageCharacteristics & IMAGE_FILE_DLL)
+ ImageSectionObject->BasedAddress = (PVOID)0x10000000;
else
- ImageSectionObject->ImageBase = 0x00400000;
+ ImageSectionObject->BasedAddress = (PVOID)0x00400000;
}
/*
{
PMEMORY_AREA MArea;
NTSTATUS Status;
- PHYSICAL_ADDRESS BoundaryAddressMultiple;
+ ULONG Granularity;
if (Segment->WriteCopy)
{
Protect = PAGE_EXECUTE_READWRITE;
}
- BoundaryAddressMultiple.QuadPart = 0;
+ if (*BaseAddress == NULL)
+ Granularity = MM_ALLOCATION_GRANULARITY;
+ else
+ Granularity = PAGE_SIZE;
#ifdef NEWCC
if (Segment->Flags & MM_DATAFILE_SEGMENT) {
&MArea,
FALSE,
AllocationType,
- BoundaryAddressMultiple);
+ Granularity);
if (!NT_SUCCESS(Status))
{
- DPRINT1("Mapping between 0x%.8X and 0x%.8X failed (%X).\n",
+ DPRINT1("Mapping between 0x%p and 0x%p failed (%X).\n",
(*BaseAddress), (char*)(*BaseAddress) + ViewSize, Status);
return(Status);
}
{
ULONG_PTR Entry;
PFILE_OBJECT FileObject;
- PBCB Bcb;
+ PROS_SHARED_CACHE_MAP SharedCacheMap;
LARGE_INTEGER Offset;
SWAPENTRY SavedSwapEntry;
PROS_SECTION_OBJECT Section;
if (Page == PFN_FROM_SSE(Entry) && Dirty)
{
FileObject = MemoryArea->Data.SectionData.Section->FileObject;
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+ SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
#ifndef NEWCC
- CcRosMarkDirtyCacheSegment(Bcb, (ULONG)(Offset.QuadPart + Segment->Image.FileOffset));
+ CcRosMarkDirtyVacb(SharedCacheMap, (ULONG)(Offset.QuadPart + Segment->Image.FileOffset));
#endif
ASSERT(SwapEntry == 0);
}
PROS_SECTION_OBJECT Section;
PVOID ImageBaseAddress = 0;
- DPRINT("Opening memory area Process %x BaseAddress %x\n",
+ DPRINT("Opening memory area Process %p BaseAddress %p\n",
Process, BaseAddress);
ASSERT(Process);
MemoryArea->Type != MEMORY_AREA_SECTION_VIEW ||
MemoryArea->DeleteInProgress)
{
- ASSERT(MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3);
+ if (MemoryArea) NT_ASSERT(MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3);
MmUnlockAddressSpace(AddressSpace);
return STATUS_NOT_MAPPED_VIEW;
}
((char*)ImageBaseAddress + (ULONG_PTR)SectionSegments[i].Image.VirtualAddress);
Status = MmUnmapViewOfSegment(AddressSpace, SBaseAddress);
+ NT_ASSERT(NT_SUCCESS(Status));
}
}
}
else
{
Status = MmUnmapViewOfSegment(AddressSpace, BaseAddress);
+ NT_ASSERT(NT_SUCCESS(Status));
}
MmUnlockAddressSpace(AddressSpace);
_SEH2_TRY
{
- memset(Sii, 0, sizeof(SECTION_IMAGE_INFORMATION));
if (Section->AllocationAttributes & SEC_IMAGE)
{
PMM_IMAGE_SECTION_OBJECT ImageSectionObject;
ImageSectionObject = Section->ImageSection;
- Sii->TransferAddress = (PVOID)ImageSectionObject->EntryPoint;
- Sii->MaximumStackSize = ImageSectionObject->StackReserve;
- Sii->CommittedStackSize = ImageSectionObject->StackCommit;
- Sii->SubSystemType = ImageSectionObject->Subsystem;
- Sii->SubSystemMinorVersion = ImageSectionObject->MinorSubsystemVersion;
- Sii->SubSystemMajorVersion = ImageSectionObject->MajorSubsystemVersion;
- Sii->ImageCharacteristics = ImageSectionObject->ImageCharacteristics;
- Sii->Machine = ImageSectionObject->Machine;
- Sii->ImageContainsCode = ImageSectionObject->Executable;
+ *Sii = ImageSectionObject->ImageInformation;
}
if (ResultLength != NULL)
SectionSegments = ImageSectionObject->Segments;
NrSegments = ImageSectionObject->NrSegments;
-
ImageBase = (ULONG_PTR)*BaseAddress;
if (ImageBase == 0)
{
- ImageBase = ImageSectionObject->ImageBase;
+ ImageBase = (ULONG_PTR)ImageSectionObject->BasedAddress;
}
ImageSize = 0;
}
}
- ImageSectionObject->ImageSize = (ULONG)ImageSize;
+ ImageSectionObject->ImageInformation.ImageFileSize = (ULONG)ImageSize;
/* Check for an illegal base address */
- if ((ImageBase + ImageSize) > (ULONG_PTR)MmHighestUserAddress)
+ if (((ImageBase + ImageSize) > (ULONG_PTR)MmHighestUserAddress) ||
+ ((ImageBase + ImageSize) < ImageSize))
{
- ImageBase = PAGE_ROUND_DOWN((ULONG_PTR)MmHighestUserAddress - ImageSize);
+ NT_ASSERT(*BaseAddress == NULL);
+ ImageBase = ALIGN_DOWN_BY((ULONG_PTR)MmHighestUserAddress - ImageSize,
+ MM_VIRTMEM_GRANULARITY);
+ NotAtBase = TRUE;
+ }
+ else if (ImageBase != ALIGN_DOWN_BY(ImageBase, MM_VIRTMEM_GRANULARITY))
+ {
+ NT_ASSERT(*BaseAddress == NULL);
+ ImageBase = ALIGN_DOWN_BY(ImageBase, MM_VIRTMEM_GRANULARITY);
+ NotAtBase = TRUE;
}
/* Check there is enough space to map the section at that point. */
if ((*BaseAddress) != NULL)
{
MmUnlockAddressSpace(AddressSpace);
- return(STATUS_UNSUCCESSFUL);
+ return(STATUS_CONFLICTING_ADDRESSES);
}
/* Otherwise find a gap to map the image. */
- ImageBase = (ULONG_PTR)MmFindGap(AddressSpace, PAGE_ROUND_UP(ImageSize), PAGE_SIZE, FALSE);
+ ImageBase = (ULONG_PTR)MmFindGap(AddressSpace, PAGE_ROUND_UP(ImageSize), MM_VIRTMEM_GRANULARITY, FALSE);
if (ImageBase == 0)
{
MmUnlockAddressSpace(AddressSpace);
- return(STATUS_UNSUCCESSFUL);
+ return(STATUS_CONFLICTING_ADDRESSES);
}
/* Remember that we loaded image at a different base address */
NotAtBase = TRUE;
}
MmUnlockAddressSpace(AddressSpace);
+ NT_ASSERT(*BaseAddress == ALIGN_DOWN_POINTER_BY(*BaseAddress, MM_VIRTMEM_GRANULARITY));
if (NotAtBase)
Status = STATUS_IMAGE_NOT_AT_BASE;
/* Check size of file */
if (SectionObjectPointer->SharedCacheMap)
{
- PBCB Bcb = SectionObjectPointer->SharedCacheMap;
- if (NewFileSize->QuadPart <= Bcb->FileSize.QuadPart)
+ PROS_SHARED_CACHE_MAP SharedCacheMap = SectionObjectPointer->SharedCacheMap;
+ if (NewFileSize->QuadPart <= SharedCacheMap->FileSize.QuadPart)
{
return FALSE;
}
return FALSE;
}
#ifndef NEWCC
- CcRosSetRemoveOnClose(SectionObjectPointer);
+ CcRosRemoveIfClosed(SectionObjectPointer);
#endif
return TRUE;
case MmFlushForWrite:
IN PFILE_OBJECT FileObject OPTIONAL)
{
NTSTATUS Status;
- ULONG Protection, FileAccess;
+ ULONG Protection;
PROS_SECTION_OBJECT *SectionObject = (PROS_SECTION_OBJECT *)Section;
/* Check if an ARM3 section is being created instead */
}
}
- /*
- * Check the protection
- */
- Protection = SectionPageProtection & ~(PAGE_GUARD | PAGE_NOCACHE);
- if (Protection != PAGE_READONLY &&
- Protection != PAGE_READWRITE &&
- Protection != PAGE_WRITECOPY &&
- Protection != PAGE_EXECUTE &&
- Protection != PAGE_EXECUTE_READ &&
- Protection != PAGE_EXECUTE_READWRITE &&
- Protection != PAGE_EXECUTE_WRITECOPY)
+ /* Convert section flag to page flag */
+ if (AllocationAttributes & SEC_NOCACHE) SectionPageProtection |= PAGE_NOCACHE;
+
+ /* Check to make sure the protection is correct. Nt* does this already */
+ Protection = MiMakeProtectionMask(SectionPageProtection);
+ if (Protection == MM_INVALID_PROTECTION)
{
+ DPRINT1("Page protection is invalid\n");
return STATUS_INVALID_PAGE_PROTECTION;
}
- if ((DesiredAccess & SECTION_MAP_WRITE) &&
- (Protection == PAGE_READWRITE ||
- Protection == PAGE_EXECUTE_READWRITE) &&
- !(AllocationAttributes & SEC_IMAGE))
- {
- DPRINT("Creating a section with WRITE access\n");
- FileAccess = FILE_READ_DATA | FILE_WRITE_DATA | SYNCHRONIZE;
- }
- else
+ /* Check if this is going to be a data or image backed file section */
+ if ((FileHandle) || (FileObject))
{
- DPRINT("Creating a section with READ access\n");
- FileAccess = FILE_READ_DATA | SYNCHRONIZE;
- }
-
- /* FIXME: somehow combine this with the above checks */
- if (AllocationAttributes & SEC_IMAGE)
- FileAccess = MiArm3GetCorrectFileAccessMask(SectionPageProtection);
+ /* These cannot be mapped with large pages */
+ if (AllocationAttributes & SEC_LARGE_PAGES)
+ {
+ DPRINT1("Large pages cannot be used with an image mapping\n");
+ return STATUS_INVALID_PARAMETER_6;
+ }
- if (!FileObject && FileHandle)
- {
- Status = ObReferenceObjectByHandle(FileHandle,
- FileAccess,
- IoFileObjectType,
- ExGetPreviousMode(),
- (PVOID *)&FileObject,
- NULL);
- if (!NT_SUCCESS(Status))
+ /* Did the caller pass an object? */
+ if (FileObject)
{
- DPRINT("Failed: 0x%08lx\n", Status);
- return Status;
+ /* Reference the object directly */
+ ObReferenceObject(FileObject);
}
+ else
+ {
+ /* Reference the file handle to get the object */
+ Status = ObReferenceObjectByHandle(FileHandle,
+ MmMakeFileAccess[Protection],
+ IoFileObjectType,
+ ExGetPreviousMode(),
+ (PVOID*)&FileObject,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to get a handle to the FO: %lx\n", Status);
+ return Status;
+ }
+ }
+ }
+ else
+ {
+ /* A handle must be supplied with SEC_IMAGE, as this is the no-handle path */
+ if (AllocationAttributes & SEC_IMAGE) return STATUS_INVALID_FILE_FOR_SECTION;
}
- else if (FileObject)
- ObReferenceObject(FileObject);
#ifndef NEWCC // A hack for initializing caching.
// This is needed only in the old case.
&ByteOffset,
NULL);
if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
+ {
+ DPRINT1("CC failure: %lx\n", Status);
return Status;
+ }
// Caching is initialized...
}
#endif