Cleanup, small fixes, a few new stubs.

diff --git a/dlls/shell32/Makefile.in b/dlls/shell32/Makefile.in
index 6a58119..89d9095 100644
--- a/dlls/shell32/Makefile.in
+++ b/dlls/shell32/Makefile.in
@@ -11,6 +11,7 @@
 	dataobject.c \
 	enumidlist.c \
 	folders.c \
+	iconcache.c \
 	pidl.c \
 	shell32_main.c \
 	shellole.c \
diff --git a/dlls/shell32/contmenu.c b/dlls/shell32/contmenu.c
index 9bca626..f2d3422 100644
--- a/dlls/shell32/contmenu.c
+++ b/dlls/shell32/contmenu.c
@@ -9,6 +9,8 @@
 #include "pidl.h"
 #include "shlobj.h"
 #include "shell32_main.h"
+#include "shresdef.h"
+#include "if_macros.h"
 
 #define __T(x)      x
 #define _T(x)       __T(x)
@@ -90,7 +92,6 @@
 	  { IContextMenu_FreePidlTable(this);
 	  }
 
-
 	  HeapFree(GetProcessHeap(),0,this);
 	  return 0;
 	}
@@ -130,7 +131,8 @@
 /**************************************************************************
 *  ICM_InsertItem()
 */ 
-static void ICM_InsertItem (HMENU32 hmenu, UINT32 indexMenu, UINT32 wID, UINT32 fType, LPSTR dwTypeData, UINT32 fState)
+void WINAPI _InsertMenuItem (HMENU32 hmenu, UINT32 indexMenu, BOOL32 fByPosition, 
+			UINT32 wID, UINT32 fType, LPSTR dwTypeData, UINT32 fState)
 {	MENUITEMINFO32A	mii;
 
 	ZeroMemory(&mii, sizeof(mii));
@@ -145,15 +147,15 @@
 	}
 	mii.wID = wID;
 	mii.fType = fType;
-	InsertMenuItem32A( hmenu, indexMenu, TRUE, &mii);
+	InsertMenuItem32A( hmenu, indexMenu, fByPosition, &mii);
 }
 /**************************************************************************
 * IContextMenu_QueryContextMenu()
 */
 
-static HRESULT WINAPI  IContextMenu_QueryContextMenu( LPCONTEXTMENU this, HMENU32 hmenu,
-							UINT32 indexMenu,UINT32 idCmdFirst,UINT32 idCmdLast,UINT32 uFlags)
-{	BOOL32			fExplore ;
+static HRESULT WINAPI IContextMenu_QueryContextMenu( LPCONTEXTMENU this, HMENU32 hmenu, UINT32 indexMenu,
+							UINT32 idCmdFirst,UINT32 idCmdLast,UINT32 uFlags)
+{	BOOL32	fExplore ;
 
 	TRACE(shell,"(%p)->(hmenu=%x indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n",this, hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
 
@@ -161,17 +163,17 @@
 	{ if(!this->bAllValues)
 	  { fExplore = uFlags & CMF_EXPLORE;
 	    if(fExplore)
-	    { ICM_InsertItem(hmenu, indexMenu++, idCmdFirst+IDM_EXPLORE, MFT_STRING, TEXT("&Explore"), MFS_ENABLED|MFS_DEFAULT);
-	      ICM_InsertItem(hmenu, indexMenu++, idCmdFirst+IDM_OPEN, MFT_STRING, TEXT("&Open"), MFS_ENABLED);
+	    { _InsertMenuItem(hmenu, indexMenu++, TRUE, idCmdFirst+IDM_EXPLORE, MFT_STRING, TEXT("&Explore"), MFS_ENABLED|MFS_DEFAULT);
+	      _InsertMenuItem(hmenu, indexMenu++, TRUE, idCmdFirst+IDM_OPEN, MFT_STRING, TEXT("&Open"), MFS_ENABLED);
 	    }
 	    else
-            { ICM_InsertItem(hmenu, indexMenu++, idCmdFirst+IDM_OPEN, MFT_STRING, TEXT("&Open"), MFS_ENABLED|MFS_DEFAULT);
-	      ICM_InsertItem(hmenu, indexMenu++, idCmdFirst+IDM_EXPLORE, MFT_STRING, TEXT("&Explore"), MFS_ENABLED);
+            { _InsertMenuItem(hmenu, indexMenu++, TRUE, idCmdFirst+IDM_OPEN, MFT_STRING, TEXT("&Open"), MFS_ENABLED|MFS_DEFAULT);
+	      _InsertMenuItem(hmenu, indexMenu++, TRUE, idCmdFirst+IDM_EXPLORE, MFT_STRING, TEXT("&Explore"), MFS_ENABLED);
             }
 
             if(uFlags & CMF_CANRENAME)
-            { ICM_InsertItem(hmenu, indexMenu++, 0, MFT_SEPARATOR, NULL, 0);
-	      ICM_InsertItem(hmenu, indexMenu++, idCmdFirst+IDM_RENAME, MFT_STRING, TEXT("&Rename"), (IContextMenu_CanRenameItems(this) ? MFS_ENABLED : MFS_DISABLED));
+            { _InsertMenuItem(hmenu, indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
+	      _InsertMenuItem(hmenu, indexMenu++, TRUE, idCmdFirst+IDM_RENAME, MFT_STRING, TEXT("&Rename"), (IContextMenu_CanRenameItems(this) ? MFS_ENABLED : MFS_DISABLED));
 	    }
 	  }
 	  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, (IDM_LAST + 1));
@@ -183,14 +185,36 @@
 * IContextMenu_InvokeCommand()
 */
 static HRESULT WINAPI IContextMenu_InvokeCommand(LPCONTEXTMENU this, LPCMINVOKECOMMANDINFO32 lpcmi)
-{	LPITEMIDLIST      pidlTemp,pidlFQ;
-	SHELLEXECUTEINFO32A  sei;
+{	LPITEMIDLIST	pidlTemp,pidlFQ;
+	LPSHELLBROWSER	lpSB;
+	LPSHELLVIEW	lpSV;
+	HWND32	hWndSV;
+	SHELLEXECUTEINFO32A	sei;
 	int   i;
 
- 	TRACE(shell,"(%p)->(invcom=%p verb=%p)\n",this,lpcmi,lpcmi->lpVerb);    
+ 	TRACE(shell,"(%p)->(invcom=%p verb=%p wnd=%x)\n",this,lpcmi,lpcmi->lpVerb, lpcmi->hwnd);    
 
 	if(HIWORD(lpcmi->lpVerb))
-	{ //the command is being sent via a verb
+	{ /* get the active IShellView */
+	  lpSB = (LPSHELLBROWSER)SendMessage32A(lpcmi->hwnd, CWM_GETISHELLBROWSER,0,0);
+	  IShellBrowser_QueryActiveShellView(lpSB, &lpSV);
+	  lpSV->lpvtbl->fnGetWindow(lpSV, &hWndSV);
+	  
+	  /* these verbs are used by the filedialogs*/
+	  if (! strcmp(lpcmi->lpVerb,CMDSTR_NEWFOLDER))
+	  { FIXME(shell,"%s\n",lpcmi->lpVerb);
+	  }
+	  else if (! strcmp(lpcmi->lpVerb,CMDSTR_VIEWLIST))
+	  { FIXME(shell,"%s\n",lpcmi->lpVerb);
+	    SendMessage32A(hWndSV, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_LISTVIEW,0),0 );
+	  }
+	  else if (! strcmp(lpcmi->lpVerb,CMDSTR_VIEWDETAILS))
+	  { FIXME(shell,"%s\n",lpcmi->lpVerb);
+	    SendMessage32A(hWndSV, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_REPORTVIEW,0),0 );
+	  } 
+	  else
+	  { FIXME(shell,"please report: unknown verb %s\n",lpcmi->lpVerb);
+	  }
 	  return NOERROR;
 	}
 
@@ -209,7 +233,7 @@
 	    }
       
 	    pidlTemp = ILCombine(this->pSFParent->mpidl, this->aPidls[i]);
-	    pidlFQ = ILCombine(this->pSFParent->mpidlNSRoot, pidlTemp);
+	    pidlFQ = ILCombine(this->pSFParent->pMyPidl, pidlTemp);
 	    SHFree(pidlTemp);
       
 	    ZeroMemory(&sei, sizeof(sei));
@@ -233,7 +257,7 @@
 	  case IDM_RENAME:
 	    MessageBeep32(MB_OK);
 	    /*handle rename for the view here*/
-	    break;
+	    break;	    
 	}
 	return NOERROR;
 }
diff --git a/dlls/shell32/dataobject.c b/dlls/shell32/dataobject.c
index e5ad445..d35757e 100644
--- a/dlls/shell32/dataobject.c
+++ b/dlls/shell32/dataobject.c
@@ -246,7 +246,7 @@
 * NOTES
 *  get or register the "Shell IDList Array" clipformat
 */
-static BOOL32 DATAOBJECT_InitShellIDList()
+static BOOL32 DATAOBJECT_InitShellIDList(void)
 {	if (cfShellIDList)
         { return(TRUE);
         }
@@ -261,7 +261,7 @@
 * NOTES
 *  get or register the "FileGroupDescriptor" clipformat
 */
-static BOOL32 DATAOBJECT_InitFileGroupDesc()
+static BOOL32 DATAOBJECT_InitFileGroupDesc(void)
 {	if (cfFileGroupDesc)
         { return(TRUE);
         }
@@ -275,7 +275,7 @@
 * NOTES
  * get or register the "FileContents" clipformat
 */
-static BOOL32 DATAOBJECT_InitFileContents()
+static BOOL32 DATAOBJECT_InitFileContents(void)
 {	if (cfFileContents)
         { return(TRUE);
         }
@@ -334,10 +334,10 @@
 
 	    TRACE(shell,"-- %lu %lu %lu\n",size, size1, size2 );
 	    TRACE(shell,"-- %p %p\n",this->pidl, pidl);
-	    TRACE(shell,"-- %p %p %p\n",pcida, (void*)pcida+size,(void*)pcida+size+size1);
+	    TRACE(shell,"-- %p %p %p\n",pcida, (LPBYTE)pcida+size,(LPBYTE)pcida+size+size1);
 	    
-	    memcpy ((void*)pcida+size, this->pidl, size1);
-	    memcpy ((void*)pcida+size+size1, pidl, size2);
+	    memcpy ((LPBYTE)pcida+size, this->pidl, size1);
+	    memcpy ((LPBYTE)pcida+size+size1, pidl, size2);
 	    TRACE(shell,"-- after copy\n");
 
 	    GlobalUnlock32(hmem);
diff --git a/dlls/shell32/folders.c b/dlls/shell32/folders.c
index 4373a3a..fe5e4a8 100644
--- a/dlls/shell32/folders.c
+++ b/dlls/shell32/folders.c
@@ -78,11 +78,14 @@
 */
 LPEXTRACTICON IExtractIcon_Constructor(LPCITEMIDLIST pidl)
 { LPEXTRACTICON ei;
+
   ei=(LPEXTRACTICON)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIcon));
   ei->ref=1;
   ei->lpvtbl=&eivt;
   ei->pidl=ILClone(pidl);
-  
+
+  pdump(pidl);
+
   TRACE(shell,"(%p)\n",ei);
   return ei;
 }
@@ -134,19 +137,15 @@
 }
 /**************************************************************************
 *  IExtractIcon_GetIconLocation
-* NOTE
-*  FIXME returns allways the icon no. 3 (closed Folder)
 */
 static HRESULT WINAPI IExtractIcon_GetIconLocation(LPEXTRACTICON this, UINT32 uFlags, LPSTR szIconFile, UINT32 cchMax, int * piIndex, UINT32 * pwFlags)
-{ FIXME (shell,"(%p) (flags=%u file=%s max=%u %p %p) semi-stub\n", this, uFlags, szIconFile, cchMax, piIndex, pwFlags);
-	if (!szIconFile)
-	{ *piIndex = 20;
-	}
-	else
-	{ *piIndex = 3;
-	}
+{	FIXME (shell,"(%p) (flags=%u file=%s max=%u %p %p) semi-stub\n", this, uFlags, szIconFile, cchMax, piIndex, pwFlags);
+
+	*piIndex = (int) SHMapPIDLToSystemImageListIndex(0, this->pidl,0);
 	*pwFlags = GIL_NOTFILENAME;
 
+	FIXME (shell,"-- %x\n",*piIndex);
+
 	return NOERROR;
 }
 /**************************************************************************
diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c
index c7fac5c..e79e71e 100644
--- a/dlls/shell32/shell32_main.c
+++ b/dlls/shell32/shell32_main.c
@@ -27,9 +27,9 @@
 #include "debug.h"
 #include "winreg.h"
 #include "imagelist.h"
+#include "sysmetrics.h"
 #include "commctrl.h"
 #include "authors.h"
-
 #include "pidl.h"
 #include "shell32_main.h"
 
@@ -96,32 +96,6 @@
 }
 
 /*************************************************************************
- * Shell_GetImageList [SHELL32.71]
- *
- * PARAMETERS
- *  imglist[1|2] [OUT] pointer which recive imagelist handles
- *
- * NOTES
- *  undocumented
- *  I don't know, which pointer is which. They may have to be
- *  exchanged. (jsch)
- */
-BOOL32 WINAPI Shell_GetImageList(HIMAGELIST * imglist1,HIMAGELIST * imglist2)
-{	WARN(shell,"(%p,%p):semi-stub.\n",imglist1,imglist2);
-	if (imglist1)
-	{ *imglist1=ShellSmallIconList;
-	}
-	if (imglist2)
-	{ *imglist2=ShellBigIconList;
-	}
-
-	return TRUE;
-}
-
-HIMAGELIST ShellSmallIconList = 0;
-HIMAGELIST ShellBigIconList = 0;
-
-/*************************************************************************
  *  SHGetFileInfoA		[SHELL32.254]
  *
  * FIXME
@@ -552,7 +526,7 @@
 	{ case FT_DIR:
 	    /* Directory: get the value from the registry, if its not there 
 			create it and the directory*/
-	    if (RegQueryValueEx32A(key,buffer,NULL,&type,tpath,&tpathlen))
+	    if (RegQueryValueEx32A(key,buffer,NULL,&type,(LPBYTE)tpath,&tpathlen))
   	    { GetWindowsDirectory32A(npath,MAX_PATH);
 	      PathAddBackslash32A(npath);
 	      switch (nFolder)
@@ -610,7 +584,7 @@
          	  RegCloseKey(key);
         	  return E_OUTOFMEMORY;
 	      }
-	      if (RegSetValueEx32A(key,buffer,0,REG_SZ,npath,sizeof(npath)+1))
+	      if (RegSetValueEx32A(key,buffer,0,REG_SZ,(LPBYTE)npath,sizeof(npath)+1))
 	      { ERR(shell,"could not create value %s\n",buffer);
 	        RegCloseKey(key);
 	        return E_OUTOFMEMORY;
@@ -753,7 +727,9 @@
 	    if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
         { RECT32 rect;
 		if( __get_dropline( hWnd, &rect ) )
-          { POINT32 pt = { lpDragInfo->pt.x, lpDragInfo->pt.y };
+          { POINT32 pt;
+	    pt.x=lpDragInfo->pt.x;
+	    pt.x=lpDragInfo->pt.y;
 		    rect.bottom += DROP_FIELD_HEIGHT;
 		    if( PtInRect32( &rect, pt ) )
             { SetWindowLong32A( hWnd, DWL_MSGRESULT, 1 );
@@ -891,9 +867,9 @@
 DWORD WINAPI SHGetPathFromIDList32A (LPCITEMIDLIST pidl,LPSTR pszPath)
 {	STRRET lpName;
 	LPSHELLFOLDER shellfolder;
-  CHAR  buffer[MAX_PATH],tpath[MAX_PATH];
-  DWORD type,tpathlen=MAX_PATH,dwdisp;
-  HKEY  key;
+	CHAR  buffer[MAX_PATH],tpath[MAX_PATH];
+	DWORD type,tpathlen=MAX_PATH,dwdisp;
+	HKEY  key;
 
 	TRACE(shell,"(pidl=%p,%p)\n",pidl,pszPath);
 
@@ -905,11 +881,11 @@
      }
      type=REG_SZ;    
      strcpy (buffer,"Desktop");					/*registry name*/
-     if ( RegQueryValueEx32A(key,buffer,NULL,&type,tpath,&tpathlen))
+     if ( RegQueryValueEx32A(key,buffer,NULL,&type,(LPBYTE)tpath,&tpathlen))
      { GetWindowsDirectory32A(tpath,MAX_PATH);
        PathAddBackslash32A(tpath);
        strcat (tpath,"Desktop");				/*folder name*/
-       RegSetValueEx32A(key,buffer,0,REG_SZ,tpath,tpathlen);
+       RegSetValueEx32A(key,buffer,0,REG_SZ,(LPBYTE)tpath,tpathlen);
        CreateDirectory32A(tpath,NULL);
      }
      RegCloseKey(key);
@@ -942,16 +918,19 @@
 }
 
 
-void (CALLBACK* pDLLInitComctl)();
-INT32 (CALLBACK* pImageList_AddIcon) (HIMAGELIST himl, HICON32 hIcon);
-INT32(CALLBACK* pImageList_ReplaceIcon) (HIMAGELIST, INT32, HICON32);
+void	(CALLBACK* pDLLInitComctl)(void);
+INT32	(CALLBACK* pImageList_AddIcon) (HIMAGELIST himl, HICON32 hIcon);
+INT32	(CALLBACK* pImageList_ReplaceIcon) (HIMAGELIST, INT32, HICON32);
 HIMAGELIST (CALLBACK * pImageList_Create) (INT32,INT32,UINT32,INT32,INT32);
-HICON32 (CALLBACK * pImageList_GetIcon) (HIMAGELIST, INT32, UINT32);
-HDPA (CALLBACK* pDPA_Create) (INT32);  
-INT32 (CALLBACK* pDPA_InsertPtr) (const HDPA, INT32, LPVOID); 
-BOOL32 (CALLBACK* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM); 
-LPVOID (CALLBACK* pDPA_GetPtr) (const HDPA, INT32);   
-BOOL32 (CALLBACK* pDPA_Destroy) (const HDPA); 
+HICON32	(CALLBACK * pImageList_GetIcon) (HIMAGELIST, INT32, UINT32);
+INT32	(CALLBACK* pImageList_GetImageCount)(HIMAGELIST);
+
+HDPA	(CALLBACK* pDPA_Create) (INT32);  
+INT32	(CALLBACK* pDPA_InsertPtr) (const HDPA, INT32, LPVOID); 
+BOOL32	(CALLBACK* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM); 
+LPVOID	(CALLBACK* pDPA_GetPtr) (const HDPA, INT32);   
+BOOL32	(CALLBACK* pDPA_Destroy) (const HDPA); 
+INT32	(CALLBACK *pDPA_Search) (const HDPA, LPVOID, INT32, PFNDPACOMPARE, LPARAM, UINT32);
 
 /*************************************************************************
  * SHELL32 LibMain
@@ -963,21 +942,12 @@
 HINSTANCE32 shell32_hInstance; 
 
 BOOL32 WINAPI Shell32LibMain(HINSTANCE32 hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{ HICON32 htmpIcon;
-  UINT32 iiconindex;
-  UINT32 index;
-  CHAR   szShellPath[MAX_PATH];
-  HINSTANCE32 hComctl32;
-  
+{ HINSTANCE32 hComctl32;
 
   TRACE(shell,"0x%x 0x%lx %p\n", hinstDLL, fdwReason, lpvReserved);
 
   shell32_hInstance = hinstDLL;
   
-  GetWindowsDirectory32A(szShellPath,MAX_PATH);
-  PathAddBackslash32A(szShellPath);
-  strcat(szShellPath,"system\\shell32.dll");
-       
   if (fdwReason==DLL_PROCESS_ATTACH)
   { hComctl32 = LoadLibrary32A("COMCTL32.DLL");	
     if (hComctl32)
@@ -989,12 +959,15 @@
       pImageList_AddIcon=GetProcAddress32(hComctl32,"ImageList_AddIcon");
       pImageList_ReplaceIcon=GetProcAddress32(hComctl32,"ImageList_ReplaceIcon");
       pImageList_GetIcon=GetProcAddress32(hComctl32,"ImageList_GetIcon");
+      pImageList_GetImageCount=GetProcAddress32(hComctl32,"ImageList_GetImageCount");
+
       /* imports by ordinal, pray that it works*/
       pDPA_Create=GetProcAddress32(hComctl32, (LPCSTR)328L);
       pDPA_Destroy=GetProcAddress32(hComctl32, (LPCSTR)329L);
       pDPA_GetPtr=GetProcAddress32(hComctl32, (LPCSTR)332L);
       pDPA_InsertPtr=GetProcAddress32(hComctl32, (LPCSTR)334L);
       pDPA_Sort=GetProcAddress32(hComctl32, (LPCSTR)338L);
+      pDPA_Search=GetProcAddress32(hComctl32, (LPCSTR)339L);
 
       FreeLibrary32(hComctl32);
     }
@@ -1003,29 +976,7 @@
       ERR(shell,"P A N I C error getting functionpointers\n");
       exit (1);
     }
-    if ( ! ShellSmallIconList )
-    { if ( (ShellSmallIconList = pImageList_Create(sysMetrics[SM_CXSMICON],sysMetrics[SM_CYSMICON],ILC_COLORDDB | ILC_MASK,0,0x20)) )
-      { for (index=0;index < 40; index++)
-        { if ( ! ( htmpIcon = ExtractIcon32A(hinstDLL, szShellPath, index))
-          || ( -1 == (iiconindex = pImageList_AddIcon (ShellSmallIconList, htmpIcon))) )
-          { ERR(shell,"could not initialize iconlist (is shell32.dll in the system directory?)\n");
-            break;
-          }
-        }
-      }
-    }
-    if ( ! ShellBigIconList )
-    { if ( (ShellBigIconList = pImageList_Create(SYSMETRICS_CXSMICON, SYSMETRICS_CYSMICON,ILC_COLORDDB | ILC_MASK,0,0x20)) )
-      { for (index=0;index < 40; index++)
-        { if ( ! (htmpIcon = ExtractIcon32A( hinstDLL, szShellPath, index)) 
-           || (-1 == (iiconindex = pImageList_AddIcon (ShellBigIconList, htmpIcon))) )
-          { ERR(shell,"could not initialize iconlist (is shell32.dll in the system directory?)\n");
-            break;
-          }
-        }
-      }
-    }
-    TRACE(shell,"hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
+    SIC_Initialize();
   }
   return TRUE;
 }
diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h
index 4c4656c..ae2523f 100644
--- a/dlls/shell32/shell32_main.h
+++ b/dlls/shell32/shell32_main.h
@@ -16,16 +16,22 @@
 /*******************************************
 * pointer to functions dynamically loaded
 */
-extern void (CALLBACK* pDLLInitComctl)();
-extern INT32 (CALLBACK* pImageList_AddIcon) (HIMAGELIST himl, HICON32 hIcon);
-extern INT32(CALLBACK* pImageList_ReplaceIcon) (HIMAGELIST, INT32, HICON32);
+extern void	(CALLBACK* pDLLInitComctl)(void);
+extern INT32	(CALLBACK* pImageList_AddIcon) (HIMAGELIST himl, HICON32 hIcon);
+extern INT32	(CALLBACK* pImageList_ReplaceIcon) (HIMAGELIST, INT32, HICON32);
 extern HIMAGELIST (CALLBACK * pImageList_Create) (INT32,INT32,UINT32,INT32,INT32);
-extern HICON32 (CALLBACK * pImageList_GetIcon) (HIMAGELIST, INT32, UINT32);
-extern HDPA (CALLBACK* pDPA_Create) (INT32);  
-extern INT32 (CALLBACK* pDPA_InsertPtr) (const HDPA, INT32, LPVOID); 
-extern BOOL32 (CALLBACK* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM); 
-extern LPVOID (CALLBACK* pDPA_GetPtr) (const HDPA, INT32);   
-extern BOOL32 (CALLBACK* pDPA_Destroy) (const HDPA); 
+extern HICON32	(CALLBACK * pImageList_GetIcon) (HIMAGELIST, INT32, UINT32);
+extern INT32	(CALLBACK* pImageList_GetImageCount)(HIMAGELIST);
+extern HDPA	(CALLBACK* pDPA_Create) (INT32);  
+extern INT32	(CALLBACK* pDPA_InsertPtr) (const HDPA, INT32, LPVOID); 
+extern BOOL32	(CALLBACK* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM); 
+extern LPVOID	(CALLBACK* pDPA_GetPtr) (const HDPA, INT32);   
+extern BOOL32	(CALLBACK* pDPA_Destroy) (const HDPA); 
+extern INT32	(CALLBACK *pDPA_Search) (const HDPA, LPVOID, INT32, PFNDPACOMPARE, LPARAM, UINT32);
+
+extern BOOL32	WINAPI SIC_Initialize(void);
+extern HICON32	WINAPI SIC_GetIcon (LPSTR sSourceFile, DWORD dwSourceIndex, BOOL32 bSmallIcon );
+
 /* FIXME should be moved to a header file. IsEqualGUID 
 is declared but not exported in compobj.c !!!*/
 #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
diff --git a/dlls/shell32/shellole.c b/dlls/shell32/shellole.c
index 1e916c6..d5a10fd 100644
--- a/dlls/shell32/shellole.c
+++ b/dlls/shell32/shellole.c
@@ -211,8 +211,8 @@
 static HRESULT WINAPI IClassFactory_QueryInterface(LPCLASSFACTORY,REFIID,LPVOID*);
 static ULONG WINAPI IClassFactory_AddRef(LPCLASSFACTORY);
 static ULONG WINAPI IClassFactory_Release(LPCLASSFACTORY);
-static HRESULT WINAPI IClassFactory_CreateInstance();
-static HRESULT WINAPI IClassFactory_LockServer();
+static HRESULT WINAPI IClassFactory_CreateInstance(LPCLASSFACTORY, LPUNKNOWN, REFIID, LPVOID *);
+static HRESULT WINAPI IClassFactory_LockServer(LPCLASSFACTORY, BOOL32);
 /**************************************************************************
  *  IClassFactory_VTable
  */
@@ -228,7 +228,7 @@
  *  IClassFactory_Constructor
  */
 
-LPCLASSFACTORY IClassFactory_Constructor()
+LPCLASSFACTORY IClassFactory_Constructor(void)
 {	LPCLASSFACTORY	lpclf;
 
 	lpclf= (LPCLASSFACTORY)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactory));
@@ -316,7 +316,7 @@
 	{ pObj = (IUnknown *)IContextMenu_Constructor(NULL, NULL, 0);
  	} 
 	else if (IsEqualIID(riid, &IID_IDataObject))
-	{ pObj = (IUnknown *)IDataObject_Constructor();
+	{ pObj = (IUnknown *)IDataObject_Constructor(0,NULL,NULL,0);
  	} 
 	else
 	{ ERR(shell,"unknown IID requested\n\tIID:\t%s\n",xriid);
diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c
index 8bb02e0..a245571 100644
--- a/dlls/shell32/shellord.c
+++ b/dlls/shell32/shellord.c
@@ -159,7 +159,7 @@
  * NOTES
  *     append \ if there is none
  */
-LPSTR WINAPI PathAddBackslash32A(LPSTR path)
+LPSTR WINAPI PathAddBackslash32A(LPCSTR path)
 {	int len;
 	TRACE(shell,"%p->%s\n",path,path);
 
@@ -171,7 +171,7 @@
 	}
 	return path+len;
 }
-LPWSTR WINAPI PathAddBackslash32W(LPWSTR path)
+LPWSTR WINAPI PathAddBackslash32W(LPCWSTR path)
 {	int len;
 	TRACE(shell,"%p->%s\n",path,debugstr_w(path));
 
@@ -183,7 +183,7 @@
 	}
 	return path+len;
 }
-LPVOID WINAPI PathAddBackslash32AW(LPVOID path)
+LPVOID WINAPI PathAddBackslash32AW(LPCVOID path)
 {	if(VERSION_OsIsUnicode())
 	  return PathAddBackslash32W(path);
 	return PathAddBackslash32A(path);
@@ -195,20 +195,20 @@
  * NOTES
  *     remove spaces from beginning and end of passed string
  */
-LPSTR WINAPI PathRemoveBlanks(LPSTR str)
-{ LPSTR x = str;
-  TRACE(shell,"%s\n",str);
-  while (*x==' ') x++;
-  if (x!=str)
+LPSTR WINAPI PathRemoveBlanks(LPCSTR str)
+{	LPSTR x = str;
+	TRACE(shell,"%s\n",str);
+	while (*x==' ') x++;
+	if (x!=str)
 	  strcpy(str,x);
-  if (!*str)
+	if (!*str)
 	  return str;
-  x=str+strlen(str)-1;
-  while (*x==' ')
+	x=str+strlen(str)-1;
+	while (*x==' ')
 	  x--;
-  if (*x==' ')
+	if (*x==' ')
 	  *x='\0';
-  return x;
+	return x;
 }
 
 
@@ -450,6 +450,27 @@
 	}
 	return (LPVOID) aptr;
 }
+/*************************************************************************
+ * PathQuoteSpaces [SHELL32.55]
+ * 
+ * NOTES
+ *     basename(char *fn);
+ */
+LPSTR WINAPI PathQuoteSpaces32A(LPCSTR aptr)
+{	FIXME(shell,"%s\n",aptr);
+	return 0;
+
+}
+LPWSTR WINAPI PathQuoteSpaces32W(LPCWSTR wptr)
+{	FIXME(shell,"L%s\n",debugstr_w(wptr));
+	return 0;	
+}
+LPVOID WINAPI PathQuoteSpaces32AW (LPCVOID fn)
+{	if(VERSION_OsIsUnicode())
+	  return PathQuoteSpaces32W(fn);
+	return PathQuoteSpaces32A(fn);
+}
+
 
 /*************************************************************************
  * PathUnquoteSpaces [SHELL32.56]
@@ -559,22 +580,6 @@
 }
 
 /*************************************************************************
- * SHMapPIDLToSystemImageListIndex [SHELL32.77]
- *
- * PARAMETERS
- * x  pointer to an instance of IShellFolder 
- * 
- * NOTES
- *     exported by ordinal
- *
- */
-DWORD WINAPI
-SHMapPIDLToSystemImageListIndex(LPSHELLFOLDER sh,DWORD y,DWORD z)
-{ FIXME(shell,"(SF=%p,pidl=%08lx,%08lx):stub.\n",sh,y,z);
-  return 0;
-}
-
-/*************************************************************************
  * OleStrToStrN  [SHELL32.78]
  * 
  * NOTES
@@ -1051,6 +1056,15 @@
  * ShellExecuteEx [SHELL32.291]
  *
  */
+BOOL32 WINAPI ShellExecuteEx32 (LPVOID sei)
+{	if (VERSION_OsIsUnicode())
+	  return ShellExecuteEx32W (sei);
+	return ShellExecuteEx32A (sei);
+}
+/*************************************************************************
+ * ShellExecuteEx32A [SHELL32.292]
+ *
+ */
 BOOL32 WINAPI ShellExecuteEx32A (LPSHELLEXECUTEINFO32A sei)
 { 	CHAR szTemp[MAX_PATH];
 
@@ -1072,6 +1086,30 @@
 	return 0;
 }
 /*************************************************************************
+ * ShellExecuteEx [SHELL32.293]
+ *
+ */
+BOOL32 WINAPI ShellExecuteEx32W (LPSHELLEXECUTEINFO32W sei)
+{ 	WCHAR szTemp[MAX_PATH];
+
+  	FIXME(shell,"(%p): stub\n",sei);
+
+	if (sei->fMask & SEE_MASK_IDLIST)
+	{ SHGetPathFromIDList32W (sei->lpIDList,szTemp);
+	  TRACE (shell,"-- idlist=%p (%s)\n", sei->lpIDList, debugstr_w(szTemp));
+	}
+
+	if (sei->fMask & SEE_MASK_CLASSNAME)
+	{ TRACE (shell,"-- classname= %s\n", debugstr_w(sei->lpClass));
+	}
+    
+	if (sei->lpVerb)
+	{ TRACE (shell,"-- action=%s\n", debugstr_w(sei->lpVerb));
+	}
+	
+	return 0;
+}
+/*************************************************************************
  * SHSetInstanceExplorer [SHELL32.176]
  *
  */
@@ -1218,7 +1256,7 @@
  * IsUserAdmin [NT 4.0:SHELL32.680]
  *
  */
-HRESULT WINAPI IsUserAdmin()
+HRESULT WINAPI IsUserAdmin(void)
 {	FIXME(shell,"stub\n");
 	return TRUE;
 }
@@ -1533,7 +1571,7 @@
  * SHAbortInvokeCommand [SHELL32.198]
  *
  */
-HRESULT WINAPI SHAbortInvokeCommand()
+HRESULT WINAPI SHAbortInvokeCommand(void)
 {	FIXME(shell,"stub\n");
 	return 1;
 }
@@ -1549,7 +1587,7 @@
  * SHFlushClipboard [SHELL32.121]
  *
  */
-HRESULT WINAPI SHFlushClipboard()
+HRESULT WINAPI SHFlushClipboard(void)
 {	FIXME(shell,"stub\n");
 	return 1;
 }
@@ -1592,3 +1630,10 @@
 	} while ( lpStart<=lpEnd ); 
 	return wptr;
 }
+/*************************************************************************
+*	PathProcessCommand	[SHELL32.653]
+*/
+HRESULT WINAPI PathProcessCommand (DWORD u, DWORD v, DWORD w, DWORD x)
+{	FIXME(shell,"0x%04lx 0x%04lx 0x%04lx 0x%04lx stub\n",u,v,w,x);
+	return 0;
+}
diff --git a/dlls/shell32/shlfolder.c b/dlls/shell32/shlfolder.c
index 1faedbd..4a9384e 100644
--- a/dlls/shell32/shlfolder.c
+++ b/dlls/shell32/shlfolder.c
@@ -105,31 +105,32 @@
 	sf=(LPSHELLFOLDER)HeapAlloc(GetProcessHeap(),0,sizeof(IShellFolder));
 	sf->ref=1;
 	sf->lpvtbl=&sfvt;
-	sf->mlpszFolder=NULL;	/* path of the folder */
+	sf->sMyPath=NULL;	/* path of the folder */
+	sf->pMyPidl=NULL;	/* my qualified pidl */
 	sf->mpSFParent=pParent;	/* parrent shellfolder */
 
 	TRACE(shell,"(%p)->(parent=%p, pidl=%p)\n",sf,pParent, pidl);
 	
 	/* keep a copy of the pidl in the instance*/
 	sf->mpidl = ILClone(pidl);
-	sf->mpidlNSRoot = NULL;
 	
 	if(sf->mpidl)        /* do we have a pidl? */
 	{ dwSize = 0;
-	  if(sf->mpSFParent->mlpszFolder)		/* get the size of the parents path */
-	  { dwSize += strlen(sf->mpSFParent->mlpszFolder) + 1;
-	    TRACE(shell,"-- (%p)->(parent's path=%s)\n",sf, debugstr_a(sf->mpSFParent->mlpszFolder));
+	  if(sf->mpSFParent->sMyPath)		/* get the size of the parents path */
+	  { dwSize += strlen(sf->mpSFParent->sMyPath) + 1;
+	    TRACE(shell,"-- (%p)->(parent's path=%s)\n",sf, debugstr_a(sf->mpSFParent->sMyPath));
 	  }   
 	  dwSize += _ILGetFolderText(sf->mpidl,NULL,0); /* add the size of the foldername*/
-	  sf->mlpszFolder = SHAlloc(dwSize);
-	  if(sf->mlpszFolder)
-	  { *(sf->mlpszFolder)=0x00;
-	    if(sf->mpSFParent->mlpszFolder)		/* if the parent has a path, get it*/
-	    {  strcpy(sf->mlpszFolder, sf->mpSFParent->mlpszFolder);
-	       PathAddBackslash32A (sf->mlpszFolder);
+	  sf->sMyPath = SHAlloc(dwSize);
+	  if(sf->sMyPath)
+	  { *(sf->sMyPath)=0x00;
+	    if(sf->mpSFParent->sMyPath)		/* if the parent has a path, get it*/
+	    {  strcpy(sf->sMyPath, sf->mpSFParent->sMyPath);
+	       PathAddBackslash32A (sf->sMyPath);
 	    }
-	    _ILGetFolderText(sf->mpidl, sf->mlpszFolder+strlen(sf->mlpszFolder), dwSize-strlen(sf->mlpszFolder));
-	    TRACE(shell,"-- (%p)->(my path=%s)\n",sf, debugstr_a(sf->mlpszFolder));
+	    sf->pMyPidl = ILCombine(sf->pMyPidl, pidl);
+	    _ILGetFolderText(sf->mpidl, sf->sMyPath+strlen(sf->sMyPath), dwSize-strlen(sf->sMyPath));
+	    TRACE(shell,"-- (%p)->(my path=%s)\n",sf, debugstr_a(sf->sMyPath));
 	  }
 	}
 	return sf;
@@ -185,14 +186,14 @@
 	  { pdesktopfolder=NULL;
 	    TRACE(shell,"-- destroyed IShellFolder(%p) was Desktopfolder\n",this);
 	  }
-	  if(this->mpidlNSRoot)
-	  { SHFree(this->mpidlNSRoot);
+	  if(this->pMyPidl)
+	  { SHFree(this->pMyPidl);
 	  }
 	  if(this->mpidl)
 	  { SHFree(this->mpidl);
 	  }
-	  if(this->mlpszFolder)
-	  { SHFree(this->mlpszFolder);
+	  if(this->sMyPath)
+	  { SHFree(this->sMyPath);
 	  }
 
 	  HeapFree(GetProcessHeap(),0,this);
@@ -296,7 +297,7 @@
 {	TRACE(shell,"(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",this,hwndOwner,dwFlags,ppEnumIDList);
 
 	*ppEnumIDList = NULL;
-	*ppEnumIDList = IEnumIDList_Constructor (this->mlpszFolder, dwFlags);
+	*ppEnumIDList = IEnumIDList_Constructor (this->sMyPath, dwFlags);
 	TRACE(shell,"-- (%p)->(new ID List: %p)\n",this,*ppEnumIDList);
 	if(!*ppEnumIDList)
 	{ return E_OUTOFMEMORY;
@@ -307,16 +308,15 @@
  *  IShellFolder_Initialize()
  *  IPersistFolder Method
  */
-static HRESULT WINAPI IShellFolder_Initialize(
-	LPSHELLFOLDER this,
-	LPCITEMIDLIST pidl)
-{ TRACE(shell,"(%p)->(pidl=%p)\n",this,pidl);
-  if(this->mpidlNSRoot)
-  { SHFree(this->mpidlNSRoot);
-    this->mpidlNSRoot = NULL;
-  }
-  this->mpidlNSRoot=ILClone(pidl);
-  return S_OK;
+static HRESULT WINAPI IShellFolder_Initialize( LPSHELLFOLDER this,LPCITEMIDLIST pidl)
+{	TRACE(shell,"(%p)->(pidl=%p)\n",this,pidl);
+
+	if(this->pMyPidl)
+	{ SHFree(this->pMyPidl);
+	  this->pMyPidl = NULL;
+	}
+	this->pMyPidl = ILClone(pidl);
+	return S_OK;
 }
 
 /**************************************************************************
@@ -327,30 +327,29 @@
 *  REFIID        riid,       //[in ] Initial Interface
 *  LPVOID*       ppvObject   //[out] Interface*
 */
-static HRESULT WINAPI IShellFolder_BindToObject(
-	LPSHELLFOLDER this,
-	LPCITEMIDLIST pidl,
-	LPBC pbcReserved,
-	REFIID riid,
-	LPVOID * ppvOut)
+static HRESULT WINAPI IShellFolder_BindToObject( LPSHELLFOLDER this, LPCITEMIDLIST pidl,
+			LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
 {	char	        xriid[50];
-  HRESULT       hr;
+	HRESULT       hr;
 	LPSHELLFOLDER pShellFolder;
 	
 	WINE_StringFromCLSID(riid,xriid);
 
 	TRACE(shell,"(%p)->(pidl=%p,%p,\n\tIID:%s,%p)\n",this,pidl,pbcReserved,xriid,ppvOut);
 
-  *ppvOut = NULL;
-  pShellFolder = IShellFolder_Constructor(this, pidl);
-  if(!pShellFolder)
-    return E_OUTOFMEMORY;
-  /*  pShellFolder->lpvtbl->fnInitialize(pShellFolder, this->mpidlNSRoot);*/
-  IShellFolder_Initialize(pShellFolder, this->mpidlNSRoot);
-  hr = pShellFolder->lpvtbl->fnQueryInterface(pShellFolder, riid, ppvOut);
-  pShellFolder->lpvtbl->fnRelease(pShellFolder);
+	*ppvOut = NULL;
+
+	pShellFolder = IShellFolder_Constructor(this, pidl);
+
+	if(!pShellFolder)
+	  return E_OUTOFMEMORY;
+
+	IShellFolder_Initialize(pShellFolder, this->pMyPidl);
+
+	hr = pShellFolder->lpvtbl->fnQueryInterface(pShellFolder, riid, ppvOut);
+ 	pShellFolder->lpvtbl->fnRelease(pShellFolder);
 	TRACE(shell,"-- (%p)->(interface=%p)\n",this, ppvOut);
-  return hr;
+	return hr;
 }
 
 /**************************************************************************
@@ -578,8 +577,8 @@
 	else if(IsEqualIID(riid, &IID_IExtractIcon))
 	{ if (cidl != 1)
 	    return(E_INVALIDARG);
-	  pidl = ILCombine(this->mpidl, apidl[0]);
-	  pObj = (LPUNKNOWN)IExtractIcon_Constructor(pidl);
+	  pidl = ILCombine(this->pMyPidl,apidl[0]);
+	  pObj = (LPUNKNOWN)IExtractIcon_Constructor( pidl );
 	  SHFree(pidl);
 	} 
 	else
@@ -672,9 +671,9 @@
 	      { /* if the IShellFolder has parents, get the path from the
 	        parent and add the ItemName*/
 	        szText[0]=0x00;
-	        if (this->mlpszFolder && strlen (this->mlpszFolder))
-	        { if (strcmp(this->mlpszFolder,"My Computer"))
-	          { strcpy (szText,this->mlpszFolder);
+	        if (this->sMyPath && strlen (this->sMyPath))
+	        { if (strcmp(this->sMyPath,"My Computer"))
+	          { strcpy (szText,this->sMyPath);
 	            PathAddBackslash32A (szText);
 	          }
 	        }
@@ -748,13 +747,13 @@
     
 	*lpszOut=0;
 
-	if (! this->mlpszFolder)
+	if (! this->sMyPath)
 	  return FALSE;
 	  
-	dwSize = strlen (this->mlpszFolder) +1;
+	dwSize = strlen (this->sMyPath) +1;
 	if ( dwSize > dwOutSize)
 	  return FALSE;
-	strcpy(lpszOut, this->mlpszFolder);
+	strcpy(lpszOut, this->sMyPath);
 
 	TRACE(shell,"-- (%p)->(return=%s)\n",this, lpszOut);
 	return TRUE;
diff --git a/include/shell.h b/include/shell.h
index 64c9dbc..7278c00 100644
--- a/include/shell.h
+++ b/include/shell.h
@@ -253,10 +253,15 @@
 /****************************************************************************
 *  string and path functions
 */
-LPSTR  WINAPI PathAddBackslash32A(LPSTR path);	
-LPWSTR WINAPI PathAddBackslash32W(LPWSTR path);	
+LPSTR  WINAPI PathAddBackslash32A(LPCSTR path);	
+LPWSTR WINAPI PathAddBackslash32W(LPCWSTR path);	
 #define  PathAddBackslash WINELIB_NAME_AW(PathAddBackslash)
-LPVOID  WINAPI PathAddBackslash32AW(LPVOID path);	
+LPVOID  WINAPI PathAddBackslash32AW(LPCVOID path);	
+
+LPSTR  WINAPI PathQuoteSpaces32A(LPCSTR path);	
+LPWSTR WINAPI PathQuoteSpaces32W(LPCWSTR path);	
+#define  PathQuoteSpaces WINELIB_NAME_AW(PathQuoteSpaces)
+LPVOID  WINAPI PathQuoteSpaces32AW(LPCVOID path);	
 
 LPSTR  WINAPI PathCombine32A(LPSTR szDest, LPCSTR lpszDir, LPCSTR lpszFile);
 LPWSTR WINAPI PathCombine32W(LPWSTR szDest, LPCWSTR lpszDir, LPCWSTR lpszFile);
@@ -278,10 +283,15 @@
 #define  PathFindFilename WINELIB_NAME_AW(PathFindFilename)
 LPCVOID WINAPI PathFindFilename32AW(LPCVOID path); 
 
-LPSTR WINAPI PathRemoveBlanks(LPSTR str);
+LPSTR WINAPI PathRemoveBlanks(LPCSTR str);
 /****************************************************************************
 *  other functions
 */
+HICON32 WINAPI ExtractIconEx32A ( LPSTR, INT32, HICON32 *, HICON32 *, UINT32 );
+HICON32 WINAPI ExtractIconEx32W ( LPWSTR, INT32, HICON32 *, HICON32 *, UINT32 );
+#define  ExtractIconEx WINELIB_NAME_AW(ExtractIconEx)
+HICON32 WINAPI ExtractIconEx32AW ( LPVOID, INT32, HICON32 *, HICON32 *, UINT32 );
+
 LPVOID WINAPI SHAlloc(DWORD len);
 DWORD WINAPI SHFree(LPVOID x);
 
diff --git a/include/shlobj.h b/include/shlobj.h
index f908096..5751a91 100644
--- a/include/shlobj.h
+++ b/include/shlobj.h
@@ -534,7 +534,7 @@
 { FVM_ICON =              1,
   FVM_SMALLICON =         2,
   FVM_LIST =              3,
-  FVM_DETAILS =           4,
+  FVM_DETAILS =           4
 } FOLDERVIEWMODE;
 
 typedef struct
@@ -626,10 +626,10 @@
 struct tagSHELLFOLDER {
 	LPSHELLFOLDER_VTABLE	lpvtbl;
 	DWORD			ref;
-	LPSTR			mlpszFolder;
-	LPITEMIDLIST	mpidl;
-	LPITEMIDLIST	mpidlNSRoot;
-	LPSHELLFOLDER	mpSFParent;
+	LPSTR			sMyPath;
+	LPITEMIDLIST		pMyPidl;
+	LPITEMIDLIST		mpidl;
+	LPSHELLFOLDER		mpSFParent;
 };
 
 extern LPSHELLFOLDER pdesktopfolder;
@@ -676,7 +676,15 @@
 #define FCT_MERGE       0x0001
 #define FCT_CONFIGABLE  0x0002
 #define FCT_ADDTOEND    0x0004
- 
+
+/* undocumented, found in the web posted by Chris Becke */ 
+#define CWM_SETPATH	(WM_USER+2)
+#define CWM_WANTIDLE	(WM_USER+3)
+#define CWM_GETSETCURRENTINFO	(WM_USER+4)
+#define CWM_SELECTITEM	(WM_USER+5)
+#define CWM_STOPWAITING	(WM_USER+6)
+#define CWM_GETISHELLBROWSER (WM_USER+7)
+
 typedef struct IShellBrowser_VTable 
 {    // *** IUnknown methods ***
     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
@@ -703,7 +711,7 @@
     STDMETHOD(QueryActiveShellView)(THIS_ IShellView ** ppshv) PURE;
     STDMETHOD(OnViewWindowActive)(THIS_ IShellView * ppshv) PURE;
     STDMETHOD(SetToolbarItems)(THIS_ LPTBBUTTON lpButtons, UINT32 nButtons, UINT32 uFlags) PURE;
-} *LPSHELLBROWSER_VTABLE,IShellBrowser_VTable;;
+} *LPSHELLBROWSER_VTABLE,IShellBrowser_VTable;
 
 struct tagSHELLBROWSER 
 { LPSHELLBROWSER_VTABLE	lpvtbl;
@@ -741,12 +749,35 @@
   FCIDM_BROWSERFIRST/LAST     for the explorer frame (IShellBrowser)
   FCIDM_GLOBAL/LAST           for the explorer's submenu IDs
 */
-#define FCIDM_SHVIEWFIRST           0x0000
-#define FCIDM_SHVIEWLAST            0x7fff
-#define FCIDM_BROWSERFIRST          0xa000
-#define FCIDM_BROWSERLAST           0xbf00
-#define FCIDM_GLOBALFIRST           0x8000
-#define FCIDM_GLOBALLAST            0x9fff
+#define FCIDM_SHVIEWFIRST	0x0000
+/* undocumented */
+#define FCIDM_SHVIEW_ARRANGE	0x7001
+#define FCIDM_SHVIEW_DELETE	0x7011
+#define FCIDM_SHVIEW_PROPERTIES	0x7013
+#define FCIDM_SHVIEW_CUT	0x7018
+#define FCIDM_SHVIEW_COPY	0x7019
+#define FCIDM_SHVIEW_INSERT	0x701A
+#define FCIDM_SHVIEW_UNDO	0x701B
+#define FCIDM_SHVIEW_INSERTLINK	0x701C
+#define FCIDM_SHVIEW_SELECTALL	0x7021
+#define FCIDM_SHVIEW_INVERTSELECTION	0x7022
+#define FCIDM_SHVIEW_BIGICON	0x7029
+#define FCIDM_SHVIEW_SMALLICON	0x702A
+#define FCIDM_SHVIEW_LISTVIEW	0x702B	
+#define FCIDM_SHVIEW_REPORTVIEW	0x702C
+#define FCIDM_SHVIEW_AUTOARRANGE	0x7031  
+#define FCIDM_SHVIEW_SNAPTOGRID	0x7032
+#define FCIDM_SHVIEW_HELP	0x7041
+
+#define FCIDM_SHVIEWLAST	0x7fff
+#define FCIDM_BROWSERFIRST	0xA000
+/* undocumented toolbar items from stddlg's*/
+#define FCIDM_TB_SMALLICON	0xA003
+#define FCIDM_TB_REPORTVIEW	0xA004
+
+#define FCIDM_BROWSERLAST	0xbf00
+#define FCIDM_GLOBALFIRST	0x8000
+#define FCIDM_GLOBALLAST	0x9fff
 
 /*
 * Global submenu IDs and separator IDs
@@ -953,6 +984,9 @@
 };
 
 #undef THIS
+
+DWORD WINAPI SHMapPIDLToSystemImageListIndex(LPSHELLFOLDER sh,LPITEMIDLIST pidl,DWORD z);
+
 /****************************************************************************
  * IShellIcon interface
  */
@@ -1026,14 +1060,14 @@
  * Class constructors
  */
 #ifdef __WINE__
-extern LPDATAOBJECT	IDataObject_Constructor();
+extern LPDATAOBJECT	IDataObject_Constructor(HWND32 hwndOwner, LPSHELLFOLDER psf, LPITEMIDLIST * apidl, UINT32 cidl);
 extern LPENUMFORMATETC	IEnumFORMATETC_Constructor(UINT32, const FORMATETC32 []);
 
-extern LPCLASSFACTORY	IClassFactory_Constructor();
+extern LPCLASSFACTORY	IClassFactory_Constructor(void);
 extern LPCONTEXTMENU	IContextMenu_Constructor(LPSHELLFOLDER, LPCITEMIDLIST *, UINT32);
 extern LPSHELLFOLDER	IShellFolder_Constructor(LPSHELLFOLDER,LPITEMIDLIST);
 extern LPSHELLVIEW	IShellView_Constructor(LPSHELLFOLDER, LPCITEMIDLIST);
-extern LPSHELLLINK	IShellLink_Constructor();
+extern LPSHELLLINK	IShellLink_Constructor(void);
 extern LPENUMIDLIST	IEnumIDList_Constructor(LPCSTR,DWORD);
 extern LPEXTRACTICON	IExtractIcon_Constructor(LPITEMIDLIST);
 #endif
diff --git a/misc/shell.c b/misc/shell.c
index 9c927f2..4d63ed5 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -471,53 +471,59 @@
  *				SHELL_GetResourceTable
  */
 static DWORD SHELL_GetResourceTable(HFILE32 hFile,LPBYTE *retptr)
-{
-  IMAGE_DOS_HEADER	mz_header;
-  char			magic[4];
-  int			size;
-  TRACE(shell,"\n");  
-  *retptr = NULL;
-  _llseek32( hFile, 0, SEEK_SET );
-  if (	(_lread32(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) ||
-  	(mz_header.e_magic != IMAGE_DOS_SIGNATURE)
-  ) { /* .ICO file ? */
-        if (mz_header.e_cblp == 1) { /* ICONHEADER.idType, must be 1 */
+{	IMAGE_DOS_HEADER	mz_header;
+	char			magic[4];
+	int			size;
+
+	TRACE(shell,"\n");  
+
+	*retptr = NULL;
+	_llseek32( hFile, 0, SEEK_SET );
+	if ((_lread32(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) || (mz_header.e_magic != IMAGE_DOS_SIGNATURE))
+	{ /* .ICO file ? */
+          if (mz_header.e_cblp == 1) 
+	  { /* ICONHEADER.idType, must be 1 */
 	    *retptr = (LPBYTE)-1;
   	    return 1;
-	}
-	else
+	  }
+	  else
 	    return 0; /* failed */
-  }
-  _llseek32( hFile, mz_header.e_lfanew, SEEK_SET );
-  if (_lread32( hFile, magic, sizeof(magic) ) != sizeof(magic))
-	return 0;
-  _llseek32( hFile, mz_header.e_lfanew, SEEK_SET);
-
-  if (*(DWORD*)magic  == IMAGE_NT_SIGNATURE)
-	return IMAGE_NT_SIGNATURE;
-  if (*(WORD*)magic == IMAGE_OS2_SIGNATURE) {
-  	IMAGE_OS2_HEADER	ne_header;
-  	LPBYTE			pTypeInfo = (LPBYTE)-1;
-
-  	if (_lread32(hFile,&ne_header,sizeof(ne_header))!=sizeof(ne_header))
-		return 0;
-
-	if (ne_header.ne_magic != IMAGE_OS2_SIGNATURE) return 0;
-	size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
-	if( size > sizeof(NE_TYPEINFO) )
-	{
-	    pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
-	    if( pTypeInfo ) {
-		_llseek32(hFile, mz_header.e_lfanew+ne_header.resource_tab_offset, SEEK_SET);
-		if( _lread32( hFile, (char*)pTypeInfo, size) != size ) { 
-		    HeapFree( GetProcessHeap(), 0, pTypeInfo); 
-		    pTypeInfo = NULL;
-		}
-	    }
 	}
-  	*retptr = pTypeInfo;
-        return IMAGE_OS2_SIGNATURE;
-  } else
+	_llseek32( hFile, mz_header.e_lfanew, SEEK_SET );
+
+	if (_lread32( hFile, magic, sizeof(magic) ) != sizeof(magic))
+	  return 0;
+
+	_llseek32( hFile, mz_header.e_lfanew, SEEK_SET);
+
+	if (*(DWORD*)magic  == IMAGE_NT_SIGNATURE)
+	  return IMAGE_NT_SIGNATURE;
+
+	if (*(WORD*)magic == IMAGE_OS2_SIGNATURE)
+	{ IMAGE_OS2_HEADER	ne_header;
+	  LPBYTE		pTypeInfo = (LPBYTE)-1;
+
+	  if (_lread32(hFile,&ne_header,sizeof(ne_header))!=sizeof(ne_header))
+	    return 0;
+
+	  if (ne_header.ne_magic != IMAGE_OS2_SIGNATURE)
+	    return 0;
+
+	  size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
+
+	  if( size > sizeof(NE_TYPEINFO) )
+	  { pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
+	    if( pTypeInfo ) 
+	    { _llseek32(hFile, mz_header.e_lfanew+ne_header.resource_tab_offset, SEEK_SET);
+	      if( _lread32( hFile, (char*)pTypeInfo, size) != size )
+	      { HeapFree( GetProcessHeap(), 0, pTypeInfo); 
+		pTypeInfo = NULL;
+	      }
+	    }
+	  }
+	  *retptr = pTypeInfo;
+	  return IMAGE_OS2_SIGNATURE;
+	}
   	return 0; /* failed */
 }
 
@@ -525,30 +531,32 @@
  *			SHELL_LoadResource
  */
 static HGLOBAL16 SHELL_LoadResource(HINSTANCE16 hInst, HFILE32 hFile, NE_NAMEINFO* pNInfo, WORD sizeShift)
-{ BYTE*  ptr;
- HGLOBAL16 handle = DirectResAlloc( hInst, 0x10, (DWORD)pNInfo->length << sizeShift);
-  TRACE(shell,"\n");
- if( (ptr = (BYTE*)GlobalLock16( handle )) )
-  { _llseek32( hFile, (DWORD)pNInfo->offset << sizeShift, SEEK_SET);
-     _lread32( hFile, (char*)ptr, pNInfo->length << sizeShift);
-     return handle;
-   }
- return 0;
+{	BYTE*  ptr;
+	HGLOBAL16 handle = DirectResAlloc( hInst, 0x10, (DWORD)pNInfo->length << sizeShift);
+
+	TRACE(shell,"\n");
+
+	if( (ptr = (BYTE*)GlobalLock16( handle )) )
+	{ _llseek32( hFile, (DWORD)pNInfo->offset << sizeShift, SEEK_SET);
+	  _lread32( hFile, (char*)ptr, pNInfo->length << sizeShift);
+	  return handle;
+	}
+	return 0;
 }
 
 /*************************************************************************
  *                      ICO_LoadIcon
  */
 static HGLOBAL16 ICO_LoadIcon(HINSTANCE16 hInst, HFILE32 hFile, LPicoICONDIRENTRY lpiIDE)
-{ BYTE*  ptr;
- HGLOBAL16 handle = DirectResAlloc( hInst, 0x10, lpiIDE->dwBytesInRes);
-  TRACE(shell,"\n");
- if( (ptr = (BYTE*)GlobalLock16( handle )) )
-  { _llseek32( hFile, lpiIDE->dwImageOffset, SEEK_SET);
-     _lread32( hFile, (char*)ptr, lpiIDE->dwBytesInRes);
-     return handle;
-   }
- return 0;
+{	BYTE*  ptr;
+	HGLOBAL16 handle = DirectResAlloc( hInst, 0x10, lpiIDE->dwBytesInRes);
+	TRACE(shell,"\n");
+	if( (ptr = (BYTE*)GlobalLock16( handle )) )
+	{ _llseek32( hFile, lpiIDE->dwImageOffset, SEEK_SET);
+	  _lread32( hFile, (char*)ptr, lpiIDE->dwBytesInRes);
+	  return handle;
+	}
+	return 0;
 }
 
 /*************************************************************************
@@ -605,274 +613,259 @@
  * This abortion is called directly by Progman
  */
 HGLOBAL16 WINAPI InternalExtractIcon(HINSTANCE16 hInstance,
-                                     LPCSTR lpszExeFileName, UINT16 nIconIndex,
-                                     WORD n )
-{
-  HGLOBAL16 	hRet = 0;
-  HGLOBAL16*	RetPtr = NULL;
-  LPBYTE  	pData;
-  OFSTRUCT 	ofs;
-  DWORD		sig;
-  HFILE32 	hFile = OpenFile32( lpszExeFileName, &ofs, OF_READ );
-  UINT16	iconDirCount = 0,iconCount = 0;
-  
-  TRACE(shell,"(%04x,file %s,start %d,extract %d\n", 
+                                     LPCSTR lpszExeFileName, UINT16 nIconIndex, WORD n )
+{	HGLOBAL16	hRet = 0;
+	HGLOBAL16*	RetPtr = NULL;
+	LPBYTE		pData;
+	OFSTRUCT	ofs;
+	DWORD		sig;
+	HFILE32		hFile = OpenFile32( lpszExeFileName, &ofs, OF_READ );
+	UINT16		iconDirCount = 0,iconCount = 0;
+	LPBYTE		peimage;
+	HANDLE32	fmapping;
+	
+	TRACE(shell,"(%04x,file %s,start %d,extract %d\n", 
 		       hInstance, lpszExeFileName, nIconIndex, n);
 
-  if( hFile == HFILE_ERROR32 || !n )
-    return 0;
+	if( hFile == HFILE_ERROR32 || !n )
+	  return 0;
 
-  hRet = GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, sizeof(HICON16)*n);
-  RetPtr = (HICON16*)GlobalLock16(hRet);
+	hRet = GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, sizeof(HICON16)*n);
+	RetPtr = (HICON16*)GlobalLock16(hRet);
 
-  *RetPtr = (n == 0xFFFF)? 0: 1;	/* error return values */
+	*RetPtr = (n == 0xFFFF)? 0: 1;	/* error return values */
 
-  sig = SHELL_GetResourceTable(hFile,&pData);
+	sig = SHELL_GetResourceTable(hFile,&pData);
 
-  if((sig == IMAGE_OS2_SIGNATURE)
-  || (sig == 1)) /* .ICO file */
-  {
-    HICON16	 hIcon = 0;
-    NE_TYPEINFO* pTInfo = (NE_TYPEINFO*)(pData + 2);
-    NE_NAMEINFO* pIconStorage = NULL;
-    NE_NAMEINFO* pIconDir = NULL;
-    LPicoICONDIR lpiID = NULL;
+	if( sig==IMAGE_OS2_SIGNATURE || sig==1 ) /* .ICO file */
+	{ HICON16	 hIcon = 0;
+	  NE_TYPEINFO* pTInfo = (NE_TYPEINFO*)(pData + 2);
+	  NE_NAMEINFO* pIconStorage = NULL;
+	  NE_NAMEINFO* pIconDir = NULL;
+	  LPicoICONDIR lpiID = NULL;
  
-    if( pData == (BYTE*)-1 )
-    {
-	/* check for .ICO file */
-
-	hIcon = ICO_GetIconDirectory(hInstance, hFile, &lpiID);
-	if( hIcon ) { iconDirCount = 1; iconCount = lpiID->idCount; }
-    }
-    else while( pTInfo->type_id && !(pIconStorage && pIconDir) )
-    {
-	/* find icon directory and icon repository */
-
-	if( pTInfo->type_id == NE_RSCTYPE_GROUP_ICON ) 
-	  {
-	     iconDirCount = pTInfo->count;
-	     pIconDir = ((NE_NAMEINFO*)(pTInfo + 1));
-       TRACE(shell,"\tfound directory - %i icon families\n", iconDirCount);
-	  }
-	if( pTInfo->type_id == NE_RSCTYPE_ICON ) 
-	  { 
-	     iconCount = pTInfo->count;
-	     pIconStorage = ((NE_NAMEINFO*)(pTInfo + 1));
-       TRACE(shell,"\ttotal icons - %i\n", iconCount);
-	  }
-  	pTInfo = (NE_TYPEINFO *)((char*)(pTInfo+1)+pTInfo->count*sizeof(NE_NAMEINFO));
-    }
-
-    /* load resources and create icons */
-
-    if( (pIconStorage && pIconDir) || lpiID )
-    {
-      if( nIconIndex == (UINT16)-1 ) RetPtr[0] = iconDirCount;
-      else if( nIconIndex < iconDirCount )
-      {
-	  UINT16   i, icon;
-
-	  if( n > iconDirCount - nIconIndex ) n = iconDirCount - nIconIndex;
-
-	  for( i = nIconIndex; i < nIconIndex + n; i++ ) 
-	  {
-	      /* .ICO files have only one icon directory */
-
-	      if( lpiID == NULL )
-	           hIcon = SHELL_LoadResource( hInstance, hFile, pIconDir + i, 
-							      *(WORD*)pData );
-	      RetPtr[i-nIconIndex] = GetIconID( hIcon, 3 );
-	      GlobalFree16(hIcon); 
-          }
-
-	  for( icon = nIconIndex; icon < nIconIndex + n; icon++ )
-	  {
-	      hIcon = 0;
-	      if( lpiID )
-		   hIcon = ICO_LoadIcon( hInstance, hFile, 
-					 lpiID->idEntries + RetPtr[icon-nIconIndex]);
-	      else
-	         for( i = 0; i < iconCount; i++ )
-		   if( pIconStorage[i].id == (RetPtr[icon-nIconIndex] | 0x8000) )
-		     hIcon = SHELL_LoadResource( hInstance, hFile, pIconStorage + i,
-								    *(WORD*)pData );
-	      if( hIcon )
-	      {
-		  RetPtr[icon-nIconIndex] = LoadIconHandler( hIcon, TRUE ); 
-		  FarSetOwner( RetPtr[icon-nIconIndex], GetExePtr(hInstance) );
-	      }
-	      else
-		  RetPtr[icon-nIconIndex] = 0;
-	  }
-      }
-    }
-    if( lpiID ) HeapFree( GetProcessHeap(), 0, lpiID);
-    else HeapFree( GetProcessHeap(), 0, pData);
-  } 
-  if( sig == IMAGE_NT_SIGNATURE)
-  {
-  	LPBYTE			peimage,idata,igdata;
-	PIMAGE_DOS_HEADER	dheader;
-	PIMAGE_NT_HEADERS	pe_header;
-	PIMAGE_SECTION_HEADER	pe_sections;
-	PIMAGE_RESOURCE_DIRECTORY	rootresdir,iconresdir,icongroupresdir;
-	PIMAGE_RESOURCE_DATA_ENTRY	idataent,igdataent;
-	HANDLE32		fmapping;
-	int			i,j;
-	PIMAGE_RESOURCE_DIRECTORY_ENTRY	xresent;
-	CURSORICONDIR		**cids;
-	
-	fmapping = CreateFileMapping32A(hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL);
-	if (fmapping == 0) { /* FIXME, INVALID_HANDLE_VALUE? */
-    WARN(shell,"failed to create filemap.\n");
-		_lclose32( hFile);
-		return 0;
-	}
-	peimage = MapViewOfFile(fmapping,FILE_MAP_READ,0,0,0);
-	if (!peimage) {
-    WARN(shell,"failed to mmap filemap.\n");
-		CloseHandle(fmapping);
-		_lclose32( hFile);
-		return 0;
-	}
-	dheader = (PIMAGE_DOS_HEADER)peimage;
-	/* it is a pe header, SHELL_GetResourceTable checked that */
-	pe_header = (PIMAGE_NT_HEADERS)(peimage+dheader->e_lfanew);
-	/* probably makes problems with short PE headers... but I haven't seen 
-	 * one yet... 
-	 */
-	pe_sections = (PIMAGE_SECTION_HEADER)(((char*)pe_header)+sizeof(*pe_header));
-	rootresdir = NULL;
-	for (i=0;i<pe_header->FileHeader.NumberOfSections;i++) {
-		if (pe_sections[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
-			continue;
-		/* FIXME: doesn't work when the resources are not in a seperate section */
-		if (pe_sections[i].VirtualAddress == pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress) {
-			rootresdir = (PIMAGE_RESOURCE_DIRECTORY)((char*)peimage+pe_sections[i].PointerToRawData);
-			break;
-		}
-	}
-
-	if (!rootresdir) {
-    WARN(shell,"haven't found section for resource directory.\n");
-		UnmapViewOfFile(peimage);
-		CloseHandle(fmapping);
-		_lclose32( hFile);
-		return 0;
-	}
-	icongroupresdir = GetResDirEntryW(rootresdir,RT_GROUP_ICON32W,
-                                          (DWORD)rootresdir,FALSE);
-	if (!icongroupresdir) {
-    WARN(shell,"No Icongroupresourcedirectory!\n");
-		UnmapViewOfFile(peimage);
-		CloseHandle(fmapping);
-		_lclose32( hFile);
-		return 0;
-	}
-
-	iconDirCount = icongroupresdir->NumberOfNamedEntries+icongroupresdir->NumberOfIdEntries;
-	if( nIconIndex == (UINT16)-1 ) {
-		RetPtr[0] = iconDirCount;
-		UnmapViewOfFile(peimage);
-		CloseHandle(fmapping);
-		_lclose32( hFile);
-		return hRet;
-	}
-
-	if (nIconIndex >= iconDirCount) {
-    WARN(shell,"nIconIndex %d is larger than iconDirCount %d\n",
-			    nIconIndex,iconDirCount);
-		UnmapViewOfFile(peimage);
-		CloseHandle(fmapping);
-		_lclose32( hFile);
-		GlobalFree16(hRet);
-		return 0;
-	}
-	cids = (CURSORICONDIR**)HeapAlloc(GetProcessHeap(),0,n*sizeof(CURSORICONDIR*));
-		
-	/* caller just wanted the number of entries */
-
-	xresent = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(icongroupresdir+1);
-	/* assure we don't get too much ... */
-	if( n > iconDirCount - nIconIndex ) n = iconDirCount - nIconIndex;
-
-	/* starting from specified index ... */
-	xresent = xresent+nIconIndex;
-
-	for (i=0;i<n;i++,xresent++) {
-		CURSORICONDIR	*cid;
-		PIMAGE_RESOURCE_DIRECTORY	resdir;
-
-		/* go down this resource entry, name */
-		resdir = (PIMAGE_RESOURCE_DIRECTORY)((DWORD)rootresdir+(xresent->u2.s.OffsetToDirectory));
-		/* default language (0) */
-		resdir = GetResDirEntryW(resdir,(LPWSTR)0,(DWORD)rootresdir,TRUE);
-		igdataent = (PIMAGE_RESOURCE_DATA_ENTRY)resdir;
-
-		/* lookup address in mapped image for virtual address */
-		igdata = NULL;
-		for (j=0;j<pe_header->FileHeader.NumberOfSections;j++) {
-			if (igdataent->OffsetToData < pe_sections[j].VirtualAddress)
-				continue;
-			if (igdataent->OffsetToData+igdataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
-				continue;
-			igdata = peimage+(igdataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
-		}
-		if (!igdata) {
-      WARN(shell,"no matching real address for icongroup!\n");
-			UnmapViewOfFile(peimage);
-			CloseHandle(fmapping);
-			_lclose32( hFile);
-			return 0;
-		}
-		/* found */
-		cid = (CURSORICONDIR*)igdata;
-		cids[i] = cid;
-		RetPtr[i] = LookupIconIdFromDirectoryEx32(igdata,TRUE,SYSMETRICS_CXICON,SYSMETRICS_CYICON,0);
-	}
-	iconresdir=GetResDirEntryW(rootresdir,RT_ICON32W,
-                                   (DWORD)rootresdir,FALSE);
-	if (!iconresdir) {
-      WARN(shell,"No Iconresourcedirectory!\n");
-	    UnmapViewOfFile(peimage);
-	    CloseHandle(fmapping);
-	    _lclose32( hFile);
-	    return 0;
-	}
-	for (i=0;i<n;i++) {
-	    PIMAGE_RESOURCE_DIRECTORY	xresdir;
-
-	    xresdir = GetResDirEntryW(iconresdir,(LPWSTR)RetPtr[i],(DWORD)rootresdir,FALSE);
-	    xresdir = GetResDirEntryW(xresdir,(LPWSTR)0,(DWORD)rootresdir,TRUE);
-
-	    idataent = (PIMAGE_RESOURCE_DATA_ENTRY)xresdir;
-
-	    idata = NULL;
-	    /* map virtual to address in image */
-	    for (j=0;j<pe_header->FileHeader.NumberOfSections;j++) {
-		if (idataent->OffsetToData < pe_sections[j].VirtualAddress)
-		    continue;
-		if (idataent->OffsetToData+idataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
-		    continue;
-		idata = peimage+(idataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
+	  if( pData == (BYTE*)-1 )
+	  { hIcon = ICO_GetIconDirectory(hInstance, hFile, &lpiID);	/* check for .ICO file */
+	    if( hIcon ) 
+	    { iconDirCount = 1; iconCount = lpiID->idCount; 
 	    }
-	    if (!idata) {
-    WARN(shell,"no matching real address found for icondata!\n");
-		RetPtr[i]=0;
+	  }
+	  else while( pTInfo->type_id && !(pIconStorage && pIconDir) )
+	  { if( pTInfo->type_id == NE_RSCTYPE_GROUP_ICON )	/* find icon directory and icon repository */
+	    { iconDirCount = pTInfo->count;
+	      pIconDir = ((NE_NAMEINFO*)(pTInfo + 1));
+	      TRACE(shell,"\tfound directory - %i icon families\n", iconDirCount);
+	    }
+	    if( pTInfo->type_id == NE_RSCTYPE_ICON ) 
+	    { iconCount = pTInfo->count;
+	      pIconStorage = ((NE_NAMEINFO*)(pTInfo + 1));
+	      TRACE(shell,"\ttotal icons - %i\n", iconCount);
+	    }
+	    pTInfo = (NE_TYPEINFO *)((char*)(pTInfo+1)+pTInfo->count*sizeof(NE_NAMEINFO));
+	  }
+
+	  /* load resources and create icons */
+
+	  if( (pIconStorage && pIconDir) || lpiID )
+	  { if( nIconIndex == (UINT16)-1 )
+	    { RetPtr[0] = iconDirCount;
+	    }
+	    else if( nIconIndex < iconDirCount )
+	    { UINT16   i, icon;
+	      if( n > iconDirCount - nIconIndex ) 
+	        n = iconDirCount - nIconIndex;
+
+	      for( i = nIconIndex; i < nIconIndex + n; i++ ) 
+	      { /* .ICO files have only one icon directory */
+
+	        if( lpiID == NULL )
+	          hIcon = SHELL_LoadResource( hInstance, hFile, pIconDir + i, *(WORD*)pData );
+	        RetPtr[i-nIconIndex] = GetIconID( hIcon, 3 );
+	        GlobalFree16(hIcon); 
+              }
+
+	      for( icon = nIconIndex; icon < nIconIndex + n; icon++ )
+	      { hIcon = 0;
+	        if( lpiID )
+	        { hIcon = ICO_LoadIcon( hInstance, hFile, lpiID->idEntries + RetPtr[icon-nIconIndex]);
+	        }
+	        else
+	        { for( i = 0; i < iconCount; i++ )
+	          { if( pIconStorage[i].id == (RetPtr[icon-nIconIndex] | 0x8000) )
+	            { hIcon = SHELL_LoadResource( hInstance, hFile, pIconStorage + i,*(WORD*)pData );
+	            }
+	          }
+	        }
+	        if( hIcon )
+	        { RetPtr[icon-nIconIndex] = LoadIconHandler( hIcon, TRUE ); 
+	          FarSetOwner( RetPtr[icon-nIconIndex], GetExePtr(hInstance) );
+	        }
+	        else
+	        { RetPtr[icon-nIconIndex] = 0;
+	        }
+	      }
+	    }
+	  }
+	  if( lpiID ) 
+	    HeapFree( GetProcessHeap(), 0, lpiID);
+	  else 
+	    HeapFree( GetProcessHeap(), 0, pData);
+	} 
+
+	if( sig == IMAGE_NT_SIGNATURE)
+	{ LPBYTE		idata,igdata;
+	  PIMAGE_DOS_HEADER	dheader;
+	  PIMAGE_NT_HEADERS	pe_header;
+	  PIMAGE_SECTION_HEADER	pe_sections;
+	  PIMAGE_RESOURCE_DIRECTORY	rootresdir,iconresdir,icongroupresdir;
+	  PIMAGE_RESOURCE_DATA_ENTRY	idataent,igdataent;
+	  int			i,j;
+	  PIMAGE_RESOURCE_DIRECTORY_ENTRY	xresent;
+	  CURSORICONDIR		**cids;
+	
+	  fmapping = CreateFileMapping32A(hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL);
+	  if (fmapping == 0) 
+	  { /* FIXME, INVALID_HANDLE_VALUE? */
+	    WARN(shell,"failed to create filemap.\n");
+	    hRet = 0;
+	    goto end_2;	/* failure */
+	  }
+	  peimage = MapViewOfFile(fmapping,FILE_MAP_READ,0,0,0);
+	  if (!peimage) 
+	  { WARN(shell,"failed to mmap filemap.\n");
+	    hRet = 0;
+	    goto end_2;	/* failure */
+	  }
+	  dheader = (PIMAGE_DOS_HEADER)peimage;
+
+	  /* it is a pe header, SHELL_GetResourceTable checked that */
+	  pe_header = (PIMAGE_NT_HEADERS)(peimage+dheader->e_lfanew);
+
+	  /* probably makes problems with short PE headers... but I haven't seen 
+	  * one yet... 
+	  */
+	  pe_sections = (PIMAGE_SECTION_HEADER)(((char*)pe_header)+sizeof(*pe_header));
+	  rootresdir = NULL;
+
+	  for (i=0;i<pe_header->FileHeader.NumberOfSections;i++) 
+	  { if (pe_sections[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
+	      continue;
+	    /* FIXME: doesn't work when the resources are not in a seperate section */
+	    if (pe_sections[i].VirtualAddress == pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress) 
+	    { rootresdir = (PIMAGE_RESOURCE_DIRECTORY)((char*)peimage+pe_sections[i].PointerToRawData);
+	      break;
+	    }
+	  }
+
+	  if (!rootresdir) 
+	  { WARN(shell,"haven't found section for resource directory.\n");
+	    goto end_4;	/* failure */
+	  }
+
+	  icongroupresdir = GetResDirEntryW(rootresdir,RT_GROUP_ICON32W, (DWORD)rootresdir,FALSE);
+
+	  if (!icongroupresdir) 
+	  { WARN(shell,"No Icongroupresourcedirectory!\n");
+	    goto end_4;	/* failure */
+	  }
+
+	  iconDirCount = icongroupresdir->NumberOfNamedEntries+icongroupresdir->NumberOfIdEntries;
+
+	  if( nIconIndex == (UINT16)-1 ) 
+	  { RetPtr[0] = iconDirCount;
+	    goto end_3;	/* success */
+	  }
+
+	  if (nIconIndex >= iconDirCount) 
+	  { WARN(shell,"nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount);
+	    GlobalFree16(hRet);
+	    goto end_4;	/* failure */
+	  }
+
+	  cids = (CURSORICONDIR**)HeapAlloc(GetProcessHeap(),0,n*sizeof(CURSORICONDIR*));
+		
+	  /* caller just wanted the number of entries */
+	  xresent = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(icongroupresdir+1);
+
+	  /* assure we don't get too much ... */
+	  if( n > iconDirCount - nIconIndex ) 
+	  { n = iconDirCount - nIconIndex;
+	  }
+
+	  /* starting from specified index ... */
+	  xresent = xresent+nIconIndex;
+
+	  for (i=0;i<n;i++,xresent++) 
+	  { CURSORICONDIR	*cid;
+	    PIMAGE_RESOURCE_DIRECTORY	resdir;
+
+	    /* go down this resource entry, name */
+	    resdir = (PIMAGE_RESOURCE_DIRECTORY)((DWORD)rootresdir+(xresent->u2.s.OffsetToDirectory));
+
+	    /* default language (0) */
+	    resdir = GetResDirEntryW(resdir,(LPWSTR)0,(DWORD)rootresdir,TRUE);
+	    igdataent = (PIMAGE_RESOURCE_DATA_ENTRY)resdir;
+
+	    /* lookup address in mapped image for virtual address */
+	    igdata = NULL;
+
+	    for (j=0;j<pe_header->FileHeader.NumberOfSections;j++) 
+	    { if (igdataent->OffsetToData < pe_sections[j].VirtualAddress)
+	        continue;
+	      if (igdataent->OffsetToData+igdataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
 		continue;
+	      igdata = peimage+(igdataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
+	    }
+
+	    if (!igdata) 
+	    { WARN(shell,"no matching real address for icongroup!\n");
+	      goto end_4;	/* failure */
+	    }
+	    /* found */
+	    cid = (CURSORICONDIR*)igdata;
+	    cids[i] = cid;
+	    RetPtr[i] = LookupIconIdFromDirectoryEx32(igdata,TRUE,SYSMETRICS_CXICON,SYSMETRICS_CYICON,0);
+	  }
+
+	  iconresdir=GetResDirEntryW(rootresdir,RT_ICON32W,(DWORD)rootresdir,FALSE);
+
+	  if (!iconresdir) 
+	  { WARN(shell,"No Iconresourcedirectory!\n");
+	    goto end_4;	/* failure */
+	  }
+
+	  for (i=0;i<n;i++) 
+	  { PIMAGE_RESOURCE_DIRECTORY	xresdir;
+	    xresdir = GetResDirEntryW(iconresdir,(LPWSTR)(DWORD)RetPtr[i],(DWORD)rootresdir,FALSE);
+	    xresdir = GetResDirEntryW(xresdir,(LPWSTR)0,(DWORD)rootresdir,TRUE);
+	    idataent = (PIMAGE_RESOURCE_DATA_ENTRY)xresdir;
+	    idata = NULL;
+
+	    /* map virtual to address in image */
+	    for (j=0;j<pe_header->FileHeader.NumberOfSections;j++) 
+	    { if (idataent->OffsetToData < pe_sections[j].VirtualAddress)
+	        continue;
+	      if (idataent->OffsetToData+idataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
+	        continue;
+	      idata = peimage+(idataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
+	    }
+	    if (!idata) 
+	    { WARN(shell,"no matching real address found for icondata!\n");
+	      RetPtr[i]=0;
+	      continue;
 	    }
 	    RetPtr[i] = CreateIconFromResourceEx32(idata,idataent->Size,TRUE,0x00030000,SYSMETRICS_CXICON,SYSMETRICS_CYICON,0);
+	  }
+	  goto end_3;	/* sucess */
 	}
-	UnmapViewOfFile(peimage);
-	CloseHandle(fmapping);
-	_lclose32( hFile);
-	return hRet;
-  }
-  _lclose32( hFile );
-  /* return array with icon handles */
-  return hRet;
+	goto end_1;	/* return array with icon handles */
 
+/* cleaning up (try & catch would be nicer) */
+end_4:	hRet = 0;	/* failure */
+end_3:	UnmapViewOfFile(peimage);	/* success */
+end_2:	CloseHandle(fmapping);
+end_1:	_lclose32( hFile);
+	return hRet;
 }
 
 /*************************************************************************
@@ -892,43 +885,41 @@
  * Return icon for given file (either from file itself or from associated
  * executable) and patch parameters if needed.
  */
-HICON32 WINAPI ExtractAssociatedIcon32A(HINSTANCE32 hInst,LPSTR lpIconPath,
-	LPWORD lpiIcon)
-{ TRACE(shell,"\n");
+HICON32 WINAPI ExtractAssociatedIcon32A(HINSTANCE32 hInst, LPSTR lpIconPath, LPWORD lpiIcon)
+{	TRACE(shell,"\n");
 	return ExtractAssociatedIcon16(hInst,lpIconPath,lpiIcon);
 }
 
-HICON16 WINAPI ExtractAssociatedIcon16(HINSTANCE16 hInst,LPSTR lpIconPath,
-	LPWORD lpiIcon)
-{ HICON16 hIcon;
+HICON16 WINAPI ExtractAssociatedIcon16(HINSTANCE16 hInst, LPSTR lpIconPath, LPWORD lpiIcon)
+{	HICON16 hIcon;
 
-  TRACE(shell,"\n");
+	TRACE(shell,"\n");
 
-  hIcon = ExtractIcon16(hInst, lpIconPath, *lpiIcon);
+	hIcon = ExtractIcon16(hInst, lpIconPath, *lpiIcon);
 
-  if( hIcon < 2 )
-  { if( hIcon == 1 ) /* no icons found in given file */
-    { char  tempPath[0x80];
+	if( hIcon < 2 )
+	{ if( hIcon == 1 ) /* no icons found in given file */
+	  { char  tempPath[0x80];
 	    UINT16  uRet = FindExecutable16(lpIconPath,NULL,tempPath);
 
 	    if( uRet > 32 && tempPath[0] )
-      { strcpy(lpIconPath,tempPath);
-		hIcon = ExtractIcon16(hInst, lpIconPath, *lpiIcon);
-        if( hIcon > 2 ) 
-          return hIcon;
+	    { strcpy(lpIconPath,tempPath);
+	      hIcon = ExtractIcon16(hInst, lpIconPath, *lpiIcon);
+	      if( hIcon > 2 ) 
+	        return hIcon;
 	    }
 	    else hIcon = 0;
-	}
+	  }
 
-	if( hIcon == 1 ) 
+	  if( hIcon == 1 ) 
 	    *lpiIcon = 2;   /* MSDOS icon - we found .exe but no icons in it */
-	else
+	  else
 	    *lpiIcon = 6;   /* generic icon - found nothing */
 
-	GetModuleFileName16(hInst, lpIconPath, 0x80);
-	hIcon = LoadIcon16( hInst, MAKEINTRESOURCE16(*lpiIcon));
-    }
-    return hIcon;
+	  GetModuleFileName16(hInst, lpIconPath, 0x80);
+	  hIcon = LoadIcon16( hInst, MAKEINTRESOURCE16(*lpiIcon));
+	}
+	return hIcon;
 }
 
 /*************************************************************************
diff --git a/relay32/shell32.spec b/relay32/shell32.spec
index 5b81549..d7be1c5 100644
--- a/relay32/shell32.spec
+++ b/relay32/shell32.spec
@@ -8,18 +8,18 @@
 # This list was updated to dll version 4.72
 
    2 stdcall SHChangeNotifyRegister(long long long long long long) SHChangeNotifyRegister
-   3 stub CheckEscapesA   # exported by name
+   3 stub CheckEscapesA@8
    4 stdcall SHChangeNotifyDeregister (long long) SHChangeNotifyDeregister
    5 stub SHChangeNotifyUpdateEntryList@16
-   6 stub CheckEscapesW   # exported by name
-   7 stdcall CommandLineToArgvW(wstr ptr) CommandLineToArgvW   # exported by name
-   8 stub Control_FillCache_RunDLL@16   # exported by name
+   6 stub CheckEscapesW@8
+   7 stdcall CommandLineToArgvW(wstr ptr) CommandLineToArgvW
+   8 stub Control_FillCache_RunDLL@16
    9 stub PifMgr_OpenProperties@16
   10 stub PifMgr_GetProperties@20
   11 stub PifMgr_SetProperties@20
-  12 stub Control_FillCache_RunDLLA   # exported by name
+  12 stub Control_FillCache_RunDLLA@16
   13 stub PifMgr_CloseProperties@8
-  14 stub Control_FillCache_RunDLLW@16   # exported by name
+  14 stub Control_FillCache_RunDLLW@16
   15 stdcall ILGetDisplayName(ptr ptr) ILGetDisplayName
   16 stdcall ILFindLastID(ptr) ILFindLastID
   17 stdcall ILRemoveLastID(ptr) ILRemoveLastID
@@ -28,7 +28,7 @@
   20 stub ILGlobalClone@4
   21 stdcall ILIsEqual (ptr ptr) ILIsEqual
   22 stdcall Control_RunDLL(long long long long) Control_RunDLL # exported by name
-  23 stub ILIsParent@12
+  23 stdcall ILIsParent (long long long) ILIsParent
   24 stdcall ILFindChild (long long) ILFindChild
   25 stdcall ILCombine(ptr ptr) ILCombine
   26 stub ILLoadFromStream@8
@@ -45,26 +45,26 @@
   37 stdcall PathCombine(ptr ptr ptr) PathCombine32AW
   38 stub PathStripPath
   39 stdcall PathIsUNC(str) PathIsUNC
-  40 stub PathIsRelative
-  41 stub Control_RunDLLA   # exported by name
-  42 stub Control_RunDLLW   # exported by name
+  40 stub PathIsRelative@4
+  41 stub Control_RunDLLA@16
+  42 stub Control_RunDLLW@16
   43 stdcall PathIsExe (ptr) PathIsExe
-  44 stub DoEnvironmentSubstA   # exported by name
+  44 stub DoEnvironmentSubstA@8
   45 stdcall PathFileExists(str) PathFileExists
   46 stdcall PathMatchSpec (str str) PathMatchSpec
   47 stub PathMakeUniqueName@20
   48 stub PathSetDlgItemPath@12
   49 stub PathQualify@4
-  50 stub PathStripToRoot
+  50 stub PathStripToRoot@4
   51 stdcall PathResolve(str long long) PathResolve
   52 stdcall PathGetArgs(str) PathGetArgs
-  53 stub DoEnvironmentSubstW@8  # exported by name
+  53 stub DoEnvironmentSubstW@8
   54 stdcall DragAcceptFiles(long long) DragAcceptFiles32
-  55 stub PathQuoteSpaces
+  55 stdcall PathQuoteSpaces (ptr) PathQuoteSpaces32AW
   56 stdcall PathUnquoteSpaces(str) PathUnquoteSpaces
   57 stdcall PathGetDriveNumber (str) PathGetDriveNumber32
   58 stdcall ParseField(str long str long) ParseField
-  59 stub RestartDialog
+  59 stub RestartDialog@12
   60 stdcall ExitWindowsDialog(long) ExitWindowsDialog
   61 stdcall RunFileDlg(long long long str str long) RunFileDlg
   62 stdcall PickIconDlg(long long long long) PickIconDlg
@@ -194,9 +194,9 @@
  186 stub ExtractAssociatedIconExW   # exported by name
  187 stub ExtractAssociatedIconW   # exported by name
  188 stdcall ExtractIconA(long str long) ExtractIcon32A   # exported by name
- 189 stub ExtractIconEx   # exported by name
- 190 stub ExtractIconExA   # exported by name
- 191 stub ExtractIconExW   # exported by name
+ 189 stdcall ExtractIconEx(ptr long ptr ptr long) ExtractIconEx32AW
+ 190 stdcall ExtractIconExA(str long ptr ptr long) ExtractIconEx32A
+ 191 stdcall ExtractIconExW(wstr long ptr ptr long) ExtractIconEx32W
  192 stub ExtractIconResInfoA   # exported by name
  193 stub ExtractIconResInfoW   # exported by name
  194 stdcall ExtractIconW(long wstr long) ExtractIcon32W   # exported by name
@@ -297,9 +297,9 @@
  288 stdcall ShellAboutA(long str str long) ShellAbout32A
  289 stdcall ShellAboutW(long wstr wstr long) ShellAbout32W
  290 stdcall ShellExecuteA(long str str str str long) ShellExecute32A
- 291 stdcall ShellExecuteEx (long) ShellExecuteEx32A
+ 291 stdcall ShellExecuteEx (long) ShellExecuteEx32
  292 stdcall ShellExecuteExA (long) ShellExecuteEx32A
- 293 stub ShellExecuteExW
+ 293 stdcall ShellExecuteExW (long) ShellExecuteEx32W
  294 stub ShellExecuteW
  295 stub ShellHookProc   # exported by name
  296 stdcall Shell_NotifyIcon(long ptr) Shell_NotifyIcon
@@ -339,7 +339,7 @@
 
  505 stdcall SHRegCloseKey (long) SHRegCloseKey32
  506 stdcall SHRegOpenKeyA (long str long) SHRegOpenKey32A
- 507 stdcall SHRegOpenKeyW (long wstr long long) SHRegOpenKey32W
+ 507 stdcall SHRegOpenKeyW (long wstr long) SHRegOpenKey32W
  508 stub SHRegQueryValueA@16
  509 stdcall SHRegQueryValueExA(long str ptr ptr ptr ptr) SHRegQueryValueEx32A
  510 stdcall SHRegQueryValueW (long long long long) SHRegQueryValue32W
@@ -366,7 +366,7 @@
  650 stub PathIsSameRoot@8
  651 stdcall ReadCabinetState (long long) ReadCabinetState 
  652 stdcall WriteCabinetState (long) WriteCabinetState
- 653 stub PathProcessCommand@16
+ 653 stdcall PathProcessCommand (long long long long) PathProcessCommand
 
  660 stdcall FileIconInit (long) FileIconInit