使用Python访问内存映射文件

4
我想利用《激战2》中的内存映射文件,与Mumble进行位置音频链接。该文件包含有关角色坐标和其他有用信息的信息。
使用此脚本,我已能够访问坐标信息:
import mmap
import struct

last=[]
while True:
    shmem = mmap.mmap(0, 20, "MumbleLink", mmap.ACCESS_READ)
    coord=struct.unpack("IL3f", shmem)[2:5]

    shmem.close()
    if last!=coord:
        print(coord)
        last = coord
        X = coord[2]
        Y = coord[0]
        Z = coord[1])

我的问题是我不知道如何从文件中获取更多信息。我该如何访问存储的其他信息,例如角色名称和相机位置。
这里有关于文件的信息: https://forum-en.guildwars2.com/forum/community/api/Map-API-Mumble-Mashup http://mumble.sourceforge.net/Link 非常感谢任何帮助。
谢谢, Ed.
2个回答

2
你可以尝试在mmap调用中映射超过20个字节的文件,比如使用1024,根据http://mumble.sourceforge.net/Link解包整个内容,然后提取名称和相机位置:
s = struct.unpack('IL3f3f3f512s3f')
name = s[11].decode('utf-16')
camera_pos_x,camera_pos_y,camera_pos_z = s[12:15]

0

对于名称,创建一个游戏中的角色名称,并确保它被写入磁盘 - 可能是通过退出游戏。

然后使用二进制文件编辑器搜索该名称。我偏爱http://sourceforge.net/projects/bpe/,但有许多类似工具可供选择。

查找相机位置可能会更加困难。我可能会先查找角色名称,然后在附近搜索可能是相机位置的物体。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接