by JohnStevenson » Mon Jun 14, 2004 1:51 pm
Hi Madshi
Great products - thanks.
I have a problem when I uninject my dll, as it does not always seem to be completely released. Here is the scenario:
Dll injection/uninjection is performed by a service application, which my program controls using SendIpcMessage. I use (Un)InjectLibrarySessionW, having obtained the session id with GetCurrentSessionId. The dll is injected from my program's main form Create procedure, and uninjected from its Destroy procedure. The service application logs its events so I can see that the dll is being successfully (un)injected. And my program does what it's supposed to do, so I know everything is working.
If I want to uninstall/update my program, my installer makes sure my program is not running, stops the service and then deletes/replaces the files. However, I keep getting "Access Denied" errors when the installer attemps to delete or overwrite the injection dll. But this only happens if my program has been automatically started from the user's Start Up folder!
If I start the program normally then stop it, I can delete the dll. But if it has been auto started I cannot, unless I log off then back on.
I can get round this problem by calling the dll injection later in my program (ie not in FormCreate but as the result of a user action), but I cannot work out why this is happening. Any ideas?
This does not happen on Win 98SE or Win2000, but only on XP. I've tested it on 2 XP machines with the same results.
Incidentally, with fast-user switching, things get really confused:
If User 1 auto-starts the program then the dll cannot be deleted by User 1 or any subsequent user.
However, if User 1 does not auto-start the program but User 2 does, both User 1 and User 2 CAN delete the dll!