if (Immediate)
{
- PSECTION ToDeref = Bcb->SectionObject;
+ PSECTION ToDeref = Bcb->SectionObject;
Bcb->Map = NULL;
Bcb->SectionObject = NULL;
Bcb->BaseAddress = NULL;
/* Needs mutex */
ULONG
CcpAllocateCacheSections(PFILE_OBJECT FileObject,
- PSECTION SectionObject)
+ PSECTION SectionObject)
{
ULONG i = INVALID_CACHE;
PNOCC_CACHE_MAP Map;
/* Initialize it */
RtlZeroMemory(Section, sizeof(*Section));
- Section->u.Flags.filler0 = 1;
+
+ /* Mark it as a "ROS" Section */
+ Section->u.Flags.filler0 = 1
+
Section->InitialPageProtection = SectionPageProtection;
Section->u.LongFlags = MiSectionFlagsFromAllocationAttributes(AllocationAttributes);
Section->Segment = NULL;
typedef struct _MM_SECTION_SEGMENT
{
- FAST_MUTEX Lock; /* lock which protects the page directory */
- PFILE_OBJECT FileObject;
- LARGE_INTEGER RawLength; /* length of the segment which is part of the mapped file */
- LARGE_INTEGER Length; /* absolute length of the segment */
+ FAST_MUTEX Lock; /* lock which protects the page directory */
+ PFILE_OBJECT FileObject;
+ LARGE_INTEGER RawLength; /* length of the segment which is part of the mapped file */
+ LARGE_INTEGER Length; /* absolute length of the segment */
ULONG ReferenceCount;
- ULONG CacheCount;
+ ULONG CacheCount;
ULONG Protection;
ULONG Flags;
BOOLEAN WriteCopy;
- BOOLEAN Locked;
+ BOOLEAN Locked;
- struct
- {
- ULONGLONG FileOffset; /* start offset into the file for image sections */
- ULONG_PTR VirtualAddress; /* start offset into the address range for image sections */
- ULONG Characteristics;
- } Image;
+ struct
+ {
+ ULONGLONG FileOffset; /* start offset into the file for image sections */
+ ULONG_PTR VirtualAddress; /* start offset into the address range for image sections */
+ ULONG Characteristics;
+ } Image;
- LIST_ENTRY ListOfSegments;
- RTL_GENERIC_TABLE PageTable;
+ LIST_ENTRY ListOfSegments;
+ RTL_GENERIC_TABLE PageTable;
} MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT;
typedef struct _MM_IMAGE_SECTION_OBJECT
PFILE_OBJECT
FILE_OBJECT_FROM_SECTION(PSECTION Section)
{
- ASSERT(Section->u.Flags.filler0 == 1);
+ ASSERT(Section->u.Flags.filler0 == 1);
- if (!Section->Segment)
- return NULL;
+ if (!Section->Segment)
+ return NULL;
- if (Section->u.Flags.Image)
- return ((PMM_IMAGE_SECTION_OBJECT)Section->Segment)->FileObject;
+ if (Section->u.Flags.Image)
+ return ((PMM_IMAGE_SECTION_OBJECT)Section->Segment)->FileObject;
- return ((PMM_SECTION_SEGMENT)Section->Segment)->FileObject;
+ return ((PMM_SECTION_SEGMENT)Section->Segment)->FileObject;
}
#define MA_GetStartingAddress(_MemoryArea) ((_MemoryArea)->VadNode.StartingVpn << PAGE_SHIFT)
VOID
NTAPI
MmGetPageFileMapping(
- struct _EPROCESS *Process,
- PVOID Address,
- SWAPENTRY* SwapEntry);
+ struct _EPROCESS *Process,
+ PVOID Address,
+ SWAPENTRY* SwapEntry);
VOID
NTAPI
ULONG
MiSectionFlagsFromAllocationAttributes(ULONG Attributes)
{
- union
- {
- ULONG LongFlags;
- MMSECTION_FLAGS Flags;
- } u;
+ union
+ {
+ ULONG LongFlags;
+ MMSECTION_FLAGS Flags;
+ } u;
- u.LongFlags = 0;
+ u.LongFlags = 0;
#define ATTRIBUTE_TO_FLAG(__a, __f) if (Attributes & __a) u.Flags.__f = 1
- ATTRIBUTE_TO_FLAG(SEC_IMAGE, Image);
- ATTRIBUTE_TO_FLAG(SEC_PHYSICALMEMORY, PhysicalMemory);
- ATTRIBUTE_TO_FLAG(SEC_FILE, File);
- ATTRIBUTE_TO_FLAG(SEC_NO_CHANGE, NoChange);
- ATTRIBUTE_TO_FLAG(SEC_BASED, Based);
- ATTRIBUTE_TO_FLAG(SEC_RESERVE, Reserve);
- ATTRIBUTE_TO_FLAG(SEC_COMMIT, Commit);
- ATTRIBUTE_TO_FLAG(SEC_NOCACHE, NoCache);
- ATTRIBUTE_TO_FLAG(SEC_WRITECOMBINE, WriteCombined);
+ ATTRIBUTE_TO_FLAG(SEC_IMAGE, Image);
+ ATTRIBUTE_TO_FLAG(SEC_PHYSICALMEMORY, PhysicalMemory);
+ ATTRIBUTE_TO_FLAG(SEC_FILE, File);
+ ATTRIBUTE_TO_FLAG(SEC_NO_CHANGE, NoChange);
+ ATTRIBUTE_TO_FLAG(SEC_BASED, Based);
+ ATTRIBUTE_TO_FLAG(SEC_RESERVE, Reserve);
+ ATTRIBUTE_TO_FLAG(SEC_COMMIT, Commit);
+ ATTRIBUTE_TO_FLAG(SEC_NOCACHE, NoCache);
+ ATTRIBUTE_TO_FLAG(SEC_WRITECOMBINE, WriteCombined);
#undef ATTRIBUTE_TO_FLAG
- return u.LongFlags;
+ return u.LongFlags;
}
/* EOF */
PFILE_OBJECT FileObject;
/* Make sure it's an image section */
- if (((PSECTION)Section)->u.Flags.Image == 0)
- {
- /* It's not, fail */
- DPRINT1("Not an image section\n");
- return STATUS_SECTION_NOT_IMAGE;
- }
+ if (((PSECTION)Section)->u.Flags.Image == 0)
+ {
+ /* It's not, fail */
+ DPRINT1("Not an image section\n");
+ return STATUS_SECTION_NOT_IMAGE;
+ }
/* Get the file object */
FileObject = MmGetFileObjectForSection(Section);
IN BOOLEAN SessionLoad,
IN PLDR_DATA_TABLE_ENTRY LdrEntry)
{
- PSECTION Section = *SectionPtr;
+ PSECTION Section = *SectionPtr;
NTSTATUS Status;
PEPROCESS Process;
PVOID Base = NULL;
#define MmSetPageEntrySectionSegment(S,O,E) do { \
DPRINT("SetPageEntrySectionSegment(old,%p,%x,%x)\n",(S),(O)->LowPart,E); \
_MmSetPageEntrySectionSegment((S),(O),(E),__FILE__,__LINE__); \
- } while (0)
+ } while (0)
extern MMSESSION MmSession;
typedef struct
{
- PSECTION Section;
+ PSECTION Section;
PMM_SECTION_SEGMENT Segment;
LARGE_INTEGER Offset;
BOOLEAN WasDirty;
NTAPI
MmCreatePhysicalMemorySection(VOID)
{
- PSECTION PhysSection;
+ PSECTION PhysSection;
NTSTATUS Status;
OBJECT_ATTRIBUTES Obj;
UNICODE_STRING Name = RTL_CONSTANT_STRING(L"\\Device\\PhysicalMemory");
if (Section->u.Flags.Image == 0)
{
- PMM_SECTION_SEGMENT Segment = (PMM_SECTION_SEGMENT)Section->Segment;
+ PMM_SECTION_SEGMENT Segment = (PMM_SECTION_SEGMENT)Section->Segment;
Sbi.BaseAddress = (PVOID)Segment->Image.VirtualAddress;
Sbi.Size.QuadPart = Segment->Length.QuadPart;
_SEH2_TRY
{
- RtlCopyMemory(SectionInformation, &Sbi, sizeof(Sbi));
+ RtlCopyMemory(SectionInformation, &Sbi, sizeof(Sbi));
if (ResultLength != NULL)
{
IN ULONG AllocationType,
IN ULONG Protect)
{
- PSECTION Section;
+ PSECTION Section;
PMMSUPPORT AddressSpace;
ULONG ViewOffset;
NTSTATUS Status = STATUS_SUCCESS;
AddressSpace = &Process->Vm;
if (Section->u.Flags.NoChange)
- AllocationType |= SEC_NO_CHANGE;
+ AllocationType |= SEC_NO_CHANGE;
MmLockAddressSpace(AddressSpace);
}
else
{
- PMM_SECTION_SEGMENT Segment = (PMM_SECTION_SEGMENT)Section->Segment;
+ PMM_SECTION_SEGMENT Segment = (PMM_SECTION_SEGMENT)Section->Segment;
/* check for write access */
if ((Protect & (PAGE_READWRITE|PAGE_EXECUTE_READWRITE)) &&
OUT PVOID * MappedBase,
IN OUT PSIZE_T ViewSize)
{
- PSECTION Section;
+ PSECTION Section;
PMM_SECTION_SEGMENT Segment;
PMMSUPPORT AddressSpace;
NTSTATUS Status;