I'm trying to generate/use the Subclassing thunk and although I have been able to compile each of them using VS2019 / x86 - I'm running into a problem during the Test step of main().
If I step through the code, everything appears to function correctly UP TO the CallWindowProc test which throws the following "Unhandled exception"
Exception thrown at 0x00CA0944 in thunks.exe: 0xC0000005: Access violation writing location 0x00000000.
The output window shows:
hWnd=00A256CC
hThunk=00CA0000
THUNK_SIZE=250
The only change I could find that seemed most appropriate was to include MEM_COMMIT on the VirtualAlloc function:
void *hThunk = VirtualAlloc(0, 0x10000, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
I've stared at it for hours trying to follow the logic (including the assembly of SubclassingFunc). Since the faulting address appears to be inside of the SubclassingThunk Code which has been copied to the dynamically-allocated page, Moreover, the fault appears to be outside of the range of the THUNK_SIZE that's been copied into that allocated space. So that seems odd to me and having walked through the listing, nothing is jumping out at me. Because I'm unclear about the best means of debugging this any further, I thought I'd ask here. Any guidance would be welcome.
Attached is the compiler listing for the file including assembler output. If I can provide or try anything else, I'll be happy to provide.
thunks.zip
Thanks!
I'm trying to generate/use the Subclassing thunk and although I have been able to compile each of them using VS2019 / x86 - I'm running into a problem during the Test step of main().
If I step through the code, everything appears to function correctly UP TO the CallWindowProc test which throws the following "Unhandled exception"
Exception thrown at 0x00CA0944 in thunks.exe: 0xC0000005: Access violation writing location 0x00000000.The output window shows:
The only change I could find that seemed most appropriate was to include
MEM_COMMITon the VirtualAlloc function:void *hThunk = VirtualAlloc(0, 0x10000, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);I've stared at it for hours trying to follow the logic (including the assembly of SubclassingFunc). Since the faulting address appears to be inside of the SubclassingThunk Code which has been copied to the dynamically-allocated page, Moreover, the fault appears to be outside of the range of the THUNK_SIZE that's been copied into that allocated space. So that seems odd to me and having walked through the listing, nothing is jumping out at me. Because I'm unclear about the best means of debugging this any further, I thought I'd ask here. Any guidance would be welcome.
Attached is the compiler listing for the file including assembler output. If I can provide or try anything else, I'll be happy to provide.
thunks.zip
Thanks!