Unhandled exception at ...: User breakpoint.

Started by
1 comment, last by SONB 18 years, 8 months ago
Hi, I'm trying to make a simple sprite animation. It works fine but the Direct3D debugging gives the following messages: 'Xample1.exe': Loaded 'E:\Eigene Dateien\Visual Studio Projects\Xample1\Debug\Xample1.exe', Symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\d3d9.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\d3d8thk.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\wbsys.dll', No symbols loaded. First-chance exception at 0x7c928fea in Xample1.exe: 0xC0000005: Access violation writing location 0x00000010. 'Xample1.exe': Unloaded 'C:\WINDOWS\system32\wbsys.dll' 'Xample1.exe': Loaded 'E:\Programme\Stardock\Object Desktop\WindowBlinds\wblind.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\msimg32.dll', No symbols loaded. 'Xample1.exe': Loaded 'E:\Programme\Stardock\Object Desktop\WindowBlinds\wbhelp.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\msctf.dll', No symbols loaded. 'Xample1.exe': Loaded 'C:\WINDOWS\system32\d3d9d.dll', No symbols loaded. Direct3D9: :====> ENTER: DLLMAIN(010116f0): Process Attach: 00000e40, tid=00000e44 Direct3D9: :====> EXIT: DLLMAIN(010116f0): Process Attach: 00000e40 Direct3D9: (INFO) :Direct3D9 Debug Runtime selected. D3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFO 'Xample1.exe': Loaded 'C:\WINDOWS\system32\d3dref9.dll', No symbols loaded. Direct3D9: (INFO) :======================= Reference SWVP device selected Direct3D9: (INFO) :HalDevice Driver style 9 Direct3D9: :DoneExclusiveMode 'Direct3D REF Device 1': Attached to debug monitor. 'Direct3D REF-owned HAL (SWVP) Device 1': Attached to debug monitor. Direct3D9: :====> ENTER: DLLMAIN(010116f0): Process Detach 00000e40, tid=00000e44 Direct3D9: (INFO) :MemFini! Direct3D9: (ERROR) :Memory still allocated! Alloc count = 104 Direct3D9: (ERROR) :Current Process (pid) = 00000e40 Unhandled exception at 0x7c911230 in Xample1.exe: User breakpoint. Direct3D9: (ERROR) :Memory Address: 00b44ff4 lAllocID=1 dwSize=000047f8, ReturnAddr=010114db (pid=00000e40) Direct3D9: (ERROR) :Memory Address: 00b4b2fc lAllocID=9 dwSize=00001440, ReturnAddr=01008044 (pid=00000e40) Direct3D9: (ERROR) :Memory Address: 00b42d04 lAllocID=10 dwSize=00000018, ReturnAddr=01008132 (pid=00000e40) Direct3D9: (ERROR) :Memory Address: 00b4c774 lAllocID=11 dwSize=00000d20, ReturnAddr=0100970f (pid=00000e40) Direct3D9: (ERROR) :Memory Address: 00b4df54 lAllocID=22 dwSize=0000180c, ReturnAddr=01008044 (pid=00000e40) Direct3D9: (ERROR) :Memory Address: 00b4f794 lAllocID=23 dwSize=00000014, ReturnAddr=01008132 (pid=00000e40) Direct3D9: (ERROR) :Memory Address: 00b42614 lAllocID=34 dwSize=000006bc, ReturnAddr=01022f4b (pid=00000e40) Direct3D9: (ERROR) :Memory Address: 00b4d4cc lAllocID=35 dwSize=00000914, ReturnAddr=0102aac2 (pid=00000e40) Direct3D9: (ERROR) :Memory Address: 00b4de14 lAllocID=38 dwSize=00000064, ReturnAddr=0102adf6 (pid=00000e40) Direct3D9: (ERROR) :Memory Address: 00b49824 lAllocID=39 dwSize=00001a94, ReturnAddr=01014a19 (pid=00000e40) Direct3D9: (ERROR) :Memory Address: 00b4deac lAllocID=40 dwSize=00000014, ReturnAddr=01014b5d (pid=00000e40) Direct3D9: (ERROR) :Total Memory Unfreed From Current Process = 44140 bytes Direct3D9: :====> EXIT: DLLMAIN(010116f0): Process Detach 00000e40 The program '[3648] Xample1.exe: Native' has exited with code 0 (0x0). The program '[3648] Xample1.exe: Direct3D REF Device 1' has exited with code 0 (0x0). The program '[3648] Xample1.exe: Direct3D REF-owned HAL (SWVP) Device 1' has exited with code 0 (0x0). I tried to get rid of those memory allocation errors but they are still there. The code follows:

// INCLUDES //////////////////////////////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>

// GLOBALS ///////////////////////////////////////////////////////////////////////////////////////////////////////
HINSTANCE hInst; // global handle to hold the application instance
HWND wndHandle; // global variable to hold the window handle

LPDIRECT3D9				g_pD3D;
LPDIRECT3DDEVICE9		g_pd3dDevice;

IDirect3DSurface9			*g_pSurface;

IDirect3DSurface9			*g_pBackbuffer;

LARGE_INTEGER timeStart;
LARGE_INTEGER timeEnd;
LARGE_INTEGER timerFreq;
float anim_rate;
int Count;

// SPRITE STRUCT ////////////////////////////////////////////////////////////////////////////////////////////////
struct {
	RECT srcRect;

	int posX;
	int posY;

} spriteStruct[8];

// FUNCTIONS /////////////////////////////////////////////////////////////////////////////////////////////////////
bool initWindow(HINSTANCE hInstance);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

bool initDirect3D(void);
bool initSprites(void);
void render(void);
bool unInitWindow(HINSTANCE hInstance);
void cleanUp(void);

// WINMAIN ////////////////////////////////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
    // Initialize the window
	if (!initWindow(hInstance))
        return false;

	// Initialize Direct3D
	if(!initDirect3D())
		return false;

	if(!initSprites())
		return false;

    // main message loop:
	MSG msg;

	ZeroMemory(&msg, sizeof(msg));

	while(msg.message!=WM_QUIT)
	{
        // Check the message queue
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
            TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			render();
		}
	}

	cleanUp();

	unInitWindow(hInstance);

    return (int)msg.wParam;
}

/******************************************************************************
* bool initWindow( HINSTANCE hInstance )
* initWindow registers the window class for the application, creates the window
******************************************************************************/
bool initWindow(HINSTANCE hInstance)
{
    WNDCLASSEX wcex;
    
	// Fill in the WNDCLASSEX structure. This describes how the window
	// will look to the system
	wcex.cbSize					= sizeof(WNDCLASSEX);					// the size of the structure
	wcex.style						= CS_HREDRAW | CS_VREDRAW;		// the class style
	wcex.lpfnWndProc			= (WNDPROC)WndProc;					// the window procedure callback
	wcex.cbClsExtra			= 0;													// extra bytes to allocate for this class
	wcex.cbWndExtra			= 0;													// extra bytes to allocate for this instance
	wcex.hInstance				= hInstance;										// handle to the application instance
	wcex.hIcon					= 0;													// icon to associate with the application
	wcex.hCursor				= LoadCursor(NULL, IDC_ARROW);	// the default cursor
	wcex.hbrBackground		= (HBRUSH)(COLOR_WINDOW+1);	// the background color
	wcex.lpszMenuName		= NULL;											// the resource name for the menu
	wcex.lpszClassName		= "DirectXExample";							// the class name being created
	wcex.hIconSm				= 0;													// the handle to the small icon

	RegisterClassEx(&wcex);

	// Create the window
	wndHandle = CreateWindow("DirectXExample",					// the window class to use
												"DirectXExample",					// the title bar text
												WS_OVERLAPPEDWINDOW,	// WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE,	 the window style
                                                CW_USEDEFAULT,					// the starting x coordinate
                                                CW_USEDEFAULT,					// the starting y coordinate
                                                640,										// the pixel width of the window
                                                480,										// the pixel height of the window
                                                NULL,									// the parent window; NULL for desktop
                                                NULL,									// the menu for the application; NULL for none
                                                hInstance,								// the handle to the application instance
                                                NULL);									// no values passed to the window

    // Make sure that the window handle that is created is valid
	if (!wndHandle)
        return false;

    // Display the window on the screen
    ShowWindow(wndHandle, SW_SHOW);
	
	UpdateWindow(wndHandle);

    return true;
}

/******************************************************************************
* LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
* LPARAM lParam)
* The window procedure
******************************************************************************/
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    // Check any available messages from the queue
	switch (message)
	{
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	}

    // Always return the message to the default window
	// procedure for further processing

    return DefWindowProc(hWnd, message, wParam, lParam);
}

/*********************************************************************
* initDirect3D
*********************************************************************/
bool initDirect3D(void)
{
    g_pD3D			= NULL;
	g_pd3dDevice	= NULL;
	g_pSurface		= NULL;

	// Create the DirectX object
	if(NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
	{
		return false;
	}

    // Fill the presentation parameters structure
	D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory(&d3dpp, sizeof(d3dpp));
	d3dpp.Windowed = TRUE;										// FALSE;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;	// D3DFMT_X8R8G8B8;
	d3dpp.BackBufferCount = 1;
	d3dpp.BackBufferHeight = 480;
	d3dpp.BackBufferWidth = 640;
	d3dpp.hDeviceWindow = wndHandle;

	// Create a default DirectX device
	if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,
													D3DDEVTYPE_REF,
													wndHandle,
													D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                                    &d3dpp, &g_pd3dDevice)))
	{
		return false;
	}

	if(FAILED(g_pd3dDevice->CreateOffscreenPlainSurface(640, 480, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &g_pSurface, NULL)))
		return false;

	if(FAILED(D3DXLoadSurfaceFromFile(g_pSurface, NULL, NULL, "anim.bmp", NULL, D3DX_DEFAULT, 0, NULL)))
		return false;


	return true;
}

bool initSprites(void)
{
	Count = 0;
	for(int i = 0; i < 8; i++)
	{
		spriteStruct.srcRect.top			= 0;
		spriteStruct.srcRect.left			= i * 64;
		spriteStruct.srcRect.right		= spriteStruct.srcRect.left + 64;
		spriteStruct.srcRect.bottom	= 64;

		spriteStruct.posX					= 300;
		spriteStruct.posY					= 200;
	}

	return true;
}

/*********************************************************************
* render
*********************************************************************/
void render(void)
{
	
	g_pBackbuffer = NULL;
	
    // Check to make sure you have a valid Direct3D device
    if(NULL == g_pd3dDevice)
		return;// Clear the back buffer to a blue color
    
	g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0,0,0 ), 1.0f, 0);

	g_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &g_pBackbuffer);

	RECT destRect;
	destRect.left			= spriteStruct[Count].posX;
	destRect.top			= spriteStruct[Count].posY;
	destRect.right		= destRect.left + 64;
	destRect.bottom	= destRect.top + 64;
		
        g_pd3dDevice->StretchRect(g_pSurface, &spriteStruct[Count].srcRect, g_pBackbuffer, &destRect, D3DTEXF_NONE);
	// }

	// Present the back buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );

	if(Count < 8)
		Count++;
	else
		Count = 0;
}

bool unInitWindow(HINSTANCE hInstance)
{
    // Unregister the window class
    UnregisterClass("DirectXExample", hInstance);

    return TRUE;
}

void cleanUp (void)
{
	if(g_pSurface != NULL)
	{
        g_pSurface->Release();
		g_pSurface = NULL;
	}

	if(g_pBackbuffer != NULL)
	{
		g_pBackbuffer->Release();
		g_pBackbuffer = NULL;
	}

    // Release the device and the Direct3D object
	if(g_pd3dDevice != NULL)
	{
		g_pd3dDevice->Release( );
		g_pd3dDevice = NULL;
	}

    if(g_pD3D != NULL)
	{
		g_pD3D->Release( );
		g_pD3D = NULL;
	}
}

That's it. Any suggestion? SONB
Advertisement
you've probably got a bad pointer or are overrunning on an array do a single step on your program to narrow down where the error is
Andrew Wardrobe
Thanx for your reply andrew.

I checked all pointers and arrays but I don't see there any errors.
In the DirectX control panel I entered the lAllocID's from the debug messages (see above) and tried to debug the app. The debugger breaked on lAllocID=1 into the line

if(NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
{
return false;
}

and on lAllocID=22 and 23 into

if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, wndHandle, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice)))
{
return false;
}

On the other ID's it says "There is no source code available for the current location".

What could be wrong with these two lines?


SONB

This topic is closed to new replies.

Advertisement