X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/2e85c969d67eb14a07314802d4ac5dd63eef660b..34292b1daab0fcd6ce02627497117d01aaa39a19:/windows/winpgen.c diff --git a/windows/winpgen.c b/windows/winpgen.c index baaf3d98..d767b233 100644 --- a/windows/winpgen.c +++ b/windows/winpgen.c @@ -17,7 +17,7 @@ #define ICON_BIG 1 #endif -#define WM_DONEKEY (WM_XUSER + 1) +#define WM_DONEKEY (WM_APP + 1) #define DEFAULT_KEYSIZE 1024 @@ -801,8 +801,9 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, switch (msg) { case WM_INITDIALOG: if (help_path) - SetWindowLong(hwnd, GWL_EXSTYLE, - GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP); + SetWindowLongPtr(hwnd, GWL_EXSTYLE, + GetWindowLongPtr(hwnd, GWL_EXSTYLE) | + WS_EX_CONTEXTHELP); else { /* * If we add a Help button, this is where we destroy it @@ -818,7 +819,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, state->collecting_entropy = FALSE; state->entropy = NULL; state->key_exists = FALSE; - SetWindowLong(hwnd, GWL_USERDATA, (LONG) state); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) state); { HMENU menu, menu1; @@ -943,7 +944,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, return 1; case WM_MOUSEMOVE: - state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); + state = (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA); if (state->collecting_entropy && state->entropy && state->entropy_got < state->entropy_required) { state->entropy[state->entropy_got++] = lParam; @@ -994,7 +995,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, case IDC_KEYSSH2DSA: { state = (struct MainDlgState *) - GetWindowLong(hwnd, GWL_USERDATA); + GetWindowLongPtr(hwnd, GWLP_USERDATA); if (!IsDlgButtonChecked(hwnd, LOWORD(wParam))) CheckRadioButton(hwnd, IDC_KEYSSH1, IDC_KEYSSH2DSA, LOWORD(wParam)); @@ -1008,7 +1009,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, case IDC_COMMENTEDIT: if (HIWORD(wParam) == EN_CHANGE) { state = (struct MainDlgState *) - GetWindowLong(hwnd, GWL_USERDATA); + GetWindowLongPtr(hwnd, GWLP_USERDATA); if (state->key_exists) { HWND editctl = GetDlgItem(hwnd, IDC_COMMENTEDIT); int len = GetWindowTextLength(editctl); @@ -1047,7 +1048,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, HIWORD(wParam) != BN_DOUBLECLICKED) break; state = - (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); + (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA); if (!state->generation_thread_exists) { BOOL ok; state->keysize = GetDlgItemInt(hwnd, IDC_BITS, &ok, FALSE); @@ -1103,7 +1104,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, if (HIWORD(wParam) != BN_CLICKED) break; state = - (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); + (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA); if (state->key_exists) { char filename[FILENAME_MAX]; char passphrase[PASSPHRASE_MAXLEN]; @@ -1198,7 +1199,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, if (HIWORD(wParam) != BN_CLICKED) break; state = - (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); + (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA); if (state->key_exists) { char filename[FILENAME_MAX]; if (prompt_keyfile(hwnd, "Save public key as:", @@ -1233,7 +1234,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, if (HIWORD(wParam) != BN_CLICKED) break; state = - (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); + (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA); if (!state->generation_thread_exists) { char filename[FILENAME_MAX]; if (prompt_keyfile(hwnd, "Load private key:", @@ -1245,7 +1246,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, } return 0; case WM_DONEKEY: - state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); + state = (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA); state->generation_thread_exists = FALSE; state->key_exists = TRUE; SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0, @@ -1385,7 +1386,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, } break; case WM_CLOSE: - state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); + state = (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA); sfree(state); if (requested_help) { WinHelp(hwnd, help_path, HELP_QUIT, 0); @@ -1404,16 +1405,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) int argc; char **argv; - split_into_argv(cmdline, &argc, &argv, NULL); - - if (argc > 0) { - /* - * Assume the first argument to be a private key file, and - * attempt to load it. - */ - cmdline_keyfile = argv[0]; - } - InitCommonControls(); hinst = inst; hwnd = NULL; @@ -1438,6 +1429,21 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) help_path = NULL; } + split_into_argv(cmdline, &argc, &argv, NULL); + + if (argc > 0) { + if (!strcmp(argv[0], "-pgpfp")) { + pgp_fingerprints(); + exit(1); + } else { + /* + * Assume the first argument to be a private key file, and + * attempt to load it. + */ + cmdline_keyfile = argv[0]; + } + } + random_ref(); return DialogBox(hinst, MAKEINTRESOURCE(201), NULL, MainDlgProc) != IDOK;