Beispiel #1
0
        protected void CopyTo(ResourceDataEntry copy)
        {
            copy._data     = Data;
            copy._codePage = _codePage;

            base.CopyTo(copy);
        }
Beispiel #2
0
        public new ResourceDataEntry Clone()
        {
            var copy = new ResourceDataEntry();

            CopyTo(copy);

            return(copy);
        }
Beispiel #3
0
        private void WriteDataEntry(ResourceDataEntry dataEntry)
        {
            PE.Fixups.Add(new WriteRVAFixup(_state.Blob, _state.DataDescriptionPos, _state.DataPos));
            _state.Blob.Write(ref _state.DataDescriptionPos, (uint)0);

            _state.Blob.Write(ref _state.DataDescriptionPos, (int)dataEntry.Length);
            _state.Blob.Write(ref _state.DataDescriptionPos, (uint)dataEntry.CodePage);
            _state.Blob.Write(ref _state.DataDescriptionPos, (uint)0);
            _state.Blob.Write(ref _state.DataPos, dataEntry.Data);
            _state.DataPos = _state.DataPos.Align(4);
        }
Beispiel #4
0
        internal static ResourceDataEntry Load(IBinaryAccessor accessor)
        {
            ResourceDataEntry entry = new ResourceDataEntry();

            entry._loadData = true;
            entry._rva      = accessor.ReadUInt32();
            entry._length   = accessor.ReadInt32();
            entry._codePage = accessor.ReadUInt32();
            accessor.ReadUInt32();

            return(entry);
        }
Beispiel #5
0
        internal static ResourceEntry Load(IBinaryAccessor accessor, long basePosition)
        {
            uint nameOrId    = accessor.ReadUInt32();
            uint dataOrTable = accessor.ReadUInt32();

            long origPosition = accessor.Position;

            accessor.Position = basePosition + (dataOrTable & 0x7fffffff);

            ResourceEntry entry;

            if ((dataOrTable & 0x80000000) != 0)
            {
                // High bit 1. The lower 31 bits are the address of another resource directory table (the next level down).
                entry = ResourceTableEntry.Load(accessor, basePosition);
            }
            else
            {
                // High bit 0. Address of a Resource Data entry (a leaf).
                entry = ResourceDataEntry.Load(accessor);
            }

            accessor.Position = origPosition;

            if ((nameOrId & 0x80000000) != 0)
            {
                // High bit 1. The address of a string that gives the Type, Name, or Language ID entry, depending on level of table.
                accessor.Position = basePosition + (nameOrId & 0x7fffffff);

                int length = accessor.ReadUInt16();
                entry._name = accessor.ReadString(length, Encoding.Unicode);

                accessor.Position = origPosition;
            }
            else
            {
                // High bit 0. A 32-bit integer that identifies the Type, Name, or Language ID entry.
                entry._id = (int)(nameOrId & 0x7fffffff);
            }

            return(entry);
        }