[File] [PATCH] of Magdir/images for OS/2 pointer "PT" variant (*.ptr)

Jörg Jenderek joerg.jen.der.ek at gmx.net
Sat Jun 22 18:17:50 UTC 2019


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hello,
some days ago i handle some OS/2 color pointer with file name
extension "ptr". When i run file command version 5.37 all of these
examples are only described as "data".

So i add/change lines in Magdir/images. Some Information is found on
fileformats.archiveteam.org website. So i add comment line like
# URL:	http://fileformats.archiveteam.org/wiki/OS/2_Pointer

In Magdir/image there exist an attempt to identify such examples by
line
 #0	string		PI		PC pointer image data

This pattern is maybe too simple and false. So this line now becomes
 0	string		PT
And more additional test lines are needed to skip bad examples.

The size of header or file in bytes is stored in variable cbSize.
This is now shown by line like
 >>2	ulelong			x	\b, cbSize %u
For inspected OS/2 pointers i found low values like 1Ah.
This can be used as additional test by jumping 4 bytes before end of
header/file and test for accessibility by line like
 >>(2.l-4) ubelong		x	End of header is OK!
I do not use this, because accessing bytes beyond ranges is not a
official documented feature in file command.

The coordinates of the hot spot for pointers like 0 2 3 15 16 23 25 28
31 are stored in 2 bytes variables xHotspot and yHotspot, which are
now shown by lines like
 >>6	uleshort		x	\b, hotspot %ux
 >>8	uleshort		x	\b%u

Nowadays pointers can becomes big with dimensions, but in ancient
times of OS/2 systems with less RAM dimensions are low. The typical
dimension sizes are 32. That also means in real examples hot spot
values are low (maybe maximal 256). So upper bits of short stored
value seems to be always null. So maybe skip bad examples by looking
for valid hot spot coordinates by additional test line like
 >>6	ulelong&0xFE00FE00	=0
But i do not use this test.

After the first header comes the DIB header. In the first 4 bytes the
DIB header size is stored. This can be shown by line like
 >>14	ulelong		x		\b, dib header size %u
For the considered pointers only values 12 is found. So
test also for valid low dib header sizes and start displaying by line
 >14	ulelong		<65		OS/2
Now afterwards show file name extension and a user defined mime type
according to nirsoft.net extension web site by lines
 !:mime	image/x-ibm-pointer
 !:ext	ptr

I only found OS/2 1.x variant with dib header size 12. Maybe that also
an OS/2 variant exist. So proceed as in the case of color icons.
So first considered the OS/2 1.x variant by checking for dib header
size twelve and show specific icon dimensions by lines
 >>14	ulelong		12		1.x pointer
 >>>18	uleshort	x		%u x
 >>>20	uleshort/2	x		%u
 >>>24	uleshort	>1		x %u

For OS/2 image width and height fields are unsigned integers whereas
for Microsoft Windows variants signed integers are used. The stored
height value was always the double of the real height. So dived
value by 2 before displaying value.

The other possible branch is for the OS/2 2.x variant which start with
looking for dib header size 64 and then display specific dimension by
lines. So add these lines as comments like
 #>>14	ulelong		64		2.x pointer
 #>>>18	ulelong		x		%u x
 #>>>22	ulelong/2	x		%u
 #>>>28	uleshort	>1		x %u
The main difference is that width and height values are stored as 4
byte values instead by 2 bytes.

After applying the above mentioned modifications by patch
file-5.37-images-ptr-PT.diff then unrecognized OS/2 pointers
are now recognized and described like

ARROW.PTR:     OS/2 1.x pointer 32 x 32,
	hotspot 31x0, cbSize 26, bits offset 32
MOVE.PTR:      OS/2 1.x pointer 32 x 32,
	hotspot 2x28, cbSize 26, bits offset 32
SIZENESW1.PTR: OS/2 1.x pointer 32 x 32,
	hotspot 15x16, cbSize 26, bits offset 32
TEXT.PTR:      OS/2 1.x pointer 32 x 32,
	hotspot 3x25, cbSize 26, bits offset 32
wait001.ptr:   OS/2 1.x pointer 32 x 32,
	hotspot 2x23, cbSize 26, bits offset 32
	hotspot 15x16, cbSize 26, bits offset 106


I hope my diff file can be applied in future version of file utility.

There still exist more OS/2 array files which are not recognized or
misidentified by file command. I will handles such things in a future
session.

With best wishes
Jörg Jenderek
- --
Jörg Jenderek







-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCXQ5wtwAKCRCv8rHJQhrU
1ia7AJ0f4TCG4wdc5+PKIz0h6eq3yfYlkACgi96yeSTkCOkvSUPsKCdzJ4BdxQ0=
=IBvr
-----END PGP SIGNATURE-----
-------------- next part --------------
--- file-5.37/magic/Magdir/images.old	2019-04-19 00:42:27 +0000
+++ file-5.37/magic/Magdir/images	2019-06-22 18:00:22 +0000
@@ -606,2 +606,39 @@
 #0	string		PI		PC pointer image data
+# URL:		http://fileformats.archiveteam.org/wiki/OS/2_Pointer
+0	string		PT
+# skip bad examples by checking for valid dib low header sizes like 12
+>14	ulelong		<65		OS/2
+!:mime	image/x-ibm-pointer
+!:ext	ptr
+>>14	ulelong		12		1.x pointer
+# image width and height fields like 32 are unsigned integers for OS/2
+>>>18	uleshort	x		%u x
+# stored height = 2 * real height
+>>>20	uleshort/2	x		%u
+# number of bits per pixel (color depth). only 1 found
+>>>24	uleshort	>1		x %u
+# xHotspot, yHotspot; coordinates of the hotspot like 0 2 3 15 16 23 25 28 31
+>>6	uleshort		x	\b, hotspot %ux
+>>8	uleshort		x	\b%u
+# No OS/2 2.x pointer found
+# >>14	ulelong		64		2.x pointer
+# # image width and height
+# >>>18	ulelong		x		%u x
+# # stored height = 2 * real height
+# >>>22	ulelong/2	x		%u
+# # number of bits per pixel (color depth). only 1 found
+# >>>28	uleshort	>1		x %u
+# #>>>26	uleshort	>1		\b, %u color planes
+# # compression method: 0~no 3~Huffman 1D
+# >>>30	ulelong		3		\b, Huffman 1D compression
+# #>>>30	ulelong		>0		\b, %u compression
+# cbSize; size of header or maybe file in bytes like 1Ah
+>>2	ulelong			x	\b, cbSize %u
+#>>2	ulelong			x	\b, cbSize %x
+# offBits; offset to bitmap data (pixel array) like 20h
+>>10	ulelong			x	\b, bits offset %u
+#>>10	ulelong			x	\b, bits offset 0x%x
+#>>(10.l) ubequad		!0	\b, bits 0x%16.16llx
+# dib header size: 12~Ch~OS/2 1.x 64~40h~OS/2 2.x
+#>>14	ulelong		x		\b, dib header size %u
 #0	string		CI		PC color icon data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.37-images-ptr-PT.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20190622/556e792c/attachment.obj>


More information about the File mailing list