MSDN Library without the Bling

The MSDN Library is one of those things I install locally right after installing Visual Studio. It’s an invaluable resource to have at your fingertips. There are however occasions when I don’t have it installed or I’m using the web for some extra search power. Inevitably I end up with something like this:

Can you find the content? Its hiding in the lower right corner and most of it is scrolled out of view to make space for all the bling that dominates the MSDN website. This is really frustrating and makes me long for the simple days of the web when it was all about content. Well there’s hope!

Instead of visiting http://msdn.com/library for the MSDN Library, visit http://msdn.com/library(loband). Notice the (loband) at the end of the URL. You’ll be presented with a simple HTML page with a link to “Persist low bandwidth view”. This stores a cookie on your computer that instructs the MSDN Library to display all future content without frames and simpler HTML.

Although it’s geared at folks with limited bandwidth, it’s a great help for those who appreciate a focus on content. Now when I search the web for shared_ptr here’s what I get:

Now if only I can remember that “bb982026” stands for shared_ptr!

Thanks for the tip Kate!

Produce the highest quality screenshots with the least amount of effort! Use Window Clippings.

Posted by KennyKerr with 1 comment(s)
Filed under:

Installing Visual Studio for C++ Development

Installing Visual Studio for .NET development is pretty easy: Install Visual Studio and the latest service pack. You’re done.

Installing Visual Studio for C++ development is fraught with problems (ok that’s perhaps a bit dramatic). In most cases you not only need Visual Studio and its service pack, but you also need the latest Windows SDK. Since Visual Studio SP1 was released I’ve had some of my installations fail, or worse, just corrupt my build environment. I couldn’t figure out why it would fail some of the time. I eventually pinged Stephan (STL) on the Visual C++ team who pointed out that the Windows SDK installation corrupts the SP1 build environment. Anyway, here is the order in which you must install everything in order for it to work.

1. Visual Studio 2008

2. Windows SDK for Windows Server 2008

3. Visual Studio 2008 Service Pack 1

If you did step 3 before step 2 you need to rerun step 3 which is extremely tedious. Also, since the Visual Studio installation is so complex, I’ve found its less painful to simply reinstall Windows than to try upgrading or repairing a broken installation.

If you follow the steps above you shouldn’t have any problems. Hope that helps.

Produce the highest quality screenshots with the least amount of effort! Use Window Clippings.

Posted by KennyKerr with 2 comment(s)
Filed under:

Windows with C++: Exploring High-Performance Algorithms

My latest Windows with C++ columns in the October 2008 issue of MSDN Magazine is now online:

Windows with C++: Exploring High-Performance Algorithms

In the concurrency space, issues such as coordination, asynchronous behavior, responsiveness, and scalability get the lion's share of the attention. These are the high-level topics that developers think about when designing applications. But, perhaps due to inexperience or the lack of good performance tools, some equally important topics are often overlooked. A case in point is high-performance algorithms.

Enjoy!

If you’re looking for one of my previous articles here is a complete list of them for you to browse through.

Produce the highest quality screenshots with the least amount of effort! Use Window Clippings.

Posted by KennyKerr with 3 comment(s)
Filed under:

Visual C++ in Short: Unblock downloaded applications

Raymond Chen published an article earlier this week about ShellExecute hooks and it reminded me of a shell hook of sorts that still exists in Windows Vista despite Raymond’s very good argument that shell hooks are often used for evil and certainly can’t be used to add security. Granted this hook is not a ShellExecute hook in the literal sense but it amounts to the same thing.

Since I’m long overdue for a Visual C++ in Short article I thought I’d talk about a security feature in Windows that isn’t, well, secure. I’ve previously written about User Account Control and cannot say enough about it being a major step forward in providing a more secure environment for normal users to work and surf the web (with Internet Explorer). But there is this little so called security feature that the Windows shell introduced prior to Windows Vista that somehow came along for the ride but never quite got the UAC makeover and that is the topic of this article.

Many applications are distributed simply as an executable without an installer. You can for example go to live.sysinternals.com and get various great system tools by simply downloading the executable and running it. Similarly you can download the Window Clippings executable and run it without first going through an installer.

Downloading an application and then running it often results in the following dialog box appearing before the application starts:



There are so many things wrong with this dialog box that I don’t really know where to start. Perhaps the most glaring problem is that it is neither consistent nor integrated into the secure desktop prompt used by User Account Control. Granted, the UAC prompt is not used since the application does not need to be elevated but the inconsistency is still jarring for the user.

A more serious problem is that, unlike UAC, this security warning is not coming from the Windows kernel but merely from the ShellExecute function called by Windows Explorer. A simple way to demonstrate this is by using the command prompt instead of Windows Explorer to run the downloaded application:



Sure enough there’s no security warning and the application runs immediately.

What about some code?

Here’s the equivalent of what Windows Explorer does, hardcoded for this example:

::ShellExecute(0, 0, L"C:\\Data\\WindowClippings.exe", L"/options", 0, SW_SHOWNORMAL);

And here’s the equivalent of what the command prompt does:

WCHAR commandLine[] = L"C:\\Data\\WindowClippings.exe /options";
::CreateProcess(0, commandLine, 0, 0, FALSE, 0, 0, 0, &si, &pi);


In fact you can even use ShellExecute’s big brother and tell it to forgo the security warning:

SHELLEXECUTEINFO info = { sizeof(info) };
info.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_NOZONECHECKS;
info.nShow = SW_SHOWNORMAL;
info.lpFile = L"C:\\Data\\WindowClippings.exe";
info.lpParameters = L"/options";

::ShellExecuteEx(&info);


The magic flag in this case is SEE_MASK_NOZONECHECKS.

It might seem that developers should just avoid ShellExecute(Ex) but that is far from the truth. It does add valuable features such as initiating the UAC prompt if needed, whereas CreateProcess would simply fail with ERROR_ELEVATION_REQUIRED.

As the application developer you can’t control whether the user will run your application using the command prompt or by simply double clicking the executable. Arguably the latter is far more common. Short of providing an installer there isn’t much you can do to avoid this security warning. All is not lost however. Take another look at the security warning:



Most users when confronted with obstacles like this one seem to just do whatever they can to overcome them as quickly as possible so they can perform the task they originally intended to perform. It is then not surprising that they completely overlook the little check box in the corner. All they need to do is clear this check box and Windows will no longer prompt them for this application. This check box only exists to annoy the user further. Think about it. Once the user has run the application a single time there’s no reason to prompt the user again in the name of security since a malicious application would have already had the opportunity to cause any intended harm. In fact the application could even unblock itself once it has been given an opportunity to execute some code!

To understand how this is possible we need to take a look at how Windows Explorer knows to block an application from running directly. For starters, you can quickly determine whether an application is blocked by looking at its properties window:



Notice the security warning at the bottom. Clicking the Unblock button has the same effect as clearing the check box in the security warning dialog box. When the application was first downloaded, the browser created an alternate NTFS data stream where it stored zone information. You can view this information using the command prompt:



Unblocking the application simply involves removing this data stream. Although not foolproof, such as when the application does not have the file permission to delete the data stream, it works in most cases.

Start by getting the full path to the executable. You can do this with the QueryFullProcessImageName function that was introduced with Windows Vista. If needed, you can fall back to the slightly less reliable GetModuleFileNameEx function for previous versions of Windows. Now simply append ":Zone.Identifier" to the path and call the DeleteFile function to get rid of it. Here is a complete example. The UnblockProcessImage function returns S_OK if the file was unblocked, S_FALSE if it wasn’t blocked to begin with, or another HRESULT describing what went wrong.

HRESULT UnblockProcessImage()
{
   static const WCHAR streamName[] = L":Zone.Identifier";

   WCHAR fileName[MAX_PATH + _countof(streamName)] = { 0 };
   DWORD length = MAX_PATH; // Deliberately not the actual size

#if _WIN32_WINNT >= 0x0600

   // QueryFullProcessImageName updates the length parameter.
   if (!::QueryFullProcessImageName(::GetCurrentProcess(),
                                    0, // flags
                                    fileName,
                                    &length))
   {
       return HRESULT_FROM_WIN32(::GetLastError());
   }

#else

   // GetModuleFileNameEx returns the length.
   length = ::GetModuleFileNameEx(::GetCurrentProcess(),
                                  0, // module
                                  fileName,
                                  length);

   if (0 == length)
   {
       return HRESULT_FROM_WIN32(::GetLastError());
   }

#endif

   wcscpy_s(fileName + length, _countof(fileName) - length, streamName);

   if (!::DeleteFile(fileName))
   {
       const DWORD error = ::GetLastError();

       if (ERROR_FILE_NOT_FOUND == error)
       {
           return S_FALSE;
       }
       else
       {
           return HRESULT_FROM_WIN32(error);
       }
   }

   return S_OK;
}

Please understand that I’m not advising developers to do this. I’m merely demonstrating that it is possible. A better solution is to simply ship your product with an installer, which is exactly what the next version of Window Clippings will provide.

Produce the highest quality screenshots! Use Window Clippings.

Posted by KennyKerr with 12 comment(s)

Window Clippings v3 Sneak Peek – New Options Window – Take 2

I’ve updated the layout a bit to reduce the focus on the configurations. I felt that the configuration selection was too prominent in the earlier builds and I also wanted to make the window simpler and more approachable.



Here you can see the options corresponding to the Image tab in version 2 of Window Clippings. There’s nothing really new here aside from the new color picker. I’ve never liked the built-in color picker that Windows provides so I decided to bake it into the options window even though it’s not a very necessary feature.

Posted by KennyKerr with 1 comment(s)
Filed under:

Feedback Forum for Window Clippings

Window Clippings has always been very much driven by the feedback I receive from the community. Up till now I have received that feedback primarily via email and comments on my blog.

As I work on version 3 I thought I should try and make this a bit more manageable and open so I’ve set up a Feedback Forum for Window Clippings. I’ve also seeded it with a few suggestions. I still need to go through all my emails and comments and add various other suggestions that I’ve received but hopefully this is enough to get things started as far as the forum is concerned. I obviously can’t guarantee that every suggestion will turn into a product feature but you can bet that popular suggestions will seriously be considered for inclusion.

Please add suggestions and vote!

Posted by KennyKerr with 2 comment(s)
Filed under:

Back to the Future... Please

A new day and a new job as a technology consultant in London. I think this screenshot says it all:

Can you tell what those applications are? I know it’s been a while so let me help you. First up is Visual Studio 2003 sporting the .NET Framework version 1.1. That’s before such fundamentals as TryParse, generics and 64 bit support.  Then there’s Visual C++ 6, released in 1998 if I remember correctly. Finally there’s Internet Explorer 6, as witnessed by the lack of PNG alpha blending (and tabbed browsing). This lovely collection of software is running on Windows XP SP2, released somewhere around 2004.

Just so we’re clear: as I write this it’s nearing the fall of 2008.  Can you feel my pain?  :)

Posted by KennyKerr with 13 comment(s)

Window Clippings v3 Sneak Peek – New Options Window

I’m hoping to get Window Clippings version 3 released before the end of the year but being an evenings and weekends project it’s hard to say for sure. What I did want to start doing is give you a sneak peek of where I’m heading and get your feedback along the way. To kick things off here are some screenshots of the new Options window. In subsequent posts I’ll talk more about the individual features but you can probably guess at a lot of what’s coming up based on what’s in these screenshots. These screenshots are taken on a high resolution screen at 120 DPI so they may appear a bit larger than usual if you’re using the default scaling.

As you can see I’ve finally decided to drop the property sheet as the number of new tabs was becoming overbearing. I hope you like the new layout.

The new window is also resizable to make it easier to manage the growing collection of add-ins:

Please keep in mind that the UI will likely change as I get closer to release and of course the official set of add-ins that will be included with v3 has not yet been finalized.

What do you think?

Posted by KennyKerr with 9 comment(s)
Filed under:

Send your Window Clippings to ImageShack

Maximilian Krauß recently sent me an add-in he wrote for uploading images to ImageShack. I’d never heard of the ImageShack service before but it turns out you can upload and host images for free and without needing to create an account. As you can see, the add-in itself provides no settings:

 

After the image is captured the add-in immediately proceeds to upload the image:

On completion it presents a window with links that you can use to refer to the uploaded image:

You can download it here

Thanks Maximilian!

Posted by KennyKerr with 1 comment(s)
Filed under:

ActionFTP for Window Clippings

Sorry for the lack of updates again. I have a pile of posts in the queue but I just haven’t had the time polish them enough for publishing. Anyway... 

Fred Taylor-Young recently released the ActionFTP add-in for Window Clippings. This is meant to be an improvement over the original FTP add-in that Ari Glaizel wrote. As with the original add-in, ActionFTP is a “Send To” add-in for uploading images to an FTP server. It however adds the ability to edit the image before it is uploaded by passing it to the program of your choice.

You can download it here. While you’re there you can admire his awesome array of monitors. :)

Posted by KennyKerr with 1 comment(s)
Filed under:
More Posts Next page »