mirror of
https://github.com/reactos/reactos.git
synced 2025-05-07 10:46:58 +00:00
[NTOSKRNL]: Here's another gem. SMSS2 couldn't call LdrVerifyImageCheckSum, nor could it create Known DLL sections (of course, magically SMSS could). Turns out what Mm expects in terms of file access rights when you map a section has almost nothing to do with what it should expect. Added a new function to ARM3 (which had most of the code there already) so correctly determine which file access rights should be needed. One big change is that you can now map sections with PAGE_EXECUTE if you only have FILE_EXECUTE (FILE_READ_DATA no longer required), as things should be.
svn path=/trunk/; revision=55323
This commit is contained in:
parent
25c5926fcb
commit
864a1bc6ae
2 changed files with 35 additions and 28 deletions
|
@ -29,6 +29,18 @@ ACCESS_MASK MmMakeSectionAccess[8] =
|
|||
SECTION_MAP_EXECUTE | SECTION_MAP_READ
|
||||
};
|
||||
|
||||
ACCESS_MASK MmMakeFileAccess[8] =
|
||||
{
|
||||
FILE_READ_DATA,
|
||||
FILE_READ_DATA,
|
||||
FILE_EXECUTE,
|
||||
FILE_EXECUTE | FILE_READ_DATA,
|
||||
FILE_WRITE_DATA | FILE_READ_DATA,
|
||||
FILE_READ_DATA,
|
||||
FILE_EXECUTE | FILE_WRITE_DATA | FILE_READ_DATA,
|
||||
FILE_EXECUTE | FILE_READ_DATA
|
||||
};
|
||||
|
||||
CHAR MmUserProtectionToMask1[16] =
|
||||
{
|
||||
0,
|
||||
|
@ -73,6 +85,24 @@ MMSESSION MmSession;
|
|||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
ACCESS_MASK
|
||||
NTAPI
|
||||
MiArm3GetCorrectFileAccessMask(IN ACCESS_MASK SectionPageProtection)
|
||||
{
|
||||
ULONG ProtectionMask;
|
||||
|
||||
/* Calculate the protection mask and make sure it's valid */
|
||||
ProtectionMask = MiMakeProtectionMask(SectionPageProtection);
|
||||
if (ProtectionMask == MM_INVALID_PROTECTION)
|
||||
{
|
||||
DPRINT1("Invalid protection mask\n");
|
||||
return STATUS_INVALID_PAGE_PROTECTION;
|
||||
}
|
||||
|
||||
/* Now convert it to the required file access */
|
||||
return MmMakeFileAccess[ProtectionMask & 0x7];
|
||||
}
|
||||
|
||||
ULONG
|
||||
NTAPI
|
||||
MiMakeProtectionMask(IN ULONG Protect)
|
||||
|
|
|
@ -150,6 +150,7 @@ static ULONG SectionCharacteristicsToProtect[16] =
|
|||
PAGE_EXECUTE_READWRITE, /* 15 = WRITABLE, READABLE, EXECUTABLE, SHARED */
|
||||
};
|
||||
|
||||
ACCESS_MASK NTAPI MiArm3GetCorrectFileAccessMask(IN ACCESS_MASK SectionPageProtection);
|
||||
static GENERIC_MAPPING MmpSectionMapping = {
|
||||
STANDARD_RIGHTS_READ | SECTION_MAP_READ | SECTION_QUERY,
|
||||
STANDARD_RIGHTS_WRITE | SECTION_MAP_WRITE,
|
||||
|
@ -3011,22 +3012,10 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject,
|
|||
Section->SectionPageProtection = SectionPageProtection;
|
||||
Section->AllocationAttributes = AllocationAttributes;
|
||||
|
||||
/*
|
||||
* Check file access required
|
||||
*/
|
||||
if (SectionPageProtection & PAGE_READWRITE ||
|
||||
SectionPageProtection & PAGE_EXECUTE_READWRITE)
|
||||
{
|
||||
FileAccess = FILE_READ_DATA | FILE_WRITE_DATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
FileAccess = FILE_READ_DATA;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reference the file handle
|
||||
*/
|
||||
FileAccess = MiArm3GetCorrectFileAccessMask(SectionPageProtection);
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FileAccess,
|
||||
IoFileObjectType,
|
||||
|
@ -3881,22 +3870,10 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject,
|
|||
ULONG i;
|
||||
ULONG FileAccess = 0;
|
||||
|
||||
/*
|
||||
* Check file access required
|
||||
*/
|
||||
if (SectionPageProtection & PAGE_READWRITE ||
|
||||
SectionPageProtection & PAGE_EXECUTE_READWRITE)
|
||||
{
|
||||
FileAccess = FILE_READ_DATA | FILE_WRITE_DATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
FileAccess = FILE_READ_DATA;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reference the file handle
|
||||
*/
|
||||
FileAccess = MiArm3GetCorrectFileAccessMask(SectionPageProtection);
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FileAccess,
|
||||
IoFileObjectType,
|
||||
|
|
Loading…
Reference in a new issue