Kopfbereich

Direkt zum Inhalt Direkt zur Navigation

Inhalt

CompRes

Welcome to the CompRes page! CompRes was written for Windows NT4/Windows 2000 and its purpose is to compare localized resources in one or two Win32 PE files for completeness, translation errors and other mistakes that can happen during localization and internationalization of a Win32 PE file (aka Win32 exe or dll). CompRes is intended to be used at the end of the build process and simply compares binaries loaded in two different languages. If a resource or part of it is missing in one of the languages, CompRes will raise an error and give you an explanation of the error on stdout (i.e. the command line).
     CompRes also tries to apply some heuristics in order to detect forgotten translations: Most developers develop in their own domestic language, say English, and copy over the English resources into a second language, say German, in the hope they will be translated some day before the final ship date into German. This often results in forgotten translations which in our example would result in a partially English UI for German users. This can be effectively prevented by using the "badwords file" feature of CompRes: You can supply to CompRes a file with single words, each separated by a line-break with words that should not appear in the translation. In our example you would supply a file with english words you know they absolutely don't exist in German (like "is", "can", "should", "may", "you", "he", "she", "it",...). If CompRes finds such a word it raises an error.
     CompRes also applies some heuristics as to the detection of badly formatted strings in stringtables: Consider the case where you do a sprintf call to a format string you have loaded from the string table (e.g. in MFC's CString::Format(..) method). If the order or number of format specification fields differ from one language version to another, your application will crash in one language version. Another possible crash is if the number of format specification fields in strings from stringtable resources differ and they are fed into the FormatMessage API (or MFC's CString::FormatMessage(..) method).

The Binary you can download here together with the sources is entirely UNICODE, hence CompRes will not run on the consumer versions of Windows. It is written as a console-mode application, therefore it is ideal for batch processing in your build scipts. CompRes is distributed under the terms and conditions of the GNU General Public License. In order to successfully compile it, you need the Microsoft Visual Studio 2005 Development Environment. Note that a ready-to-execute binary is contained in the download package.Fromversion 1.0.7.0 on, CompRes will only run on Windows 200 or higher.

 

Dowload CompRes version 1.0.7.0 built on 06/14/09

Downloads thus far:     145
Size:204049 bytes
MD5 Checksum:da185bbddfcf8a0f5a475d80c72938b8

 
Dowload CompRes version 1.0.2.0 built on 05/10/03

Downloads thus far:     687
Size:130233 bytes
MD5 Checksum:818eb8988714cecc3abbe9fb935d53d3

 
Dowload CompRes version 1.0.1.0 built on 05/04/03

Downloads thus far:     578
Size:122998 bytes
MD5 Checksum:7068ad310eae4eb2d2df7e01f47f4f74

 
Dowload CompRes version 1.0.0.0 built on 04/21/03

Downloads thus far:     593
Size:115987 bytes
MD5 Checksum:a2a02f46a27b883fe3d4fc3cabb2ea23


Which types of resources are covered by CompRes?

As of version 1.0.2.0, stringtables, menus, accelerators, dialog and dialogex resources are detected and compared by CompRes. Version 1.0.7.0 checks for the existence of al lother resource types. Sorry for Delphi users, unfortunately Borland defined their own proprietary resource format.

How does it work?

CompRes employs a concept that I borrowed from the windiff tool that ships with the NT Resource Kit or the Platform SDK: The concept of the "left file" and the "right file" which you have to supply both on the command line to CompRes. The background is that I assume that you conceptually consider your domestic language version as the left file and the localized version as the right file (although they can actually be the same files technically, if they contain both resource versions), but this is not really mandatory in a technical sense. However, the badwords file always looks in the resources of the *right* file for bad words.

There are two more mandatory command line parameters besides the two file names for left and right file. They denote the languages in which the left and the right file should be interpreted and they are

-l=language ID,sublanguage ID
and
-r=language ID,sublanguage ID

Both these two command line parameters expect a 'language ID' and a 'sublanguage ID', separated by a comma, as parameters. The language IDs and sublanguage IDs are nothing else than numbers (defined in the VC or PlatSDK header files, look up the numbers there or in the MSDN help). For instance, the parameters -l=9,1 -r=7,1 mean: "treat the left file as an English (sublanguage U.S. English) file and the right file as a German (sublanguage Germany) file. So if you have two DLLs, fooenu.dll (English resources) and foodeu.dll (German resources) you could compare them using the following command line:

compres -l=9,1 -r=7,1 fooenu.dll foodeu.dll

The order of the file names is: left file comes first, right file last (just as you would read them from left to right, all people with a different reading order may forgive me my cultural bias here...).

Other options are:

-e=ExceptionFile: Unicode text file that declares exceptions, i.e. resources that should be ignored during comparison.
-b=BadwordFile: Unicode text file that contains "bad words" that may not be in any text item of the right file
-d: Ignore differences in style bits of dialogs
-f: Ignore differences in font information of dialogs
-c: Ignore differences in style bits of dialogs items (controls)
-t: Ignore tab order differences in dialogs
-i: Check case-insensitive
-ie: Ignore a missing exception file (for batch processing)
-ib: Ignore a missing badwords file (for batch processing)


What the hell is the exception file?

With the help of the optional exception file you can instruct CompRes to ignore errors it would otherwise find. The exception file is a Unicode text file that consists out of separate lines, each containing a certain "exception". The first character in each line denotes the type of resource to ignore: 'S' stands for stringtable, 'D' for dialog , 'A' for accelerator and 'M' for menu resource. A '=' must appear next, followed by either the string identifier of the resource or the ordinal number of the resource. String identifiers must be surrounded by double-quotes. In the case of menus or dialogs you can specify a control ID or a menu ID to ignore if you don't want to ignore the whole menu or dialog. More than one stringtable entry can be ignored using commas and hyphens.

Examples:

M="HELLO" means "ignore the menu with the string ID "HELLO""
M=132 means "ignore the menu with the ordinal ID 132"
M="Hello":40001 means "ignore the menu item with the ID 40001 in the menu with the string ID "Hello""
M=122:1 means "ignore the menu item with the ID 1 in the menu with ordinal ID 122"
S=100-102,105,600,7122 means "ignore string IDs 100-102 and 105, 600, and 7122" (well, duh!?!)
A=40100,17122 means "ignore accelerator IDs 40100 and 17122"
D=100:1 means "ignore the control with ID 1 in the dialog with the ordinal ID 100"
D="MyDialog":122 means "ignore the control with ID 122 in the dialog with the string ID "MyDialog""

A word about the exit code of CompRes

If an error is detected, CompRes fails with a process exit code that is greater than zero and issues an error description to stdout. If everything is okay, CompRes terminates with a process exit code of zero and will issue nothing to stdout.

Change Log:

1.0.7.006/14/2009Added support for x64 modules and checks for all resource types.
1.0.2.005/10/2003 Fixed a bug in not proper displaying missing dialogs in the right file
Added accelerator comparison
Introduced the -ie and -ib command line options
Cleaned up some code
1.0.1.005/04/2003 Except for menus, all errors are now shown, not just the first one per category
Menu mnemonics are now checked for consistency between left and right file and for duplicates
1.0.0.004/21/2003 Initial public version


Why I wrote this cool program...

...well, simply because I had had to fix two very annoying bugs in the beginning of 2003 for my employer, and these were those kinds of bugs that I thought an automated tool should be able to find during the build process prior to shipping the whole product. Hence the idea for CompRes was born.

What was technically challenging in writing this program?

Nothing if it weren't for the fact that this is the first major program of mine that uses STL. I could again, for the 1.305.768th time, have written a program that makes use of all the fine things that come with MFC and the fine collection classes it has. This way, however I wouldn't have learned anything new for the 1.305.767th time so this time I decided that STL is the name of the game.
Last Updated on Sunday, 14 June 2009 16:21