Valter Minute's blog

Twitter












Tag Cloud


APIs to create APIs

Antelope Canyon (Arizona, USA)
I hope that the title sounds funny, because, as usual, I can't found a better one...
During the last months I had to port from CE 5 to CE 6 a project where I used an undocumented feature of Windows CE 5, the ability to register an API sets.
This feature allows an application, a driver or a system module to register its own APIs, that can then be accessed by application as regular OS APIs.
I had to use that undocumented feature to provide some redraw functions for a custom "skin" of the Windows CE UI.
In Windows CE you can provide your own custom implementation of windows and control drawing functions. This great (and not so well documented, IMHO) feature of the OS allows the creation of user interfaces that are completely different from the one provided by default and allow a full and deep customization of the UI of all the applications running on your device, both custom ones and OS or third party provided ones.
In my custom UI I needed to export some drawing  functions to .NET applications, to let those same function to be used inside managed custom controls, to keep all the UI coherent.
I didn't want to duplicate code, and the implementation of custom UIs on CE (static libraries linked to GWES) does not allow any "generic" function call interface (like DeviceIoControl for drivers or KernelIoControl for OAL).
I tried to find another mechanism and stumbled upon CreatAPISet and other API-realted functions inside the CE shared source. Having the source code of most of the OS is a great tool for a hacker... and I used it to create my own API set.
After having bored you with this sad story about myself, I'm happy to announce that now the APIs that can be used to create your own API set (sounds like a joke) are documented inside Platform Builder reference!
If you search "Creating, Registering, and Using a Handle-based API Set" inside PB help or simply follow this link:
http://msdn.microsoft.com/en-us/library/bb202802.aspx
you will find a detailed description of the operations required to register your own API server and use this feature of the OS.
This also made my porting simpler and keep me safe from the side effects of using undocumented features of an OS: the risk of losing compatibiltiy with newer versions and the risk that some of those functions may have unexpected side effects when used in some particular conditions (the nasty thing you usually discover inside the "remarks" sections of the reference page of documented APIs).

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

No comments posted yet.