Hello! I'm trying to access AMS2 Shared Memory on Linux, I play the game through Steam using Proton-GE. I have a Python script that (I believe) reads telemetry and race data from AMS2 Shared Memory. On Windows, I would normally use the SharedMemory API described in SharedMemory.h, but on Linux I'm having trouble locating or accessing the memory-mapped file created by the game. The game process (AMS2AVX.exe) has several shared memory files mapped under /dev/shm/. I can see these mappings through /proc/<pid>/maps and lsof. I can read those files with Python using mmap. However, none of them appear to match the structure defined in SharedMemory.h. Running strings on the mapped files does not reveal track names, car names, participant names, or any obvious AMS2 telemetry data. I was unable to find any shared memory object named $pcars2$, SMS_*, or similar. So my questions are: Does AMS2 Shared Memory work under Proton-GE? Has anyone successfully accessed AMS2 telemetry from Linux? Is the shared memory object still available somewhere inside the Wine/Proton namespace? Is there a recommended way to access AMS2 Shared Memory from a native Linux application? Any guidance would be appreciated! Thanks in advance.
Datalink is your answer to use shared memory when on linux. https://github.com/LukasLichten/Datalink Unfortunately creator doesn't provide compiled application, so you will have to do it yourself. Download this git and compile it in terminal how it is mentioned at the bottom of git. You will probably have to download missing libraries to compile. (Try compiling and see what errors it outputs to see what is missing. Google and AI is your friend here. Later you can delete these libraries, just write down what you downloaded) After that you have to make sure system knows what Datalink is. In terminal: symlink (location to compiled folder)/target/debug/Datalink to ~/.local/bin To make sure it works in terminal type "Datalink --help" which should put out version # and other info in terminal. If it doesn't work first time, try restarting PC and check again, just in case. And last part - add "Datalink %command%" in steam launch options. What you now have is shared memory in your linux space. It allows you to run linux applications and read sharedmemory. For windows applications, install simhub, crewchief or anything you want in your games prefix. For windows application installation I use Protontricks (available as Flatpak). And then you will have to make .json config file and place it inside this prefix "C:\users\steamuser\AppData\Roaming\Datalink\" (Datalink has to be launched once with the game already for this folder to be there) This is how .json config looks for simhub Code: { "game_id":"override", "maps": [ { "name": "simhub", "size": 15660 } ], "apps": [ { "path": "C:\\Program Files (x86)\\SimHub\\SimHubWPF.exe", "args": [] } ], "post_apps": [ { "path": "/usr/bin/notify-send", "args": [ "Game closing", "I don't know about you, but your game has closed" ] } ], "notes": "v1" } The only important part is the path to .exe in apps section. Each application will have its own config file. To not launch/use application remove .json config from location mentioned above. Now the reasonable response is "this is bit much, is this worth it?". Which is absolutely correct assessment. Windows application can be run in prefix by just using correct steam launch options, but in my experience was very unreliable and not work or even launch properly. These launch options would be multiple rows of line and it gets messy very quick. Using Datalink is much cleaner option. This is the upside.
Yes, but is not actually what I need hahaha.. I'm developing an app and I need to get the data from the Shared Memory using the script I'm writting.. Then comes the problem described above xD Thanks for the reply! Hmm, interesting.. I'll try this when I have the time. Thank you for the reply!
Could you post the link to the header file? It's a .h file—a C language header—and it might help you with the conversion. I haven't programmed in years, but I have some experience as a programmer-analyst in C and C++, and I know Python, though I've only dabbled in it a little. Anyway, if there's anything I can do to help, don't hesitate to ask
I believe it's the SharedMemory.h ? Then it is in AMS2 folder: Automobilista 2/Support/SharedMemory/AMS2_SharedMemoryExampleApp I don't know if it's what you're looking for xD
is C++ languaje, the SharedMemory.h is the header and the App.cpp is the main file, AMS2_SharedMemoryExampleApp is the project files of the Visual C++ for to compile, well, what do you need from this file ? I imagine you've written a Python script to communicate with the AMS2 and retrieve the telemetry data, but this shared-memory program is written in C++, so the functions you need to call from Python are in C++. Knowing the function calls, you can perform the conversion. The header file contains the ENUMs and function declarations, while the main file (App.cpp) contains the function definitions and the main function. What you’re trying to do now is retrieve the data from the memory call stack in Linux, but in Linux it’s written in C—even though C++ is C with classes and polymorphism—and the memory calls in Windows (written in C++) and in Linux (written in C) are different. That’s why it works in Windows but you need to change the calls in Linux. ------ In the App.cpp you have this at start : // Used for memory-mapped functionality #include <windows.h> #include "sharedmemory.h" This is designed for Windows. If you want it for Linux, you'll have to adapt the code.
Thanks for the explanation. My main issue is that I cannot find where the shared memory object created by OpenFileMapping is exposed. On Windows the sample application opens the AMS2 shared memory and reads the SharedMemory structure without problems. On Linux/Proton I can see several shared memory segments under /dev/shm and I can read them using mmap, but none of them seem to match the SharedMemory structure. The issue is that I don't even know if the $pcars2$ shared memory object is accessible under Proton/Wine and with this name, or if there is a specific way to access it from a native Linux application.
It doesn't work because you're trying to read Windows shared memory on Linux; the structure is different. What you can do is capture the shared memory through Wine—that is, by running the shared memory application in Wine and capturing the memory stack calls through Wine as if you were in Windows—or, as I mentioned earlier, by modifying the C++ program so that it loads the shared memory natively in Linux instead of in Windows. Edit : Since AMS2 runs through Wine/Proton, it makes sense to capture the shared memory through Wine rather than natively in Linux, so that the structure of the shared memory program remains unchanged—after all, it was designed for Windows, not Linux.