Пример #1
0
        /// <summary>
        /// Create a Data directory header from file
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <param name="opHeader">The optional header</param>
        public DataDirectoryHeader(Reader reader, OptionalHeader opHeader)
        {
            this.reader = reader;

            this.entries = new List <Entry>();
            this.dirs    = new List <DataDirectory>();

            this.opHeader = opHeader;

            headerBaseAddress = this.opHeader.endOfHeader;

            setupStruct();

            ///
            /// init values
            ///

            foreach (var item in entries)
            {
                item.readValue(this.reader);
            }

            int sizeTmp = headerBaseAddress;

            entries.ForEach(e => sizeTmp += (((int)e.getEntrySize()) / 8) * 2);

            this.endOfHeader = sizeTmp + 0x8;
        }
Пример #2
0
        /// <summary>
        /// Create a Data directory header from memory
        /// </summary>
        /// <param name="opHeader">The optional header</param>
        public DataDirectoryHeader(OptionalHeader opHeader)
        {
            this.entries = new List <Entry>();
            this.dirs    = new List <DataDirectory>();

            this.opHeader = opHeader;

            headerBaseAddress = this.opHeader.endOfHeader;

            setupStruct();

            ///
            /// init values
            ///

            // exe as default, so export anything
            this.exportDirectory.setVirtualAddress(0);
            this.exportDirectory.setSize(0);

            // defined by the user
            this.importDirectory.setVirtualAddress(0);
            this.importDirectory.setSize(0);
            this.resourceDirectory.setVirtualAddress(0);
            this.resourceDirectory.setSize(0);
            this.exceptionDirectory.setVirtualAddress(0);
            this.exceptionDirectory.setSize(0);
            this.securityDirectory.setVirtualAddress(0);
            this.securityDirectory.setSize(0);
            this.baseRelocationDirectory.setVirtualAddress(0);
            this.baseRelocationDirectory.setSize(0);

            // debug info
            this.debugDirectory.setVirtualAddress(0);
            this.debugDirectory.setSize(0);

            this.architectureDirectory.setVirtualAddress(0);
            this.architectureDirectory.setSize(0);
            this.relativesAddressDirectory.setVirtualAddress(0);
            this.relativesAddressDirectory.setSize(0);
            this.tlsDirectory.setVirtualAddress(0);
            this.tlsDirectory.setSize(0);

            // null as default
            this.loadConfigDirectory.setVirtualAddress(0);
            this.loadConfigDirectory.setSize(0);
            this.boundImportsDirectory.setVirtualAddress(0);
            this.boundImportsDirectory.setSize(0);

            this.importTableAddressDirectory.setVirtualAddress(0);
            this.importTableAddressDirectory.setSize(0);

            // null as default
            this.delayLoadDescriptorDirectory.setVirtualAddress(0);
            this.delayLoadDescriptorDirectory.setSize(0);

            // defined by the user if is .NET executable
            this.netHeaderDirectory.setVirtualAddress(0);
            this.netHeaderDirectory.setSize(0);

            int sizeTmp = headerBaseAddress;

            entries.ForEach(e => sizeTmp += (((int)e.getEntrySize()) / 8) * 2);

            this.endOfHeader = sizeTmp + 0x8;
        }