<?xml version="1.0"?>
<rss version="2.0">
    <channel>
        <title>OpenRCE: Blog</title>
        <link>http://www.openrce.org/rss/feeds/blog</link>
        <description>OpenRCE: The Open Reverse Code Engineering Community</description>
                <item>
            <title>What's in a name?</title>
                            <pubDate>Wed, 09 Apr 2008 12:54:46 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/1120/What's_in_a_name?</link>
                                        <author>nummish &lt;email-suppressed@example.com&gt;</author>
                                                    <description>Most of the RE work I've done in the past was on windows where cdecl is implemented for &lt;br /&gt;
&lt;br /&gt;
function(arg1,arg2) &lt;br /&gt;
&lt;br /&gt;
as:&lt;br /&gt;
&lt;br /&gt;
push arg2&lt;br /&gt;
push arg1&lt;br /&gt;
call function&lt;br /&gt;
&lt;br /&gt;
But lately I've been working with gcc compiled binaries that allocate the stack space before hand and implement cdecl as:&lt;br /&gt;
&lt;br /&gt;
mov [esp+4], arg2&lt;br /&gt;
mov [esp], arg1&lt;br /&gt;
call function&lt;br /&gt;
&lt;br /&gt;
Apparently this is referred to as SUB/MOV method (thx Ero!) and is default for gcc. When IDA disassembles binaries using this method, it looks somewhat weird:&lt;br /&gt;
&lt;br /&gt;
mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [esp+3C218h+var_3C214], arg2&lt;br /&gt;
mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [esp+3C218h+var_3C218], arg1&lt;br /&gt;
call&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function&lt;br /&gt;
&lt;br /&gt;
My initial reaction to this was to write a script that would jump to each function that called other functions and rename the first (last?) couple variables to something a little more sane to enhance the readability. This was a bad idea. What ended up happening is that in some functions the stack offset changed part way through the function, causing the names to be off about half the time. &lt;br /&gt;
&lt;br /&gt;
The solution? OpAlt(). The Edit-&amp;gt;Operand type-&amp;gt;Manual.../Alt-F1. This does not propagate like a standard variable renaming does,&amp;nbsp;&amp;nbsp;it just changes the one instance of that operand. This will cause a little bit more work when scripting, but the results are somewhat more accurate. Renaming the variable in the frame is still ok, but only if you check that the stack offset for all outgoing calls are the same. (hint: GetSpd())</description>
                    </item>
                <item>
            <title>OS X / Objc Reversing</title>
                            <pubDate>Mon, 07 Apr 2008 12:45:20 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/1113/OS_X_/_Objc_Reversing</link>
                                        <author>nummish &lt;email-suppressed@example.com&gt;</author>
                                                    <description>I've been doing some reversing on my mbp lately, and noticed there really isn't a large community resource for anyone reversing objective c binaries, or reversing on the apple at all. I know there are people doing it with all the iTunes DRM stuff and the iPhone unlocking scene, but everyone either keeps to themselves, or starts to look at a binary, sees all the symbols and walks away because it's too easy.&lt;br /&gt;
&lt;br /&gt;
For the most part people seem to simply use otool+otx, class-dumper or IDA on parallels.&lt;br /&gt;
&lt;br /&gt;
To make up for this vacuum of knowledge, I've put together a mailing list at 0x90.org for anyone interested in this topic. It's low traffic, but hopefully it can be useful in the long run.&lt;br /&gt;
&lt;br /&gt;
http://0x90.org/mailman/listinfo/xso</description>
                    </item>
                <item>
            <title>When the starting point isn't the starting point..</title>
                            <pubDate>Mon, 01 Aug 2005 01:20:04 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/15/When_the_starting_point_isn't_the_starting_point..</link>
                                        <author>nummish &lt;email-suppressed@example.com&gt;</author>
                                                    <description>After taking the time to rewrite every mnemonic from scratch, again, I decided to attack the nagging flaw that kora pointed out over coffee. &lt;br /&gt;
&lt;br /&gt;
With larger applications it seemed like they were disassembling properly, so to actually test properly we threw a very simple 5 line program with no calls. Sadly, out of the ten functions disassembled, none of them were the actual test program.&lt;br /&gt;
&lt;br /&gt;
Other than the entry point, there are at least 10 direct or relative called functions that can be disassembled for most of the code I've compiled with gcc. One of the ones that wasn't showing up was main(). The main() function is called in start usually by a call to a jump to the base of the stack, which isn't currently handled.&lt;br /&gt;
&lt;br /&gt;
I finally got the the symbol tables (which include the address of main()) adding functions after the rest of them are found. Next up, repairing the damage I did to the Indirect Operands.</description>
                    </item>
                <item>
            <title>I &amp;lt;3 Intel</title>
                            <pubDate>Sat, 23 Jul 2005 17:21:53 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/13/I_&lt;3_Intel</link>
                                        <author>nummish &lt;email-suppressed@example.com&gt;</author>
                                                    <description>The documentation is ok. But every so often you find something that forces you to ask questions, and you're only comfort is a manual so large it had to be split into two very large manuals that are totally inconsistent between revisions and really don't have a solution to wtf you wanted to know in the first place.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
An instruction on the intel chipset can be from one to about 15 bytes long. Or anywhere inbetween. Fine. No problem.&lt;br /&gt;
&lt;br /&gt;
[prefixes][opcode][mod r/m][sib][other crap..]&lt;br /&gt;
&lt;br /&gt;
makes sense.. I can deal with that.. so start off with the first less than obvious part:&lt;br /&gt;
&lt;br /&gt;
Mod R/M: (one byte)&lt;br /&gt;
&lt;br /&gt;
[Mod - 2 bits][Reg - 3 bits][R/M - 3 bits]&lt;br /&gt;
&lt;br /&gt;
... ok, so the way this works is that the Reg field always indicates which one of 8 registers is being referenced. if Mod == 3 (11b) Then the R/M field is another register indicator. &lt;br /&gt;
&lt;br /&gt;
So.. if your operands are &amp;quot;r32, r/m32&amp;quot; then the r32 portion is the &lt;i&gt;reg&lt;/i&gt; field and the r/m32 is the &lt;i&gt;r/m&lt;/i&gt; field. if it happens to be two registers, then mod is 3, as I already stated.&lt;br /&gt;
&lt;br /&gt;
Now.. if your operands are &amp;quot;r/m32, r32&amp;quot; then it's the same, the only difference here is that your destination and source is supplied by the opposite fields as before. But they're read from the same fields.. makes perfect sense.&lt;br /&gt;
&lt;br /&gt;
Until.. if your operands are &amp;quot;r32, r32&amp;quot; .. what.. the.. fuck.. like seriously, there's about 10 instructions that have a format similar to this. You would think that it would be explained clearly or upfront somewhere. After a brief googling, I found some guy who referred to the Mod R/M byte as being &amp;quot;cryptically named&amp;quot;, at which point I lost my faith in humanity on the internet and decided to break out nasm and just compile them. &lt;br /&gt;
&lt;br /&gt;
From what I can guess, the rule for Mod R/M goes like this:&lt;br /&gt;
if Dest == register and Src == reg/mem -&amp;gt; Dest == &lt;i&gt;reg&lt;/i&gt; Src == &lt;i&gt;r/m&lt;/i&gt;&lt;br /&gt;
if Dest == reg/mem and Src == register -&amp;gt; Dest == &lt;i&gt;r/m&lt;/i&gt; Src == &lt;i&gt;reg&lt;/i&gt;&lt;br /&gt;
if Dest == register and AnythingElse == register -&amp;gt; Dest == &lt;i&gt;reg&lt;/i&gt; AnythingElse == &lt;i&gt;r/m&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
I may have missed the brief sentence where that was explained somewhere, but really it's a completeness thing that annoyed the crap out of me last night. If I'm wrong about this, please tell me.</description>
                    </item>
                <item>
            <title>Not quite free of the mnemonic stranglehold.</title>
                            <pubDate>Thu, 14 Jul 2005 14:20:52 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/10/Not_quite_free_of_the_mnemonic_stranglehold.</link>
                                        <author>nummish &lt;email-suppressed@example.com&gt;</author>
                                                    <description>Yesterday, or the day before (I can't really remember now), I posted what I thought was the most glorious commit logs for KlaunmoetD. &lt;i&gt;All menmonics are done&lt;/i&gt; .. It took me a day of breaking other parts of the disassembly system to realize that all the original conditional instructions were built as one single class (MOVcc, SETcc, JccREL8 &amp;amp; JccREL32).. I think I'm going to cry. Hopefully I can knock those out of the park tonight, but I'm really going to need to rebuild the OperandBuilder class to accept Intel style operand strings. There may be a performance hit there, but the readability of the classes and the accuracy should be worth it.&lt;br /&gt;
&lt;br /&gt;
Today's useful C# fact:&lt;br /&gt;
[Obsolete(&amp;quot;Put this around all your conditional classes, and if you didn't already have 400 compiler warnings your life would be easier tracking those conditional mnemonic classes&amp;quot;)]</description>
                    </item>
            </channel>
</rss>
