Wednesday, September 2, 2009

Security warnings and NTFS ADS

Since Windows XP Service Pack 2, after downloading a file from the internet and running it, you have probably see a message box in this form:


The solution to get rid for good of this warning is to clear the check box or to open the properties of the file and unblock it:

If you have multiple files to unblock, you can use the streams.exe utility, by SysInternals.
What's happening behind the scenes? Since NT 3.51, NTFS has the possibility to store data into the so-called ADS or Alternative Data Streams, alternative containers of information associated to files. A file has a main stream called $DATA where its information is stored, but multiple streams can be created in the form file:stream. The information contained in a stream can be shown by opening a command line and using the command more:

more < file:stream

In the case of the downloaded executables, Windows adds a stream named zone.identifier, that contains the following information:
[ZoneTransfer]
ZoneId = 3


When ZoneId gets a value of 3, it means that the file was downloaded from the internet zone.

Thursday, August 20, 2009

C++/CLI: the debugger can't hit any breakpoint

I'm extending a pure C++ solution using C++/CLI one with VS2008: it's a dll that gets invoked by our main program. For debugging purposes, in the same solution I have a separate project that links to the public interface of the DLL. Nice and easy, right? Yes, until I added the /CLR switch to the compiler command line; from that moment on, I was unable to debug the DLL, since VS couldn't reach the breakpoints I set, showing them as hollow circles with the yellow alert sign superimposed and informing me that no source code could be found. The precise error was:

"Breakpoint will not currently be hit. There is no source code available for the current location"

To make a (quite) long story short, the problem was in the settings of the debugger: you have to set the debugger in mixed mode
in the project of the exe calling the dll.




Tuesday, August 18, 2009

Visual Studio 2008 error "C2471: cannot update program database"

Having converted a Visual Studio 2005 C++ solution to Visual Studio 2008, while regenerating it for the first time I got a bunch of "C2471: cannot update program database" (in italian: "C2471: impossibile aggiornare il database di programma") errors. Ouch... At first I tried installing the Microsoft hotfix but for unknown reason the setup refused to work, then I found this blog post by Loren Heiny, where he writes about a workaround he found. Perhaps the solution is even simpler: just restart Visual Studio 2008 and regenerate the project. Why? Oh well, the only hypothesis I could think of is that, immediately after a solution conversion, VC++ 2008 keeps some files opened and is not able to update them.
Have fun!