473,466 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DllMain(DLL_PROCESS_DETACH) not called

I can get Explorer to load (via LoadLibrary()) my DLL using VirtualAlloc(),
WriteProcessMemory(), and CreateRemoteThread() (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_DETACH).]

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_PROCESS_DETACH) is not called when Explorer terminates after my
DLL has been loaded as described above.

Why isn't DllMain called with DLL_PROCESS_DETACH when Explorer terminates?

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

<quote>
If you terminate a process by calling TerminateProcess or
TerminateJobObject, the DLLs of that process do not receive
DLL_PROCESS_DETACH 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_DETACH when Explorer terminates?

It depends on "how" the process was terminated.
If it was terminated using "TerminateProcess" then DLL_PROCESS_DETACH
will not be called.

<quote>
If you terminate a process by calling TerminateProcess or
TerminateJobObject, the DLLs of that process do not receive
DLL_PROCESS_DETACH 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
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...
1
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...
4
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...
0
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...
1
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...
7
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...
3
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
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...
10
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.