Пример #1
0
 public override uint ByteSize(MetadataTables tables)
 {
     throw new NotImplementedException();
 }
Пример #2
0
        public void Read(ReaderContext ctxt)
        {
            if (ctxt.Tracer != null)
            {
                ctxt.Tracer.Append("PEFile '");
                ctxt.Tracer.Append(ctxt.FileName);
                ctxt.Tracer.AppendLine("' {");
                ctxt.Tracer.Indent();
            }
            try
            {
                var reader = ctxt.GetFileReader();

                DOSHeader.Read(ctxt, reader);
                reader.Offset = DOSHeader.LfaNew.Offset; // Follow LfaNew pointer
                PEFileHeader.Read(ctxt, reader);
                PEOptionalHeader.Read(ctxt, reader);
                SectionHeaders = new SectionHeader[PEFileHeader.NumberOfSections];
                for (var i = 0; i < SectionHeaders.Length; i++)
                    SectionHeaders[i].Read(ctxt, reader);
                ctxt.SectionHeaders = SectionHeaders; // RVA's may now be resolved

                PEOptionalHeader.Deref(ctxt);

                Tables = new MetadataTables();
                ctxt.Tables = Tables; // Coded indexes may now be resolved
                Tables.Read(ctxt);
            }
            finally
            {
                if (ctxt.Tracer != null)
                {
                    ctxt.Tracer.Outdent();
                    ctxt.Tracer.AppendLine("}");
                }
            }
        }
Пример #3
0
 public override uint ByteSize(MetadataTables tables)
 {
     throw new PEException("method type parameters do not have sizes");
 }
Пример #4
0
 public override uint ByteSize(MetadataTables tables)
 {
     throw new PEException("pseudo types do not have sizes");
 }
Пример #5
0
        public override uint ByteSize(MetadataTables tables)
        {
            var typeDefRow = TypeDefOrRef.Value as TypeDefRow;
            if (typeDefRow != null)
            {
                var classLayoutRow = tables.ClassLayoutTable.SingleOrDefault(cl => cl.Parent.Value == typeDefRow);
                if (classLayoutRow != null)
                    return classLayoutRow.ClassSize;
            }

            if (!IsValueType)
                return 0;

            throw new PEException("cannot determine size of type");
        }
Пример #6
0
 public override uint ByteSize(MetadataTables tables)
 {
     switch (PrimitiveType)
     {
         case PrimitiveType.Boolean:
         case PrimitiveType.Int8:
         case PrimitiveType.UInt8:
             return 1;
         case PrimitiveType.Char:
         case PrimitiveType.Int16:
         case PrimitiveType.UInt16:
             return 2;
         case PrimitiveType.Int32:
         case PrimitiveType.UInt32:
         case PrimitiveType.Single:
             return 4;
         case PrimitiveType.Int64:
         case PrimitiveType.UInt64:
         case PrimitiveType.Double:
             return 8;
         case PrimitiveType.Void:
             throw new PEException("void type does not have a size");
         case PrimitiveType.IntNative:
         case PrimitiveType.UIntNative:
         case PrimitiveType.String:
         case PrimitiveType.TypedRef:
         case PrimitiveType.Type:
         case PrimitiveType.Object:
             throw new PEException("cannot determine size of type");
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
Пример #7
0
 public abstract uint ByteSize(MetadataTables tables);