I have a Win32 application that gets the HANDLE of a MFC application. My goal is to force the MFC program not to display ASSERT error message box.
Basically, I have made a prototype that allows my Win32 application to force the MFC application to show a message box, just to check if the idea is possible. Now I need to force the MFC application not to display such ASSERT error message boxes.
Is that possible?
You can do this by intercepting the
MessageBoxA/MessageBoxWfunction call. At a usermode level, this is typically done in one of three places:MessageBoxin your executable. You need to find the one that you want to disable. Then you can overwrite the call with code that does nothing (i.e. overwrite withnopinstructions).MessageBoxcan allow theMessageBoxcall to be redirected to some routine that does nothing.MessageBoxfunction. This can be located byGetProcAddressand the first instruction replaced with aret.The manipulation is done either at runtime (dynamically) or statically (binary rewriting/executable editing) with the first option being far more common. A library which can help you achieve runtime detouring is Microsoft Detours.
This is not a comprehensive list of all the possibilities, but rather the most common methods of execution redirection and detouring.