Posts

Showing posts from May, 2007

How to create instance of MsftDiscMaster2 in C#

Well... its kinda bittersweet when after 10 minutes composing a compelling post on a technical problem, you figure out the problem right before you hit submit. The tide turns on the bitter side when you spent most of your time formatting the post than composing the text. So... to precent wastage of "knowledge", I post my question, as well as the answer, in the hope that it will help somebody. I was tinkering with the CD-burning API in the Windows Vista SDK, and one of the basic classes needed for that is MsftDiscMaster2 . The MSDN example is in VBScript and does this to create an object of type MsftDiscMaster2 : WScript .CreateObject( "IMAPI2.MsftDiscRecorder2" ) Now, to port this to C-Sharp, the first thing that I tried was this: MsftDiscMaster2 g_DiscMaster = ( MsftDiscMaster2 ) Activator .CreateInstance( typeof ( MsftDiscMaster2 )); It showed me a runtime excption: Cannot create an instance of an interface. However, when I try this round-about way, it works! Msf

Don't catch it!

Dot your i's, cross your t's - but don't catch your exceptions. That's what is recommended if you are coding for Windows Vista. Well, not exactly. There is an extremely interesting post on the recent ANI cursor handling security vulnerability here . It has a new take on catching exceptions. Catching an exception from a vulnerable snippet of code may nullify the protection provided by Vista's address space randomization, since the hacker may repeatedly try different input values without the process exiting. Really interesting. The real question is.. how much attention do we really need to pay to this? Where do we draw the line between reliable code (one that catches exceptions) and secure code (one that doesn't). Is it too early to be worrying about this? I wonder.