Esempio n. 1
0
        internal static async Task <VarFileInfo> LoadAsync(Stream stream)
        {
            var count = 3 * sizeof(ushort);
            var len   = await stream.ReadUInt16Async().ConfigureAwait(false);

            var valLen = await stream.ReadUInt16Async().ConfigureAwait(false);

            var type = await stream.ReadUInt16Async().ConfigureAwait(false);

            var key = await stream.ReadUnicodeStringAsync().ConfigureAwait(false);

            count += (key.Length + 1) * sizeof(ushort);
            count += await VersionResource.AlignWordBoundaryAsync(stream).ConfigureAwait(false);

            var variables = new List <VersionVariable>();
            var data      = await stream.ReadBytesAsync(len - count).ConfigureAwait(false);

            using (var mem = new MemoryStream(data))
            {
                while (mem.Position < mem.Length)
                {
                    var variable = await LoadVariableAsync(mem).ConfigureAwait(false);

                    variables.Add(variable);
                }
            }

            var result = new VarFileInfo(key, variables.ToArray());

            return(result);
        }
Esempio n. 2
0
 internal VersionInfo(VersionResource resource, uint languageId, FixedFileInfo fixedInfo, StringFileInfo stringInfo, VarFileInfo varInfo)
 {
     Resource  = resource;
     Language  = languageId;
     Fixed     = fixedInfo;
     Strings   = stringInfo;
     Variables = varInfo;
 }
Esempio n. 3
0
        public async Task <VersionInfo> GetInfoAsync(ResourceLanguage language)
        {
            var buffer = await GetBytesAsync(language).ConfigureAwait(false);

            using (var mem = new MemoryStream(buffer))
            {
                var count = 3 * sizeof(ushort);

                await mem.ReadBytesAsync(count).ConfigureAwait(false);

                var key = await mem.ReadUnicodeStringAsync().ConfigureAwait(false);

                if (key != "VS_VERSION_INFO")
                {
                    throw new Exception("Invalid file version information.");
                }

                await AlignWordBoundaryAsync(mem).ConfigureAwait(false);

                var ffiData = await mem.ReadStructAsync <VS_FIXEDFILEINFO>().ConfigureAwait(false);

                var fixedFileInfo = new FixedFileInfo(ffiData);

                await AlignWordBoundaryAsync(mem).ConfigureAwait(false);

                var stringFileInfo = await StringFileInfo.LoadAsync(mem).ConfigureAwait(false);

                await AlignWordBoundaryAsync(mem).ConfigureAwait(false);

                var varFileInfo = await VarFileInfo.LoadAsync(mem).ConfigureAwait(false);

                var info = new VersionInfo(this, language, fixedFileInfo, stringFileInfo, varFileInfo);

                return(info);
            }
        }