程序工作正常(伴隨隨機崩潰)和Memory Validator報告pD3D = Direct3DCreate9中的未初始化讀取問題。 可能是什麼問題?未初始化的讀取問題
init3D.h
class CD3DWindow
{
public:
CD3DWindow();
~CD3DWindow();
LPDIRECT3D9 pD3D;
HRESULT PreInitD3D();
HWND hWnd;
bool killed;
VOID KillD3DWindow();
};
init3D.cpp
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;
}
裏面主要的應用程序的.h
CD3DWindow *d3dWin;
裏面主要的應用程序的.cpp
d3dWin = new CD3DWindow;
d3dWin->PreInitD3D();
這裏是錯誤報告:
Error: UNINITIALIZED READ: reading register ebx
@0:00:02.969 in thread 4092
0x7c912a1f <ntdll.dll+0x12a1f> ntdll.dll!RtlUnicodeToMultiByteN
0x7e42d4c4 <USER32.dll+0x1d4c4> USER32.dll!WCSToMBEx
0x7e428b79 <USER32.dll+0x18b79> USER32.dll!EnumDisplayDevicesA
0x4fdfc8c7 <d3d9.dll+0x2c8c7> d3d9.dll!DebugSetLevel
0x4fdfa701 <d3d9.dll+0x2a701> d3d9.dll!D3DPERF_GetStatus
0x4fdfafad <d3d9.dll+0x2afad> d3d9.dll!Direct3DCreate9
0x00644c59 <Temp.exe+0x244c59> Temp.exe!CD3DWindow::PreInitD3D
c:\_work\Temp\initd3d.cpp:32
你認爲「隨機崩潰」是「工作正常」? – jalf
:-)沒有。我想建議DirectX正確初始化,所以Direct3DCreate9不是問題。任何想法可能是問題? – en667
誤報,忽略它。在init3D.h中定義了' –