Author: mbosma Date: Sun Apr 2 22:09:19 2006 New Revision: 21446
URL: http://svn.reactos.ru/svn/reactos?rev=21446&view=rev Log: Merge a bit better.
Modified: branches/cache_manager_rewrite/reactos/ntoskrnl/mm/pe.c branches/cache_manager_rewrite/reactos/ntoskrnl/mm/section.c
Modified: branches/cache_manager_rewrite/reactos/ntoskrnl/mm/pe.c URL: http://svn.reactos.ru/svn/reactos/branches/cache_manager_rewrite/reactos/nto... ============================================================================== --- branches/cache_manager_rewrite/reactos/ntoskrnl/mm/pe.c (original) +++ branches/cache_manager_rewrite/reactos/ntoskrnl/mm/pe.c Sun Apr 2 22:09:19 2006 @@ -146,16 +146,13 @@ [1] Microsoft Corporation, "Microsoft Portable Executable and Common Object File Format Specification", revision 6.0 (February 1999) */ -NTSTATUS NTAPI PeFmtCreateSection -( - IN CONST VOID * FileHeader, - IN SIZE_T FileHeaderSize, - IN PFILE_OBJECT FileObject, - OUT PMM_IMAGE_SECTION_OBJECT ImageSectionObject, - OUT PULONG Flags, - IN PEXEFMT_CB_READ_FILE ReadFileCb, - IN PEXEFMT_CB_ALLOCATE_SEGMENTS AllocateSegmentsCb -) +NTSTATUS NTAPI PeFmtCreateSection(IN CONST VOID * FileHeader, + IN SIZE_T FileHeaderSize, + IN PFILE_OBJECT FileObject, + OUT PMM_IMAGE_SECTION_OBJECT ImageSectionObject, + OUT PULONG Flags, + IN PEXEFMT_CB_READ_FILE ReadFileCb, + IN PEXEFMT_CB_ALLOCATE_SEGMENTS AllocateSegmentsCb) { NTSTATUS nStatus; ULONG cbFileHeaderOffsetSize = 0; @@ -177,12 +174,12 @@ ULONG nFileSizeOfHeaders = 0; ULONG i;
- ASSERT(FileHeader); - ASSERT(FileHeaderSize > 0); - ASSERT(FileObject); - ASSERT(ImageSectionObject); - ASSERT(ReadFileCb); - ASSERT(AllocateSegmentsCb); + ASSERT(FileHeader); + ASSERT(FileHeaderSize > 0); + ASSERT(FileObject); + ASSERT(ImageSectionObject); + ASSERT(ReadFileCb); + ASSERT(AllocateSegmentsCb);
ASSERT(Intsafe_CanOffsetPointer(FileHeader, FileHeaderSize));
@@ -247,17 +244,8 @@ cbNtHeaderSize = 0; lnOffset.QuadPart = pidhDosHeader->e_lfanew;
- /* read the header from the file */ - nStatus = ReadFileCb - ( - FileObject, - ImageSectionObject->BytesPerSector, - &lnOffset, - sizeof(IMAGE_NT_HEADERS64), - &pData, - &pBuffer, - &cbReadSize - ); + /* read the header from the file */ + nStatus = ReadFileCb(FileObject, ImageSectionObject->BytesPerSector, &lnOffset, sizeof(IMAGE_NT_HEADERS64), &pData, &pBuffer, &cbReadSize);
if(!NT_SUCCESS(nStatus)) DIE(("ReadFile failed, status %08X\n", nStatus)); @@ -538,17 +526,8 @@
lnOffset.QuadPart = cbSectionHeadersOffset;
- /* read the header from the file */ - nStatus = ReadFileCb - ( - FileObject, - ImageSectionObject->BytesPerSector, - &lnOffset, - cbSectionHeadersSize, - &pData, - &pBuffer, - &cbReadSize - ); + /* read the header from the file */ + nStatus = ReadFileCb(FileObject, ImageSectionObject->BytesPerSector, &lnOffset, cbSectionHeadersSize, &pData, &pBuffer, &cbReadSize);
if(!NT_SUCCESS(nStatus)) DIE(("ReadFile failed with status %08X\n", nStatus));
Modified: branches/cache_manager_rewrite/reactos/ntoskrnl/mm/section.c URL: http://svn.reactos.ru/svn/reactos/branches/cache_manager_rewrite/reactos/nto... ============================================================================== --- branches/cache_manager_rewrite/reactos/ntoskrnl/mm/section.c (original) +++ branches/cache_manager_rewrite/reactos/ntoskrnl/mm/section.c Sun Apr 2 22:09:19 2006 @@ -6129,6 +6129,21 @@ BOOLEAN FileObjectCreated; PSECTION_OBJECT *SectionObject = (PSECTION_OBJECT *)Section;
+ /* + * Check the protection + */ + ULONG Protection = SectionPageProtection & ~(PAGE_GUARD | PAGE_NOCACHE); + if (Protection != PAGE_NOACCESS && + Protection != PAGE_READONLY && + Protection != PAGE_READWRITE && + Protection != PAGE_WRITECOPY && + Protection != PAGE_EXECUTE && + Protection != PAGE_EXECUTE_READ && Protection != PAGE_EXECUTE_READWRITE && Protection != PAGE_EXECUTE_WRITECOPY) + { + CHECKPOINT1; + return STATUS_INVALID_PAGE_PROTECTION; + } + if (AllocationAttributes & SEC_IMAGE && FileHandle == NULL && FileObject == NULL)