context: using System.Collections.Generic;
  using AsmResolver.PE.Exports;
  // ReSharper disable InconsistentNaming
  
  namespace AsmResolver.PE.Imports
  {
      /// <summary>
      /// Provides an implementation of the <see cref="ISymbolResolver"/> that includes some static ordinal-name mappings
      /// from known Windows libraries.
      /// </summary>
      /// <remarks>
      /// This class should only be used for quick static lookup of common ordinals to names (e.g. in conjuction with
      /// the <see cref="ImportHash"/> class). The resulting symbol objects are mock objects and do not contain a valid
      /// address to the actual symbol.
      /// </remarks>
      public sealed class DefaultSymbolResolver : ISymbolResolver
      {
          // Ordinal name mappings extracted using the AsmResolver.PE.Exports.OrdinalMapper utility.
  
          private static readonly Dictionary<uint, string> _ws2_32OrdinalMapping = new()
          {
              [1] = "accept",
              [2] = "bind",
              [3] = "closesocket",
              [4] = "connect",
              [5] = "getpeername",
              [6] = "getsockname",
              [7] = "getsockopt",
              [8] = "htonl",
              [9] = "htons",
              [10] = "ioctlsocket",
              [11] = "inet_addr",
              [12] = "inet_ntoa",
              [13] = "listen",
              [14] = "ntohl",
              [15] = "ntohs",
              [16] = "recv",
              [17] = "recvfrom",
              [18] = "select",
              [19] = "send",
              [20] = "sendto",
              [21] = "setsockopt",
              [22] = "shutdown",
              [23] = "socket",
              [24] = "WSApSetPostRoutine",
              [25] = "FreeAddrInfoEx",
              [26] = "FreeAddrInfoExW",
              [27] = "FreeAddrInfoW",
              [28] = "GetAddrInfoExA",
              [29] = "GetAddrInfoExCancel",
              [30] = "GetAddrInfoExOverlappedResult",
              [31] = "GetAddrInfoExW",
              [32] = "GetAddrInfoW",
              [33] = "GetHostNameW",
              [34] = "GetNameInfoW",
              [35] = "InetNtopW",
              [36] = "InetPtonW",
              [37] = "SetAddrInfoExA",
              [38] = "SetAddrInfoExW",
              [39] = "WPUCompleteOverlappedRequest",
              [40] = "WPUGetProviderPathEx",
              [41] = "WSAAccept",
              [42] = "WSAAddressToStringA",
              [43] = "WSAAddressToStringW",
              [44] = "WSAAdvertiseProvider",
              [45] = "WSACloseEvent",
              [46] = "WSAConnect",
              [47] = "WSAConnectByList",
              [48] = "WSAConnectByNameA",
              [49] = "WSAConnectByNameW",
              [50] = "WSACreateEvent",
              [51] = "gethostbyaddr",
              [52] = "gethostbyname",
              [53] = "getprotobyname",
              [54] = "getprotobynumber",
              [55] = "getservbyname",
              [56] = "getservbyport",
              [57] = "gethostname",
              [58] = "WSADuplicateSocketA",
              [59] = "WSADuplicateSocketW",
              [60] = "WSAEnumNameSpaceProvidersA",
              [61] = "WSAEnumNameSpaceProvidersExA",
              [62] = "WSAEnumNameSpaceProvidersExW",
              [63] = "WSAEnumNameSpaceProvidersW",
              [64] = "WSAEnumNetworkEvents",
              [65] = "WSAEnumProtocolsA",
              [66] = "WSAEnumProtocolsW",
              [67] = "WSAEventSelect",
              [68] = "WSAGetOverlappedResult",
              [69] = "WSAGetQOSByName",
              [70] = "WSAGetServiceClassInfoA",
              [71] = "WSAGetServiceClassInfoW",
              [72] = "WSAGetServiceClassNameByClassIdA",
              [73] = "WSAGetServiceClassNameByClassIdW",
              [74] = "WSAHtonl",
              [75] = "WSAHtons",
              [76] = "WSAInstallServiceClassA",
              [77] = "WSAInstallServiceClassW",
              [78] = "WSAIoctl",
              [79] = "WSAJoinLeaf",
              [80] = "WSALookupServiceBeginA",
              [81] = "WSALookupServiceBeginW",
              [82] = "WSALookupServiceEnd",
              [83] = "WSALookupServiceNextA",
              [84] = "WSALookupServiceNextW",
              [85] = "WSANSPIoctl",
              [86] = "WSANtohl",
              [87] = "WSANtohs",
              [88] = "WSAPoll",
              [89] = "WSAProviderCompleteAsyncCall",
              [90] = "WSAProviderConfigChange",
              [91] = "WSARecv",
              [92] = "WSARecvDisconnect",
              [93] = "WSARecvFrom",
              [94] = "WSARemoveServiceClass",
              [95] = "WSAResetEvent",
              [96] = "WSASend",
              [97] = "WSASendDisconnect",
              [98] = "WSASendMsg",
              [99] = "WSASendTo",
              [100] = "WSASetEvent",
              [101] = "WSAAsyncSelect",
              [102] = "WSAAsyncGetHostByAddr",
              [103] = "WSAAsyncGetHostByName",
              [104] = "WSAAsyncGetProtoByNumber",
              [105] = "WSAAsyncGetProtoByName",
              [106] = "WSAAsyncGetServByPort",
              [107] = "WSAAsyncGetServByName",
              [108] = "WSACancelAsyncRequest",
              [109] = "WSASetBlockingHook",
              [110] = "WSAUnhookBlockingHook",
              [111] = "WSAGetLastError",
              [112] = "WSASetLastError",
              [113] = "WSACancelBlockingCall",
              [114] = "WSAIsBlocking",
              [115] = "WSAStartup",
              [116] = "WSACleanup",
              [117] = "WSASetServiceA",
              [118] = "WSASetServiceW",
              [119] = "WSASocketA",
              [120] = "WSASocketW",
              [121] = "WSAStringToAddressA",
              [122] = "WSAStringToAddressW",
              [123] = "WSAUnadvertiseProvider",
              [124] = "WSAWaitForMultipleEvents",
              [125] = "WSCDeinstallProvider",
              [126] = "WSCDeinstallProvider32",
              [127] = "WSCDeinstallProviderEx",
              [128] = "WSCEnableNSProvider",
              [129] = "WSCEnableNSProvider32",
              [130] = "WSCEnumNameSpaceProviders32",
              [131] = "WSCEnumNameSpaceProvidersEx32",
              [132] = "WSCEnumProtocols",
              [133] = "WSCEnumProtocols32",
              [134] = "WSCEnumProtocolsEx",
              [135] = "WSCGetApplicationCategory",
              [136] = "WSCGetApplicationCategoryEx",
              [137] = "WSCGetProviderInfo",
              [138] = "WSCGetProviderInfo32",
              [139] = "WSCGetProviderPath",
              [140] = "WSCGetProviderPath32",
              [141] = "WSCInstallNameSpace",
              [142] = "WSCInstallNameSpace32",
              [143] = "WSCInstallNameSpaceEx",
              [144] = "WSCInstallNameSpaceEx2",
              [145] = "WSCInstallNameSpaceEx32",
              [146] = "WSCInstallProvider",
              [147] = "WSCInstallProvider64_32",
              [148] = "WSCInstallProviderAndChains64_32",
              [149] = "WSCInstallProviderEx",
              [150] = "WSCSetApplicationCategory",
              [151] = "__WSAFDIsSet",
              [152] = "WSCSetApplicationCategoryEx",
              [153] = "WSCSetProviderInfo",
              [154] = "WSCSetProviderInfo32",
              [155] = "WSCUnInstallNameSpace",
              [156] = "WSCUnInstallNameSpace32",
              [157] = "WSCUnInstallNameSpaceEx2",
              [158] = "WSCUpdateProvider",
              [159] = "WSCUpdateProvider32",
              [160] = "WSCUpdateProviderEx",
              [161] = "WSCWriteNameSpaceOrder",
              [162] = "WSCWriteNameSpaceOrder32",
              [163] = "WSCWriteProviderOrder",
              [164] = "WSCWriteProviderOrder32",
              [165] = "WSCWriteProviderOrderEx",
              [166] = "WahCloseApcHelper",
              [167] = "WahCloseHandleHelper",
              [168] = "WahCloseNotificationHandleHelper",
              [169] = "WahCloseSocketHandle",
              [170] = "WahCloseThread",
              [171] = "WahCompleteRequest",
              [172] = "WahCreateHandleContextTable",
              [173] = "WahCreateNotificationHandle",
              [174] = "WahCreateSocketHandle",
              [175] = "WahDestroyHandleContextTable",
              [176] = "WahDisableNonIFSHandleSupport",
              [177] = "WahEnableNonIFSHandleSupport",
              [178] = "WahEnumerateHandleContexts",
              [179] = "WahInsertHandleContext",
              [180] = "WahNotifyAllProcesses",
              [181] = "WahOpenApcHelper",
              [182] = "WahOpenCurrentThread",
              [183] = "WahOpenHandleHelper",
              [184] = "WahOpenNotificationHandleHelper",
              [185] = "WahQueueUserApc",
              [186] = "WahReferenceContextByHandle",
              [187] = "WahRemoveHandleContext",
              [188] = "WahWaitForNotification",
              [189] = "WahWriteLSPEvent",
              [190] = "freeaddrinfo",
              [191] = "getaddrinfo",
              [192] = "getnameinfo",
              [193] = "inet_ntop",
              [194] = "inet_pton",
              [500] = "WEP",
          };
  
          private static readonly Dictionary<uint, string> _oleaut32OrdinalMapping = new()
          {
              [2] = "SysAllocString",
              [3] = "SysReAllocString",
              [4] = "SysAllocStringLen",
              [5] = "SysReAllocStringLen",
              [6] = "SysFreeString",
              [7] = "SysStringLen",
              [8] = "VariantInit",
              [9] = "VariantClear",
              [10] = "VariantCopy",
              [11] = "VariantCopyInd",
              [12] = "VariantChangeType",
              [13] = "VariantTimeToDosDateTime",
              [14] = "DosDateTimeToVariantTime",
              [15] = "SafeArrayCreate",
              [16] = "SafeArrayDestroy",
              [17] = "SafeArrayGetDim",
              [18] = "SafeArrayGetElemsize",
              [19] = "SafeArrayGetUBound",
              [20] = "SafeArrayGetLBound",
              [21] = "SafeArrayLock",
              [22] = "SafeArrayUnlock",
              [23] = "SafeArrayAccessData",
              [24] = "SafeArrayUnaccessData",
              [25] = "SafeArrayGetElement",
              [26] = "SafeArrayPutElement",
              [27] = "SafeArrayCopy",
              [28] = "DispGetParam",
              [29] = "DispGetIDsOfNames",
              [30] = "DispInvoke",
              [31] = "CreateDispTypeInfo",
              [32] = "CreateStdDispatch",
              [33] = "RegisterActiveObject",
              [34] = "RevokeActiveObject",
              [35] = "GetActiveObject",
              [36] = "SafeArrayAllocDescriptor",
              [37] = "SafeArrayAllocData",
              [38] = "SafeArrayDestroyDescriptor",
              [39] = "SafeArrayDestroyData",
              [40] = "SafeArrayRedim",
              [41] = "SafeArrayAllocDescriptorEx",
              [42] = "SafeArrayCreateEx",
              [43] = "SafeArrayCreateVectorEx",
              [44] = "SafeArraySetRecordInfo",
              [45] = "SafeArrayGetRecordInfo",
              [46] = "VarParseNumFromStr",
              [47] = "VarNumFromParseNum",
              [48] = "VarI2FromUI1",
              [49] = "VarI2FromI4",
              [50] = "VarI2FromR4",
              [51] = "VarI2FromR8",
              [52] = "VarI2FromCy",
              [53] = "VarI2FromDate",
              [54] = "VarI2FromStr",
              [55] = "VarI2FromDisp",
              [56] = "VarI2FromBool",
              [57] = "SafeArraySetIID",
              [58] = "VarI4FromUI1",
              [59] = "VarI4FromI2",
              [60] = "VarI4FromR4",
              [61] = "VarI4FromR8",
              [62] = "VarI4FromCy",
              [63] = "VarI4FromDate",
              [64] = "VarI4FromStr",
              [65] = "VarI4FromDisp",
              [66] = "VarI4FromBool",
              [67] = "SafeArrayGetIID",
              [68] = "VarR4FromUI1",
              [69] = "VarR4FromI2",
              [70] = "VarR4FromI4",
              [71] = "VarR4FromR8",
              [72] = "VarR4FromCy",
              [73] = "VarR4FromDate",
              [74] = "VarR4FromStr",
              [75] = "VarR4FromDisp",
              [76] = "VarR4FromBool",
              [77] = "SafeArrayGetVartype",
              [78] = "VarR8FromUI1",
              [79] = "VarR8FromI2",
              [80] = "VarR8FromI4",
              [81] = "VarR8FromR4",
              [82] = "VarR8FromCy",
              [83] = "VarR8FromDate",
              [84] = "VarR8FromStr",
              [85] = "VarR8FromDisp",
              [86] = "VarR8FromBool",
              [87] = "VarFormat",
              [88] = "VarDateFromUI1",
              [89] = "VarDateFromI2",
              [90] = "VarDateFromI4",
              [91] = "VarDateFromR4",
              [92] = "VarDateFromR8",
              [93] = "VarDateFromCy",
              [94] = "VarDateFromStr",
              [95] = "VarDateFromDisp",
              [96] = "VarDateFromBool",
              [97] = "VarFormatDateTime",
              [98] = "VarCyFromUI1",
              [99] = "VarCyFromI2",
              [100] = "VarCyFromI4",
              [101] = "VarCyFromR4",
              [102] = "VarCyFromR8",
              [103] = "VarCyFromDate",
              [104] = "VarCyFromStr",
              [105] = "VarCyFromDisp",
              [106] = "VarCyFromBool",
              [107] = "VarFormatNumber",
              [108] = "VarBstrFromUI1",
              [109] = "VarBstrFromI2",
              [110] = "VarBstrFromI4",
  
gt:             [111] = "VarBstrFromR4",