Exemplo n.º 1
0
 internal RESOURCEHEADER(ByteReader br)
 {
     DataSize   = br.ReadInt32();
     HeaderSize = br.ReadInt32();
     TYPE       = ReadOrdinalOrName(br);
     NAME       = ReadOrdinalOrName(br);
     br.Align(4);
     DataVersion     = br.ReadInt32();
     MemoryFlags     = br.ReadUInt16();
     LanguageId      = br.ReadUInt16();
     Version         = br.ReadInt32();
     Characteristics = br.ReadInt32();
 }
Exemplo n.º 2
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);
         }
     }
 }
Exemplo n.º 3
0
 private static void WriteNameOrOrdinal(ByteBuffer bb, OrdinalOrName id, Dictionary <string, int> strings, ref int stringTableOffset, ByteBuffer stringTable)
 {
     if (id.Name == null)
     {
         bb.Write((int)id.Ordinal);
     }
     else
     {
         int stringOffset;
         if (!strings.TryGetValue(id.Name, out stringOffset))
         {
             stringOffset = stringTableOffset;
             strings.Add(id.Name, stringOffset);
             stringTableOffset += id.Name.Length * 2 + 2;
             stringTable.Write((ushort)id.Name.Length);
             foreach (char c in id.Name)
             {
                 stringTable.Write((short)c);
             }
         }
         bb.Write(0x80000000U | (uint)stringOffset);
     }
 }
Exemplo n.º 4
0
 internal bool IsEqual(OrdinalOrName other)
 {
     return(this.Name == null
         ? this.Ordinal == other.Ordinal
         : String.Compare(this.Name, other.Name, StringComparison.OrdinalIgnoreCase) == 0);
 }
Exemplo n.º 5
0
 internal bool IsGreaterThan(OrdinalOrName other)
 {
     return(this.Name == null
         ? this.Ordinal > other.Ordinal
         : String.Compare(this.Name, other.Name, StringComparison.OrdinalIgnoreCase) > 0);
 }
Exemplo n.º 6
0
 internal ResourceDirectoryEntry(OrdinalOrName id)
 {
     this.OrdinalOrName = id;
 }