View Single Post
Old 02-09-2009, 00:48   #8 (permalink)
mobytes
Crazy Poster
 
Join Date: Jan 2009
Posts: 51
Member: 957095
Status: Offline
Thanks Meter: 16
Quote:
Originally Posted by elseWestcott View Post
VSM files start with the bytes 01 00 00 bc which appear to be nothing more than a magic number. Changing any of these first four bytes causes the file to not be recognized as a VSM file.

Next are four bytes that give the length of the resource section in little-endian order so 46 0b 00 00 signifies that the length is 0x00000b46 or 2886 bytes long.

The next four bytes are calculated by taking 0xffffffff - (the CRC-32 of the resource section). If the CRC-32 of the resource section is 0x5480b153 then take 0xffffffff - 0x5480b153 = 0xab7f4eac so the four bytes are ac 4e 7f ab.

The Vendor ID takes the next two bytes. Remember that little-endian order is used, so 36 01 is used to represent the vendor id 310 for Wind Italy. The Vendor ID MAY be changed without affecting the file signature or the checksum.

The next two bytes are always zero.

There is a single byte value of unknown purpose followed by two bytes of zero followed by a byte that is zero when the unknown value is zero, and one when the unknown value is non-zero.

There are eight bytes of zero before the resource section begins. This may be reserved for future use.

The resource section may be empty, but most often it contains resources. Each resource starts with two bytes that specify the resource type, followed by a two byte resource length value, followed by the resource data. If the last byte of the resource falls on an even-numbered address offset (assuming the first byte in the file is considered offset zero) then there is a pad null byte between the two resources. The pad byte is not figured into the length of either resource, but is included in the value for the total resource section length found in the file header.

The resouces may be listed in any order, however changing any byte in the resource section including resource order will cause the file signature to be invalid.

Following the resource section there may or may not be a footer and signature. The footer is the byte sequence: 1F 2D C8 D7 33 00 00 00 80 00 00 00. I am not sure of the function of the first eight bytes, but I believe the 80 00 specifies that the signature is of length 0x0080 or 128 bytes. There are two null bytes followed by a 128 byte (1024 bit) signature.

The following table lists the values to use to define a field type followed by a name for each. There are also some values for flags listed after the field for which they are used.
elseWestcott,

Nice work. Do you have an updated version of your parsing tool? - I'm having trouble parsing the PNGs from some of the VSMs with your 2/3/2009 release.

Also, your online VSM design tool is fantastic. Thanks again.

Do you know under what circumstances it is necessary to have a signed VSM file?

mobytes
  Reply With Quote
The Following User Says Thank You to mobytes For This Useful Post:
 
Page generated in 0.08111 seconds with 7 queries