Пример #1
0
        internal override void BuildSignatures(MetaDataOut md)
        {
            MemoryStream outSig = new MemoryStream();

            TypeSig(outSig);
            sigIx = md.AddToBlobHeap(outSig.ToArray());
        }
Пример #2
0
 internal override void BuildTables(MetaDataOut md)
 {
     if (!(exceptType is ClassDef))
     {
         exceptType.BuildMDTables(md);
     }
 }
Пример #3
0
        internal sealed override void BuildTables(MetaDataOut md)
        {
            md.AddToTable(MDTable.Method, this);
            nameIx = md.AddToStringsHeap(name);

            if (genericParams != null)
            {
                foreach (object genericParam in genericParams)
                {
                    ((GenericParam)genericParam).BuildMDTables(md);
                }
            }
            if (security != null)
            {
                foreach (object sec in security)
                {
                    ((DeclSecurity)sec).BuildMDTables(md);
                }
            }
            if (pinvokeImpl != null)
            {
                pinvokeImpl.BuildMDTables(md);
            }
            if (entryPoint)
            {
                md.SetEntryPoint(this);
            }
            if (locals != null)
            {
                localSig = new LocalSig(locals);
                localSig.BuildMDTables(md);
            }

            // The following code is done out of line in method
            // TraverseCode *after* all the method indices have
            // been allocated in the metadata.
            // (kjg, March 2010)
            //try {
            //  if (code != null) {
            //    if (code.IsEmpty()) {
            //      code = null;
            //    }
            //    else {
            //      code.BuildTables(md);
            //    }
            //  }
            //}
            //catch (InstructionException ex) {
            //  throw new Exception(ex.AddMethodName(name));
            //}


            parIx = md.TableIndex(MDTable.Param);
            for (int i = 0; i < sig.numPars; i++)
            {
                parList[i].seqNo = (ushort)(i + 1);
                parList[i].BuildMDTables(md);
            }
            sig.BuildTables(md);
        }
Пример #4
0
 internal sealed override void BuildTables(MetaDataOut md)
 {
     if (!(elemType is ClassDef))
     {
         elemType.BuildMDTables(md);
     }
 }
Пример #5
0
 internal sealed override void TypeSig(MemoryStream str)
 {
     str.WriteByte(typeIndex);
     elemType.TypeSig(str);
     MetaDataOut.CompressNum(BlobUtil.CompressUInt(numDims), str);
     if ((sizes != null) && (sizes.Length > 0))
     {
         MetaDataOut.CompressNum(BlobUtil.CompressUInt((uint)sizes.Length), str);
         foreach (int size in sizes)
         {
             MetaDataOut.CompressNum(BlobUtil.CompressUInt((uint)size), str);
         }
     }
     else
     {
         str.WriteByte(0);
     }
     if ((lowerBounds != null) && (lowerBounds.Length > 0))
     {
         MetaDataOut.CompressNum(BlobUtil.CompressUInt((uint)lowerBounds.Length), str);
         foreach (int lowerBound in lowerBounds)
         {
             MetaDataOut.CompressNum(BlobUtil.CompressInt(lowerBound), str);
         }
     }
     else
     {
         str.WriteByte(0);
     }
 }
Пример #6
0
 internal sealed override void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.Field, this);
     nameIx = md.AddToStringsHeap(name);
     if (!type.isDef())
     {
         type.BuildMDTables(md);
     }
     if (initVal != null)
     {
         FieldRVA rva = new FieldRVA(this, initVal);
         rva.BuildMDTables(md);
     }
     if (constVal != null)
     {
         ConstantElem constElem = new ConstantElem(this, constVal);
         constElem.BuildMDTables(md);
     }
     if (hasOffset)
     {
         FieldLayout layout = new FieldLayout(this, offset);
         layout.BuildMDTables(md);
     }
     if (marshalType != null)
     {
         FieldMarshal marshalInfo = new FieldMarshal(this, marshalType);
         marshalInfo.BuildMDTables(md);
     }
 }
Пример #7
0
 internal void BuildTables(MetaDataOut md)
 {
     Contract.Requires(md != null);
     if (!(type is ClassDef))
     {
         type.BuildMDTables(md);
     }
 }
Пример #8
0
 internal sealed override void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.AssemblyRef, this);
     keyIx  = md.AddToBlobHeap(keyBytes);
     nameIx = md.AddToStringsHeap(name);
     cultIx = md.AddToStringsHeap(culture);
     hashIx = md.AddToBlobHeap(hashBytes);
 }
Пример #9
0
 /*----------------------------- internal functions ------------------------------*/
 internal override sealed void BuildSignatures(MetaDataOut md)
 {
     MemoryStream sig = new MemoryStream();
     sig.WriteByte(FieldTag);
     type.TypeSig(sig);
     sigIx = md.AddToBlobHeap(sig.ToArray());
     done = false;
 }
Пример #10
0
 internal void AddConstraints(MetaDataOut md)
 {
     Contract.Requires(md != null);
     foreach (GenericParamConstraint constraint in constraints)
     {
         md.AddToTable(MDTable.GenericParamConstraint, constraint);
     }
 }
Пример #11
0
        internal override void BuildSignatures(MetaDataOut md)
        {
            MemoryStream str = new MemoryStream();

            TypeSig(str);
            sigIx = md.AddToBlobHeap(str.ToArray());
            done  = false;
        }
Пример #12
0
 internal sealed override void BuildTables(MetaDataOut md)
 {
     md.AddToTable(tabIx, this);
     foreach (Local local in locals)
     {
         local.BuildTables(md);
     }
 }
Пример #13
0
        internal sealed override void BuildSignatures(MetaDataOut md)
        {
            sig.BuildSignatures(md);
            MemoryStream sigStream = new MemoryStream();

            TypeSig(sigStream);
            sigIx = md.AddToBlobHeap(sigStream.ToArray());
            done  = false;
        }
Пример #14
0
 internal override Type AddTypeSpec(MetaDataOut md)
 {
     if (this.myTypeSpec == null)
     {
         this.myTypeSpec = new GenericParTypeSpec(this);
         md.AddToTable(MDTable.TypeSpec, this.myTypeSpec);
     }
     return(this.myTypeSpec);
 }
Пример #15
0
        /*----------------------------- internal functions ------------------------------*/

        internal sealed override void BuildSignatures(MetaDataOut md)
        {
            MemoryStream sig = new MemoryStream();

            sig.WriteByte(FieldTag);
            type.TypeSig(sig);
            sigIx = md.AddToBlobHeap(sig.ToArray());
            done  = false;
        }
Пример #16
0
 internal virtual Type AddTypeSpec(MetaDataOut md)
 {
     Contract.Requires(md != null);
     if (!isDef())
     {
         BuildMDTables(md);
     }
     return(this);
 }
Пример #17
0
 internal override void TypeSig(MemoryStream str)
 {
     str.WriteByte(GENERICINST);
     MetaDataOut.CompressNum(BlobUtil.CompressUInt((uint)instTypes.Length), str);
     foreach (Type instType in instTypes)
     {
         instType.TypeSig(str);
     }
 }
Пример #18
0
 internal sealed override uint GetBlobIndex(MetaDataOut md)
 {
     if (addedToBlobHeap != md)
     {
         blobIndex       = md.AddToBlobHeap(val);
         addedToBlobHeap = md;
     }
     return(blobIndex);
 }
Пример #19
0
 internal void BuildTables(MetaDataOut md)
 {
     Contract.Requires(md != null);
     // FIXME Contract.Requires(handlers != null);
     foreach (HandlerBlock handler in handlers)
     {
         handler.BuildTables(md);
     }
 }
Пример #20
0
        /*-------------------- Constructors ---------------------------------*/

        /// <summary>
        /// Create a new PE File with the name "fileName".  If "fileName" ends in ".dll" then
        /// the file is a dll, otherwise it is an exe file.  This PE File has no assembly.
        /// </summary>
        /// <param name="fileName">Name for the output file.</param>
        public PEFile(string fileName)
            : base(fileName)
        {
            Contract.Requires(fileName != null);
            //PrimitiveType.ClearAddedFlags();   // KJG 18-April-2005 - Now done in MetaDataOut
            this.fileName = fileName;
            metaData      = new MetaDataOut();
            versionInfo   = new PEFileVersionInfo();
            versionInfo.SetDefaults(fileName);
        }
Пример #21
0
        private System.IO.FileStream unmanagedResources; // Unmanaged resources read from a file.

        #endregion Fields

        #region Constructors

        /*-------------------- Constructors ---------------------------------*/
        /// <summary>
        /// Create a new PE File with the name "fileName".  If "fileName" ends in ".dll" then
        /// the file is a dll, otherwise it is an exe file.  This PE File has no assembly.
        /// </summary>
        /// <param name="fileName">Name for the output file.</param>
        public PEFile(string fileName)
            : base(fileName)
        {
            Contract.Requires(fileName != null);
            //PrimitiveType.ClearAddedFlags();   // KJG 18-April-2005 - Now done in MetaDataOut
            this.fileName = fileName;
            metaData = new MetaDataOut();
            versionInfo = new PEFileVersionInfo();
            versionInfo.SetDefaults(fileName);
        }
Пример #22
0
 // fix for Whidbey bug
 internal void AddGenericsToTable(MetaDataOut md)
 {
     if (genericParams != null)
     {
         foreach (object genericParam in genericParams)
         {
             md.AddToTable(MDTable.GenericParam, (GenericParam)genericParam);
         }
     }
 }
Пример #23
0
 internal sealed override void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.File, this);
     nameIx = md.AddToStringsHeap(name);
     hashIx = md.AddToBlobHeap(hashBytes);
     if (entryPoint)
     {
         md.SetEntryPoint(this);
     }
 }
Пример #24
0
 internal sealed override void BuildTables(MetaDataOut md)
 {
     if (!special)
     {
         md.AddToTable(MDTable.TypeRef, this);
         nameIx      = md.AddToStringsHeap(Name);
         nameSpaceIx = md.AddToStringsHeap(NameSpace);
     }
     parent.BuildMDTables(md);
 }
Пример #25
0
 internal sealed override void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.Event, this);
     nameIx = md.AddToStringsHeap(name);
     eventType.BuildMDTables(md);
     for (int i = 0; i < tide; i++)
     {
         methods[i].BuildMDTables(md);
     }
 }
Пример #26
0
 internal sealed override void BuildTables(MetaDataOut md)
 {
     if (!(cmodType is ClassDef))
     {
         cmodType.BuildMDTables(md);
     }
     if (!(type is ClassDef))
     {
         type.BuildMDTables(md);
     }
 }
Пример #27
0
 internal override sealed Type AddTypeSpec(MetaDataOut md)
 {
     if (typeSpecAdded)
     {
         return(this);
     }
     md.ConditionalAddTypeSpec(this);
     BuildMDTables(md);
     typeSpecAdded = true;
     return(this);
 }
Пример #28
0
        /*-------------------- Constructors ---------------------------------*/

        internal PEWriter(PEFileVersionInfo verInfo, string fileName, MetaDataOut md, bool writePDB)
            : base(new FileStream(fileName, FileMode.Create))
        {
            Contract.Requires(verInfo != null);
            Contract.Requires(fileName != null);
            Contract.Requires(md != null);
            InitPEWriter(verInfo, md, writePDB, fileName);
            TimeSpan tmp = System.IO.File.GetCreationTime(fileName).Subtract(FileImage.origin);

            dateStamp = Convert.ToUInt32(tmp.TotalSeconds);
        }
Пример #29
0
 internal sealed override void TypeSig(MemoryStream sig)
 {
     sig.WriteByte(typeIndex);
     genClass.TypeSig(sig);
     //MetaDataOut.CompressNum((uint)genericParams.Count, sig);
     MetaDataOut.CompressNum(BlobUtil.CompressUInt((uint)genericParams.Count), sig);
     for (int i = 0; i < genericParams.Count; i++)
     {
         ((Type)genericParams[i]).TypeSig(sig);
     }
 }
Пример #30
0
        internal byte[] SigBytes()
        {
            MemoryStream sig = new MemoryStream();

            sig.WriteByte(LocalSigByte);
            MetaDataOut.CompressNum(BlobUtil.CompressUInt((uint)locals.Length), sig);
            foreach (Local lcl in locals)
            {
                ((Local)lcl).TypeSig(sig);
            }
            return(sig.ToArray());
        }
Пример #31
0
 internal sealed override void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.ExportedType, this);
     nameSpaceIx = md.AddToStringsHeap(NameSpace);
     nameIx      = md.AddToStringsHeap(Name);
     if (implementation is ModuleRef)
     {
         ModuleFile mFile = ((ModuleRef)implementation).modFile;
         mFile.BuildMDTables(md);
         implementation = mFile;
     }
 }
Пример #32
0
 internal sealed override uint GetBlobIndex(MetaDataOut md)
 {
     if (addedToBlobHeap != md)
     {
         MemoryStream str = new MemoryStream();
         BinaryWriter bw  = new BinaryWriter(str);
         Write(bw);
         blobIndex       = md.AddToBlobHeap(str.ToArray());
         addedToBlobHeap = md;
     }
     return(blobIndex);
 }
Пример #33
0
 internal void BuildSignatures(MetaDataOut md)
 {
     Contract.Requires(md != null);
     if (!retType.isDef())
         retType.BuildSignatures(md);
     for (int i = 0; i < numPars; i++)
     {
         if (!parTypes[i].isDef())
             parTypes[i].BuildSignatures(md);
     }
     for (int i = 0; i < numOptPars; i++)
     {
         if (!optParTypes[i].isDef())
             optParTypes[i].BuildSignatures(md);
     }
 }
Пример #34
0
 internal override sealed void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.Field, this);
     nameIx = md.AddToStringsHeap(name);
     if (!type.isDef()) type.BuildMDTables(md);
     if (initVal != null)
     {
         FieldRVA rva = new FieldRVA(this, initVal);
         rva.BuildMDTables(md);
     }
     if (constVal != null)
     {
         ConstantElem constElem = new ConstantElem(this, constVal);
         constElem.BuildMDTables(md);
     }
     if (hasOffset)
     {
         FieldLayout layout = new FieldLayout(this, offset);
         layout.BuildMDTables(md);
     }
     if (marshalType != null)
     {
         FieldMarshal marshalInfo = new FieldMarshal(this, marshalType);
         marshalInfo.BuildMDTables(md);
     }
 }
Пример #35
0
 internal override sealed void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.Module, this);
     nameIx = md.AddToStringsHeap(name);
     mvidIx = md.AddToGUIDHeap(mvid);
     defaultClass.BuildTables(md);
     foreach (object cls in classes)
     {
         ((Class)cls).BuildMDTables(md);
     }
     foreach (ManifestResource rsrc in resources)
     {
         rsrc.BuildMDTables(md);
     }
 }
Пример #36
0
        /*----------------------------- Writing -----------------------------------------*/
        private void InitPEWriter(PEFileVersionInfo verInfo, MetaDataOut md, bool writePDB, string fileName)
        {
            Contract.Requires(verInfo != null);
            Contract.Requires(md != null);
            Contract.Requires(fileName != null);
            this.verInfo = verInfo;
            if (!verInfo.fromExisting)
                verInfo.lMajor = MetaData.LMajors[(int)verInfo.netVersion];
            if (verInfo.isDLL)
            {
                hintNameTable = FileImage.dllHintNameTable.ToCharArray();
                if (!verInfo.fromExisting) verInfo.characteristics = FileImage.dllCharacteristics;
            }
            else
            {
                hintNameTable = FileImage.exeHintNameTable.ToCharArray();
                if (!verInfo.fromExisting) verInfo.characteristics = FileImage.exeCharacteristics;
            }
            text = new Section(FileImage.textName, 0x60000020);     // IMAGE_SCN_CNT  CODE, EXECUTE, READ
            metaData = md;
            metaData.InitMetaDataOut(this);

            // Check if we should include a PDB file
            if (writePDB)
            {

                // Work out the PDB filename from the PE files filename
                if ((fileName == null) || (fileName == "")) fileName = "default";

                // Setup the PDB Writer object
                pdbWriter = new PDBWriter(fileName);

                // Set the amount of space required for the debug information
                debugBytesSize += pdbWriter.PDBFilename.Length;

            }
        }
Пример #37
0
 internal override sealed void BuildTables(MetaDataOut md)
 {
     if (theType == null) throw new InstructionException(IType.typeOp, instr);
       theType = theType.AddTypeSpec(md);
 }
Пример #38
0
 internal override void BuildSignatures(MetaDataOut md)
 {
     MemoryStream outSig = new MemoryStream();
     TypeSig(outSig);
     sigIx = md.AddToBlobHeap(outSig.ToArray());
 }
Пример #39
0
 internal PEWriter(PEFileVersionInfo verInfo, Stream str, MetaDataOut md)
     : base(str)
 {
     Contract.Requires(verInfo != null);
     Contract.Requires(str != null);
     Contract.Requires(md != null);
     // NOTE: Can not write a PDB file if using a stream.
     InitPEWriter(verInfo, md, false, null);
     TimeSpan tmp = DateTime.Now.Subtract(FileImage.origin);
     dateStamp = Convert.ToUInt32(tmp.TotalSeconds);
     closeStream = false;
 }
Пример #40
0
 internal override sealed void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.MemberRef, this);
     nameIx = md.AddToStringsHeap(name);
     if (parent != null)
     {
         if (parent is ClassSpec) md.ConditionalAddTypeSpec(parent);
         if (parent is ConstructedTypeSpec)
             md.ConditionalAddTypeSpec(((ConstructedTypeSpec)parent).Spec);
         parent.BuildMDTables(md);
     }
     sig.BuildTables(md);
 }
Пример #41
0
 /*----------------------------- internal functions ------------------------------*/
 internal override sealed void BuildTables(MetaDataOut md)
 {
     md.AddToTable(tabIx, this);
 }
Пример #42
0
 internal sealed override void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.FieldMarshal, this);
     ntIx = md.AddToBlobHeap(nt.ToBlob());
 }
Пример #43
0
 internal override sealed void BuildSignatures(MetaDataOut md)
 {
     sig.BuildSignatures(md);
     MemoryStream sigStream = new MemoryStream();
     TypeSig(sigStream);
     sigIx = md.AddToBlobHeap(sigStream.ToArray());
     done = false;
 }
Пример #44
0
 internal virtual void BuildTables(MetaDataOut md)
 {
     Contract.Requires(md != null);
 }
Пример #45
0
 /*------------------------- internal functions --------------------------*/
 internal override sealed void BuildTables(MetaDataOut md)
 {
     md.AddToTable(tabIx, this);
     nameIx = md.AddToStringsHeap(name);
     if (type is ClassSpec) md.ConditionalAddTypeSpec(type);
     if (!type.isDef())
         type.BuildMDTables(md);
     if (parent != null)
     {
       if (parent is ClassSpec) md.ConditionalAddTypeSpec(parent);
       parent.BuildMDTables(md);
     }
 }
Пример #46
0
 internal override sealed void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.FieldLayout, this);
 }
Пример #47
0
 // fix for Whidbey bug
 internal void AddGenericsToTable(MetaDataOut md)
 {
     Contract.Requires(md != null);
     //for (int i=0; i < methods.Count; i++) {
     //  ((MethodDef)methods[i]).AddGenericsToTable(md);
     //}
     for (int i = 0; i < genericParams.Count; i++)
     {
         md.AddToTable(MDTable.GenericParam, (GenericParam)genericParams[i]);
     }
 }
Пример #48
0
 internal override void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.MethodSpec, this);
     if (!(methParent is MethodDef)) // Never build a method def
         methParent.BuildMDTables(md);
     foreach (Type instType in instTypes)
     {
         instType.BuildMDTables(md);
     }
 }
Пример #49
0
        internal override sealed void BuildTables(MetaDataOut md)
        {
            // The processing of superTypes must be done either entirely
              // before or entirely after the processing of this TypeDef.
              // Otherwise the method indices will not be monotonic in table-2.

              if (superType != null) {
            superType.BuildMDTables(md);
            if (superType is ClassSpec) md.ConditionalAddTypeSpec(superType);
              }

              //uint startT = md.TableIndex(MDTable.TypeDef);
              //uint startM = md.TableIndex(MDTable.Method);

              md.AddToTable(MDTable.TypeDef, this);
              methodIx = md.TableIndex(MDTable.Method);
              fieldIx = md.TableIndex(MDTable.Field);

              //Console.WriteLine("Building tables for " + this.TypeName());
              //Console.WriteLine("tIx {0}, methods {1} - {2}",
              //  Hex.Short((short)startT),
              //  Hex.Short((short)startM),
              //  Hex.Short((short)md.TableIndex(MDTable.Method)));

              foreach (GenericParam genericParam in genericParams)
              {
              genericParam.BuildMDTables(md);
              }
            nameIx = md.AddToStringsHeap(Name);
              nameSpaceIx = md.AddToStringsHeap(NameSpace);
              if (security != null) {
            foreach (object sec in security)
            {
                ((DeclSecurity)sec).BuildMDTables(md);
            }
              }

              if (Layout != null) Layout.BuildMDTables(md);

              // Console.WriteLine("adding methods " + methods.Count);
              foreach (object method in methods)
              {
              ((MethodDef)method).BuildMDTables(md);
              }

            // Console.WriteLine("adding fields");
              foreach (object field in fields)
              {
              ((FieldDef)field).BuildMDTables(md);
              }
              // Console.WriteLine("adding interfaceimpls and methodimpls");
              if (interfaces.Count > 0) {
            for (int i = 0; i < interfaces.Count; i++) {
              ((InterfaceImpl)interfaces[i]).BuildMDTables(md);
            }
              }
              if (methodImpls.Count > 0) {
            foreach (object methodImpl in methodImpls)
            {
                ((MethodImpl)methodImpl).BuildMDTables(md);
            }
              }
              // Console.WriteLine("adding events and properties");
              if (events.Count > 0) {
            new MapElem(this, md.TableIndex(MDTable.Event), MDTable.EventMap).BuildMDTables(md);
            for (int i = 0; i < events.Count; i++) {
              ((Event)events[i]).BuildMDTables(md);
            }
              }
              if (properties.Count > 0) {
            new MapElem(this, md.TableIndex(MDTable.Property), MDTable.PropertyMap).BuildMDTables(md);
            for (int i = 0; i < properties.Count; i++) {
              ((Property)properties[i]).BuildMDTables(md);
            }
              }
              // Console.WriteLine("Adding nested classes");
              if (nestedClasses.Count > 0) {
            foreach (object nestedClass in nestedClasses)
            {
                ClassDef nClass = (ClassDef)nestedClass;
                nClass.BuildMDTables(md);
                new MapElem(nClass, this, MDTable.NestedClass).BuildTables(md);
            }
              }
              // Console.WriteLine("End of building tables");
        }
Пример #50
0
 // fix for Whidbey bug
 internal void AddGenericsToTable(MetaDataOut md)
 {
     if (genericParams != null)
     {
         foreach (object genericParam in genericParams)
         {
             md.AddToTable(MDTable.GenericParam, (GenericParam)genericParam);
         }
     }
 }
Пример #51
0
 internal override sealed Type AddTypeSpec(MetaDataOut md)
 {
     md.ConditionalAddTypeSpec(this);
       BuildMDTables(md);
       return this;
 }
Пример #52
0
        internal override sealed void BuildSignatures(MetaDataOut md)
        {
            if (locals != null)
            {
                localSig.BuildSignatures(md);
                locToken = localSig.Token();
            }
            if (code != null)
            {
                // If the stack depth has not been explicity set, try to work out what is needed.
                if (maxStack == 0)
                {
                    try
                    {

                        // Set the flag to show if the return type is void or other.
                        code.ReturnsVoid = GetRetType().SameType(PrimitiveType.Void);

                        // Calculate the max stack depth
                        maxStack = code.GetMaxStackDepthRequired();
                    }
                    catch (CouldNotFindMaxStackDepth)
                    {
                        // Could not find the depth, assign the default
                        maxStack = DefaultMaxStackDepth;
                    }
                }
                code.CheckCode(locToken, initLocals, maxStack, md);
                textOffset = md.AddCode(code);
                if (Diag.DiagOn) Console.WriteLine("code offset = " + textOffset);
            }
            sig.BuildSignatures(md);
            MemoryStream outSig = new MemoryStream();
            TypeSig(outSig);
            sigIx = md.AddToBlobHeap(outSig.ToArray());
            done = false;
        }
Пример #53
0
 internal override void BuildTables(MetaDataOut md)
 {
     if (!genClass.isDef())
         genClass.BuildMDTables(md);
     for (int i = 0; i < genericParams.Count; i++)
     {
         if (!((Type)genericParams[i]).isDef() &&
             (!(genericParams[i] is GenericParam)))
             ((Type)genericParams[i]).BuildMDTables(md);
     }
 }
Пример #54
0
        internal override sealed void BuildTables(MetaDataOut md)
        {
            md.AddToTable(MDTable.Method, this);
            nameIx = md.AddToStringsHeap(name);

            if (genericParams != null)
            {
                foreach (object genericParam in genericParams)
                {
                    ((GenericParam)genericParam).BuildMDTables(md);
                }
            }
            if (security != null)
            {
                foreach (object sec in security)
                {
                    ((DeclSecurity)sec).BuildMDTables(md);
                }
            }
            if (pinvokeImpl != null) pinvokeImpl.BuildMDTables(md);
            if (entryPoint) md.SetEntryPoint(this);
            if (locals != null)
            {
                localSig = new LocalSig(locals);
                localSig.BuildMDTables(md);
            }

              // The following code is done out of line in method
              // TraverseCode *after* all the method indices have
              // been allocated in the metadata.
              // (kjg, March 2010)
            //try {
            //  if (code != null) {
            //    if (code.IsEmpty()) {
            //      code = null;
            //    }
            //    else {
            //      code.BuildTables(md);
            //    }
            //  }
            //}
            //catch (InstructionException ex) {
            //  throw new Exception(ex.AddMethodName(name));
            //}

            parIx = md.TableIndex(MDTable.Param);
            for (int i = 0; i < sig.numPars; i++)
            {
                parList[i].seqNo = (ushort)(i + 1);
                parList[i].BuildMDTables(md);
            }
            sig.BuildTables(md);
        }
Пример #55
0
 /*-------------------- Constructors ---------------------------------*/
 internal PEWriter(PEFileVersionInfo verInfo, string fileName, MetaDataOut md, bool writePDB)
     : base(new FileStream(fileName, FileMode.Create))
 {
     Contract.Requires(verInfo != null);
     Contract.Requires(fileName != null);
     Contract.Requires(md != null);
     InitPEWriter(verInfo, md, writePDB, fileName);
     TimeSpan tmp = System.IO.File.GetCreationTime(fileName).Subtract(FileImage.origin);
     dateStamp = Convert.ToUInt32(tmp.TotalSeconds);
 }
Пример #56
0
 internal void TraverseCode(MetaDataOut md)
 {
     try {
     if (code != null) {
       if (code.IsEmpty()) {
         code = null;
       }
       else {
         code.BuildTables(md);
       }
     }
       }
       catch (InstructionException ex) {
     throw new Exception(ex.AddMethodName(name));
       }
 }
Пример #57
0
 internal override sealed bool Check(MetaDataOut md)
 {
     target = (int)dest.GetLabelOffset() - (int)(offset + size);
       if ((target < minByteVal) || (target > maxByteVal)) { // check for longver
     if (shortVer) {
       if (instr == (uint)BranchOp.leave_s)
     instr = (uint)BranchOp.leave;
       else
     instr = instr += longInstrOffset;
       size += 3;
       shortVer = false;
       return true;
     }
       }
       else if (!shortVer) { // check for short ver
     if (instr == (uint)BranchOp.leave)
       instr = (uint)BranchOp.leave_s;
     else
       instr = instr -= longInstrOffset;
     size -= 3;
     shortVer = true;
     return true;
       }
       return false;
 }
Пример #58
0
 internal override sealed void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.Assembly, this);
     nameIx = md.AddToStringsHeap(name);
     cultIx = md.AddToStringsHeap(culture);
     keyIx = md.AddToBlobHeap(publicKey);
     if (security != null)
     {
         foreach (object dclSecurity in security)
         {
             ((DeclSecurity)dclSecurity).BuildMDTables(md);
         }
     }
 }
Пример #59
0
 internal override void BuildTables(MetaDataOut md)
 {
     if (!(exceptType is ClassDef)) exceptType.BuildMDTables(md);
 }
Пример #60
0
 internal void BuildTables(MetaDataOut md)
 {
     Contract.Requires(md != null);
     // FIXME Contract.Requires(handlers != null);
     foreach (HandlerBlock handler in handlers)
     {
         handler.BuildTables(md);
     }
 }