Adding BLDLEVEL information to executablesWritten by Roman Stangl |
1. What is BLDLEVELThe BLDLEVEL (Build Level) is a signature that OS/2 modules (*.EXE and *.DLL files) contain, which allows one to easily identify the version and/or build date of that modules. OS/2 ships with a commandline utility named BLDLEVEL which allows you to display such signatures. For example, Figure 1.a shows the output when invoking the command BLDLEVEL \os2krnl against the kernel of a OS/2 WARP 4 installation. [C:\]BLDLEVEL \os2krnl Signature: @#IBM:9.23#@ IBM OS/2 Kernel Vendor: IBM Revision: 9.23 Description: IBM OS/2 KernelFigure 1.a The following REXX batch job, showing how you can add a Build Level to your own products, was taken from my Program Commander/2 (PC/2) program, which is available from my homepage, and it's Freeware! 2. Adding BLDLEVEL signatures2.1 Changes to a header fileIn order to support the inclusion of the Build Level into your products, just add the following macros to any header file, as for example shown in Figure 2.1.a for my PC/2 program. Just replace the macro's value with the data you want to be included into the signature. /* PC/2 BLDLEVEL information (in C source modules added via macro concatenation) for BuildLevel.cmd to generate BLDLEVEL information */ #define BLDLEVEL_VENDOR "(C) Roman Stangl (rstangl@vnet.ibm.com)" #define BLDLEVEL_VERSION "V1.99r (05,1997)" #define BLDLEVEL_INFO "PC/2 - Program Commander/2"Figure 2.1.a When running the command BLDLEVEL executable, where executable is any DLL or EXE of my PC/2 product, output similar to Figure 2.1.b will be displayed. Signature: @#(C) Roman Stangl (rstangl@vnet.ibm.com):V1.99r (05,1997) (PC2.exe )#@PC/2 - Program Commander/2 Vendor: (C) Roman Stangl (rstangl@vnet.ibm.com) Revision: V1.99r (05,1997) (PC2.exe) Description: PC/2 - Program Commander/2Figure 2.1.b [NOTE: the first line should be unbroken -- Ed] 2.2 The executable BuildLevel.cmdFigure 2.2.a (click) shows the REXX batch job BuildLevel.cmd which will modify your module definition files to add the Build Level signature created from the name of the module and the data read from the macros in the header file. Either save this document as ASCII text, or get BuildLevel.cmd from PC/2 via my homepage. The batch file is sufficiently commented, so it shouldn't be that difficult to see what it does. 2.3 Changes in the MakefileFigure 2.3.a shows how to add a step while linking an executable to include Build Level information into that executable. For DLL's the step is completely equivalent, add the same parameters are passed to BuildLevel.cmd, that is the module definition file and the header file containing the macros. The differences between an EXE and DLL are inside the module definition file, not the step to add Build Level signatures. BLDLEVEL = BuildLevel PC2.exe: $(ALL_OBJ) $(SRC)\PC2.def $(SRC)\PC2.l $(SRC)\PC2.res $(BLDLEVEL) $(SRC)\PC2.def $(SRC)\PC2.h $(LINK) @Source\PC2.l rc $(SRC)\PC2.res PC2.exeFigure 2.3.a When running BuildLevel.cmd against a module definition file, the Description statement will be modified according to the information in the header file. Additionally, the module type will be added (module definition files for executables must only contain a NAME statement, whereas for dynamic link libraries only a LIBRARY statement may be included, however the correct one must be present). Figure 2.3.b shows what a module definition file looks like after BuildLevel.cmd has been invoked against it, only the Description statement should have been touched, containing the signature in a form readable by the BLDLEVEL utility. NAME PC2 WINDOWAPI NEWFILES Description '$@#(C) Roman Stangl (rstangl@vnet.ibm.com):V1.99r (05,1997) (PC2.exe)#@PC/2 - Program Commander/2' DATA MULTIPLE STACKSIZE 96000 HEAPSIZE 128000 PROTMODEFigure 2.3.b [NOTE: the fourth line should be unbroken -- Ed] 2.4 Known limitationsAs the BLDLEVEL utility does not scan the complete file when looking for a signature but just near at the end of the file, it is possible that it doesn't find a signature even if you have added one for sure. The reason most likely is that you have created modules that contain debug information. As the debug information (at least partly) seems to be added to the module after the signature, the signature is too far away from the end of the file for BLDLEVEL to find it. Once you create modules without debugging information, BLDLEVEL should be able to find the signature again. 3. CreditsFrom the DDK (device driver kit) I found out that the BLDLEVEL signature can be added via the resource definition files (*.DEF files), developing the REXX batch job was no problem afterwards. You can reach me at rstangl@vnet.ibm.com |