Add PE version resource models

This commit is contained in:
Matt Nadareski
2022-11-09 15:17:53 -08:00
parent 6b14321505
commit 72f6af7019
8 changed files with 633 additions and 0 deletions

View File

@@ -489,6 +489,225 @@ namespace BurnOutSharp.Models.PortableExecutable
IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT = 0x0001,
}
public enum FixedFileInfoFileSubtype : uint
{
/// <summary>
/// The driver type is unknown by the system.
/// The font type is unknown by the system.
/// </summary>
VFT2_UNKNOWN = 0x00000000,
#region VFT_DRV
/// <summary>
/// The file contains a printer driver.
/// </summary>
VFT2_DRV_PRINTER = 0x00000001,
/// <summary>
/// The file contains a keyboard driver.
/// </summary>
VFT2_DRV_KEYBOARD = 0x00000002,
/// <summary>
/// The file contains a language driver.
/// </summary>
VFT2_DRV_LANGUAGE = 0x00000003,
/// <summary>
/// The file contains a display driver.
/// </summary>
VFT2_DRV_DISPLAY = 0x00000004,
/// <summary>
/// The file contains a mouse driver.
/// </summary>
VFT2_DRV_MOUSE = 0x00000005,
/// <summary>
/// The file contains a network driver.
/// </summary>
VFT2_DRV_NETWORK = 0x00000006,
/// <summary>
/// The file contains a system driver.
/// </summary>
VFT2_DRV_SYSTEM = 0x00000007,
/// <summary>
/// The file contains an installable driver.
/// </summary>
VFT2_DRV_INSTALLABLE = 0x00000008,
/// <summary>
/// The file contains a sound driver.
/// </summary>
VFT2_DRV_SOUND = 0x00000009,
/// <summary>
/// The file contains a communications driver.
/// </summary>
VFT2_DRV_COMM = 0x0000000A,
/// <summary>
/// The file contains a versioned printer driver.
/// </summary>
VFT2_DRV_VERSIONED_PRINTER = 0x0000000C,
#endregion
#region VFT_FONT
/// <summary>
/// The file contains a raster font.
/// </summary>
VFT2_FONT_RASTER = 0x00000001,
/// <summary>
/// The file contains a vector font.
/// </summary>
VFT2_FONT_VECTOR = 0x00000002,
/// <summary>
/// The file contains a TrueType font.
/// </summary>
VFT2_FONT_TRUETYPE = 0x00000003,
#endregion
}
public enum FixedFileInfoFileType : uint
{
/// <summary>
/// The file type is unknown to the system.
/// </summary>
VFT_UNKNOWN = 0x00000000,
/// <summary>
/// The file contains an application.
/// </summary>
VFT_APP = 0x00000001,
/// <summary>
/// The file contains a DLL.
/// </summary>
VFT_DLL = 0x00000002,
/// <summary>
/// The file contains a device driver. If FileType is VFT_DRV, FileSubtype
/// contains a more specific description of the driver.
/// </summary>
VFT_DRV = 0x00000003,
/// <summary>
/// The file contains a font. If FileType is VFT_FONT, FileSubtype contains
/// a more specific description of the font file.
/// </summary>
VFT_FONT = 0x00000004,
/// <summary>
/// The file contains a virtual device.
/// </summary>
VFT_VXD = 0x00000005,
/// <summary>
/// The file contains a static-link library.
/// </summary>
VFT_STATIC_LIB = 0x00000007,
}
[Flags]
public enum FixedFileInfoFlags : uint
{
/// <summary>
/// The file contains debugging information or is compiled with debugging
/// features enabled.
/// </summary>
VS_FF_DEBUG = 0x00000001,
/// <summary>
/// The file is a development version, not a commercially released product.
/// </summary>
VS_FF_PRERELEASE = 0x00000002,
/// <summary>
/// The file has been modified and is not identical to the original shipping
/// file of the same version number.
/// </summary>
VS_FF_PATCHED = 0x00000004,
/// <summary>
/// The file was not built using standard release procedures. If this flag is
/// set, the StringFileInfo structure should contain a PrivateBuild entry.
/// </summary>
VS_FF_PRIVATEBUILD = 0x00000008,
/// <summary>
/// The file's version structure was created dynamically; therefore, some
/// of the members in this structure may be empty or incorrect. This flag
/// should never be set in a file's VS_VERSIONINFO data.
/// </summary>
VS_FF_INFOINFERRED = 0x00000010,
/// <summary>
/// The file was built by the original company using standard release
/// procedures but is a variation of the normal file of the same version number.
/// If this flag is set, the StringFileInfo structure should contain a SpecialBuild
/// entry.
/// </summary>
VS_FF_SPECIALBUILD = 0x00000020,
}
[Flags]
public enum FixedFileInfoOS : uint
{
/// <summary>
/// The operating system for which the file was designed is
/// unknown to the system.
/// </summary>
VOS_UNKNOWN = 0x00000000,
/// <summary>
/// The file was designed for 16-bit Windows.
/// </summary>
VOS__WINDOWS16 = 0x00000001,
/// <summary>
/// The file was designed for 16-bit Presentation Manager.
/// </summary>
VOS__PM16 = 0x00000002,
/// <summary>
/// The file was designed for 32-bit Presentation Manager.
/// </summary>
VOS__PM32 = 0x00000003,
/// <summary>
/// The file was designed for 32-bit Windows.
/// </summary>
VOS__WINDOWS32 = 0x00000004,
/// <summary>
/// The file was designed for MS-DOS.
/// </summary>
VOS_DOS = 0x00010000,
/// <summary>
/// The file was designed for 16-bit OS/2.
/// </summary>
VOS_OS216 = 0x00020000,
/// <summary>
/// The file was designed for 32-bit OS/2.
/// </summary>
VOS_OS232 = 0x00030000,
/// <summary>
/// The file was designed for Windows NT.
/// </summary>
VOS_NT = 0x00040000,
}
[Flags]
public enum GuardFlags : uint
{
@@ -2364,6 +2583,12 @@ namespace BurnOutSharp.Models.PortableExecutable
IMAGE_SYM_DTYPE_ARRAY = 0x03,
}
public enum VersionResourceType : ushort
{
BinaryData = 0,
TextData = 1,
}
public enum WindowsCertificateRevision : ushort
{
/// <summary>

View File

@@ -0,0 +1,88 @@
using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.PortableExecutable
{
/// <summary>
/// Contains version information for a file. This information is language and
/// code page independent.
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/api/verrsrc/ns-verrsrc-vs_fixedfileinfo"/>
[StructLayout(LayoutKind.Sequential)]
public class FixedFileInfo
{
/// <summary>
/// Contains the value 0xFEEF04BD. This is used with the szKey member of the VS_VERSIONINFO
/// structure when searching a file for the FixedFileInfo structure.
/// </summary>
public uint Signature;
/// <summary>
/// The binary version number of this structure. The high-order word of this member contains
/// the major version number, and the low-order word contains the minor version number.
/// </summary>
public uint StrucVersion;
/// <summary>
/// The most significant 32 bits of the file's binary version number. This member is used with
/// FileVersionLS to form a 64-bit value used for numeric comparisons.
/// </summary>
public uint FileVersionMS;
/// <summary>
/// The least significant 32 bits of the file's binary version number. This member is used with
/// FileVersionMS to form a 64-bit value used for numeric comparisons.
/// </summary>
public uint FileVersionLS;
/// <summary>
/// The most significant 32 bits of the binary version number of the product with which this file
/// was distributed. This member is used with ProductVersionLS to form a 64-bit value used for
/// numeric comparisons.
/// </summary>
public uint ProductVersionMS;
/// <summary>
/// The least significant 32 bits of the binary version number of the product with which this file
/// was distributed. This member is used with ProductVersionMS to form a 64-bit value used for
/// numeric comparisons.
/// </summary>
public uint ProductVersionLS;
/// <summary>
/// Contains a bitmask that specifies the valid bits in FileFlags. A bit is valid only if it was
/// defined when the file was created.
/// </summary>
public uint FileFlagsMask;
/// <summary>
/// Contains a bitmask that specifies the Boolean attributes of the file.
/// </summary>
public FixedFileInfoFlags FileFlags;
/// <summary>
/// The operating system for which this file was designed.
/// </summary>
public FixedFileInfoOS FileOS;
/// <summary>
/// The general type of file.
/// </summary>
public FixedFileInfoFileType FileType;
/// <summary>
/// The function of the file. The possible values depend on the value of FileType. For all values
/// of FileType not described in the following list, FileSubtype is zero.
/// </summary>
public FixedFileInfoFileSubtype FileSubtype;
/// <summary>
/// The most significant 32 bits of the file's 64-bit binary creation date and time stamp.
/// </summary>
public uint FileDateMS;
/// <summary>
/// The least significant 32 bits of the file's 64-bit binary creation date and time stamp.
/// </summary>
public uint FileDateLS;
}
}

View File

@@ -0,0 +1,79 @@
namespace BurnOutSharp.Models.PortableExecutable
{
/// <summary>
/// Represents the organization of data in a file-version resource. It contains a string
/// that describes a specific aspect of a file, for example, a file's version, its
/// copyright notices, or its trademarks.
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/string-str"/>
public class StringData
{
/// <summary>
/// The length, in bytes, of this String structure.
/// </summary>
public ushort Length;
/// <summary>
/// The size, in words, of the Value member.
/// </summary>
public ushort ValueLength;
/// <summary>
/// The type of data in the version resource.
/// </summary>
public VersionResourceType ResourceType;
/// <summary>
/// An arbitrary Unicode string. The Key member can be one or more of the following
/// values. These values are guidelines only.
/// - Comments: The Value member contains any additional information that should be
/// displayed for diagnostic purposes. This string can be an arbitrary length.
/// - CompanyName: The Value member identifies the company that produced the file.
/// For example, "Microsoft Corporation" or "Standard Microsystems Corporation, Inc."
/// - FileDescription: The Value member describes the file in such a way that it can be
/// presented to users. This string may be presented in a list box when the user is
/// choosing files to install. For example, "Keyboard driver for AT-style keyboards"
/// or "Microsoft Word for Windows".
/// - FileVersion: The Value member identifies the version of this file. For example,
/// Value could be "3.00A" or "5.00.RC2".
/// - InternalName: The Value member identifies the file's internal name, if one exists.
/// For example, this string could contain the module name for a DLL, a virtual device
/// name for a Windows virtual device, or a device name for a MS-DOS device driver.
/// - LegalCopyright: The Value member describes all copyright notices, trademarks, and
/// registered trademarks that apply to the file. This should include the full text of
/// all notices, legal symbols, copyright dates, trademark numbers, and so on. In
/// English, this string should be in the format "Copyright Microsoft Corp. 1990 1994".
/// - LegalTrademarks: The Value member describes all trademarks and registered trademarks
/// that apply to the file. This should include the full text of all notices, legal
/// symbols, trademark numbers, and so on. In English, this string should be in the
/// format "Windows is a trademark of Microsoft Corporation".
/// - OriginalFilename: The Value member identifies the original name of the file, not
/// including a path. This enables an application to determine whether a file has been
/// renamed by a user. This name may not be MS-DOS 8.3-format if the file is specific
/// to a non-FAT file system.
/// - PrivateBuild: The Value member describes by whom, where, and why this private version
/// of the file was built. This string should only be present if the VS_FF_PRIVATEBUILD
/// flag is set in the dwFileFlags member of the VS_FIXEDFILEINFO structure. For example,
/// Value could be "Built by OSCAR on \OSCAR2".
/// - ProductName: The Value member identifies the name of the product with which this file is
/// distributed. For example, this string could be "Microsoft Windows".
/// - ProductVersion: The Value member identifies the version of the product with which this
/// file is distributed. For example, Value could be "3.00A" or "5.00.RC2".
/// - SpecialBuild: The Value member describes how this version of the file differs from the
/// normal version. This entry should only be present if the VS_FF_SPECIALBUILD flag is
/// set in the dwFileFlags member of the VS_FIXEDFILEINFO structure. For example, Value
/// could be "Private build for Olivetti solving mouse problems on M250 and M250E computers".
/// </summary>
public string Key;
/// <summary>
/// As many zero words as necessary to align the Value member on a 32-bit boundary.
/// </summary>
public ushort Padding;
/// <summary>
/// A zero-terminated string. See the szKey member description for more information.
/// </summary>
public string Value;
}
}

View File

@@ -0,0 +1,43 @@
namespace BurnOutSharp.Models.PortableExecutable
{
/// <summary>
/// Represents the organization of data in a file-version resource. It contains version
/// information that can be displayed for a particular language and code page.
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/stringfileinfo"/>
public class StringFileInfo
{
/// <summary>
/// The length, in bytes, of the entire StringFileInfo block, including all
/// structures indicated by the Children member.
/// </summary>
public ushort Length;
/// <summary>
/// This member is always equal to zero.
/// </summary>
public ushort ValueLength;
/// <summary>
/// The type of data in the version resource.
/// </summary>
public VersionResourceType ResourceType;
/// <summary>
/// The Unicode string L"StringFileInfo".
/// </summary>
public string Key;
/// <summary>
/// As many zero words as necessary to align the Children member on a 32-bit boundary.
/// </summary>
public ushort Padding;
/// <summary>
/// An array of one or more StringTable structures. Each StringTable structure's Key
/// member indicates the appropriate language and code page for displaying the text in
/// that StringTable structure.
/// </summary>
public StringTable[] Children;
}
}

View File

@@ -0,0 +1,46 @@
namespace BurnOutSharp.Models.PortableExecutable
{
/// <summary>
/// Represents the organization of data in a file-version resource. It contains language
/// and code page formatting information for the strings specified by the Children member.
/// A code page is an ordered character set.
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/stringtable"/>
public class StringTable
{
/// <summary>
/// The length, in bytes, of this StringTable structure, including all structures
/// indicated by the Children member.
/// </summary>
public ushort Length;
/// <summary>
/// This member is always equal to zero.
/// </summary>
public ushort ValueLength;
/// <summary>
/// The type of data in the version resource.
/// </summary>
public VersionResourceType ResourceType;
/// <summary>
/// An 8-digit hexadecimal number stored as a Unicode string. The four most significant
/// digits represent the language identifier. The four least significant digits represent
/// the code page for which the data is formatted. Each Microsoft Standard Language
/// identifier contains two parts: the low-order 10 bits specify the major language,
/// and the high-order 6 bits specify the sublanguage.
/// </summary>
public string Key;
/// <summary>
/// As many zero words as necessary to align the Children member on a 32-bit boundary.
/// </summary>
public ushort Padding;
/// <summary>
/// An array of one or more StringData structures.
/// </summary>
public StringData[] Children;
}
}

View File

@@ -0,0 +1,50 @@
namespace BurnOutSharp.Models.PortableExecutable
{
/// <summary>
/// Represents the organization of data in a file-version resource. It typically contains a
/// list of language and code page identifier pairs that the version of the application or
/// DLL supports.
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/var-str"/>
public class VarData
{
/// <summary>
/// The length, in bytes, of the Var structure.
/// </summary>
public ushort Length;
/// <summary>
/// The size, in words, of the Value member.
/// </summary>
public ushort ValueLength;
/// <summary>
/// The type of data in the version resource.
/// </summary>
public VersionResourceType ResourceType;
/// <summary>
/// The Unicode string L"Translation".
/// </summary>
public string Key;
/// <summary>
/// As many zero words as necessary to align the Value member on a 32-bit boundary.
/// </summary>
public ushort Padding;
/// <summary>
/// An array of one or more values that are language and code page identifier pairs.
///
/// If you use the Var structure to list the languages your application or DLL supports
/// instead of using multiple version resources, use the Value member to contain an array
/// of DWORD values indicating the language and code page combinations supported by this
/// file. The low-order word of each DWORD must contain a Microsoft language identifier,
/// and the high-order word must contain the IBM code page number. Either high-order or
/// low-order word can be zero, indicating that the file is language or code page
/// independent. If the Var structure is omitted, the file will be interpreted as both
/// language and code page independent.
/// </summary>
public uint[] Value;
}
}

View File

@@ -0,0 +1,41 @@
namespace BurnOutSharp.Models.PortableExecutable
{
/// <summary>
/// Represents the organization of data in a file-version resource. It contains version
/// information not dependent on a particular language and code page combination.
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/varfileinfo"/>
public class VarFileInfo
{
/// <summary>
/// The length, in bytes, of the entire VarFileInfo block, including all structures
/// indicated by the Children member.
/// </summary>
public ushort Length;
/// <summary>
/// This member is always equal to zero.
/// </summary>
public ushort ValueLength;
/// <summary>
/// The type of data in the version resource.
/// </summary>
public VersionResourceType ResourceType;
/// <summary>
/// The Unicode string L"VarFileInfo".
/// </summary>
public string Key;
/// <summary>
/// As many zero words as necessary to align the Children member on a 32-bit boundary.
/// </summary>
public ushort Padding;
/// <summary>
/// Typically contains a list of languages that the application or DLL supports.
/// </summary>
public Var[] Children;
}
}

View File

@@ -0,0 +1,61 @@
namespace BurnOutSharp.Models.PortableExecutable
{
/// <summary>
/// Represents the organization of data in a file-version resource. It is the root
/// structure that contains all other file-version information structures.
/// </summary>
/// <see href="https://learn.microsoft.com/en-us/windows/win32/menurc/vs-versioninfo"/>
public class VersionInfo
{
/// <summary>
/// The length, in bytes, of the VS_VERSIONINFO structure. This length does not
/// include any padding that aligns any subsequent version resource data on a
/// 32-bit boundary.
/// </summary>
public ushort Length;
/// <summary>
/// The length, in bytes, of the Value member. This value is zero if there is no
/// Value member associated with the current version structure.
/// </summary>
public ushort ValueLength;
/// <summary>
/// The type of data in the version resource. This member is 1 if the version resource
/// contains text data and 0 if the version resource contains binary data.
/// </summary>
public VersionResourceType ResourceType;
/// <summary>
/// The Unicode string L"VS_VERSION_INFO".
/// </summary>
public string Key;
/// <summary>
/// Contains as many zero words as necessary to align the Value member on a 32-bit boundary.
/// </summary>
public ushort Padding1;
/// <summary>
/// Arbitrary data associated with this VS_VERSIONINFO structure. The ValueLength member
/// specifies the length of this member; if ValueLength is zero, this member does not exist.
/// </summary>
public FixedFileInfo Value;
/// <summary>
/// As many zero words as necessary to align the Children member on a 32-bit boundary.
/// These bytes are not included in wValueLength. This member is optional.
/// </summary>
public ushort Padding2;
/// <summary>
/// The StringFileInfo structure to store user-defined string information data.
/// </summary>
public StringFileInfo StringFileInfo;
/// <summary>
/// The VarFileInfo structure to store language information data.
/// </summary>
public VarFileInfo VarFileInfo;
}
}