Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 11:28

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C++ DLL_PROCESS_DETACH

Discussion on C++ DLL_PROCESS_DETACH within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
Chriko2502's Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 39
Received Thanks: 1
C++ DLL_PROCESS_DETACH

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
Chriko2502 is offline  
Old 03/16/2014, 23:41   #2


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,904
Received Thanks: 25,394
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.
MrSm!th is offline  
Old 03/17/2014, 07:58   #3
 
Chriko2502's Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 39
Received Thanks: 1
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?
Chriko2502 is offline  
Old 03/17/2014, 13:43   #4
 
elite*gold: 1000
Join Date: Apr 2012
Posts: 1,003
Received Thanks: 208
I guess you could try to hook PostQuitMessage.
qkuh is offline  
Reply




All times are GMT +2. The time now is 11:28.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.