beeradmoore/dlss-swapper · error · Exception

Failed to get function address

Error message

Failed to get function address

What it means

FSR31Helper.GetVersions resolves the ffxQuery export from the already-loaded FidelityFX DLL using GetProcAddress. If the export is absent, GetProcAddress returns IntPtr.Zero and the helper throws 'Failed to get function address'. This means the DLL loaded fine but does not expose the expected entry point.

Solutions

  1. Update AMD Radeon/Adrenalin drivers to a version that ships the ffxQuery export (FSR 3.1+).
  2. Verify the export exists before calling: check with dumpbin /exports or Dependencies tool on the exact dllPath file.
  3. Confirm dllPath points to the intended FidelityFX API DLL, not a similarly named unrelated library.
  4. Gracefully degrade: treat a missing ffxQuery as 'FSR version info unavailable' and return an empty list instead of throwing.
  5. If supporting multiple SDK versions, probe for the export and fall back to older query functions.

Example fix

// before
var pAddressOfFunctionToCall = GetProcAddress(hModule, "ffxQuery");
if (pAddressOfFunctionToCall == IntPtr.Zero)
    throw new Exception("Failed to get function address");
// after
var pAddressOfFunctionToCall = GetProcAddress(hModule, "ffxQuery");
if (pAddressOfFunctionToCall == IntPtr.Zero)
{
    Logger.Warn($"ffxQuery export not found in {dllPath}; FSR version info unavailable.");
    FreeLibrary(hModule);
    return new List<string?>();
}
Defensive patterns

Strategy: fallback

Validate before calling

var h = LoadLibrary(dllPath);
bool hasFfxQuery = h != IntPtr.Zero && GetProcAddress(h, "ffxQuery") != IntPtr.Zero;
if (h != IntPtr.Zero) FreeLibrary(h);
if (!hasFfxQuery) { /* use fallback version detection or skip */ }

Type guard

static bool HasExport(string dllPath, string export)
{
    var h = LoadLibrary(dllPath);
    if (h == IntPtr.Zero) return false;
    var ok = GetProcAddress(h, export) != IntPtr.Zero;
    FreeLibrary(h);
    return ok;
}

Try / catch

try
{
    var versions = FSR31Helper.GetVersions();
}
catch (Exception ex) when (ex.Message == "Failed to get function address")
{
    Logger.Warn(ex, "DLL loaded but ffxQuery export missing (older FSR runtime); returning no versions.");
    versions = new List<string?>();
}

Prevention

When it happens

Trigger: Calling GetVersions against a FidelityFX/DLL build that predates the ffxQuery export (older FSR runtime), a wrong DLL file at dllPath (name matches but it is a different library), or a stripped/patched export table. Also when the helper targets FSR 3.1 API while the installed driver ships FSR 3.0 or an incompatible interface.

Common situations: Outdated AMD drivers without the FidelityFX API query interface; a DLL from a different SDK version where the function was renamed; grabbing a similarly named DLL (e.g. amd_fidelityfx_dx12 variants) that lacks ffxQuery.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of beeradmoore/dlss-swapper@ab9b1e2d4b (2026-09-15). Data as JSON: /api/errors/ca26345987a2bd0f. Report an issue: GitHub.

Appendix: source

Thrown at src/Helpers/FSR31/FSR31Helper.cs:43

    public static List<string?> GetVersions(string dllPath)
    {
        if (Path.Exists(dllPath) == false)
        {
            return new List<string?>();
        }
        Logger.Info($"AMDFidelityFXAPI - Loading {dllPath}");
        var hModule = LoadLibrary(dllPath);
        if (hModule == IntPtr.Zero)
        {
            throw new Exception("Failed to load DLL");
        }

        try
        {
            var pAddressOfFunctionToCall = GetProcAddress(hModule, "ffxQuery");
            if (pAddressOfFunctionToCall == IntPtr.Zero)
            {
                throw new Exception("Failed to get function address");
            }

            var ffxQuery = Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(ffxQueryDelegate)) as ffxQueryDelegate;
            if (ffxQuery is null)
            {
                throw new Exception("Failed to get function delegate");
            }

            var versionQuery = new QueryDescGetVersions();

            //versionQuery.createDescType = FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE;
            versionQuery.createDescType = FxxConsts.FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE;

            // versionQuery.device = GetDX12Device(); // only for DirectX 12 applications
            versionQuery.device = IntPtr.Zero;

            // uint64_t versionCount = 0;
            UInt64 versionCount = 0;

View on GitHub (pinned to ab9b1e2d4b)