OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Applications => Topic started by: Martin Iturbide on September 05, 2019, 11:14:33 pm

Title: About bldlevel
Post by: Martin Iturbide on September 05, 2019, 11:14:33 pm
Hi

I have some questions related to the bldlevel command.

1) Do you know some other tools that allows me to see/extract the bldlevel information from files beside bldlevel.exe?

2) Is there any way to include the bldlevel information to an executable that does not have it? Can it only be done while compiling the binary? or can it be applied to binary where you don't have the source code.

Regards

Title: Re: About bldlevel
Post by: Andreas Schnellbacher on September 06, 2019, 12:53:35 am
1) Do you know some other tools that allows me to see/extract the bldlevel information from files beside bldlevel.exe?
No. Most likely, because the usage is simple.

2) Is there any way to include the bldlevel information to an executable that does not have it? Can it only be done while compiling the binary? or can it be applied to binary where you don't have the source code.
Adding BLDLEVEL information to executables (http://www.edm2.com/0506/buildlevel.html)

The buildlevel is added to the .def file. AFAIK that requires a compiler.

The EDM/2 Meta Index (http://www.edm2.com/common/metaindex.html#Dev) is very helpful for developing.
Title: Re: About bldlevel
Post by: Dave Yeo on September 06, 2019, 12:59:14 am
As far as I know, it has to done when compiling the binary. I guess if a binary had a large description, the description could be replaced with a binary editor. Most exe's don't have a description, which is also added in the def file.
Actually, bldlevel does complain about not finding "driver EA's" so perhaps that is a way.
Title: Re: About bldlevel
Post by: Pete on September 06, 2019, 03:11:11 am
Hi Martin

If you have a copy of USbcfg installed then you should also have a copy of GETDESC.DLL which USBcfg uses to extract buildlevel information. However, this DLL is built to work with Pascal coding so would probably need a bit of reworking to work with "c" code.

The DLL was put together by Lars, of USB drivers fame, so you could ask him if he could build a "c" version.


Later Edit: The zip file Lars sent me contains source (cpp, def files) and makefile so you could probably modify it yourself. Let me know if you want a copy.


Regards

Pete
Title: Re: About bldlevel
Post by: André Heldoorn on September 06, 2019, 07:43:09 am
2) Is there any way to include the bldlevel information to an executable that does not have it?

HELLO.C:

Code: [Select]
#include <stdio.h>
int main(void)
{
printf("Hello, world!\n");
return 0;
}

TEST.CMD (requires ICC.EXE):

Code: [Select]
/* Not tested */
CALL CharOut 'APPEND.ME',"@#os2world.com:0.00#@##1##Fri Sep 06 07:08:09 2019 secret::::2::@@ One and one and one is tree"||D2C(0)
CALL CharOut 'APPEND.ME'
'@ICC HELLO.C'
'@LXLITE HELLO.EXE'
'@COPY HELLO.EXE /B + APPEND.ME /B Hello2.EXE'
'@CLS'
'@BLDLEVEL.EXE HELLO2.EXE'
'@HELLO2.EXE'
EXIT

If you are allowed to touch the EXE, believe it's important, and perhaps have an undo-script in case the compiled code is broken. Now, or e.g. after using RC.EXE to append an icon to a PM executable later.
Title: Re: About bldlevel
Post by: André Heldoorn on September 06, 2019, 08:10:30 am
Depending on the goal, maybe almost hidden text can be added to ZIP files (without an executable-shaped prefix) instead.

Code: [Select]
DIR > TEXT
ZIP TEXT1.ZIP TEXT
COPY TEXT /B + TEXT1.ZIP /B TEXT2.ZIP
CLS
UNZIP TEXT2.ZIP

To extract, stop reading when you've found the original header of the ZIP file (if the file TEXT doesn't contain the same characters).
Title: Re: About bldlevel
Post by: Lars on September 06, 2019, 09:16:19 am
Hi Martin

If you have a copy of USbcfg installed then you should also have a copy of GETDESC.DLL which USBcfg uses to extract buildlevel information. However, this DLL is built to work with Pascal coding so would probably need a bit of reworking to work with "c" code.

The DLL was put together by Lars, of USB drivers fame, so you could ask him if he could build a "c" version.


Later Edit: The zip file Lars sent me contains source (cpp, def files) and makefile so you could probably modify it yourself. Let me know if you want a copy.


Regards

Pete

Err,  I have to admit that in the end, GETDESC.DLL also uses a direct call to "bldlevel.exe" to extract the description info. The DLL just pipes the output into a memory buffer, extracts the description string and passes it back into the string buffer provided by the caller.

The reason for this: Initially (on my first attempt) I determined that the description would end up (for the compiler and linker toolset that I used) in the resident name table of the DLL (that's a place in the DLL file that serves a special purpose).  I was done and everything was fine. Unfortunately, another compiler and linker toolset would NOT place the description info into the resident name table but "somewhere else" into the file.
In short: there was no common way to determine this info and therefore I used bldlevel.exe which just scans the complete file for the description string template.
Title: Re: About bldlevel
Post by: Dave Yeo on September 06, 2019, 04:39:06 pm
Wonder about FileVerGetVersionStringFromFile() and the corresponding FileVerCreateModuleVersion() and  FileVerParseModuleVersion() which don't seem to be documented. Also seems to be CSFGETVERSIONSTRINGFROMFILE() in filever.dll.
Markexe has the option "SETVERSION      - Write 32 bit Module Version Field" as well. I also notice that exehdr outputs the bldlevel string.
Title: Re: About bldlevel
Post by: Martin Iturbide on September 06, 2019, 06:31:51 pm
hi.

I noticed that there may be some bldlevel clone.
Code: [Select]
[C:\os2]bldlevel bldlevel.exe
Build Level Display Facility Version 6.12.675 Sep 25 2001
(C) Copyright IBM Corporation 1993-2001
Signature:       @#IBM:14.082#@ Build level display facility
Vendor:          IBM
Revision:        14.82
File Version:    14.82
Description:     Build level display facility

On OSFree some time ago for my experiments I grabbed their bldlevel.exe.

Code: [Select]
[C:\HOME\DOWNLOADS]bldlevel
Build Level Display Facility Version 1.1
(C) Copyright 2003-2004 by Yuri Prokushev

     Use the BLDLEVEL command to search for a version string in a file.

     SYNTAX:  bldlevel [drive:][path]filename
         or   bldlevel /?
         or   bldlevel

     Where:
       drive           Specifies a drive letter for the path or filename,
                       for example: C:
       path            Specifies a path,
                       for example: \os2\dll\
       filename        Specifies the name for the file.

     /?              Displays this information.
     no parameter    Displays this information.

I guess there is an open source bldlevel clone by Yuri Prokushev, but I don't know exactly where is the source code in the OSfree repo.

Regards
Title: Re: About bldlevel
Post by: Gregg Young on September 06, 2019, 09:34:28 pm
As far as I know, it has to done when compiling the binary. I guess if a binary had a large description, the description could be replaced with a binary editor. Most exe's don't have a description, which is also added in the def file.
Actually, bldlevel does complain about not finding "driver EA's" so perhaps that is a way.

There is an EA that looks as if it would do this:
From the OS/2 programing guide
The .VERSION extended attribute (EA) contains the version number of the file format, as shown below.


    My_Application 1.0



The name of this EA consists of the string ".VERSION". The value of this EA contains the file object version number. This attribute can be ASCII or binary. Only the application that created the file object should modify the value of this EA. It can also be used to indicate an application or dynamic link library version number.
Title: Re: About bldlevel
Post by: Remy on September 07, 2019, 01:10:41 am
Hi

I have some questions related to the bldlevel command.

1) Do you know some other tools that allows me to see/extract the bldlevel information from files beside bldlevel.exe?

2) Is there any way to include the bldlevel information to an executable that does not have it? Can it only be done while compiling the binary? or can it be applied to binary where you don't have the source code.

Regards

Just use AddToFile.cmd from David Azarewicz
https://88watts.net/software.html

Regards
Rémy
Title: Re: About bldlevel
Post by: Dave Yeo on September 07, 2019, 01:14:29 am
Just use AddToFile.cmd from David Azarewicz
https://88watts.net/software.html

Regards
Rémy

That's to simplify adding the bldlevel info during building.
Title: Re: About bldlevel
Post by: Alex Taylor on September 07, 2019, 01:39:43 am
Veit Kannegieser's RXUNLOCK library has the RxBldLevel() function. 

Interestingly, it occasionally finds BLDLEVEL signatures in executables where IBM's BLDLEVEL doesn't.  I guess it uses a more tolerant search mechanism (TTBOMK it basically does a brute force search for the BLDLEVEL header through the whole file).

In theory, I think the BLDLEVEL signature can be anywhere in the file.  In some cases when using REXX2EXE, I've found simply doing a binary append of a prebuilt BLDLEVEL signature to the EXE after the fact has worked.  e.g.
Code: [Select]
        @rexx2exe blah.cmd blah_.exe /2 /k       
        @copy /b blah_.exe+blah.blv blah.exe
(where blah.blv is a text file containing the pre-formatted BLDLEVEL signature).

OTOH, this technique does not work for some other executable types, like VX-REXX apps.  It probably has something to do with how the executable wrapper works.  (I've never tried this trick with an already-linked object code a.k.a. 'native' EXE.)
Title: Re: About bldlevel
Post by: walking_x on September 14, 2019, 07:35:31 am
Be careful with various versions, because original bldlevel has a limit on searching string in a file.

Not sure about the exact limit, but looks like only first 500 or 512kb of file is scanned. Signature placed after this position is just "invisible".
Title: Re: About bldlevel
Post by: Lars on September 14, 2019, 09:16:00 am
Be careful with various versions, because original bldlevel has a limit on searching string in a file.

Not sure about the exact limit, but looks like only first 500 or 512kb of file is scanned. Signature placed after this position is just "invisible".
...which would explain why IBM linkers place this string into the resident name table ...
Title: Re: About bldlevel
Post by: Valery Sedletski on September 14, 2019, 10:47:43 am
2Martin: Build Level is just a special string embedded into the binary. Yuri Prokushev researched its format and wrote a doc about it:

http://osfree.org/doku/en:docs:os2:bld:index

Also, he reimplemented bldlevel.exe in REXX:

https://github.com/osfree-project/osfree/blob/master/OS2/CMD/bldlevel/bldlevel.rexx

The buildlevel.exe file you mentioned above is converted from bldlevel.rexx via RexxWrapper (http://rexxwrapper.sourceforge.net/, written by Mark Hessling)

BTW, you can embed the build level string in any file. For example, QSINIT is a plain COM file, but its "os2ldr" contains the build level information. It's just a special string embedded into the binary. AFAIK, in LX/NE executables, it is contained in entry table, if I'm not wrong.
Title: Re: About bldlevel
Post by: Pete on September 14, 2019, 03:13:39 pm
Hi Valery

Just had a play with bldlevel.rexx - copied the file to bldlvl.cmd and ran it in an os2 window.

Not very encouraging as all it reports is:-

SYS0317: The system cannot find message  xxxx
in message file OSO001.MSG.

where xxxx is a choice of 8069, 8070, 8073,  8075.

Looks like either I am not using the rexx file correctly or it is looking for non-existent messages in OSO001.MSG.


Regards

Pete

Title: Re: About bldlevel
Post by: Martin Iturbide on September 14, 2019, 06:55:46 pm
Hi Pete

I have a copy of OSO001.MSG right here (https://archive.org/download/Readme_20160422/cwarp00034-Files.zip/Warp%2FMSG%2FOSO001.MSG).

regards
Title: Re: About bldlevel
Post by: Pete on September 14, 2019, 08:12:28 pm
Hi Martin

As the .msg file exists it seems that the messages bldlevel.rexx wants to display do not exist in the .msg file.


Regards

Pete
Title: Re: About bldlevel
Post by: Valery Sedletski on September 15, 2019, 04:49:29 am
2Pete: It seems, bldlevel.rexx requires osFree version of oso001.msg. It is an extension of standard OS/2 version.
You can download oso001.msg, oso001h.msg and oso001.txt (message file source) from ftp://osfree.org/upload/.

PS: If you don't want to touch your oso001.msg, you can modify the script, so that it will bear messages in its body,
instead of a message file.
Title: Re: About bldlevel
Post by: Dave Yeo on September 15, 2019, 06:52:15 am
Just use AddToFile.cmd from David Azarewicz
https://88watts.net/software.html

Regards
Rémy

That's to simplify adding the bldlevel info during building.

It does make things simple though. Adding bldlevel to the screensaver modules example,
makefile changes,
Code: [Select]
diff --git a/Modules/AnTVSim/makefile b/Modules/AnTVSim/makefile
index 0516f49..000ad0b 100644
--- a/Modules/AnTVSim/makefile
+++ b/Modules/AnTVSim/makefile
@@ -31,6 +31,8 @@ dllflags = -bd
 cflags = $(debugflags) -bm -bt=OS2 -6s -fpi87 -fp6 -sg -otexanr -wx

 .before
+    rm -f description.lnk
+    ..\..\AddToFile.cmd description.lnk,option description,BLDLEVEL,DSS,1.80,Analogue TV Simulator - ScreenSaver module,24
     set include=$(%os2tk)\h;$(%include);..\..

 .extensions:
@@ -44,7 +46,7 @@ $(dllname).dll: $(object_files)
     wcc386 $[* $(dllflags) $(cflags)

 .obj.dll : .AUTODEPEND
-    wlink @$(dllname)
+    wlink @$(dllname) @description
 !ifdef has_resource_file
     rc $(rcname) $(dllname).dll
 !endif
output
Code: [Select]
Build Level Display Facility Version 6.12.675 Sep 25 2001
(C) Copyright IBM Corporation 1993-2001
Signature:       @#DSS:1.80#@##1## 14 Sep 2019 21:28:45     ARCAOS-C02::::::24@@
Analogue TV Simulator - ScreenSaver module
Vendor:          DSS
Revision:        1.80
Date/Time:       14 Sep 2019 21:28:45
Build Machine:   ARCAOS-C02
FixPak Version:  24
File Version:    1.80
Description:     Analogue TV Simulator - ScreenSaver module

Never even bothered to remove the OPTION DESCRIPTION line from AnTVSim.lnk (no def file)
Do have to think about the best vendor string and wonder about ASD.