Exemplo n.º 1
0
        public byte[] GetBlobBytes(int offset)
        {
            int       ad       = this.BlobOffset + offset;
            DoubleInt dataSize = Util.GetDataSize(this.Data, ad);

            return(Util.GetBytes(this.Data, ad + dataSize.A, dataSize.B));
        }
Exemplo n.º 2
0
        public DoubleInt GetDataSizeInfo(StringBuilder sb, int ad, string format)
        {
            DoubleInt ret = Util.GetDataSize(this.Data, ad);

            sb.AppendFormat("{0:X8}:", ad);
            int len = 16;

            for (int i = 0; i < ret.A; i++)
            {
                if (i > 0)
                {
                    sb.Append(' ');
                    len--;
                }
                sb.AppendFormat("{0:X2}", this.Data[ad++]);
                len -= 2;
            }
            for (int i = 0; i < len; i++)
            {
                sb.Append(' ');
            }
            sb.Append(' ');
            sb.AppendFormat(format, ret.B);
            return(ret);
        }
Exemplo n.º 3
0
        public string GetUSString(int offset)
        {
            int       ad       = this.USOffset + offset;
            DoubleInt dataSize = Util.GetDataSize(this.Data, ad);

            byte [] bytes = Util.GetBytes(this.Data, ad + dataSize.A, dataSize.B);
            return(Encoding.Unicode.GetString(bytes, 0, dataSize.B - 1));
        }
Exemplo n.º 4
0
        private void ReadSignature()
        {
            int sign;

            if (this.table is MethodDefTable)
            {
                sign = (this.table as MethodDefTable).Signature;
            }
            else if (this.table is MemberRefTable)
            {
                sign = (this.table as MemberRefTable).Signature;
                if (this.table.Children == null)
                {
                    this.table.Children = new ArrayList[]
                    {
                        new ArrayList()
                    }
                    ;
                }
            }
            else
            {
                return;
            }
            int       ad       = this.data.idxm.BlobOffset + sign;
            DoubleInt dataSize = Util.GetDataSize(this.data.data, ad);

            ad += dataSize.A;
            this.SignatureFlags = this.data.data[ad++];
            if (this.IsField)
            {
                this.RetType = this.data.idxm.ReadType(ad);
                return;
            }
            DoubleInt count = Util.GetDataSize(this.data.data, ad);

            this.ParamCount = count.B;
            ad          += count.A;
            this.RetType = this.data.idxm.ReadType(ad);
            ad          += this.RetType.Size;
            for (int i = 0; i < this.ParamCount; i++)
            {
                TypeData ds = this.data.idxm.ReadType(ad);
                if (table is MethodDefTable)
                {
                    (this.table.Children[0][i] as ParamTable).Tag = ds;
                }
                else
                {
                    this.table.Children[0].Add(ds);
                }
                ad += ds.Size;
            }
        }
Exemplo n.º 5
0
        public void GetSignatureInfos(StringBuilder sb, int offset)
        {
            sb.AppendFormat("  *** Signature [Blob {0:X8}] ***\r\n\r\n", offset);
            int       ad       = this.BlobOffset + offset;
            DoubleInt dataSize = this.GetDataSizeInfo(sb, ad, "Blob Length: {0:X4}\r\n");

            ad += dataSize.A;
            int    end = ad + dataSize.B;
            string comment1 = "", comment2 = "";

            sb.AppendFormat("{0:X8}:", ad);
            int type = this.Data[ad++];

            switch (type)
            {
            case 0x06: sb.AppendFormat("{0,-16:X2} FIELD\r\n", type);
                break;

            case 0x07:
            {
                sb.AppendFormat("{0,-16:X2} LOCAL_SIG\r\n", type);
                DoubleInt di = this.GetDataSizeInfo(sb, ad, "Count: {0:X4}\r\n");
                ad += di.A;
                break;
            }

            default:
            {
                sb.AppendFormat("{0,-16:X2} {1}\r\n", type, (MethodFlags)type);
                DoubleInt di = this.GetDataSizeInfo(sb, ad, "ParamCount: {0:X4}\r\n");
                ad      += di.A;
                comment1 = "RetType:";
                comment2 = "Param:";
                break;
            }
            }
            string comment = comment1;

            while (ad < end)
            {
                TypeData ds = this.ReadType(ad);
                this.GetSignatureInfo(sb, ad, ds, comment);
                ad += ds.Size;
                if (comment == comment1)
                {
                    comment = comment2;
                }
            }
        }
Exemplo n.º 6
0
        public TypeData ReadType(int offset)
        {
            TypeData ret;

            ret.Size    = 1;
            ret.Token   = 0;
            ret.Element = ret.Option = ELEMENT_TYPE.END;
            int b = this.Data[offset];

            if (!Enum.IsDefined(typeof(ELEMENT_TYPE), b))
            {
                return(ret);
            }
            ELEMENT_TYPE et = (ELEMENT_TYPE)b;

            switch (et)
            {
            case ELEMENT_TYPE.SZARRAY:
            {
                ret = this.ReadType(offset + 1);
                ret.Size++;
                ret.Option = et;
                break;
            }

            case ELEMENT_TYPE.VALUETYPE:
            case ELEMENT_TYPE.CLASS:
            {
                DoubleInt ds = Util.GetDataSize(this.Data, offset + 1);
                ret.Token = this.GetToken(CodedIndices.TypeDefOrRef, ds.B);
                ret.Size  = 1 + ds.A;
                break;
            }

            default: ret.Element = et;
                break;
            }
            return(ret);
        }
Exemplo n.º 7
0
        private void ReadLocalVars()
        {
            this.LocalVarSig = this.data.idxm.GetTable(this.LocalVarSigTok) as StandAloneSigTable;
            if (this.LocalVarSig == null)
            {
                return;
            }
            int       ad       = this.data.idxm.BlobOffset + this.LocalVarSig.Signature;
            DoubleInt dataSize = Util.GetDataSize(this.data.data, ad);

            ad += dataSize.A;
            ad++;
            DoubleInt count = Util.GetDataSize(this.data.data, ad);

            ad            += count.A;
            this.LocalVars = new ArrayList();
            for (int i = 0; i < count.B; i++)
            {
                TypeData ds = this.data.idxm.ReadType(ad);
                this.LocalVars.Add(ds);
                ad += ds.Size;
            }
        }