diff --git a/exeinfo/Program.cs b/exeinfo/Program.cs index 995037a..67e7741 100644 --- a/exeinfo/Program.cs +++ b/exeinfo/Program.cs @@ -30,6 +30,8 @@ using System.Globalization; using System.Linq; using System.Text; using libexeinfo; +using libexeinfo.Windows; +using Version = libexeinfo.Windows.Version; namespace exeinfo { @@ -64,16 +66,15 @@ namespace exeinfo Console.WriteLine("\tVersion resource {0}:", vers.Name); Console.WriteLine("\t\tFile version: {0}", vers.FileVersion); Console.WriteLine("\t\tProduct version: {0}", vers.ProductVersion); - Console.WriteLine("\t\tFile type: {0}", NE.Version.TypeToString(vers.FileType)); - if(vers.FileType == NE.VersionFileType.VFT_DRV) - Console.WriteLine("\t\tFile subtype: {0} driver", - NE.Version.DriverToString(vers.FileSubtype)); - else if(vers.FileType == NE.VersionFileType.VFT_DRV) - Console.WriteLine("\t\tFile subtype: {0} font", NE.Version.FontToString(vers.FileSubtype)); + Console.WriteLine("\t\tFile type: {0}", Version.TypeToString(vers.FileType)); + if(vers.FileType == VersionFileType.VFT_DRV) + Console.WriteLine("\t\tFile subtype: {0} driver", Version.DriverToString(vers.FileSubtype)); + else if(vers.FileType == VersionFileType.VFT_DRV) + Console.WriteLine("\t\tFile subtype: {0} font", Version.FontToString(vers.FileSubtype)); else if(vers.FileSubtype > 0) Console.WriteLine("\t\tFile subtype: {0}", (uint)vers.FileSubtype); Console.WriteLine("\t\tFile flags: {0}", vers.FileFlags); - Console.WriteLine("\t\tFile OS: {0}", NE.Version.OsToString(vers.FileOS)); + Console.WriteLine("\t\tFile OS: {0}", Version.OsToString(vers.FileOs)); foreach(KeyValuePair> strByLang in vers.StringsByLanguage) { @@ -126,15 +127,15 @@ namespace exeinfo Console.WriteLine("\tVxD version resource {0}:", vers.Name); Console.WriteLine("\t\tFile version: {0}", vers.FileVersion); Console.WriteLine("\t\tProduct version: {0}", vers.ProductVersion); - Console.WriteLine("\t\tFile type: {0}", NE.Version.TypeToString(vers.FileType)); - if(vers.FileType == NE.VersionFileType.VFT_DRV) - Console.WriteLine("\t\tFile subtype: {0} driver", NE.Version.DriverToString(vers.FileSubtype)); - else if(vers.FileType == NE.VersionFileType.VFT_DRV) + Console.WriteLine("\t\tFile type: {0}", Version.TypeToString(vers.FileType)); + if(vers.FileType == VersionFileType.VFT_DRV) + Console.WriteLine("\t\tFile subtype: {0} driver", Version.DriverToString(vers.FileSubtype)); + else if(vers.FileType == VersionFileType.VFT_DRV) Console.WriteLine("\t\tFile subtype: {0} font", - NE.Version.FontToString(vers.FileSubtype)); + Version.FontToString(vers.FileSubtype)); else if(vers.FileSubtype > 0) Console.WriteLine("\t\tFile subtype: {0}", (uint)vers.FileSubtype); Console.WriteLine("\t\tFile flags: {0}", vers.FileFlags); - Console.WriteLine("\t\tFile OS: {0}", NE.Version.OsToString(vers.FileOS)); + Console.WriteLine("\t\tFile OS: {0}", Version.OsToString(vers.FileOs)); foreach(KeyValuePair> strByLang in vers.StringsByLanguage) { @@ -179,23 +180,22 @@ namespace exeinfo { recognized = true; Console.Write(peExe.Information); - - if(((PE)peExe).Versions != null) + + if(((PE)peExe).Versions != null) foreach(PE.Version vers in ((PE)peExe).Versions) { Console.WriteLine("\tVersion resource {0}:", vers.Name); Console.WriteLine("\t\tFile version: {0}", vers.FileVersion); Console.WriteLine("\t\tProduct version: {0}", vers.ProductVersion); - Console.WriteLine("\t\tFile type: {0}", PE.Version.TypeToString(vers.FileType)); - if(vers.FileType == PE.VersionFileType.VFT_DRV) - Console.WriteLine("\t\tFile subtype: {0} driver", - PE.Version.DriverToString(vers.FileSubtype)); - else if(vers.FileType == PE.VersionFileType.VFT_DRV) - Console.WriteLine("\t\tFile subtype: {0} font", PE.Version.FontToString(vers.FileSubtype)); + Console.WriteLine("\t\tFile type: {0}", Version.TypeToString(vers.FileType)); + if(vers.FileType == VersionFileType.VFT_DRV) + Console.WriteLine("\t\tFile subtype: {0} driver", Version.DriverToString(vers.FileSubtype)); + else if(vers.FileType == VersionFileType.VFT_DRV) + Console.WriteLine("\t\tFile subtype: {0} font", Version.FontToString(vers.FileSubtype)); else if(vers.FileSubtype > 0) Console.WriteLine("\t\tFile subtype: {0}", (uint)vers.FileSubtype); Console.WriteLine("\t\tFile flags: {0}", vers.FileFlags); - Console.WriteLine("\t\tFile OS: {0}", PE.Version.OsToString(vers.FileOS)); + Console.WriteLine("\t\tFile OS: {0}", Version.OsToString(vers.FileOs)); foreach(KeyValuePair> strByLang in vers.StringsByLanguage) { @@ -231,7 +231,6 @@ namespace exeinfo } } - if(peExe.Strings != null && peExe.Strings.Any()) { Console.WriteLine("\tStrings:"); diff --git a/exeinfogui/Win16/PanelWin16Version.xeto.cs b/exeinfogui/Win16/PanelWin16Version.xeto.cs index 7ec1e8a..6912894 100644 --- a/exeinfogui/Win16/PanelWin16Version.xeto.cs +++ b/exeinfogui/Win16/PanelWin16Version.xeto.cs @@ -31,6 +31,8 @@ using System.Globalization; using System.Text; using Eto.Forms; using Eto.Serialization.Xaml; +using libexeinfo.Windows; +using Version = libexeinfo.Windows.Version; namespace exeinfogui.Win16 { @@ -95,17 +97,16 @@ namespace exeinfogui.Win16 { txtFileDate.Text = version.FileDate != new DateTime(1601, 1, 1) ? $"{version.FileDate}" : "Not set"; txtFileFlags.Text = version.FileFlags == 0 ? "Normal" : $"{version.FileFlags}"; - txtFileOs.Text = libexeinfo.NE.Version.OsToString(version.FileOS); + txtFileOs.Text = Version.OsToString(version.FileOs); - if(version.FileType == libexeinfo.NE.VersionFileType.VFT_DRV) - txtFileSubtype.Text = $"{libexeinfo.NE.Version.DriverToString(version.FileSubtype)} driver"; - else if(version.FileType == libexeinfo.NE.VersionFileType.VFT_DRV) - txtFileSubtype.Text = - $"{libexeinfo.NE.Version.FontToString(version.FileSubtype)} font"; + if(version.FileType == VersionFileType.VFT_DRV) + txtFileSubtype.Text = $"{Version.DriverToString(version.FileSubtype)} driver"; + else if(version.FileType == VersionFileType.VFT_DRV) + txtFileSubtype.Text = $"{Version.FontToString(version.FileSubtype)} font"; else if(version.FileSubtype > 0) txtFileSubtype.Text = $"{(uint)version.FileSubtype}"; else txtFileSubtype.Text = "None"; - txtFileType.Text = libexeinfo.NE.Version.TypeToString(version.FileType); + txtFileType.Text = Version.TypeToString(version.FileType); txtFileVersion.Text = $"{version.FileVersion}"; txtProductVersion.Text = $"{version.ProductVersion}"; diff --git a/libexeinfo/NE/Consts.cs b/libexeinfo/NE/Consts.cs index 355d117..b49229f 100644 --- a/libexeinfo/NE/Consts.cs +++ b/libexeinfo/NE/Consts.cs @@ -32,14 +32,6 @@ namespace libexeinfo /// New Executable signature, "NE" /// const ushort SIGNATURE = 0x454E; - /// - /// Signature for a - /// - const string FIXED_FILE_INFO_SIG = "VS_VERSION_INFO"; - /// - /// Signature for list of name=value strings inside a version resource - /// - const string STRING_FILE_INFO = "StringFileInfo"; const ushort SEGMENT_TYPE_MASK = 0x07; const ushort SEGMENT_FLAGS_MASK = 0x3F8; diff --git a/libexeinfo/NE/Enums.cs b/libexeinfo/NE/Enums.cs index 289a8fa..5238d70 100644 --- a/libexeinfo/NE/Enums.cs +++ b/libexeinfo/NE/Enums.cs @@ -136,92 +136,5 @@ namespace libexeinfo Win32 = 4, Borland = 5 } - - /// - /// Version file flags. - /// - [Flags] - public enum VersionFileFlags : uint - { - VS_FF_DEBUG = 0x00000001, - VS_FF_INFOINFERRED = 0x00000010, - VS_FF_PATCHED = 0x00000004, - VS_FF_PRERELEASE = 0x00000002, - VS_FF_PRIVATEBUILD = 0x00000008, - VS_FF_SPECIALBUILD = 0x00000020 - } - - /// - /// Version file operating system. - /// - public enum VersionFileOS : uint - { - VOS_DOS = 0x00010000, - VOS_NT = 0x00040000, - VOS_WINDOWS16 = 0x00000001, - VOS_WINDOWS32 = 0x00000004, - VOS_OS216 = 0x00020000, - VOS_OS232 = 0x00030000, - VOS_PM16 = 0x00000002, - VOS_PM32 = 0x00000003, - VOS_UNKNOWN = 0x00000000, - - // Combinations, some have no sense - VOS_DOS_NT = 0x00050000, - VOS_DOS_WINDOWS16 = 0x00010001, - VOS_DOS_WINDOWS32 = 0x00010004, - VOS_DOS_PM16 = 0x00010002, - VOS_DOS_PM32 = 0x00010003, - VOS_NT_WINDOWS16 = 0x00040001, - VOS_NT_WINDOWS32 = 0x00040004, - VOS_NT_PM16 = 0x00040002, - VOS_NT_PM32 = 0x00040003, - VOS_OS216_WINDOWS16 = 0x00020001, - VOS_OS216_WINDOWS32 = 0x00020004, - VOS_OS216_PM16 = 0x00020002, - VOS_OS216_PM32 = 0x00020003, - VOS_OS232_WINDOWS16 = 0x00030001, - VOS_OS232_WINDOWS32 = 0x00030004, - VOS_OS232_PM16 = 0x00030002, - VOS_OS232_PM32 = 0x00030003 - } - - /// - /// Version file subtype. - /// - public enum VersionFileSubtype : uint - { - VFT2_UNKNOWN = 0x00000000, - // Drivers - VFT2_DRV_COMM = 0x0000000A, - VFT2_DRV_DISPLAY = 0x00000004, - VFT2_DRV_INSTALLABLE = 0x00000008, - VFT2_DRV_KEYBOARD = 0x00000002, - VFT2_DRV_LANGUAGE = 0x00000003, - VFT2_DRV_MOUSE = 0x00000005, - VFT2_DRV_NETWORK = 0x00000006, - VFT2_DRV_PRINTER = 0x00000001, - VFT2_DRV_SOUND = 0x00000009, - VFT2_DRV_SYSTEM = 0x00000007, - VFT2_DRV_VERSIONED_PRINTER = 0x0000000C, - // Fonts - VFT2_FONT_RASTER = 0x00000001, - VFT2_FONT_TRUETYPE = 0x00000003, - VFT2_FONT_VECTOR = 0x00000002 - } - - /// - /// Version file type. - /// - public enum VersionFileType : uint - { - VFT_APP = 0x00000001, - VFT_DLL = 0x00000002, - VFT_DRV = 0x00000003, - VFT_FONT = 0x00000004, - VFT_STATIC_LIB = 0x00000007, - VFT_UNKNOWN = 0x00000000, - VFT_VXD = 0x00000005 - } } } \ No newline at end of file diff --git a/libexeinfo/NE/Structs.cs b/libexeinfo/NE/Structs.cs index 167cc2f..cb6226d 100644 --- a/libexeinfo/NE/Structs.cs +++ b/libexeinfo/NE/Structs.cs @@ -63,7 +63,7 @@ namespace libexeinfo public ushort alignment_shift; public ushort resource_entries; public TargetOS target_os; - public ExecutableFlags ExecutableFlags; + public ExecutableFlags ExecutableFlags; public ushort return_thunks_offset; public ushort segment_reference_thunks; public ushort minimum_swap_area; @@ -122,27 +122,6 @@ namespace libexeinfo public string szName; } - /// - /// Fixed file version info - /// - [StructLayout(LayoutKind.Sequential)] - public struct FixedFileInfo - { - public uint dwSignature; - public uint dwStrucVersion; - public uint dwFileVersionMS; - public uint dwFileVersionLS; - public uint dwProductVersionMS; - public uint dwProductVersionLS; - public uint dwFileFlagsMask; - public uint dwFileFlags; - public uint dwFileOS; - public uint dwFileType; - public uint dwFileSubtype; - public uint dwFileDateMS; - public uint dwFileDateLS; - } - public struct ResidentName { /// diff --git a/libexeinfo/NE/Version.cs b/libexeinfo/NE/Version.cs index ce952d1..1f68b54 100644 --- a/libexeinfo/NE/Version.cs +++ b/libexeinfo/NE/Version.cs @@ -40,7 +40,7 @@ namespace libexeinfo /// Gets all the version resources from this instance /// /// The decoded version resources. - public List GetVersions() + List GetVersions() { return (from type in Resources.types where (type.id & 0x7FFF) == (int)ResourceTypes.RT_VERSION @@ -80,43 +80,43 @@ namespace libexeinfo /// File version. /// /// The file version. - public string FileVersion { get; set; } + public string FileVersion { get; private set; } /// /// Product version. /// /// The product version. - public string ProductVersion { get; set; } + public string ProductVersion { get; private set; } /// /// File flags. /// /// The file flags. - public VersionFileFlags FileFlags { get; set; } + public VersionFileFlags FileFlags { get; private set; } /// /// File operating system. /// /// The file operating system. - public VersionFileOS FileOS { get; set; } + public VersionFileOS FileOs { get; private set; } /// /// File type. /// /// The type of the file. - public VersionFileType FileType { get; set; } + public VersionFileType FileType { get; private set; } /// /// File subtype. /// /// The file subtype. - public VersionFileSubtype FileSubtype { get; set; } + public VersionFileSubtype FileSubtype { get; private set; } /// /// File date. /// /// The file date. - public DateTime FileDate { get; set; } + public DateTime FileDate { get; private set; } /// /// Resource name @@ -167,7 +167,7 @@ namespace libexeinfo void DecodeNode(VersionNode node, string parent, string grandparent) { - if(node.szName == FIXED_FILE_INFO_SIG) + if(node.szName == Consts.FixedFileInfoSig) { IntPtr infoPtr = Marshal.AllocHGlobal(node.cbData); Marshal.Copy(node.rgbData, 0, infoPtr, node.cbData); @@ -179,19 +179,19 @@ namespace libexeinfo ProductVersion = $"{(info.dwProductVersionMS & 0xFFFF0000) >> 16}.{info.dwProductVersionMS & 0xFFFF:D2}.{(info.dwProductVersionLS & 0xFFFF0000) >> 16}.{info.dwProductVersionLS & 0xFFFF}"; FileFlags = (VersionFileFlags)(info.dwFileFlags & info.dwFileFlagsMask); - FileOS = (VersionFileOS)info.dwFileOS; + FileOs = (VersionFileOS)info.dwFileOS; FileType = (VersionFileType)info.dwFileType; FileSubtype = (VersionFileSubtype)info.dwFileSubtype; FileDate = DateTime.FromFileTime(info.dwFileDateMS * 0x100000000 + info.dwFileDateLS); } - if(parent == STRING_FILE_INFO) + if(parent == Consts.StringFileInfo) { Dictionary strings = new Dictionary(); StringsByLanguage.Add(node.szName, strings); } - if(grandparent == STRING_FILE_INFO) + if(grandparent == Consts.StringFileInfo) if(StringsByLanguage.TryGetValue(parent, out Dictionary strings)) { Encoding encoding; @@ -206,121 +206,6 @@ namespace libexeinfo foreach(VersionNode n in node.children) DecodeNode(n, node.szName, parent); } - - /// - /// Converts a to string - /// - /// The string. - /// - /// - /// - public static string TypeToString(VersionFileType type) - { - switch(type) - { - case VersionFileType.VFT_APP: return "Application"; - case VersionFileType.VFT_DLL: return "Dynamic-link library"; - case VersionFileType.VFT_DRV: return "Device driver"; - case VersionFileType.VFT_FONT: return "Font"; - case VersionFileType.VFT_STATIC_LIB: return "Static-link library"; - case VersionFileType.VFT_UNKNOWN: return "Unknown"; - case VersionFileType.VFT_VXD: return "Virtual device"; - default: return $"Unknown type code {(uint)type}"; - } - } - - /// - /// Converts a to string, considering file type to be a driver - /// - /// The string. - /// - /// - /// - public static string DriverToString(VersionFileSubtype subtype) - { - switch(subtype) - { - case VersionFileSubtype.VFT2_DRV_COMM: return "Communications"; - case VersionFileSubtype.VFT2_DRV_DISPLAY: return "Display"; - case VersionFileSubtype.VFT2_DRV_INSTALLABLE: return "Installable"; - case VersionFileSubtype.VFT2_DRV_KEYBOARD: return "Keyboard"; - case VersionFileSubtype.VFT2_DRV_LANGUAGE: return "Language"; - case VersionFileSubtype.VFT2_DRV_MOUSE: return "Mouse"; - case VersionFileSubtype.VFT2_DRV_NETWORK: return "Network"; - case VersionFileSubtype.VFT2_DRV_PRINTER: return "Printer"; - case VersionFileSubtype.VFT2_DRV_SOUND: return "Sound"; - case VersionFileSubtype.VFT2_DRV_SYSTEM: return "System"; - case VersionFileSubtype.VFT2_DRV_VERSIONED_PRINTER: return "Versioned"; - case VersionFileSubtype.VFT2_UNKNOWN: return "Unknown"; - default: return $"Unknown type code {(uint)subtype}"; - } - } - - /// - /// Converts a to string, considering file type to be a font - /// - /// The string. - /// - /// - /// - public static string FontToString(VersionFileSubtype subtype) - { - switch(subtype) - { - case VersionFileSubtype.VFT2_FONT_RASTER: return "Raster"; - case VersionFileSubtype.VFT2_FONT_TRUETYPE: return "TrueType"; - case VersionFileSubtype.VFT2_FONT_VECTOR: return "Vector"; - case VersionFileSubtype.VFT2_UNKNOWN: return "Unknown"; - default: return $"Unknown type code {(uint)subtype}"; - } - } - - /// - /// Converts a to string - /// - /// The string. - /// - /// - /// - public static string OsToString(VersionFileOS os) - { - switch(os) - { - case VersionFileOS.VOS_DOS: return "DOS"; - case VersionFileOS.VOS_NT: return "Windows NT"; - case VersionFileOS.VOS_WINDOWS16: return "16-bit Windows"; - case VersionFileOS.VOS_WINDOWS32: return "32-bit Windows"; - case VersionFileOS.VOS_OS216: return "16-bit OS/2"; - case VersionFileOS.VOS_OS232: return "32-bit OS/2"; - case VersionFileOS.VOS_PM16: return "16-bit Presentation Manager"; - case VersionFileOS.VOS_PM32: return "32-bit Presentation Manager"; - case VersionFileOS.VOS_UNKNOWN: return "Unknown"; - case VersionFileOS.VOS_DOS_NT: return "DOS running under Windows NT"; - case VersionFileOS.VOS_DOS_WINDOWS16: return "16-bit Windows running under DOS"; - case VersionFileOS.VOS_DOS_WINDOWS32: return "32-bit Windows running under DOS"; - case VersionFileOS.VOS_DOS_PM16: return "16-bit Presentation Manager running under DOS"; - case VersionFileOS.VOS_DOS_PM32: return "32-bit Presentation Manager running under DOS"; - case VersionFileOS.VOS_NT_WINDOWS16: return "16-bit Windows running under Windows NT"; - case VersionFileOS.VOS_NT_WINDOWS32: return "32-bit Windows running under Windows NT"; - case VersionFileOS.VOS_NT_PM16: - return "16-bit Presentation Manager running under Windows NT"; - case VersionFileOS.VOS_NT_PM32: - return "32-bit Presentation Manager running under Windows NT"; - case VersionFileOS.VOS_OS216_WINDOWS16: return "16-bit Windows running under 16-bit OS/2"; - case VersionFileOS.VOS_OS216_WINDOWS32: return "32-bit Windows running under 16-bit OS/2"; - case VersionFileOS.VOS_OS216_PM16: - return "16-bit Presentation Manager running under 16-bit OS/2"; - case VersionFileOS.VOS_OS216_PM32: - return "32-bit Presentation Manager running under 16-bit OS/2"; - case VersionFileOS.VOS_OS232_WINDOWS16: return "16-bit Windows running under 32-bit OS/2"; - case VersionFileOS.VOS_OS232_WINDOWS32: return "32-bit Windows running under 32-bit OS/2"; - case VersionFileOS.VOS_OS232_PM16: - return "16-bit Presentation Manager running under 32-bit OS/2"; - case VersionFileOS.VOS_OS232_PM32: - return "32-bit Presentation Manager running under 32-bit OS/2"; - default: return $"Unknown OS code {(uint)os}"; - } - } } } } \ No newline at end of file diff --git a/libexeinfo/PE/Consts.cs b/libexeinfo/PE/Consts.cs index 53f3a05..095f1d1 100644 --- a/libexeinfo/PE/Consts.cs +++ b/libexeinfo/PE/Consts.cs @@ -32,15 +32,7 @@ namespace libexeinfo /// Portable Executable signature, "PE\0\0" /// const ushort SIGNATURE = 0x00004550; - const ushort PE32 = COFF.ZMAGIC; - internal const ushort PE32Plus = 0x20b; - /// - /// Signature for a - /// - const string FIXED_FILE_INFO_SIG = "VS_VERSION_INFO"; - /// - /// Signature for list of name=value strings inside a version resource - /// - const string STRING_FILE_INFO = "StringFileInfo"; + const ushort PE32 = COFF.ZMAGIC; + internal const ushort PE32Plus = 0x20b; } } \ No newline at end of file diff --git a/libexeinfo/PE/Enums.cs b/libexeinfo/PE/Enums.cs index 8312899..d9d4e83 100644 --- a/libexeinfo/PE/Enums.cs +++ b/libexeinfo/PE/Enums.cs @@ -25,13 +25,14 @@ // THE SOFTWARE. using System; + // ReSharper disable InconsistentNaming namespace libexeinfo { public partial class PE { - public enum DebugTypes : uint + enum DebugTypes : uint { /// /// Unknown value, ignored by all tools. @@ -52,7 +53,7 @@ namespace libexeinfo /// debugger how to interpret non-standard stack frames, which use the /// EBP register for a purpose other than as a frame pointer. /// - IMAGE_DEBUG_TYPE_FPO = 3, + IMAGE_DEBUG_TYPE_FPO = 3, IMAGE_DEBUG_TYPE_MISC = 4, IMAGE_DEBUG_TYPE_EXCEPTION = 5, IMAGE_DEBUG_TYPE_FIXUP = 6, @@ -65,7 +66,7 @@ namespace libexeinfo /// The following values are defined for the DllCharacteristics field of the optional header. /// [Flags] - public enum DllCharacteristics : ushort + enum DllCharacteristics : ushort { /// /// Image can handle a high entropy 64-bit virtual address space. @@ -117,7 +118,7 @@ namespace libexeinfo /// The following values defined for the Subsystem field of the optional header determine which Windows subsystem (if /// any) is required to run the image. /// - public enum Subsystems : ushort + enum Subsystems : ushort { /// /// An unknown subsystem @@ -176,92 +177,5 @@ namespace libexeinfo /// IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 } - - /// - /// Version file flags. - /// - [Flags] - public enum VersionFileFlags : uint - { - VS_FF_DEBUG = 0x00000001, - VS_FF_INFOINFERRED = 0x00000010, - VS_FF_PATCHED = 0x00000004, - VS_FF_PRERELEASE = 0x00000002, - VS_FF_PRIVATEBUILD = 0x00000008, - VS_FF_SPECIALBUILD = 0x00000020 - } - - /// - /// Version file operating system. - /// - public enum VersionFileOS : uint - { - VOS_DOS = 0x00010000, - VOS_NT = 0x00040000, - VOS_WINDOWS16 = 0x00000001, - VOS_WINDOWS32 = 0x00000004, - VOS_OS216 = 0x00020000, - VOS_OS232 = 0x00030000, - VOS_PM16 = 0x00000002, - VOS_PM32 = 0x00000003, - VOS_UNKNOWN = 0x00000000, - - // Combinations, some have no sense - VOS_DOS_NT = 0x00050000, - VOS_DOS_WINDOWS16 = 0x00010001, - VOS_DOS_WINDOWS32 = 0x00010004, - VOS_DOS_PM16 = 0x00010002, - VOS_DOS_PM32 = 0x00010003, - VOS_NT_WINDOWS16 = 0x00040001, - VOS_NT_WINDOWS32 = 0x00040004, - VOS_NT_PM16 = 0x00040002, - VOS_NT_PM32 = 0x00040003, - VOS_OS216_WINDOWS16 = 0x00020001, - VOS_OS216_WINDOWS32 = 0x00020004, - VOS_OS216_PM16 = 0x00020002, - VOS_OS216_PM32 = 0x00020003, - VOS_OS232_WINDOWS16 = 0x00030001, - VOS_OS232_WINDOWS32 = 0x00030004, - VOS_OS232_PM16 = 0x00030002, - VOS_OS232_PM32 = 0x00030003 - } - - /// - /// Version file subtype. - /// - public enum VersionFileSubtype : uint - { - VFT2_UNKNOWN = 0x00000000, - // Drivers - VFT2_DRV_COMM = 0x0000000A, - VFT2_DRV_DISPLAY = 0x00000004, - VFT2_DRV_INSTALLABLE = 0x00000008, - VFT2_DRV_KEYBOARD = 0x00000002, - VFT2_DRV_LANGUAGE = 0x00000003, - VFT2_DRV_MOUSE = 0x00000005, - VFT2_DRV_NETWORK = 0x00000006, - VFT2_DRV_PRINTER = 0x00000001, - VFT2_DRV_SOUND = 0x00000009, - VFT2_DRV_SYSTEM = 0x00000007, - VFT2_DRV_VERSIONED_PRINTER = 0x0000000C, - // Fonts - VFT2_FONT_RASTER = 0x00000001, - VFT2_FONT_TRUETYPE = 0x00000003, - VFT2_FONT_VECTOR = 0x00000002 - } - - /// - /// Version file type. - /// - public enum VersionFileType : uint - { - VFT_APP = 0x00000001, - VFT_DLL = 0x00000002, - VFT_DRV = 0x00000003, - VFT_FONT = 0x00000004, - VFT_STATIC_LIB = 0x00000007, - VFT_UNKNOWN = 0x00000000, - VFT_VXD = 0x00000005 - } - } + } } \ No newline at end of file diff --git a/libexeinfo/PE/Structs.cs b/libexeinfo/PE/Structs.cs index c427816..5e1494d 100644 --- a/libexeinfo/PE/Structs.cs +++ b/libexeinfo/PE/Structs.cs @@ -24,7 +24,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System; using System.Runtime.InteropServices; using static libexeinfo.COFF; @@ -453,45 +452,24 @@ namespace libexeinfo public class ResourceNode { - public uint id; - public string name; public ResourceNode[] children; - public byte[] data; - public int level; + public byte[] data; + public uint id; + public int level; + public string name; } - + /// /// Node in a version resource /// class VersionNode { - public ushort wValueLength; - public ushort wLength; - public ushort wType; public VersionNode[] children; public byte[] rgbData; public string szName; - } - - /// - /// Fixed file version info - /// - [StructLayout(LayoutKind.Sequential)] - public struct FixedFileInfo - { - public uint dwSignature; - public uint dwStrucVersion; - public uint dwFileVersionMS; - public uint dwFileVersionLS; - public uint dwProductVersionMS; - public uint dwProductVersionLS; - public uint dwFileFlagsMask; - public uint dwFileFlags; - public uint dwFileOS; - public uint dwFileType; - public uint dwFileSubtype; - public uint dwFileDateMS; - public uint dwFileDateLS; + public ushort wLength; + public ushort wType; + public ushort wValueLength; } } } \ No newline at end of file diff --git a/libexeinfo/PE/Version.cs b/libexeinfo/PE/Version.cs index 103d7ad..e2b05b2 100644 --- a/libexeinfo/PE/Version.cs +++ b/libexeinfo/PE/Version.cs @@ -40,7 +40,7 @@ namespace libexeinfo /// Gets all the version resources from this instance /// /// The decoded version resources. - public List GetVersions() + List GetVersions() { return (from node in WindowsResourcesRoot.children where node.id == (uint)ResourceTypes.RT_VERSION @@ -67,7 +67,7 @@ namespace libexeinfo StringsByLanguage = new Dictionary>(); - VersionNode root = GetNode(data, 0, out int rootLength); + VersionNode root = GetNode(data, 0, out int _); DecodeNode(root, null, null); } @@ -81,37 +81,37 @@ namespace libexeinfo /// File version. /// /// The file version. - public string FileVersion { get; set; } + public string FileVersion { get; private set; } /// /// Product version. /// /// The product version. - public string ProductVersion { get; set; } + public string ProductVersion { get; private set; } /// /// File flags. /// /// The file flags. - public VersionFileFlags FileFlags { get; set; } + public VersionFileFlags FileFlags { get; private set; } /// /// File operating system. /// /// The file operating system. - public VersionFileOS FileOS { get; set; } + public VersionFileOS FileOs { get; private set; } /// /// File type. /// /// The type of the file. - public VersionFileType FileType { get; set; } + public VersionFileType FileType { get; private set; } /// /// File subtype. /// /// The file subtype. - public VersionFileSubtype FileSubtype { get; set; } + public VersionFileSubtype FileSubtype { get; private set; } /// /// File date. @@ -131,8 +131,8 @@ namespace libexeinfo VersionNode node = new VersionNode { - wLength = BitConverter.ToUInt16(data, startPosition + nodeLength), - wValueLength = BitConverter.ToUInt16(data, startPosition + nodeLength + 2), + wLength = BitConverter.ToUInt16(data, startPosition + nodeLength), + wValueLength = BitConverter.ToUInt16(data, startPosition + nodeLength + 2), wType = BitConverter.ToUInt16(data, startPosition + nodeLength + 4) }; nodeLength += 6; @@ -140,16 +140,15 @@ namespace libexeinfo MemoryStream nameMs = new MemoryStream(); while(true) { - if(data[startPosition + nodeLength] == 0 && data[startPosition + nodeLength + 1] == 0) - break; - - nameMs.WriteByte(data[startPosition + nodeLength]); + if(data[startPosition + nodeLength] == 0 && data[startPosition + nodeLength + 1] == 0) break; + + nameMs.WriteByte(data[startPosition + nodeLength]); nameMs.WriteByte(data[startPosition + nodeLength + 1]); - nodeLength+=2; + nodeLength += 2; } - node.szName = Encoding.Unicode.GetString(nameMs.ToArray()); - nodeLength+=2; + node.szName = Encoding.Unicode.GetString(nameMs.ToArray()); + nodeLength += 2; if(nodeLength % 4 > 0) nodeLength += 4 - nodeLength % 4; @@ -177,7 +176,7 @@ namespace libexeinfo void DecodeNode(VersionNode node, string parent, string grandparent) { - if(node.szName == FIXED_FILE_INFO_SIG) + if(node.szName == Consts.FixedFileInfoSig) { IntPtr infoPtr = Marshal.AllocHGlobal(node.wValueLength); Marshal.Copy(node.rgbData, 0, infoPtr, node.wValueLength); @@ -189,143 +188,26 @@ namespace libexeinfo ProductVersion = $"{(info.dwProductVersionMS & 0xFFFF0000) >> 16}.{info.dwProductVersionMS & 0xFFFF:D2}.{(info.dwProductVersionLS & 0xFFFF0000) >> 16}.{info.dwProductVersionLS & 0xFFFF}"; FileFlags = (VersionFileFlags)(info.dwFileFlags & info.dwFileFlagsMask); - FileOS = (VersionFileOS)info.dwFileOS; + FileOs = (VersionFileOS)info.dwFileOS; FileType = (VersionFileType)info.dwFileType; FileSubtype = (VersionFileSubtype)info.dwFileSubtype; FileDate = DateTime.FromFileTime(info.dwFileDateMS * 0x100000000 + info.dwFileDateLS); } - if(parent == STRING_FILE_INFO) + if(parent == Consts.StringFileInfo) { Dictionary strings = new Dictionary(); StringsByLanguage.Add(node.szName, strings); } - if(grandparent == STRING_FILE_INFO) + if(grandparent == Consts.StringFileInfo) if(StringsByLanguage.TryGetValue(parent, out Dictionary strings)) - { strings.Add(node.szName, Encoding.Unicode.GetString(node.rgbData)); - } if(node.children == null) return; foreach(VersionNode n in node.children) DecodeNode(n, node.szName, parent); } - - /// - /// Converts a to string - /// - /// The string. - /// - /// - /// - public static string TypeToString(VersionFileType type) - { - switch(type) - { - case VersionFileType.VFT_APP: return "Application"; - case VersionFileType.VFT_DLL: return "Dynamic-link library"; - case VersionFileType.VFT_DRV: return "Device driver"; - case VersionFileType.VFT_FONT: return "Font"; - case VersionFileType.VFT_STATIC_LIB: return "Static-link library"; - case VersionFileType.VFT_UNKNOWN: return "Unknown"; - case VersionFileType.VFT_VXD: return "Virtual device"; - default: return $"Unknown type code {(uint)type}"; - } - } - - /// - /// Converts a to string, considering file type to be a driver - /// - /// The string. - /// - /// - /// - public static string DriverToString(VersionFileSubtype subtype) - { - switch(subtype) - { - case VersionFileSubtype.VFT2_DRV_COMM: return "Communications"; - case VersionFileSubtype.VFT2_DRV_DISPLAY: return "Display"; - case VersionFileSubtype.VFT2_DRV_INSTALLABLE: return "Installable"; - case VersionFileSubtype.VFT2_DRV_KEYBOARD: return "Keyboard"; - case VersionFileSubtype.VFT2_DRV_LANGUAGE: return "Language"; - case VersionFileSubtype.VFT2_DRV_MOUSE: return "Mouse"; - case VersionFileSubtype.VFT2_DRV_NETWORK: return "Network"; - case VersionFileSubtype.VFT2_DRV_PRINTER: return "Printer"; - case VersionFileSubtype.VFT2_DRV_SOUND: return "Sound"; - case VersionFileSubtype.VFT2_DRV_SYSTEM: return "System"; - case VersionFileSubtype.VFT2_DRV_VERSIONED_PRINTER: return "Versioned"; - case VersionFileSubtype.VFT2_UNKNOWN: return "Unknown"; - default: return $"Unknown type code {(uint)subtype}"; - } - } - - /// - /// Converts a to string, considering file type to be a font - /// - /// The string. - /// - /// - /// - public static string FontToString(VersionFileSubtype subtype) - { - switch(subtype) - { - case VersionFileSubtype.VFT2_FONT_RASTER: return "Raster"; - case VersionFileSubtype.VFT2_FONT_TRUETYPE: return "TrueType"; - case VersionFileSubtype.VFT2_FONT_VECTOR: return "Vector"; - case VersionFileSubtype.VFT2_UNKNOWN: return "Unknown"; - default: return $"Unknown type code {(uint)subtype}"; - } - } - - /// - /// Converts a to string - /// - /// The string. - /// - /// - /// - public static string OsToString(VersionFileOS os) - { - switch(os) - { - case VersionFileOS.VOS_DOS: return "DOS"; - case VersionFileOS.VOS_NT: return "Windows NT"; - case VersionFileOS.VOS_WINDOWS16: return "16-bit Windows"; - case VersionFileOS.VOS_WINDOWS32: return "32-bit Windows"; - case VersionFileOS.VOS_OS216: return "16-bit OS/2"; - case VersionFileOS.VOS_OS232: return "32-bit OS/2"; - case VersionFileOS.VOS_PM16: return "16-bit Presentation Manager"; - case VersionFileOS.VOS_PM32: return "32-bit Presentation Manager"; - case VersionFileOS.VOS_UNKNOWN: return "Unknown"; - case VersionFileOS.VOS_DOS_NT: return "DOS running under Windows NT"; - case VersionFileOS.VOS_DOS_WINDOWS16: return "16-bit Windows running under DOS"; - case VersionFileOS.VOS_DOS_WINDOWS32: return "32-bit Windows running under DOS"; - case VersionFileOS.VOS_DOS_PM16: return "16-bit Presentation Manager running under DOS"; - case VersionFileOS.VOS_DOS_PM32: return "32-bit Presentation Manager running under DOS"; - case VersionFileOS.VOS_NT_WINDOWS16: return "16-bit Windows running under Windows NT"; - case VersionFileOS.VOS_NT_WINDOWS32: return "32-bit Windows running under Windows NT"; - case VersionFileOS.VOS_NT_PM16: - return "16-bit Presentation Manager running under Windows NT"; - case VersionFileOS.VOS_NT_PM32: - return "32-bit Presentation Manager running under Windows NT"; - case VersionFileOS.VOS_OS216_WINDOWS16: return "16-bit Windows running under 16-bit OS/2"; - case VersionFileOS.VOS_OS216_WINDOWS32: return "32-bit Windows running under 16-bit OS/2"; - case VersionFileOS.VOS_OS216_PM16: - return "16-bit Presentation Manager running under 16-bit OS/2"; - case VersionFileOS.VOS_OS216_PM32: - return "32-bit Presentation Manager running under 16-bit OS/2"; - case VersionFileOS.VOS_OS232_WINDOWS16: return "16-bit Windows running under 32-bit OS/2"; - case VersionFileOS.VOS_OS232_WINDOWS32: return "32-bit Windows running under 32-bit OS/2"; - case VersionFileOS.VOS_OS232_PM16: - return "16-bit Presentation Manager running under 32-bit OS/2"; - case VersionFileOS.VOS_OS232_PM32: - return "32-bit Presentation Manager running under 32-bit OS/2"; - default: return $"Unknown OS code {(uint)os}"; - } - } } } } \ No newline at end of file diff --git a/libexeinfo/Windows/Consts.cs b/libexeinfo/Windows/Consts.cs new file mode 100644 index 0000000..7765e91 --- /dev/null +++ b/libexeinfo/Windows/Consts.cs @@ -0,0 +1,40 @@ +// +// Consts.cs +// +// Author: +// Natalia Portillo +// +// Copyright (c) 2017-2018 Copyright © Claunia.com +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace libexeinfo.Windows +{ + public static class Consts + { + /// + /// Signature for a + /// + public const string FixedFileInfoSig = "VS_VERSION_INFO"; + /// + /// Signature for list of name=value strings inside a version resource + /// + public const string StringFileInfo = "StringFileInfo"; + } +} \ No newline at end of file diff --git a/libexeinfo/Windows/Enums.cs b/libexeinfo/Windows/Enums.cs index f0b266a..adbad9e 100644 --- a/libexeinfo/Windows/Enums.cs +++ b/libexeinfo/Windows/Enums.cs @@ -24,6 +24,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using System; + namespace libexeinfo.Windows { /// @@ -73,4 +75,91 @@ namespace libexeinfo.Windows CmykRle8 = 12, CmykRle4 = 13 } + + /// + /// Version file flags. + /// + [Flags] + public enum VersionFileFlags : uint + { + VS_FF_DEBUG = 0x00000001, + VS_FF_INFOINFERRED = 0x00000010, + VS_FF_PATCHED = 0x00000004, + VS_FF_PRERELEASE = 0x00000002, + VS_FF_PRIVATEBUILD = 0x00000008, + VS_FF_SPECIALBUILD = 0x00000020 + } + + /// + /// Version file operating system. + /// + public enum VersionFileOS : uint + { + VOS_DOS = 0x00010000, + VOS_NT = 0x00040000, + VOS_WINDOWS16 = 0x00000001, + VOS_WINDOWS32 = 0x00000004, + VOS_OS216 = 0x00020000, + VOS_OS232 = 0x00030000, + VOS_PM16 = 0x00000002, + VOS_PM32 = 0x00000003, + VOS_UNKNOWN = 0x00000000, + + // Combinations, some have no sense + VOS_DOS_NT = 0x00050000, + VOS_DOS_WINDOWS16 = 0x00010001, + VOS_DOS_WINDOWS32 = 0x00010004, + VOS_DOS_PM16 = 0x00010002, + VOS_DOS_PM32 = 0x00010003, + VOS_NT_WINDOWS16 = 0x00040001, + VOS_NT_WINDOWS32 = 0x00040004, + VOS_NT_PM16 = 0x00040002, + VOS_NT_PM32 = 0x00040003, + VOS_OS216_WINDOWS16 = 0x00020001, + VOS_OS216_WINDOWS32 = 0x00020004, + VOS_OS216_PM16 = 0x00020002, + VOS_OS216_PM32 = 0x00020003, + VOS_OS232_WINDOWS16 = 0x00030001, + VOS_OS232_WINDOWS32 = 0x00030004, + VOS_OS232_PM16 = 0x00030002, + VOS_OS232_PM32 = 0x00030003 + } + + /// + /// Version file subtype. + /// + public enum VersionFileSubtype : uint + { + VFT2_UNKNOWN = 0x00000000, + // Drivers + VFT2_DRV_COMM = 0x0000000A, + VFT2_DRV_DISPLAY = 0x00000004, + VFT2_DRV_INSTALLABLE = 0x00000008, + VFT2_DRV_KEYBOARD = 0x00000002, + VFT2_DRV_LANGUAGE = 0x00000003, + VFT2_DRV_MOUSE = 0x00000005, + VFT2_DRV_NETWORK = 0x00000006, + VFT2_DRV_PRINTER = 0x00000001, + VFT2_DRV_SOUND = 0x00000009, + VFT2_DRV_SYSTEM = 0x00000007, + VFT2_DRV_VERSIONED_PRINTER = 0x0000000C, + // Fonts + VFT2_FONT_RASTER = 0x00000001, + VFT2_FONT_TRUETYPE = 0x00000003, + VFT2_FONT_VECTOR = 0x00000002 + } + + /// + /// Version file type. + /// + public enum VersionFileType : uint + { + VFT_APP = 0x00000001, + VFT_DLL = 0x00000002, + VFT_DRV = 0x00000003, + VFT_FONT = 0x00000004, + VFT_STATIC_LIB = 0x00000007, + VFT_UNKNOWN = 0x00000000, + VFT_VXD = 0x00000005 + } } \ No newline at end of file diff --git a/libexeinfo/Windows/Structs.cs b/libexeinfo/Windows/Structs.cs index 2041e0a..a739c3b 100644 --- a/libexeinfo/Windows/Structs.cs +++ b/libexeinfo/Windows/Structs.cs @@ -60,4 +60,25 @@ namespace libexeinfo.Windows public int[] Pixels; public uint Width; } + + /// + /// Fixed file version info + /// + [StructLayout(LayoutKind.Sequential)] + public struct FixedFileInfo + { + public uint dwSignature; + public uint dwStrucVersion; + public uint dwFileVersionMS; + public uint dwFileVersionLS; + public uint dwProductVersionMS; + public uint dwProductVersionLS; + public uint dwFileFlagsMask; + public uint dwFileFlags; + public uint dwFileOS; + public uint dwFileType; + public uint dwFileSubtype; + public uint dwFileDateMS; + public uint dwFileDateLS; + } } \ No newline at end of file diff --git a/libexeinfo/Windows/Version.cs b/libexeinfo/Windows/Version.cs new file mode 100644 index 0000000..75b4974 --- /dev/null +++ b/libexeinfo/Windows/Version.cs @@ -0,0 +1,140 @@ +// +// Version.cs +// +// Author: +// Natalia Portillo +// +// Copyright (c) 2017-2018 Copyright © Claunia.com +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace libexeinfo.Windows +{ + public static class Version + { + /// + /// Converts a to string + /// + /// The string. + /// + /// + /// + public static string TypeToString(VersionFileType type) + { + switch(type) + { + case VersionFileType.VFT_APP: return "Application"; + case VersionFileType.VFT_DLL: return "Dynamic-link library"; + case VersionFileType.VFT_DRV: return "Device driver"; + case VersionFileType.VFT_FONT: return "Font"; + case VersionFileType.VFT_STATIC_LIB: return "Static-link library"; + case VersionFileType.VFT_UNKNOWN: return "Unknown"; + case VersionFileType.VFT_VXD: return "Virtual device"; + default: return $"Unknown type code {(uint)type}"; + } + } + + /// + /// Converts a to string, considering file type to be a driver + /// + /// The string. + /// + /// + /// + public static string DriverToString(VersionFileSubtype subtype) + { + switch(subtype) + { + case VersionFileSubtype.VFT2_DRV_COMM: return "Communications"; + case VersionFileSubtype.VFT2_DRV_DISPLAY: return "Display"; + case VersionFileSubtype.VFT2_DRV_INSTALLABLE: return "Installable"; + case VersionFileSubtype.VFT2_DRV_KEYBOARD: return "Keyboard"; + case VersionFileSubtype.VFT2_DRV_LANGUAGE: return "Language"; + case VersionFileSubtype.VFT2_DRV_MOUSE: return "Mouse"; + case VersionFileSubtype.VFT2_DRV_NETWORK: return "Network"; + case VersionFileSubtype.VFT2_DRV_PRINTER: return "Printer"; + case VersionFileSubtype.VFT2_DRV_SOUND: return "Sound"; + case VersionFileSubtype.VFT2_DRV_SYSTEM: return "System"; + case VersionFileSubtype.VFT2_DRV_VERSIONED_PRINTER: return "Versioned"; + case VersionFileSubtype.VFT2_UNKNOWN: return "Unknown"; + default: return $"Unknown type code {(uint)subtype}"; + } + } + + /// + /// Converts a to string, considering file type to be a font + /// + /// The string. + /// + /// + /// + public static string FontToString(VersionFileSubtype subtype) + { + switch(subtype) + { + case VersionFileSubtype.VFT2_FONT_RASTER: return "Raster"; + case VersionFileSubtype.VFT2_FONT_TRUETYPE: return "TrueType"; + case VersionFileSubtype.VFT2_FONT_VECTOR: return "Vector"; + case VersionFileSubtype.VFT2_UNKNOWN: return "Unknown"; + default: return $"Unknown type code {(uint)subtype}"; + } + } + + /// + /// Converts a to string + /// + /// The string. + /// + /// + /// + public static string OsToString(VersionFileOS os) + { + switch(os) + { + case VersionFileOS.VOS_DOS: return "DOS"; + case VersionFileOS.VOS_NT: return "Windows NT"; + case VersionFileOS.VOS_WINDOWS16: return "16-bit Windows"; + case VersionFileOS.VOS_WINDOWS32: return "32-bit Windows"; + case VersionFileOS.VOS_OS216: return "16-bit OS/2"; + case VersionFileOS.VOS_OS232: return "32-bit OS/2"; + case VersionFileOS.VOS_PM16: return "16-bit Presentation Manager"; + case VersionFileOS.VOS_PM32: return "32-bit Presentation Manager"; + case VersionFileOS.VOS_UNKNOWN: return "Unknown"; + case VersionFileOS.VOS_DOS_NT: return "DOS running under Windows NT"; + case VersionFileOS.VOS_DOS_WINDOWS16: return "16-bit Windows running under DOS"; + case VersionFileOS.VOS_DOS_WINDOWS32: return "32-bit Windows running under DOS"; + case VersionFileOS.VOS_DOS_PM16: return "16-bit Presentation Manager running under DOS"; + case VersionFileOS.VOS_DOS_PM32: return "32-bit Presentation Manager running under DOS"; + case VersionFileOS.VOS_NT_WINDOWS16: return "16-bit Windows running under Windows NT"; + case VersionFileOS.VOS_NT_WINDOWS32: return "32-bit Windows running under Windows NT"; + case VersionFileOS.VOS_NT_PM16: return "16-bit Presentation Manager running under Windows NT"; + case VersionFileOS.VOS_NT_PM32: return "32-bit Presentation Manager running under Windows NT"; + case VersionFileOS.VOS_OS216_WINDOWS16: return "16-bit Windows running under 16-bit OS/2"; + case VersionFileOS.VOS_OS216_WINDOWS32: return "32-bit Windows running under 16-bit OS/2"; + case VersionFileOS.VOS_OS216_PM16: return "16-bit Presentation Manager running under 16-bit OS/2"; + case VersionFileOS.VOS_OS216_PM32: return "32-bit Presentation Manager running under 16-bit OS/2"; + case VersionFileOS.VOS_OS232_WINDOWS16: return "16-bit Windows running under 32-bit OS/2"; + case VersionFileOS.VOS_OS232_WINDOWS32: return "32-bit Windows running under 32-bit OS/2"; + case VersionFileOS.VOS_OS232_PM16: return "16-bit Presentation Manager running under 32-bit OS/2"; + case VersionFileOS.VOS_OS232_PM32: return "32-bit Presentation Manager running under 32-bit OS/2"; + default: return $"Unknown OS code {(uint)os}"; + } + } + } +} \ No newline at end of file diff --git a/libexeinfo/libexeinfo.csproj b/libexeinfo/libexeinfo.csproj index c2e57a4..7d2c3f4 100644 --- a/libexeinfo/libexeinfo.csproj +++ b/libexeinfo/libexeinfo.csproj @@ -105,9 +105,11 @@ + +