[haiku-development] Reading version information of a big endian resource file

  • From: "Mark Hellegers" <mark@xxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 01 May 2016 16:29:42 +0200 CEST

Hello,

I am running into a problem with a big endian resource file.
It is a resource file containing the application version of the 
application I am building.
When I construct a BAppFileInfo object pointing to the resource file, 
the version information is wrong. Instead of 1.5.0 I get 
16777216.83886080.0, which would be correct if it were a little endian 
file.
I dug around a bit in the source code of Haiku that reads it, but I am 
not sure how to solve it.
I found the following calls are being made:
- BAppFileInfo::GetVersionInfo is being called at a certain point
- This function calls _ReadData with type B_VERSION_INFO_TYPE which is 
locally defined as 'APPV'
- _ReadData calls BResources::LoadResource
- LoadResource calls ResourceFile::ReadResource
- Finally ResourceFile::ReadResource reads the data from the file and 
tries to convert it by swapping the data, but because 
B_VERSION_INFO_TYPE is not known to the swap_data function (defined in 
ByteOrder.h), the swap_data function returns B_BAD_VALUE and thus does 
nothing.

I understand that the swap_data function cannot really do anything with 
the type, but it seems that the BAppFileInfo::GetVersionInfo assumes 
the data is valid as is and passes it back to the caller. I might be 
able to fix it if BAppFileInfo could see that it is a big endian file, 
but I don't see anywhere that information is accessible outside the 
ResourceFile class.

Any pointers on how to fix it would be much appreciated.

Kind regards,

Mark Hellegers

--
Spangalese for beginners

`Maloya coy hoba huba.'
`My tapeworm washed the car.'



Other related posts: