Python秘籍pymem地址

问题描述

在示例脚本中

import pymem
import pymem.process
import pymem.memory

process = pymem.process
mem = pymem.memory



DMC5 = pymem.Pymem("Game.exe")
DMC5_base = DMC5.process_handle

         
adress = 0x1F1BFF714C8
value = 99

mem.write_int(DMC5_base,adress,value)

脚本运行良好,没有任何问题。但是如果我关闭游戏并再次打开它,地址就会改变,你将不得不手动在脚本中插入一个新的。有没有办法输入静态数据?

解决方法

要找到一个可靠的指针,你需要找到一个静态地址,加上偏移量,它总是指向你想要的地址。这是通过内存修改在游戏中作弊时的常见问题。以下是关于如何为 Cheat Engine 执行此操作的教程:https://www.solarstrike.net/phpBB3/viewtopic.php?t=65

这是关于如何使用 MHS + CE 进行操作的另一个教程:https://progamercity.net/ghack-tut/229-tutorial-maplestory-finding-pointers-ce-amp-mhs.html

但本质上,通常的做法是使用调试器获取读取或写入地址的任何代码的地址,然后检查汇编代码以确定使用哪些地址和指针来获取该地址。然后,获取它添加指针的基地址,然后使用调试器查看读取那个值的内容,以及它使用的偏移量和指针。在找到静态地址之前,您通常需要这样做 2-3 次。

一旦获得指针偏移量和基地址,就可以通过常规指针逻辑访问该内存地址。下面是一个示例:How do I look up the value of a multi-level pointer inside a process in Python?

您也可以使用 ReadWriteMemory module

例如 - 这是一个 Python 脚本,用于读取和写入 32 位 Cheat Engine 教程第 8 步中的多级指针值:

from ReadWriteMemory import ReadWriteMemory

base_address = 0x00400000  # "Tutorial-i386.exe"
static_address_offset = 0x002426E0  # the offset from the base of the static address of the pointer chain
pointer_static_address = base_address + static_address_offset  # "Tutorial-i386.exe" + 2426E0
offsets = [0x0C,0x14,0x00,0x18]

rwm = ReadWriteMemory()
process = rwm.get_process_by_name('Tutorial-i386.exe')
process.open()
my_pointer = process.get_pointer(pointer_static_address,offsets=offsets)
pointer_value = process.read(my_pointer)
print(f'Value: {pointer_value}')
value_to_set = int(input('Enter a value: '))
process.write(my_pointer,value_to_set)
,

您很有可能会在某个论坛上找到列出的偏移量,我建议您在谷歌上搜索偏移量