<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Cookiezi on Medium]]></title>
        <description><![CDATA[Stories by Cookiezi on Medium]]></description>
        <link>https://medium.com/@cookiezi?source=rss-8ab754a06552------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Ub-0qk4keKDV0mUe.png</url>
            <title>Stories by Cookiezi on Medium</title>
            <link>https://medium.com/@cookiezi?source=rss-8ab754a06552------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:57:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cookiezi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Reverse Engineering osu! ( 1 )]]></title>
            <link>https://medium.com/@cookiezi/reverse-engineering-osu-1-3b2085efea60?source=rss-8ab754a06552------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b2085efea60</guid>
            <category><![CDATA[osu]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Cookiezi]]></dc:creator>
            <pubDate>Thu, 25 Jun 2015 16:48:23 GMT</pubDate>
            <atom:updated>2015-06-25T16:50:50.242Z</atom:updated>
            <content:encoded><![CDATA[<p>osu! is a popular rhythm game written in .Net C#. I’m a great fan of it. I appreciate the incredible work of the entire community. There are some people making third party tools to utilize our gaming experiences, and achieve something impossible with the bare game.</p><p>However due to the closed developing process, independent developers cannot access the in depth implementations of the game program. I hope this series could help you understand the osu! binaries and create better applications to benefit the community. Therefore I expect you to be familiar with object oriented programming languages and experienced with software development, otherwise it would be painful to understand my words.</p><p>For the record, I do not intend to reconstruct the osu! program. The whole purpose of this series is to help you understand how osu! works, by revealing some of its internal implementations. Writing about the reverse engineering process allows you to discover more about it on your own, so I won’t receive lots of questions on how I did it. Neither would I like anyone to make a crack of the game, so I won’t write anything about modifying the program nor cheating on it.</p><h3>Deobfuscate osu!.exe</h3><p>For security purpose, osu!.exe is obfuscated on .Net IL level. It means if you tried to recover the source code from the .Net IL, you would get messy identifier names, and all string constants are hidden into a big obfuscated binary blob.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B57kVknvCrmWIcxxlqVhvA.png" /><figcaption>Obfuscated C# code</figcaption></figure><p>Therefore we have to deobfuscate it before we can actually look at the code. I choose <a href="https://github.com/0xd4d/de4dot">de4dot</a> to do this dirty work. You can download the latest release or use the following git command to clone the project with its submodules.</p><pre>git clone --recursive <a href="https://github.com/0xd4d/de4dot.git">https://github.com/0xd4d/de4dot.git</a></pre><p>Open the de4dot.sln project file with Visual Studio. We have to patch the code in order to bypass some fatal errors that the obfuscator added to prevent us from deobfuscating it. Search the entire solution to find “A method was removed that is still referenced by this module” (without the quotes), and replace the line with</p><pre>return 0;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RLNGRZ5GA2go2Vx8_fB1pQ.png" /><figcaption>Patched de4dot</figcaption></figure><p>Now you may compile it. After that, drag and drop osu!.exe on to the compiled de4dot.exe to generate the deobfuscated osu!-cleaned.exe file.</p><h3>Recover Raw C# from .Net IL</h3><p>Now we need to decompile the program to convert .Net IL binaries into raw C# code. I choose <a href="http://www.telerik.com/products/decompiler.aspx">Telerik’s JustDecompile</a> to do the job. Alternatives are <a href="http://reflector.net/">Red Gate’s Reflector</a> and <a href="http://ilspy.net/">ILSpy</a>. Simply load osu!-cleaned.exe and you will see the readable source code. In JustDecompile, you can export the generated code into a Visual Studio project by right clicking the loaded assembly then choose “Create Project…” Then you can open the project in Visual Studio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ff-fDlNWMA527pq54f3L4A.png" /><figcaption>Export deobfuscated C# code into Visual Studio project</figcaption></figure><p><strong>Note:</strong> There’s no perfect deobfuscator nor decompiler produces compilable source code without any modifications, so please don’t expect the generated code to be compilable as it is. The one I generated has over 4,000 errors across the project.</p><p>However, there’s no way for computer programs to automatically figure out all the original variable names. Most of the names you see are generated according to their types and uses, unless they are enumerations. Fortunately we can easily recognize string constants this time, which will greatly help us understand the code.</p><h3>General Code Analysis Approach</h3><p>Before I analyze specific implementations in the following posts, I’m going to tell you how to do the work, so you can do it on your own.</p><p>First you need a convenient programming environment. Most importantly you will need the tools to search for string constants, change identifier names, locate definitions, and find out all references for an identifier. I recommend to use Visual Studio with <a href="http://www.telerik.com/products/justcode.aspx">Telerik’s JustCode</a>, which provides a rich tool set, including some useful refactoring features to help you with the raw code. However it’s not a requirement since it’s a commercial product and you may have substitutions or your own means to do it. If you can reach this far then I believe you could.</p><p>To explore the raw code, don’t go through every file since there are hundreds of them. Try think about a feature in osu! you want to learn about, then think of a string constant closely related to it. Then use the search function to find it across the entire solution.</p><p>For example, I’d like to see how osu! parses its configuration file. First I know the file is called “osu!.cfg” so I can search for it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*tPuOtbOPC172pii89XtMrA.png" /></figure><p>Choose “Find All” to list all occurrences, and here is the result we want. From the code structure and with the help of all the string constants, we can easily figure out the uses of many of those identifiers. For example, as we see the pattern is multiple assignments, it implies the method reads values from the configuration file and assigns them to static variables, which means the method is used in the initialization process.</p><p>With my own experience, I can tell the</p><pre>Class203.smethod_14(String field, int defaultValue, int min, int max)</pre><p>method reads the specified field as an integer with provided default value and validation range. In this case, I can assign a new name to it in order to easily recognize it next time. To do that, with JustCode installed, I merely need to move the cursor onto the identifier and press F2 to enter the new name, then press enter to confirm to every occurrence across the project. To rename its parameters, press F12 to step into the definition, and repeat the above method to rename them.</p><p>From the code, we know Class1164 manages audio volumes. To see what other methods uses these values, use Shift-F12 to search across the project and list all occurrences. You will find the thing you seek for if you have the patient to dig into the code.</p><p>This general approach applies almost all situations, closer or further, you will find an entry point to dig up. In the next post, I will start analyze from the score submission system interacts with the osu! server.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b2085efea60" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>