首页
社区
课程
招聘
[求助]MmAllocatePagesForMdl 共享内存 属性的问题
发表于: 2017-5-9 21:09 4417

[求助]MmAllocatePagesForMdl 共享内存 属性的问题

2017-5-9 21:09
4417

LowAddress.QuadPart = 0;

MAX_MEM(HighAddress.QuadPart);

// 分配4K的共享缓冲区

Mdl = MmAllocatePagesForMdl(LowAddress,

HighAddress,

LowAddress,

TotalBytes);

if (!Mdl)

{

return STATUS_INSUFFICIENT_RESOURCES;

}

Status = ObReferenceObjectByHandle

(

ProcessHandle,

PROCESS_VM_OPERATION,

*PsProcessType,

UserMode,

(PVOID*)(&Process),

NULL);

if (!NT_SUCCESS(Status))

{

__try

{

*lpStatus = STATUS_INSUFFICIENT_RESOURCES;

return STATUS_INSUFFICIENT_RESOURCES;

}

__except (1)

{

return STATUS_INSUFFICIENT_RESOURCES;

}

}

KeStackAttachProcess((PRKPROCESS)(PVOID)(Process), &ApcState);

//KdPrint(("jmg-kernel-> AllocateVirtualMemory call Process: %s\n", PsGetProcessImageFileName(PsGetCurrentProcess())));

// 映射共享缓冲区到用户地址空间

UserVAToReturn = MmMapLockedPagesSpecifyCache

(Mdl,

UserMode,

MmCached,

NULL,

FALSE,

NormalPagePriority);

Mdl->MdlFlags = Mdl->MdlFlags | MDL_MAPPED_TO_SYSTEM_VA;

PVOID MappedSystemCallTable = MmMapLockedPages(Mdl, UserMode);

KeUnstackDetachProcess(&ApcState);

ObDereferenceObject(Process);

if (!UserVAToReturn)

{

MmFreePagesFromMdl(Mdl);

IoFreeMdl(Mdl);

return STATUS_INSUFFICIENT_RESOURCES;

}

 

映射 到了R3 的地址..mdl地址属性应该怎么改成可执行呢??



[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 12848
活跃值: (9142)
能力值: ( LV9,RANK:280 )
在线值:
发帖
回帖
粉丝
2
为啥不直接用ZwAllocateVirtualMemory?...
2017-5-9 22:02
0
游客
登录 | 注册 方可回帖
返回
//