[PATCH] msvcrt: Pass WCHAR strings to MessageBoxIndirectW.
Nikolay Sivov
bunglehead at gmail.com
Thu Dec 22 15:53:40 CST 2016
On Thu, 22 Dec 2016 14:38:19 -0700
Alex Henrie <alexhenrie24 at gmail.com> wrote:
> Cc: Piotr Caban <piotr at codeweavers.com>
> Cc: Nikolay Sivov <bunglehead at gmail.com>
>
> Fixes https://bugs.winehq.org/show_bug.cgi?id=42057
>
> I figured this would be a good time to get rid of the misleading
> Hungarian notation and move the string into the single function that
> uses it.
>
> v2: Switch to WCHAR type.
>
> Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
> ---
> dlls/msvcrt/exit.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/dlls/msvcrt/exit.c b/dlls/msvcrt/exit.c
> index 9ba0891806..ad5a78d54d 100644
> --- a/dlls/msvcrt/exit.c
> +++ b/dlls/msvcrt/exit.c
> @@ -41,8 +41,6 @@ typedef struct MSVCRT__onexit_table_t
> MSVCRT__onexit_t *_end;
> } MSVCRT__onexit_table_t;
>
> -static const char szMsgBoxTitle[] = "Wine C++ Runtime Library";
> -
> extern int MSVCRT_app_type;
> extern MSVCRT_wchar_t *MSVCRT__wpgmptr;
>
> @@ -112,10 +110,12 @@ void CDECL MSVCRT__exit(int exitcode)
> /* Print out an error message with an option to debug */
> static void DoMessageBoxW(const MSVCRT_wchar_t *lead, const MSVCRT_wchar_t *message)
> {
> - static const MSVCRT_wchar_t message_format[] = {'%','s','\n','\n','P','r','o','g','r','a','m',':',' ','%','s','\n',
> + static const WCHAR message_format[] = {'%','s','\n','\n','P','r','o','g','r','a','m',':',' ','%','s','\n',
> '%','s','\n','\n','P','r','e','s','s',' ','O','K',' ','t','o',' ','e','x','i','t',' ','t','h','e',' ',
> 'p','r','o','g','r','a','m',',',' ','o','r',' ','C','a','n','c','e','l',' ','t','o',' ','s','t','a','r','t',' ',
> 't','h','e',' ','W','i','n','e',' ','d','e','b','b','u','g','e','r','.','\n',0};
> + static const WCHAR title[] =
> + {'W','i','n','e',' ','C','+','+',' ','R','u','n','t','i','m','e',' ','L','i','b','r','a','r','y',0};
'message_format' is used with MSVCRT__snwprintf, so it should be wchar_t strictly speaking.
>
> MSGBOXPARAMSW msgbox;
> MSVCRT_wchar_t text[2048];
Another existing bug is wrong buffer length here:
---
MSVCRT__snwprintf(text,sizeof(text),message_format, lead, MSVCRT__wpgmptr, message);
---
Could be a separate patch I guess.
> @@ -126,8 +126,8 @@ static void DoMessageBoxW(const MSVCRT_wchar_t *lead, const MSVCRT_wchar_t *mess
> msgbox.cbSize = sizeof(msgbox);
> msgbox.hwndOwner = GetActiveWindow();
> msgbox.hInstance = 0;
> - msgbox.lpszText = (LPCWSTR)text;
> - msgbox.lpszCaption = (LPCWSTR)szMsgBoxTitle;
> + msgbox.lpszText = text;
> + msgbox.lpszCaption = title;
What I meant is that you can remove 'text' cast without changing its type.
> msgbox.dwStyle = MB_OKCANCEL|MB_ICONERROR;
> msgbox.lpszIcon = NULL;
> msgbox.dwContextHelpId = 0;
More information about the wine-devel
mailing list