From 137f75328be1ab33ffd1585c9b48580926519cd6 Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Wed, 13 Apr 2011 05:33:47 +0200 Subject: [PATCH] inetcpl: Add a security propsheet. --- dlls/inetcpl.cpl/Makefile.in | 5 +- dlls/inetcpl.cpl/cpl_En.rc | 12 +++ dlls/inetcpl.cpl/inetcpl.c | 18 ++++ dlls/inetcpl.cpl/inetcpl.h | 25 +++++- dlls/inetcpl.cpl/security.c | 195 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 252 insertions(+), 3 deletions(-) create mode 100644 dlls/inetcpl.cpl/security.c diff --git a/dlls/inetcpl.cpl/Makefile.in b/dlls/inetcpl.cpl/Makefile.in index 8046dc77ab4..98a19301da6 100644 --- a/dlls/inetcpl.cpl/Makefile.in +++ b/dlls/inetcpl.cpl/Makefile.in @@ -1,11 +1,12 @@ MODULE = inetcpl.cpl IMPORTS = comctl32 shlwapi user32 advapi32 -DELAYIMPORTS = cryptui wininet +DELAYIMPORTS = cryptui wininet ole32 urlmon C_SRCS = \ content.c \ general.c \ - inetcpl.c + inetcpl.c \ + security.c RC_SRCS = \ cpl_De.rc \ diff --git a/dlls/inetcpl.cpl/cpl_En.rc b/dlls/inetcpl.cpl/cpl_En.rc index f8459b49655..cd7f5f52c49 100644 --- a/dlls/inetcpl.cpl/cpl_En.rc +++ b/dlls/inetcpl.cpl/cpl_En.rc @@ -67,6 +67,18 @@ BEGIN END +/* "Security" propsheet */ +IDD_SECURITY DIALOG 0, 0, 320, 220 +STYLE WS_CAPTION | WS_CHILD | WS_DISABLED +FONT 8, "MS Shell Dlg" +CAPTION "Security" +BEGIN + + CONTROL "Listview", IDC_SEC_LISTVIEW, "SysListView32", + LVS_ICON | LVS_ALIGNLEFT | LVS_AUTOARRANGE | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_BORDER | WS_VSCROLL, + 4, 4, 312, 58 +END + /* "Content" propsheet */ IDD_CONTENT DIALOG 0, 0, 320, 220 STYLE WS_CAPTION | WS_CHILD | WS_DISABLED diff --git a/dlls/inetcpl.cpl/inetcpl.c b/dlls/inetcpl.cpl/inetcpl.c index 49cd8920c71..019a0af321e 100644 --- a/dlls/inetcpl.cpl/inetcpl.c +++ b/dlls/inetcpl.cpl/inetcpl.c @@ -20,6 +20,8 @@ */ #define NONAMELESSUNION +#define COBJMACROS +#define CONST_VTABLE #include #include @@ -28,6 +30,7 @@ #include #include #include +#include "ole2.h" #include "wine/debug.h" @@ -82,10 +85,17 @@ static int CALLBACK propsheet_callback(HWND hwnd, UINT msg, LPARAM lparam) */ static void display_cpl_sheets(HWND parent) { + INITCOMMONCONTROLSEX icex; PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES]; PROPSHEETHEADERW psh; DWORD id = 0; + OleInitialize(NULL); + /* Initialize common controls */ + icex.dwSize = sizeof(INITCOMMONCONTROLSEX); + icex.dwICC = ICC_LISTVIEW_CLASSES | ICC_BAR_CLASSES; + InitCommonControlsEx(&icex); + ZeroMemory(&psh, sizeof(psh)); ZeroMemory(psp, sizeof(psp)); @@ -98,6 +108,12 @@ static void display_cpl_sheets(HWND parent) psp[id].dwSize = sizeof (PROPSHEETPAGEW); psp[id].hInstance = hcpl; + psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_SECURITY); + psp[id].pfnDlgProc = security_dlgproc; + id++; + + psp[id].dwSize = sizeof (PROPSHEETPAGEW); + psp[id].hInstance = hcpl; psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_CONTENT); psp[id].pfnDlgProc = content_dlgproc; id++; @@ -115,6 +131,8 @@ static void display_cpl_sheets(HWND parent) /* display the dialog */ PropertySheetW(&psh); + + OleUninitialize(); } /********************************************************************* diff --git a/dlls/inetcpl.cpl/inetcpl.h b/dlls/inetcpl.cpl/inetcpl.h index 45b1ba40055..1797b4994e8 100644 --- a/dlls/inetcpl.cpl/inetcpl.h +++ b/dlls/inetcpl.cpl/inetcpl.h @@ -24,11 +24,31 @@ #include #include - +#include extern HMODULE hcpl; INT_PTR CALLBACK content_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN; INT_PTR CALLBACK general_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN; +INT_PTR CALLBACK security_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN; + +/* ## Memory allocation functions ## */ + +static inline void * __WINE_ALLOC_SIZE(1) heap_alloc( size_t len ) +{ + return HeapAlloc( GetProcessHeap(), 0, len ); +} + +static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero( size_t len ) +{ + return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len ); +} + +static inline BOOL heap_free( void *mem ) +{ + return HeapFree( GetProcessHeap(), 0, mem ); +} + +/* ######### */ #define NUM_PROPERTY_PAGES 8 @@ -57,6 +77,9 @@ INT_PTR CALLBACK general_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN; #define IDC_DELETE_FORM_DATA 1014 #define IDC_DELETE_PASSWORDS 1015 +#define IDD_SECURITY 2000 +#define IDC_SEC_LISTVIEW 2001 + #define IDD_CONTENT 4000 #define IDC_CERT 4100 #define IDC_CERT_PUBLISHER 4101 diff --git a/dlls/inetcpl.cpl/security.c b/dlls/inetcpl.cpl/security.c new file mode 100644 index 00000000000..e853dd0e30c --- /dev/null +++ b/dlls/inetcpl.cpl/security.c @@ -0,0 +1,195 @@ +/* + * Internet control panel applet: security propsheet + * + * Copyright 2011 Detlef Riekenberg + * + * 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 COBJMACROS +#define CONST_VTABLE +#define NONAMELESSUNION + +#include +#include +#include +#include +#include +#include "commctrl.h" + +#include "ole2.h" +#include "urlmon.h" +#include "initguid.h" +#include "winreg.h" +#include "shlwapi.h" + +#include "inetcpl.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(inetcpl); + +typedef struct secdlg_data_s { + HWND hsec; /* security propsheet */ + HWND hlv; /* listview */ + IInternetSecurityManager *sec_mgr; + IInternetZoneManager *zone_mgr; + DWORD zone_enumerator; + DWORD num_zones; +} secdlg_data; + +/********************************************************************* + * security_cleanup_zones [internal] + * + */ +static void security_cleanup_zones(secdlg_data *sd) +{ + if (sd->zone_enumerator) { + IInternetZoneManager_DestroyZoneEnumerator(sd->zone_mgr, sd->zone_enumerator); + } + + if (sd->zone_mgr) { + IInternetZoneManager_Release(sd->zone_mgr); + } + + if (sd->sec_mgr) { + IInternetSecurityManager_Release(sd->sec_mgr); + } +} + +/********************************************************************* + * security_enum_zones [internal] + * + */ +static HRESULT security_enum_zones(secdlg_data * sd) +{ + HRESULT hr; + + hr = CoInternetCreateSecurityManager(NULL, &sd->sec_mgr, 0); + if (SUCCEEDED(hr)) { + hr = CoInternetCreateZoneManager(NULL, &sd->zone_mgr, 0); + if (SUCCEEDED(hr)) { + hr = IInternetZoneManager_CreateZoneEnumerator(sd->zone_mgr, &sd->zone_enumerator, &sd->num_zones, 0); + } + } + return hr; +} + +/********************************************************************* + * security_on_destroy [internal] + * + * handle WM_NCDESTROY + * + */ +static INT_PTR security_on_destroy(secdlg_data * sd) +{ + TRACE("(%p)\n", sd); + + security_cleanup_zones(sd); + SetWindowLongPtrW(sd->hsec, DWLP_USER, 0); + heap_free(sd); + return TRUE; +} + +/********************************************************************* + * security_on_initdialog [internal] + * + * handle WM_INITDIALOG + * + */ +static INT_PTR security_on_initdialog(HWND hsec) +{ + secdlg_data *sd; + HRESULT hr; + + sd = heap_alloc_zero(sizeof(secdlg_data)); + SetWindowLongPtrW(hsec, DWLP_USER, (LONG_PTR) sd); + if (!sd) { + return FALSE; + } + + sd->hsec = hsec; + sd->hlv = GetDlgItem(hsec, IDC_SEC_LISTVIEW); + + hr = security_enum_zones(sd); + if (FAILED(hr)) { + ERR("got 0x%x\n", hr); + security_on_destroy(sd); + return FALSE; + } + + TRACE("found %d zones\n", sd->num_zones); + return TRUE; +} + +/********************************************************************* + * security_on_notify [internal] + * + * handle WM_NOTIFY + * + */ +static INT_PTR security_on_notify(WPARAM wparam, LPARAM lparam) +{ + NMLISTVIEW *nm; + + nm = (NMLISTVIEW *) lparam; + switch (nm->hdr.code) + { + case PSN_APPLY: + TRACE("PSN_APPLY (0x%lx, 0x%lx) from %p with code: %d\n", wparam, lparam, + nm->hdr.hwndFrom, nm->hdr.code); + break; + + default: + TRACE("WM_NOTIFY (0x%lx, 0x%lx) from %p with code: %d\n", wparam, lparam, + nm->hdr.hwndFrom, nm->hdr.code); + + } + return FALSE; +} + +/********************************************************************* + * security_dlgproc [internal] + * + */ +INT_PTR CALLBACK security_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + secdlg_data *sd; + + if (msg == WM_INITDIALOG) { + return security_on_initdialog(hwnd); + } + + sd = (secdlg_data *)GetWindowLongPtrW(hwnd, DWLP_USER); + if (sd) { + switch (msg) + { + case WM_NOTIFY: + return security_on_notify(wparam, lparam); + + case WM_NCDESTROY: + return security_on_destroy(sd); + + default: + /* do not flood the log */ + if ((msg == WM_SETCURSOR) || (msg == WM_NCHITTEST) || + (msg == WM_MOUSEMOVE) || (msg == WM_MOUSEACTIVATE) || (msg == WM_PARENTNOTIFY)) + return FALSE; + + TRACE("(%p, 0x%08x/%03d, 0x%08lx, 0x%08lx)\n", hwnd, msg, msg, wparam, lparam); + } + } + return FALSE; +} -- 2.11.4.GIT