c++ - DllMain freezing When register a COM dll -
i try register com dll named mixcenter.dll. have found out dlls dependent on. when executives dllmain first time, freezes , never returns. seems deadlock, don't call loadlibrary, , never execute dllmain. there other reasons situation ? dllmain looks like:
bool apientry dllmain(handle hmodule, dword ul_reason_for_call, lpvoid lpreserved) { switch(ul_reason_for_call) { case dll_process_attach: g_hinstdll = hmodule; log(info) <<"--------------begin logging--------------"; return dllentrypoint((hinstance)hmodule, ul_reason_for_call, lpreserved); case dll_thread_attach: break; case dll_thread_detach: break; case dll_process_detach: log(info) << "--------------end logging--------------"; break; } return true; } i log whole execution using dependency walker, essential part of log is:
loadlibraryexw("mixcenter.dll", 0x00000000, load_with_altered_search_path) called "regsvr32.exe" @ address 0x003920ff thread 1. loaded "mixcenter.dll" @ address 0x10000000 thread 1. hooked module. loaded "msvcr80.dll" @ address 0x6f250000 thread 1. hooked module. loaded "d3d9.dll" @ address 0x6c130000 thread 1. hooked module. loaded "d3d8thk.dll" @ address 0x73490000 thread 1. hooked module. loaded "d3dx9_40.dll" @ address 0x69b00000 thread 1. hooked module. loaded "msvcp80.dll" @ address 0x71430000 thread 1. hooked module. dllmain(0x6f250000, dll_process_attach, 0x00000000) in "msvcr80.dll" called thread 1. getprocaddress(0x75c90000 [kernel32.dll], "flsalloc") called "msvcr80.dll" @ address 0x6f253001 , returned 0x75ce8731 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "flsgetvalue") called "msvcr80.dll" @ address 0x6f25300e , returned 0x75ce0dc7 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "flssetvalue") called "msvcr80.dll" @ address 0x6f25301b , returned 0x75ce2904 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "flsfree") called "msvcr80.dll" @ address 0x6f253028 , returned 0x75ce2ad7 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "encodepointer") called "msvcr80.dll" @ address 0x6f252bbc , returned 0x77603275 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "encodepointer") called "msvcr80.dll" @ address 0x6f252bbc , returned 0x77603275 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "encodepointer") called "msvcr80.dll" @ address 0x6f252bbc , returned 0x77603275 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "encodepointer") called "msvcr80.dll" @ address 0x6f252bbc , returned 0x77603275 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "encodepointer") called "msvcr80.dll" @ address 0x6f252bbc , returned 0x77603275 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "encodepointer") called "msvcr80.dll" @ address 0x6f252bbc , returned 0x77603275 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "encodepointer") called "msvcr80.dll" @ address 0x6f252bbc , returned 0x77603275 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "initializecriticalsectionandspincount") called "msvcr80.dll" @ address 0x6f259668 , returned 0x75ce0d2b thread 1. getprocaddress(0x75c90000 [kernel32.dll], "encodepointer") called "msvcr80.dll" @ address 0x6f252bbc , returned 0x77603275 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252c33 , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "encodepointer") called "msvcr80.dll" @ address 0x6f252d3a , returned 0x77603275 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "decodepointer") called "msvcr80.dll" @ address 0x6f252d4a , returned 0x775ff050 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "isprocessorfeaturepresent") called "msvcr80.dll" @ address 0x6f26a967 , returned 0x75ce0dd4 thread 1. getprocaddress(0x75bc0000 [msvcrt.dll], "_set_error_mode") called "msvcr80.dll" @ address 0x6f254447 , returned 0x75bd4a3d thread 1. getprocaddress(0x75bc0000 [msvcrt.dll], "?set_terminate@@yap6axxzp6axxz@z") called "msvcr80.dll" @ address 0x6f254463 , returned 0x75beebb7 thread 1. getprocaddress(0x75bc0000 [msvcrt.dll], "_get_terminate") called "msvcr80.dll" @ address 0x6f25447f , returned null thread 1. error: (127). getprocaddress(0x75c90000 [kernel32.dll], "findactctxsectionstringw") called "msvcr80.dll" @ address 0x6f251dbe , returned 0x75ce18f9 thread 1. getprocaddress(0x75c90000 [kernel32.dll], "getsystemwindowsdirectoryw") called "msvcr80.dll" @ address 0x6f251f1a , returned 0x75ce0e64 thread 1. dllmain(0x6f250000, dll_process_attach, 0x00000000) in "msvcr80.dll" returned 1 (0x1) thread 1. dllmain(0x73490000, dll_process_attach, 0x00000000) in "d3d8thk.dll" called thread 1. dllmain(0x73490000, dll_process_attach, 0x00000000) in "d3d8thk.dll" returned 1 (0x1) thread 1. dllmain(0x6c130000, dll_process_attach, 0x00000000) in "d3d9.dll" called thread 1. dllmain(0x6c130000, dll_process_attach, 0x00000000) in "d3d9.dll" returned 1 (0x1) thread 1. dllmain(0x69b00000, dll_process_attach, 0x00000000) in "d3dx9_40.dll" called thread 1. dllmain(0x69b00000, dll_process_attach, 0x00000000) in "d3dx9_40.dll" returned 1 (0x1) thread 1. dllmain(0x71430000, dll_process_attach, 0x00000000) in "msvcp80.dll" called thread 1. dllmain(0x71430000, dll_process_attach, 0x00000000) in "msvcp80.dll" returned 1 (0x1) thread 1. dllmain(0x10000000, dll_process_attach, 0x00000000) in "mixcenter.dll" called thread 1.
there lot of things can't in dllmain. not can not call loadlibrary yourself, can't cause loadlibrary called, , registering com server sounds might loadlibrary @ point.
but not extent of can't in dllmain. list long , complex, best thing use 2-phase initialization scheme, in dllmain sets flag , other code within dll complex initialization. "other code" might thread withing dll, or might init() function call dll's main routines when invoked.
Comments
Post a Comment