首页
社区
课程
招聘
[讨论]如何获取 目标进程虚拟内存的物理地址
发表于: 2019-2-21 13:39 3131

[讨论]如何获取 目标进程虚拟内存的物理地址

2019-2-21 13:39
3131
插入代码
```    KAPC_STATE APC;
    PEPROCESS pEProc;
    PsLookupProcessByProcessId((HANDLE)0x1B44, &pEProc);
    ObDereferenceObject(pEProc);
    KeStackAttachProcess(pEProc, &APC);

    UINT_PTR Dllmodule = (UINT_PTR)ExAllocatePool(NonPagedPool, 0x1000);

VIRT_ADDR Addr = { (uint64_t)Dllmodule };
    PTE_CR3 Cr3 = { __readcr3() };

    uint64_t a = PFN_TO_PAGE(Cr3.pml4_p) + sizeof(PML4E) * Addr.pml4_index;

PHYSICAL_ADDRESS aaa = { 0 };
    aaa.QuadPart = a;
    PVOID MmMapptr = MmMapIoSpace(aaa, sizeof(PHYSICAL_ADDRESS), MmNonCached);
    DbgPrint("pml4 %p ", a);
    DbgPrint("MmMapptr %p \n", MmMapptr);
    if (MmMapptr)
    {
        MmUnmapIoSpace(MmMapptr, sizeof(PHYSICAL_ADDRESS));
    }

    KeUnstackDetachProcess(&APC);

插入代码
```

 

#define PFN_TO_PAGE(pfn) ( pfn << 12 )

 

typedef union CR3_
{
uint64_t value;
struct
{
uint64_t ignored_1 : 3;
uint64_t write_through : 1;
uint64_t cache_disable : 1;
uint64_t ignored_2 : 7;
uint64_t pml4_p : 40;
uint64_t reserved : 12;
};
} PTE_CR3;

 

typedef union VIRTADDR
{
uint64_t value;
void *pointer;
struct
{
uint64_t offset : 12;
uint64_t pt_index : 9;
uint64_t pd_index : 9;
uint64_t pdpt_index : 9;
uint64_t pml4_index : 9;
uint64_t reserved : 16;
};
} VIRT_ADDR;

 

为什么我MmMapIoSpace 会返回等于0

 

难道uint64_t a = PFN_TO_PAGE(Cr3.pml4_p) + sizeof(PML4E) * Addr.pml4_index;

 

这个a不是物理内存吗

 

有大佬知道吗


[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回