Inheritance: System.IO.BinaryReader
示例#1
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal static void GetFieldRefs(PEReader buff, uint num, ClassRef parent)
 {
     for (int i=0; i < num; i++) {
         uint flags = buff.ReadUInt16();
         string name = buff.GetString();
         uint sigIx = buff.GetBlobIx();
         if ((flags & (uint)FieldAttr.Public) == (uint)FieldAttr.Public) {
             if (parent.GetField(name) == null) {
                 //Console.WriteLine(parent.NameString());
                 buff.currentClassScope = parent;
                 FieldRef fRef = new FieldRef(parent,name,buff.GetFieldType(sigIx));
                 buff.currentClassScope = null;
                 parent.AddToFieldList(fRef);
             }
         }
     }
 }
示例#2
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal IntConst(PEReader buff, int numBytes)
 {
     switch (numBytes) {
         case (1) : val = buff.ReadSByte();
             type = ElementType.I8;
             break;
         case (2) : val = buff.ReadInt16();
             type = ElementType.I2;
             break;
         case (4) : val = buff.ReadInt32();
             type = ElementType.I4;
             break;
         case (8) : val = buff.ReadInt64();
             type = ElementType.I8;
             break;
         default: val = 0;
             break;
     }
     size = (uint)numBytes; // * 4;
 }
示例#3
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal static void Read(PEReader buff, TableRow[] impls)
 {
     for (int i=0; i < impls.Length; i++)
         impls[i] = new InterfaceImpl(buff);
 }
示例#4
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal static void Read(PEReader buff, TableRow[] gpars)
 {
     for (int i=0; i < gpars.Length; i++)
         gpars[i] = new GenericParamConstraint(buff);
 }
示例#5
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal ImplMap(PEReader buff)
 {
     flags = buff.ReadUInt16();
     memForIndex = buff.GetCodedIndex(CIx.MemberForwarded);
     importName = buff.GetString();
     scopeIx = buff.GetIndex(MDTable.ModuleRef);
     sortTable = true;
     tabIx = MDTable.ImplMap;
 }
示例#6
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal static AssemblyRef ReadAssemblyRef(PEReader buff)
 {
     buff.SetElementPosition(MDTable.Assembly,1);
     HashAlgorithmType hAlg = (HashAlgorithmType)buff.ReadUInt32();
     ushort majVer = buff.ReadUInt16();
     ushort minVer = buff.ReadUInt16();
     ushort bldNo = buff.ReadUInt16();
     ushort revNo = buff.ReadUInt16();
     uint flags = buff.ReadUInt32();
     byte[] pKey =  buff.GetBlob();
     string name = buff.GetString();
     string cult = buff.GetString();
     AssemblyRef assemRef = null;
     if (name.ToLower() == "mscorlib") {
         assemRef = MSCorLib.mscorlib;
         assemRef.AddVersionInfo(majVer,minVer,bldNo,revNo);
         if (pKey.Length > 8) assemRef.AddKey(pKey);
         else assemRef.AddKeyToken(pKey);
         assemRef.AddCulture(cult);
         assemRef.SetFlags(flags);
     } else {
         assemRef = new AssemblyRef(name,majVer,minVer,bldNo,revNo,flags,pKey,cult,null);
     }
     //AssemblyRef assemRef = new AssemblyRef(name,majVer,minVer,bldNo,revNo,flags,pKey,cult,null);
     assemRef.ReadAsDef();
     return assemRef;
 }
示例#7
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal void CheckParent(MethodDef paren, PEReader buff)
 {
     if (paren == buff.GetCodedElement(CIx.TypeOrMethodDef,parentIx)) {
         parent = paren;
         paren.InsertGenericParam(this);
     }
 }
示例#8
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal FieldMarshal(PEReader buff)
 {
     parentIx = buff.GetCodedIndex(CIx.HasFieldMarshal);
     ntIx = buff.GetBlobIx();
     sortTable = true;
     tabIx = MDTable.FieldMarshal;
 }
示例#9
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal static void Read(PEReader buff, TableRow[] fMarshal)
 {
     for (int i=0; i < fMarshal.Length; i++)
         fMarshal[i] = new FieldMarshal(buff);
 }
示例#10
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal static void Read(PEReader buff, TableRow[] layouts)
 {
     for (int i=0; i < layouts.Length; i++)
         layouts[i] = new FieldLayout(buff);
 }
示例#11
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal override sealed void Resolve(PEReader buff)
 {
     field = (FieldDef)buff.GetElement(MDTable.Field,fieldIx);
     field.SetOffset(offset);
 }
示例#12
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal FieldLayout(PEReader buff)
 {
     offset = buff.ReadUInt32();
     fieldIx = buff.GetIndex(MDTable.Field);
     tabIx = MDTable.FieldLayout;
 }
示例#13
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal void Resolve(PEReader buff, uint fIx)
 {
     /*
     if ((flags & HasFieldMarshal) != 0)
       marshalType = FieldMarshal.FindMarshalType(buff,this,
         buff.MakeCodedIndex(CIx.HasFieldMarshal,MDTable.Field,fIx));
     if ((flags & HasFieldRVA) != 0)
       initVal = FieldRVA.FindValue(buff,this,fIx);
     if ((flags & HasDefault) != 0)
       constVal = ConstantElem.FindConst(buff,this,
         buff.MakeCodedIndex(CIx.HasConstant,MDTable.Field,fIx));
     long offs = FieldLayout.FindLayout(buff,this,fIx);
     if (offs > -1){
       hasOffset = true;
       offset = (uint)offs;
     }
     */
     buff.currentClassScope = parent;
     type = buff.GetFieldType(sigIx);
     buff.currentClassScope = null;
 }
示例#14
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal static void Read(PEReader buff, TableRow[] fields)
 {
     for (int i=0; i < fields.Length; i++)
         fields[i] = new FieldDef(buff);
 }
示例#15
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal static void Read(PEReader buff, TableRow[] table, PEFile pefile)
 {
     for (int i=0; i < table.Length; i++) {
         HashAlgorithmType hAlg = (HashAlgorithmType)buff.ReadUInt32();
         ushort majVer = buff.ReadUInt16();
         ushort minVer = buff.ReadUInt16();
         ushort bldNo = buff.ReadUInt16();
         ushort revNo = buff.ReadUInt16();
         uint flags = buff.ReadUInt32();
         byte[] pKey =  buff.GetBlob();
         string name = buff.GetString();
         string cult = buff.GetString();
         table[i] = new Assembly(name,hAlg,majVer,minVer,bldNo,revNo,flags,pKey,cult,pefile);
     }
 }
示例#16
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal override void Resolve(PEReader buff)
 {
     field = buff.GetCodedElement(CIx.HasFieldMarshal,parentIx);
     nt = buff.GetBlobNativeType(ntIx);
     if (field is FieldDef) {
         ((FieldDef)field).SetMarshalType(nt);
     } else {
         ((Param)field).SetMarshalType(nt);
     }
 }
示例#17
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal FloatConst(PEReader buff)
 {
     val = buff.ReadSingle();
     size = 4;
     type = ElementType.R4;
 }
示例#18
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal override Member ResolveParent(PEReader buff)
 {
     if (parent != null) return this;
     MetaDataElement paren = buff.GetCodedElement(CIx.MemberRefParent,parentIx);
     //Console.WriteLine("parentIx = " + parentIx);
     //Console.WriteLine("paren = " + paren);
     if (paren is ClassDef)
         return((ClassDef)paren).GetField(this.name);
     //if (paren is ClassSpec)
     // paren = ((ClassSpec)paren).GetParent();
     if (paren is ReferenceScope)
         parent = ((ReferenceScope)paren).GetDefaultClass();
     if (paren is TypeSpec)
         parent = new ConstructedTypeSpec((TypeSpec)paren);
     else
         parent = (Class)paren;
     if (parent != null) {
         Field existing = (Field)((Class)parent).GetFieldDesc(name);
         if (existing != null) {
             return existing;
         }
     }
     parent.AddToFieldList(this);
     return this;
 }
示例#19
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal GenericParam(PEReader buff)
     : base(VAR)
 {
     index = buff.ReadUInt16();
     flags = buff.ReadUInt16();
     parentIx = buff.GetCodedIndex(CIx.TypeOrMethodDef);
     name = buff.GetString();
     if (extraField) kind = buff.ReadUInt16();
     sortTable = true;
     tabIx = MDTable.GenericParam;
     // resolve generic param immediately for signature resolution
     parent = buff.GetCodedElement(CIx.TypeOrMethodDef,parentIx);
     if (parent != null) {
         if (parent is MethodDef) {
             typeIndex = MVAR;
             ((MethodDef)parent).AddGenericParam(this);
         } else {
             ((ClassDef)parent).AddGenericParam(this);
         }
     }
 }
示例#20
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal FieldRVA(PEReader buff)
 {
     rva = buff.ReadUInt32();
     fieldIx = buff.GetIndex(MDTable.Field);
     tabIx = MDTable.FieldRVA;
 }
示例#21
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal GenericParamConstraint(PEReader buff)
 {
     parentIx = buff.GetIndex(MDTable.GenericParam);
     constraintIx = buff.GetCodedIndex(CIx.TypeDefOrRef);
     tabIx = MDTable.GenericParamConstraint;
 }
示例#22
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal static void Read(PEReader buff, TableRow[] fRVAs)
 {
     for (int i=0; i < fRVAs.Length; i++)
         fRVAs[i] = new FieldRVA(buff);
 }
示例#23
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal override void Resolve(PEReader buff)
 {
     parent = (GenericParam)buff.GetElement(MDTable.GenericParam,parentIx);
     parent.AddConstraint((Class)buff.GetCodedElement(CIx.TypeDefOrRef,constraintIx));
 }
示例#24
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal override sealed void Resolve(PEReader buff)
 {
     field = (FieldDef)buff.GetElement(MDTable.Field,fieldIx);
     field.AddDataValue(buff.GetDataConstant(rva,field.GetFieldType()));
 }
示例#25
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal override void Resolve(PEReader buff)
 {
     meth = (MethodDef)buff.GetCodedElement(CIx.MemberForwarded,memForIndex);
     importScope = (ModuleRef)buff.GetElement(MDTable.ModuleRef,scopeIx);
     if (meth != null) meth.AddPInvokeInfo(this);
 }
示例#26
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal FileRef(PEReader buff)
 {
     flags = buff.ReadUInt32();
     name = buff.GetString();
     hashBytes = buff.GetBlob();
     tabIx = MDTable.File;
 }
示例#27
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal InterfaceImpl(PEReader buff)
 {
     classIx = buff.GetIndex(MDTable.TypeDef);
     interfacesIndex = buff.GetCodedIndex(CIx.TypeDefOrRef);
     tabIx = MDTable.InterfaceImpl;
 }
示例#28
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal static void Read(PEReader buff, TableRow[] files)
 {
     for (int i=0; i < files.Length; i++) {
         uint flags = buff.ReadUInt32();
         if (flags == HasMetaData)
             files[i] = new ModuleFile(buff.GetString(),buff.GetBlob());
         else
             files[i] = new ResourceFile(buff.GetString(),buff.GetBlob());
     }
 }
示例#29
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal override void Resolve(PEReader buff)
 {
     theClass = (ClassDef)buff.GetElement(MDTable.TypeDef,classIx);
     theInterface = (Class)buff.GetCodedElement(CIx.TypeDefOrRef,interfacesIndex);
     theClass.AddImplementedInterface(this);
 }
示例#30
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal FieldDef(PEReader buff)
     : base(null,null,null)
 {
     flags = buff.ReadUInt16();
     name = buff.GetString();
     sigIx = buff.GetBlobIx();
     tabIx = MDTable.Field;
 }