首页 > 解决方案 > 如何找到某物的内存位置

问题描述

几天前,我对与记忆等有关的东西产生了兴趣。我在例如 CSGO 中看到了多个更改内存变量的脚本。该脚本对控制玩家穿过墙壁的可见性的内存地址做了一些事情。我想知道,你怎么知道某个东西有什么内存地址以及它叫什么等等。在找到正确的地址之前,有什么方法可以在不尝试地址的情况下知道吗?

带有内存地址的代码:

import pymem
import pymem.process

dwEntityList = (0x4D4B104)
dwGlowObjectManager = (0x5292F20)
m_iGlowIndex = (0xA428)
m_iTeamNum = (0xF4)


def main():
    print("Diamond has launched.")
    pm = pymem.Pymem("csgo.exe")
    client = pymem.process.module_from_name(pm.process_handle, "client.dll").lpBaseOfDll

    while True:
        glow_manager = pm.read_int(client + dwGlowObjectManager)

        for i in range(1, 32):  # Entities 1-32 are reserved for players.
            entity = pm.read_int(client + dwEntityList + i * 0x10)

            if entity:
                entity_team_id = pm.read_int(entity + m_iTeamNum)
                entity_glow = pm.read_int(entity + m_iGlowIndex)

                if entity_team_id == 2:  # Terrorist
                    pm.write_float(glow_manager + entity_glow * 0x38 + 0x4, float(1))   # R
                    pm.write_float(glow_manager + entity_glow * 0x38 + 0x8, float(0))   # G
                    pm.write_float(glow_manager + entity_glow * 0x38 + 0xC, float(0))   # B
                    pm.write_float(glow_manager + entity_glow * 0x38 + 0x10, float(1))  # Alpha
                    pm.write_int(glow_manager + entity_glow * 0x38 + 0x24, 1)           # Enable glow

                elif entity_team_id == 3:  # Counter-terrorist
                    pm.write_float(glow_manager + entity_glow * 0x38 + 0x4, float(0))   # R
                    pm.write_float(glow_manager + entity_glow * 0x38 + 0x8, float(0))   # G
                    pm.write_float(glow_manager + entity_glow * 0x38 + 0xC, float(1))   # B
                    pm.write_float(glow_manager + entity_glow * 0x38 + 0x10, float(1))  # Alpha
                    pm.write_int(glow_manager + entity_glow * 0x38 + 0x24, 1)           # Enable glow


if __name__ == '__main__':
    main()

如果你能帮助我,请告诉我。

标签: memory-management

解决方案


推荐阅读