In order to avoid infinite loop, I think you can first try this:
static bool isMyMessageBox = false;
if( ! isMyMessageBox)
{
isMyMessageBox = true;
::MessageBox(....);
isMyMessageBox = false;
}
If it works, you should take care it works in multi-threaded case too. (Probably TlsGetValue and TlsSetValue can help).