Example #1
0
        public override void VisitAssemblyLinkedResource(AssemblyLinkedResource res)
        {
            MetadataToken impl = new MetadataToken(TokenType.AssemblyRef,
                                                   (uint)m_asm.MainModule.AssemblyReferences.IndexOf(res.Assembly) + 1);

            AddManifestResource(0, res.Name, res.Flags, impl);
        }
Example #2
0
        public override void VisitResourceCollection(ResourceCollection resources)
        {
            if (!m_tHeap.HasTable(ManifestResourceTable.RId))
            {
                return;
            }

            ManifestResourceTable mrTable = m_tableReader.GetManifestResourceTable();
            FileTable             fTable  = m_tableReader.GetFileTable();

            BinaryReader br;

            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);

                    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;
                }
            }
        }
		private void HandleItem(AssemblyLinkedResource alres)
		{
			_alres = alres;
			Attributes.Bind(alres);
			NameReference.Bind(alres == null ? null : alres.Assembly);
		}
Example #4
0
		public override void VisitAssemblyLinkedResource (AssemblyLinkedResource res)
		{
			MetadataToken impl = new MetadataToken (TokenType.AssemblyRef,
				(uint) m_asm.MainModule.AssemblyReferences.IndexOf (res.Assembly) + 1);

			AddManifestResource (0, res.Name, res.Flags, impl);
		}
		public override void VisitAssemblyLinkedResource (AssemblyLinkedResource res)
		{
			target.MainModule.Resources.Add (res);
		}
		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;
				}
			}
		}
Example #7
0
		/// <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 virtual void VisitAssemblyLinkedResource (AssemblyLinkedResource res)
		{
		}
 private void ShowResource(AssemblyLinkedResource alr)
 {
     ShowText(String.Format("AssemblyLinkedResource: {0}", alr.Assembly.FullName), null, false);
 }
Example #10
0
 public AssemblyResourceItem(AssemblyLinkedResource resource)
     : base(resource, "AssemblyResourceItem")
 {
     m_resource = resource;
 }
 public virtual void VisitAssemblyLinkedResource(AssemblyLinkedResource res)
 {
 }
 public override void VisitAssemblyLinkedResource(AssemblyLinkedResource res)
 {
     // TODO.
 }
		public override void VisitAssemblyLinkedResource (AssemblyLinkedResource alr)
		{
			m_writer.Write (".assembly extern ");
			m_writer.BaseWriter.WriteLine (Formater.Escape (alr.Assembly.Name));
		}