adirh3 / Sonar.AutoSwitch

53 stars 6 forks source link

Sonar API #9

Open NineLord opened 1 year ago

NineLord commented 1 year ago

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!

adirh3 commented 1 year ago

@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.

malkiebr commented 1 year ago

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

bavtan commented 1 year ago

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?

adirh3 commented 1 year ago

@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.

wex commented 1 year ago

@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.

MiguelBCosta commented 11 months ago

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;
        }
Sonny-Crockett commented 11 months ago

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