ResEdit doesn't work with the Windows SDK 8.0 and above (use 7.1 or below)

ResEdit is a nice resource file editor for Windows programs. Regrettably, it has some issues with the latest versions of the Windows SDK (8.0 and 8.1) – it’s possible to create a resource script (.rc) file, but you won’t be able to open it again later. Even if %PROGRAMFILES(x86)%Windows Kits8.1Include is set as include path, symbols like VOS_NT_WINDOWS32 (defined in verrsrc.h) won’t be resolved and you’ll get ‘undeclared identifier’ errors if your resource script contains them.

Use an earlier version of the Windows SDK (like 7.1) and ResEdit has no problem reading the header files.

For reference, I’m successfully using the following include paths:
%PROGRAMFILES(x86)%Microsoft SDKsWindowsv7.1AInclude
%PROGRAMFILES(x86)%Microsoft Visual Studio 12.0VCinclude

It’s not just me experiencing this issue:
ResEdit started to be Annoying‘ (January 2012)
Resedit Problem‘ (June 2014)

Html.AntiForgeryToken() sets an X-Frame-Options header with the value 'SAMEORIGIN'

I recently migrated a project from ASP.NET MVC 4 to MVC 5 and the process went quite smoothly, except that all of a sudden my webpages were being returned with the X-Frame-Options header set with the value ‘SAMEORIGIN‘. This is actually a reasonable default as it helps mitigate the risk of ClickJacking. The website in question, however, is designed to run in an iFrame, and this header immediately caused issues.

After a fruitless search of all my code in Visual Studio for ‘X-Frame-Options’ and ‘SAMEORIGIN’, I decided to try Windows Grep as a last resort, and it found that ‘SAMEORIGIN’ was present in System.Web.WebPages.dll. Thanks to Microsoft making ASP.NET MVC open source, I was able to find the relevant code quite easily on GitHub; it turns out that the AntiForgeryWorker class adds the header when you call Html.AntiForgeryToken() as of August this year. Even better, there’s an easy way to prevent this behaviour: set the static property AntiForgeryConfig.SuppressXFrameOptionsHeader to true (I’ve done this in my Application_Start() method). MSDN doesn’t didn’t even document this property yet, so I’m lucky to have found it. Two other bloggers have written about this in English and Japanese.

Enabling the compatibility property sheet for (almost) all programs in Windows 8/8.1

Windows 8 and 8.1 hide the compatibility property sheet for certain programs (namely programs included with Windows, like Notepad, and those on a whitelist of programs known to run correctly on Windows 8/8.1 – defined in %WinDir%apppatchpcamain.sdb). In some cases, one can still run the ‘troubleshoot compatibility’ wizard by right-clicking on the file, which just presents compatibility settings in a novice-friendly, poweruser-unfriendly way.

The compatibility property sheet and context menu are defined in acppage.dll. By patching this DLL, we can enable the compatibility property sheet for (almost) all programs, including programs like Notepad and those whitelisted in pcamain.sdb.

Patching Windows system DLL files is probably a bad idea, and I take no responsibility if your computer explodes after you take the following steps.

I’ll write a tool to automate this process at some point, but for now, here are the manual steps if you’re feeling adventurous:

  1. Make a backup of acppage.dll from %WinDir%System32
  2. Take ownership of acppage.dll in %WinDir%System32:
  3. Grant administrator users full control over acppage.dll:
  4. Using your favourite hex editor (I like XVI32), overwrite the two bytes at the relevant address to 0x31 0xC0:

    • Windows 8.1 64-bit: 5A92 (the original bytes should be 0x8B 0xC7)
    • Windows 8.1 32-bit: 4B26 (the original bytes should be 0x8B 0xC6)
    • Windows 8 64-bit: 4DBB (the original bytes should be 0x8B 0xC3)
    • Windows 8 32-bit: 3D44 (the original bytes should be 0x8B 0xC6)

    Warning: If the existing bytes don’t match with what I’ve written above, don’t overwrite them! The addresses change with patches to Windows. The above addresses were current as of 2013-09-04.

  5. Restart explorer.exe

Voilà – the compatibility property sheet will appear for most programs now (I’ve noticed that it doesn’t show up for File Explorer):

Screenshot of Notepad.exe and the Compatibility property sheet

How does this actually work?

These two bytes are in the CLayerUIPropPage::Initialize function – this basically does a bunch of checks to determine whether the property sheet should be displayed or not. The original code (0x8B …) sets the return value (the EAX register) to the result of these checks – a non-zero result means the sheet won’t be displayed. We modify the function to always return 0 by using the instruction xor eax, eax (0x31 0xC0).

Windows 8.1 Impressions

Windows 8.1 is done, though Microsoft is apparently worried enough about driver and application support that not even loyal MSDN and TechNet subscribers will get it until October 17 this year. To no-one’s surprise, the RTM ISOs were promptly leaked, which leaves us in the odd situation where the only way to test your programs against the latest version of Windows is to download disc images from shady websites.

My impressions of Windows 8.1 don’t differ much from what I wrote earlier this year when it was still ‘Windows Blue’: no-one who hates Windows 8 is going to be swayed by Windows 8.1, but if you love Windows 8, you’ll probably love Windows 8.1.

For all that’s been written about the return of the Start Button, there are very few concessions towards desktop users in Windows 8.1. Including ‘boot to desktop’ and ‘use desktop background on Start Screen’ as options makes the overall user experience slightly less jarring, but it’s really nothing to get excited about. I highly recommend StartIsBack to restore the Windows Vista/7-style Start Menu. Start Menu programs abound (what does that tell you?), but StartIsBack really feels like it’s part of Windows, not a third-party program.

The biggest change that Windows 8.1 brings to the desktop is improved high DPI support – Windows now supports per-monitor DPI, and no longer requires users to log off in order to change their DPI settings. I’m sceptical about how many applications will bother supporting this functionality, but it’s a nice feature to have.

Given that Windows 8.1 doesn’t offer much to desktop users like me, I might as well write about annoyances introduced with this version.

New annoyances

  • Microsoft has made it hard to create a local account when installing Windows (as opposed to using a Microsoft account to sign in). Windows 8 strongly encouraged you to use a Microsoft account, but Windows 8.1 is worse – the only methods I’ve found to avoid this are to disable network connections or to type in a bogus email address – only then will Windows offer to create a local user account.
  • SkyDrive is now integrated with Windows, but apparently only if you sign in with a Microsoft account (see above). I guess I won’t be using the desktop SkyDrive client anymore.
  • Libraries are hidden by default, and even when they’re turned on, the navigation pane in File Explorer is polluted with shortcuts to the ‘Desktop’, ‘Documents’, ‘Downloads’, ‘Music’, ‘Pictures’ and ‘Videos’ folders (not libraries), as is the main ‘This PC’ (formerly ‘Computer’ – who decided changing that was a good idea?).
  • Unlike some, I don’t hate the default background images (though I question the choice of the orange default image), but the JPEG compression is horrendous. I’m shocked that Microsoft included such low-quality images in Windows.

None of these are show-stoppers, but coupled with the fact that Windows 8.1 offers almost nothing new for desktop users, it’s hard to get excited about this update.

Migrating from Opera to Chrome

I’ve used Opera as my primary web browser since the year 2005. It’s never looked quite at home on Windows and its tiny market share means it’s lucky to ever be included on a website’s list of ‘supported browsers’, but still I preferred it over Internet Explorer, Firefox and later Chrome. I valued the user interface for nearly always being extremely responsive (much more so than the other browsers, in my experience), even when I had more than 100 tabs open, which somehow manages to happen quite often. Features like mouse gestures and an RSS reader are available out of the box – other browsers require a lot of extensions before they come close to reaching the level of functionality that’s built-in to Opera.

Opera (the company) announced in February this year that Opera (the browser) would be moving from the Presto engine to the Google Chromium implementation of WebKit (it was later revealed that in fact both Google and Opera will be using a new engine called ‘Blink’, forked from WebKit). An early version of Opera 15, the first version to be built around Chromium, was released this week, so of course I was keen to try it out. Regrettably, most of what I loved about Opera is gone – no RSS, no customisable mouse gestures, basically no UI customisation, no sidebar (handy for RSS, downloads and window/tab management), no separate search box, no MDI (multiple document interface), no private tabs (rather than windows) and probably other features that I’ve forgotten. On one hand, I’m disappointed that my favourite browser has changed for the worse. On the other hand, this gives me a reason to switch to a better-supported browser.

I’ve never really cared too much for Firefox, so Google Chrome seemed the obvious choice. Benchmarks would suggest Firefox’s engine is getting ever faster, but the UI has never been quite responsive enough for my liking. This is quite possibly unfair prejudice on my part.

Chrome is certainly not perfect, buy with the help of extensions, it’s a pretty good replacement for Opera. That said, I don’t see any particular advantages over Opera, other than perhaps the benefit of knowing that your browser is being developed by a tech giant and will almost certainly be supported by nearly every website.

Here’s what I don’t like, and the steps I’ve taken to mitigate each issue:

  1. No mouse gesture support. The Smooth Gestures extension is decent, and it’s certainly much easier to setup gestures than it is in the old Opera settings dialog. You can tell it’s not a native part of the browser, though, as gestures only work when drawn within a page (not on the tab bar or address bar, for example), and they don’t work at all on the new tab page, settings page or Chrome Web Store pages.
  2. No MRU tab ordering. I’m really missing Opera’s most recently used ordering of tabs (the same ordering that Windows uses for windows), and I’m quite shocked that in 2013 Chrome doesn’t have an option to enable this. Partially resolved by the ‘Tab to the next’ extension, but it’s far from ideal. The (Shift+)Ctrl+Tab shortcut is almost useless.
  3. No RSS reader. I’ve started using Feedly, since Google Reader is apparently about to be shut down. It seems pretty good – I just need to get used to the keyboard shortcuts.
  4. No support for POST searches. I find this one a bit baffling – there’s no support for creating a search shortcut that requires the POST verb (I personally need this for WWWJDIC). I happened to have already written a simple script to ‘translate’ GET requests to POST requests (the usage being something like post.php?url=encodedurl&args=encodedpostargs). My POST searches go via my server now, but it’s a reasonable compromise.

Surprisingly – given its multi-process architecture – Chrome doesn’t seem to handle lots of tabs being open at once as well as Opera did, but it’s not terrible. Flash seems to be crashing more in Chrome, which doesn’t make a lot of sense to me, as I thought it was the same plugin. Tabs take up more horizontal width than seems necessary, and I don’t really like that they go to the very top of the window when maximised (makes it difficult to grab the window border).

I’ll give Opera 15 another shot when it is out of beta – by then it might be closer in functionality to Opera 12.15 – but for now Chrome doesn’t seem like a bad alternative, even with its various flaws.

Short: Google Analytics doesn't support Windows Phone apps – pretend your app is a website, instead

Using Google Analytics in a Windows Phone 7+ app is really simple. There’s a small hurdle, however, in that Google Analytics doesn’t support Windows Phone, and if your property is configured as an ‘App’, you won’t be able to track any data. The solution is to configure your property as a ‘Web Site’ when you create it. You’ll miss out on niceties like screen tracking, but it’s possible to use events to record similar data.

Short: The Windows Phone Toolkit ContextMenu control's Foreground property does nothing

While the ContextMenu control in the Windows Phone Toolkit has a Foreground property, setting it has no effect, as it’s not used in the default control template (unlike the Background and BorderBrush properties, which work as expected). To change the text colour in a ContextMenu, set the Foreground property of MenuItems individually.

Keiki Usage Meter Version 3.2.1 Released

Tonight I released Keiki Usage Meter Version 3.2.1. This release was prompted by Optus changing some things on their end that stopped the Optus Broadband (Legacy) plugin from working. There are some changes to the way tooltips, buttons, group boxes, combo boxes, radio buttons and check boxes are rendered, but nothing particularly noteworthy.

I also published some (sparse) documentation on developing plugins. I’d be happy to publish third-party plugins on my website at some stage.

Warning: Simple Storage Spaces in Windows 8 can’t be dismantled

A new feature in Windows 8 is ‘storage spaces’, a kind of software RAID, similar to the drive extender functionality found in the defunct Windows Home Server. Unlike Windows Home Server, however, Windows 8 provides no means of removing hard drives from simple (no resiliency) storage spaces, even when there’s adequate free space. Deleting the storage space will remove all your data, so you’ll need to copy everything to other storage devices first. If all your hard drives are being used by the storage space, this can be tricky.

My home server has recently decided to reset itself at random intervals (no errors to speak of), possibly due to an incompatibility between some piece of hardware and Windows 8 (or possibly just a failing piece of hardware). I’d like to try re-installing Windows 8 to see if that helps, and try Windows 7 if it doesn’t, but first I need to find a way to transfer about 8TB of data from my storage space.

Moral of the story: don’t use simple storage spaces if you ever plan to dismantle them.

Theme Colours in Windows ‘Blue’

As I noted in my earlier post, the method for selecting theme (‘accent’) colours in Windows ‘Blue’ build 9364 has changed from Windows 8 RTM. I’m not going to bother looking too closely at the updates to the functions in UxTheme.dll this early in the development process, but I did notice two new registry values in the key HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerAccent: ‘AccentColor’ and ‘StartColor’. These are DWORD values that store the accent colour and background colour, respectively. The format is 0xAABBGGRR. The old ‘ColorSet_Version3’ value from Windows 8 is gone for obvious reasons. ‘AccentId_v8.00’ from Windows 8 is now ‘MotionAccentId_v1.00’, but it seems to serve the same purpose – indicating which background image is selected.