Wednesday, November 28, 2007

DLL Dependencies

Found this blog entry on geekswithblogs.net linking to Dependency Walker. This is an application that shows you the dependancies that a DLL has.

I couldn't get to the site though, so I downloaded the app from majorgeeks.com.

There's a comment on that blog saying it doesn't work with .Net assemblies though, but you can just use ildasm for that, and look in the manifest.

Monday, November 26, 2007

Blackwater (Jeremy Scahill)

I'm currently reading Blackwater: The Rise of the World's Most Powerful Mercenary Army by Jeremy Scahill. It recounts the history of Blackwater USA (Wiki entry here), the company employing a large proportion of the "security contractors" hired to protect assets in hostile places around the globe, such as in Iraq.

The book begins by documenting the bloody ambush of Blackwater contractors in Fallujah in March 2006, and moves on to tell how the U.S. Government is increasingly using companies such as Blackwater to influence foreign policy where it would be politically unwise to use the U.S. Military. Scahill tells how Blackwater has set up bases in Tbilisi, Georgia and Azerbaijan which are now tantamount to having unofficial U.S. bases in the area, but without the political uproar.

The book certainly makes interesting reading. In fact, what I find most enlightening is not how powerful and influential companies like Blackwater are, but rather the clear political wrangling that goes off behind closed doors, that common folk like me only get a hint about in the press.

Scahill is obviously very passionate about this cause, and he has produced a seemingly well researched piece of writing that forces us to ask questions not just about our role in Iraq, but also asks us to cast an eye over other conflicts and places of political unrest. It is clear from the stories told in this book that our governments aren't giving us a true picture of what is happening in these places. But this is something a cynical, skeptical person such as myself already suspected anyway.

However, the book could hardly be called impartial, and as such it loses much of the credibility it should be earning. Scahill's choice of language is constantly laced with emotive terms that will make it easy for any party opposed to his views to dismiss the entire book as left-wing propaganda.

In choosing to write in this style Scahill has made a rod for his own back. What should be a chilling, hard hitting exposé on the U.S. Government's recent political choices is in danger of being wholly dismissed when the questions it raises deserve to be answered.

If you can look past the occasional emotional phrase, and concentrate on the fully referenced source material, you can see a book which raises as many questions as it answers. Although I doubt answering these questions was ever Scahill's intention, in writing this book he has at least made public what is happening that other media sources aren't giving us a true picture of.

What does that error code mean?

If you've ever come across an error number in managed code it can be infuriatingly difficult to find out the true root cause of your problem: normally there's a helpful wrapper around the numbers, giving (semi) meaningful names to the errors encountered.

But, work with stuff long enough and you'll soon find a huge, dirty-looking (mostly negative) integer staring back at you in your log files or debugger window and you'll wonder "What the **** does that mean?"

If you can't find anything on Google for the exact number you've got, paste the number into calc and convert it to hex. You'll usually get a number preceded by a bunch of Fs, which you can ignore. Do another search for this hex number (minus the Fs), and you'll sometimes get something which will point you in the right direction.

It was on such a search where I stumbled across this helpful document. This text file contains a heap of hex error codes and their meanings. judging by the ntstatus.txt file name they look to date back to Windows NT days, but they're still helpful now in some cases.

I can't say that everything in there is accurate, or that every error code you'll get is listed there.

Creating an Interop Assembly for RTC Client API 1.3

If you want to use the RTC Client API 1.3 in managed code (like C# or VB.Net), you need to create an Interop assembly from the rtccore.idl file that is found in the C:\Program Files\RTC Client API v1.3 SDK\SDK\IDL directory (if you used the default installation path).

There are some steps detailing how to create the assembly here: Creating a Interop Assembly for RTC Client API 1.3. However, I found that they were a little out of date and I had to do some reading around before I understood them.

To create the assembly:

1. Download and install the Microsoft ® Windows Server® 2003 R2 Platform SDK. This SDK works for "the x86, x64 and Itanium-based versions of Windows Server 2003, Windows Server 2003 R2, Windows XP SP2, Windows XP x64 Pro Edition, and Windows 2000".

2. Go to the Visual Studio 2005 Command Prompt from Start Menu -> All Programs -> Microsoft Visual Studio 2005 -> Visual Studio Tools

3. In the Command Prompt window, change directory to where the rtccore.idl file is (C:\Program Files\RTC Client API v1.3 SDK by default).

4. In the Command Prompt type: midl /I "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include" rtccore.idl. This will create 5 new files in the directory. One of which is rtccore.tlb.

5. In the Command Prompt type: tlbimp rtccore.tlb /out:Interop.RTCCore.dll /namespace:RTCCore /sysarray. This will create an Interop.RTCCore.dll file in the directory, which you can then reference in your .Net applications.

Using Microsoft's Speech API (SAPI) in managed code

Neat little article here for How to use Microsoft's Speech API (SAPI) in a managed application.

Doesn't go into much detail on how to use it afterwards, but there's enough there to show how simple it is.