The title pretty much says it all..
What I'm trying to do is write a tool that will monitor a dll file containing a plugin and when I overwrite it, by recompiling, it should automatically reload it. I know I can make a copy, load the copy and monitor the original, but I thought there might be a better way.. If I understood it right the dll is completely loaded into memory so there shouldn't be a problem in deleting the file..
Right-click on the . dll file in the search results, and select "Delete" from the options that pop up. This will move the file to the Recycle Bin.
dll Files are installed by software programs while they are installed These files contain code that tells programs how to operate. If you delete . dll files programs may not work properly. We suggest you not to delete these files as they may cause serious issues with the proper functioning of the computer.
A dll can only be loaded into a processes memory once.
Every process that loads the DLL maps it into its virtual address space. After the process loads the DLL into its virtual address, it can call the exported DLL functions. The system maintains a per-process reference count for each DLL. When a thread loads the DLL, the reference count is incremented by one.
If your asking if you can safely unload/unmap a DLL loaded in a process from code in the DLL itself, the answer is no - there isn't really a safe way to do this. Think about it this way: Unloading a DLL is done by decrementing it's reference count using FreeLibrary().
You can use load-time dynamic linking or run-time dynamic linking in your DLL in the same way as in the executable. The only restriction is not to call LoadLibrary from your DllMain function to avoid deadlocks.
No, that's not how Windows works. Loading a DLL merely creates a memory mapped file, nothing is actually read from the file beyond the relocations (if necessary). Not until your code calls an exported function. Which causes a page fault because the code wasn't loaded yet. Now the code gets read from the file into RAM. If space is needed for other processes then the pages simply gets unmapped. Getting reloaded again on the next page fault.
The MMF puts a hard lock on the file. You can only rename it, not overwrite or delete it. That would crash the program. Release the lock with FreeLibrary().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With