memory-management - 如何找到某物的内存位置
问题描述
几天前,我对与记忆等有关的东西产生了兴趣。我在例如 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()
如果你能帮助我,请告诉我。
解决方案
推荐阅读
- azure-devops - 如何在 Azure DevOps 发布管道的测试项目中替换值 appsettings.json?
- r - 为什么更改标签会扰乱我的情节?
- asp.net - 从 SQL 数据库填充 am4core 饼图
- reactjs - Nivo Line:使用 xScale 类型“时间”时是否可以设置自定义 x 轴刻度?
- docker - Docker 工作流插件在启动容器时返回空错误消息
- python - 获取 url 的 csv 文件。for 循环中的问题仅获取最后一个单元格值
- apache-spark - Spark 结构化流式传输 - 从 kafka 写入到 s3 作业的简单 Spark 读取中的输入表物化
- java - org.hibernate.internal.util.config.ConfigurationException:找不到 cfg.xml 资源 [hibernate.cfg.xml]
- r - 当缺少数据时,使用 R 随机森林预测新数据
- machine-learning - 错误注释:x = 0, y = 0, < 0 or > 1 with YOLO