Mandelbrot Set with C++ AMP

March 23, 2014

C++ AMP (Accelerated Massive Parallelism) is a Microsoft C++ library that can be used for General Purpose (GP) computing on Graphic Processing Units (GPU), and theoretically at least, other future devices – all in mostly standard C++. “General Purpose” here means processing that is unrelated to graphic rendering, which is the basic capability of a GPU. AMP certainly has alternatives, such as Microsoft’s own High Level Shader Language (HLSL), used mostly for shader authoring, part of the GPU’s graphic pipeline; but shaders can be used for general purpose computing as well called DirectCompute; DirectCompute seems to no longer being...
no comments

Debugger Visualizer for Non-Serializable Types

March 19, 2014

A debugger visualizer provides a rich way to “visualize” in some sense a .NET object within Visual Studio while debugging. Writing a basic debugger visualizer is simple enough: create a Class Library project with a class that derives from DialogDebuggerVisualizer and override the Show method. Inside the Show method, a call to IVisualizerObjectProvider.GetObject method (the interface is provided in an argument to Show) retrieves the object in question. The next step would be to create the actual “visualizer”and show it with a call to IDialogVisualizerService.ShowDialog method. To actually advertise the existence of the visualizer, an assembly level attribute...
no comments

Creating an Object Manager Browser Part 3 – Security Dialog

February 26, 2014

In the previous post we’ve managed to get most of WinObj’s functionality – browsing the folders and viewing object information. The last “major” missing piece is the security dialog that shows security related information for certain object types. I’m certainly not a security expert; on top of that the security API in Windows is one of the most dreadful APIs in all Windows. Fortunately, to get the standard security dialog to show we just need to call one function – EditSecurity or CreateSecurityPage. The former shows the basic security dialog box and returns when it’s dismissed, while the latter...

Creating an Object Manager Browser Part 2–Viewing Object Information

February 9, 2014

In the previous post, I’ve shown how to use Native API functions to access information not available through the normal, documented, Windows API. In this post, I’d like to show how to take a look at specific objects, such as mutexes, events and semaphores. But first, a bug fix. In the code that was doing the directory object enumeration was a bug, manifested when the list of objects was too long – or rather, the buffer required to hold all object names and type names was insufficient. The code checked the returned number of bytes needs and compared with...
no comments

Creating a “WinObj”-like Tool

February 5, 2014

The SysInternals WinObj tool allows looking into the Object Manager’s namespace: The left view looks like file system folders, but in fact these are logical folders maintained by the Object Manager (part of the Executive within the kernel) purely in memory. I will not get into details about the information itself that is provided by the tool in this post. You can find some information on the web and the book “The SysInternals Administrative Reference”. How does WinObj gets the information? One obvious way is to use a driver – in kernel mode everything is...

Test Signing Drivers on Windows 8.x

January 26, 2014

I’ve been on a driver streak lately, maybe because I’m completing my third “Windows Internals” course on PluralSight. (if you’re a .NET developer, then you may want to skip this post… ) The last two modules of that course (should be published in a week or two if all goes well) deal with writing a software driver, meaning a driver that exists for the sole purpose of executing code in the all-powerful kernel mode. One of the requirements of a driver for a 64 bit Windows system is to be signed – otherwise it would fail installation. This means...
no comments

Sharing Code between Windows, WinRT and Windows Phone

December 16, 2013

In recent times, I often find myself developing for more than one “Windows” platform – typically Windows Phone and Windows 8 Store and sometimes Windows (WPF) as well. In this post, I’d like to share some of the tools and techniques I’ve been using to ease code sharing. Portable Class Libraries (PCLs) PCLs came out in Visual Studio 2012 and provide an easy way to create a single project that can be referenced by multiple project types. When you create a PCL, you get the following dialog: This dialog allows you to select multiple targeted platforms (at...

Color Gradient Generator

November 12, 2013

A while back, I created a WPF Mandelbrot Set program with zoom abilities. I demonstrated the use of async/await for writing code that works asynchronously (to keep the UI responsive), but is easy to write as synchronous code. Here’s a sample image:The image is grayscale, so I wanted to make it use colors, to indicate the level of “being part of” the Mandelbrot set. The problem here is how to create a nice color gradient that moves smoothly from color to color.One possible option might be to leverage an existing class, such as WPF’s LinearGradientBrush, set up a bunch...

MVVM View vs. Control

November 3, 2013

In the MVVM world, Views are attached to ViewModels. How can a view be implemented? Typical answers for say, WPF, are: Window, User Control and Data Template. Similar answers exist for Windows Phone and Windows 8, where “Window” may be dropped or replaced by Page.This is certainly true, but about that User Control? Can any user control automatically be considered a View? Not quite.The distinction between view and control (user control or otherwise) is based on reusability and dependency. A View requires a ViewModel to give it context. A View cannot function without a ViewModel. Typical XAML View would...
no comments

Using KeyedCollection<> instead of a Dictionary<>

October 23, 2013

The System.Collections.Generic.Dictionary<TKey, TValue> class is one of the most useful of all .NET collections. It maps a key to a value, and allows for fast retrieval based on the key, as it’s implemented as a hash table, calling GetHashCode on the key object to get to a specific “bucket”, and then looks up the actual value (with Object.Equals or a specific IEqualityComparer<Tkey>.Equals).One feature that Dictionary<> doesn’t support is the ability to access items by integer index. That is, insertion order is not maintained. For most cases, this may be ok, but some cases require fast search and index based...
no comments