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


C# EndianBinaryReader.ReadUInt64方法代码示例

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


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

示例1: ReadSegmentHeader

        //
        /// <summary>
        /// Read the segment header from the program header table
        /// </summary>
        private ELF_SegmentHeader ReadSegmentHeader(UInt32 index)
        {
            EndianBinaryReader ebr = new EndianBinaryReader(binFile, endian);
              ELF_SegmentHeader segmentHeader = new ELF_SegmentHeader();

              // Seek to the start of the section header in section header table
              binFile.Seek((Int64)(hdr.e_phentsize * index + hdr.e_phoff), SeekOrigin.Begin);

              //Debug.DebugMSG( "Segment["+index+"] = \n{");

              // Read segment type
              segmentHeader.p_type = (ELF_SegmentType) ebr.ReadUInt32();

              //Debug.DebugMSG(   "  Segment Type               : " + segmentHeader.p_type);

              if (ELF_FileClass.ELFCLASS_32 == hdr.e_ident.fileClass)
              {
            segmentHeader.p_offset      = (UInt64) ebr.ReadUInt32();
            segmentHeader.p_vaddr       = (UInt64) ebr.ReadUInt32();
            segmentHeader.p_paddr       = (UInt64) ebr.ReadUInt32();
            segmentHeader.p_filesz      = (UInt64) ebr.ReadUInt32();
            segmentHeader.p_memsz       = (UInt64) ebr.ReadUInt32();
            segmentHeader.p_flags       = (UInt32) ebr.ReadUInt32();
            segmentHeader.p_align       = (UInt64) ebr.ReadUInt32();

            /*
            Debug.DebugMSG( "  Segment Flags              : 0x" + segmentHeader.p_flags.ToString("X8"));
            Debug.DebugMSG( "  Segment Offset             : 0x" + segmentHeader.p_offset.ToString("X8"));
            Debug.DebugMSG( "  Segment Virtual Address    : 0x" + segmentHeader.p_vaddr.ToString("X8"));
            Debug.DebugMSG( "  Segment Physical Address   : 0x" + segmentHeader.p_paddr.ToString("X8"));
            Debug.DebugMSG( "  Segment File Size          : 0x" + segmentHeader.p_filesz.ToString("X8"));
            Debug.DebugMSG( "  Segment Memory Size        : 0x" + segmentHeader.p_memsz.ToString("X8"));
            Debug.DebugMSG( "  Segment Align              : 0x" + segmentHeader.p_align.ToString("X8"));
            */
              }
              else
              {
            segmentHeader.p_flags       = (UInt32) ebr.ReadUInt32();
            segmentHeader.p_offset      = (UInt64) ebr.ReadUInt64();
            segmentHeader.p_vaddr       = (UInt64) ebr.ReadUInt64();
            segmentHeader.p_paddr       = (UInt64) ebr.ReadUInt64();
            segmentHeader.p_filesz      = (UInt64) ebr.ReadUInt64();
            segmentHeader.p_memsz       = (UInt64) ebr.ReadUInt64();
            segmentHeader.p_align       = (UInt64) ebr.ReadUInt64();

            /*
            Debug.DebugMSG( "  Segment Flags              : 0x" + segmentHeader.p_flags.ToString("X8"));
            Debug.DebugMSG( "  Segment Offset             : 0x" + segmentHeader.p_offset.ToString("X16"));
            Debug.DebugMSG( "  Segment Virtual Address    : 0x" + segmentHeader.p_vaddr.ToString("X16"));
            Debug.DebugMSG( "  Segment Physical Address   : 0x" + segmentHeader.p_paddr.ToString("X16"));
            Debug.DebugMSG( "  Segment File Size          : 0x" + segmentHeader.p_filesz.ToString("X16"));
            Debug.DebugMSG( "  Segment Memory Size        : 0x" + segmentHeader.p_memsz.ToString("X16"));
            Debug.DebugMSG( "  Segment Align              : 0x" + segmentHeader.p_align.ToString("X16"));
            */
              }

              //Debug.DebugMSG(   "}" );

              return segmentHeader;
        }
开发者ID:sv99,项目名称:DVSDK,代码行数:64,代码来源:ELF.cs

示例2: ParseELFHeader

        public static ELF_Header ParseELFHeader(Stream fs)
        {
            ELF_Header hdr;

              // Read ELF Header
              fs.Seek(0, SeekOrigin.Begin);
              BinaryReader br = new BinaryReader(fs);

              hdr.e_ident.magic         = br.ReadBytes(4);
              hdr.e_ident.fileClass     = (ELF_FileClass) br.ReadByte();
              hdr.e_ident.dataEncoding  = (ELF_DataEncoding) br.ReadByte();
              hdr.e_ident.fileVersion   = (ELF_FileVersion) br.ReadByte();
              hdr.e_ident.osAbiID       = (ELF_OsAbiID) br.ReadByte();
              hdr.e_ident.abiVersion    = br.ReadByte();
              hdr.e_ident.pad           = br.ReadBytes(7);

              if ( (0x7F != hdr.e_ident.magic[0]) ||
               ('E' != hdr.e_ident.magic[1])  ||
               ('L' != hdr.e_ident.magic[2])  ||
               ('F' != hdr.e_ident.magic[3]) )
              {
            throw new Exception("ELF magic number not found. Not an ELF object file.");
              }

              if ( (ELF_FileClass.ELFCLASS_32 != hdr.e_ident.fileClass) &&
               (ELF_FileClass.ELFCLASS_64 != hdr.e_ident.fileClass) )
              {
            throw new Exception("Invalid ELF class. Not a valid ELF object file.");
              }

              if ( (ELF_DataEncoding.ELFDATA_2LSB != hdr.e_ident.dataEncoding) &&
               (ELF_DataEncoding.ELFDATA_2MSB != hdr.e_ident.dataEncoding) )
              {
            throw new Exception("Invalid ELF encoding. Not a valid ELF object file.");
              }

              if ( (ELF_FileVersion.ELFVER_CURRENT != hdr.e_ident.fileVersion) )
              {
            throw new Exception("Invalid ELF file version. Not a valid ELF object file.");
              }

              Debug.DebugMSG("ELF Identifier = \n{");
              Debug.DebugMSG("  magic[0]        : 0x" + hdr.e_ident.magic[0].ToString("X2"));
              Debug.DebugMSG("  magic[1]        : 0x" + hdr.e_ident.magic[1].ToString("X2"));
              Debug.DebugMSG("  magic[2]        : 0x" + hdr.e_ident.magic[2].ToString("X2"));
              Debug.DebugMSG("  magic[3]        : 0x" + hdr.e_ident.magic[3].ToString("X2"));
              Debug.DebugMSG("  fileClass       : " + hdr.e_ident.fileClass);
              Debug.DebugMSG("  dataEncoding    : " + hdr.e_ident.dataEncoding);
              Debug.DebugMSG("  fileVersion     : " + hdr.e_ident.fileVersion);
              Debug.DebugMSG("  OS/ABI ID       : " + hdr.e_ident.osAbiID);
              Debug.DebugMSG("  ABIVersion      : " + hdr.e_ident.abiVersion);
              Debug.DebugMSG("}\n\n");

              // Now that we have read and parsed the ELF Identifier array,
              // we have enough info to get the rest of the header and
              // correctly parse entire file
              Endian endian = (ELF_DataEncoding.ELFDATA_2LSB == hdr.e_ident.dataEncoding) ? Endian.LittleEndian : Endian.BigEndian;
              EndianBinaryReader ebr = new EndianBinaryReader(fs,endian);

              hdr.e_type          = (ELF_Type)    ebr.ReadUInt16();
              hdr.e_machine       = (ELF_Machine) ebr.ReadUInt16();
              hdr.e_version       = (ELF_Version) ebr.ReadUInt32();

              Debug.DebugMSG(   "ELF Type                               : " + hdr.e_type);
              Debug.DebugMSG(   "ELF Machine                            : " + hdr.e_machine);
              Debug.DebugMSG(   "ELF Version                            : " + hdr.e_version);

              // FIXME: Do we need this check? Is it a good idea?
              if (ELF_Type.ELFTYPE_EXEC != hdr.e_type)
              {
            throw new Exception("ELF file type is wrong - not a valid ELF executable.");
              }

              // Read entry point and program header and section header offsets
              // The size of these values is class dependent (32- or 64-bit)
              if (ELF_FileClass.ELFCLASS_32 == hdr.e_ident.fileClass)
              {
            hdr.e_entry       = (UInt64) ebr.ReadUInt32();
            hdr.e_phoff       = (UInt64) ebr.ReadUInt32();
            hdr.e_shoff       = (UInt64) ebr.ReadUInt32();

            Debug.DebugMSG( "ELF Entry Point                        : 0x" + hdr.e_entry.ToString("X8"));
            Debug.DebugMSG( "ELF Program Header Offset              : 0x" + hdr.e_phoff.ToString("X8"));
            Debug.DebugMSG( "ELF Section Header Table Offset        : 0x" + hdr.e_shoff.ToString("X8"));
              }
              else
              {
            hdr.e_entry       = ebr.ReadUInt64();
            hdr.e_phoff       = ebr.ReadUInt64();
            hdr.e_shoff       = ebr.ReadUInt64();

            Debug.DebugMSG( "ELF Entry Point                        : 0x" + hdr.e_entry.ToString("X16"));
            Debug.DebugMSG( "ELF Program Header Offset              : 0x" + hdr.e_phoff.ToString("X16"));
            Debug.DebugMSG( "ELF Section Header Table Offset        : 0x" + hdr.e_shoff.ToString("X16"));
              }

              hdr.e_flags         = ebr.ReadUInt32();
              hdr.e_ehsize        = ebr.ReadUInt16();
              hdr.e_phentsize     = ebr.ReadUInt16();
              hdr.e_phnum         = ebr.ReadUInt16();
//.........这里部分代码省略.........
开发者ID:sv99,项目名称:DVSDK,代码行数:101,代码来源:ELF.cs

示例3: ReadSectionHeader

        /// <summary>
        /// Read the section header from the section header table
        /// </summary>
        private ELF_SectionHeader ReadSectionHeader(UInt32 index)
        {
            EndianBinaryReader ebr = new EndianBinaryReader(binFile, endian);
              ELF_SectionHeader sectionHeader = new ELF_SectionHeader();

              // Seek to the start of the section header in section header table
              binFile.Seek((Int64)(hdr.e_shentsize * index + hdr.e_shoff), SeekOrigin.Begin);

              //Debug.DebugMSG( "Section["+index+"] = \n{");

              sectionHeader.sh_name = ebr.ReadUInt32();
              sectionHeader.sh_type = (ELF_SectionType) ebr.ReadUInt32();

              //Debug.DebugMSG(   "  Section Name Index         : " + sectionHeader.sh_name);
              //Debug.DebugMSG(   "  Section Type               : " + sectionHeader.sh_type);

              if (ELF_FileClass.ELFCLASS_32 == hdr.e_ident.fileClass)
              {
            sectionHeader.sh_flags      = (UInt64) ebr.ReadUInt32();
            sectionHeader.sh_addr       = (UInt64) ebr.ReadUInt32();
            sectionHeader.sh_offset     = (UInt64) ebr.ReadUInt32();
            sectionHeader.sh_size       = (UInt64) ebr.ReadUInt32();

            /*Debug.DebugMSG( "  Section Flags              : 0x" + sectionHeader.sh_flags.ToString("X8"));
            Debug.DebugMSG( "  Section Address            : 0x" + sectionHeader.sh_addr.ToString("X8"));
            Debug.DebugMSG( "  Section Offset             : 0x" + sectionHeader.sh_offset.ToString("X8"));
            Debug.DebugMSG( "  Section Size               : 0x" + sectionHeader.sh_size.ToString("X8"));*/
              }
              else
              {
            sectionHeader.sh_flags      = ebr.ReadUInt64();
            sectionHeader.sh_addr       = ebr.ReadUInt64();
            sectionHeader.sh_offset     = ebr.ReadUInt64();
            sectionHeader.sh_size       = ebr.ReadUInt64();

            /*Debug.DebugMSG( "  Section Flags              : 0x" + sectionHeader.sh_flags.ToString("X16"));
            Debug.DebugMSG( "  Section Address            : 0x" + sectionHeader.sh_addr.ToString("X16"));
            Debug.DebugMSG( "  Section Offset             : 0x" + sectionHeader.sh_offset.ToString("X16"));
            Debug.DebugMSG( "  Section Size               : 0x" + sectionHeader.sh_size.ToString("X16"));*/
              }
              sectionHeader.sh_link      = ebr.ReadUInt32();
              sectionHeader.sh_info      = ebr.ReadUInt32();
              //Debug.DebugMSG(   "  Section Link Index         : 0x" + sectionHeader.sh_flags.ToString("X8"));
              //Debug.DebugMSG(   "  Section Info Field         : 0x" + sectionHeader.sh_addr.ToString("X8"));

              if (ELF_FileClass.ELFCLASS_32 == hdr.e_ident.fileClass)
              {
            sectionHeader.sh_addralign      = (UInt64) ebr.ReadUInt32();
            sectionHeader.sh_entsize        = (UInt64) ebr.ReadUInt32();

            //Debug.DebugMSG( "  Section Addr Aligmnent     : 0x" + sectionHeader.sh_addralign.ToString("X8"));
            //Debug.DebugMSG( "  Section Entry Size         : 0x" + sectionHeader.sh_entsize.ToString("X8"));
              }
              else
              {
            sectionHeader.sh_addralign      = ebr.ReadUInt64();
            sectionHeader.sh_entsize        = ebr.ReadUInt64();

            //Debug.DebugMSG( "  Section Addr Aligmnent     : 0x" + sectionHeader.sh_addralign.ToString("X16"));
            //Debug.DebugMSG( "  Section Entry Size         : 0x" + sectionHeader.sh_entsize.ToString("X16"));
              }
              //Debug.DebugMSG("}");

              return sectionHeader;
        }
开发者ID:sv99,项目名称:DVSDK,代码行数:68,代码来源:ELF.cs

示例4: ParseSymbolTable

        /// <summary>
        /// Parse the ELF file's symbol table.
        /// </summary>
        private void ParseSymbolTable()
        {
            EndianBinaryReader ebr = new EndianBinaryReader(binFile, endian);
              UInt32 numSymbols = (UInt32) headerRef["numEntriesInSymTable"];
              ELF_Symbol sym;
              Byte info, other;

              symRef = new Hashtable[numSymbols];

              // Read the symbol table
              for (UInt32 symNum = 0; symNum < numSymbols; symNum++)
              {
            symRef[symNum] = new Hashtable();

            // Go to current symbol
            ebr.BaseStream.Seek((Int64) ((UInt64)headerRef["symbolTableAddr"]) + ((UInt32)headerRef["symbolTableEntrySize"] * symNum),SeekOrigin.Begin);
            sym.st_name       = (UInt32) ebr.ReadUInt32();

            if (ELF_FileClass.ELFCLASS_32 == hdr.e_ident.fileClass)
            {
              sym.st_value    = (UInt64) ebr.ReadUInt32();
              sym.st_size     = (UInt64) ebr.ReadUInt32();
              info            = ebr.ReadByte();
              other           = ebr.ReadByte();
              sym.st_shndx    = ebr.ReadUInt16();
            }
            else
            {
              info            = ebr.ReadByte();
              other           = ebr.ReadByte();
              sym.st_shndx    = ebr.ReadUInt16();
              sym.st_value    = ebr.ReadUInt64();
              sym.st_size     = ebr.ReadUInt64();
            }
            sym.st_type       = (ELF_SymbolType) (info & 0xF);
            sym.st_binding    = (ELF_SymbolBinding) ((info >> 4) & 0xF);
            sym.st_visibility = (ELF_SymbolVisibility) (other & 0x3);

            /*
            Debug.DebugMSG( "Symbol[" + symNum + "] = \n{" );
            Debug.DebugMSG( "  Symbol Name Offset        : 0x" + sym.st_name.ToString("X8"));
            Debug.DebugMSG( "  Symbol Value              : 0x" + sym.st_value.ToString("X16"));
            Debug.DebugMSG( "  Symbol Size               : 0x" + sym.st_size.ToString("X16"));
            Debug.DebugMSG( "  Symbol Type               : "   + sym.st_type);
            Debug.DebugMSG( "  Symbol Binding            : "   + sym.st_binding);
            Debug.DebugMSG( "  Symbol Visibility         : "   + sym.st_visibility);
            Debug.DebugMSG( "  Symbol's Relevant Section : 0x" + sym.st_shndx.ToString("X4"));
            Debug.DebugMSG( "}\n");
            */

            // Move to name in String Table
            ebr.BaseStream.Seek( (Int64) ((UInt64)headerRef["stringTableAddr"]) + (sym.st_name), SeekOrigin.Begin);
            symRef[symNum]["name"] = ELF_getStringFromStringTable();
            Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"name\"]: " + ((String)symRef[symNum]["name"]).ToString());

            symRef[symNum]["value"] = sym.st_value;
            Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"value\"]: " + ((UInt64)symRef[symNum]["value"]).ToString("X8"));

            symRef[symNum]["secNum"] = sym.st_shndx;
            Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"secNum\"]: " + ((UInt16)symRef[symNum]["secNum"]).ToString("X4"));

            symRef[symNum]["type"] = sym.st_type;
            Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"type\"]: " + sym.st_type);

            symRef[symNum]["binding"] = sym.st_binding;
            Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"binding\"]: " + sym.st_binding);

            symRef[symNum]["visibility"] = sym.st_visibility;
            Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"visibility\"]: " + sym.st_visibility);

              }
              Debug.DebugMSG("Parse Symbol Table Done");
        }
开发者ID:sv99,项目名称:DVSDK,代码行数:76,代码来源:ELF.cs

示例5: Load

        public void Load(Stream inputStream)
        {
            this.SetInternalStream(inputStream);

            DisposeLevels();
            _zoomLevels.Clear();

            _reader = new EndianBinaryReader(EndianBitConverter.Little, inputStream);

            // Check magic bytes
            if (_reader.ReadInt64() != 0x08002b4949)
                throw new Exception("Invalid ZIF file");

            while (_reader.BaseStream.Position < MAX_ZIF_BYTES)
            {
                ulong offset = _reader.ReadUInt64();
                if (offset == 0)
                    break;

                _reader.Seek(offset, SeekOrigin.Begin);
                var numTags = _reader.ReadUInt64();

                var level = new ZoomLevel(_reader);
                for (ulong i = 0; i < numTags; ++i)
                {
                    var key = _reader.ReadUInt16();
                    var notUsed = _reader.ReadUInt16();
                    var val1 = _reader.ReadUInt64();
                    var val2 = _reader.ReadUInt64();
                    level.AddTag(key, val1, val2);
                }
                _zoomLevels.Insert(0, level);
            }            
        }
开发者ID:asherber,项目名称:Zif.Reader,代码行数:34,代码来源:ZifReader.cs

示例6: Extract

        static void Extract(string FileName, EndianBinary.Endian Endian)
        {
            FileStream Input = new FileStream(FileName, FileMode.Open);
            EndianBinaryReader Reader = new EndianBinaryReader(Input, Endian);

            byte b = Reader.ReadByte();
            MemoryStream SignatureBuffer = new MemoryStream();
            while (b != 0)
            {
                SignatureBuffer.WriteByte(b);
                b = Reader.ReadByte();
            }
            string Signature = Encoding.ASCII.GetString(SignatureBuffer.ToArray());
            SignatureBuffer.Dispose();
            Reader.BaseStream.Seek(8, SeekOrigin.Begin); //Pula parte da assinatura

            if (Signature != "MSSG")
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Invalid file!");
                Console.ResetColor();
            }

            string OutDir = Path.GetFileNameWithoutExtension(FileName);
            Directory.CreateDirectory(OutDir);

            ulong FileCount = Reader.ReadUInt64();
            ulong FileLength = Reader.ReadUInt64();
            Reader.ReadUInt64(); //??? 0x800

            for (ulong Entry = 0; Entry < FileCount; Entry++)
            {
                Input.Seek((long)(0x20 + Entry * 0x20), SeekOrigin.Begin);

                ulong Offset = Reader.ReadUInt64();
                ulong Length1 = Reader.ReadUInt64();
                ulong Length2 = Reader.ReadUInt64();
                Reader.ReadUInt64(); //Padding

                Input.Seek((long)Offset, SeekOrigin.Begin);
                byte[] Buffer = new byte[Length1];
                Reader.Read(Buffer, 0, Buffer.Length);

                string SubFileSignature = Encoding.ASCII.GetString(Buffer, 0, 4);
                bool IsLangFile = SubFileSignature == "LANG";
                File.WriteAllBytes(Path.Combine(OutDir, "file_" + Entry.ToString() + (IsLangFile ? ".lang" : ".bin")), Buffer);
            }

            Reader.Close();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Extracted all files from " + Path.GetFileName(FileName) + "!");
            Console.ResetColor();
        }
开发者ID:gdkchan,项目名称:DOA5Tool,代码行数:54,代码来源:Program.cs

示例7: ParseMessage

        private LifxResponse ParseMessage(byte[] packet)
        {
            using (var ms = new MemoryStream(packet))
            {
                var header = new FrameHeader();

                using (var reader = new EndianBinaryReader(EndianBitConverter.Little, ms, Encoding.UTF8))
                {
                    //frame
                    var size = reader.ReadUInt16();
                    if (packet.Length != size || size < 36)
                    {
                        throw new Exception("Invalid packet");
                    }

                    var a = reader.ReadUInt16(); //origin:2, reserved:1, addressable:1, protocol:12
                    var source = reader.ReadUInt32();
                    //frame address
                    header.TargetMacAddress = reader.ReadBytes(8);
                    ms.Seek(6, SeekOrigin.Current); //skip reserved
                    var b = reader.ReadByte(); //reserved:6, ack_required:1, res_required:1, 
                    header.Sequence = reader.ReadByte();
                    //protocol header
                    var nanoseconds = reader.ReadUInt64();
                    header.AtTime = Utilities.Epoch.AddMilliseconds(nanoseconds * 0.000001);
                    var type = (MessageType)reader.ReadUInt16();
                    ms.Seek(2, SeekOrigin.Current); //skip reserved
                    byte[] payload = null;
                    if (size > 36)
                    {
                        payload = reader.ReadBytes(size - 36);
                    }

                    return LifxResponse.Create(header, type, source, payload);
                }
            }
        }
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:37,代码来源:LifxLocalClient.cs


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