How can I fix this access violation writing location?

0

I am porting from 32 to 64 bit and the project is so far that it is compiling. But I get exceptions when I try to start the program. I already changed Set/GetWindowLong with Set/GetWindowLongPtr anf checked with the /Wp64 for warnings but there are too many (like 3000).

This is the block of code where the exception appears:

FARPROC old_evhndl = (FARPROC)obj->old_eventhandler(); //ide shows me here the address of old_evhndl
if (!old_evhndl || !IsWindow (hwnd))
    return 0;

if ((msg==WM_MOUSEWHEEL)&&scroll_handl)
    return 0;

LRESULT lRes = CallWindowProc(old_evhndl, hwnd, msg, (WPARAM)wParam,(LPARAM) lParam); //exception points here | ide shows me here the address of old_evhndl
return lRes;

The exception:

Exception thrown at 0x00007FF9F241D7E6 (user32.dll) in filetool.exe: 0xC0000005: Access violation writing location 0x00000000BFEFD0B0.

The high 32 bits of that 64-bit address are all zero AND it's obviously invalid as it's showing up in an access violation. So it's obviously been truncated.

Realistically, the only way this happens is casting a pointer to a 32-bit integer type and back.

I traced it back but could not find anything suspicious. Maybe it can't handle the conversion from old_eventhandler to FARPROC. old_eventhandler has the type void*.

The address the ide is pointing me for old_evhndl is ntdll.dll!0x00007FF9F 403BE60. I see a similarity to this address 0x00007FF9F E24D7E6. You can also see it from here: https://imgur.com/2gCMG6b

c++
visual-studio
exception
32bit-64bit
memory-access
asked on Stack Overflow Apr 7, 2020 by (unknown user) • edited Apr 7, 2020 by Hive7

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0