Skip to content

[Request]: Adjust documentation and sample code for AMF DLL loading to avoid searching unnecessary directories #559

@cgutman

Description

@cgutman

Is your feature request related to a problem? Please describe.

The current AMF documentation recommends the following to load the AMF DLL on Windows:

The AMF run-time is supplied as part of the Windows driver installation. The AMF run-time DLL should be loaded dynamically using the LoadLibraryW Win32 function. The name of the DLL is defined by the AMF_DLL_NAME macro. Always pass the AMF_DLL_NAME macro to LoadLibraryW instead of the actual DLL name to ensure code portability as the name might be defined differently depending on the platform:
HMODULE hAMFDll = LoadLibraryW(AMF_DLL_NAME);

Using LoadLibrary() (rather than LoadLibraryEx() with LOAD_LIBRARY_SEARCH_* flags) isn't ideal because it includes ton of unnecessary directories on the search path (including everything on PATH).

Describe the solution you'd like
Adjusting the documentation to advise developers to use a more specific search path like:
LoadLibraryExW(AMF_DLL_NAME, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32)

This will avoid matching a copy of the AMF runtime DLL located in some other unintended directory (particularly on a non-AMD system where there may be no legitimate AMF runtime DLL present at all).

Describe alternatives you've considered
N/A

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions