[File] [PATCH] of Magdir/c64 Commodore 64 cartridge misidentfies DROID CRT

Christos Zoulas christos at zoulas.com
Thu Mar 7 22:30:32 UTC 2024


Applied, thanks!

christos

> On May 24, 2023, at 5:47 PM, Jörg Jenderek <joerg.jen.der.ek at gmx.net> wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello,
> some days ago i enabled secure boot on an installation and the
> machine crashed. I am no expert in that field but i believed that
> something went wrong when "enrolling" security certificates. So i
> looked for such samples on my systems. Sometimes these have suffix
> crt. Unfortunately this suffix is also used for other files types
> like Commodore 64 cartridges.
> 
> When running file command version 5.44 on such Commodore CRT samples
> and related files, i get an output like:
> 
> Archon Cartridge v1.1.crt:     Commodore 64 cartridge:
>       		 	       "Magic Desk",
> 			       Magic Desk,
> 			       Domark, HES Australia
> DaffyDuck.crt:                 Commodore 64 cartridge:
> 			       "DAFFY DUCK",
> 			       EasyFlash
> Disk Utilities 1c.crt:         Commodore 64 cartridge:
>     	       		       "ndefpack 1.0.1",
> 			       EasyFlash
> boxymoxy_v11.crt:              Commodore 64 cartridge:
> 			       "VICE CART",
> 			       GMod2
> c64gscar.crt:                  Commodore 64 cartridge:
> 			       "C64GS Cartridge",
> 			       C64 Game System, System 3
> fc3-geos.crt:                  Commodore 64 cartridge:
> 			       "FINAL CARTRIDGE 3",
> 			       Final Cartridge III
> fmt-822-signature-id-1179.crt: Commodore 64 cartridge:
> 			       "\253\253\253\253\253\253\253\253",
> fmt-822.crt:                   Commodore 64 cartridge
> 			       , 16 KB game
> maniac.crt:                    Commodore 64 cartridge:
> 			       "EASYFLASH",
> 			       EasyFlash
> pop.crt:                       Commodore 64 cartridge:
> 			       "EasyFlash",
> 			       EasyFlash
> sales.crt:                     Commodore 64 cartridge:
> 			       "sales",
> 			       16 KB game
> 
> Furthermore only generic mime type application/octet-stream
> or text/plain is shown with -i. With option --extension
> only 3 byte sequence ??? is shown.
> 
> For comparison reason i also run the file format identification
> utility DROID ( See https://sourceforge.net/projects/droid/).
> The samples are described as "CRT C64 Cartridge Image Format"
> by PUID fmt/822.
> 
> For comparison reason i run the file format identification utility
> TrID ( See https://mark0.net/soft-trid-e.html). The cartridge samples
> are described as here with high priority as "C64 Cartridge image"
> with suffix CRT by crt-c64.trid.xml. But the samples are also
> described with low priority as "CCS64 Cartridge" with wrong suffix
> CAR by car-ccs64.trid.xml (See appended trid-v-cdr_c64.txt.gz).
> 
> TrID list the used file name extension and often with -v option the
> related URL pointing to used file format information. With the help
> of these tools i found a page about CaRTridge Images. So this is
> now expressed inside Magdir/c64 by additional comment lines like:
> # Reference: https://vice-emu.sourceforge.io/vice_17.html#SEC391
> #		http://ist.uwaterloo.ca/~schepers/formats/CRT.TTX
> #		http://mark0.net/download/triddefs_xml.7z
> #		defs/c/crt-c64.trid.xml
> 
> The DROID samples like fmt-822-signature-id-1179.crt are not real
> Commodore 64 cartridge. These are used by DROID to recognise
> such cartridges and contain just some leading bytes.
> 
> The description happens inside Magdir/c64 and test the first 13
> bytes. This looks like:
> 0	string		C64\40CARTRIDGE	Commodore 64 cartridge
> The DROID tool also test if the next 3 bytes of 16-byte cartridge
> signature are spaces. TrID also use this additional characteristic
> for variant "C64 Cartridge image", but for "C64 Cartridge image"
> variant only 1 appended space is checked. In my inspected samples i
> also get 3 spaces but just in case for "exotic" variant show this
> information by additional line like:
>> 14	ubeshort	!0x2020	\b, at 14 %#x
> 
> Afterwards the 32-byte null padded cartridge names are shown if
> available by lines like:
>> 0x20	ubyte	0	\b,
>> 0x20	ubyte	!0
>>> 0x20	string/T	x	\b: "%.32s",
> For real samples i get strings like "BUGS BUNNY" "CART64"
> "EasyFlash" "FINAL CARTRIDGE" "Magic Desk" "VICE CART". For the
> DROID samples i get "\253\253\253\253\253\253\253\253" for variant
> filled with 0xAB values or nothing for variant with nil bytes.
> 
> Afterwards the cartridge hardware types is shown. For some types
> like 0 there a next level sub classification is done by displaying
> cartridge Hardware Revision/Subtype at offset 0x18. In current
> version hardware types in range 0-77 are listed. This is done by
> lines like:
>> 0x16	beshort	0
>>> 0x18	beshort	0x0000	16 KB game
>>> 0x18	beshort	0x0001	8 KB game
>>> 0x18	beshort	0x0100	UltiMax mode
>>> 0x18	beshort	0x0101	RAM/disabled
>> 0x16	beshort	1	Action Replay
>> 0x16	beshort	2	KCS Power Cartridge
> ...
>> 0x16	beshort	75	IEEE Flash! 64
>> 0x16	beshort	76	Turtle Graphics II
>> 0x16	beshort	77	Freeze Frame MK2
> 
> In one of the documents an additional type with higher number 78
> for "Partner 64" is listed. For cases of accident or future
> expansion now show higher types number by additional lines like:
>> 0x16	beshort	78	Partner 64
>> 0x16	ubeshort >78	Unknown type %#x
>>> 0x1A	ubyte	>0	revision %#x
> For the DROID samples i get "unknown type 0xabab revision 0xab" for
> for variant filled with 0xAB values or "16 KB game" for variant
> with nil bytes.
> 
> I want to distinguish DROID samples from real CRT samples. So i
> look at other fields in header and display unusual values. After
> the signature the file header length is stored. Typical and minimum
> value is 40h, but some times wrong 20h appear in some samples, but
> i myself found no such samples. So report this field by additional
> line after last displaying like:
>> 0x10	ubelong	!0x40	\b, header length %#x
> Afterwards the cartridge version is stored. Typical version are
> 1.0 1.1 (adds CRT sub type/hardware revision) 2.0 (introduces
> VIC20, PLUS4, C128, CBM2). In my samples the version was 1.0. So
> show other values by lines like:
>> 0x14	ubeshort	!0x0100
>>> 0x14	ubyte		x	\b, version %u
>>> 0x15	ubyte		x	\b.%u
> For the DROID samples i get "version 171.171" for variant filled
> with 0xAB values or "version 0.0" for variant with nil bytes.
> 
> After the header the cartridge content begins which start with ROM
> signature which must be CHIP according to DROID. So for damaged CRT
> show unusual values by additional lines like:
>> 0x40	ubelong	!0x43484950	\b, invalid ROM signature
>>> 0x40	string	x		"%0.4s"
> For the DROID samples this ROM signature is valid.
> 
> Afterwards the total packet length is stored. This is shown by line
> like:
>> 0x44	ubelong	x	\b, packet length %#x
> For real CRT samples i get values like 2010h 4010h. For the DROID
> samples i get here nothing because that offset is beyond the end of
> file size limit.
> 
> So i choose this criterium as second test to skip DROID samples
> because this is the most significant proofing test. I done this by
> putting the displaying part in sub routine c64-crt. One advantage
> is that i can keep many magic lines. Another advantage is that the
> routine can be also used for other cartridge variants which start
> with other starting signature. So the start now becomes like:
> 0	string		C64\40CARTRIDGE
>> 0x44	ubelong		>0x10
>>> 0	use		c64-crt
> 0	name		c64-crt
>> 0	string		x		Commodore 64 cartridge
> !:mime	application/x-commodore-crt
> !:ext	crt
> Instead of generic mime type application/octet-stream i show an
> user defined one. The file name suffix is CRT, but according to
> TrID CAR is used for "CCS64 Cartridge" variant, but i have and
> found no such samples.
> 
> After applying the above mentioned modifications by patch
> file-5.44-c64-crt.diff then misidentification of DROID samples vanish
> and now i get an output with more details like:
> 
> Archon Cartridge v1.1.crt:     Commodore 64 cartridge:
>       		 	       "Magic Desk",
> 			       Magic Desk, Domark, HES Australia
> 			       , packet length 0x2010
> DaffyDuck.crt:                 Commodore 64 cartridge:
> 			       "DAFFY DUCK",
> 			       EasyFlash
> 			       , packet length 0x2010
> Disk Utilities 1c.crt:         Commodore 64 cartridge:
>     	       		       "ndefpack 1.0.1",
> 			       EasyFlash
> 			       , packet length 0x2010
> boxymoxy_v11.crt:              Commodore 64 cartridge:
> 			       "VICE CART",
> 			       GMod2
> 			       , packet length 0x2010
> c64gscar.crt:                  Commodore 64 cartridge:
> 			       "C64GS Cartridge",
> 			       C64 Game System, System 3
> 			       , packet length 0x2010
> fc3-geos.crt:                  Commodore 64 cartridge:
> 			       "FINAL CARTRIDGE 3",
> 			       Final Cartridge III
> 			       , packet length 0x4010
> fmt-822-signature-id-1179.crt: ISO-8859 text
> 			       , with no line terminators
> fmt-822.crt:                   data
> maniac.crt:                    Commodore 64 cartridge:
> 			       "EASYFLASH",
> 			       EasyFlash
> 			       , packet length 0x2010
> pop.crt:                       Commodore 64 cartridge:
> 			       "EasyFlash",
> 			       EasyFlash
> 			       , packet length 0x2010
> sales.crt:                     Commodore 64 cartridge:
> 			       "sales",
> 			       16 KB game
> 			       , packet length 0x4010
> 
> I hope my diff file can be applied in future version of
> file utility.
> 
> With best wishes
> Jörg Jenderek
> - --
> Jörg Jenderek
> 
> 
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
> 
> iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCZG6F/QAKCRCv8rHJQhrU
> 1n+1AKDaYbwozhIdo7GMw9Zf+mBwR1z95ACfUM4geiUNG+bCzMWO5ltmHTGe0ZE=
> =7XQT
> -----END PGP SIGNATURE-----
> <trid-v-crt_c64.txt.gz><file-5_44-c64-crt_diff.DEFANGED-1762><file-5_44-c64-crt_diff_sig.DEFANGED-1763>-- 
> File mailing list
> File at astron.com
> https://mailman.astron.com/mailman/listinfo/file
> <sanitizer.log>



More information about the File mailing list