Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Windows Messenger Private API

1.73/5 (4 votes)
2 Oct 20053 min read 1   583  
Explains how to use Windows Messenger's private API, and provides a wrapper class for the challenge-response process

Introduction

Windows Messenger provides API for accessing some of its internal objects, e.g. enumerate the logged-on user's contact list. This API is exposed as a COM object, through the Messenger API Type Library (msmsgs.exe).

A major drawback of this API is that it lacks some basic functionality. For example, it is impossible to programmatically add a given user to the contact list without the need for user interaction (we can only launch the "Add a contact..." dialog box).

This article suggests a solution to this unfortunate issue, through the use of Windows Messenger Private APIs.

Windows Messenger's Private API

Windows Messenger has another set of APIs, which is probably intended for internal MS use only. This API is also exposed as a COM object, through the Messenger Private Type Library (msmsgs.exe). Among other things, the API provides the ability to programmatically add a user to the contact list, with no user interaction whatsoever.

However, attempting to use this API reveals that each and every method throws an exception, claiming that the object wasn't "unlocked". MSDN documentation explains that applications need to authenticate themselves in a challenge-response process, which requires the use of an ID / KEY pair. The latter might have been issued by MS in the past, but no more.

The attached C# source code package demonstrates how the private API can be unlocked.

What's Inside?

The source code package consists of a single VS2003 project (console application) and two C# classes:

  • MessengerUnlocker unlocks a given MessengerPriv object, by performing the challenge-response process. This is the nuts-and-bolts of this article.
  • MessengerUnlockerDemo is nothing but a Main method that creates, unlocks and uses a MessengerPriv object. To prove that the latter is indeed unlocked, a hard-coded user is added to the running user's contact list.

Source code is documented in a standard C# style. Here and there, the source links to external Internet sites for further explanations regarding the challenge-response process.

Troubleshooting

Make sure you have Windows Messenger installed, running and signed-in before running the demo.

Before running the demo a second time, remove the newly added user from the contact list. Attempting to add an already-added contact causes an exception to be thrown.

Disclaimer

This code heavily relies on private and unsupported APIs, which are subject to change at any given moment (assessing the likeliness of the API actually changing in the future is left for the reader). This article is the product of my curiosity and free time. If you base your production code on this, you are mad.

The code was tested against Windows Messenger 4.7.3001, but might as well work perfectly against other versions of Windows Messenger (4.6 in particular). It would probably not work against MSN Messenger of any version.

Thanks

Special thanks goes to http://www.hypothetic.org/docs/msn/, for their great documentation of the Messenger Protocol. These wonderful guys provided me with the last missing piece of the puzzle - a valid ApplicationId / ApplicationKey pair :)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here