Exemple #1
0
        private static bool TryGetSimilarSymbol(ImportedSymbol symbol, IImportedModule module, out ImportedSymbol existingSymbol)
        {
            for (int i = 0; i < module.Symbols.Count; i++)
            {
                var s = module.Symbols[i];
                if (symbol.IsImportByName != s.IsImportByName)
                {
                    continue;
                }

                if (symbol.IsImportByName)
                {
                    if (symbol.Name == s.Name)
                    {
                        existingSymbol = s;
                        return(true);
                    }
                }
                else // if (symbol.IsImportByOrdinal)
                {
                    if (symbol.Ordinal == s.Ordinal)
                    {
                        existingSymbol = s;
                        return(true);
                    }
                }
            }

            existingSymbol = null;
            return(false);
        }
 private void WriteModuleImportEntry(IBinaryStreamWriter writer, IImportedModule module)
 {
     WriteModuleImportEntry(writer,
                            GetModuleThunkTable(module).Rva,
                            module.TimeDateStamp,
                            module.ForwarderChain,
                            HintNameTable.GetModuleNameRva(module),
                            ImportAddressDirectory.GetModuleThunkTable(module).Rva);
 }
        private void AddLookupTable(IImportedModule module)
        {
            var lookupTable = CreateThunkTable();

            foreach (var member in module.Symbols)
            {
                lookupTable.AddMember(member);
            }
            _lookupTables.Add(module, lookupTable);
            _lookupTablesLength += lookupTable.GetPhysicalSize();
        }
Exemple #4
0
        private void AddLookupTable(IImportedModule module)
        {
            var lookupTable = new ThunkTableBuffer(HintNameTable, Is32Bit);

            foreach (var member in module.Symbols)
            {
                lookupTable.AddMember(member);
            }
            _lookupTables.Add(module, lookupTable);
            _lookupTablesLength += lookupTable.GetPhysicalSize();
        }
        /// <inheritdoc />
        public override void AddModule(IImportedModule module)
        {
            if (_entriesLength == 0)
            {
                _entriesLength = SerializedImportedModule.ModuleImportSize;
            }

            _entriesLength += SerializedImportedModule.ModuleImportSize;

            ImportAddressDirectory.AddModule(module);
            base.AddModule(module);

            HintNameTable.AddModule(module);
        }
 /// <summary>
 /// Obtains the thunk table of a module.
 /// </summary>
 /// <param name="module">The module to get the associated thunk table for.</param>
 /// <returns>The thunk table.</returns>
 public ThunkTableBuffer GetModuleThunkTable(IImportedModule module) => _lookupTables[module];
 /// <summary>
 /// Creates a thunk table for a module and its imported members, and adds it to the buffer.
 /// </summary>
 /// <param name="module">The module to add.</param>
 public virtual void AddModule(IImportedModule module)
 {
     Modules.Add(module);
     AddLookupTable(module);
 }
 private static void WriteModuleName(IBinaryStreamWriter writer, IImportedModule module)
 {
     writer.WriteAsciiString(module.Name);
     writer.WriteByte(0);
 }
 /// <summary>
 /// Gets the virtual address to the beginning of the name of a module.
 /// </summary>
 /// <param name="module">The module to obtain the name RVA for.</param>
 /// <returns>The virtual address.</returns>
 /// <remarks>
 /// This method should only be used after the hint-name table has been relocated to the right location in the
 /// PE file.
 /// </remarks>
 public uint GetModuleNameRva(IImportedModule module) => Rva + _moduleNameOffsets[module];
 /// <summary>
 /// Adds the name of the module and the names of all named entries to the hint-name table.
 /// </summary>
 /// <param name="module">The module to add.</param>
 public void AddModule(IImportedModule module)
 {
     _modules.Add(module);
 }