首页
社区
课程
招聘
[求助]MmMapViewOfSection函数疑问
发表于: 2009-6-10 22:59 8277

[求助]MmMapViewOfSection函数疑问

2009-6-10 22:59
8277
哪位帮我看看这个函数啊,不是很懂它。
NTSTATUS
MmMapViewOfSection(
    IN PVOID SectionToMap,
    IN PEPROCESS Process,
    IN OUT PVOID *CapturedBase,
    IN ULONG ZeroBits,
    IN ULONG CommitSize,
    IN OUT PLARGE_INTEGER SectionOffset,
    IN OUT PULONG CapturedViewSize,
    IN SECTION_INHERIT InheritDisposition,
    IN ULONG AllocationType,
    IN ULONG Protect
    )
{
     ControlArea = Section->Segment->ControlArea;
    ImageCommitment = Section->Segment->ImageCommitment;

    if (PsGetCurrentProcess() != Process) {
        KeAttachProcess (&Process->Pcb);//改变Cr3,指向Attached进程的目录表。之后当前线程操作的用户空间就是Attached的进程。
        Attached = TRUE;
    }
//下面是根据节对象的类型来分别调用不同的函数来映射。
  if (ControlArea->u.Flags.PhysicalMemory) {
//请问这里具体干什么的。还有就是不是页文件也能映射的吗。具体是哪个处理函数处理页面文件的?

        MmLockPagableSectionByHandle(ExPageLockHandle);
        status = MiMapViewOfPhysicalSection (ControlArea,
                                             Process,
                                             CapturedBase,
                                             SectionOffset,
                                             CapturedViewSize,
                                             ProtectionMask,
                                             ZeroBits,
                                             AllocationType,
                                             &ReleasedWsMutex);
        MmUnlockPagableImageSection(ExPageLockHandle);

    } else if (ControlArea->u.Flags.Image) {
       //我的理解这里是要映射可执行文件
        status = MiMapViewOfImageSection (
                                        ControlArea,
                                        Process,
                                        CapturedBase,
                                        SectionOffset,
                                        CapturedViewSize,
                                        Section,
                                        InheritDisposition,
                                        ZeroBits,
                                        ImageCommitment,
                                        &ReleasedWsMutex
                                        );

    } else {
        
        //我的理解,这里是要映射共享数据文件
        // Not an image section, therefore it is a data section.
        //

        status = MiMapViewOfDataSection (ControlArea,
                                         Process,
                                         CapturedBase,
                                         SectionOffset,
                                         CapturedViewSize,
                                         Section,
                                         InheritDisposition,
                                         ProtectionMask,
                                         CommitSize,
                                         ZeroBits,
                                         AllocationType,
                                         &ReleasedWsMutex
                                        );
    }
if (Attached) {
        KeDetachProcess();
    }
}

}

[课程]FART 脱壳王!加量不加价!FART作者讲授!

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 364
活跃值: (152)
能力值: ( LV12,RANK:450 )
在线值:
发帖
回帖
粉丝
2

见http://www.longene.org/forum/viewtopic.php?f=8&p=2668
MiMapViewOfPhysicalSection  这个是用在映射物理地址的(在创建\Device\PhysicalMemory对象后)。
更详细的可看毛大师的Windows内核情景分析。MmMapViewOfSection 是在创建内存共享区(Section )
后进行映射的函数,可以映射普通文件,PE文件(虽然这个也可看做普通文件,但win下特别对待了),以及
\Device\PhysicalMemory 对象(把物理内存进行映射)
2009-6-11 00:11
0
游客
登录 | 注册 方可回帖
返回
//