internal NETHeaderReader(NTHeader header, NETHeader parent) { this.parent = parent; header._assembly._netHeader = parent; image = header._assembly._peImage; this.ntHeader = header; }
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); }
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); }
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); }
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); } }
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)); } }
public MetaDataRow(uint offset, params ValueType[] parts) { this._offset = offset; this._parts = parts; this._netHeader = null; }
internal UserStringsHeap(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name) : base(netheader, headeroffset, rawHeader, name) { }
public MetaDataTokenResolver(NETHeader netheader) { this._netheader = netheader; }
public BlobSignatureReader(byte[] bytes, NETHeader netHeader) : this(new MemoryStream(bytes), netHeader) { }
public static MSILInstruction Create(MSILOpCode opcode, uint metadataToken, NETHeader netHeader) { return new MSILInstruction() { OpCode = opcode, OperandBytes = BitConverter.GetBytes(metadataToken), Operand = netHeader.TokenResolver.ResolveToken(metadataToken) }; }
/// <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; }
public BlobSignatureReader(byte[] bytes, NETHeader netHeader) : this(new MemoryStream(bytes), netHeader) { }
public BlobSignatureReader(Stream input, NETHeader netHeader) : base(input) { _netHeader = netHeader; }
public MetaDataRow(uint offset, params ValueType[] parts) { this._offset = offset; this._parts = parts; this._netHeader = null; }
internal TablesHeap(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name) : base(netheader, headeroffset, rawHeader, name) { }
public MetaDataTokenResolver(NETHeader netheader) { this._netheader = netheader; }
public BlobSignatureReader(Stream input, NETHeader netHeader) : base(input) { _netHeader = netHeader; }