Sonar.AutoSwitch icon indicating copy to clipboard operation
Sonar.AutoSwitch copied to clipboard

Sonar API

Open NineLord opened this issue 2 years ago • 7 comments

I saw that you found some rest API to sonar's "SteelSeriesGGClient", do you have a link to this API documentation? I was able to find GameSence but it doesn't have the abilities you showed.

I'm trying to create a script to switch between audio devices (and sound configurations) so I can assign it to a key bind (instead of when using a specific process).

Thank you!

NineLord avatar Jan 28 '23 07:01 NineLord

@NineLord I used Wireshark to look at the HTTP request made by the Steel Series GG client. To do that, install Wireshark then open it and sniff localhost, then filter HTTP (in the search box) to see all the requests from the client.

adirh3 avatar Jan 30 '23 19:01 adirh3

Hey @adirh3 ... if you ever made ANY level of documentation of what you learned probing into the HTTP calls, would you kindly share it? Great work, REALLY

malkiebr avatar Feb 02 '23 05:02 malkiebr

sniffing works to see whats going on but problem is everytime steelseries GG starts its using a different port, and sonar is using something different than coreprobs.json in program data folder, how do you find out which ports to send requests?

bavtan avatar Feb 23 '23 20:02 bavtan

@malkiebr @bavtan sorry somehow missed your questions 😓, if still relevant -

I suggest looking at -https://github.com/adirh3/Sonar.AutoSwitch/blob/584d5ff86aa1e06b9c53a10eadd852eba29d304c/Sonar.AutoSwitch/Services/SteelSeriesSonarService.cs#L63

All the relevant logic is there, basically it looks for ports used by the GG client process and then uses it for the HTTP requests. Also, I don't plan to make any documentation as this may change and I will not even know.

adirh3 avatar May 22 '23 20:05 adirh3

@NineLord if you are still looking for more information, just ended here thru Google and decided to push my findings to GitHub: https://github.com/wex/sonar-rev

@adirh3 there might also be something useful for you in readme - I was able to reverse engineer the source for correct port.

wex avatar Jul 26 '23 00:07 wex

I know this issue is a little old. but I started developing an SDK for sonar. I intend to transform it into a nuget package soon.

Anyway, the best way I found to find the API URL other than through trial and error is through reflection.

I hope it helps in some way, anyone who also wants to do reverse engineering.

PS: The sonar API is written in C#, you can use dnSpy to decopile SteelSeriesSonar.exe and extract the SoundStage.API.dll reference from it then just use dsnSpy on SoundStage.API.dll. To decompress the SoundStage.API just use Costura decompressor

        public static string PROCESS_NAME = "SteelSeriesSonar";
        public static string FindApiUrl()
        {
            string address;
            Process process = Process.GetProcesses().FirstOrDefault(p => p.ProcessName == PROCESS_NAME);
            using (DataTarget dataTarget = DataTarget.AttachToProcess(process.Id, suspend: false))
            {
                var clrVersion = dataTarget.ClrVersions.FirstOrDefault();
                var runtime = clrVersion.CreateRuntime();
                ClrHeap heap = runtime.Heap;
                var clrObjects = heap.EnumerateObjects();
                var webServer = clrObjects.FirstOrDefault(t => t.Type.Name.EndsWith("WebServer"));
                var WebServerAddressField = webServer.Type.Fields.FirstOrDefault(field => field.Name.Contains("WebServerAddress"));
                webServer.TryReadStringField(WebServerAddressField.Name, null, out address);
            }
            return address;
        }

MiguelBCosta avatar Nov 08 '23 14:11 MiguelBCosta

I know this issue is a little old. but I started developing an SDK for sonar. I intend to transform it into a nuget package soon.

Anyway, the best way I found to find the API URL other than through trial and error is through reflection.

I hope it helps in some way, anyone who also wants to do reverse engineering.

PS: The sonar API is written in C#, you can use dnSpy to decopile SteelSeriesSonar.exe and extract the SoundStage.API.dll reference from it then just use dsnSpy on SoundStage.API.dll. To decompress the SoundStage.API just use Costura decompressor

        public static string PROCESS_NAME = "SteelSeriesSonar";
        public static string FindApiUrl()
        {
            string address;
            Process process = Process.GetProcesses().FirstOrDefault(p => p.ProcessName == PROCESS_NAME);
            using (DataTarget dataTarget = DataTarget.AttachToProcess(process.Id, suspend: false))
            {
                var clrVersion = dataTarget.ClrVersions.FirstOrDefault();
                var runtime = clrVersion.CreateRuntime();
                ClrHeap heap = runtime.Heap;
                var clrObjects = heap.EnumerateObjects();
                var webServer = clrObjects.FirstOrDefault(t => t.Type.Name.EndsWith("WebServer"));
                var WebServerAddressField = webServer.Type.Fields.FirstOrDefault(field => field.Name.Contains("WebServerAddress"));
                webServer.TryReadStringField(WebServerAddressField.Name, null, out address);
            }
            return address;
        }

Does the API look usable for something like MIDI Mixer, controlling the levels and muting the digital audio device channels?

https://docs.midi-mixer.com/plugins/create-a-plugin

Sonny-Crockett avatar Nov 10 '23 14:11 Sonny-Crockett