Share via


Finding "black-listed" Win32 APIs in your DLLs

 

When you want to use Win32 or COM APIs in your Windows Store app, there is a subset of APIs you can use. Microsoft recently asked what Win32 API or functionality you as developers are missing from the list. I think this is a great initiative to expand the reach and capabilities of WinRT apps. This has obviously tickled your interest as well. Finally you can seriously look at that old VB6 app that uses some utility C DLLs you couldn’t justify porting to WinRT. And with universal apps, you might even be able to turn it into a Windows Phone app as well.

So here is your chance to let us know what you need. Problem is, you’re not quite sure what that is. You want to find out what APIs you’re actually using in those old C/C++ DLLs you haven't touched in a while.

You have several options here. You can add the WINAPI_FAMILY=WINAPI_PARTITION_APP preprocessor flag and try to build your binaries. Alternatively, you can build a new Windows Store app, link the DLLs in, and test your app with Windows Application Certification Tool (WACK). It turns out there is an even easier way to find those offending APIs. Here’s how to go about it.

  1. Create a Windows Store app from a template. Any template is fine.
  2. Don’t do anything to the app itself. Hit F5 to deploy your app. Just make sure you build the release app, otherwise you'll get false positives for APIs that are only found in debug builds. 
  3. Now here’s the trick. You'll want to drop your legacy DLLs into this location: \myapp\bin\Release\AppX\. This will be a folder where you find myapp.exe and the AppxManifest.xml
  4. Start WACK  and select your app.
  5. Run through WACK and it will flag all the APIs you’re using that are not on the "approved" Win32 and COM API list.

Note that you'll get a lot of errors if you have an older version of the CRT that is not compatible with Windows RT.