Skip to content

Commit 36174f9

Browse files
committed
[USER32] Implement support for the MB_SERVICE_NOTIFICATION flag in the MessageBox*() APIs.
1 parent c035f46 commit 36174f9

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

win32ss/user/user32/windows/messagebox.c

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
*/
3131

3232
#include <user32.h>
33+
#include <ndk/exfuncs.h>
34+
3335
#include <ntstrsafe.h>
3436

3537
WINE_DEFAULT_DEBUG_CHANNEL(user32);
@@ -454,6 +456,86 @@ MessageBoxTimeoutIndirectW(
454456
MSGBTNINFO Buttons;
455457
LPCWSTR ButtonText[MSGBOXEX_MAXBTNS];
456458

459+
// TODO: Check whether the caller is an NT 3.x app and if so, check
460+
// instead for the MB_SERVICE_NOTIFICATION_NT3X flag and adjust it.
461+
if (lpMsgBoxParams->dwStyle & MB_SERVICE_NOTIFICATION)
462+
{
463+
NTSTATUS Status;
464+
UNICODE_STRING CaptionU, TextU;
465+
ULONG Response = ResponseNotHandled; /* HARDERROR_RESPONSE */
466+
ULONG_PTR MsgBoxParams[4] =
467+
{
468+
(ULONG_PTR)&TextU,
469+
(ULONG_PTR)&CaptionU,
470+
/*
471+
* Retrieve the message box flags. Note that we filter out
472+
* MB_SERVICE_NOTIFICATION to not enter an infinite recursive
473+
* loop when we will call MessageBox() later on.
474+
*/
475+
lpMsgBoxParams->dwStyle & ~MB_SERVICE_NOTIFICATION,
476+
dwTimeout
477+
};
478+
479+
/* hwndOwner must be NULL */
480+
if (lpMsgBoxParams->hwndOwner != NULL)
481+
{
482+
ERR("MessageBoxTimeoutIndirectW(MB_SERVICE_NOTIFICATION): hwndOwner is not NULL!\n");
483+
return 0;
484+
}
485+
486+
//
487+
// FIXME: TODO: Implement the special case for Terminal Services.
488+
//
489+
490+
RtlInitUnicodeString(&CaptionU, lpMsgBoxParams->lpszCaption);
491+
RtlInitUnicodeString(&TextU, lpMsgBoxParams->lpszText);
492+
493+
Status = NtRaiseHardError(STATUS_SERVICE_NOTIFICATION | HARDERROR_OVERRIDE_ERRORMODE,
494+
ARRAYSIZE(MsgBoxParams),
495+
(1 | 2),
496+
MsgBoxParams,
497+
OptionOk, /* NOTE: This parameter is ignored */
498+
&Response);
499+
if (!NT_SUCCESS(Status))
500+
{
501+
ERR("MessageBoxTimeoutIndirectW(MB_SERVICE_NOTIFICATION): NtRaiseHardError failed, Status = 0x%08lx\n", Status);
502+
return 0;
503+
}
504+
505+
/* Map the returned response to the buttons */
506+
switch (Response)
507+
{
508+
/* Not handled */
509+
case ResponseReturnToCaller:
510+
case ResponseNotHandled:
511+
break;
512+
513+
case ResponseAbort:
514+
return IDABORT;
515+
case ResponseCancel:
516+
return IDCANCEL;
517+
case ResponseIgnore:
518+
return IDIGNORE;
519+
case ResponseNo:
520+
return IDNO;
521+
case ResponseOk:
522+
return IDOK;
523+
case ResponseRetry:
524+
return IDRETRY;
525+
case ResponseYes:
526+
return IDYES;
527+
case ResponseTryAgain:
528+
return IDTRYAGAIN;
529+
case ResponseContinue:
530+
return IDCONTINUE;
531+
532+
/* Not handled */
533+
default:
534+
break;
535+
}
536+
return 0;
537+
}
538+
457539
ZeroMemory(&mbd, sizeof(mbd));
458540
memcpy(&mbd.mbp, lpMsgBoxParams, sizeof(mbd.mbp));
459541
mbd.wLanguageId = (WORD)lpMsgBoxParams->dwLanguageId;

0 commit comments

Comments
 (0)