473,769 Members | 4,985 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DllMain(DLL_PRO CESS_DETACH) not called

I can get Explorer to load (via LoadLibrary()) my DLL using VirtualAlloc(),
WriteProcessMem ory(), and CreateRemoteThr ead() (a technique discussed here
occasionally). [Using the same technique, I can get Explorer to later use
FreeLibrary() to unload my DLL (at which time, DllMain is called with
DLL_PROCESS_DET ACH).]

But I'd really like to jusy leave my DLL attached to Explorer until Explorer
terminates (typically logoff or shutdown). But I notice that
DllMain(DLL_PRO CESS_DETACH) is not called when Explorer terminates after my
DLL has been loaded as described above.

Why isn't DllMain called with DLL_PROCESS_DET ACH when Explorer terminates?

Thanks.
--
- Vince
Sep 5 '06 #1
2 6273
Hi Vincent!
Why isn't DllMain called with DLL_PROCESS_DET ACH when Explorer terminates?
It depends on "how" the process was terminated.
If it was terminated using "TerminateProce ss" then DLL_PROCESS_DET ACH
will not be called.

<quote>
If you terminate a process by calling TerminateProces s or
TerminateJobObj ect, the DLLs of that process do not receive
DLL_PROCESS_DET ACH notifications.
</quote>

Greetings
Jochen
Sep 5 '06 #2
On Tue, 05 Sep 2006 08:32:05 +0200, "Jochen Kalmbach [MVP]"
<no************ ********@holzma .dewrote:
>Hi Vincent!
>Why isn't DllMain called with DLL_PROCESS_DET ACH when Explorer terminates?

It depends on "how" the process was terminated.
If it was terminated using "TerminateProce ss" then DLL_PROCESS_DET ACH
will not be called.

<quote>
If you terminate a process by calling TerminateProces s or
TerminateJobOb ject, the DLLs of that process do not receive
DLL_PROCESS_DE TACH notifications.
</quote>
I am simply logging off. I would expect Explorer to be terminating
gracefully.
--
- Vince
Sep 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3210
by: Vamsi | last post by:
Hello, I am working in VC++ environment.while using gdi+, i want to use a public member variable of Bitmap. which needs to be initialized at the time of creation. and i m using this gdi+ in a Dll application. i am trying to initialize the bitmap object at the constructor. like Bitmap m-bmpobj; // Bitmap Obj which is a private member of the TextEffect Class
1
6547
by: phark52 | last post by:
My main app calls LoadLibrary() to load a DLL, which calls CreateThread(). This does NOT return NULL and I get a thread ID. However, ThreadProc never gets executed when this code is in the DLL. It works fine in the standalone EXE source. I put example code below. #define MB(msg) MessageBox(0, msg, "", MB_OK|MB_ICONINFORMATION); DWORD APIENTRY tproc() {
4
10226
by: Michael Roper | last post by:
In Jesse Liberty's "Programming in C#" he says that "...an assembly must have exactly one entry point: DLLMain, WinMain, or Main. DLLMain is the entry point for DLLs..." In the MSDN ".Net Framework Developer's Guide" it says that "...each assembly can have only one entry point (that is, DllMain, WinMain, or Main..." So we've got "must" vs. "can" and "DLLMain" vs. "DllMain."
0
1640
by: Arno Huetter | last post by:
Hi there, I invoke a native DLL function from managed code. This works fine, but it seems that the DLL's DllMain function is never called upon attaching / detaching. Does anyone have an idea why that could be the case? Thanks in advance! Kind regards,
1
8657
by: Boris | last post by:
With MFC Extension DLL that exports classes through __declspec(dllexport) DLL_PROCESS_ATTACH/DLL_PROCESS_DETACH 1. Does each a process loads dll only once and unloads dll only once during its life-time? DLL_THREAD_ATTACH/DLL_THREAD_DETACH 2. Does each a thread loads dll only once and unloads dll only once during its life-time? Does DLL_THREAD_DETACH occurs only when thread terminates?
7
2430
by: Adam | last post by:
I have a managed cpp wrapper. Im using this in a native dll as a static variable. I need to free this library when the dll is done being used. The perfect place to do this is DllMain for DLL_PROCESS_DETACH, but I can't do this when touching managed code, even if its just calling "delete someObject;". Any recommendations on how to free this object (it needs to be freed when the dll is being unloaded from its caller). Since the CRT is...
3
3090
by: Jozsef Bekes | last post by:
Hi All, is there a mechanism just like DllMain in VC6, a function that gets called whenever an assembly gets loaded? Thank you for all answers. Jozsi
3
1380
by: Abubakar | last post by:
Hi, I have a dll that gets called by an exe, I just placed a little code in its dlmain method and put a breakpoint on the code only to discover that its getting called nearly hundreds of times. I suspect each time some exported function is getting called the dllmain also gets called. Why is it happening and why should it happen? Regards, ...ab
10
2351
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, From MSDN, http://msdn2.microsoft.com/en-us/library/ms682583.aspx parameter fdwReason of DllMain has four values, DLL_PROCESS_ATTACH
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.