我需要直接与操作系统交谈,要求它在您的 Python 进程虚拟内存中分配页面。
如何访问地址为 0xB621740000 的虚拟内存并保留内存?
我使用 VirtualAlloc 吗?在此之前,我必须要 OpenProcess 吗?
下面是我的代码:
PVOID = LPVOID
SIZE_T = ctypes.c_size_t
PAGE_SIZE = 4 * 1024
kernel32 = ctypes.WinDLL('Kernel32', use_last_error=True)
address_str = input('Please enter an address where pages should be allocated: ')
address = int(address_str, 0)
handle = OpenProcess(PROCESS_VM_READ, True, 15460)
VirtualAlloc(address, PAGE_SIZE, MEM_RESERVE, PAGE_READWRITE)