{"id":6505,"date":"2019-07-04T23:05:21","date_gmt":"2019-07-04T23:05:21","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=6505"},"modified":"2019-07-04T23:13:14","modified_gmt":"2019-07-04T23:13:14","slug":"batch-decompilation-with-ida-hex-rays-decompiler","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2019\/07\/04\/batch-decompilation-with-ida-hex-rays-decompiler\/","title":{"rendered":"Batch decompilation with IDA \/ Hex-Rays Decompiler"},"content":{"rendered":"\n<p>if you are very used to 32-bit IDA you may sometimes find yourself in a blind alley when you try to port your working solution to IDA 64-bit. This was the case with my old batch decompilation script. <\/p>\n\n\n\n<p>The way it works is very simple &#8211; for every &lt;file&gt; in a folder, run IDA in its automation\/batch mode mode, decompile the &lt;file&gt;, and finally save it in a &lt;file&gt;.c file &#8211; more or less like the below (I am omitting the loop):<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>c:\\Ida\\idaw.exe -A -Ohexrays:-new:%%k.c:ALL &#8220;%%k&#8221;<\/p><\/blockquote>\n\n\n\n<p>Nothing could be simpler.<\/p>\n\n\n\n<p>Until you run it with the 64-bit idaw64.exe:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>c:\\Ida\\idaw64.exe -A -Ohexrays:-new:%%k.c:ALL &#8220;%%k&#8221;<\/p><\/blockquote>\n\n\n\n<p>It doesn&#8217;t work. It loads idaw64 and just stays there.<\/p>\n\n\n\n<p>The gotcha is in a plug-in name. The 64-bit decompiler&#8217;s plugin name is not <em>hexrays<\/em>, it&#8217;s not <em>hexrays64<\/em> either. It is actually <em>hexx64.dll<\/em>. <\/p>\n\n\n\n<p>So, you have to run this instead:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p> c:\\Ida\\idaw64.exe -A -Ohexx64:-new:%%k.c:ALL &#8220;%%k&#8221; <\/p><\/blockquote>\n\n\n\n<p>It&#8217;s ridiculously trivial, but it&#8217;s always the little things. <\/p>\n\n\n\n<p>Also, interestingly, when you google <em>hexx64.dll<\/em> or  <em>hexx64.p64<\/em> you only get a few hits. As if not too many ppl ever came across the issue.<\/p>\n\n\n\n<p>Another gotcha is that if you run it with too many files, your system&#8217;s performance will deteriorate quickly. I don&#8217;t know if it is memory fragmentation\/leaks, or something else, but after running the script on a number of samples I observed my VM dying on me and requiring a restart due to low memory (despite no other process running on a 2G RAM guest). If you know what causes it I would be grateful if you could let me know.<\/p>\n\n\n\n<p>The third gotcha is to rely on the text version of IDA for this task &#8211; it is faster than the GUI version. At least in my experience.<\/p>\n\n\n\n<p>Finally, the last gotcha is to remove all the other plugins from the IDA&#8217;s Plugins directory, other than the one you are using e.g. <em>hexrays<\/em>. Why? This may look like nothing, but IDA enumerates and loads all of them _each_ time it starts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>if you are very used to 32-bit IDA you may sometimes find yourself in a blind alley when you try to port your working solution to IDA 64-bit. This was the case with my old batch decompilation script. The way &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2019\/07\/04\/batch-decompilation-with-ida-hex-rays-decompiler\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[85,58,44,18,16,60],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6505"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=6505"}],"version-history":[{"count":2,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6505\/revisions"}],"predecessor-version":[{"id":6509,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6505\/revisions\/6509"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=6505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=6505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=6505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}