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


C# BinaryReader.ReadCString方法代码示例

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


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

示例1: BFCodeLabel

 internal BFCodeLabel(BinaryReader reader)
 {
     _name = reader.ReadCString(24);
     _offset = reader.ReadUInt32();
     int unused = reader.ReadInt32();
     _opcodeIndex = (int)_offset;
 }
开发者ID:TGEnigma,项目名称:Amicitia,代码行数:7,代码来源:BFCodeLabel.cs

示例2: WorldServerInfo

        public WorldServerInfo(BinaryReader reader)
        {
            Type = reader.ReadByte();
            locked = reader.ReadByte();
            Flags = reader.ReadByte();
            Name = reader.ReadCString();
            string address = reader.ReadCString();
            string[] tokens = address.Split(':');
            Address = tokens[0];
            Port = tokens.Length > 1 ? int.Parse(tokens[1]) : 8085;
            Population = reader.ReadSingle();
            load = reader.ReadByte();
            timezone = reader.ReadByte();
            unk1 = reader.ReadByte();

            if ((Flags & 4) != 0)
            {
                version_major = reader.ReadByte();
                version_minor = reader.ReadByte();
                version_bugfix = reader.ReadByte();
                build = reader.ReadUInt16();
            }

            unk2 = reader.ReadUInt16();
        }
开发者ID:Archives,项目名称:MangosClient,代码行数:25,代码来源:WorldServerInfo.cs

示例3: MARHandler

        public MARHandler(byte[] data, int i)
        {
            using (var ms = new MemoryStream(data))
            using (var br = new BinaryReader(ms, Encoding.ASCII))
            {
                int magic = br.ReadInt32();

                if (magic != 0x0052414d) // MAR\0
                {
                    throw new InvalidDataException("MARHandler: magic");
                }

                StreamWriter fs = new StreamWriter(String.Format("names{0}.txt", i + 1), false);

                int[] offsetsStart = new int[] { 0x1AC, 0x245FC, 0x356DC };
                int[] offsetsEnd = new int[] { 0x384, 0x5E0D8, 0x43078 };

                br.BaseStream.Position = offsetsStart[i];

                while (br.BaseStream.Position < offsetsEnd[i])
                {
                    fs.WriteLine("{0}", br.ReadCString());
                }

                fs.Close();
            }
        }
开发者ID:Ser0ja,项目名称:blte,代码行数:27,代码来源:MARHandler.cs

示例4: CreatureResponse

        public CreatureResponse(BinaryReader br)
        {
            entry = br.ReadInt32();

            for (int i = 0; i < 8; ++i)
                name[i] = br.ReadCString();

            subname = br.ReadCString();
            IconName = br.ReadCString();
            type_flags = br.ReadInt32();
            type_flags2 = br.ReadInt32();
            type = br.ReadInt32();
            family = br.ReadInt32();
            rank = br.ReadInt32();

            for (int i = 0; i < 2; ++i)
                KillCredit[i] = br.ReadInt32();

            for (int i = 0; i < 4; ++i)
                Modelid[i] = br.ReadInt32();

            ModHealth = br.ReadSingle();
            ModMana = br.ReadSingle();
            RacialLeader = br.ReadByte();

            for (int i = 0; i < 6; ++i)
                questItems[i] = br.ReadInt32();

            movementId = br.ReadInt32();
            expansionUnknown = br.ReadInt32();
        }
开发者ID:lan143,项目名称:Yuki,代码行数:31,代码来源:CreatureResponse.cs

示例5: InstallHandler

        public InstallHandler(BinaryReader stream, BackgroundWorkerEx worker)
        {
            worker?.ReportProgress(0, "Loading \"install\"...");

            stream.ReadBytes(2); // IN

            byte b1 = stream.ReadByte();
            byte b2 = stream.ReadByte();
            short numTags = stream.ReadInt16BE();
            int numFiles = stream.ReadInt32BE();

            int numMaskBytes = (numFiles + 7) / 8;

            List<InstallTag> Tags = new List<InstallTag>();

            for (int i = 0; i < numTags; i++)
            {
                InstallTag tag = new InstallTag();
                tag.Name = stream.ReadCString();
                tag.Type = stream.ReadInt16BE();

                byte[] bits = stream.ReadBytes(numMaskBytes);

                for (int j = 0; j < numMaskBytes; j++)
                    bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023);

                tag.Bits = new BitArray(bits);

                Tags.Add(tag);
            }

            for (int i = 0; i < numFiles; i++)
            {
                InstallEntry entry = new InstallEntry();
                entry.Name = stream.ReadCString();
                entry.MD5 = stream.ReadBytes(16);
                entry.Size = stream.ReadInt32BE();

                InstallData.Add(entry);

                entry.Tags = Tags.FindAll(tag => tag.Bits[i]);

                worker?.ReportProgress((int)((i + 1) / (float)numFiles * 100));
            }
        }
开发者ID:aeo24,项目名称:WoWMap,代码行数:45,代码来源:InstallHandler.cs

示例6: ReadStringsFromSection

 protected void ReadStringsFromSection(BinaryReader reader, ref string[] array, int stringLength)
 {
     using (BinaryReader sectionReader = new BinaryReader(ReadSection(reader)))
     {
         for (int i = 0; i < array.Length; i++)
         {
             array[i] = sectionReader.ReadCString(stringLength);
         }
     }
 }
开发者ID:TGEnigma,项目名称:Amicitia,代码行数:10,代码来源:MessageTableBase.cs

示例7: Parse

        public override void Parse()
        {
            var gr = Packet.CreateReader();

            var clientBuild = gr.ReadUInt32();
            var unk1 = gr.ReadUInt32();
            var account = gr.ReadCString();
            var unk2 = gr.ReadUInt32();
            var clientSeed = gr.ReadUInt32();
            var unk4 = gr.ReadUInt32();
            var unk5 = gr.ReadUInt32();
            var unk6 = gr.ReadUInt32();
            var unk3 = gr.ReadUInt64();
            var digest = gr.ReadBytes(20);

            AppendFormatLine("Client Build: {0}", clientBuild);
            AppendFormatLine("Unk1: {0}", unk1);
            AppendFormatLine("Account: {0}", account);
            AppendFormatLine("Unk2: {0}", unk2);
            AppendFormatLine("Client Seed: {0}", clientSeed);
            AppendFormatLine("Unk4: {0}", unk4);
            AppendFormatLine("Unk5: {0}", unk5);
            AppendFormatLine("Unk6: {0}", unk6);
            AppendFormatLine("Unk3: {0}", unk3);
            AppendFormatLine("Digest: {0}", digest.ToHexString());

            // addon info
            var addonData = gr.ReadBytes((int)gr.BaseStream.Length - (int)gr.BaseStream.Position);
            var decompressed = addonData.Decompress();

            AppendFormatLine("Decompressed addon data:");
            AppendFormatLine(decompressed.HexLike(0, decompressed.Length));

            using (var reader = new BinaryReader(new MemoryStream(decompressed)))
            {
                var count = reader.ReadUInt32();
                AppendFormatLine("Addons Count: {0}", count);
                for (var i = 0; i < count; ++i)
                {
                    var addonName = reader.ReadCString();
                    var enabled = reader.ReadByte();
                    var crc = reader.ReadUInt32();
                    var unk7 = reader.ReadUInt32();
                    AppendFormatLine("Addon {0}: name {1}, enabled {2}, crc {3}, unk7 {4}", i, addonName, enabled, crc, unk7);
                }

                var unk8 = reader.ReadUInt32();
                AppendFormatLine("Unk5: {0}", unk8);
            }
            // addon info end

            CheckPacket(gr);
        }
开发者ID:frostmourne,项目名称:toms_tools,代码行数:53,代码来源:AuthSession.cs

示例8: InstallHandler

        public InstallHandler(BinaryReader stream)
        {
            stream.ReadBytes(2); // IN

            byte b1 = stream.ReadByte();
            byte b2 = stream.ReadByte();
            short numTags = stream.ReadInt16BE();
            int numFiles = stream.ReadInt32BE();
            int numMaskBytes = (numFiles + 7) / 8;

            List<InstallTag> Tags = new List<InstallTag>();

            for (int i = 0; i < numTags; i++)
            {
                InstallTag tag = new InstallTag();
                tag.Name = stream.ReadCString();
                tag.Type = stream.ReadInt16BE();

                byte[] bits = stream.ReadBytes(numMaskBytes);

                for (int j = 0; j < numMaskBytes; j++)
                    bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023);

                tag.Bits = new BitArray(bits);
                Tags.Add(tag);
            }

            for (int i = 0; i < numFiles; i++)
            {
                InstallEntry entry = new InstallEntry();
                entry.Name = stream.ReadCString();
                entry.MD5 = stream.Read<MD5Hash>();
                entry.Size = stream.ReadInt32BE();

                InstallData.Add(entry);

                entry.Tags = Tags.FindAll(tag => tag.Bits[i]);
            }
        }
开发者ID:Kruithne,项目名称:W3DT,代码行数:39,代码来源:InstallHandler.cs

示例9: Read

 public bool Read(byte[] data)
 {
     using (MemoryStream ms = new MemoryStream(data))
     {
         using (BinaryReader br = new BinaryReader(new MemoryStream(data)))
         {
             GID = br.ReadInt32();
             Mapname = br.ReadCString(16);
             IP = new IPAddress(br.ReadBytes(4));
             Port = br.ReadInt16();
         }
     }
     return true;
 }
开发者ID:GodLesZ,项目名称:FimbulwinterClient,代码行数:14,代码来源:HC_Notify_Zonesvr.cs

示例10: Parse

        public override string Parse()
        {
            var gr = Packet.CreateReader();

            var clientBuild = gr.ReadUInt32();
            var unk1 = gr.ReadUInt32();
            var account = gr.ReadCString();
            var unk2 = gr.ReadUInt32();
            var clientSeed = gr.ReadUInt32();
            var unk3 = gr.ReadUInt64();
            var digest = gr.ReadBytes(20);

            AppendFormatLine("Client Build: {0}", clientBuild);
            AppendFormatLine("Unk1: {0}", unk1);
            AppendFormatLine("Account: {0}", account);
            AppendFormatLine("Unk2: {0}", unk2);
            AppendFormatLine("Client Seed: {0}", clientSeed);
            AppendFormatLine("Unk3: {0}", unk3);
            AppendFormatLine("Digest: {0}", Utility.ByteArrayToHexString(digest));

            // addon info
            var addonData = gr.ReadBytes((int)gr.BaseStream.Length - (int)gr.BaseStream.Position);
            var decompressed = Utility.Decompress(addonData);

            AppendFormatLine("Decompressed addon data:");
            AppendFormatLine(Utility.PrintHex(decompressed, 0, decompressed.Length));

            using (var reader = new BinaryReader(new MemoryStream(decompressed)))
            {
                var count = reader.ReadUInt32();
                AppendFormatLine("Addons Count: {0}", count);
                for (var i = 0; i < count; ++i)
                {
                    var addonName = reader.ReadCString();
                    var enabled = reader.ReadByte();
                    var crc = reader.ReadUInt32();
                    var unk4 = reader.ReadUInt32();
                    AppendFormatLine("Addon {0}: name {1}, enabled {2}, crc {3}, unk4 {4}", i, addonName, enabled, crc, unk4);
                }

                var unk5 = reader.ReadUInt32();
                AppendFormatLine("Unk5: {0}", unk5);
            }
            // addon info end

            CheckPacket(gr);

            return GetParsedString();
        }
开发者ID:a1ien,项目名称:WoWPacketViewer,代码行数:49,代码来源:AuthSession.cs

示例11: DownloadHandler

        public DownloadHandler(BinaryReader stream, BackgroundWorkerEx worker)
        {
            worker?.ReportProgress(0, "Loading \"download\"...");

            stream.Skip(2); // DL

            byte b1 = stream.ReadByte();
            byte b2 = stream.ReadByte();
            byte b3 = stream.ReadByte();

            int numFiles = stream.ReadInt32BE();

            short numTags = stream.ReadInt16BE();

            int numMaskBytes = (numFiles + 7) / 8;

            for (int i = 0; i < numFiles; i++)
            {
                MD5Hash key = stream.Read<MD5Hash>();

                //byte[] unk = stream.ReadBytes(0xA);
                stream.Skip(0xA);

                //var entry = new DownloadEntry() { Index = i, Unk = unk };
                var entry = new DownloadEntry() { Index = i };

                DownloadData.Add(key, entry);

                worker?.ReportProgress((int)((i + 1) / (float)numFiles * 100));
            }

            for (int i = 0; i < numTags; i++)
            {
                DownloadTag tag = new DownloadTag();
                string name = stream.ReadCString();
                tag.Type = stream.ReadInt16BE();

                byte[] bits = stream.ReadBytes(numMaskBytes);

                for (int j = 0; j < numMaskBytes; j++)
                    bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023);

                tag.Bits = new BitArray(bits);

                Tags.Add(name, tag);
            }
        }
开发者ID:WoW-Tools,项目名称:CASCExplorer,代码行数:47,代码来源:DownloadHandler.cs

示例12: Read

        // Private Methods
        private void Read(uint numNodes, BinaryReader reader)
        {
            string tag = reader.ReadCString(4);
            if (tag != TAG)
            {
                // Shouldn't happen
                throw new InvalidDataException("NDNM Tag mismatch!");
            }

            _length = reader.ReadUInt32();
            _names = new MDNodeName[numNodes];

            for (int i = 0; i < numNodes; i++)
            {
                _names[i].Name = reader.ReadCStringAligned();
                _names[i].ID = reader.ReadInt32();
            }
        }
开发者ID:TGEnigma,项目名称:Amicitia,代码行数:19,代码来源:NDNM.cs

示例13: GetTexture

		/// <summary>
		/// Returns an SM2 map texuture
		/// </summary>
		public BitmapSource GetTexture(Map map, int detail, UnitSync unitSync)
		{
			UnitSync.NativeMethods.RemoveAllArchives();
			UnitSync.NativeMethods.AddAllArchives(map.ArchiveName);
			ProgressChanged(this, new ProgressChangedEventArgs(0, "Extracting map"));
			var mapName = map.Name + ".smf";
			var smfFileData = unitSync.ReadVfsFile("maps\\" + mapName);
			var reader = new BinaryReader(new MemoryStream(smfFileData));
			var smfHeader = reader.ReadStruct<SMFHeader>();
			smfHeader.SelfCheck();
			var mapWidth = smfHeader.mapx;
			var mapHeight = smfHeader.mapy;

			reader.BaseStream.Position = smfHeader.tilesPtr;
			var mapTileHeader = reader.ReadStruct<MapTileHeader>();

			// get the tile files and the number of tiles they contain
			var tileFiles = new Dictionary<byte[], int>();
			for (var i = 0; i < mapTileHeader.numTileFiles; i++)
			{
				var numTiles = reader.ReadInt32();
				var tileFileData = unitSync.ReadVfsFile("maps\\" + reader.ReadCString());
				tileFiles.Add(tileFileData, numTiles);
			}

			// get the position of the tiles
			var mapUnitInTiles = Tiles.TileMipLevel1Size/smfHeader.texelPerSquare;
			var tilesX = smfHeader.mapx/mapUnitInTiles;
			var tilesY = smfHeader.mapy/mapUnitInTiles;
			var tileIndices = new int[tilesX*tilesY];
			for (var i = 0; i < tileIndices.Length; i++)
			{
				tileIndices[i] = reader.ReadInt32();
			}

			Tiles.ProgressChanged += (s, e) => ProgressChanged(this, e);

			UnitSync.NativeMethods.RemoveAllArchives();
			// load the tiles
			return Tiles.LoadTiles(tileFiles, tileIndices, tilesX, tilesY, detail);
		}
开发者ID:ParzivalX,项目名称:Zero-K-Infrastructure,代码行数:44,代码来源:SM2.cs

示例14: Read

        public static D3RootEntry Read(int type, BinaryReader s)
        {
            D3RootEntry e = new D3RootEntry();

            e.Type = type;
            e.MD5 = s.ReadBytes(16);

            if (type == 0 || type == 1) // has SNO id
            {
                e.SNO = s.ReadInt32();

                if (type == 1) // has file index
                    e.FileIndex = s.ReadInt32();
            }
            else // Named file
            {
                e.Name = s.ReadCString();
            }

            return e;
        }
开发者ID:hurricup,项目名称:CASCExplorer,代码行数:21,代码来源:D3RootHandler.cs

示例15: DownloadHandler

        public DownloadHandler(BinaryReader stream)
        {
            stream.Skip(2); // DL

            byte b1 = stream.ReadByte();
            byte b2 = stream.ReadByte();
            byte b3 = stream.ReadByte();

            int numFiles = stream.ReadInt32BE();

            short numTags = stream.ReadInt16BE();

            int numMaskBytes = numFiles / 8 + (numFiles % 8 > 0 ? 1 : 0);

            for (int i = 0; i < numFiles; i++)
            {
                byte[] key = stream.ReadBytes(0x10);
                byte[] unk = stream.ReadBytes(0xA);
                DownloadEntry entry = new DownloadEntry() { Index = i, Unk = unk };

                DownloadData.Add(key, entry);
            }

            for (int i = 0; i < numTags; i++)
            {
                DownloadTag tag = new DownloadTag();
                string name = stream.ReadCString();
                tag.Type = stream.ReadInt16BE();

                byte[] bits = stream.ReadBytes(numMaskBytes);

                for (int j = 0; j < numMaskBytes; j++)
                    bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023);

                tag.Bits = new BitArray(bits);

                Tags.Add(name, tag);
            }
        }
开发者ID:Kruithne,项目名称:W3DT,代码行数:39,代码来源:DownloadHandler.cs


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