[PATCH] winewtsn: add a new program that shows a dialog to inform about a crash

Mikołaj Zalewski mikolaj at zalewski.pl
Sun Dec 14 15:04:43 CST 2008


---
 .gitignore                    |    1 +
 configure.ac                  |    1 +
 programs/winewtsn/Makefile.in |   18 +
 programs/winewtsn/crashdlg.c  |   99 +
 programs/winewtsn/resource.h  |   35 +
 programs/winewtsn/rsrc.rc     |   26 +
 programs/winewtsn/rsrc_En.rc  |   53 +
 programs/winewtsn/util.c      |  123 +
 programs/winewtsn/winewtsn.c  |  171 +
 programs/winewtsn/winewtsn.h  |   38 +
 tools/wine.inf.in             |    2 +-
 12 files changed, 4664 insertions(+), 5415 deletions(-)

diff --git a/.gitignore b/.gitignore
index dd81905..8d7fb04 100644
--- a/.gitignore
+++ b/.gitignore
@@ -275,6 +275,7 @@ programs/winetest/*_test.exe
 programs/winetest/tests.rc
 programs/winetest/winetest
 programs/winevdm/winevdm
+programs/winewtsn/winewtsn
 programs/winhlp32/macro.lex.yy.c
 programs/winhlp32/winhlp32
 programs/winver/winver
diff --git a/configure.ac b/configure.ac
index 071013c..db5b6cb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2160,6 +2160,7 @@ WINE_CONFIG_MAKEFILE([programs/winemine/Makefile],[programs/Makeprog.rules],[pro
 WINE_CONFIG_MAKEFILE([programs/winepath/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS,ALL_PROGRAM_BIN_INSTALL_DIRS])
 WINE_CONFIG_MAKEFILE([programs/winetest/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS])
 WINE_CONFIG_MAKEFILE([programs/winevdm/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS])
+WINE_CONFIG_MAKEFILE([programs/winewtsn/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS])
 WINE_CONFIG_MAKEFILE([programs/winhlp32/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS])
 WINE_CONFIG_MAKEFILE([programs/winver/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS])
 WINE_CONFIG_MAKEFILE([programs/wordpad/Makefile],[programs/Makeprog.rules],[programs],[ALL_PROGRAM_DIRS,ALL_PROGRAM_INSTALL_DIRS])
diff --git a/programs/winewtsn/Makefile.in b/programs/winewtsn/Makefile.in
new file mode 100644
index 0000000..7792fb0
--- /dev/null
+++ b/programs/winewtsn/Makefile.in
@@ -0,0 +1,18 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = winewtsn.exe
+APPMODE   = -mwindows
+IMPORTS   = user32 gdi32 advapi32 kernel32 comctl32 ntdll
+
+C_SRCS = \
+	crashdlg.c \
+	util.c \
+	winewtsn.c        
+
+RC_SRCS = rsrc.rc
+
+ at MAKE_PROG_RULES@
+
+ at DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/programs/winewtsn/crashdlg.c b/programs/winewtsn/crashdlg.c
new file mode 100644
index 0000000..0ff0467
--- /dev/null
+++ b/programs/winewtsn/crashdlg.c
@@ -0,0 +1,99 @@
+/*
+ * The dialog that displays after a crash
+ *
+ * Copyright 2008 Mikolaj Zalewski
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define WIN32_LEAN_AND_MEAN
+
+#include <windows.h>
+#include "resource.h"
+#include "winewtsn.h"
+
+static HFONT g_hBoldFont;
+static HMENU g_hDebugMenu = NULL;
+
+static void set_bold_font(HWND hDlg)
+{
+    HFONT hNormalFont = (HFONT)SendDlgItemMessageW(hDlg, IDC_STATIC_TXT1,
+            WM_GETFONT, 0, 0);
+    LOGFONTW font;
+    GetObjectW(hNormalFont, sizeof(LOGFONTW), &font);
+    font.lfWeight = FW_BOLD;
+    g_hBoldFont = CreateFontIndirectW(&font);
+    SendDlgItemMessageW(hDlg, IDC_STATIC_TXT1, WM_SETFONT, (WPARAM)g_hBoldFont, TRUE);
+}
+
+static void set_message_with_filename(HWND hDlg)
+{
+    WCHAR originalText[1000];
+    WCHAR newText[1000 + MAX_PROGRAM_NAME_LENGTH];
+    GetDlgItemTextW(hDlg, IDC_STATIC_TXT1, originalText,
+            sizeof(originalText)/sizeof(originalText[0]));
+    wsprintfW(newText, originalText, g_ProgramName);
+    SetDlgItemTextW(hDlg, IDC_STATIC_TXT1, newText);
+}
+
+static INT_PTR WINAPI DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    switch (msg)
+    {
+    case WM_INITDIALOG:
+    {
+        set_bold_font(hwnd);
+        set_message_with_filename(hwnd);
+        return TRUE;
+    }
+    case WM_CTLCOLORSTATIC:
+    {
+        /* WM_CTLCOLOR* don't use DWLP_MSGRESULT */
+        INT_PTR id = GetDlgCtrlID((HWND)lParam);
+        if (id == IDC_STATIC_BG || id == IDC_STATIC_TXT1)
+            return (LONG_PTR)GetSysColorBrush(COLOR_WINDOW);
+
+        return FALSE;
+    }
+    case WM_RBUTTONDOWN:
+    {
+        POINT mousePos;
+        if (!(wParam & MK_SHIFT))
+            return FALSE;
+        if (g_hDebugMenu == NULL)
+            g_hDebugMenu = LoadMenuW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDM_DEBUG_POPUP));
+        GetCursorPos(&mousePos);
+        TrackPopupMenu(GetSubMenu(g_hDebugMenu, 0), TPM_RIGHTBUTTON, mousePos.x, mousePos.y,
+                0, hwnd, NULL);
+        return TRUE;
+    }
+    case WM_COMMAND:
+        switch (LOWORD(wParam))
+        {
+            case IDOK:
+            case IDCANCEL:
+            case ID_DEBUG:
+                EndDialog(hwnd, LOWORD(wParam));
+                return TRUE;
+        }
+        return TRUE;
+    }
+    return FALSE;
+}
+
+INT_PTR display_crash_dialog()
+{
+    return DialogBoxW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDD_CRASH_DLG), NULL, DlgProc);
+}
diff --git a/programs/winewtsn/resource.h b/programs/winewtsn/resource.h
new file mode 100644
index 0000000..64215b4
--- /dev/null
+++ b/programs/winewtsn/resource.h
@@ -0,0 +1,35 @@
+/*
+ * Resource IDs (resource.h)
+ *
+ * Copyright 2008 Mikolaj Zalewski
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+
+#define IDD_CRASH_DLG   100
+
+#define IDC_STATIC_BG   100
+#define IDC_STATIC_TXT1 101
+#define IDC_STATIC_TXT2 102
+
+#define IDM_DEBUG_POPUP 100
+
+#define ID_DEBUG        200
+
+#define IDS_WINEWTSN          16
+#define IDS_INTERNAL_PROGRAM  17
+#define IDS_INVALID_PARAMS    18
+#define IDS_UNIDENTIFIED      19
diff --git a/programs/winewtsn/rsrc.rc b/programs/winewtsn/rsrc.rc
new file mode 100644
index 0000000..1c202a9
--- /dev/null
+++ b/programs/winewtsn/rsrc.rc
@@ -0,0 +1,26 @@
+/*
+ * Resources (rsrc.rc)
+ *
+ * Copyright 2008 Mikolaj Zalewski
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <windef.h>
+#include <winuser.h>
+
+#include "resource.h"
+
+#include "rsrc_En.rc"
diff --git a/programs/winewtsn/rsrc_En.rc b/programs/winewtsn/rsrc_En.rc
new file mode 100644
index 0000000..28b2bb5
--- /dev/null
+++ b/programs/winewtsn/rsrc_En.rc
@@ -0,0 +1,53 @@
+/*
+ * English Language Support
+ *
+ * Copyright 2008 Mikolaj Zalewski
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+IDM_DEBUG_POPUP MENU
+BEGIN
+    POPUP ""
+    BEGIN
+        MENUITEM "&Debug", ID_DEBUG
+    END
+END
+
+IDD_CRASH_DLG DIALOGEX 100, 100, 273, 175
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Program Error"
+FONT 8, "Tahoma"
+BEGIN
+    LTEXT           "",IDC_STATIC_BG,0,0,273,52,WS_BORDER,0
+    LTEXT           "The program %s has met a serious problem and needs to close. We are sorry for the inconvinience.",
+                    IDC_STATIC_TXT1,27,10,224,30
+    LTEXT           "This can be caused by a problem in the program or a deficiency in Wine. \
+                    You may want to check http://appdb.winehq.org if there are some  \
+                    tips about running this applicaiton.\n\n\
+                    If this problem is not present under Windows and it has not been reported \
+                    yet, you can report it at http://bugs.winehq.org",IDC_STATIC_TXT2,27,60,224,100
+    DEFPUSHBUTTON   "Close", IDOK, 205, 151, 60, 16, WS_TABSTOP
+END
+
+STRINGTABLE
+BEGIN
+    IDS_WINEWTSN         "Winewtsn"
+    IDS_INTERNAL_PROGRAM "This is an internal program to inform about a program crash. It is ment to be only started automatically by Wine."
+    IDS_INVALID_PARAMS   "Internal errors - invalid parameters received"
+    IDS_UNIDENTIFIED     "(unidentified)"
+END
diff --git a/programs/winewtsn/util.c b/programs/winewtsn/util.c
new file mode 100644
index 0000000..6bd94d2
--- /dev/null
+++ b/programs/winewtsn/util.c
@@ -0,0 +1,123 @@
+/*
+ * Utility functions for winewtsn
+ *
+ * Copyright 2008 Mikolaj Zalewski
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define WIN32_LEAN_AND_MEAN
+
+#include <windows.h>
+#include "resource.h"
+#include "winewtsn.h"
+
+#include <wine/debug.h>
+#include <wine/unicode.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(winewtsn);
+
+/* needed for get_process_image_name */
+#include "winternl.h"
+#define STATUS_SUCCESS                   ((NTSTATUS) 0x00000000)
+#define STATUS_INFO_LENGTH_MISMATCH      ((NTSTATUS) 0xC0000004)
+
+LPWSTR get_process_image_name(HANDLE hProcess)
+{
+    UNICODE_STRING *output;
+    ULONG size, returned;
+    NTSTATUS status;
+
+    status = NtQueryInformationProcess(hProcess, ProcessImageFileName, NULL, 0, &size);
+    if (status != STATUS_INFO_LENGTH_MISMATCH)
+    {
+        WINE_FIXME("First query returned %08x\n", status);
+        return NULL;
+    }
+
+    output = HeapAlloc(GetProcessHeap(), 0, size);
+    status = NtQueryInformationProcess(hProcess, ProcessImageFileName, output, size, &returned);
+    if (status != STATUS_SUCCESS)
+    {
+        WINE_FIXME("Second query returned %08x\n", status);
+        HeapFree(GetProcessHeap(), 0, output);
+        return NULL;
+    }
+
+    return output->Buffer;
+}
+
+int MessageBoxResId(HWND hwnd, UINT textId, UINT captionId, UINT uType)
+{
+    WCHAR caption[256];
+    WCHAR text[256];
+    LoadStringW(GetModuleHandleW(NULL), captionId, caption, sizeof(caption)/sizeof(caption[0]));
+    LoadStringW(GetModuleHandleW(NULL), textId, text, sizeof(text)/sizeof(text[0]));
+    return MessageBoxW(hwnd, text, caption, uType);
+}
+
+/* helper for parse_command_line */
+static LPWSTR argdupW(const WCHAR *start, const WCHAR *end)
+{
+    LPWSTR result = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (end - start + 1));
+    const WCHAR *pcInput = start;
+    WCHAR *pcOutput = result;
+
+    while (pcInput < end)
+    {
+        if (*pcInput != '\"')
+            *(pcOutput++) = *pcInput;
+        pcInput++;
+    }
+    *pcOutput = 0;
+    return result;
+}
+
+/* This function doesn't support nested quotes. We don't use CommandLineToArgvW
+ * to avoid the need to import shell32.
+ */
+void parse_command_line(LPCWSTR cmdline, int *pArgc, LPWSTR **pArgv)
+{
+    BOOL in_quote = FALSE;
+    const WCHAR *pc = cmdline;
+
+    *pArgc = 0;
+    /* make sure we pass a valid pointer to HeapReAlloc: */
+    *pArgv = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWSTR));
+    while (*pc)
+    {
+        const WCHAR *arg_start;
+        while (isspaceW(*pc))
+            pc++;
+
+        arg_start = pc;
+        while (*pc && (!isspaceW(*pc) || in_quote))
+        {
+            if (*pc == '\"')
+                in_quote = !in_quote;
+            pc++;
+        }
+
+        if (arg_start < pc)
+        {
+            /* found an argument */
+            LPWSTR arg = argdupW(arg_start, pc);
+            (*pArgc)++;
+            *pArgv = HeapReAlloc(GetProcessHeap(), 0, *pArgv, (*pArgc)*sizeof(LPWSTR));
+            (*pArgv)[(*pArgc) - 1] = arg;
+        }
+    }
+}
+
diff --git a/programs/winewtsn/winewtsn.c b/programs/winewtsn/winewtsn.c
new file mode 100644
index 0000000..aa15f6b
--- /dev/null
+++ b/programs/winewtsn/winewtsn.c
@@ -0,0 +1,171 @@
+/*
+ * A program to inform the user about a crash
+ *
+ * Copyright 2008 Mikolaj Zalewski
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define WIN32_LEAN_AND_MEAN
+
+#include <windows.h>
+#include "resource.h"
+#include "winewtsn.h"
+
+#include <wine/debug.h>
+#include <wine/unicode.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(winewtsn);
+
+/* filled by process_arguments */
+static DWORD g_TargetProcessId = 0;
+static HANDLE g_hTargetProcess = NULL;
+static HANDLE g_hEvent = NULL;
+
+BOOL process_arguments(int argc, LPWSTR *argv)
+{
+    /* the process id and optionally the event handle */
+    if (argc != 2 && argc != 3)
+        return FALSE;
+
+    if (argc == 3)
+    {
+        g_hEvent = (HANDLE)atolW(argv[2]);
+        if (g_hEvent == NULL)
+            return 0;
+    }
+    else
+        g_hEvent = NULL;
+
+    g_TargetProcessId = (DWORD)atolW(argv[1]);
+    if (g_TargetProcessId == 0)
+        return FALSE;
+
+    g_hTargetProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, g_TargetProcessId);
+    if (g_hTargetProcess == NULL)
+        return FALSE;
+    return TRUE;
+}
+
+WCHAR *get_program_name(HANDLE hProcess)
+{
+    LPWSTR image_name;
+    WCHAR *programname;
+
+    image_name = get_process_image_name(hProcess);
+    if (image_name == NULL)
+    {
+        static WCHAR unidentified[MAX_PROGRAM_NAME_LENGTH];
+        LoadStringW(GetModuleHandleW(NULL), IDS_UNIDENTIFIED,
+                unidentified, MAX_PROGRAM_NAME_LENGTH);
+        return unidentified;
+    }
+
+    programname = strrchrW(image_name, '\\');
+    if (programname != NULL)
+        programname++;
+    else
+        programname = image_name;
+    /* don't display a too long string to the user */
+    if (strlenW(programname) > MAX_PROGRAM_NAME_LENGTH)
+    {
+        programname[MAX_PROGRAM_NAME_LENGTH - 4] = '.';
+        programname[MAX_PROGRAM_NAME_LENGTH - 3] = '.';
+        programname[MAX_PROGRAM_NAME_LENGTH - 2] = '.';
+        programname[MAX_PROGRAM_NAME_LENGTH - 1] = 0;
+    }
+
+    /* TODO: if the image has a VERSIONINFO, we could try to find there a more
+     * user-friendly program name */
+
+    /* we waist some memory for the full path and UNICODE_STRING header, but
+     * that's OK, as this function is called only once */
+    return programname;
+}
+
+void start_winedbg(DWORD process_id, HANDLE hEventId, BOOL interactive)
+{
+    const WCHAR WSZ_AUTO[] = {'-','-','a','u','t','o',' ',0};
+    const WCHAR WSZ_EMPTY[] = {0};
+    WCHAR command[MAX_PATH];
+    WCHAR full_command[MAX_PATH];
+    STARTUPINFOW startup;
+    PROCESS_INFORMATION info;
+    DWORD flags;
+
+    if (hEventId != NULL)
+    {
+        const WCHAR format[] = {'w','i','n','e','d','b','g',' ',
+                '%','s','%','l','d',' ','%','l','d',0};
+        wsprintfW(command, format, interactive ? WSZ_EMPTY : WSZ_AUTO, process_id, hEventId);
+    } else {
+        const WCHAR format[] = {'w','i','n','e','d','b','g',' ','%','s','%','l','d',0};
+        wsprintfW(command, format, interactive ? WSZ_EMPTY : WSZ_AUTO, process_id);
+    }
+
+    if (GetSystemDirectoryW(full_command, MAX_PATH - lstrlenW(command) - 1))
+    {
+        const WCHAR SZ_BACKSLASH[] = {'\\', 0};
+        if (full_command[lstrlenW(full_command) - 1] != '\\')
+            strcatW(full_command, SZ_BACKSLASH);
+        strcatW(full_command, command);
+    }
+    else
+        strcpyW(full_command, command);
+
+    flags = interactive ? CREATE_NEW_CONSOLE : 0;
+    ZeroMemory(&startup, sizeof(startup));
+    startup.cb = sizeof(startup);
+    if (!CreateProcessW(NULL, full_command, NULL, NULL, TRUE, flags, NULL, NULL, &startup, &info))
+    {
+        WINE_FIXME("Couldn't start winedbg to generate the dump - error %u\n", GetLastError());
+        return;
+    }
+
+    CloseHandle(info.hThread);
+
+    /* if we exit before winedbg attaches itself to the target process, it may die */
+    WaitForSingleObject(info.hProcess, INFINITE);
+    CloseHandle(info.hProcess);
+}
+
+int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)
+{
+    int argc;
+    LPWSTR *argv;
+    INT_PTR dlg_result;
+
+    parse_command_line(GetCommandLineW(), &argc, &argv);
+    if (argc < 2)
+    {
+        MessageBoxResId(NULL, IDS_INTERNAL_PROGRAM, IDS_WINEWTSN, MB_OK);
+        return 0;
+    }
+
+    if (!process_arguments(argc, argv))
+    {
+        MessageBoxResId(NULL, IDS_INVALID_PARAMS, IDS_WINEWTSN, MB_OK|MB_ICONWARNING);
+        return 1;
+    }
+
+    g_ProgramName = get_program_name(g_hTargetProcess);
+    CloseHandle(g_hTargetProcess);
+    g_hTargetProcess = NULL;
+
+    dlg_result = display_crash_dialog();
+
+    start_winedbg(g_TargetProcessId, g_hEvent, dlg_result == ID_DEBUG);
+    return 0;
+}
diff --git a/programs/winewtsn/winewtsn.h b/programs/winewtsn/winewtsn.h
new file mode 100644
index 0000000..57fba68
--- /dev/null
+++ b/programs/winewtsn/winewtsn.h
@@ -0,0 +1,38 @@
+/*
+ * A program to inform the user about a crash
+ *
+ * Copyright 2008 Mikolaj Zalewski
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef WINEWTSN_H_
+#define WINEWTSN_H_
+
+/* maximum length of g_ProgramName */
+#define MAX_PROGRAM_NAME_LENGTH 80
+
+/* program name to show to the user */
+LPWSTR g_ProgramName;
+
+/* implemented in crashdlg.c */
+INT_PTR display_crash_dialog();
+
+/* implemented in util.c */
+int MessageBoxResId(HWND hwnd, UINT textId, UINT captionId, UINT uType);
+void parse_command_line(LPCWSTR cmdline, int *pArgc, LPWSTR **pArgv);
+LPWSTR get_process_image_name(HANDLE hProcess);
+
+#endif /* WINEWTSN_H_ */
diff --git a/tools/wine.inf.in b/tools/wine.inf.in
index 4756d7d..44696cc 100644
--- a/tools/wine.inf.in
+++ b/tools/wine.inf.in
@@ -214,7 +214,7 @@ HKLM,%CurrentVersionNT%\Fonts,,,""
 HKLM,%CurrentVersionNT%\Q246009,"Installed",,"1"
 
 [Debugger]
-HKLM,%CurrentVersionNT%\AeDebug,"Debugger",2,"winedbg --auto %ld %ld"
+HKLM,%CurrentVersionNT%\AeDebug,"Debugger",2,"winewtsn %ld %ld"
 HKLM,%CurrentVersionNT%\AeDebug,"Auto",2,"1"
 HKCU,Software\Wine\Debug,"RelayExclude",2,"ntdll.RtlEnterCriticalSection;ntdll.RtlLeaveCriticalSection;kernel32.94;kernel32.95;kernel32.96;kernel32.97;kernel32.98"
 HKCU,Software\Wine\Debug,"RelayFromExclude",2,"winex11.drv;user32;gdi32;advapi32;kernel32"
-- 
1.4.4.2


--------------070201040107060603070503--



More information about the wine-patches mailing list