示例#1
0
            public FileSegment GetLookupSegment(ImageSymbolImport symbolImport)
            {
                FileSegment segment;

                if (!_lookupSegments.TryGetValue(symbolImport, out segment))
                {
                    if (symbolImport.IsImportByOrdinal)
                    {
                        segment = DataSegment.CreateNativeInteger(symbolImport.Lookup, Is32Bit);
                    }
                    else if (symbolImport.HintName != null)
                    {
                        _nameTableBuffer.AddHintNameSegment(symbolImport.HintName);
                        segment = new PointerSegment(symbolImport.HintName, _offsetConverter, Is32Bit);
                    }
                    else
                    {
                        segment = DataSegment.CreateNativeInteger(0, Is32Bit);
                    }

                    _lookupSegments.Add(symbolImport, segment);
                    Segments.Add(segment);
                }
                return(segment);
            }
        public void AddSymbolExport(ImageSymbolExport export)
        {
            if (export.Name != null)
            {
                export.NameOrdinal = (uint)(_addressesTable.Segments.Count + _exportDirectory.OrdinalBase);
                _nameOrdinalTable.Segments.Add(
                    new DataSegment(BitConverter.GetBytes((ushort)_addressesTable.Segments.Count)));
                var nameSegment = DataSegment.CreateAsciiString(export.Name, true);
                _namesTable.Segments.Add(nameSegment);
                _nameRvaTable.Segments.Add(new PointerSegment(nameSegment, _converter, true));
            }

            _addressesTable.Segments.Add(DataSegment.CreateNativeInteger(export.Rva, true));
        }