Exemplo n.º 1
0
 internal NETHeaderReader(NTHeader header, NETHeader parent)
 {
     this.parent = parent;
     header._assembly._netHeader = parent;
     image = header._assembly._peImage;
     this.ntHeader = header;
 }
Exemplo n.º 2
0
 internal TypeSystem(NETHeader netheader)
 {
     this._managedHeader = netheader;
     if (netheader.ParentAssembly._path.StartsWith(@"C:\Windows\Microsoft.NET\Framework") && netheader.ParentAssembly._path.EndsWith("\\mscorlib.dll"))
         _iscorlib = true;
     else
     {
         _mscorlibRef = new AssemblyReference("mscorlib", AssemblyAttributes.None, new Version(), AssemblyHashAlgorithm.None, 0, null) { _netheader = netheader };
     }
     Void = CreateCorLibTypeRef("System", "Void", ElementType.Void);
     IntPtr = CreateCorLibTypeRef("System", "IntPtr", ElementType.I);
     Int8 = CreateCorLibTypeRef("System", "SByte", ElementType.I1);
     Int16 = CreateCorLibTypeRef("System", "Int16", ElementType.I2);
     Int32 = CreateCorLibTypeRef("System", "Int32", ElementType.I4);
     Int64 = CreateCorLibTypeRef("System", "Int64", ElementType.I8);
     UIntPtr = CreateCorLibTypeRef("System", "UIntPtr", ElementType.U);
     UInt8 = CreateCorLibTypeRef("System", "Byte", ElementType.U1);
     UInt16 = CreateCorLibTypeRef("System", "UInt16", ElementType.U2);
     UInt32 = CreateCorLibTypeRef("System", "UInt32", ElementType.U4);
     UInt64 = CreateCorLibTypeRef("System", "UInt64", ElementType.U8);
     Object = CreateCorLibTypeRef("System", "Object", ElementType.Object);
     Single = CreateCorLibTypeRef("System", "Single", ElementType.R4);
     Double = CreateCorLibTypeRef("System", "Double", ElementType.R8);
     Char = CreateCorLibTypeRef("System", "Char", ElementType.Char);
     String = CreateCorLibTypeRef("System", "String", ElementType.String);
     Type = CreateCorLibTypeRef("System", "Type", ElementType.Type);
     Boolean = CreateCorLibTypeRef("System", "Boolean", ElementType.Boolean);
 }
Exemplo n.º 3
0
        internal MetaDataStream(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name)
        {
            this._headeroffset = headeroffset;
            this._netheader    = netheader;
            this._streamHeader = rawHeader;
            this._name         = name;
            this._indexsize    = 2;

            byte[] contents = netheader._assembly._peImage.ReadBytes(StreamOffset, (int)StreamSize);
            _mainStream = new MemoryStream();
            _binReader  = new BinaryReader(_mainStream);
            _binWriter  = new BinaryWriter(_mainStream);
            _mainStream.Write(contents, 0, contents.Length);
            _mainStream.Seek(0, SeekOrigin.Begin);
        }
Exemplo n.º 4
0
        internal MetaDataStream(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name)
        {
            this._headeroffset = headeroffset;
            this._netheader = netheader;
            this._streamHeader = rawHeader;
            this._name = name;
            this._indexsize = 2;

            byte[] contents = netheader._assembly._peImage.ReadBytes(StreamOffset, (int)StreamSize);
            _mainStream = new MemoryStream();
            _binReader = new BinaryReader(_mainStream);
            _binWriter = new BinaryWriter(_mainStream);
            _mainStream.Write(contents, 0, contents.Length);
            _mainStream.Seek(0, SeekOrigin.Begin);
        }
Exemplo n.º 5
0
 private MetaDataStream GetHeap(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name)
 {
     switch (name)
     {
         case "#~":
         case "#-":
             return new TablesHeap(netheader, headeroffset, rawHeader, name);
         case "#Strings":
             return new StringsHeap(netheader, headeroffset, rawHeader, name);
         case "#US":
             return new UserStringsHeap(netheader, headeroffset, rawHeader, name);
         case "#GUID":
             return new GuidHeap(netheader, headeroffset, rawHeader, name);
         case "#Blob":
             return new BlobHeap(netheader, headeroffset, rawHeader, name);
         default:
             return new MetaDataStream(netheader, headeroffset, rawHeader, name);
     }
 }
Exemplo n.º 6
0
        private MetaDataStream GetHeap(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name)
        {
            switch (name)
            {
            case "#~":
            case "#-":
                return(new TablesHeap(netheader, headeroffset, rawHeader, name));

            case "#Strings":
                return(new StringsHeap(netheader, headeroffset, rawHeader, name));

            case "#US":
                return(new UserStringsHeap(netheader, headeroffset, rawHeader, name));

            case "#GUID":
                return(new GuidHeap(netheader, headeroffset, rawHeader, name));

            case "#Blob":
                return(new BlobHeap(netheader, headeroffset, rawHeader, name));

            default:
                return(new MetaDataStream(netheader, headeroffset, rawHeader, name));
            }
        }
Exemplo n.º 7
0
 public MetaDataRow(uint offset, params ValueType[] parts)
 {
     this._offset = offset;
     this._parts = parts;
     this._netHeader = null;
 }
Exemplo n.º 8
0
 internal UserStringsHeap(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name)
     : base(netheader, headeroffset, rawHeader, name)
 {
 }
Exemplo n.º 9
0
 public MetaDataTokenResolver(NETHeader netheader)
 {
     this._netheader = netheader;
 }
Exemplo n.º 10
0
 public BlobSignatureReader(byte[] bytes, NETHeader netHeader)
     : this(new MemoryStream(bytes), netHeader)
 {
 }
Exemplo n.º 11
0
 public static MSILInstruction Create(MSILOpCode opcode, uint metadataToken, NETHeader netHeader)
 {
     return new MSILInstruction() { OpCode = opcode, OperandBytes = BitConverter.GetBytes(metadataToken), Operand = netHeader.TokenResolver.ResolveToken(metadataToken) };
 }
Exemplo n.º 12
0
        /// <summary>
        /// Gets the Portable Executeable's NT header by specifing the assembly.
        /// </summary>
        /// <param name="assembly">The assembly to read the nt header</param>
        /// <returns></returns>
        public static NETHeader FromAssembly(LWin32 assembly)
        {
            NETHeader header = new NETHeader();

            header._assembly = assembly;
            NETHeaderReader reader = new NETHeaderReader(assembly._ntHeader, header);
            header._metadata = new MetaDataHeader(reader);
            reader.LoadData();
            header.TokenResolver = new MetaDataTokenResolver(header);
            return header;
        }
Exemplo n.º 13
0
 public BlobSignatureReader(byte[] bytes, NETHeader netHeader)
     : this(new MemoryStream(bytes), netHeader)
 {
 }
Exemplo n.º 14
0
 public BlobSignatureReader(Stream input, NETHeader netHeader)
     : base(input)
 {
     _netHeader = netHeader;
 }
Exemplo n.º 15
0
 public MetaDataRow(uint offset, params ValueType[] parts)
 {
     this._offset    = offset;
     this._parts     = parts;
     this._netHeader = null;
 }
Exemplo n.º 16
0
 internal TablesHeap(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name)
     : base(netheader, headeroffset, rawHeader, name)
 {
 }
Exemplo n.º 17
0
 public MetaDataTokenResolver(NETHeader netheader)
 {
     this._netheader = netheader;
 }
Exemplo n.º 18
0
 public BlobSignatureReader(Stream input, NETHeader netHeader)
     : base(input)
 {
     _netHeader = netHeader;
 }