shell32: Avoid an unsafe iface to object cast in AddToEnumList().

This commit is contained in:
Michael Stefaniuc 2011-10-10 01:04:37 +02:00 committed by Alexandre Julliard
parent bd407b700e
commit 28d8819b63
7 changed files with 25 additions and 31 deletions

View File

@ -286,7 +286,7 @@ static PIDLCPanelStruct* _ILGetCPanelPointer(LPCITEMIDLIST pidl)
/**************************************************************************
* ISF_ControlPanel_fnEnumObjects
*/
static BOOL SHELL_RegisterCPanelApp(IEnumIDList* list, LPCSTR path)
static BOOL SHELL_RegisterCPanelApp(IEnumIDListImpl *list, LPCSTR path)
{
LPITEMIDLIST pidl;
CPlApplet* applet;
@ -329,7 +329,7 @@ static BOOL SHELL_RegisterCPanelApp(IEnumIDList* list, LPCSTR path)
return TRUE;
}
static int SHELL_RegisterRegistryCPanelApps(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath)
static int SHELL_RegisterRegistryCPanelApps(IEnumIDListImpl *list, HKEY hkey_root, LPCSTR szRepPath)
{
char name[MAX_PATH];
char value[MAX_PATH];
@ -358,7 +358,7 @@ static int SHELL_RegisterRegistryCPanelApps(IEnumIDList* list, HKEY hkey_root, L
return cnt;
}
static int SHELL_RegisterCPanelFolders(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath)
static int SHELL_RegisterCPanelFolders(IEnumIDListImpl *list, HKEY hkey_root, LPCSTR szRepPath)
{
char name[MAX_PATH];
HKEY hkey;
@ -391,19 +391,18 @@ static int SHELL_RegisterCPanelFolders(IEnumIDList* list, HKEY hkey_root, LPCSTR
/**************************************************************************
* CreateCPanelEnumList()
*/
static BOOL CreateCPanelEnumList(
IEnumIDList * iface,
DWORD dwFlags)
static BOOL CreateCPanelEnumList(IEnumIDListImpl *list, DWORD dwFlags)
{
CHAR szPath[MAX_PATH];
WIN32_FIND_DATAA wfd;
HANDLE hFile;
TRACE("(%p)->(flags=0x%08x)\n", iface, dwFlags);
TRACE("(%p)->(flags=0x%08x)\n", list, dwFlags);
/* enumerate control panel folders */
if (dwFlags & SHCONTF_FOLDERS)
SHELL_RegisterCPanelFolders(iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
SHELL_RegisterCPanelFolders(list, HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
/* enumerate the control panel applets */
if (dwFlags & SHCONTF_NONFOLDERS)
@ -414,7 +413,7 @@ static BOOL CreateCPanelEnumList(
p = PathAddBackslashA(szPath);
strcpy(p, "*.cpl");
TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n",iface,debugstr_a(szPath));
TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n", list, debugstr_a(szPath));
hFile = FindFirstFileA(szPath, &wfd);
if (hFile != INVALID_HANDLE_VALUE)
@ -426,14 +425,16 @@ static BOOL CreateCPanelEnumList(
if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
strcpy(p, wfd.cFileName);
SHELL_RegisterCPanelApp(iface, szPath);
SHELL_RegisterCPanelApp(list, szPath);
}
} while(FindNextFileA(hFile, &wfd));
FindClose(hFile);
}
SHELL_RegisterRegistryCPanelApps(iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
SHELL_RegisterRegistryCPanelApps(iface, HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
SHELL_RegisterRegistryCPanelApps(list, HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
SHELL_RegisterRegistryCPanelApps(list, HKEY_CURRENT_USER,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
}
return TRUE;
}
@ -451,8 +452,8 @@ static HRESULT WINAPI ISF_ControlPanel_fnEnumObjects(IShellFolder2 *iface, HWND
if (!(list = IEnumIDList_Constructor()))
return E_OUTOFMEMORY;
CreateCPanelEnumList(list, dwFlags);
*ppEnumIDList = &list->IEnumIDList_iface;
CreateCPanelEnumList(*ppEnumIDList, dwFlags);
TRACE("--(%p)->(new ID List: %p)\n", This, *ppEnumIDList);

View File

@ -39,17 +39,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
/**************************************************************************
* AddToEnumList()
*/
BOOL AddToEnumList(
IEnumIDList * iface,
LPITEMIDLIST pidl)
BOOL AddToEnumList(IEnumIDListImpl *This, LPITEMIDLIST pidl)
{
IEnumIDListImpl *This = (IEnumIDListImpl *)iface;
struct enumlist *pNew;
TRACE("(%p)->(pidl=%p)\n",This,pidl);
if (!iface || !pidl)
if (!This || !pidl)
return FALSE;
pNew = SHAlloc(sizeof(*pNew));
@ -83,10 +79,7 @@ BOOL AddToEnumList(
/**************************************************************************
* CreateFolderEnumList()
*/
BOOL CreateFolderEnumList(
IEnumIDList *list,
LPCWSTR lpszPath,
DWORD dwFlags)
BOOL CreateFolderEnumList(IEnumIDListImpl *list, LPCWSTR lpszPath, DWORD dwFlags)
{
LPITEMIDLIST pidl=NULL;
WIN32_FIND_DATAW stffile;

View File

@ -426,7 +426,7 @@ static HRESULT WINAPI RecycleBin_EnumObjects(IShellFolder2 *iface, HWND hwnd, SH
if (FAILED(ret = TRASH_EnumItems(&pidls, &pidls_count)))
goto failed;
for (i=0; i<pidls_count; i++)
if (!AddToEnumList(&list->IEnumIDList_iface, pidls[i]))
if (!AddToEnumList(list, pidls[i]))
goto failed;
}

View File

@ -223,11 +223,11 @@ typedef struct
/* Creates an IEnumIDList; add LPITEMIDLISTs to it with AddToEnumList. */
IEnumIDListImpl *IEnumIDList_Constructor(void) DECLSPEC_HIDDEN;
BOOL AddToEnumList(IEnumIDList *list, LPITEMIDLIST pidl) DECLSPEC_HIDDEN;
BOOL AddToEnumList(IEnumIDListImpl *list, LPITEMIDLIST pidl) DECLSPEC_HIDDEN;
/* Enumerates the folders and/or files (depending on dwFlags) in lpszPath and
* adds them to the already-created list.
*/
BOOL CreateFolderEnumList(IEnumIDList *list, LPCWSTR lpszPath, DWORD dwFlags) DECLSPEC_HIDDEN;
BOOL CreateFolderEnumList(IEnumIDListImpl *list, LPCWSTR lpszPath, DWORD dwFlags) DECLSPEC_HIDDEN;
#endif

View File

@ -286,7 +286,7 @@ static const WCHAR Desktop_NameSpaceW[] = { 'S','O','F','T','W','A','R','E',
'o','r','e','r','\\','D','e','s','k','t','o','p','\\','N','a','m','e','s','p',
'a','c','e','\0' };
static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags)
static BOOL CreateDesktopEnumList(IEnumIDListImpl *list, DWORD dwFlags)
{
BOOL ret = TRUE;
WCHAR szPath[MAX_PATH];
@ -352,8 +352,8 @@ static HRESULT WINAPI ISF_Desktop_fnEnumObjects (IShellFolder2 * iface,
if (!(list = IEnumIDList_Constructor()))
return E_OUTOFMEMORY;
CreateDesktopEnumList(list, dwFlags);
*ppEnumIDList = &list->IEnumIDList_iface;
CreateDesktopEnumList(*ppEnumIDList, dwFlags);
TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);

View File

@ -455,8 +455,8 @@ IShellFolder_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner,
if (!(list = IEnumIDList_Constructor()))
return E_OUTOFMEMORY;
CreateFolderEnumList(list, This->sPathTarget, dwFlags);
*ppEnumIDList = &list->IEnumIDList_iface;
CreateFolderEnumList(*ppEnumIDList, This->sPathTarget, dwFlags);
TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);

View File

@ -292,7 +292,7 @@ static const WCHAR MyComputer_NameSpaceW[] = { 'S','O','F','T','W','A','R','E',
'o','r','e','r','\\','M','y','C','o','m','p','u','t','e','r','\\','N','a','m',
'e','s','p','a','c','e','\0' };
static BOOL CreateMyCompEnumList(IEnumIDList *list, DWORD dwFlags)
static BOOL CreateMyCompEnumList(IEnumIDListImpl *list, DWORD dwFlags)
{
BOOL ret = TRUE;
@ -362,8 +362,8 @@ static HRESULT WINAPI ISF_MyComputer_fnEnumObjects (IShellFolder2 *iface,
if (!(list = IEnumIDList_Constructor()))
return E_OUTOFMEMORY;
CreateMyCompEnumList(list, dwFlags);
*ppEnumIDList = &list->IEnumIDList_iface;
CreateMyCompEnumList(*ppEnumIDList, dwFlags);
TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);