From 157709d7a294e30182d0dfe2758df18e490a7457 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Sat, 24 Jan 2009 16:41:04 -0800 Subject: [PATCH] cryptui: Export all selected certificates when requested from the certificate manager, not just the first one. --- dlls/cryptui/main.c | 84 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/dlls/cryptui/main.c b/dlls/cryptui/main.c index 5c070148f8a..498c158f9bf 100644 --- a/dlls/cryptui/main.c +++ b/dlls/cryptui/main.c @@ -1001,6 +1001,67 @@ static void cert_mgr_do_remove(HWND hwnd) } } +static void cert_mgr_do_export(HWND hwnd) +{ + HWND lv = GetDlgItem(hwnd, IDC_MGR_CERTS); + int selectionCount = SendMessageW(lv, LVM_GETSELECTEDCOUNT, 0, 0); + + if (selectionCount == 1) + { + int selection = SendMessageW(lv, LVM_GETNEXTITEM, -1, + LVNI_SELECTED); + + if (selection >= 0) + { + PCCERT_CONTEXT cert = cert_mgr_index_to_cert(hwnd, selection); + + if (cert) + { + CRYPTUI_WIZ_EXPORT_INFO info; + + info.dwSize = sizeof(info); + info.pwszExportFileName = NULL; + info.dwSubjectChoice = CRYPTUI_WIZ_EXPORT_CERT_CONTEXT; + info.u.pCertContext = cert; + info.cStores = 0; + CryptUIWizExport(0, hwnd, NULL, &info, NULL); + } + } + } + else if (selectionCount > 1) + { + HCERTSTORE store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, + CERT_STORE_CREATE_NEW_FLAG, NULL); + + if (store) + { + CRYPTUI_WIZ_EXPORT_INFO info; + int selection = -1; + + info.dwSize = sizeof(info); + info.pwszExportFileName = NULL; + info.dwSubjectChoice = + CRYPTUI_WIZ_EXPORT_CERT_STORE_CERTIFICATES_ONLY; + info.u.hCertStore = store; + info.cStores = 0; + do { + selection = SendMessageW(lv, LVM_GETNEXTITEM, selection, + LVNI_SELECTED); + if (selection >= 0) + { + PCCERT_CONTEXT cert = cert_mgr_index_to_cert(hwnd, + selection); + + CertAddCertificateContextToStore(store, cert, + CERT_STORE_ADD_ALWAYS, NULL); + } + } while (selection >= 0); + CryptUIWizExport(0, hwnd, NULL, &info, NULL); + CertCloseStore(store, 0); + } + } +} + static LRESULT CALLBACK cert_mgr_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { @@ -1135,29 +1196,8 @@ static LRESULT CALLBACK cert_mgr_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, break; } case IDC_MGR_EXPORT: - { - HWND lv = GetDlgItem(hwnd, IDC_MGR_CERTS); - int selection = SendMessageW(lv, LVM_GETNEXTITEM, -1, - LVNI_SELECTED); - - if (selection >= 0) - { - PCCERT_CONTEXT cert = cert_mgr_index_to_cert(hwnd, selection); - - if (cert) - { - CRYPTUI_WIZ_EXPORT_INFO info; - - info.dwSize = sizeof(info); - info.pwszExportFileName = NULL; - info.dwSubjectChoice = CRYPTUI_WIZ_EXPORT_CERT_CONTEXT; - info.u.pCertContext = cert; - info.cStores = 0; - CryptUIWizExport(0, hwnd, NULL, &info, NULL); - } - } + cert_mgr_do_export(hwnd); break; - } case IDC_MGR_REMOVE: cert_mgr_do_remove(hwnd); break; -- 2.11.4.GIT