Saturday, December 1, 2007

Become A Resource Hacker

Did you know there are goodies embedded within EXEs and DLLs?
Here’s how to access and play around with them
Resource Hacker(www.angusj.com/resourcehacker) is a freeware utility that allows you to view the cursors, icons, bitmaps, GIF, AVI, and JPEGs embedded within files.

These are referred to as resources. For example, an EXE file will have an icon, version
number, and more embedded within it. You’ll also come across embedded WAV and MIDI resources. Essentially, using the tool, you can view, modify, add, delete, and extract resources in 32-bit Windows executables, DLLs, screensaver (.scr) files, and more. It works on almost all 32-bit versions of Windows, including XP and 98.

In addition to the above, menus and dialogs can be viewed as they would appear in a running application, so you can view, in real-time, the effects of the modifications you make to the file.
Resources can be saved as image files; as script files (.rc); as binary resource files (*.res); or as binary files (.bin). The program can also modify, add and delete resources.
You can download Resource Hacker from www.angusj.com/resourcehacker. It is no longer being updated, however. Extract the contents of the .zip file to a folder of your choice, and you’re ready to run the program. The Interface After you launch Resource Hacker and open a file such as a DLL or EXE, you will be presented with a window that has a blank space on the right and a list of resources on the left, which appear similar to directories in Windows Explorer. The name of the directories (which are the listed resources) explain what resource of the source file
they contain. For example, “Icon” contains icons, “Cursor” contains cursor files, and so on. It’s that simple!

In order to view an embedded resource, just double-click on the directory to expand it and click on the name of
the resource. Each resource consists of three parts.
Resource Type: This indicates whether the resource is a cursor, bitmap, menu, or whatever.
Resource Name: Each resource has a unique name in a file.
Resource Language: This is the code number of the language used in the file.
Modifying Resources Change an icon, cursor or bitmap As already stated, you can change the icon of an EXE using Resource Hacker. Let’s replace the icon of WinRAR.exe
with that of utorrent.exe or µTorrent, as in the screenshot. Open WinRAR.exe in Resource Hacker and expand the
Icon resource folder. Expand the 2 folder, right-click on 1029, and select “Replace Resource…” Click on “Open file
with new icon” and select utorrent.exe. Now click Replace. Save the file, and when you open it, you’ll see that
the icon has changed!
Edit menus, strings, and dialog boxes Select the desired resource (such as String Table > 3858 > 1033). Make your changes by typing in the new text you
wish to include, and click Compile Script. The script will be compiled; an error message will come up if something
goes wrong, so that you can rectify the problem.
Add new resources Click on Action > Add a new Resource. Click the “Open file with new resource” button. Select the resource and
click Open. Specify the resource Type, Name and Language, and click on the Add Resource button.
Add new menu items New menu items can be added to an application. Go to the desired menu (for example, Menu > 215 > 1033). Add a line
anywhere inside POPUP “{Menu Name}” in the following format: MENUITEM “your_string”, 12345, MFT_STRING, MFS_GRAYED MFS_DEFAULT Here, “your_string” is the text that will be displayed on the screen, “12345” is the unique identifier which
defines the function associated with the menu item (you might need to use trial and error to find it), MFT_STRING
means it is a menu item with text, MFS_GRAYED means the menu item is disabled, and MFS_ENABLED means it is
enabled. MFS_DEFAULT sets the menu item text to bold. Let’s modify the menus in WinRAR—add a menu called “Test”. Open WinRAR.exe using Resource Hacker. In the left of
the window, click on Menu > MAIN_MENU > 1049. In the right-hand side, scroll down to the bottom of the window.
Before the last closed curly brace, add the following lines: POPUP “&Test” { MENUITEM “&This is a test”,190 } Click “Compile Script” and save the file. On opening WinRAR, you will see an extra menu called “Test” after
“Help”, and when you click on that, you will see a menu item: “This is a test”. Use the Ampersand (&) before the
letter you want to set as the item’s accelerator. For example, M&enu will make the menu accessible using [Alt] +
[E].

0 comments

 
© 2011 Technotronical Matrix | 2012 Templates
Designed by Blog Thiết Kế
Back to top