Monday, February 18, 2013


Yup. Harassed.

Proper stressed out.

We found a problem today. An issue with dialling into a remote device running Windows CE6.

The device is running the out-of-the-box RAS server with a custom configuration/launcher. There are some minor issues with the launcher, but mainly that's fine. Which is a massive relief! We won't have to update all of the remote devices.

No, the problem is on the server which does the dial-up. Yes, I know this architecture is backward. The server? Dialling up? WTF?

Legacy stuff - just live with it.

The dial-up server was only able to keep one connection active at once! It could dial two or more, but you could only get IP traffic through the latest connectoid to answer. A wee bit of a problem! We absolutely need to able to connect to many devices concurrently.

This is a fairly large problem waiting to get bigger and uglier. I can think of a few things that fit into that category.

Apparently, the problem lies with the routing table. Heh - go figure.

The routing table maps potential IP end points with network interfaces. Each table entry can be wide or narrow depending upon the subnet mask. Full mask - narrow address range. Empty mask - HUGE address range.

By default, the RASDial function connects to the remote device and sets up some entries in the routing table. Very helpful of it? Nope - not in this case. Pretty much just remove all the entries that were automatically added. And add your own.

If you don't manage the routing manually, then when a new connection is made, you lose traffic to all the previous ones.

All you need is a single entry that maps the new remote server IP address with a subnet of to a gateway with the same IP address. And you can do that with the 'ROUTE' command line utility.


The operating system references each network adapter with an index number. You will need this when adding a new route. It essentially routes the new traffic via that network adapter. An active RAS connectoid is classed as a network adapter.

For example.


removes the ridiculously wide default address range route for the RAS connection on


adds the route you need to map all traffic to so it gets to the RAS server (assuming network interface index 3 - the 'IF' parameter).

Finally, you should remove the route with destination ''.

Neat eh?

In code, you can do this by spawning a process with the appropriate ROUTE command line, using WMI (Win32_IP4RouteTable) or with API calls (IPHlpApi.dll).

I found the former the quickest and most reliable implementation.

So I'm not as harassed now.

[Update] One thing to be wary of. For any of these options to work, the application has to be running as administrator. If you're using the option that launches the command line utility, set the Verb member of the ProcessStartInfo structure to 'runas'. You'll find, however, that the UAC dialog keeps popping up. It is possible to force the UAC to popup just once when the program starts by changing the application manifest file. The process that you spawn can also be created without using ShellExecute which bypasses the UAC checks completely (ProcessStartInfo.UseShellExecute = false). However, I just could not get that to work at all! Maybe you'll have better luck.

Saturday, February 16, 2013


Imagine a large airy room. It's a splendid room. The walls have burnished oak panelling and the floor is tastefully tiled with regular patterns of deep green and grey. There are tall curtained lattice windows looking out to a verdant garden.

It's a bit dusty though, and, well, empty. There are just you and the cobwebs.

You look around to try and find anything of interest.

You find nothing. The room is empty.

Before you entered the room you didn't know what to expect. But, you thought that there would be more than this!

You grasp the ornate brass door handle before giving the room one last disappointed glance and then you leave, unfulfilled.

It's a sad, sad tale. What's even sadder is that the owner of the room was watching all the time. Maybe he has a little spy hole in one of the wall panels. Maybe he's behind one of the apple trees in the garden. Maybe he's just omnipresent.

But when he saw the expression on your face as you were leaving his heart became heavy. He shared your sense of emptiness.

All the while he wanted to say, "It's such a lovely room! Please, stay a while".

There's real love in this room. A sense of pride expressed by the workmanship in every tile; in the deep pile of the curtains; in the gleaming polish of the door handle.

You see, the room's not empty. It's just not full yet.

Over time, the room will be enriched with luxurious and interesting curios and knick-knacks. Lots of interesting things to enjoy, to ruminate upon and to share.

That's what will happen with Strongly Typed. I'll add more and more snippets of wonder to keep you coming back to the wonderful room.

So next time, please, stay a while.

Because it's great to meet you.