Category Archives: Research

Directory object dialog in .NET, and advanced COM marshaling

Last week I wanted to start a new .NET project, and I needed a directory object picker for it. I searched the web and found some solutions, but they just didn’t look right and decided that I can do a lot better than those. So in the spirit of creating good and reusable code, I started implementing my own IDsObjectPicker wrapper in my framework. I thought it would be easy, and it turned out to be anything but, but the result was awesome: clean, easy to use, and it works. And just like last time, I learned a lot about COM interop, you can read all about it here, or just scroll through and grab it already. Continue reading

How to impersonate the Windows system account in an application

During the research of my previous post, I wanted to find out if it’s possible to impersonate the system account in an application (NT AUTHORITY\SYSTEM). Apparently, and much to my surprise, it’s a bit more powerful than the administrator account. The short answer is that there’s no clean, reliable, non-intrusive and portable way to do that, and in most cases, there are much better solutions. But if you really want the impersonation, then here are the possibilities that I found on my Windows 7 system. Continue reading

Getting the size of a volume shadow copy snapshot

The volume shadow service (VSS) has a storage limit on each volume. If it needs more space for a new snapshot, it deletes an old one. If you want to create a smarter space management algorithm, which also considers the size of individual snapshots, you’re in trouble, because getting the size is not documented anywhere. But now it is :) . Continue reading

Windows antivirus API in .NET, and a COM interop crash course

Like I said in my previous post, I already coded something cool in my framework, and here it is: .NET code to call the Windows antivirus API. The best use case scenario I can think of is when retrieving and then redistributing file content from an untrusted data source, especially a web upload form. In cases like this, content might slip through the realtime protection of most antivirus products, and an API like the one I created is the only solution. Continue reading