The most effective utility for editing resources would be one that works equally well with programs written in any language. Personally, I prefer the Restorator utility, which can be downloaded from the following site: Restorator home page. Restorator allows you to edit boot loader files and has significantly more to offer in the way of capabilities than any other program I have had the pleasure to use. As a result, this is the program we will consider here.
Before proceeding to the following material, I recommend that you install this program on your computer so that it will always be handy, allowing your to check into the described operations as they are covered. This book is not a help file for this program, so we will only consider those basic elements that are relevant to breaking programs and providing them with a more pleasant appearance.
The main window has three parts:
Let's open a program to use as a guinea pig to help us learn how to alter resources. The dialer.exe program, which is installed with Windows, will fit this purpose as well as any other. This file can be found in the Windows folder, so, if your operating system is installed on the C: drive, the path to the file will be the following: c:\windows\dialer.exe.
To open the file in Restorator, select the File/Open menu sequence. You will see the standard file open dialog window. Navigate to the dialer.exe file and open it. The program will load the resource names into the Resource tree window. To open the entire resource tree, select the file name in the Resource Tree window (it should be at the root of the resource tree) and press the asterisk key on the number keypad. The result should be that as shown in the next figure.
I picked this program with a purpose, as it contains practically every type of resource, so it is a handy example in learning how they may be edited.
After opening the Menu section in the resource tree, you will see only one item, numbered 118. Select this and the menu's source code will be shown in the Resource Viewer window. To edit the source code, select the Viewer/Edit mode menu sequence. This will display the resource as source code in the Resource Viewer window and cause a window for previewing the editing changes to appear.
The listing below shows the complete source text of the Dialer menu coded in resource instructions. These instructions are easy to understand and we will examine their function here. After this, you should have no problems with creating any kind of menu of your own.
118 MENU
{
POPUP "&File"
{
MENUITEM "E&xit", 1000
}
POPUP "&Edit"
{
MENUITEM "Cu&t\tCtrl+X", 1001
MENUITEM "&Copy\tCtrl+C", 1002
MENUITEM "&Paste\tCtrl+V", 1003
MENUITEM "&Delete\tDel", 1004
MENUITEM SEPARATOR
MENUITEM "&Speed Dial...", 1005
}
POPUP "&Tools"
{
MENUITEM "&Connect Using...", 1006
MENUITEM "&Dialing Properties...", 1008
}
POPUP "&Help"
{
MENUITEM "&Help Topics", 1010
MENUITEM "&What's This?", 1015
MENUITEM SEPARATOR
MENUITEM "&About Phone Dialer", 1011
}
}
Prior to examining the source code in the listing, you need to know a few things about comments. Comments are optional text that has no effect on the resource, but allows you to add your own explanations or notes. When the resource compiler encounters a double slash, it treats the text that follows in that line as a comment. Consequently, I will insert explanations to the code under consideration and you can use comments to mark the changes that you make.
Menu source code begins with a number, which defines the name of the resource. It is followed by the keyword MENU. In this case, the resource's name is 118, so the menu source code starts with this number. The beginning and end of the menu are delimited by curly brackets {}:
118 MENU
{
// Menu description goes in here
}
If you have some experience in programming in C/C++, this description will be familiar to you.
Popup menus and their elements are defined between the curly brackets delimiting the main menu. The definition of a popup menu begins with the keyword POPUP, followed by the name, in double quotes, that will be shown in the main menu. The ampersand (&) character can be placed anywhere in a menu's name. The letter following this character will be the menu's hotkey; that is, pressing this letter along with the
The popup menu File can be defined like follows:
POPUP "&File"
{
}
A popup menu definition is again followed by curly brackets, in which elements of the popup menu are defined. The definition of the elements is done as follows:
MENUITEM "Name", Code
The same rules apply to the names of the popup menu elements as to the menu itself , i.e., the use of the ampersand character to designate hotkeys. Moreover, hotkeys can be designated by writing their combination after the \t character sequence; for example, \tCtrl+X designates the combination of the
A pull-down menu item code is an identifier used by the program to determine the requested action and respond to it properly. Consequently, changing menu items' names will not affect the operation of the program. Changing their code, however, will.
Resource editors can be used to switch the places of identifiers. For example, the following are some items in the Edit menu and their correct codes:
MENUITEM "Cu&t\tCtrl+X", 1001 MENUITEM "&Copy\tCtrl+C", 1002 MENUITEM "&Paste\tCtrl+V", 1003
Suppose that you change the codes as follows:
MENUITEM "Cu&t\tCtrl+X", 1002 MENUITEM "&Copy\tCtrl+C", 1003 MENUITEM "&Paste\tCtrl+V", 1001
Now, when you try to execute the Cut command, data will be copied onto the clipboard. The Paste operation will be performed when you attempt to copy, while cutting will be the result of trying to paste. This type of editing, of course, belongs to the practical joke category, which is another story altogether.
All you can do is change the places of menu item code. Changing the codes themselves is useless, as nothing will work.
A separator between menu items is inserted with the following code:
MENUITEM SEPARATOR
The modified menu can be previewed in the preview window that opened when you entered the edit mode. To see the changes that have been made, however, you must update the information by pressing the
Can you use BBCode? You can use [quote] to quote, [b] and [i] for text decoration. You can't use any other codes.