diff --git a/dlls/cryptui/cryptui_En.rc b/dlls/cryptui/cryptui_En.rc index c970c58cbf3..91164b65273 100644 --- a/dlls/cryptui/cryptui_En.rc +++ b/dlls/cryptui/cryptui_En.rc @@ -147,6 +147,12 @@ STRINGTABLE DISCARDABLE IDS_EXPORT_FILE_TITLE "Export Filename" IDS_EXPORT_FILE_SUBTITLE "Specify the name of the file in which the content will be saved." IDS_EXPORT_FILE_EXISTS "The specified file already exists. Do you want to replace it?" + IDS_EXPORT_FILTER_CERT "DER-Encoded Binary X.509 (*.cer)" + IDS_EXPORT_FILTER_BASE64_CERT "Base64-Encoded X.509 (*.cer)" + IDS_EXPORT_FILTER_CRL "Certificate Revocation List (*.crl)" + IDS_EXPORT_FILTER_CTL "Certificate Trust List (*.stl)" + IDS_EXPORT_FILTER_CMS "CMS/PKCS #7 Messages (*.p7b)" + IDS_EXPORT_FILTER_PFX "Personal Information Exchange (*.pfx)" } IDD_GENERAL DIALOG DISCARDABLE 0, 0, 255, 236 diff --git a/dlls/cryptui/cryptuires.h b/dlls/cryptui/cryptuires.h index ee6f5a129d9..7384314f97a 100644 --- a/dlls/cryptui/cryptuires.h +++ b/dlls/cryptui/cryptuires.h @@ -146,6 +146,12 @@ #define IDS_EXPORT_FILE_TITLE 1203 #define IDS_EXPORT_FILE_SUBTITLE 1204 #define IDS_EXPORT_FILE_EXISTS 1205 +#define IDS_EXPORT_FILTER_CERT 1206 +#define IDS_EXPORT_FILTER_BASE64_CERT 1207 +#define IDS_EXPORT_FILTER_CRL 1208 +#define IDS_EXPORT_FILTER_CTL 1209 +#define IDS_EXPORT_FILTER_CMS 1210 +#define IDS_EXPORT_FILTER_PFX 1211 #define IDD_GENERAL 100 #define IDD_DETAIL 101 diff --git a/dlls/cryptui/main.c b/dlls/cryptui/main.c index adeb58a4383..f7b93041804 100644 --- a/dlls/cryptui/main.c +++ b/dlls/cryptui/main.c @@ -5718,6 +5718,74 @@ static BOOL export_validate_filename(HWND hwnd, struct ExportWizData *data, return ret; } +static const WCHAR export_filter_cert[] = { '*','.','c','e','r',0 }; +static const WCHAR export_filter_crl[] = { '*','.','c','r','l',0 }; +static const WCHAR export_filter_ctl[] = { '*','.','s','t','l',0 }; +static const WCHAR export_filter_cms[] = { '*','.','p','7','b',0 }; +static const WCHAR export_filter_pfx[] = { '*','.','p','f','x',0 }; + +static WCHAR *make_export_file_filter(DWORD exportFormat, DWORD subjectChoice) +{ + int baseLen, allLen, totalLen = 2, baseID; + LPWSTR filter = NULL, baseFilter, all; + LPCWSTR filterStr; + + switch (exportFormat) + { + case CRYPTUI_WIZ_EXPORT_FORMAT_BASE64: + baseID = IDS_EXPORT_FILTER_BASE64_CERT; + filterStr = export_filter_cert; + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_PFX: + baseID = IDS_EXPORT_FILTER_PFX; + filterStr = export_filter_pfx; + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7: + baseID = IDS_EXPORT_FILTER_CMS; + filterStr = export_filter_cms; + break; + default: + switch (subjectChoice) + { + case CRYPTUI_WIZ_EXPORT_CRL_CONTEXT: + baseID = IDS_EXPORT_FILTER_CRL; + filterStr = export_filter_crl; + break; + case CRYPTUI_WIZ_EXPORT_CTL_CONTEXT: + baseID = IDS_EXPORT_FILTER_CTL; + filterStr = export_filter_ctl; + break; + default: + baseID = IDS_EXPORT_FILTER_CERT; + filterStr = export_filter_cert; + break; + } + } + baseLen = LoadStringW(hInstance, baseID, (LPWSTR)&baseFilter, 0); + totalLen += baseLen + strlenW(filterStr) + 2; + allLen = LoadStringW(hInstance, IDS_IMPORT_FILTER_ALL, (LPWSTR)&all, 0); + totalLen += allLen + strlenW(filter_all) + 2; + filter = HeapAlloc(GetProcessHeap(), 0, totalLen * sizeof(WCHAR)); + if (filter) + { + LPWSTR ptr; + + ptr = filter; + memcpy(ptr, baseFilter, baseLen * sizeof(WCHAR)); + ptr += baseLen; + *ptr++ = 0; + strcpyW(ptr, filterStr); + ptr += strlenW(filterStr) + 1; + memcpy(ptr, all, allLen * sizeof(WCHAR)); + ptr += allLen; + *ptr++ = 0; + strcpyW(ptr, filter_all); + ptr += strlenW(filter_all) + 1; + *ptr++ = 0; + } + return filter; +} + static LRESULT CALLBACK export_file_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { @@ -5808,6 +5876,31 @@ static LRESULT CALLBACK export_file_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, } break; } + case WM_COMMAND: + switch (wp) + { + case IDC_EXPORT_BROWSE_FILE: + { + OPENFILENAMEW ofn; + WCHAR fileBuf[MAX_PATH]; + + data = (struct ExportWizData *)GetWindowLongPtrW(hwnd, DWLP_USER); + memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = make_export_file_filter(data->exportFormat, + data->pExportInfo->dwSubjectChoice); + ofn.lpstrFile = fileBuf; + ofn.nMaxFile = sizeof(fileBuf) / sizeof(fileBuf[0]); + fileBuf[0] = 0; + if (GetSaveFileNameW(&ofn)) + SendMessageW(GetDlgItem(hwnd, IDC_EXPORT_FILENAME), WM_SETTEXT, + 0, (LPARAM)ofn.lpstrFile); + HeapFree(GetProcessHeap(), 0, (LPWSTR)ofn.lpstrFilter); + break; + } + } + break; } return ret; }