Windows resources field overflows to next field

76 views Asked by At

I try to build resource file with Borland resources compiler, but the fields' data have to overflow. Even if I make padding with spaces for 30 characters, it overflows in some cases (in some cases not)... is there some binary format description of Microsoft resources files?

Here is the codes.

resource.rc file:

VS_VERSION_INFO VERSIONINFO
FILEVERSION     1, 1, 1, 1
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904E4"
        BEGIN
            VALUE "CompanyName",        "VAR_COMPANYNAME"
            VALUE "FileDescription",    "VAR_FILEDESCRIPTION"
            VALUE "FileVersion",        "VAR_FILEVERSION"
            VALUE "InternalName",       "VAR_INTERNALNAME"
            VALUE "LegalCopyright",     "VAR_LEGALCOPYRIGHT"
            VALUE "LegalTrademarks1",   "VAR_LEGALTRAIDMARKS1"
            VALUE "LegalTrademarks2",   "VAR_LEGALTRAIDMARKS2"
            VALUE "OriginalFilename",   "VAR_ORIGNALFILENAME"
            VALUE "ProductName",        "VAR_PRODUCTNAME"
            VALUE "ProductVersion",     "VAR_PRODUCTVERSION"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 1033, 1252
    END
END

resource.bat file:

@echo off

T:\bin\brcc32.exe -foTSEDO.res "C:\repos\gradlecpp\src\main\resources\resource.rc"

resource.ps1 file:

$ErrorActionPreference = "SilentlyContinue"

Remove-Item "TSEDO.rc"
Remove-Item "TSEDO.res"
Remove-Item "TSEDO.dll"

$ErrorActionPreference = "Stop"
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition

$process = Start-Process `
    -NoNewWindow `
    -FilePath "$scriptPath\resources.bat" `
    -Wait `
    -PassThru
if ($process.ExitCode -ne 0) {
    "Error " + $process.ExitCode
    exit
}

$process = Start-Process `
    -NoNewWindow `
    -FilePath "T:\Bin\bpr2mak.exe" `
    -ArgumentList 'TSEDO.bpr -t..\template.bmk' `
    -Wait `
    -PassThru

if ($process.ExitCode -ne 0) {
    "Error " + $process.ExitCode
    exit
}

$process = Start-Process `
    -NoNewWindow `
    -FilePath "T:\bin\make.exe" `
    -ArgumentList '-fTSEDO.mak' `
    -Wait `
    -PassThru

if ($process.ExitCode -ne 0) {
    "Error " + $process.ExitCode
    exit
}

(Get-Item TSEDO.dll).VersionInfo.CompanyName
(Get-Item TSEDO.dll).VersionInfo.FileDescription
(Get-Item TSEDO.dll).VersionInfo.FileVersion
(Get-Item TSEDO.dll).VersionInfo.InternalName
(Get-Item TSEDO.dll).VersionInfo.LegalCopyright
(Get-Item TSEDO.dll).VersionInfo.LegalTrademarks1
(Get-Item TSEDO.dll).VersionInfo.LegalTrademarks2
(Get-Item TSEDO.dll).VersionInfo.OriginalFilename
(Get-Item TSEDO.dll).VersionInfo.ProductName
(Get-Item TSEDO.dll).VersionInfo.ProductVersion

Here is Borland utils version:

c:\repos\torgovayasystema\EDO>brcc32 -h
Borland Resource Compiler  Version 5.40
Copyright (c) 1990, 1999 Inprise Corporation.  All rights reserved.

Here is output of build script:

PS C:\repos\torgovayasystema\edo> resources.ps1
Borland Resource Compiler  Version 5.40
Copyright (c) 1990, 1999 Inprise Corporation.  All rights reserved.
BPR2MAK C++Builder Project file to Makefile converter. Version 5.0
Copyright (C) 2000, Borland/Inprise Corporation

Loading project file
Loading template
Generating Makefile
.......................................MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
        T:\bin\..\BIN\ilink32 @MAKE0000.@@@
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Warning: Public symbol '_PATH_TO_SAVE_DIADOC_FILES' defined in both module C:\REPOS\TORGOVAYASYSTEMA\EDO\FMEDODOCOUT.OBJ
 and C:\REPOS\TORGOVAYASYSTEMA\EDO\FMEDODOCOUTSTATUS.OBJ
VAR_COMPANYNAME
VAR_FILEDESCRIPTION
VAR_FILEVERSION
VAR_INTERNALNAMEH↕☺LegalCopyright
VAR_LEGALCOPYRIGHTP¶☺LegalTrademarks1
VAR_ORIGNALFILENAME
VAR_PRODUCTNAME
VAR_PRODUCTVERSIOND

And the graphical one:

enter image description here

I have Windows 7 SP1.

1

There are 1 answers

1
Remy Lebeau On

As shown in MSDN's VERSIONINFO resource example, you need to add a null terminator to the end of each string value in each localized BLOCK, eg:

VS_VERSION_INFO VERSIONINFO
FILEVERSION     1, 1, 1, 1
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904E4"
        BEGIN
            VALUE "CompanyName",        "VAR_COMPANYNAME\0"
            VALUE "FileDescription",    "VAR_FILEDESCRIPTION\0"
            VALUE "FileVersion",        "VAR_FILEVERSION\0"
            VALUE "InternalName",       "VAR_INTERNALNAME\0"
            VALUE "LegalCopyright",     "VAR_LEGALCOPYRIGHT\0"
            VALUE "LegalTrademarks1",   "VAR_LEGALTRAIDMARKS1\0"
            VALUE "LegalTrademarks2",   "VAR_LEGALTRAIDMARKS2\0"
            VALUE "OriginalFilename",   "VAR_ORIGNALFILENAME\0"
            VALUE "ProductName",        "VAR_PRODUCTNAME\0"
            VALUE "ProductVersion",     "VAR_PRODUCTVERSION\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 1033, 1252
    END
END