Exemple #1
0
 internal override sealed void Write(PEWriter output)
 {
     base.Write(output);
     output.Write(numCases);
     for (int i=0; i < numCases; i++) {
         int target = (int)cases[i].GetLabelOffset() - (int)(offset + size);
         output.Write(target);
     }
 }
Exemple #2
0
 internal override sealed void Write(PEWriter output)
 {
     //Console.WriteLine("Writing assembly element with nameIx of " + nameIx + " at file offset " + output.Seek(0,SeekOrigin.Current));
     output.Write((uint)hashAlgId);
     output.Write(majorVer);
     output.Write(minorVer);
     output.Write(buildNo);
     output.Write(revisionNo);
     output.Write(flags);
     output.BlobIndex(keyIx);
     output.StringsIndex(nameIx);
     output.StringsIndex(cultIx);
 }
Exemple #3
0
 internal override void Write(PEWriter output)
 {
     //Console.WriteLine("Writing instruction " + instr + " with size " + size);
     if (twoByteInstr) output.Write(leadByte);
     output.Write((byte)instr);
 }
Exemple #4
0
 internal override void Write(PEWriter output, bool fatFormat)
 {
     base.Write(output,fatFormat);
     output.Write(filterLabel.GetLabelOffset());
 }
Exemple #5
0
 internal override sealed void Write(PEWriter output)
 {
     output.Write((byte)0x22);
     output.Write(fVal);
 }
Exemple #6
0
 internal override sealed void Write(PEWriter output)
 {
     output.Write(flags);
     output.StringsIndex(nameIx);
     output.WriteCodedIndex(CIx.TypeDefOrRef,eventType);
 }
Exemple #7
0
 internal override sealed void Write(PEWriter output)
 {
     output.Write(offset);
     output.WriteIndex(MDTable.Field,field.Row);
 }
Exemple #8
0
 internal override void Write(PEWriter output)
 {
     output.Write(byteVal);
 }
Exemple #9
0
 internal void WriteByteCodes(PEWriter output)
 {
     for (int i=0; i < byteCodes.Count; i++) {
         ((CILInstructions)byteCodes[i]).Write(output);
     }
     for (int i=0; i < byteCodePadding; i++) {
         output.Write((byte)0);
     }
 }
Exemple #10
0
 internal override void Write(PEWriter output, bool fatFormat)
 {
     base.Write(output,fatFormat);
     output.Write(exceptType.Token());
 }
Exemple #11
0
 internal override sealed void Write(PEWriter output)
 {
     output.Write(flags);
     output.Write(0);
     output.StringsIndex(nameIx);
     output.StringsIndex(nameSpaceIx);
     output.WriteCodedIndex(CIx.Implementation,implementation);
 }
Exemple #12
0
 internal override sealed void Write(PEWriter output)
 {
     output.Write(cValue.GetTypeIndex());
     output.Write((byte)0);
     output.WriteCodedIndex(CIx.HasConstant,parent);
     output.BlobIndex(valIx);
 }
Exemple #13
0
 internal override sealed void Write(PEWriter output)
 {
     output.Write(packSize);
     output.Write(classSize);
     output.WriteIndex(MDTable.TypeDef,parent.Row);
 }
Exemple #14
0
 internal override void Write(PEWriter output, bool fatFormat)
 {
     if (Diag.DiagOn) Console.WriteLine("writing exception details");
     for (int i=0; i < handlers.Count; i++) {
         if (Diag.DiagOn) Console.WriteLine("Except block " + i);
         HandlerBlock handler = (HandlerBlock)handlers[i];
         flags = handler.GetFlag();
         if (Diag.DiagOn) Console.WriteLine("flags = " + flags);
         if (fatFormat) output.Write((uint)flags);
         else output.Write(flags);
         base.Write(output,fatFormat);
         handler.Write(output,fatFormat);
     }
 }
Exemple #15
0
 internal override sealed void Write(PEWriter output)
 {
     output.Write((UInt16)action);   // or should this be 2 bytes??
     output.WriteCodedIndex(CIx.HasDeclSecurity,parent);
     output.BlobIndex(permissionIx);
 }
Exemple #16
0
 internal void WriteCodedIndex(CIx code, MetaDataElement elem, PEWriter output)
 {
     uint ix = 0;
     if (elem != null) {
         ix = (elem.Row << CIxShiftMap[(uint)code]) | elem.GetCodedIx(code);
         // Console.WriteLine("coded index = " + ix + " row = " + elem.Row);
         //} else {
         // Console.WriteLine("elem for coded index is null");
     }
     if (lgeCIx[(uint)code])
         output.Write(ix);
     else
         output.Write((ushort)ix);
 }
Exemple #17
0
 internal override sealed void Write(PEWriter output)
 {
     base.Write(output);
     output.Write(val);
 }
Exemple #18
0
 internal void WriteMetaData(PEWriter output)
 {
     this.output = output;
     if (Diag.DiagOn) {
         mdStart = output.Seek(0,SeekOrigin.Current);
         Console.WriteLine("Writing metaData at " + Hex.Long(mdStart));
     }
     output.Write(MetaDataSignature);
     output.Write(output.verInfo.mdMajVer);
     output.Write(output.verInfo.mdMinVer);
     output.Write(0);         // Reserved
     output.Write(output.verInfo.netVerString.Length);
     output.Write(output.verInfo.netVerString.ToCharArray());   // version string is already zero padded
     output.Write((short)0);  // Flags, reserved
     output.Write((ushort)numStreams);
     // write tilde header
     output.Write(tildeStart);
     output.Write(tildeTide + tildePadding);
     output.Write(tildeNameArray);
     for (int i=1; i < numStreams; i++) {
         if (Diag.DiagOn)
             Console.WriteLine("Stream " + new String(streams[i].name) + " should start at " + Hex.Long(streams[i].Start+mdStart));
         streams[i].WriteHeader(output);
     }
     if (Diag.DiagOn) {
         Console.Write("Writing tilde stream at " + Hex.Long(output.Seek(0,SeekOrigin.Current)));
         Console.WriteLine(" should be at " + Hex.Long(tildeStart + mdStart));
     }
     WriteTildeStream(output);
     for (int i=1; i < numStreams; i++) {
         if (Diag.DiagOn)
             Console.WriteLine("Writing stream " + new String(streams[i].name) + " at " + Hex.Long(output.Seek(0,SeekOrigin.Current)));
         streams[i].Write(output);
     }
     //Console.WriteLine("Finished Writing metaData at " + output.Seek(0,SeekOrigin.Current));
 }
Exemple #19
0
 internal override sealed void Write(PEWriter output)
 {
     base.Write(output);
     output.Write(field.Token());
 }
Exemple #20
0
 internal void WriteResources(PEWriter output)
 {
     if (resources == null) return;
     for (int i=0; i < resources.Count; i++) {
         byte[] resBytes = (byte[])resources[i];
         output.Write((uint)resBytes.Length);
         output.Write(resBytes);
     }
 }
Exemple #21
0
 internal override sealed void Write(PEWriter output)
 {
     output.Write(flags);
     output.StringsIndex(nameIx);
     output.BlobIndex(hashIx);
 }
Exemple #22
0
 internal void WriteTildeStream(PEWriter output)
 {
     long startTilde = output.Seek(0,SeekOrigin.Current);
     //Console.WriteLine("Starting tilde output at offset " + Hex.Long(startTilde));
     output.Write((uint)0); // Reserved
     output.Write(output.verInfo.tsMajVer); // MajorVersion
     output.Write(output.verInfo.tsMinVer); // MinorVersion
     output.Write(heapSizes);
     output.Write((byte)1); // Reserved
     output.Write(valid);
     output.Write(sorted);
     for (int i=0; i < NumMetaDataTables; i++) {
         if (tables[i] != null) {
             uint count = (uint)tables[i].Count;
             output.Write(count);
         }
     }
     long tabStart = output.Seek(0,SeekOrigin.Current);
     //Console.WriteLine("Starting metaData tables at " + tabStart);
     for (int i=0; i < NumMetaDataTables; i++) {
         if (tables[i] != null) {
             //Console.WriteLine("Starting metaData table " + i + " at " + (output.Seek(0,SeekOrigin.Current) - startTilde));
             ArrayList table = tables[i];
             for (int j=0; j < table.Count; j++) {
                 ((MetaDataElement)table[j]).Write(output);
             }
         }
     }
     // reset the typespec flags
     if (tables[(int)MDTable.TypeSpec] != null) {
         ArrayList typeSpecTable = tables[(int)MDTable.TypeSpec];
         for (int i=0; i < typeSpecTable.Count; i++) {
             ((TypeSpec)typeSpecTable[i]).typeSpecAdded = false;
         }
     }
     //Console.WriteLine("Writing padding at " + output.Seek(0,SeekOrigin.Current));
     for (int i=0; i < tildePadding; i++) output.Write((byte)0);
 }
Exemple #23
0
 internal override void Write(PEWriter output, bool fatFormat)
 {
     base.Write(output,fatFormat);
     output.Write((int)0);
 }
Exemple #24
0
        internal void Write(PEWriter output)
        {
            if (Diag.DiagOn) Console.WriteLine("Writing header flags = " + Hex.Short(headerFlags));
            if (tinyFormat) {
                if (Diag.DiagOn) Console.WriteLine("Writing tiny code");
                output.Write((byte)headerFlags);
            } else {
                if (Diag.DiagOn) Console.WriteLine("Writing fat code");
                output.Write(headerFlags);
                output.Write((ushort)maxStack);
                output.Write(offset);
                output.Write(localSigIx);
            }
            if (Diag.DiagOn) {
                Console.WriteLine(Hex.Int(tide) + " CIL instructions");
                Console.WriteLine("starting instructions at " + output.Seek(0,SeekOrigin.Current));
            }

            // Added to enable PDB generation
            if (output.pdbWriter != null) {

                // Open the method
                output.pdbWriter.OpenMethod((int)thisMeth.Token());

                // Check if this is the entry point method
                if (thisMeth.HasEntryPoint()) output.pdbWriter.SetEntryPoint((int)thisMeth.Token());
            }

            // Write out each memember of the buffer
            for (int i=0; i < tide; i++) {
                buffer[i].Write(output);
            }

            // Added to enable PDB generation
            if (output.pdbWriter != null && tide > 0) {
                output.pdbWriter.CloseMethod();
            }
            if (Diag.DiagOn) Console.WriteLine("ending instructions at " + output.Seek(0,SeekOrigin.Current));
            for (int i=0; i < paddingNeeded; i++) { output.Write((byte)0); }
            if (exceptions != null) {
                // Console.WriteLine("Writing exceptions");
                // Console.WriteLine("header = " + Hex.Short(exceptHeader) + " exceptSize = " + Hex.Int(exceptSize));
                output.Write(exceptHeader);
                output.Write3Bytes((uint)exceptSize);
                for (int i=0; i < exceptions.Count; i++) {
                    TryBlock tryBlock = (TryBlock)exceptions[i];
                    tryBlock.Write(output,fatExceptionFormat);
                }
            }
        }
Exemple #25
0
 internal override void Write(PEWriter output)
 {
     output.Write(index);
     output.Write(flags);
     output.WriteCodedIndex(CIx.TypeOrMethodDef,parent);
     output.StringsIndex(nameIx);
     if (extraField) output.Write(kind);
 }
Exemple #26
0
 internal override sealed void Write(PEWriter output)
 {
     output.Write(flags);
     output.StringsIndex(nameIx);
     output.StringsIndex(nameSpaceIx);
     //if (superType != null)
     // Console.WriteLine("getting coded index for superType of " + name + " = " + superType.GetCodedIx(CIx.TypeDefOrRef));
     output.WriteCodedIndex(CIx.TypeDefOrRef,superType);
     output.WriteIndex(MDTable.Field,fieldIx);
     output.WriteIndex(MDTable.Method,methodIx);
 }
Exemple #27
0
 internal override sealed void Write(PEWriter output)
 {
     output.Write(flags);
     output.WriteCodedIndex(CIx.MemberForwarded,meth);
     output.StringsIndex(iNameIx);
     output.WriteIndex(MDTable.ModuleRef,importScope.Row);
 }
Exemple #28
0
 internal virtual void Write(PEWriter output, bool fatFormat)
 {
     if (fatFormat) output.Write(start.GetLabelOffset());
     else output.Write((short)start.GetLabelOffset());
     uint len = end.GetLabelOffset() - start.GetLabelOffset();
     if (Diag.DiagOn) Console.WriteLine("block start = " + start.GetLabelOffset() + "  len = " + len);
     if (fatFormat) output.Write(len);
     else output.Write((byte)len);
 }
Exemple #29
0
 internal override sealed void Write(PEWriter output)
 {
     base.Write(output);
     if (byteNum)
         output.Write((sbyte)val);
     else
         output.Write(val);
 }
Exemple #30
0
 internal override sealed void Write(PEWriter output)
 {
     base.Write(output);
     output.Write(USHeapIndex  | strIndex);
 }