Access violating reading location

I have this code

1
2
3
	old_evhndl =  *(FARPROC*)(obj->old_eventhandler());

	return CallWindowProc(old_evhndl, hwnd, msg, (WPARAM)wParam, (LPARAM)lParam);


The exception points to the last line and shows me this:

Exception thrown at 0x00007FF9F23F5260 (user32.dll) in filetool.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

I know that there is a problem with pointer conversions. What I could observe is that when I comment the first line out there is no exception. So I guess there is a problem with this (FARPROC)obj->old_eventhandler();

old_eventhandler() has a void* as a return type. It is defined like this:

1
2
#ifndef _GwGUI_MOTIF
virtual void* old_eventhandler()    { return NULL;  }

old_evhndl is defined like this:

static FARPROC old_evhndl = NULL;
STRICT is not defined so CallWindowProc is expecting a FARPROC as the first argument.
Last edited on
Since FARPROC is already hiding a pointer (it is just a function pointer), then perhaps you meant

old_evhndl = static_cast<FARPROC>(obj->old_eventhandler());

It does not work. I still get the same exception
Pull it apart into multiple statements and examine with the debugger.

Where does the pointer that's returned by old_eventhandler() come from? Does the function have the correct signature and calling convention?
any chance you are mixing 64 and 32 bit?
I don't think mixing of 64 and 32 bit. It will created mess.
Topic archived. No new replies allowed.