Problem with my own programmed game

Well hello,

I created myself a game. I runs alright with Debugger, but without debugger, it crashes immediately.
I tried to find the error, with cout. After each function or something I type a line like "cout << "DIRECTX::LoadTexture()\n";" or something similiar.

Anyway, here is a piece of code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
IDAdd  = GUI::AddChild("Button", "Add Message", 100, 20, 698, 117, WS_VISIBLE | WS_CHILD | BS_BITMAP | BS_FLAT);	
IDEdit = GUI::AddChild("Edit", "", 695, 20, 2, 117, WS_VISIBLE | WS_CHILD | WS_BORDER);
IDList = GUI::AddChild("Listbox", "", 796, 125, 2, 2, WS_VISIBLE | WS_CHILD | WS_BORDER | WS_TABSTOP | WS_VSCROLL | LBS_DISABLENOSCROLL);

cout<< "GUI::AddChild() Done\n";

SendMessage(Childs[IDAdd],  BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)(HANDLE)LoadImage(NULL, "Images/AddMessage.bmp", IMAGE_BITMAP, 100, 20, LR_LOADFROMFILE));
SendMessage(Childs[IDEdit], WM_SETFONT, (WPARAM)CreateFontA(15, 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, "Comic Sans MS"), FALSE);
SendMessage(Childs[IDList], WM_SETFONT, (WPARAM)CreateFontA(15, 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, "Comic Sans MS"), FALSE);

cout << "SendMessage() Done\n";

Oldproc = (PROC)SetWindowLongPtr(Childs[1], GWL_WNDPROC, (DWORD)EditProc);
cout << "Oldproc\n";
assert(Oldproc);
SetFocus(MainWnd);

cout << "SetFocus() Done\n";

cout << "DIRECTX:\n";
DirectX		= new DIRECTX(MainWnd); // Creating DirectX
cout << "DirectX = new DIRECTX(MainWnd);\n";

The output was:
Output wrote:

GUI::AddChild() Done
SendMessage() Done
Oldproc
SetFocus() Done
DIRECTX:


Its really weird. Because it crashes at the part where DIRECTX: is initialized.
But the weird part is this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
DIRECTX::DIRECTX(HWND Window) {      
	cout << "DIRECTX::DIRECTX\n";
	DIRECTX::counter		= 0;
	cout << "DIRECTX::counter\n";
	DIRECTX::DXWindow		= Window;
	cout << "DIRECTX::DXWindow\n";
	DIRECTX::Interface		= 0;
	cout << "DIRECTX::Interace\n";
	DIRECTX::Device		= 0;
	DIRECTX::Sprite		= 0;

	DIRECTX::InitInterface();
	cout << "DIRECTX::InitInterface();\n";
	DIRECTX::InitDevice();
	cout << "DIRECTX::InitDevice();\n";
	DIRECTX::InitSprite();
	cout << "DIRECTX::InitSprite();\n";

}

This is the Constructor of DIRECTX. But it immidiatly crashes after coming in the constructor, it doesn't even cout DIRECTX::DIRECTX() T___T.

I'm really stuck, does ANYBODY had this problem before? I really need to fix it, I'm so frustrated.
You have memory corruption. Look for duplicate deletes (that is, deleting the same pointer more than once), buffer overflows, and possibly invalid deletes (deleting a pointer that wasn't actually ever allocated).
This is one of the toughest type of bug to fix because the bugged line can be arbitrarily far from the line where the program crashes.
Topic archived. No new replies allowed.