Windows Hacks: ‘The Escape’

What’s the keyboard shortcut to close an application? Yes, its Alt+F4. Its not an easy shortcut to hit. I always thought that the Escape key was a much better shortcut to close applications. Once I convinced myself that it was the ‘One-True-Way’TM, I decided to impose that shortcut on the applications that I use. Metapad and Irfan View already had that option – the other application I had my sight on was the Windows Explorer(explorer.exe). This tutorial will teach you how to add the Escape key as a shortcut to close Windows Explorer.

By the way, this is a post about my Windows days – this is much easier to do in Linux – but thats another story.

Stuff you need to know before continuing

This is a fairly advanced hack – its not for everyone. It involves editing core Windows files – which might be dangerous if done incorrectly. It also involves a bit of reverse engineering which might be considered illegal by some lawyers. So continue only if you are sure.

This hack involes modifying Windows core files – which might some problems if done incorrectly. I cannot be held accountable for the outcome – be it good or bad. Actually, scratch that. Ff the result was a success, feel free to hold me accountable.

If you decide to continue, I would say that the result is worth the risk – you will learn a method that will let you add custom shortcuts to application that don’t provide you with the source code. And it gives you a really cool feeling if you actually manage to pull the hack successfully.

I originally made this hack for Windows 98 – but it works on Windows XP as well. I have not tested it in Vista – I would be very grateful if anyone lets me know if it works in Vista or not.

Stuff you are going to need…

  • Get Resource Hacker – you will be editing core windows DLLs with this tool.
  • FreeDOS or Linux Live CD/DVD – you have to save the file to the original location when windows is not running. You must also know how to work in the Live OS – be it DOS or Linux.
  • Courage – As I said before, this hack is not for the faint of heart.

Lets Begin

Install Resource Hacker.

Make a backup of ‘C:\WINDOWS\system32\browselc.dll‘ and ‘C:\WINDOWS\system32\Restore\filelist.xml‘ before doing anything – just in case.

Go to C:\WINDOWS\system32

Make sure that you are seeing all the files there…
Tools -> Folder Options -> ‘View’ Tab -> Hidden Files and folders -> Show hidden files and folders(must be checked)

Refresh the folder and then find the file ‘browselc.dll

Make a copy of that file in some other folder – say C:/Hacks/

Now open Resource Hacker

Open the DLL file in Resource Hacker…
File -> Open -> C:/Hacks/browselc.dll

In the ‘Menu’ find look through all sections to find a menu with the ‘File->Close’ item.

It should be at Menu -> 263 -> 1033

Find the string
MENUITEM "&Close", 40993, MFT_STRING, MFS_ENABLED

In this the number 40993 is what we want. Write the number down somewhere. Think of it as the function that gets executed when that menu item is clicked. You can create a shortcut for any menu item by find out this number for that menu item.

Now we have to add a shortcut for this ‘function’ – go to the ‘Accelerators’ section – ‘Accelerators -> 256 -> 1033’. We found the menu at Menu -> 263 -> 1033 – so the Shortcut should be at Accelerators -> 256 -> 1033. See the pattern?

Find the line
VK_ESCAPE, 41498, NOINVERT, VIRTKEY

Modify it to read
VK_ESCAPE, 40993, NOINVERT, VIRTKEY

I have changed the number to 40993 – the call for the ‘Close’ action.

Now hit the ‘Compile Script’ button on the top. If you have done it correctly, you should not get any errors.

Save the new version using File -> Save

Congratulations, you have successfully created a new ‘Accelerator'(shortcut). Now the hard part – putting the file back into ‘C:\WINDOWS\system32’.

If you are on Windows XP, it monitors for changed files – so if we put the changed DLL file back, it will be reverted to the original file on the next boot. To get around it, follow the steps below…

Open up the file C:\WINDOWS\system32\Restore\filelist.xml in a editor like notepad

Find these lines…

<Exclude>
	<REC>%windir%\system.ini</REC>
	<REC>%windir%\tasks\desktop.ini</REC>
	<REC>%windir%\win.ini</REC>
	<REC>*:\AUTOEXEC.BAT</REC>
	<REC>*:\CONFIG.MSI</REC>
	<REC>*:\CONFIG.SYS</REC>
</Exclude>

Add the line…
<REC>%windir%\system32\browselc.dll</REC>
after the line <REC>*:\CONFIG.SYS</REC>

After doing this you may not be able to save the file. Curse windows for a bit and continue.

Open up a DOS Shell and enter these commands in order…

attrib -S -H C:\WINDOWS\system32\Restore\filelist.xml
attrib -R C:\WINDOWS\system32\Restore\filelist.xml

Now you will be able to save this file – do so.

Replace Original browselc.dll with Modified Version

The next thing to do is replace the original browselc.dll file with our hacked version. This cannot be done when windows is running. It must be done when windows is down – that’s where FreeDOS CD or Linux Live CDs comes in.

FreeDOS

If you have FreeDOS CD, boot into that as the LiveCD(I hope you know how to do this – basically, you put in the CD, reboot the system, change the setting in the BIOS to make the CD the primary boot device and boot into the CD. Needless to say, you need a bootable CD for this to work.)

After you have booted into DOS, execute the command…
copy C:\Hacks\browselc.dll C:\Windows\system32\browselc.dll

Now remove the FreeDOS CD, reboot back into windows.

Linux

If you have a live Linux CD, pop it in and boot into that. Now mount the partition that’s the C partition in windows(usually sda1 or hda1). Then all you have to do is copy the modified DLL file from the ‘Hacks’ folder to ‘Windows\system32\’ folder in that partition using the File manager for that distribution.

Once that is done, you reboot into windows.

All Done

Finally, its all over. All you have to do is open up a folder – and press the Escape key. If all went well, the explorer application will be closed.

This is a rather complicated way to do a rather simple thing – you set custom shortcuts easily using tools like AutoHotKey and setting up macros. But by doing it my way, you will learn a method to peek into exe and dll files. And if you are a programmer like me – it will give you hours of entertainment. I have actually found left over stuff from Windows 3.1 in Windows XP DLLs – but that’s a post for another time.

8 Comments

  1. Wow! That’s cool indeed!

    I felt from the start that I could care less about closing a window with ‘Esc’ but kept reading anyway because this is so well written. Yet at one point I realised that my whole thinking had been wrong – this isn’t about closing a window with ‘Esc’ at all! “Hours of entertainment”: These 3 words are the key. Only lesser minds will care about something being useful. It’s immeasurably better to be entertained in the process of understanding!

  2. Too much effort. You don’t need anything like Linux livecd to replace a file locked by explorer.exe. Just run Resource Hacker when you have killed explorer.exe or had it shut down itself (goto Shutdown computer dialog box and while holding Ctrl+Shift+Alt click Cancel and explorer.exe closes itself gracefully). Then carry on with the relevant stuff in Resource Hacker as described above.

Comments are closed.