<?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>IDC Quirks</title>
                            <pubDate>Wed, 24 Jan 2007 21:52:39 -0600</pubDate>
                                        <link>https://www.openrce.org/blog/view/586/IDC_Quirks</link>
                                        <author>fileoffset &lt;email-suppressed@example.com&gt;</author>
                                                    <description>If trying to get the high dword of an overflow multiply calculation, i.e:&lt;br /&gt;
&lt;br /&gt;
0x0aabbcc * 0x0ddeeff = 0x09403 [edx] 83c4b834 [eax]&lt;br /&gt;
&lt;br /&gt;
Doing something like this in IDC:&lt;br /&gt;
&lt;br /&gt;
auto a = 0x0aabbcc * 0x0ddeeff;&lt;br /&gt;
&lt;br /&gt;
will result in 'a' being the lower dword only (0x083c4b834). A workaround for this is to force one of the operands to a floating point constant like such:&lt;br /&gt;
&lt;br /&gt;
auto a = 11189196.0 * 0x0ddeeff;&lt;br /&gt;
&lt;br /&gt;
'a' is now a floating point number. Attempting to shift it right will fail, since IDA attempts to convert the floating point to a long and fails, so we must do it the long way (divide by 0x0ffffffff):&lt;br /&gt;
&lt;br /&gt;
auto a = (11189196.0 * 0x0ddeeff) / 4294967295.0;&lt;br /&gt;
&lt;br /&gt;
'a' is now 0x09403, just what we wanted :)&lt;br /&gt;
&lt;br /&gt;
If anyone knows a better way to do this, feel free to comment...</description>
                    </item>
            </channel>
</rss>
