コード例 #1
0
ファイル: ModHeaders.cs プロジェクト: Shine6Z/GenXSource
        public string StringFromRVA(BinaryReader reader, uint rva)
        {
            long   offs = reader.BaseStream.Position;
            string s;

            try
            {
                s = "";
                uint nameOffs = ModHeaders.Rva2Offset(rva);
                reader.BaseStream.Position = nameOffs;
                byte b = reader.ReadByte();
                while (b != 0)
                {
                    s += (char)b;
                    b  = reader.ReadByte();
                }
            }
            catch            //(Exception e)
            {
                s = "Unable to find string";
            }
            finally
            {
                reader.BaseStream.Position = offs;
            }
            return(s);
        }
コード例 #2
0
ファイル: ModHeaders.cs プロジェクト: Shine6Z/GenXSource
        public MModule(BinaryReader reader)
        {
            try
            {
                _mh = new ModHeaders(reader);
            }
            catch            //(Exception e)
            {
                return;
            }

            //imports
            try
            {
                _imp = new ImpExports(reader, this);
            }
            catch            //(Exception e)
            {
                return;
            }

            //relocs
            try
            {
                _fix = new Relocations(reader, this);
            }
            catch            //(Exception e)
            {
                return;
            }

            //heaps
            try
            {
                _stringHeap = new MDStringHeap(reader, _mh.MetaDataHeaders.StringStreamHeader.Offset + _mh.MetaDataHeaders.StorageSigAndHeader.Start, _mh.MetaDataHeaders.StringStreamHeader.Size, _mh.MetaDataHeaders.StringStreamHeader.Name);
                _blobHeap   = new MDBlobHeap(reader, _mh.MetaDataHeaders.BlobStreamHeader.Offset + _mh.MetaDataHeaders.StorageSigAndHeader.Start, _mh.MetaDataHeaders.BlobStreamHeader.Size, _mh.MetaDataHeaders.BlobStreamHeader.Name);
                _GUIDHeap   = new MDGUIDHeap(reader, _mh.MetaDataHeaders.GUIDStreamHeader.Offset + _mh.MetaDataHeaders.StorageSigAndHeader.Start, _mh.MetaDataHeaders.GUIDStreamHeader.Size, _mh.MetaDataHeaders.GUIDStreamHeader.Name);

                if (_mh.MetaDataHeaders.USStreamHeader != null)
                {
                    _USHeap = new MDBlobHeap(reader, _mh.MetaDataHeaders.USStreamHeader.Offset + _mh.MetaDataHeaders.StorageSigAndHeader.Start, _mh.MetaDataHeaders.USStreamHeader.Size, _mh.MetaDataHeaders.USStreamHeader.Name);
                }
            }
            catch            //(Exception e)
            {
                return;
            }

            //tables
            try
            {
                reader.BaseStream.Position = _mh.MetaDataTableHeader.End;
                _tables = new MDTables(reader, this);
            }
            catch            //(Exception e)
            {
                return;
            }
        }