We still don't have (m)any reliable documentation for our beloved Robomaster S1 and I think it is time to provide some more in-depth reverse engineering methods & tools for the community. If you are not familiar with some basic C# knowledge this post is probably not for you.
To my current knowledge the Robomaster S1 application is the only way to access, program & control the S1. So let's start and have some fun with it, shall we?
Some background information The Robomaster S1 (PC-)Application is created with a tool called Unity. Unity is a cross-platform game engine like the Unreal Engine from Epic. If you play computer games you probably know what I'm talking about.
Compiled Unity code is almost not optimized/protected in any way and very easy to decompile. Don't worry, we don't have to mess around with Assembly language - it's nice C# or IL code. Intermediate language (IL) is an object-oriented programming language designed to be used by compilers for the .NET Framework before static or dynamic compilation to machine code.
Most of the Robomaster application magic happens in the ...\RoboMaster_Data\Managed\Assembly-CSharp.dll. That's just how Unity works. All the DJI developers hard work is compiled and dumped into this single dynamic-link library. Very nice, thank you DJI & Unity Technologies
On a side note: If you are interested in the Robomaster S1 application Audio, Mesh, Textures, etc. you are able to extract this stuff as well. You will find freeware Unity asset extractors all over the internet.
How to decompile the heart of the S1 application
To take a closer look under the hood you'll need a decompiler like ILSpy or dnSpy (both are freeware). I'm not entirely sure if it is allowed to link the GitHub repositories here, but a little Google search will do the trick. There are not many forks and both tools should be relatively easy to find.
In my opinion dnSpy is more advanced. It allows you to debug the application while it is running (set breakpoints, get values of variables, ... you name it). Please be aware that you'll need the patched Unity mono.dll & mono-2.0-bdwgc.dll for the real-time debugging stuff with dnSpy. The GitHub repository also provides the corresponding links (the latest 2019 version worked fine for me). If you want to mod the existing S1 code give ILSpy with the Reflexil extention a try.
For the basic decompilation process start ILSpy/dnSpy and load (or drag & drop) the mentioned Assembly-CSharp.dll. Simple as that and in all its glory:
Closer look
The provided screenshot shows the MotorAddress Module as an C# example, but there is so much more to explore... Please be aware that there are some limitations regarding the decompiled source code. Especially the search functions of ILSpy/dnSpy are a bit confusing and sometime don't work in the way they should. For source code analysis I personally prefer to decompile the DLL with ILSpy and export it as C# project (File -> Save Code…)
Feel free to dig around, reverse engineer and do whatever you want. I'm sure our great community will soon release some cool tools and solutions for the DJI Robomaster S1.
Cheers
|