当前位置: 首页>>代码示例>>C#>>正文


C# IReader.SeekTo方法代码示例

本文整理汇总了C#中IReader.SeekTo方法的典型用法代码示例。如果您正苦于以下问题:C# IReader.SeekTo方法的具体用法?C# IReader.SeekTo怎么用?C# IReader.SeekTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IReader的用法示例。


在下文中一共展示了IReader.SeekTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CacheFileVersionInfo

        public CacheFileVersionInfo(IReader reader)
        {
            reader.SeekTo(0x4);
            Version = reader.ReadInt32();

            if (Version == SecondGenVersion)
            {
                Engine = EngineType.SecondGeneration;

                // Read second-generation build string
                reader.SeekTo(0x12C);
                BuildString = reader.ReadAscii();
            }
            else if (Version >= ThirdGenVersion)
            {
                Engine = EngineType.ThirdGeneration;

                // Read third-generation build string
                reader.SeekTo(0x11C);
                BuildString = reader.ReadAscii();
            }

            if (string.IsNullOrWhiteSpace(BuildString))
            {
                // Assume it's a first-generation build
                Engine = EngineType.FirstGeneration;
                Version = 0;

                // Read first-generation build string
                reader.SeekTo(0x40);
                BuildString = reader.ReadAscii();
            }
        }
开发者ID:Nibre,项目名称:Assembly,代码行数:33,代码来源:CacheFileVersionInfo.cs

示例2: GetTagAddress

        public static uint GetTagAddress(IReader memoryReader, ushort index, uint exeBase)
        {
            //uint newcountaddr = MaxTagCountAddress;
            // Read the tag count and validate the tag index
            memoryReader.SeekTo(MaxTagCountAddress + exeBase);
            var maxIndex = memoryReader.ReadUInt16();
            if (index >= maxIndex)
                return 0;

            // Read the tag index table to get the index of the tag in the address table
            memoryReader.SeekTo(TagIndexArrayPointerAddress + exeBase);
            var tagIndexTableAddress = memoryReader.ReadUInt32();
            if (tagIndexTableAddress == 0)
                return 0;
            memoryReader.SeekTo(tagIndexTableAddress + index * 4);
            var addressIndex = memoryReader.ReadInt32();
            if (addressIndex < 0)
                return 0;

            // Read the tag's address in the address table
            memoryReader.SeekTo(TagAddressArrayPointerAddress + exeBase);
            var tagAddressTableAddress = memoryReader.ReadUInt32();
            if (tagAddressTableAddress == 0)
                return 0;
            memoryReader.SeekTo(tagAddressTableAddress + addressIndex * 4);
            return memoryReader.ReadUInt32();
        }
开发者ID:t3hm00kz,项目名称:Assembly,代码行数:27,代码来源:EldoradoRTEProvider.cs

示例3: ThirdGenVersionInfo

        public ThirdGenVersionInfo(IReader reader)
        {
            reader.SeekTo(0x4);
            Version = reader.ReadInt32();

            reader.SeekTo(0x11C);
            BuildString = reader.ReadAscii();
        }
开发者ID:YxCREATURExY,项目名称:Assembly,代码行数:8,代码来源:ThirdGenVersionInfo.cs

示例4: LoadCacheFile

        /// <summary>
        ///     Loads a cache file from a stream.
        /// </summary>
        /// <param name="reader">The stream to read from.</param>
        /// <param name="engineDb">The engine database to use to process the cache file.</param>
        /// <param name="engineInfo">On output, this will contain the cache file's engine description.</param>
        /// <returns>The cache file that was loaded.</returns>
        /// <exception cref="ArgumentException">Thrown if the cache file is invalid.</exception>
        /// <exception cref="NotSupportedException">Thrown if the cache file's target engine is not supported.</exception>
        public static ICacheFile LoadCacheFile(IReader reader, EngineDatabase engineDb, out EngineDescription engineInfo)
        {
            // Set the reader's endianness based upon the file's header magic
            reader.SeekTo(0);
            byte[] headerMagic = reader.ReadBlock(4);
            reader.Endianness = DetermineCacheFileEndianness(headerMagic);

            // Load engine version info
            var version = new CacheFileVersionInfo(reader);
            if (version.Engine != EngineType.SecondGeneration && version.Engine != EngineType.ThirdGeneration)
                throw new NotSupportedException("Engine not supported");

            // Load build info
            engineInfo = engineDb.FindEngineByVersion(version.BuildString);
            if (engineInfo == null)
                throw new NotSupportedException("Engine version \"" + version.BuildString + "\" not supported");

            // Load the cache file depending upon the engine version
            switch (version.Engine)
            {
                case EngineType.SecondGeneration:
                    return new SecondGenCacheFile(reader, engineInfo, version.BuildString);

                case EngineType.ThirdGeneration:
                    return new ThirdGenCacheFile(reader, engineInfo, version.BuildString);

                default:
                    throw new NotSupportedException("Engine not supported");
            }
        }
开发者ID:ChadSki,项目名称:Assembly,代码行数:39,代码来源:CacheFileLoader.cs

示例5: LoadStrings

        public LocaleTable LoadStrings(IReader reader)
        {
            LocaleTable result = new LocaleTable(this);

            byte[] stringData = ReadLocaleData(reader);
            using (EndianReader stringReader = new EndianReader(new MemoryStream(stringData), Endian.BigEndian))
            {
                reader.SeekTo(LocaleIndexTableLocation.AsOffset());

                // Read each locale
                for (int i = 0; i < StringCount; i++)
                {
                    // Read the offset and stringID
                    StringID id;
                    int offset;
                    ReadLocalePointer(reader, out id, out offset);

                    if (offset >= stringReader.Length)
                        break; // Bad table - bail out so we don't end up in a huge memory-hogging loop

                    stringReader.SeekTo(offset);
                    string locale = stringReader.ReadUTF8();
                    result.Strings.Add(new Locale(id, locale));
                    //result.Add(ReplaceSymbols(locale));
                }
            }
            return result;
        }
开发者ID:YxCREATURExY,项目名称:Assembly,代码行数:28,代码来源:ThirdGenLanguage.cs

示例6: Load

        /// <summary>
        ///     Loads the strings into the StringTable
        /// </summary>
        private void Load(IReader reader)
        {
            reader.SeekTo(0);
            // Read the header
            var stringCount = reader.ReadInt32();  // int32 string count
            var dataSize = reader.ReadInt32();     // int32 string data size

            // Read string offsets
            var stringOffsets = new int[stringCount];
            for (var i = 0; i < stringCount; i++)
                stringOffsets[i] = reader.ReadInt32();

            // Seek to each offset and read each string
            var dataOffset = reader.BaseStream.Position;
            foreach (var offset in stringOffsets)
            {
                if (offset == -1 || offset >= dataSize)
                {
                    _strings.Add("");
                    continue;
                }
                reader.BaseStream.Position = dataOffset + offset;
                _strings.Add(reader.ReadAscii());
            }
        }
开发者ID:t3hm00kz,项目名称:Assembly,代码行数:28,代码来源:FourthGenIndexedStringTable.cs

示例7: DetectAlignment

        static void DetectAlignment(ICacheFile cacheFile, IReader reader, int baseOffset, XElement baseElement, Dictionary<XElement, int> alignsByElem, HashSet<uint> visitedTagBlocks)
        {
            // Loop through all tag blocks and data references
            foreach (var elem in baseElement.Elements())
            {
                var isTagBlock = (elem.Name.LocalName == "reflexive");
                var isDataRef = (elem.Name.LocalName == "dataRef");
                if (!isTagBlock && !isDataRef)
                    continue;

                // Read the address
                var offset = ParseInteger(elem.Attribute("offset").Value);
                var count = 0;
                var entrySize = 0;
                if (isTagBlock)
                {
                    reader.SeekTo(baseOffset + offset);
                    count = reader.ReadInt32();
                    entrySize = ParseInteger(elem.Attribute("entrySize").Value);
                }
                else
                {
                    reader.SeekTo(baseOffset + offset + 0xC);
                }

                var addr = reader.ReadUInt32();
                if (addr == 0)
                    continue;
                if (isTagBlock && !cacheFile.MetaArea.ContainsBlockPointer(addr, count * entrySize))
                    continue;

                // Only update the alignment if it's less than the currently-guessed alignment
                int oldAlign;
                var newAlign = GetAlignment(addr);
                if (!alignsByElem.TryGetValue(elem, out oldAlign) || newAlign < oldAlign)
                    alignsByElem[elem] = newAlign;

                // If it's a tag block, then recurse into it
                if (isTagBlock && !visitedTagBlocks.Contains(addr))
                {
                    visitedTagBlocks.Add(addr);
                    var blockBaseOffset = cacheFile.MetaArea.PointerToOffset(addr);
                    for (var i = 0; i < count; i++)
                        DetectAlignment(cacheFile, reader, blockBaseOffset + i * entrySize, elem, alignsByElem, visitedTagBlocks);
                }
            }
        }
开发者ID:ChadSki,项目名称:Assembly,代码行数:47,代码来源:Program.cs

示例8: LoadCacheFile

        /// <summary>
        ///     Loads a cache file from a stream.
        /// </summary>
        /// <param name="reader">The stream to read from.</param>
        /// <param name="engineDb">The engine database to use to process the cache file.</param>
        /// <param name="engineInfo">On output, this will contain the cache file's engine description.</param>
        /// <returns>The cache file that was loaded.</returns>
        /// <exception cref="ArgumentException">Thrown if the cache file is invalid.</exception>
        /// <exception cref="NotSupportedException">Thrown if the cache file's target engine is not supported.</exception>
        public static ICacheFile LoadCacheFile(IReader map_reader, IReader tag_reader, IReader string_reader, out string tagnamesLocation, string filesLocation, EngineDatabase engineDb, out EngineDescription engineInfo)
        {
            // Set the reader's endianness based upon the file's header magic
            map_reader.SeekTo(0);
            byte[] headerMagic = map_reader.ReadBlock(4);
            Endian engianess = DetermineCacheFileEndianness(headerMagic);
            map_reader.Endianness = engianess;
            if(tag_reader != null) tag_reader.Endianness = engianess;
            if (tag_reader != null) string_reader.Endianness = engianess;

            // Load engine version info
            var version = new CacheFileVersionInfo(map_reader);
            if (version.Engine != EngineType.SecondGeneration && version.Engine != EngineType.ThirdGeneration && version.Engine != EngineType.FourthGeneration)
                throw new NotSupportedException("Engine not supported");

            // Load build info
            engineInfo = engineDb.FindEngineByVersion(version.BuildString);
            if (engineInfo == null)
                throw new NotSupportedException("Engine version \"" + version.BuildString + "\" not supported");

            // Load the cache file depending upon the engine version
            switch (version.Engine)
            {
                case EngineType.SecondGeneration:
                    tagnamesLocation = null;
                    return new SecondGenCacheFile(map_reader, engineInfo, version.BuildString);

                case EngineType.ThirdGeneration:
                    tagnamesLocation = null;
                    return new ThirdGenCacheFile(map_reader, engineInfo, version.BuildString);

                case EngineType.FourthGeneration:
                    if (tag_reader == null || tag_reader.BaseStream.Length == 0) throw new Exception("Can't load version 4 cache file without tags file. Please make sure that tags.dat is in the same folder at the map file.");
                    if (string_reader == null || tag_reader.BaseStream.Length == 0) throw new Exception("Can't load version 4 cache file without strings file. Please make sure that tags.dat is in the same folder at the map file.");

                    // Load the tag names csv file
                    string tagnames_filename = "tagnames_" + version.BuildString + ".csv";
                    string tagnames_location = filesLocation != null ? filesLocation + tagnames_filename : "";
                    if (!File.Exists(tagnames_location)) tagnames_location = "tagnames\\" + tagnames_filename;
                    if (!File.Exists(tagnames_location)) tagnames_location = null;

                    FileStream tagnamesFileStream = tagnames_location != null ? TryInitFilestream(tagnames_location) : null;
                    EndianReader tagnames_reader = null;
                    if (tagnamesFileStream != null)
                    {
                        tagnames_reader = new EndianReader(tagnamesFileStream, Endian.BigEndian);
                        tagnames_reader.Endianness = engianess;
                    }

                    tagnamesLocation = tagnames_location;

                    FourthGenCacheFile cache_file = new FourthGenCacheFile(map_reader, tag_reader, string_reader, tagnames_reader, engineInfo, version.BuildString);
                    tagnamesFileStream.Close();
                    return cache_file;

                default:
                    throw new NotSupportedException("Engine not supported");
            }
        }
开发者ID:no1dead,项目名称:Assembly,代码行数:68,代码来源:CacheFileLoader.cs

示例9: ReadOffsets

 private int[] ReadOffsets(IReader reader, Pointer indexTableLocation, int count)
 {
     reader.SeekTo(indexTableLocation.AsOffset());
     int[] offsets = new int[count];
     for (int i = 0; i < count; i++)
         offsets[i] = reader.ReadInt32();
     return offsets;
 }
开发者ID:YxCREATURExY,项目名称:Assembly,代码行数:8,代码来源:ThirdGenStringTable.cs

示例10: DecryptData

        private IReader DecryptData(IReader reader, Pointer dataLocation, int tableSize, AESKey key)
        {
            // Round the table size to an AES block size
            tableSize = (tableSize + 0xF) & ~0xF;

            reader.SeekTo(dataLocation.AsOffset());
            byte[] data = reader.ReadBlock(tableSize);
            if (key != null)
                data = AES.Decrypt(data, key.Key, key.IV);
            return new EndianReader(new MemoryStream(data), Endian.BigEndian);
        }
开发者ID:YxCREATURExY,项目名称:Assembly,代码行数:11,代码来源:ThirdGenStringTable.cs

示例11: LoadScenarioBspMeta

		public IScenarioBSP LoadScenarioBspMeta(ITag sbspTag, IReader reader)
		{
			if (sbspTag.MetaLocation == null || sbspTag.Class == null || sbspTag.Class.Magic != SbspMagic)
				throw new ArgumentException("sbspTag does not point to metadata for a scenario BSP");
			if (!SupportsScenarioBsps)
				throw new NotSupportedException("Scenario BSP metadata loading is not supported for the cache file's engine.");

			reader.SeekTo(sbspTag.MetaLocation.AsOffset());
			var layout = _buildInfo.Layouts.GetLayout("scenario structure bsp");
			var values = StructureReader.ReadStructure(reader, layout);
			return new FourthGenScenarioBSP(values, reader, _metaArea, _buildInfo);
		}
开发者ID:t3hm00kz,项目名称:Assembly,代码行数:12,代码来源:FourthGenResourceMetaLoader.cs

示例12: LoadRenderModelMeta

		public IRenderModel LoadRenderModelMeta(ITag modeTag, IReader reader)
		{
			if (modeTag.MetaLocation == null || modeTag.Class == null || modeTag.Class.Magic != ModeMagic)
				throw new ArgumentException("modeTag does not point to metadata for a renderable model");
			if (!SupportsRenderModels)
				throw new NotSupportedException("Render model metadata loading is not supported for the cache file's engine.");

			reader.SeekTo(modeTag.MetaLocation.AsOffset());
			var layout = _buildInfo.Layouts.GetLayout("render model");
			var values = StructureReader.ReadStructure(reader, layout);
			return new FourthGenRenderModel(values, reader, _metaArea, _buildInfo);
		}
开发者ID:t3hm00kz,项目名称:Assembly,代码行数:12,代码来源:FourthGenResourceMetaLoader.cs

示例13: LoadSoundMeta

		public ISound LoadSoundMeta(ITag sndTag, IReader reader)
		{
			if (sndTag.MetaLocation == null || sndTag.Class == null || sndTag.Class.Magic != SndMagic)
				throw new ArgumentException("sndTag");
			if (!SupportsSounds)
				throw new NotSupportedException("Sound metadata loading is not supported for the cache file's engine.");

			reader.SeekTo(sndTag.MetaLocation.AsOffset());
			var layout = _buildInfo.Layouts.GetLayout("sound");
			var values = StructureReader.ReadStructure(reader, layout);
			return new FourthGenSound(values, reader, _metaArea, _buildInfo);
		}
开发者ID:t3hm00kz,项目名称:Assembly,代码行数:12,代码来源:FourthGenResourceMetaLoader.cs

示例14: ReadShader

		/// <summary>
		/// Reads a shader from a stream.
		/// </summary>
		/// <param name="reader">The stream to read from. It should be positioned at the beginning of the shader pointer.</param>
		/// <param name="type">The type of shader to read.</param>
		/// <returns>
		/// The shader that was read, or <c>null</c> if reading failed.
		/// </returns>
		public IShader ReadShader(IReader reader, ShaderType type)
		{
			var info = ReadShaderInfo(reader, type);
			if (info == null || info.CodeDataSize == 0)
				return null;
			
			// Read the code data
			var dataOffset = _cacheFile.MetaArea.PointerToOffset(info.DataAddress);
			reader.SeekTo(dataOffset + info.ConstantDataSize); // Code data comes after the constant data
			var microcode = reader.ReadBlock((int)info.CodeDataSize);

			return new ThirdGenShader(type, microcode, info.DatabasePath);
		}
开发者ID:t3hm00kz,项目名称:Assembly,代码行数:21,代码来源:ThirdGenShaderStreamer.cs

示例15: ReadClasses

        private static List<ITagClass> ReadClasses(IReader reader, uint classTableOffset, int numClasses, BuildInformation buildInfo)
        {
            StructureLayout layout = buildInfo.GetLayout("class entry");

            List<ITagClass> result = new List<ITagClass>();
            reader.SeekTo(classTableOffset);
            for (int i = 0; i < numClasses; i++)
            {
                StructureValueCollection values = StructureReader.ReadStructure(reader, layout);
                result.Add(new SecondGenTagClass(values));
            }
            return result;
        }
开发者ID:iBotPeaches,项目名称:Assembly,代码行数:13,代码来源:SecondGenTagTable.cs


注:本文中的IReader.SeekTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。