Help with access violation reading location (exception) RRS feed

  • Question

  • I have this lines of code:

    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 


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

    #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.

    Wednesday, April 8, 2020 12:40 PM

All replies

  • Did you try ‘(FARPROC)obj->old_eventhandler()’ instead of ‘*(FARPROC*)obj->old_eventhandler()’?

    Wednesday, April 8, 2020 2:13 PM
  • Yes, I tried but it does not work.
    • Edited by poiuzt12321 Thursday, April 9, 2020 8:22 AM
    Thursday, April 9, 2020 5:22 AM
  • Hi,

    Thank you for posting here.

    >>0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

    As far as I'm concerned, You may not have initialized something. Some default initialization will be performed during debugging.

    I'm appreciate that if you could provide us with a sample demo to reproduce the issue, We will provide you with better help. 

    Best Regards,

    Jeanine Zhang

    Thursday, April 9, 2020 8:40 AM
  • In the code shown, old_eventhandler() returns NULL. You are then dereferencing this NULL pointer, which of course leads to a crash.

    Igor Tandetnik

    • Proposed as answer by Tim Roberts Saturday, April 11, 2020 6:52 AM
    Friday, April 10, 2020 4:24 AM