public void readEntries(ref int offset, bool firstTime)
        {
            // read named entries + id entries
            for (int i = 0; i < this.NumberOfNamedEntries.getValue() + this.NumberOfIdEntries.getValue(); i++)
            {
                var newEntry = new ResourceDirectoryEntry(this.resources, this.reader, entries, ref offset);

                if (firstTime)
                {
                    newEntry.firstNode = true;
                }

                this.resourceEntries.Add(newEntry);
            }

            // read sub branchs
            foreach (ResourceDirectoryEntry entry in resourceEntries)
            {
                entry.readInformations(ref offset);

                foreach (ResourceDirectoryTable table in entry.resourceTables)
                {
                    table.readEntries(ref offset, false);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Get the data node from its resource type and id
        /// </summary>
        /// <param name="type">Resource type</param>
        /// <param name="id">Resource id</param>
        /// <returns>Data entry corresponding to arguments</returns>
        public ResourceDataEntry getResourceDataFromId(ResourceTypes type, int id)
        {
            List <ResourceDirectoryEntry> nodes = getNodesFromResourceType(type);

            if (nodes.Count <= 0)
            {
                return(null);
            }

            ResourceDirectoryEntry selectedNode = null;

            foreach (ResourceDirectoryEntry node in nodes)
            {
                if (node.directoryId == id)
                {
                    selectedNode = node;
                }
            }

            if (selectedNode == null)
            {
                return(null);
            }

            ResourceDirectoryEntry dataDirectory = null;

            // in reality, after first node, there is only one table
            foreach (ResourceDirectoryEntry item in selectedNode.resourceTables[0].resourceEntries)
            {
                // end node (not documented ?)
                if (item.directoryId == 1033)
                {
                    dataDirectory = item;
                }
            }

            if (dataDirectory == null)
            {
                return(null);
            }

            return(dataDirectory.dataEntry);
        }
예제 #3
0
        /// <summary>
        /// Get sub node for a resource type
        /// </summary>
        /// <param name="type">Resource type</param>
        /// <returns>A list of directory entry for a resource type</returns>
        public List <ResourceDirectoryEntry> getNodesFromResourceType(ResourceTypes type)
        {
            List <ResourceDirectoryEntry> nodes = new List <ResourceDirectoryEntry>();

            ResourceDirectoryEntry startNode = getEntryFromResourceType(type);

            if (startNode.resourceTables.Count <= 0)
            {
                return(null);
            }

            // in reality, after first node, there is only one table
            foreach (ResourceDirectoryEntry item in startNode.resourceTables[0].resourceEntries)
            {
                nodes.Add(item);
            }

            return(nodes);
        }