Esempio n. 1
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;
            }
        }
Esempio n. 2
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;

            }
        }
Esempio n. 3
0
        internal void WriteLocals(PDBWriter writer)
        {
            try {

            Local[] locals = _thisMeth.GetLocals();

            foreach (LocalBinding binding in _localBindings) {
              writer.BindLocal(binding._name, binding._index, _thisMeth.locToken, 0, 0);
            }
              }
              catch (Exception e) {
            throw new Exception("Exception while writing debug info for: " +
            this._thisMeth.NameString() + "\r\n" + e.ToString(), e);
              }
        }