Discussion:
ISOLATION_AWARE_ENABLED used, The dll is freed automatically.
(too old to reply)
Terry
2010-05-20 09:05:01 UTC
Permalink
Raw Message
Hi,all:
My namespace extension using following flag to enable XP style common control.
ISOLATION_AWARE_ENABLED

It works.

But when the last function _Term() which is called when explorer close.
It is called in DllMain like this:
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID
/*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
if(S_OK != _Module.Init(ObjectMap, hInstance))
return FALSE;
g_hInstAppRes = (HINSTANCE)_Module.GetResourceInstance();
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
_Module.Term();
return TRUE; // ok
}

I actually need to do some uninitialization work in Term function --
_Module.Term();
However, I found a dll loaded dynamically by my extension have already been
released. So when I call a function ReleaseXXXX() in the this dll cause a
crash.
I think the dynamicly loaded dll's reference count should big than 1, since
I have not called the FreeLibrary function.

Could anyone help me.

Thanks.
Terry
bviksoe
2010-05-21 06:33:44 UTC
Permalink
Raw Message
Post by Terry
Hi,all:
My namespace extension using following flag to enable XP style common control.
ISOLATION_AWARE_ENABLED
It works.
But when the last function _Term() which is called when explorer close.
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID
/*lpReserved*/)
{
    if (dwReason == DLL_PROCESS_ATTACH)
    {
        if(S_OK != _Module.Init(ObjectMap, hInstance))
                        return FALSE;
                g_hInstAppRes = (HINSTANCE)_Module.GetResourceInstance();
        DisableThreadLibraryCalls(hInstance);
    }
    else if (dwReason == DLL_PROCESS_DETACH)
        _Module.Term();
    return TRUE;    // ok
}
I actually need to do some uninitialization work in Term function --
_Module.Term();
However, I found a dll loaded dynamically by my extension have already been
released. So when I call a function ReleaseXXXX() in the this dll cause a
crash.
I think the dynamicly loaded dll's reference count should big than 1, since
I have not called the FreeLibrary function.
Could anyone help me.
Thanks.
Terry
Raymond to the rescue:
http://blogs.msdn.com/oldnewthing/archive/2005/05/23/421024.aspx

regards
bjarke
Terry
2010-05-22 05:13:01 UTC
Permalink
Raw Message
Hi, Bviksoe:
Thank you very much for your reply.

Since I can not do uninitialization works in dll detach.
Do you know where is the good place to do these work?

My namespace folder object seems to be created and freed many times. The
object release function could not be a good place, I think.


Could you please give me some advice?
Thanks.

Terry
Post by bviksoe
Post by Terry
Hi,all:
My namespace extension using following flag to enable XP style common control.
ISOLATION_AWARE_ENABLED
It works.
But when the last function _Term() which is called when explorer close.
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID
/*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
if(S_OK != _Module.Init(ObjectMap, hInstance))
return FALSE;
g_hInstAppRes = (HINSTANCE)_Module.GetResourceInstance();
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
_Module.Term();
return TRUE; // ok
}
I actually need to do some uninitialization work in Term function --
_Module.Term();
However, I found a dll loaded dynamically by my extension have already been
released. So when I call a function ReleaseXXXX() in the this dll cause a
crash.
I think the dynamicly loaded dll's reference count should big than 1, since
I have not called the FreeLibrary function.
Could anyone help me.
Thanks.
Terry
http://blogs.msdn.com/oldnewthing/archive/2005/05/23/421024.aspx
regards
bjarke
.
Jean-Marie Pierrard
2010-05-22 10:01:33 UTC
Permalink
Raw Message
Hi Terry,

Perhaps you should do this uninitialization in DllCanUnloadNow, when this
function returns true ?
Just an idea...

Best regards,
Jean-Marie
Post by Terry
Thank you very much for your reply.
Since I can not do uninitialization works in dll detach.
Do you know where is the good place to do these work?
My namespace folder object seems to be created and freed many times. The
object release function could not be a good place, I think.
Could you please give me some advice?
Thanks.
Terry
Loading...