Microsoft Windows and all that goes with it

Windows 8

Illustration

Windows 8 download is here. Go get it.

And, while you are at it, get Windows 8 Server beta and a Visual Studio 11 beta.

[2012-03-01: I just finished installation and it cannot either install .NET Framework not it can do Windows Update. Somebody screwed-up something…]

P.S. And I still cannot run my own software without running through hoops since Windows 8 “protects me”.

Illustration

P.P.S. And, since my computer has no SLAC, Hyper-V as single reason for upgrade is there no more… :(

Solving a Mess

If Tom’s Hardware is to be believed, we will lose Windows 7 Starter/Home Basic/Home Premium/Business/Enterprise/Ultimate mess. Instead we will have Windows 8, Windows 8 Enterprise and Windows 8 Professional.

I do not know about you, but I do feel this is MUCH better. Until they start adding new releases…

[2012-03-03: Having three editions for Windows 8 was too good to be true. It seems that there are plans for 8 different versions (not including ARM). I am sure that everybody will be thankful to Microsoft for being forced to read various comparisons only to find later that some critical feature is not supported in selected edition. I can hardly wait…]

[2012-04-17: There might be some hope for Microsoft. It seems that count will stop at two (and few extras).]

IPv6 in IPv4 World

Illustration

In order to get into modern era I decided to teach my computer to talk IPv6. Windows 7 already comes with IPv6. I mean, how hard can it be?

Well, since my Internet provider does not give a **** about IPv6 first step is to get a tunnel. And there are quite a few IPv6 tunnel providers. In my case I decided to go with SixXS since they have support for both Windows 7 and (via black magic) my DD-WRT router. For Windows 7 you do need to have their AICCU client installed (and probably OpenVPN). Slight nuisance but bearable.

Once my account was ready (it took them less than a day) I created an Dynamic NAT-traversing IPv4 Endpoint using AYIYA (now repeat this really fast). All eager I awaited for confirmation. Instead of it I got “SixXS has discussed your request regarding a tunnel but have decided not to approve this request”. Nothing in mail pointed to what I did wrong. My guess was that they noticed I am trying to use Ashburn, VA (where I currently live) with my Croatian address (where I usually live). I elaborated my situation and waited for response. And waited. And waited. No response (10 days and counting).

Thus I decided to see what other brokers are out there and I found one that would work for me - Hurricane Electric. They give you up to five /64 tunnels and upon that you can additionally request /48 prefix. Their tunnel endpoints are not that numerous but I think that they offer satisfactory range.

But that is not the best thing. After reading guides for setting up SixXS I was pleasantly surprised that my configuration consisted of 4 lines:

netsh interface teredo set state disabled
netsh interface ipv6 add v6v4tunnel IP6Tunnel 192.168.1.2  10.20.30.40
netsh interface ipv6 add address    IP6Tunnel 2001:db8::1:0:0:2
netsh interface ipv6 add route ::/0 IP6Tunnel 2001:db8::1:0:0:1

And you do not need to remember those 4 lines since they will be generated automatically for you and available on Tunnel Details page. Just take care to fill first IP correctly (192.168.1.2 in this example) No additional software, no new drivers - Simplicity at it’s best.

So far I think I am convert. While SixSX has a little bit better support for dynamic IPs, things are not too bleak for Hurricane. And keep in mind that Hurricane does tunneling over protocol 41 so there is need for your network to support this (almost each one does).

In short, I would say that Hurricane Electric is much better choice if you have normal provider who does not block any traffic. In any case, I am IPv6 (and so can you). :)

ReFS

Illustration

For long time now NTFS is the system of choice for Windows. Well, that is about to change.

For upcoming Windows 8 beta we shall get Resilient File System (ReFS for friends). Features are making my head spin:

  • Compatible with NTFS application layer.
  • Data is verified and auto-corrected.
  • Live data recovery (bye, bye offline mode).
  • Transactional model.

From design point of view it looks more like unholy combination of relational database and version control than a file system (that sounds familiar). As I read I decided that it will be my new system to install Windows 8 on. And then I noticed two deal breakers: It will be available only on Windows Server 8 and you will not be able to boot of it.

At first this file system is intended for Windows Server 8 volumes only. You will boot good old NTFS and then store all your data on ReFS. And forget per-file encryption since EFS is not supported. Well, at least there is BitLocker.

My developer life is more aligned with Windows client OS than server so I will skip it for now. I just hope that ReFS will not stay limited to server but that it will find it’s way into consumer’s life also. And, Microsoft, don’t forget booting…

[2015-03-12: With Windows 8.1 you get ReFS on client Windows too.] [2017-09-05: ReFS is no longer supported on Windows 10 Pro.]

VHD on ExFAT

Illustration

One of nicest hidden gems in Windows 7 is exFAT. It’s a simple file system with support for huge files (16 EB) but without any support for access control. Pretty straightforward replacement for FAT32.

As leap of faith action I decided to format one whole disk with it. It was disk that kept my multimedia files and occasional virtual disk. I wasn’t troubled by security since BitLocker works like a charm even inside of VHD. Unfortunately that plan was snipped in the bud.

As soon as I created virtual disk I was greeted with “The requested operation cannot be completed due to file system limitation”. Even worse, you cannot attach already existing VHD that happens to be there. It simply refuses to do anything.

While I haven’t done any detailed analysis, it seems that exFAT and VHD do not work together.

Focus Thief

Illustration

There is NO REASON WHATSOEVER to make a window top-most if user has not explicitly requested so. And no application should make that sin.

Let’s imagine a scenario in which your server temporarily refuses connection. Outlook detects that password/user-name fails and decides to ask you. Since this is so important it shows window in foreground as A FUCKING TOP-MOST window. You dismiss it with cancel in order to continue with your work. In three seconds FUCKING TOP-MOST window reappears and you click it away, again. And it appears again. And you dismiss it again. And you start writing something only to have that FUCKING TOP-MOST window steal focus again. Most viruses/worms/diseases I know are not annoying as much as Outlook 2010.

I believe that developer who implemented this should be forced to do team programming with whichever moron manager thought this was a good idea. And they should kick each other in balls every time window pops-up.

Word of Caution

Of course I did install Windows 8 Developer Preview. And of course I selected my primary machine as guinea pig. Installation of Windows 8 itself went into virtual disk onto my RAID mirror and it completed without any issue.

My feeling for interface is that it is too phone-like with all stupid restrictions that this brings. For example, most of dialogs cannot be traversed by using Tab key. If you are using keyboard as your primary input device that will annoy you. Interface between legacy and new applications is troublesome at best and I have feeling that Microsoft will need to do a lot of work on this one.

I also find new start menu as pointless exercise in minimalism. It might be me, but I do not see why menu of only few items deserves it’s own taskbar space. If desire is to remove “clutter” they might as well remove that whole button.

And this is all I have to say so far.

P.S. If you are wondering why there ain’t any more opinions about Windows 8, answer lies in fact that I am not using it anymore.

Although I did install it in VHD, that VHD was on RAID mirror. At first everything seemed to be working fine but after hibernation my RAID was broken and I could not boot. Quick visit to DISKPART (part of Windows 8) gave me opportunity to know that RAID is being rebuilt and, in Microsoft’s eternal wisdom, there was no way to check it’s progress. However, few hours later, sync was done and I could boot.

After next hibernate I was given same treatment once over but this time I could not make it boot (even as RAID status said healthy). My first solution was to execute BOOTSEC.EXE /FIXMBR and BOOTSEC.EXE /REBUILDBCD. I was surprised when these commands (executed from Windows 8 installation prompt) gave me my original (Windows 7) BCD and not a new Windows 8 one. I haven’t analysed it further but it seems that someone forgot to update that part of installation medium.

For better or for worse, I need to install Windows 8 again. This time I will probably sacrifice virtual machine and thus I will not check what I desire the most - Hyper-V in client OS.

Windows 8 Developer Preview

Today world should see Windows 8 Developer Preview. Download will be is available at Windows Dev Center. I can hardly wait to see Hyper-V for client OS in action.

P.S. I will not try it this week since I am behind hotel wireless. As soon as I get some normal connection I intend to start using it. Whatever that brings…

Hyper-V This

Illustration

I adore Hyper-V as a product but I do not use it on my desktop. I tried to use server OS mostly because of Hyper-V but it was just too painful. Then I tried to use Virtual PC but new version got stripped of it’s support for anything that is not Microsoft OS. At the end I use VirtualBox for most of my personal needs and I use Hyper-V Server whenever I have a need for more permanent and robust solution. Well, this is about to change. It looks like Windows 8 is going to have Hyper-V built right in.

Compared with Windows Server line it got one feature that was annoyingly missing - support for WiFi adapters. Finally there is possibility to connect your laptop’s wireless card to virtual machine and to have traffic go through it. That feature was missing for a long time because of some issues with how wireless adapters work and it is good to see that it will be available (hopefully Microsoft will not back out of this) with all naughty stuff sorted in background.

Another Hyper-V “feature” that annoyed me is inability of hibernating machine with Hyper-V installed. There is no mention of any changes here, but I do hope that this issue is also sorted out. I simply cannot imagine desktop/laptop virtualization without this.

All in all seems like Microsoft is putting all it’s virtual eggs in one virtual basket and that there will be finally consolidated virtualization architecture on both server and desktop products. Virtual PC 2007 SP1 be gone, you were inadequate solution anyhow.

Original announcement is available as part of Microsoft’s Building Windows 8 blog.

Long live Ctrl+Alt+Left.

How to Initialize Disk

Illustration

When new EMPTY disk is added to Windows first thing that needs to be done is initialization. Only after this step Windows will recognize disk as their own and allow you to create partitions.

Part of (bigger) script was automatic disk initialization. Surfing Internet yielded just few results for this particular problem. Most of them were using DISKPART and this was not acceptable. I needed something in Win32 API.

Theory is simple enough. Single function that does it all is DeviceIoControl. Unfortunately this function is ridiculously overloaded. Little bit of investigation will bring us to IOCTL_DISK_CREATE_DISK control code which does disk initialization. Even better - almost all parameters can be ignored or set to default.

Only parameter that we must understand is CREATE_DISK structure so it is only appropriate to have it use unions. As you might know, there is no meaningful support for unions in C#. There is a way around it with FieldOffset(0) but it does not look nice.

Rest of code is fairly straightforward. To call it just use DiskIO.InitializeDisk("\\.\PHYSICALDRIVE4") (substitute number for whichever drive you wish to initialize).

Full code follows:

internal static class DiskIO {

    public static void InitializeDisk(string path) {
        var signature = new byte[4];
        RandomNumberGenerator.Create().GetBytes(signature); //lazy way to generate "unique" signature

        using (SafeFileHandle handle = NativeMethods.CreateFile(path, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, 0, IntPtr.Zero, NativeMethods.OPEN_EXISTING, 0, IntPtr.Zero)) {
            if (handle.IsInvalid) { throw new Win32Exception(); }

            var cd = new NativeMethods.CREATE_DISK();
            cd.PartitionStyle = NativeMethods.PARTITION_STYLE.PARTITION_STYLE_MBR;
            cd.MbrGpt.Mbr.Signature = BitConverter.ToInt32(signature, 0);
            Int32 bytesOut = 0;
            if (NativeMethods.DeviceIoControl(handle, NativeMethods.IOCTL_DISK_CREATE_DISK, ref cd, Marshal.SizeOf(cd), IntPtr.Zero, 0, ref bytesOut, IntPtr.Zero) == false) { throw new Win32Exception(); }
        }
    }


    private static class NativeMethods {

        public const int GENERIC_READ = -2147483648;
        public const int GENERIC_WRITE = 1073741824;
        public const int OPEN_EXISTING = 3;

        public const int IOCTL_DISK_CREATE_DISK = 0x7C058;


        public enum PARTITION_STYLE {
            PARTITION_STYLE_MBR = 0,
            PARTITION_STYLE_GPT = 1,
            PARTITION_STYLE_RAW = 2,
        }


        [StructLayoutAttribute(LayoutKind.Sequential)]
        public struct CREATE_DISK {
            public PARTITION_STYLE PartitionStyle;
            public CREATE_DISK_UNION_MBR_GPT MbrGpt;
        }

        [StructLayoutAttribute(LayoutKind.Explicit)]
        public struct CREATE_DISK_UNION_MBR_GPT {
            [FieldOffset(0)]
            public CREATE_DISK_MBR Mbr;
            [FieldOffset(0)]
            public CREATE_DISK_GPT Gpt;
        }


        [StructLayoutAttribute(LayoutKind.Sequential)]
        public struct CREATE_DISK_MBR {
            public Int32 Signature;
        }

        [StructLayoutAttribute(LayoutKind.Sequential)]
        public struct CREATE_DISK_GPT {
            public Guid DiskId;
            public Int32 MaxPartitionCount;
        }


        [DllImportAttribute("kernel32.dll", EntryPoint = "CreateFileW", SetLastError = true)]
        public static extern SafeFileHandle CreateFile([MarshalAsAttribute(UnmanagedType.LPWStr)] string lpFileName, Int32 dwDesiredAccess, Int32 dwShareMode, IntPtr lpSecurityAttributes, Int32 dwCreationDisposition, Int32 dwFlagsAndAttributes, IntPtr hTemplateFile);

        [DllImportAttribute("kernel32.dll", EntryPoint = "DeviceIoControl", SetLastError = true)]
        [return: MarshalAsAttribute(UnmanagedType.Bool)]
        public static extern Boolean DeviceIoControl(SafeFileHandle hDevice, Int32 dwIoControlCode, ref CREATE_DISK lpInBuffer, int nInBufferSize, IntPtr lpOutBuffer, Int32 nOutBufferSize, ref Int32 lpBytesReturned, IntPtr lpOverlapped);

    }

}