FPCRes alignment issues
Summary
resources compiled with fpcres are giving errors
System Information
Windows 10 x86, Linux x86-64 FPC 3.2.2 both on windows and linux
Steps to reproduce
- run fpcres version.rc -of res
- compile and run test program
Example Project
program test;
{$mode objfpc}{$H+}
{$R version.rc}
uses FileInfo,SysUtils;
var v:TVersionInfo;
begin
v := TVersionInfo.Create;
v.Load(HInstance);
writeln(Format('%d.%d.%d.%d',
[v.FixedInfo.FileVersion[0],
v.FixedInfo.FileVersion[1],
v.FixedInfo.FileVersion[2],
v.FixedInfo.FileVersion[3]
]));
v.Free;
end.
version.rc:
1 VERSIONINFO
FILEVERSION 8,26,0,0
PRODUCTVERSION 8,26,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "041304E4"
BEGIN
VALUE "CompanyName", "Dummy BV.\0"
VALUE "FileDescription", "Programnam\0"
VALUE "FileVersion", "8.26.0.0\0"
VALUE "InternalName", "Programnam\0"
VALUE "LegalCopyright", "c 2009 Dummy BV.\0"
VALUE "LegalTrademarks", "Dummy BV.\0"
VALUE "OriginalFilename", "Programnam.exe\0"
VALUE "ProductName", "Programnam\0"
VALUE "ProductVersion", "8.26.0.0\0"
VALUE "Comments", "http://www.Dummy.nl\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x413, 1252
END
END
What is the current bug behavior?
when running the test program it crashes with a
An unhandled exception occurred at $004269B8:
EDuplicateKeyException: Duplicate key 'gramnam'
What is the expected (correct) behavior?
the 8.26.0.0 version printed on screen
Possible fixes
stripping out the \0 from the rc make it seem to work on linux and windows, but in that case the version info in the windows-executable is garbled (when viewing the properties of the file in explorer)
original discussion: https://forum.lazarus.freepascal.org/index.php?topic=62309
Edited by Marco Van de Voort