Click to See Complete Forum and Search --> : WM_COPYDATA failing


dave2k
November 21st, 2005, 03:31 PM
i have case WM_COPYDATA:
//MessageBeep(0);
PostMessage(hwnd, WM_CUSTOM, wParam, lParam);
return 0;

case WM_CUSTOM:
{
MessageBeep(0);
COPYDATASTRUCT *lpMsg =(COPYDATASTRUCT*)lParam;
MessageBox(NULL, (char*)lpMsg->lpData, "", NULL);
//MessageBeep(0);
break;
}

the reason behind doing this is to try and let the hook which is sending the WM_COPYDATA data to resume what's it's doing immediately, and for my program to spend time anaylising it's data.

The trouble is, when i run this code, i get an error: access violation when reading 0xffffff

what could this be?

Mike Harnad
November 21st, 2005, 04:59 PM
Have you stepped through the code in the debugger? Where does it crash?

dave2k
November 21st, 2005, 05:11 PM
it crashes on the MessageBox line,
cheers

Mike Harnad
November 21st, 2005, 05:14 PM
Have you checked that ...

COPYDATASTRUCT *lpMsg =(COPYDATASTRUCT*)lParam;
lpMsg is a valid pointer?

dave2k
November 21st, 2005, 05:16 PM
yep - when i put the lines COPYDATASTRUCT *lpMsg =(COPYDATASTRUCT*)lParam;
MessageBox(NULL, (char*)lpMsg->lpData, "", NULL);after my COPYDATA case, it prints out the text in a message box correctly

Mike Harnad
November 21st, 2005, 05:21 PM
So, in your first post, does it crash on the first case, or the second?

dave2k
November 21st, 2005, 05:24 PM
the second

is it possible something to do with the lParam pointing to memory outside of my apps memory space..