Skip to main content
GameDev.net gamedev.net
🔒 Locked

(NTDLL.DLL):0xc0000142 :DLL Initialization Failed in release mode on windows vista

Started by kundi Sep 15, 2009 at 10:07 AM 20 replies 12.9k views
Original Post
kundi
kundi
I developed a dialog-based DirectX graphics application in VS2003.NET use MFC and D3D9X on windows XP, it can run correctly. Then I put this application on windows vista, when I debug this application in debug mode, it can run correctly. But when I run it in release mode, it does not run and not any reaction. Then I debug it in release mode on windows vista, it is interrupted at the beginning, and promopt the error: Unhandle exception in xx.exe(NTDLL.DLL):0xc0000142 :DLL Initialization Failed. I konwed that it is caused by loaded dll of d3d9, but I don`t know why? Hopefully someone encountered the same problem and give me some help, or can help me to investigate it. Thanks [Edited by - kundi on September 15, 2009 6:46:36 PM]
mmakrzem
mmakrzem
sounds like a memory problem. In debug mode your variables will get initialized for you but in release mode no free lunch. You have to do it yourself so make sure that you are not trying to use any variables that have not been setup properly.
kundi
kundi
If does not load the d3d9 library, the applicaton also can run correctly on vista OS in release mode. But if loads d3d9 library,then if report the error:Unhandle exception in xx.exe(NTDLL.DLL):0xc0000142 :DLL Initialization Failed.

So I think that it is causede by fail to loading D3D9 library before application start. But I don`t why it happened? Because it can execute smoothly in debug mode. So maybe it is not related to any variables is not initialized, but load d3d9 dll failed.
Codeka
Codeka
STATUS_DLL_INIT_FAILED (which is 0xC0000142) is returned when a DLL's DllMain method returns an error.

I suggest you use the debug DirectX DLL (via the DirectX Control Panel application), turn up the log level and then use something like DebugView to see whether it spits out any error messages.
yewbie
yewbie
Try using http://www.dependencywalker.com/ and profile the program you can tell what its trying to load when and where it crashes

edit: mistype on url

[Edited by - yewbie on September 16, 2009 10:28:19 PM]
kundi
kundi
Is it possibly relative to user Privilege on windows vista?
Codeka
Codeka
Quote:
Original post by kundi
Is it possibly relative to user Privilege on windows vista?
Unlikely. Did you try what was suggested above?
kundi
kundi
No,I didn`t, Just because Vista OS has some privilege limit on some operation sometimes. So I just guess.

Maybe it is not possible, because I use the Vista OS as administrator.
kundi
kundi
No,I didn`t, Just because Vista OS has some privilege limit on some operation sometimes. So I just guess.

Maybe it is not possible, because I use the Vista OS as administrator.
kundi
kundi
Does DirectX Control Panel application can run on VISTA?
I don`t konw how to debug directx dll.

Hi Codeka, Could you give me some suggestion?
kundi
kundi
On vista OS, the main problem is that it can debug and run correctly in debug mode. But fail to load d3d9 dll in release mode.
Codeka
Codeka
Yes, it runs on Vista. You need to have the DirectX SDK for it to be installed, though. What happens when you try it?

I would also check the event viewer to see if anything gets logged there. Did you try dependency walker that yewbie mentioned?
kundi
kundi
Hi Codeka, I have installed DirectX SDK on vista os. I have tried using depends.exe to open my application exe file, and the information of dlls dependency is right.

And I runned DirectX Control Panel application on vista, and setted the debug output level to the hightest level, But I don
t konw what to go follow.
can you tell me how to debug the directx dll concretly ? and where I can find the logged file about debug ouput infomation?
yewbie
yewbie
When you ran it in depends did you actually profile it?, its really good for tracking down weird problems like this.
kundi
kundi
How to profile?
kundi
kundi
I have known how to profile?
I will try it again.

Thanks yewbie.
kundi
kundi
00:00:03.578: DllMain(0x007B0000, DLL_PROCESS_ATTACH, 0x0012FD24) in "d:\windows\system32\MFC71D.DLL" returned 1 (0x1) by thread 1.
00:00:03.578: DllMain(0x10480000, DLL_PROCESS_ATTACH, 0x0012FD24) in "d:\windows\system32\MSVCP71D.DLL" called by thread 1.
00:00:03.594: DllMain(0x10480000, DLL_PROCESS_ATTACH, 0x0012FD24) in "d:\windows\system32\MSVCP71D.DLL" returned 1 (0x1) by thread 1.
00:00:03.594: DllMain(0x726D0000, DLL_PROCESS_ATTACH, 0x0012FD24) in "d:\windows\system32\D3D8THK.DLL" called by thread 1.
00:00:03.594: DllMain(0x726D0000, DLL_PROCESS_ATTACH, 0x0012FD24) in "d:\windows\system32\D3D8THK.DLL" returned 1 (0x1) by thread 1.
00:00:03.594: DllMain(0x4C7F0000, DLL_PROCESS_ATTACH, 0x0012FD24) in "f:\casino\myproject\\\D3D9.DLL" called by thread 1.
00:00:03.609: DllMain(0x4C7F0000, DLL_PROCESS_ATTACH, 0x0012FD24) in "f:\casino\myproject\\\D3D9.DLL" returned 0 (0x0) by thread 1.
00:00:03.609: First chance exception 0xC0000142 (DLL Initialization Failed) occurred in "d:\windows\system32\NTDLL.DLL" at address 0x77B78FC7 by thread 1.
00:00:03.609: Second chance exception 0xC0000142 (DLL Initialization Failed) occurred in "d:\windows\system32\NTDLL.DLL" at address 0x77B78FC7 by thread 1.
00:00:03.609: Thread 1 exited with code -1073741502 (0xC0000142).
00:00:03.640: Thread 2 started in "d:\windows\system32\NTDLL.DLL" at address 0x77BD0F18.
00:00:03.656: Exited "f:\casino\myproject\\\BOBING.EXE" (process 0xCEC) with code -1073741502 (0xC0000142) by thread 2.
kundi
kundi
Above is the last information.

The Entry Point DllMain of D3D9.DLL is failed.

kundi
kundi
What`s wrong?

Can you help me investigate it? Thanks.
kundi
kundi
What`s wrong?

Can you help me investigate it? Thanks.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.