Elrey.5472 Posted October 3, 2018 Share Posted October 3, 2018 I'm trying to read stuff from the mumblelink shared memory file following this: [https://wiki.guildwars2.com/wiki/API:MumbleLink](https://wiki.guildwars2.com/wiki/API:MumbleLink "https://wiki.guildwars2.com/wiki/API:MumbleLink") using Python 3.6 import mmap import struct def read_memory(): """Based on: https://wiki.guildwars2.com/wiki/API:MumbleLink""" # Access the memory size = "IL3f3f3f512s3f3f3f290s256s2048s" shmem = mmap.mmap(0, struct.calcsize(size), "MumbleLink", mmap.ACCESS_READ) s = struct.unpack(size, shmem) shmem.close() # Divide it to understand it uiversion = s[0] uitick = s[1] coord = s[2:5] coordfront_and_top = s[5:11] game = s[11].decode('utf-16') camera = s[12:15] camerafront_and_top = s[15:21] identity = parse_identity(s[21].decode('utf-16')) context = s[22] description = s[23].decode('utf-16') print("UIVersion: {0}".format(uiversion)) print("UITick: {0}".format(uitick)) print("Coordenadas: {0}".format(coord)) print("Coordenadas Front(3) and Top(3): {0}".format(coordfront_and_top)) print("Juego: {0}".format(game)) print("Camara: {0}".format(camera)) print("Camera Front and Top: {0}".format(camerafront_and_top)) print("Identidad: {0}".format(identity)) print("Contexto: {0}".format(context)) print("Descripción: {0}".format(description)) **And this is the output:** UIVersion: 2 UITick: 1278 Coordenadas: (-174.10513305664062, 17.903413772583008, 297.5890197753906) Coordenadas Front(3) and Top(3): (-0.1873851865530014, 0.0, -0.9822865128517151, 0.0, 0.0, 0.0) Juego: Guild Wars 2 Camara: (-172.872314453125, 52.529701232910156, 304.051513671875) Camera Front and Top: (-0.05790528282523155, -0.9510565996170044, -0.3035430312156677, 0.0, 0.0, 0.0) Identidad: {'Nombre': 'Ellantriel', 'Profesión': 'Elementalista', 'Raza': 'Humano', 'Mapa': 'Arco de León', 'ID de Mundo': 268435458, 'team_color_id': 0, 'Comandante': 'No', 'map': 50, 'fov': 1.222, 'uisz': 1} Contexto: 0㤴戞2 Descripción: က橃 As you can see, context and description doesn't work as intended. I am wondering why. What am I doing wrong? Note: Identity is parsed with another dictionary function to get the names of IDs (race, proffession, maps) instead of the IDs itself. I left that part of the code out as that's not needed to debug the issue. Link to comment Share on other sites More sharing options...
Nightlark.4029 Posted October 27, 2018 Share Posted October 27, 2018 The context isn't a ascii string, it is another struct: struct MumbleContext { byte serverAddress[28]; // contains sockaddr_in or sockaddr_in6 unsigned mapId; unsigned mapType; unsigned shardId; unsigned instance; unsigned buildId; }; You need to split the context section into those fields (overall size for it is 256 bytes, but GW2 only seems to use 52 bytes if I'm counting right, so there are 204 unused bytes for context -- the Mumble structure has an right before the context that contains a 32-bit integer for the length of the context). I'm not finding anything for description, so it might not be used and either just contain garbage or all null bytes (possible that not parsing 32-bits for the context-length has resulted in being off by 2 utf-16 characters, and it could be showing part of the context structure. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now