Uninitialized read problem
<p>Program works fine (with random crashes) and Memory Validator reports Uninitialized read problem in pD3D = Direct3DCreate9.
What could be the problem ?</p>

<p>init3D.h </p>

<pre><code>    class CD3DWindow
    {
            public:
                CD3DWindow();
                ~CD3DWindow();
                LPDIRECT3D9 pD3D;
                HRESULT PreInitD3D();
                HWND hWnd;  
                bool killed;
                VOID KillD3DWindow();
    };
</code></pre>

<p>init3D.cpp</p>

<pre><code>    CD3DWindow::CD3DWindow()
    {
        pD3D=NULL; 
    }

    CD3DWindow::~CD3DWindow()
    {
        if (!killed) KillD3DWindow();
    }

    HRESULT CD3DWindow::PreInitD3D()
    {
        pD3D = Direct3DCreate9( D3D_SDK_VERSION );  // Here it reports a problem 
        if( pD3D == NULL )  return E_FAIL;
    // Other not related code

    VOID CD3DWindow::KillD3DWindow()
    {
        if (killed) return;
        diwrap::input.UnCreate();   
        if (hWnd) DestroyWindow(hWnd);
        UnregisterClass( "D3D Window", wc.hInstance );
        killed = true;
    }
</code></pre>

<p>Inside main app .h</p>

<pre><code>    CD3DWindow *d3dWin;
</code></pre>

<p>Inside main app .cpp</p>

<pre><code>    d3dWin = new CD3DWindow;
d3dWin-&gt;PreInitD3D();
</code></pre>

<p>And here is the error report:</p>

<pre><code> Error: UNINITIALIZED READ: reading register ebx
@0:00:02.969 in thread 4092

 0x7c912a1f &lt;ntdll.dll+0x12a1f&gt; ntdll.dll!RtlUnicodeToMultiByteN

0x7e42d4c4 &lt;USER32.dll+0x1d4c4&gt; USER32.dll!WCSToMBEx

0x7e428b79 &lt;USER32.dll+0x18b79&gt; USER32.dll!EnumDisplayDevicesA

0x4fdfc8c7 &lt;d3d9.dll+0x2c8c7&gt; d3d9.dll!DebugSetLevel

0x4fdfa701 &lt;d3d9.dll+0x2a701&gt; d3d9.dll!D3DPERF_GetStatus

0x4fdfafad &lt;d3d9.dll+0x2afad&gt; d3d9.dll!Direct3DCreate9

0x00644c59 &lt;Temp.exe+0x244c59&gt; Temp.exe!CD3DWindow::PreInitD3D
c:\_work\Temp\initd3d.cpp:32   
</code></pre>
