예제 #1
0
        private static Dictionary <String, String> FfiToDict(VSFixedFileInfo ffi)
        {
            Dictionary <String, String> d = new Dictionary <String, String>();

            d.Add("Signature", GetUInt32String(ffi.Signature));
            d.Add("StrucVersion", GetUInt32String(ffi.StrucVersion));
            d.Add("FileVersionMS", GetUInt32String(ffi.FileVersionMS));
            d.Add("FileVersionLS", GetUInt32String(ffi.FileVersionLS));
            d.Add("FileVersion", null);
            d.Add("ProductVersionMS", GetUInt32String(ffi.ProductVersionMS));
            d.Add("ProductVersionLS", GetUInt32String(ffi.ProductVersionLS));
            d.Add("ProductVersion", null);

            d.Add("FileFlagsMask", GetUInt32String(ffi.FileFlagsMask));
            d.Add("FileFlags", ffi.FileFlags.ToString());
            d.Add("FileOS", ffi.FileOS.ToString());
            d.Add("FileType", ffi.FileType.ToString());
            d.Add("FileSubType", GetUInt32String(ffi.FileSubType));
            d.Add("FileSubTypeDriver", ffi.FileSubTypeDriver.ToString());
            d.Add("FileSubTypeFont", ffi.FileSubTypeFont.ToString());
            d.Add("FileDateMS", GetUInt32String(ffi.FileDateMS));
            d.Add("FileDateLS", GetUInt32String(ffi.FileDateLS));
            d.Add("FileDate", null);

            return(d);
        }
예제 #2
0
        private static Dictionary <string, string> FfiToDict(VSFixedFileInfo ffi)
        {
            var d = new Dictionary <string, string>
            {
                { "Signature", GetUInt32String(ffi.Signature) },
                { "StrucVersion", GetUInt32String(ffi.StrucVersion) },
                { "FileVersionMS", GetUInt32String(ffi.FileVersionMS) },
                { "FileVersionLS", GetUInt32String(ffi.FileVersionLS) },
                { "FileVersion", null },
                { "ProductVersionMS", GetUInt32String(ffi.ProductVersionMS) },
                { "ProductVersionLS", GetUInt32String(ffi.ProductVersionLS) },
                { "ProductVersion", null },
                { "FileFlagsMask", GetUInt32String(ffi.FileFlagsMask) },
                { "FileFlags", ffi.FileFlags.ToString() },
                { "FileOS", ffi.FileOS.ToString() },
                { "FileType", ffi.FileType.ToString() },
                { "FileSubType", GetUInt32String(ffi.FileSubType) },
                { "FileSubTypeDriver", ffi.FileSubTypeDriver.ToString() },
                { "FileSubTypeFont", ffi.FileSubTypeFont.ToString() },
                { "FileDateMS", GetUInt32String(ffi.FileDateMS) },
                { "FileDateLS", GetUInt32String(ffi.FileDateLS) },
                { "FileDate", null }
            };


            return(d);
        }
예제 #3
0
        private static VersionItem RecurseItem(VersionItemMode mode, BinaryReader rdr)
        {
            Int64 initPos = rdr.BaseStream.Position;

            VersionItem item = new VersionItem(mode);

            item.Length      = rdr.ReadUInt16();
            item.ValueLength = rdr.ReadUInt16();
            item.Type        = rdr.ReadUInt16();
            item.Key         = GetKey(mode, rdr, out item._mode);

            rdr.Align4();

            mode = item.Mode;

            List <VersionItem> children = new List <VersionItem>();

            while (rdr.BaseStream.Position < initPos + item.Length)
            {
                switch (mode)
                {
                case Mode.Root:

                    if (item.Value == null)
                    {
                        Byte[] ffiBytes = rdr.ReadBytes(item.ValueLength);                                   // this is where FixedFileInfo goes
                        /*Byte[] padding2 = */ rdr.Align4();

                        if (ffiBytes.Length >= 52)                                  // 52 == 0x34

                        {
                            VSFixedFileInfo ffi = new VSFixedFileInfo(ffiBytes);

                            if (ffi.Signature != 0xFEEF04BD)
                            {
                                throw new InvalidOperationException("Unrecognised VS_VERSIONINFO Signature");
                            }

                            Dictionary <String, String> ffiDict = FfiToDict(ffi);

                            item.Value = ffiDict;
                        }
                        else
                        {
                            throw new InvalidOperationException("Unexpected VS_FIXEDFILEINFO length");
                        }
                    }

                    goto default;

                case Mode.String:

                    Byte[] bytes = rdr.ReadBytes(item.ValueLength * 2);
                    String s     = Encoding.Unicode.GetString(bytes.SubArray(0, bytes.Length - 2));                            // miss out the null terminator
                    item.Value = s;

                    break;

                case Mode.Var:

                    Byte[] data = rdr.ReadBytes(item.ValueLength);                               // wValueLength = size in bytes
                    item.Value = data;

                    // data is a DWORD array 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.
                    // ms-help://MS.MSDNQTR.v90.en/winui/winui/windowsuserinterface/resources/versioninformation/versioninformationreference/versioninformationstructures/var.htm

                    break;

                default:
                    VersionItem child = RecurseItem(GetNextMode(mode), rdr);
                    children.Add(child);

                    break;
                }

                // the reader was corrupted before entering the third String of the first StringTable of the StringFileInfo
                // so let's see if padding here helps

                rdr.Align4();
            }

            rdr.Align4();

            item.Children = children.ToArray();

            return(item);
        }