NTSTATUS status = ObOpenObjectByPointer((PVOID)epGame,
OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE,
NULL,
GENERIC_ALL,
*PsProcessType,
KernelMode,
&handle
);
if (status != STATUS_SUCCESS)
{
KdPrint(("ObOpenObjectByPoINTer error\n"));
}
status = ZwAllocateVirtualMemory(handle, &pMallocMemoryAddr, 0, &length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (status != STATUS_SUCCESS)
{
KdPrint(("ZwAllocateVirtualMemory %p,%p , %d\n", pMallocMemoryAddr , &pMallocMemoryAddr, status));
}
if (NULL != epGame) {
KeStackAttachProcess(epGame,&apcState);
if (MmIsAddressValid(pMallocMemoryAddr)) {
char test[] = { 0x12,0x12,0x12 ,0x12 ,0x12,0x12 ,0x12 ,0x12 };
RtlCopyMemory(pMallocMemoryAddr, test, 8);
}
KeUnstackDetachProcess(&apcState);
ObDereferenceObject(epGame);//清除对象
MallocMemoryAddrress = (ULONG64)pMallocMemoryAddr;
RtlCopyMemory(pIoBuffer, &MallocMemoryAddrress, 8);//返回8字节长度值
nStatus = STATUS_SUCCESS;
大家好,我有个困惑的问题,x64位驱动申请指定进程空间的内存,申请成功了,但是KeStackAttachProcess后使用MmIsAddressValid显示不可用的,导致不能使用RtlCopyMemory等。