The addr is RVA
| 2920 | |
| 2921 | // The addr is RVA |
| 2922 | void PEView::AddPESymbol(BNSymbolType type, const string& dll, const string& name, uint64_t addr, |
| 2923 | BNSymbolBinding binding, uint64_t ordinal, vector<Ref<TypeLibrary>> libs) |
| 2924 | { |
| 2925 | // Don't create symbols that are present in the database snapshot now |
| 2926 | if (type != ExternalSymbol && m_backedByDatabase) |
| 2927 | return; |
| 2928 | |
| 2929 | // If name is empty, symbol is not valid |
| 2930 | if (name.size() == 0) |
| 2931 | return; |
| 2932 | |
| 2933 | // Ensure symbol is within the executable |
| 2934 | if (type != ExternalSymbol) |
| 2935 | { |
| 2936 | bool ok = false; |
| 2937 | for (auto& i : m_sections) |
| 2938 | { |
| 2939 | if ((addr >= i.virtualAddress) && (addr < (i.virtualAddress + i.virtualSize))) |
| 2940 | { |
| 2941 | ok = true; |
| 2942 | break; |
| 2943 | } |
| 2944 | } |
| 2945 | if (!ok) |
| 2946 | return; |
| 2947 | } |
| 2948 | |
| 2949 | auto address = type == ExternalSymbol ? addr : m_imageBase + addr; |
| 2950 | Ref<Type> symbolTypeRef; |
| 2951 | |
| 2952 | if (libs.size() && ((type == ExternalSymbol) || (type == ImportAddressSymbol) || (type == ImportedDataSymbol))) |
| 2953 | { |
| 2954 | QualifiedName n(name); |
| 2955 | for (auto lib : libs) |
| 2956 | { |
| 2957 | Ref<TypeLibrary> appliedLib = lib; |
| 2958 | symbolTypeRef = ImportTypeLibraryObject(appliedLib, n); |
| 2959 | if (symbolTypeRef) |
| 2960 | { |
| 2961 | m_logger->LogDebug("pe: type library '%s' found hit for '%s'", lib->GetGuid().c_str(), name.c_str()); |
| 2962 | RecordImportedObjectLibrary(GetDefaultPlatform(), address, appliedLib, n); |
| 2963 | } |
| 2964 | } |
| 2965 | } |
| 2966 | |
| 2967 | m_symbolQueue->Append( |
| 2968 | [=]() { |
| 2969 | // If name does not start with alphabetic character or symbol, prepend an underscore |
| 2970 | string rawName = name; |
| 2971 | if (!(((name[0] >= 'A') && (name[0] <= 'Z')) || ((name[0] >= 'a') && (name[0] <= 'z')) || (name[0] == '_') |
| 2972 | || (name[0] == '?') || (name[0] == '$') || (name[0] == '@'))) |
| 2973 | rawName = "_" + name; |
| 2974 | |
| 2975 | string shortName = rawName; |
| 2976 | string fullName = rawName; |
| 2977 | Ref<Type> typeRef = symbolTypeRef; |
| 2978 | |
| 2979 | if (m_arch && name.size() > 0) |
nothing calls this directly
no test coverage detected