예제 #1
0
 internal ResourceDirectoryEntry(PeImage image, uint offset, Structures.IMAGE_RESOURCE_DIRECTORY_ENTRY rawEntry, string customName)
 {
     this._image = image;
     this._offset = offset;
     this._rawEntry = rawEntry;
     this._customName = customName;
 }
예제 #2
0
 internal LibraryReference(PeImage image, uint offset, Structures.IMAGE_IMPORT_DESCRIPTOR rawDescriptor, string libraryName, ImportMethod[] importMethods)
 {
     this._image = image;
     this._offset = offset;
     this._rawDescriptor = rawDescriptor;
     this.LibraryName = libraryName;
     this.ImportMethods = importMethods;
 }
예제 #3
0
 internal MetaDataStream(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name)
 {
     this.headeroffset = headeroffset;
     this.netheader = netheader;
     this.streamHeader = rawHeader;
     this.name = name;
     this.indexsize = 2;
 }
예제 #4
0
파일: Section.cs 프로젝트: Rex-Hays/GNIDA
 internal Section(Win32Assembly assembly,
     uint headeroffset, 
     Structures.IMAGE_SECTION_HEADER rawHeader)
 {
     this._rawHeader = rawHeader;
     this.headeroffset = headeroffset;
     this.assembly = assembly;
     this.HasImage = true;
 }
예제 #5
0
        internal ResourceDataEntry(PeImage image, uint offset, ResourceDirectoryEntry parentEntry, Structures.IMAGE_RESOURCE_DATA_ENTRY rawDataEntry)
        {
            this.image = image;
            this.offset = offset;
            this.ParentEntry = parentEntry;
            this.rawDataEntry = rawDataEntry;

            Section resourceSection = Section.GetSectionByRva(image.assembly, image.assembly.ntHeader.OptionalHeader.DataDirectories[(int)DataDirectoryName.Resource].TargetOffset.Rva);
            targetOffset = OffsetToData - resourceSection.RVA + resourceSection.RawOffset;
        }
예제 #6
0
        internal MetaDataStream(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name)
        {
            this._headeroffset = headeroffset;
            this._netheader = netheader;
            this._streamHeader = rawHeader;
            this._name = name;
            this._indexsize = 2;

            byte[] contents = netheader._assembly._peImage.ReadBytes(StreamOffset, (int)StreamSize);
            _mainStream = new MemoryStream();
            _binReader = new BinaryReader(_mainStream);
            _binWriter = new BinaryWriter(_mainStream);
            _mainStream.Write(contents, 0, contents.Length);
            _mainStream.Seek(0, SeekOrigin.Begin);
        }
예제 #7
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;
     }
 }
예제 #8
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)
     {
         targetOffset = new Offset(0, 0, 0, ASM.OperandType.Normal);
     }
     else
     {
         OffsetConverter converter = new OffsetConverter(targetSection);
         this.targetOffset = Offset.FromRva(rawDataDir.RVA, targetSection.ParentAssembly);
         this.targetSection = targetSection;
     }
 }
예제 #9
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);
            }
        }
예제 #10
0
 internal TablesHeap(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name)
     : base(netheader, headeroffset, rawHeader, name)
 {
 }
 private string ReadLibraryName(Structures.IMAGE_IMPORT_DESCRIPTOR rawImportDir)
 {
     uint nameoffset = offsetConverter.RvaToFileOffset(rawImportDir.NameRVA);
     return image.ReadZeroTerminatedString(nameoffset);
 }
        private ImportMethod[] ReadImportMethods(Structures.IMAGE_IMPORT_DESCRIPTOR rawImportDir)
        {
            List<ImportMethod> methods = new List<ImportMethod>();

            int currentIndex = 0;
            uint baseoffset = offsetConverter.RvaToFileOffset(rawImportDir.OriginalFirstThunk);
            uint baseft= offsetConverter.RvaToFileOffset(rawImportDir.FirstThunk);
            while (true)
            {

                uint methodOffset = 0;
                uint ftOffset = 0;

                ulong ofunction = ReadFunctionValue(baseoffset, currentIndex, out methodOffset);

                if (ofunction == 0)
                    break;

                ulong ft = ReadFunctionValue(baseft, currentIndex, out ftOffset);
                ushort hint = 0;
                string name = ReadFunctionName(ofunction, out hint);

                uint rva = (uint)(rawImportDir.FirstThunk + (currentIndex *(header.OptionalHeader.Is32Bit ? sizeof(uint) : sizeof(ulong))));
                methods.Add(new ImportMethod((uint)ofunction, (uint)ft, rva , hint, name));

                //advance to next function value
                image.SetOffset(methodOffset + (header.OptionalHeader.Is32Bit ? sizeof(uint) : sizeof(ulong)));
                currentIndex++;
            }
            return methods.ToArray();
        }
예제 #13
0
 internal UserStringsHeap(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name)
     : base(netheader, headeroffset, rawHeader, name)
 {
     stream = new MemoryStream(Contents);
     binaryreader = new BinaryReader(stream);
 }
예제 #14
0
 //MetaDataStream stream)
 //: base(stream)
 internal BlobHeap(NETHeader netheader, int headeroffset, Structures.METADATA_STREAM_HEADER rawHeader, string name)
     : base(netheader, headeroffset, rawHeader, name)
 {
     this.mainStream = new MemoryStream(Contents);
     this.mainReader = new BinaryReader(this.mainStream);
 }