Unhandled exception

So i`m trying to create a window but getting error.
Can someone help me with some advices?

CreateWnd:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
BOOL WindowWrap::CreateWnd(LPCTSTR szCaption, HINSTANCE hInst, HICON hIcon, HMENU hMenu, BOOL bMinBox)
{

	m_dwMainThreadID = GetCurrentThreadId();
	m_hCursorArrow = LoadCursor(NULL, IDC_ARROW);
	m_hCursorWait = LoadCursor(NULL, IDC_WAIT);
	m_hCursorIbeam = LoadCursor(NULL, IDC_IBEAM);
	m_hCursorSize = LoadCursor(NULL, IDC_SIZEALL);
	m_hCursorCurrent = m_hCursorArrow;
	m_hCursorHand = LoadCursor(NULL, IDC_HAND);
	
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);
	wcex.style			= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
	wcex.lpfnWndProc	= (WNDPROC)(m_Trunk.sfp4(&vEngine::WindowWrap::WndProc));;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInst;
	wcex.hIcon			= hIcon;
	wcex.hCursor		= m_hCursorCurrent;
	wcex.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);
	wcex.lpszMenuName	= 0;
	wcex.lpszClassName	= szCaption;
	wcex.hIconSm		= 0;// LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
	
	if( 0 == RegisterClassEx(&wcex) ) 
	{
		OutputDebugString(_T("error register window class"));
		return FALSE;
	}

	if (bMinBox)
		m_hWnd = ::CreateWindow(szCaption, szCaption, WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU,
			CW_USEDEFAULT, CW_USEDEFAULT, m_nWidth, m_nHeight, NULL, NULL, hInst, NULL); // <---- error there
	else
		m_hWnd = ::CreateWindow(szCaption, szCaption, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU,
			CW_USEDEFAULT, CW_USEDEFAULT, m_nWidth, m_nHeight, NULL, NULL, hInst, NULL);

	if( !m_hWnd ) 
	{
		OutputDebugString(_T("error creating window"));
		return 1;
	}
//... some other staff there
}


m_Trunk:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//m_Trunk is
TSFPTrunk<WindowWrap>			m_Trunk;

//
//

//sfp4
template<typename T>
	DWORD (WINAPI* sfp4(T f))(DWORD, DWORD, DWORD, DWORD)	
	{
		DWORD dwID = *(DWORD*)(VOID*)&f;
		std::map<DWORD, DWORD>::iterator it = m_mapFP.find(dwID);
		if( it != m_mapFP.end() )
			return (DWORD(WINAPI*)(DWORD,DWORD,DWORD,DWORD))it->second;

		LPBYTE pByte = new BYTE[MAX_SFP_CODE_SIZE];
		if( pByte == NULL )
			return NULL;

		m_RealCodeList.push_back(pByte);
		m_fp4List.push_back((sfp_FP4)f);
		m_mapFP.insert(std::pair<DWORD, DWORD>(dwID, (DWORD)pByte));

		memcpy( pByte, m_Code4, sizeof(m_Code4));
		*(DWORD*)&pByte[20] = (DWORD)&m_pObj;
		*(DWORD*)&pByte[28] = (DWORD)&m_fp4List.back();

		return (DWORD(WINAPI*)(DWORD,DWORD,DWORD,DWORD))pByte;
	}


WndProc:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112


LRESULT WindowWrap::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	//
	switch( msg )
	{
	case WM_ERASEBKGND:	// ґ¦Анґ°їЪ±»ІЛµҐµИ¶«ОчёІёЗµДЦШ»­
		if( m_pRender )
			m_pRender->Present();	
		return false;
	case WM_DESTROY:
		PostQuitMessage(0);	
		break;
	case WM_ACTIVATEAPP:
	case WM_ACTIVATE:
		m_bWindowActive = (wParam != 0);
		if( FALSE == m_bWindowActive )
			::ClipCursor(NULL);	
		break;

	case WM_LBUTTONDOWN:
		if( m_bWindowActive )
		{
			RECT rcWindow;	
			::GetClientRect(hWnd, &rcWindow);
			::ClientToScreen(hWnd, (LPPOINT)&rcWindow);
			::ClientToScreen(hWnd, (LPPOINT)&rcWindow + 1);
			::ClipCursor(&rcWindow);
		}
		break;

	case WM_LBUTTONUP:
		if( m_bWindowActive )
			::ClipCursor(NULL);	
		break;

	case WM_MOVE:
	case WM_SIZE:
		if( m_bWindowActive && m_pRender )
			m_pRender->UpdateWindowPos();
		break;

	case WM_SETCURSOR:  
		/*::SetCursor(m_hCursorCurrent);*/
		OnWindowsMsg(WM_SETCURSOR, (DWORD)wParam, (DWORD)lParam);
		return true;

    case WM_SYSCOMMAND:
		switch (wParam)
		{
		case SC_TASKLIST:
		case SC_SCREENSAVE:
		case SC_MONITORPOWER:
        case SC_KEYMENU:
        case SC_MOUSEMENU:
			return false;
		case SC_CLOSE:
			PostMessage(hWnd, WM_COMMAND, IDM_FILE_EXIT, 0);
			OnWindowsMsg(WM_QUIT, 0, 0);
			return false;
		default:
			OnWindowsMsg((DWORD)msg, (DWORD)wParam, (DWORD)lParam);
			break;
		}
		break;

	case WM_SYSKEYUP:
		if( wParam == VK_MENU || wParam == VK_F10 ) 
			return false;
		break;
	}

	//if( m_bWindowActive )
	{
		switch( msg )
		{
		case WM_CHAR:
		case WM_KEYDOWN:
		case WM_KEYUP:
		case WM_LBUTTONDOWN:
		case WM_LBUTTONUP:
		case WM_LBUTTONDBLCLK:
		case WM_RBUTTONDOWN:
		case WM_RBUTTONUP:
		case WM_MOUSEMOVE:
		case WM_MOUSEWHEEL:
		case WM_SYSKEYDOWN:
		case WM_SYSCHAR:
		case WM_SYSKEYUP:
		case WM_INPUTLANGCHANGE:
		case WM_IME_SETCONTEXT:				
		case WM_INPUTLANGCHANGEREQUEST:
		case WM_VENGINE_USER:
		case WM_COMMAND:
			OnWindowsMsg((DWORD)msg, (DWORD)wParam, (DWORD)lParam);
			break;
		case WM_IME_STARTCOMPOSITION:
		case WM_IME_ENDCOMPOSITION:
		case WM_IME_NOTIFY:
		case WM_IME_COMPOSITION:
			{
				OnWindowsMsg((DWORD)msg, (DWORD)wParam, (DWORD)lParam);
				if( m_bInvisibleIme )
					return false;
			}
			break;
		}
	}

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


Now i`m just thinking about problem with passed params to CreateWindow but i`m not sure.

Also szCaptions is L"LoginServer", height and width are defined too and hInst - LoginServer.exe!_IMAGE_DOS_HEADER__ImageBase
Last edited on
http://www.cplusplus.com/forum/general/112111/

> I paste code from different files so its not from just one.
http://www.eelis.net/iso-c++/testcase.xhtml
A testcase consisting of randomly copy&paste'd bits of code that you thought were relevant can obviously not reproduce the problem.


> It worked when i replace WndProc with other one. Other one was like without
> any logic (just empty one) but i got some errors with that later.
I don't want a description, just post the code.
¿what did that "empty" WndProc() return?
also, if «it worked but got some errors later», then it did not work.
Its hard to post all code because there is a lot of it.

I just created github rep with project.

https://github.com/rankery/LoongSource/blob/master/Source/vEngine/system/window_wrap.cpp#L115

Link to this file with line where project crushes.


Also it may be helpfull

1
2
3
4
5
6

00A6C6AE  call        dword ptr [__imp__CreateWindowExW@48 (0A89410h)]  
00A6C6B4  mov         edx,dword ptr [this]   // <-- error with this action
00A6C6B7  mov         dword ptr [edx+40h],eax  
			0, 0, m_nWidth, m_nHeight, NULL, NULL, hInst, NULL);
Last edited on
Its hard to post all code because there is a lot of it.

Then construct a minimal, compilable codeset that exhibits the problem. In all probability, the process of doing that will help you diagnose the problem yourself, and if it doesn't, you'll have something that you can post here so that we can help you.
I went to your github project page trying to download it and debug, but gave up because it lacks 2 practical minimums.

1. comments for each function and class, what the code does, in english of course, that is necessary if you wan't people to collaborate with your project.

2. error checking code is missing everywhere, most of the WIN32 and COM problems can be solved by error checking which you lack.
Topic archived. No new replies allowed.