public override void VisitLinkedResource (LinkedResource res) { FileTable fTable = m_tableWriter.GetFileTable (); FileRow fRow = m_rowWriter.CreateFileRow ( Mono.Cecil.FileAttributes.ContainsNoMetaData, m_mdWriter.AddString (res.File), m_mdWriter.AddBlob (res.Hash)); fTable.Rows.Add (fRow); AddManifestResource ( 0, res.Name, res.Flags, new MetadataToken (TokenType.File, (uint) fTable.Rows.IndexOf (fRow) + 1)); }
public override void VisitResourceCollection (ResourceCollection resources) { if (!m_tHeap.HasTable (ManifestResourceTable.RId)) return; ManifestResourceTable mrTable = m_tableReader.GetManifestResourceTable (); FileTable fTable = m_tableReader.GetFileTable (); for (int i = 0; i < mrTable.Rows.Count; i++) { ManifestResourceRow mrRow = mrTable [i]; if (mrRow.Implementation.RID == 0) { EmbeddedResource eres = new EmbeddedResource ( ReadString (mrRow.Name), mrRow.Flags); BinaryReader br = m_ir.MetadataReader.GetDataReader ( m_img.CLIHeader.Resources.VirtualAddress); br.BaseStream.Position += mrRow.Offset; eres.Data = br.ReadBytes (br.ReadInt32 ()); resources.Add (eres); continue; } switch (mrRow.Implementation.TokenType) { case TokenType.File : FileRow fRow = fTable [(int) mrRow.Implementation.RID - 1]; LinkedResource lres = new LinkedResource ( ReadString (mrRow.Name), mrRow.Flags, ReadString (fRow.Name)); lres.Hash = ReadBlob (fRow.HashValue); resources.Add (lres); break; case TokenType.AssemblyRef : AssemblyNameReference asm = m_module.AssemblyReferences [(int) mrRow.Implementation.RID - 1]; AssemblyLinkedResource alr = new AssemblyLinkedResource ( ReadString (mrRow.Name), mrRow.Flags, asm); resources.Add (alr); break; } } }
public override void VisitLinkedResource (LinkedResource res) { target.MainModule.Resources.Add (res); }
public virtual void VisitLinkedResource (LinkedResource res) { }
/// <summary> /// Inject a resource to a module definition /// </summary> /// <param name="mdef">Module definition</param> /// <param name="name">Resource name</param> /// <param name="resourceType">Resource type</param> /// <returns>resource</returns> public static Resource InjectResource(ModuleDefinition mdef, string name, ResourceType resourceType) { Resource result; switch (resourceType) { case ResourceType.AssemblyLinked: var anref = new AssemblyNameReference(name, new Version()); mdef.AssemblyReferences.Add(anref); result = new AssemblyLinkedResource(name, ManifestResourceAttributes.Public, anref); break; case ResourceType.Embedded: result = new EmbeddedResource(name, ManifestResourceAttributes.Public, new byte[] {}); break; case ResourceType.Linked: result = new LinkedResource(name, ManifestResourceAttributes.Public); break; default: throw new ArgumentException(); } mdef.Resources.Add(result); return result; }
public LinkedResourceItem(LinkedResource resource) : base(resource, "LinkedResourceItem") { m_resource = resource; }
private void ShowResource(LinkedResource lr) { ShowText(String.Format("LinkedResource: {0}", lr.File), null, false); }
public virtual void VisitLinkedResource(LinkedResource res) { }
public override void VisitLinkedResource(LinkedResource res) { // TODO. }
private void HandleItem(LinkedResource lres) { _lres = lres; Attributes.Bind(lres); }
void HandleItem(LinkedResource lres) { this.lres = lres; Attributes.Bind(lres); }
public override void VisitLinkedResource (LinkedResource lr) { m_writer.Write (".file "); m_writer.BaseWriter.Write (Formater.Escape (lr.File)); m_writer.BaseWriter.WriteLine (" at 0x0"); }