xfreerdp: fix usage of invalid structure pointer in event handling

This commit is contained in:
Marc-André Moreau 2011-09-25 17:47:40 -04:00
parent e5215158d2
commit 3b3152003f
2 changed files with 42 additions and 28 deletions

View File

@ -128,20 +128,19 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
wfInfo* wfi;
PAINTSTRUCT ps;
rdpInput* input;
boolean processed;
processed = True;
ptr = GetWindowLongPtr(hWnd, GWLP_USERDATA);
wfi = (wfInfo*) ptr;
input = wfi->instance->input;
switch (Msg)
if (wfi != NULL)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
input = wfi->instance->input;
case WM_PAINT:
if (wfi != NULL)
{
switch (Msg)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
BitBlt(hdc, ps.rcPaint.left, ps.rcPaint.top,
ps.rcPaint.right - ps.rcPaint.left,
@ -149,39 +148,53 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
wfi->primary->hdc, ps.rcPaint.left, ps.rcPaint.top,
SRCCOPY);
EndPaint(hWnd, &ps);
}
break;
break;
case WM_LBUTTONDOWN:
if (wfi != NULL)
case WM_LBUTTONDOWN:
input->MouseEvent(input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, X_POS(lParam), Y_POS(lParam));
break;
break;
case WM_LBUTTONUP:
if (wfi != NULL)
case WM_LBUTTONUP:
input->MouseEvent(input, PTR_FLAGS_BUTTON1, X_POS(lParam), Y_POS(lParam));
break;
break;
case WM_RBUTTONDOWN:
if (wfi != NULL)
case WM_RBUTTONDOWN:
input->MouseEvent(input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, X_POS(lParam), Y_POS(lParam));
break;
break;
case WM_RBUTTONUP:
if (wfi != NULL)
case WM_RBUTTONUP:
input->MouseEvent(input, PTR_FLAGS_BUTTON2, X_POS(lParam), Y_POS(lParam));
break;
break;
case WM_MOUSEMOVE:
if (wfi != NULL)
case WM_MOUSEMOVE:
input->MouseEvent(input, PTR_FLAGS_MOVE, X_POS(lParam), Y_POS(lParam));
break;
case WM_SETCURSOR:
SetCursor(wfi->cursor);
break;
default:
processed = False;
break;
}
}
else
{
processed = False;
}
if (processed)
return 0;
switch (Msg)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
case WM_SETCURSOR:
if (wfi != NULL)
SetCursor(wfi->cursor);
else
SetCursor(g_default_cursor);
SetCursor(g_default_cursor);
break;
case WM_SETFOCUS:

View File

@ -65,6 +65,7 @@ boolean wf_pre_connect(freerdp* instance)
wfi = (wfInfo*) xzalloc(sizeof(wfInfo));
SET_WFI(instance, wfi);
wfi->instance = instance;
settings = instance->settings;