diff --git a/windows/dialog.c b/windows/dialog.c index f65c8a61..f2c309b8 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -853,14 +853,13 @@ struct hostkey_dialog_ctx { const char *helpctx; }; -static INT_PTR CALLBACK HostKeyMoreInfoProc(HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam) +static INT_PTR HostKeyMoreInfoProc(HWND hwnd, UINT msg, WPARAM wParam, + LPARAM lParam, void *vctx) { + struct hostkey_dialog_ctx *ctx = (struct hostkey_dialog_ctx *)vctx; + switch (msg) { case WM_INITDIALOG: { - const struct hostkey_dialog_ctx *ctx = - (const struct hostkey_dialog_ctx *)lParam; - SetWindowLongPtr(hwnd, GWLP_USERDATA, (INT_PTR)ctx); if (ctx->fingerprints[SSH_FPTYPE_SHA256]) SetDlgItemText(hwnd, IDC_HKI_SHA256, @@ -876,26 +875,25 @@ static INT_PTR CALLBACK HostKeyMoreInfoProc(HWND hwnd, UINT msg, case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: - EndDialog(hwnd, 0); + ShinyEndDialog(hwnd, 0); return 0; } return 0; case WM_CLOSE: - EndDialog(hwnd, 0); + ShinyEndDialog(hwnd, 0); return 0; } return 0; } -static INT_PTR CALLBACK HostKeyDialogProc(HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam) +static INT_PTR HostKeyDialogProc(HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam, void *vctx) { + struct hostkey_dialog_ctx *ctx = (struct hostkey_dialog_ctx *)vctx; + switch (msg) { case WM_INITDIALOG: { strbuf *sb = strbuf_new(); - const struct hostkey_dialog_ctx *ctx = - (const struct hostkey_dialog_ctx *)lParam; - SetWindowLongPtr(hwnd, GWLP_USERDATA, (INT_PTR)ctx); for (int id = 100;; id++) { char buf[256]; @@ -970,26 +968,21 @@ static INT_PTR CALLBACK HostKeyDialogProc(HWND hwnd, UINT msg, case IDC_HK_ACCEPT: case IDC_HK_ONCE: case IDCANCEL: - EndDialog(hwnd, LOWORD(wParam)); + ShinyEndDialog(hwnd, LOWORD(wParam)); return 0; case IDHELP: { - const struct hostkey_dialog_ctx *ctx = - (const struct hostkey_dialog_ctx *) - GetWindowLongPtr(hwnd, GWLP_USERDATA); launch_help(hwnd, ctx->helpctx); return 0; } case IDC_HK_MOREINFO: { - const struct hostkey_dialog_ctx *ctx = - (const struct hostkey_dialog_ctx *) - GetWindowLongPtr(hwnd, GWLP_USERDATA); - DialogBoxParam(hinst, MAKEINTRESOURCE(IDD_HK_MOREINFO), - hwnd, HostKeyMoreInfoProc, (LPARAM)ctx); + ShinyDialogBox(hinst, MAKEINTRESOURCE(IDD_HK_MOREINFO), + "PuTTYHostKeyMoreInfo", hwnd, + HostKeyMoreInfoProc, ctx); } } return 0; case WM_CLOSE: - EndDialog(hwnd, IDCANCEL); + ShinyEndDialog(hwnd, IDCANCEL); return 0; } return 0; @@ -1021,9 +1014,9 @@ SeatPromptResult win_seat_confirm_ssh_host_key( ctx->host = host; ctx->port = port; int dlgid = (mismatch ? IDD_HK_WRONG : IDD_HK_ABSENT); - int mbret = DialogBoxParam( - hinst, MAKEINTRESOURCE(dlgid), wgs->term_hwnd, - HostKeyDialogProc, (LPARAM)ctx); + int mbret = ShinyDialogBox( + hinst, MAKEINTRESOURCE(dlgid), "PuTTYHostKeyDialog", + wgs->term_hwnd, HostKeyDialogProc, ctx); assert(mbret==IDC_HK_ACCEPT || mbret==IDC_HK_ONCE || mbret==IDCANCEL); if (mbret == IDC_HK_ACCEPT) { store_host_key(host, port, keytype, keystr); diff --git a/windows/putty-common.rc2 b/windows/putty-common.rc2 index 955a1cb3..b6ccb3d8 100644 --- a/windows/putty-common.rc2 +++ b/windows/putty-common.rc2 @@ -61,6 +61,7 @@ IDD_HK_ABSENT DIALOG DISCARDABLE 50, 50, 340, 160 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "PuTTY Security Alert" FONT 8, "MS Shell Dlg" +CLASS "PuTTYHostKeyDialog" BEGIN LTEXT "The host key is not cached for this server:", 100, 40, 20, 300, 8 LTEXT "You have no guarantee that the server is the computer you think it is.", 101, 40, 40, 300, 8 @@ -120,6 +121,7 @@ IDD_HK_MOREINFO DIALOG DISCARDABLE 140, 40, 400, 156 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "PuTTY: information about the server's host key" FONT 8, "MS Shell Dlg" +CLASS "PuTTYHostKeyMoreInfo" BEGIN LTEXT "SHA256 fingerprint:", 100, 12, 12, 80, 8 EDITTEXT IDC_HKI_SHA256, 100, 10, 288, 12, ES_READONLY