Пример #1
0
        private static DateTime GetFileDate(VS_FIXEDFILEINFO info)
        {
            var value  = Utils.MakeUInt64(info.dwFileDateMS, info.dwFileDateLS);
            var result = DateTime.FromFileTime(value.ToInt64());

            return(result);
        }
Пример #2
0
        private static FileVersion GetProductVersion(VS_FIXEDFILEINFO info)
        {
            var major = Utils.HiWord(info.dwProductVersionMS);
            var minor = Utils.LoWord(info.dwProductVersionMS);
            var build = Utils.HiWord(info.dwProductVersionLS);
            var priv  = Utils.LoWord(info.dwProductVersionLS);

            return(new FileVersion(major, minor, build, priv));
        }
Пример #3
0
        private static FontFileSubType GetFontFileSubType(VS_FIXEDFILEINFO info)
        {
            var fileType = (FileType)info.dwFileType;

            if (fileType != FileType.Font)
            {
                return(FontFileSubType.Unknown);
            }

            return((FontFileSubType)info.dwFileSubtype);
        }
Пример #4
0
        private static DriverFileSubType GetDriverFileSubType(VS_FIXEDFILEINFO info)
        {
            var fileType = (FileType)info.dwFileType;

            if (fileType != FileType.Driver)
            {
                return(DriverFileSubType.Unknown);
            }

            return((DriverFileSubType)info.dwFileSubtype);
        }
Пример #5
0
 internal FixedFileInfo(VS_FIXEDFILEINFO info)
 {
     FileVersion    = GetFileVersion(info);
     ProductVersion = GetProductVersion(info);
     FileDate       = GetFileDate(info);
     FileOS         = (FileOS)info.dwFileOS;
     FileType       = (FileType)info.dwFileType;
     DriverSubType  = GetDriverFileSubType(info);
     FontSubType    = GetFontFileSubType(info);
     Flags          = GetFileFlags(info);
 }
Пример #6
0
            /// <summary>
            /// Creates a default Windows VS_FIXEDFILEINFO structure.
            /// </summary>
            /// <returns>A default Windows VS_FIXEDFILEINFO.</returns>
            public static VS_FIXEDFILEINFO GetWindowsDefault()
            {
                VS_FIXEDFILEINFO fixedFileInfo = new VS_FIXEDFILEINFO();

                fixedFileInfo.dwSignature     = Winver.VS_FFI_SIGNATURE;
                fixedFileInfo.dwStrucVersion  = Winver.VS_FFI_STRUCVERSION;
                fixedFileInfo.dwFileFlagsMask = Winver.VS_FFI_FILEFLAGSMASK;
                fixedFileInfo.dwFileOS        = (uint)Winver.FileOs.VOS__WINDOWS32;
                fixedFileInfo.dwFileSubtype   = (uint)Winver.FileSubType.VFT2_UNKNOWN;
                fixedFileInfo.dwFileType      = (uint)Winver.FileType.VFT_DLL;
                return(fixedFileInfo);
            }
Пример #7
0
        private static VersionInfo GetVersionInfo(DumpModule module)
        {
            MINIDUMP_MODULE  raw     = module.Raw;
            VS_FIXEDFILEINFO version = raw.VersionInfo;
            int minor = (ushort)version.dwFileVersionMS;
            int major = (ushort)(version.dwFileVersionMS >> 16);
            int patch = (ushort)version.dwFileVersionLS;
            int rev   = (ushort)(version.dwFileVersionLS >> 16);

            VersionInfo versionInfo = new VersionInfo(major, minor, rev, patch);

            return(versionInfo);
        }
        public static bool GetModuleVersionInfo(string moduleName, out VS_FIXEDFILEINFO info)
        {
            info = new VS_FIXEDFILEINFO();

            // Get verion info size
            uint dwHandle;
            uint cbVerInfo = GetFileVersionInfoSize(moduleName, out dwHandle);

            if (cbVerInfo == 0)
            {
                return(false);
            }

            // Allocate buffer for version info
            var verInfo = new byte[cbVerInfo];

            unsafe
            {
                fixed(byte *pVerInfo = verInfo)
                {
                    // Get version info
                    if (!GetFileVersionInfo(moduleName, dwHandle, cbVerInfo, (IntPtr)pVerInfo))
                    {
                        return(false);
                    }

                    // Find fixed file info
                    IntPtr pInfo;
                    uint   cbLen;

                    if (!VerQueryValue((IntPtr)pVerInfo, "\\", out pInfo, out cbLen))
                    {
                        return(false);
                    }

                    // Check correct length
                    if (cbLen < Marshal.SizeOf <VS_FIXEDFILEINFO>())
                    {
                        return(false);
                    }

                    // Return it
                    info = Marshal.PtrToStructure <VS_FIXEDFILEINFO>(pInfo);

                    return(true);
                }
            }
        }
Пример #9
0
        public HResult GetModuleVersionInformation(int index, out VS_FIXEDFILEINFO fileInfo)
        {
            int versionBufferSize = Marshal.SizeOf(typeof(VS_FIXEDFILEINFO));
            byte[] versionBuffer = new byte[versionBufferSize];
            fileInfo = default;

            fixed (byte* getVersionInfoPtr = s_getVersionInfo)
            fixed (byte* versionBufferPtr = versionBuffer)
            {
                HResult hr = VTable.GetModuleVersionInformation(Self, (uint)index, 0, getVersionInfoPtr, versionBufferPtr, (uint)versionBufferSize, null);
                if (hr == HResult.S_OK)
                {
                    fileInfo = *((VS_FIXEDFILEINFO*)versionBufferPtr);
                }
                return hr;
            }
        }
Пример #10
0
        public static VS_FIXEDFILEINFO parse_vf(BinaryReader fileBinaryReader)
        {
            VS_FIXEDFILEINFO vf = new VS_FIXEDFILEINFO();

            vf.dwSignature        = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwStrucVersion     = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwFileVersionMS    = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwFileVersionLS    = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwProductVersionMS = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwProductVersionLS = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwFileFlagsMask    = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwFileFlags        = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwFileOS           = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwFileType         = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwFileSubtype      = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwFileDateMS       = Helpers.ReadUInt32(fileBinaryReader);
            vf.dwFileDateLS       = Helpers.ReadUInt32(fileBinaryReader);
            return(vf);
        }
        public FixedFileInfo(VS_FIXEDFILEINFO nativeFfi)
        {
            Signature = nativeFfi.dwSignature;
            uint major = (nativeFfi.dwStrucVersion & 0xffff0000) >> 16;
            uint minor = (nativeFfi.dwStrucVersion & 0x0000ffff);

            StructureVersion = new Version((int)major, (int)minor, 0, 0);

            uint build, rev;

            major = (nativeFfi.dwFileVersionMS & 0xffff0000) >> 16;
            minor = (nativeFfi.dwFileVersionMS & 0x0000ffff);
            build = (nativeFfi.dwFileVersionLS & 0xffff0000) >> 16;
            rev   = (nativeFfi.dwFileVersionLS & 0x0000ffff);

            FileVersion = new Version((int)major,
                                      (int)minor,
                                      (int)build,
                                      (int)rev);

            major = (nativeFfi.dwProductVersionMS & 0xffff0000) >> 16;
            minor = (nativeFfi.dwProductVersionMS & 0x0000ffff);
            build = (nativeFfi.dwProductVersionLS & 0xffff0000) >> 16;
            rev   = (nativeFfi.dwProductVersionLS & 0x0000ffff);

            ProductVersion = new Version((int)major,
                                         (int)minor,
                                         (int)build,
                                         (int)rev);

            Flags       = (FixedFileInfoFlags)(nativeFfi.dwFileFlagsMask & (uint)nativeFfi.dwFileFlags);
            OS          = (FixedFileInfoOs)nativeFfi.dwFileOS;
            FileType    = (FixedFileInfoFileType)nativeFfi.dwFileType;
            FileSubType = nativeFfi.dwFileSubtype;

            long filetime = nativeFfi.dwFileDateLS + (((long)nativeFfi.dwFileDateMS) << 32);

            FileDate = DateTime.FromFileTime(filetime);
        } // end constructor
Пример #12
0
        private static FileFlags GetFileFlags(VS_FIXEDFILEINFO info)
        {
            var flags = FileFlags.None;

            if ((info.dwFileFlagsMask & info.dwFileFlags & (uint)FileFlags.Debug) == (uint)FileFlags.Debug)
            {
                flags &= FileFlags.Debug;
            }

            if ((info.dwFileFlagsMask & info.dwFileFlags & (uint)FileFlags.InfoInferred) == (uint)FileFlags.InfoInferred)
            {
                flags &= FileFlags.InfoInferred;
            }

            if ((info.dwFileFlagsMask & info.dwFileFlags & (uint)FileFlags.Patched) == (uint)FileFlags.Patched)
            {
                flags &= FileFlags.Patched;
            }

            if ((info.dwFileFlagsMask & info.dwFileFlags & (uint)FileFlags.PreRelease) == (uint)FileFlags.PreRelease)
            {
                flags &= FileFlags.PreRelease;
            }

            if ((info.dwFileFlagsMask & info.dwFileFlags & (uint)FileFlags.PrivateBuild) == (uint)FileFlags.PrivateBuild)
            {
                flags &= FileFlags.PrivateBuild;
            }

            if ((info.dwFileFlagsMask & info.dwFileFlags & (uint)FileFlags.SpecialBuild) == (uint)FileFlags.SpecialBuild)
            {
                flags &= FileFlags.SpecialBuild;
            }

            return(flags);
        }
Пример #13
0
 /// <summary>
 /// Creates a default Windows VS_FIXEDFILEINFO structure.
 /// </summary>
 /// <returns>A default Windows VS_FIXEDFILEINFO.</returns>
 public static VS_FIXEDFILEINFO GetWindowsDefault()
 {
     VS_FIXEDFILEINFO fixedFileInfo = new VS_FIXEDFILEINFO();
     fixedFileInfo.dwSignature = Winver.VS_FFI_SIGNATURE;
     fixedFileInfo.dwStrucVersion = Winver.VS_FFI_STRUCVERSION;
     fixedFileInfo.dwFileFlagsMask = Winver.VS_FFI_FILEFLAGSMASK;
     fixedFileInfo.dwFileOS = (uint) Winver.FileOs.VOS__WINDOWS32;
     fixedFileInfo.dwFileSubtype = (uint) Winver.FileSubType.VFT2_UNKNOWN;
     fixedFileInfo.dwFileType = (uint) Winver.FileType.VFT_DLL;
     return fixedFileInfo;
 }
Пример #14
0
 private static extern void MoveMemory( out VS_FIXEDFILEINFO x, uint src, int size );
Пример #15
0
 private static unsafe extern bool VerQueryValue(byte[] pBlock,
                                                 string pSubBlock, out VS_FIXEDFILEINFO* pValue, out uint len);