{"id":6766,"date":"2019-09-28T00:18:11","date_gmt":"2019-09-28T00:18:11","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=6766"},"modified":"2019-09-28T00:18:13","modified_gmt":"2019-09-28T00:18:13","slug":"rundll32-api-calling","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2019\/09\/28\/rundll32-api-calling\/","title":{"rendered":"RunDll32 &#8212; API calling"},"content":{"rendered":"\n<p>This is a quickie.<\/p>\n\n\n\n<p>Using rundll32 to run stuff is well-known. You can load DLLs, and call APIs.<\/p>\n\n\n\n<p>Sometimes tho, we may get confused about data format we need to provide to APIs. If your API accepts an ANSI, or a Unicode string, different rules apply.<\/p>\n\n\n\n<p>The best way to test _any_ API executed via rundll32.exe is to call it by a &#8216;native&#8217; name w\/o a suffix (A or W). This way, it will go through a sequence of:<\/p>\n\n\n\n<ul><li>Loading our DLL<\/li><li>Retrieving an address of the API with a &#8216;W&#8217; suffix (Wide\/Unicode)<\/li><li>Retrieving an address of the API with a &#8216;A&#8217; suffix (ANSI),  <\/li><li>Retrieving an address of the API with no suffix at all (ANSI, assumed)<\/li><\/ul>\n\n\n\n<p>What it means (practically) is that if you supply an API name with a &#8216;A&#8217; or &#8216;W&#8217; suffix, the sequence of API name resolving is going to look like this:<\/p>\n\n\n\n<ul><li> FunctionNameAW<\/li><li>FunctionNameAA<\/li><li>FunctionNameA <\/li><\/ul>\n\n\n\n<p>or<\/p>\n\n\n\n<ul><li>FunctionNameWW<\/li><li>FunctionNameWA<\/li><li>FunctionNameW<\/li><\/ul>\n\n\n\n<p>Knowing the way rundll32.exe accepts and processes the API function names is actually very helpful &#8211; especially when you are calling functions that require Unicode strings as an argument&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a quickie. Using rundll32 to run stuff is well-known. You can load DLLs, and call APIs. Sometimes tho, we may get confused about data format we need to provide to APIs. If your API accepts an ANSI, or &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2019\/09\/28\/rundll32-api-calling\/\">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":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6766"}],"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=6766"}],"version-history":[{"count":3,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6766\/revisions"}],"predecessor-version":[{"id":6805,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6766\/revisions\/6805"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=6766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=6766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=6766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}