thisKai / rust-windows-dll

Macro for dynamically loading windows dll functions
MIT License
19 stars 6 forks source link

Support load dll again after free() is called #5

Open J-F-Liu opened 2 years ago

J-F-Liu commented 2 years ago

I need to reload a dll file to do some initialization agian. After call the trait method WindowsDll::free(), WindowsDll::ptr() and WindowsDllProc::proc() still return cached result. It would be good to have a method to reload dll.

thisKai commented 2 years ago

I'm doing some restructuring to make this work. I thought I could get away with using once_cell for caching, but to enable this use case I think I'll have use locks or atomics instead. I may have to remove function pointer caching for now so I can get the reloading working more quickly. Hopefully when I've released the next version you will be able to just call the function again after freeing the library and it should reload the library automatically.

J-F-Liu commented 2 years ago

Thanks, maybe it's better to be implemented separately. I already implemented this by myself, but the function names are hard coded.