Represents a base relocation block in the relocation data directory.
Inheritance: FileSegment
        internal static BaseRelocationBlock FromReadingContext(ReadingContext context)
        {
            var reader = context.Reader;
            var block  = new BaseRelocationBlock(reader.ReadUInt32())
            {
                _blockSize = reader.ReadUInt32(),
            };

            block._entriesReadingContext = context.CreateSubContext(reader.Position, (int)(block.BlockSize - (2 * sizeof(uint))));
            return(block);
        }
Esempio n. 2
0
        public static ImageRelocationDirectory FromReadingContext(ReadingContext context)
        {
            var directory      = new ImageRelocationDirectory();
            var relocDirectory =
                context.Assembly.NtHeaders.OptionalHeader.DataDirectories[
                    ImageDataDirectory.BaseRelocationDirectoryIndex];

            while (context.Reader.Position < context.Reader.StartPosition + relocDirectory.Size)
            {
                var block = BaseRelocationBlock.FromReadingContext(context);
                directory.Blocks.Add(block);
                context.Reader.Position += block.BlockSize - 2 * sizeof(uint);
            }

            return(directory);
        }
Esempio n. 3
0
        internal static BaseRelocationBlock FromReadingContext(ReadingContext context)
        {
            var reader = context.Reader;
            long offset = reader.Position;
            var block = new BaseRelocationBlock(reader.ReadUInt32())
            {
                StartOffset = offset,
                _blockSize = reader.ReadUInt32(),
            };

            block._entriesReadingContext = context.CreateSubContext(reader.Position, (int)(block.BlockSize - (2 * sizeof (uint))));
            return block;
        }