Question about #c++# : How does c++ implement hot load dll

crw1234 注册会员
2023-02-28 21:07

  • Use the Dynamic Link Library(DLL) mechanism provided by Windows operating system. The main idea of hot-loaded DLL is to dynamically load and unload the DLL while the program is running, instead of loading all the DLLS in when the program starts, so as to avoid the program update problem caused by the occupied DLL.

Here are the basic steps to implement a hot-loaded DLL:

  • Load DLL library: Load the DLL library using the LoadLibrary() function, which returns an HMODULE handle representing the loaded DLL.
  • Get the address of the exported function in the DLL library: Use the GetProcAddress() function to get the address of the function that needs to be used in the DLL library. The function returns the address of the function. You can use the function pointer to point to the address.
  • Using functions: Use function Pointers to invoke functions exported from DLL libraries to complete related operations.
  • Uninstalls DLL libraries: Uninstalls DLL libraries using the FreeLibrary() function, which accepts an HMODULE handle as an argument indicating the DLL library to be uninstalled.

About the Author

Question Info

Publish Time
2023-02-28 21:07
Update Time
2023-02-28 21:07