public ResourceDirectoryEntry(Resources resources, Reader reader, List <Entry> entries, ref int offset) { this.reader = reader; this.resources = resources; this.entries = entries; this.localEntries = new List <Entry>(); this.resourceTables = new List <ResourceDirectoryTable>(); this.dataEntry = null; this.Name = new NumericEntry(null, true, "Name", offset, EntrySize._32Bits); offset += (int)this.Name.getRawSize(); this.OffsetToData = new NumericEntry(null, true, "OffsetToData", offset, EntrySize._32Bits); offset += (int)this.OffsetToData.getRawSize(); this.Name.readValue(this.reader); this.localEntries.Add(this.Name); this.OffsetToData.readValue(this.reader); this.localEntries.Add(this.OffsetToData); }
public void readInformations(ref int offset) { UInt32 nameOffset = (UInt32)this.Name.getValue(); // the directory is named if (nameOffset >= 0x80000000) { isNamedDirectory = true; // insure the size UInt32 nameDefinitionBlock = (nameOffset - (UInt32)0x80000000); int nameBlockOffset = (int)nameDefinitionBlock + resources.resourceBaseAddress; // read the name length int unicodeStringSize = reader.readByte(nameBlockOffset); // read the unicode name directoryName = reader.readUnicodeString(nameBlockOffset + 1, unicodeStringSize); } // the directory has a common id else { // the directory id is typed if (firstNode) { // don't know how I can handle properly exceptions here directoryType = (ResourceTypes)Enum.Parse(typeof(ResourceTypes), Enum.GetName(typeof(ResourceTypes), (int)nameOffset), true); directoryId = (int)nameOffset; } // the directory id is an ordinal else { directoryId = (int)nameOffset; } } UInt32 tableOffset = (UInt32)this.OffsetToData.getValue(); if (tableOffset >= 0x80000000) { // insure the size UInt32 nextResourceDirectoryTable = (tableOffset - (UInt32)0x80000000); // probably the wrost way to do it offset = (int)nextResourceDirectoryTable + resources.resourceBaseAddress; ResourceDirectoryTable newEntry = new ResourceDirectoryTable(this.resources, this.reader, entries, ref offset); this.resourceTables.Add(newEntry); } else { // probably the wrost way to do it offset = (int)tableOffset + resources.resourceBaseAddress; this.dataEntry = new ResourceDataEntry(this.resources, this.reader, entries, ref offset); } }