示例#1
0
 internal void Finish()
 {
     if (bb != null)
     {
         throw new InvalidOperationException();
     }
     bb          = new ByteBuffer(1024);
     linkOffsets = new List <int>();
     root.Write(bb, linkOffsets);
     root = null;
 }
		private static void ExtractResources(ResourceDirectoryEntry root, byte[] buf)
		{
			ByteReader br = new ByteReader(buf, 0, buf.Length);
			while (br.Length >= 32)
			{
				br.Align(4);
				RESOURCEHEADER hdr = new RESOURCEHEADER(br);
				if (hdr.DataSize != 0)
				{
					root[hdr.TYPE][hdr.NAME][new OrdinalOrName(hdr.LanguageId)].Data = ByteBuffer.Wrap(br.ReadBytes(hdr.DataSize));
				}
			}
		}
		internal ResourceSection(ByteBuffer versionInfo, byte[] unmanagedResources)
		{
			ResourceDirectoryEntry root = new ResourceDirectoryEntry(new OrdinalOrName("root"));
			if (versionInfo != null)
			{
				root[new OrdinalOrName(16)][new OrdinalOrName(1)][new OrdinalOrName(0)].Data = versionInfo;
			}
			else if (unmanagedResources != null)
			{
				ExtractResources(root, unmanagedResources);
			}
			root.Write(bb, linkOffsets);
		}
示例#4
0
        private static void ExtractResources(ResourceDirectoryEntry root, byte[] buf)
        {
            ByteReader br = new ByteReader(buf, 0, buf.Length);

            while (br.Length >= 32)
            {
                br.Align(4);
                RESOURCEHEADER hdr = new RESOURCEHEADER(br);
                if (hdr.DataSize != 0)
                {
                    root[hdr.TYPE][hdr.NAME][new OrdinalOrName(hdr.LanguageId)].Data = ByteBuffer.Wrap(br.ReadBytes(hdr.DataSize));
                }
            }
        }
示例#5
0
        internal ResourceSection(ByteBuffer versionInfo, byte[] unmanagedResources)
        {
            ResourceDirectoryEntry root = new ResourceDirectoryEntry(new OrdinalOrName("root"));

            if (versionInfo != null)
            {
                root[new OrdinalOrName(16)][new OrdinalOrName(1)][new OrdinalOrName(0)].Data = versionInfo;
            }
            else if (unmanagedResources != null)
            {
                ExtractResources(root, unmanagedResources);
            }
            root.Write(bb, linkOffsets);
        }
示例#6
0
 internal ResourceDirectoryEntry this[OrdinalOrName id]
 {
     get
     {
         foreach (ResourceDirectoryEntry entry in entries)
         {
             if (entry.OrdinalOrName.IsEqual(id))
             {
                 return(entry);
             }
         }
         // the entries must be sorted
         ResourceDirectoryEntry newEntry = new ResourceDirectoryEntry(id);
         if (id.Name == null)
         {
             for (int i = namedEntries; i < entries.Count; i++)
             {
                 if (entries[i].OrdinalOrName.IsGreaterThan(id))
                 {
                     entries.Insert(i, newEntry);
                     return(newEntry);
                 }
             }
             entries.Add(newEntry);
             return(newEntry);
         }
         else
         {
             for (int i = 0; i < namedEntries; i++)
             {
                 if (entries[i].OrdinalOrName.IsGreaterThan(id))
                 {
                     entries.Insert(i, newEntry);
                     namedEntries++;
                     return(newEntry);
                 }
             }
             entries.Insert(namedEntries++, newEntry);
             return(newEntry);
         }
     }
 }
示例#7
0
 internal ResourceDirectoryEntry this[OrdinalOrName id]
 {
     get
     {
         foreach (ResourceDirectoryEntry entry in entries)
         {
             if (entry.OrdinalOrName.Ordinal == id.Ordinal && entry.OrdinalOrName.Name == id.Name)
             {
                 return(entry);
             }
         }
         ResourceDirectoryEntry newEntry = new ResourceDirectoryEntry(id);
         if (id.Name == null)
         {
             entries.Add(newEntry);
         }
         else
         {
             entries.Insert(namedEntries++, newEntry);
         }
         return(newEntry);
     }
 }
示例#8
0
		internal ResourceDirectoryEntry this[OrdinalOrName id]
		{
			get
			{
				foreach (ResourceDirectoryEntry entry in entries)
				{
					if (entry.OrdinalOrName.Ordinal == id.Ordinal && entry.OrdinalOrName.Name == id.Name)
					{
						return entry;
					}
				}
				ResourceDirectoryEntry newEntry = new ResourceDirectoryEntry(id);
				if (id.Name == null)
				{
					entries.Add(newEntry);
				}
				else
				{
					entries.Insert(namedEntries++, newEntry);
				}
				return newEntry;
			}
		}
示例#9
0
		internal void Finish()
		{
			if (bb != null)
			{
				throw new InvalidOperationException();
			}
			bb = new ByteBuffer(1024);
			linkOffsets = new List<int>();
			root.Write(bb, linkOffsets);
			root = null;
		}
		internal ResourceDirectoryEntry this[OrdinalOrName id]
		{
			get
			{
				foreach (ResourceDirectoryEntry entry in entries)
				{
					if (entry.OrdinalOrName.IsEqual(id))
					{
						return entry;
					}
				}
				// the entries must be sorted
				ResourceDirectoryEntry newEntry = new ResourceDirectoryEntry(id);
				if (id.Name == null)
				{
					for (int i = namedEntries; i < entries.Count; i++)
					{
						if (entries[i].OrdinalOrName.IsGreaterThan(id))
						{
							entries.Insert(i, newEntry);
							return newEntry;
						}
					}
					entries.Add(newEntry);
					return newEntry;
				}
				else
				{
					for (int i = 0; i < namedEntries; i++)
					{
						if (entries[i].OrdinalOrName.IsGreaterThan(id))
						{
							entries.Insert(i, newEntry);
							namedEntries++;
							return newEntry;
						}
					}
					entries.Insert(namedEntries++, newEntry);
					return newEntry;
				}
			}
		}