C++ DLL_PROCESS_DETACH

03/16/2014 21:56 Chriko2502#1
Hi, its me again having a question about the dll_process_detach. I am injecting my dll file into a target process and running some functions... When i am closing the target process (using the [x] in the top right corner) the DLL_PROCESS_DETACH is executet, isnt it? But when i run the following code the internetopen fails, where its working fine in the "main routine" of my dll file... also i am wondering because the follwoing KillProcessByName workes quite fine...

Perhaps u can tell my why this is happening or better why the internetopen isnt working :( And perhaps u have some solution or hints for me?

THX a lot!

Code:
.....
case DLL_PROCESS_DETACH: 

			HINTERNET hInternet = InternetOpen("Blablabla", INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
			HINTERNET hInternetSite = InternetConnect(hInternet, "Blablabla", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
			HINTERNET hInternetSiteRequest = HttpOpenRequest(hInternetSite, "POST", "Blablabla", NULL, NULL, NULL, 0, 1);

			KillProcessByName("ABC.exe");
			
			AddLog("DLL Detached");
			AddLog("==========LOG END==========\n\n\n");
			break;

....
PS: of cause the "Blablabla" is different in the original code ;)
03/16/2014 23:41 MrSm!th#2
It's not a good idea to do such things in your DllMain. The called blocking-functions will block the whole process.
Especially, note that you cannot be sure that the wininet.dll is still loaded when your DllMain is called with DLL_PROCESS_DETACH.
03/17/2014 07:58 Chriko2502#3
Quote:
Originally Posted by MrSm!th View Post
Especially, note that you cannot be sure that the wininet.dll is still loaded when your DllMain is called with DLL_PROCESS_DETACH.
Ok then i need a function, which is "listening" if the process is closing... Perhpas u can tell me how to do that?
03/17/2014 13:43 qkuh#4
I guess you could try to hook PostQuitMessage.