예제 #1
0
        private Dictionary <uint, Structures.IMAGE_DATA_DIRECTORY> ConstructDataDirectories(bool ignoreHeaderNumbers)
        {
            Dictionary <uint, Structures.IMAGE_DATA_DIRECTORY> rawdatadirs = new Dictionary <uint, Structures.IMAGE_DATA_DIRECTORY>();

            for (int i = 0; i < (ignoreHeaderNumbers ? 0x10 : (optionalheadersig == 0x10b ? optionalHeader32.NumberOfRvaAndSizes : optionalHeader64.NumberOfRvaAndSizes)); i++)
            {
                uint byteoffset = (uint)image.Stream.Position;
                Structures.IMAGE_DATA_DIRECTORY datadir = image.ReadStructure <Structures.IMAGE_DATA_DIRECTORY>();
                rawdatadirs.Add(byteoffset, datadir);
            }
            return(rawdatadirs);
        }
예제 #2
0
 internal DataDirectory(DataDirectoryName name, Section targetSection, uint headerOffset, Structures.IMAGE_DATA_DIRECTORY rawDataDir)
 {
     this._name = name;
     this._headerOffset = headerOffset;
     this._rawDataDir = rawDataDir;
     if (rawDataDir.RVA == 0 || targetSection == null)
     {
         _targetOffset = new Offset(0, 0, 0);
     }
     else
     {
         this._targetOffset = Offset.FromRva(rawDataDir.RVA, targetSection.ParentAssembly);
         this._targetSection = targetSection;
     }
 }
예제 #3
0
        internal DataDirectory(DataDirectoryName name, Section[] assemblySections, uint offset, Structures.IMAGE_DATA_DIRECTORY rawDataDir)
        {
            this._rawDataDir = rawDataDir;
            this._name = name;
            if (rawDataDir.RVA == 0)
            {
                _targetOffset = new Offset(0, 0, 0);
            }
            else
            {
                this._headerOffset = offset;

                _targetSection = Section.GetSectionByRva(assemblySections, rawDataDir.RVA);
                if (_targetSection == null)
                    this.TargetOffset = new Offset(0, rawDataDir.RVA, 0);
                else
                    this._targetOffset = Offset.FromRva(rawDataDir.RVA, assemblySections[0].ParentAssembly);
            }
        }
예제 #4
0
 internal DataDirectory(DataDirectoryName name, Section targetSection, uint headerOffset, Structures.IMAGE_DATA_DIRECTORY rawDataDir)
 {
     this._name         = name;
     this._headerOffset = headerOffset;
     this._rawDataDir   = rawDataDir;
     if (rawDataDir.RVA == 0 || targetSection == null)
     {
         _targetOffset = new Offset(0, 0, 0);
     }
     else
     {
         this._targetOffset  = Offset.FromRva(rawDataDir.RVA, targetSection.ParentAssembly);
         this._targetSection = targetSection;
     }
 }
예제 #5
0
        internal DataDirectory(DataDirectoryName name, Section[] assemblySections, uint offset, Structures.IMAGE_DATA_DIRECTORY rawDataDir)
        {
            this._rawDataDir = rawDataDir;
            this._name       = name;
            if (rawDataDir.RVA == 0)
            {
                _targetOffset = new Offset(0, 0, 0);
            }
            else
            {
                this._headerOffset = offset;

                _targetSection = Section.GetSectionByRva(assemblySections, rawDataDir.RVA);
                if (_targetSection == null)
                {
                    this.TargetOffset = new Offset(0, rawDataDir.RVA, 0);
                }
                else
                {
                    this._targetOffset = Offset.FromRva(rawDataDir.RVA, assemblySections[0].ParentAssembly);
                }
            }
        }