ReactOS 0.4.15-dev-7958-gcd0bb1a
iconcache.cpp File Reference
#include "precomp.h"
Include dependency graph for iconcache.cpp:

Go to the source code of this file.

Classes

struct  SIC_ENTRY
 

Namespaces

namespace  anonymous_namespace{iconcache.cpp}
 

Macros

#define INVALID_INDEX   -1
 

Typedefs

typedef struct SIC_ENTRYLPSIC_ENTRY
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static INT CALLBACK SIC_CompareEntries (LPVOID p1, LPVOID p2, LPARAM lparam)
 
static int SIC_LoadOverlayIcon (int icon_idx)
 
static HICON SIC_OverlayShortcutImage (HICON SourceIcon, BOOL large)
 
static INT SIC_IconAppend (LPCWSTR sSourceFile, INT dwSourceIndex, HICON hSmallIcon, HICON hBigIcon, DWORD dwFlags)
 
static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags)
 
INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags)
 
BOOL SIC_Initialize (void)
 
static INT CALLBACK sic_free (LPVOID ptr, LPVOID lparam)
 
void SIC_Destroy (void)
 
BOOL WINAPI Shell_GetImageLists (HIMAGELIST *lpBigList, HIMAGELIST *lpSmallList)
 
BOOL PidlToSicIndex (IShellFolder *sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, int *pIndex)
 
int WINAPI SHMapPIDLToSystemImageListIndex (IShellFolder *sh, LPCITEMIDLIST pidl, int *pIndex)
 
EXTERN_C HRESULT WINAPI SHMapIDListToImageListIndexAsync (IShellTaskScheduler *pts, IShellFolder *psf, LPCITEMIDLIST pidl, UINT flags, PFNASYNCICONTASKBALLBACK pfn, void *pvData, void *pvHint, int *piIndex, int *piIndexSel)
 
INT WINAPI Shell_GetCachedImageIndexA (LPCSTR szPath, INT nIndex, UINT bSimulateDoc)
 
INT WINAPI Shell_GetCachedImageIndexW (LPCWSTR szPath, INT nIndex, UINT bSimulateDoc)
 
EXTERN_C INT WINAPI Shell_GetCachedImageIndexAW (LPCVOID szPath, INT nIndex, BOOL bSimulateDoc)
 
EXTERN_C INT WINAPI Shell_GetCachedImageIndex (LPCWSTR szPath, INT nIndex, UINT bSimulateDoc)
 
UINT WINAPI ExtractIconExW (LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
 
UINT WINAPI ExtractIconExA (LPCSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
 
HICON WINAPI ExtractAssociatedIconA (HINSTANCE hInst, LPSTR lpIconPath, LPWORD lpiIcon)
 
HICON WINAPI ExtractAssociatedIconW (HINSTANCE hInst, LPWSTR lpIconPath, LPWORD lpiIcon)
 
EXTERN_C HICON WINAPI ExtractAssociatedIconExW (HINSTANCE hInst, LPWSTR lpIconPath, LPWORD lpiIconIdx, LPWORD lpiIconId)
 
EXTERN_C HICON WINAPI ExtractAssociatedIconExA (HINSTANCE hInst, LPSTR lpIconPath, LPWORD lpiIconIdx, LPWORD lpiIconId)
 
HRESULT WINAPI SHDefExtractIconW (LPCWSTR pszIconFile, int iIndex, UINT uFlags, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
 
HRESULT WINAPI SHDefExtractIconA (LPCSTR pszIconFile, int iIndex, UINT uFlags, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
 
EXTERN_C INT WINAPI SHGetIconOverlayIndexA (LPCSTR pszIconPath, INT iIconIndex)
 
EXTERN_C INT WINAPI SHGetIconOverlayIndexW (LPCWSTR pszIconPath, INT iIconIndex)
 

Variables

static HDPA sic_hdpa = 0
 
static HIMAGELIST ShellSmallIconList
 
static HIMAGELIST ShellBigIconList
 
CRITICAL_SECTION anonymous_namespace{iconcache.cpp}::SHELL32_SicCS = { &critsect_debug, -1, 0, 0, 0, 0 }
 
CRITICAL_SECTION_DEBUG anonymous_namespace{iconcache.cpp}::critsect_debug
 

Macro Definition Documentation

◆ INVALID_INDEX

#define INVALID_INDEX   -1

Definition at line 27 of file iconcache.cpp.

Typedef Documentation

◆ LPSIC_ENTRY

Function Documentation

◆ ExtractAssociatedIconA()

HICON WINAPI ExtractAssociatedIconA ( HINSTANCE  hInst,
LPSTR  lpIconPath,
LPWORD  lpiIcon 
)

Definition at line 908 of file iconcache.cpp.

909{
910 HICON hIcon = NULL;
911 INT len = MultiByteToWideChar(CP_ACP, 0, lpIconPath, -1, NULL, 0);
912 /* Note that we need to allocate MAX_PATH, since we are supposed to fill
913 * the correct executable if there is no icon in lpIconPath directly.
914 * lpIconPath itself is supposed to be large enough, so make sure lpIconPathW
915 * is large enough too. Yes, I am puking too.
916 */
917 LPWSTR lpIconPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
918
919 TRACE("%p %s %p\n", hInst, debugstr_a(lpIconPath), lpiIcon);
920
921 if (lpIconPathW)
922 {
923 MultiByteToWideChar(CP_ACP, 0, lpIconPath, -1, lpIconPathW, len);
924 hIcon = ExtractAssociatedIconW(hInst, lpIconPathW, lpiIcon);
925 WideCharToMultiByte(CP_ACP, 0, lpIconPathW, -1, lpIconPath, MAX_PATH , NULL, NULL);
926 HeapFree(GetProcessHeap(), 0, lpIconPathW);
927 }
928 return hIcon;
929}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
HINSTANCE hInst
Definition: dxdiag.c:13
GLenum GLsizei len
Definition: glext.h:6722
HICON WINAPI ExtractAssociatedIconW(HINSTANCE hInst, LPWSTR lpIconPath, LPWORD lpiIcon)
Definition: iconcache.cpp:937
#define debugstr_a
Definition: kernel32.h:31
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
#define TRACE(s)
Definition: solgame.cpp:4
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by test_ExtractAssociatedIcon().

◆ ExtractAssociatedIconExA()

EXTERN_C HICON WINAPI ExtractAssociatedIconExA ( HINSTANCE  hInst,
LPSTR  lpIconPath,
LPWORD  lpiIconIdx,
LPWORD  lpiIconId 
)

Definition at line 991 of file iconcache.cpp.

992{
993 HICON ret;
994 INT len = MultiByteToWideChar( CP_ACP, 0, lpIconPath, -1, NULL, 0 );
995 LPWSTR lpwstrFile = (LPWSTR)HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
996
997 TRACE("%p %s %p %p)\n", hInst, lpIconPath, lpiIconIdx, lpiIconId);
998
999 MultiByteToWideChar( CP_ACP, 0, lpIconPath, -1, lpwstrFile, len );
1000 ret = ExtractAssociatedIconExW(hInst, lpwstrFile, lpiIconIdx, lpiIconId);
1001 HeapFree(GetProcessHeap(), 0, lpwstrFile);
1002 return ret;
1003}
EXTERN_C HICON WINAPI ExtractAssociatedIconExW(HINSTANCE hInst, LPWSTR lpIconPath, LPWORD lpiIconIdx, LPWORD lpiIconId)
Definition: iconcache.cpp:979
int ret

◆ ExtractAssociatedIconExW()

EXTERN_C HICON WINAPI ExtractAssociatedIconExW ( HINSTANCE  hInst,
LPWSTR  lpIconPath,
LPWORD  lpiIconIdx,
LPWORD  lpiIconId 
)

Definition at line 979 of file iconcache.cpp.

980{
981 FIXME("%p %s %p %p): stub\n", hInst, debugstr_w(lpIconPath), lpiIconIdx, lpiIconId);
982 return 0;
983}
#define FIXME(fmt,...)
Definition: debug.h:111
#define debugstr_w
Definition: kernel32.h:32

Referenced by ExtractAssociatedIconExA().

◆ ExtractAssociatedIconW()

HICON WINAPI ExtractAssociatedIconW ( HINSTANCE  hInst,
LPWSTR  lpIconPath,
LPWORD  lpiIcon 
)

Definition at line 937 of file iconcache.cpp.

938{
939 HICON hIcon = NULL;
940 WORD wDummyIcon = 0;
941
942 TRACE("%p %s %p\n", hInst, debugstr_w(lpIconPath), lpiIcon);
943
944 if(lpiIcon == NULL)
945 lpiIcon = &wDummyIcon;
946
947 hIcon = ExtractIconW(hInst, lpIconPath, *lpiIcon);
948
949 if( hIcon < (HICON)2 )
950 { if( hIcon == (HICON)1 ) /* no icons found in given file */
951 { WCHAR tempPath[MAX_PATH];
952 HINSTANCE uRet = FindExecutableW(lpIconPath,NULL,tempPath);
953
954 if( uRet > (HINSTANCE)32 && tempPath[0] )
955 { wcscpy(lpIconPath,tempPath);
956 hIcon = ExtractIconW(hInst, lpIconPath, *lpiIcon);
957 if( hIcon > (HICON)2 )
958 return hIcon;
959 }
960 }
961
962 if( hIcon == (HICON)1 )
963 *lpiIcon = 2; /* MSDOS icon - we found .exe but no icons in it */
964 else
965 *lpiIcon = 6; /* generic icon - found nothing */
966
967 if (GetModuleFileNameW(hInst, lpIconPath, MAX_PATH))
969 }
970 return hIcon;
971}
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
unsigned short WORD
Definition: ntddk_ex.h:93
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
HICON WINAPI ExtractIconW(HINSTANCE hInstance, LPCWSTR lpszFile, UINT nIconIndex)
Definition: shell32_main.c:876
HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
Definition: shlexec.cpp:1257
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2075

Referenced by ExtractAssociatedIconA().

◆ ExtractIconExA()

UINT WINAPI ExtractIconExA ( LPCSTR  lpszFile,
INT  nIconIndex,
HICON phiconLarge,
HICON phiconSmall,
UINT  nIcons 
)

Definition at line 885 of file iconcache.cpp.

886{
887 UINT ret = 0;
888 INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0);
889 LPWSTR lpwstrFile = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
890
891 TRACE("%s %i %p %p %i\n", lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
892
893 if (lpwstrFile)
894 {
895 MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len);
896 ret = ExtractIconExW(lpwstrFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
897 HeapFree(GetProcessHeap(), 0, lpwstrFile);
898 }
899 return ret;
900}
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:849
unsigned int UINT
Definition: ndis.h:50

◆ ExtractIconExW()

UINT WINAPI ExtractIconExW ( LPCWSTR  lpszFile,
INT  nIconIndex,
HICON phiconLarge,
HICON phiconSmall,
UINT  nIcons 
)

Definition at line 849 of file iconcache.cpp.

850{
851 UINT ret = 0;
852
853 /* get entry point of undocumented function PrivateExtractIconExW() in user32 */
854#if defined(__CYGWIN__) || defined (__MINGW32__) || defined(_MSC_VER)
856
858 HMODULE hUser32 = GetModuleHandleA("user32");
859 PrivateExtractIconExW = (UINT(WINAPI*)(LPCWSTR,int,HICON*,HICON*,UINT)) GetProcAddress(hUser32, "PrivateExtractIconExW");
860
862 return ret;
863 }
864#endif
865
866 TRACE("%s %i %p %p %i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge, phiconSmall, nIcons);
867 ret = PrivateExtractIconExW(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
868
869 /* PrivateExtractIconExW() may return -1 if the provided file is not a valid PE image file or the said
870 * file couldn't be found. The behaviour is correct although ExtractIconExW() only returns the successfully
871 * extracted icons from a file. In such scenario, simply return 0.
872 */
873 if (ret == 0xFFFFFFFF)
874 {
875 WARN("Invalid file or couldn't be found - %s\n", debugstr_w(lpszFile));
876 ret = 0;
877 }
878
879 return ret;
880}
#define WARN(fmt,...)
Definition: debug.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define WINAPI
Definition: msvc.h:6
UINT WINAPI WINAPI PrivateExtractIconExW(LPCWSTR, int, HICON *, HICON *, UINT)
Definition: exticon.c:916
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by CAppsListView::AddApplication(), CShellLink::CreateShortcutIcon(), DoExtractIcon(), DoLoadIcons(), ExtractIconExA(), FileTypesDlg_OnItemChanging(), COpenWithList::GetIcon(), GetIconFromFile(), CNewMenu::Initialize(), CFileDefExt::InitOpensWithField(), SetupDiGetClassImageListExW(), SetupDiLoadClassIcon(), START_TEST(), CFileDefExt::UpdateFolderIcon(), and ViewTree_AddIcon().

◆ PidlToSicIndex()

BOOL PidlToSicIndex ( IShellFolder sh,
LPCITEMIDLIST  pidl,
BOOL  bBigIcon,
UINT  uFlags,
int pIndex 
)

Definition at line 709 of file iconcache.cpp.

715{
717 WCHAR szIconFile[MAX_PATH]; /* file containing the icon */
718 INT iSourceIndex; /* index or resID(negated) in this file */
719 BOOL ret = FALSE;
720 UINT dwFlags = 0;
721 int iShortcutDefaultIndex = INVALID_INDEX;
722
723 TRACE("sf=%p pidl=%p %s\n", sh, pidl, bBigIcon?"Big":"Small");
724
725 if (!sic_hdpa)
727
728 if (SUCCEEDED (sh->GetUIObjectOf(0, 1, &pidl, IID_NULL_PPV_ARG(IExtractIconW, &ei))))
729 {
730 if (SUCCEEDED(ei->GetIconLocation(uFlags &~ GIL_FORSHORTCUT, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags)))
731 {
732 *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex, uFlags);
733 ret = TRUE;
734 }
735 }
736
737 if (INVALID_INDEX == *pIndex) /* default icon when failed */
738 {
739 if (0 == (uFlags & GIL_FORSHORTCUT))
740 {
741 *pIndex = 0;
742 }
743 else
744 {
745 if (INVALID_INDEX == iShortcutDefaultIndex)
746 {
747 iShortcutDefaultIndex = SIC_LoadIcon(swShell32Name, 0, GIL_FORSHORTCUT);
748 }
749 *pIndex = (INVALID_INDEX != iShortcutDefaultIndex ? iShortcutDefaultIndex : 0);
750 }
751 }
752
753 return ret;
754
755}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UINT uFlags
Definition: api.c:59
unsigned int BOOL
Definition: ntddk_ex.h:94
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
INT SIC_GetIconIndex(LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags)
Definition: iconcache.cpp:440
static HDPA sic_hdpa
Definition: iconcache.cpp:38
BOOL SIC_Initialize(void)
Definition: iconcache.cpp:481
static INT SIC_LoadIcon(LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags)
Definition: iconcache.cpp:387
#define INVALID_INDEX
Definition: iconcache.cpp:27
#define SUCCEEDED(hr)
Definition: intsafe.h:50
_Out_ PULONG _Out_ PULONG pIndex
Definition: ndis.h:4565
short sh
Definition: format.c:272
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define IID_NULL_PPV_ARG(Itype, ppType)

Referenced by FM_InitMenuPopup(), SHGetFileInfoW(), and SHMapPIDLToSystemImageListIndex().

◆ SHDefExtractIconA()

HRESULT WINAPI SHDefExtractIconA ( LPCSTR  pszIconFile,
int  iIndex,
UINT  uFlags,
HICON phiconLarge,
HICON phiconSmall,
UINT  nIconSize 
)

Definition at line 1037 of file iconcache.cpp.

1039{
1040 HRESULT ret;
1041 INT len = MultiByteToWideChar(CP_ACP, 0, pszIconFile, -1, NULL, 0);
1042 LPWSTR lpwstrFile = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1043
1044 TRACE("%s %d 0x%08x %p %p %d\n", pszIconFile, iIndex, uFlags, phiconLarge, phiconSmall, nIconSize);
1045
1046 MultiByteToWideChar(CP_ACP, 0, pszIconFile, -1, lpwstrFile, len);
1047 ret = SHDefExtractIconW(lpwstrFile, iIndex, uFlags, phiconLarge, phiconSmall, nIconSize);
1048 HeapFree(GetProcessHeap(), 0, lpwstrFile);
1049 return ret;
1050}
HRESULT WINAPI SHDefExtractIconW(LPCWSTR pszIconFile, int iIndex, UINT uFlags, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
Definition: iconcache.cpp:1009

◆ SHDefExtractIconW()

HRESULT WINAPI SHDefExtractIconW ( LPCWSTR  pszIconFile,
int  iIndex,
UINT  uFlags,
HICON phiconLarge,
HICON phiconSmall,
UINT  nIconSize 
)

Definition at line 1009 of file iconcache.cpp.

1011{
1012 UINT ret;
1013 HICON hIcons[2];
1014 WARN("%s %d 0x%08x %p %p %d, semi-stub\n", debugstr_w(pszIconFile), iIndex, uFlags, phiconLarge, phiconSmall, nIconSize);
1015
1016 ret = PrivateExtractIconsW(pszIconFile, iIndex, nIconSize, nIconSize, hIcons, NULL, 2, LR_DEFAULTCOLOR);
1017 /* FIXME: deal with uFlags parameter which contains GIL_ flags */
1018 if (ret == 0xFFFFFFFF)
1019 return E_FAIL;
1020 if (ret > 0) {
1021 if (phiconLarge)
1022 *phiconLarge = hIcons[0];
1023 else
1024 DestroyIcon(hIcons[0]);
1025 if (phiconSmall)
1026 *phiconSmall = hIcons[1];
1027 else
1028 DestroyIcon(hIcons[1]);
1029 return S_OK;
1030 }
1031 return S_FALSE;
1032}
#define E_FAIL
Definition: ddrawi.h:102
#define S_OK
Definition: intsafe.h:52
#define S_FALSE
Definition: winerror.h:2357
UINT WINAPI PrivateExtractIconsW(_In_reads_(MAX_PATH) LPCWSTR szFileName, _In_ int nIconIndex, _In_ int cxIcon, _In_ int cyIcon, _Out_writes_opt_(nIcons) HICON *phicon, _Out_writes_opt_(nIcons) UINT *piconid, _In_ UINT nIcons, _In_ UINT flags)
#define LR_DEFAULTCOLOR
Definition: winuser.h:1087
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053

Referenced by CNetConUiObject::Extract(), CNtObjectFolderExtractIcon::Extract(), CRegistryFolderExtractIcon::Extract(), SHDefExtractIconA(), and SHDefExtractIconWrapW().

◆ Shell_GetCachedImageIndex()

EXTERN_C INT WINAPI Shell_GetCachedImageIndex ( LPCWSTR  szPath,
INT  nIndex,
UINT  bSimulateDoc 
)

Definition at line 838 of file iconcache.cpp.

839{
840 return Shell_GetCachedImageIndexAW(szPath, nIndex, bSimulateDoc);
841}
EXTERN_C INT WINAPI Shell_GetCachedImageIndexAW(LPCVOID szPath, INT nIndex, BOOL bSimulateDoc)
Definition: iconcache.cpp:832
LPCWSTR szPath
Definition: env.c:37

Referenced by CShellMenuCallback::OnGetInfo().

◆ Shell_GetCachedImageIndexA()

INT WINAPI Shell_GetCachedImageIndexA ( LPCSTR  szPath,
INT  nIndex,
UINT  bSimulateDoc 
)

Definition at line 807 of file iconcache.cpp.

808{
809 INT ret, len;
810 LPWSTR szTemp;
811
812 WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_a(szPath), nIndex, bSimulateDoc);
813
814 len = MultiByteToWideChar( CP_ACP, 0, szPath, -1, NULL, 0 );
815 szTemp = (LPWSTR)HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
816 MultiByteToWideChar( CP_ACP, 0, szPath, -1, szTemp, len );
817
818 ret = SIC_GetIconIndex( szTemp, nIndex, 0 );
819
820 HeapFree( GetProcessHeap(), 0, szTemp );
821
822 return ret;
823}

Referenced by Shell_GetCachedImageIndexAW().

◆ Shell_GetCachedImageIndexAW()

EXTERN_C INT WINAPI Shell_GetCachedImageIndexAW ( LPCVOID  szPath,
INT  nIndex,
BOOL  bSimulateDoc 
)

Definition at line 832 of file iconcache.cpp.

833{ if( SHELL_OsIsUnicode())
834 return Shell_GetCachedImageIndexW((LPCWSTR)szPath, nIndex, bSimulateDoc);
835 return Shell_GetCachedImageIndexA((LPCSTR)szPath, nIndex, bSimulateDoc);
836}
INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, UINT bSimulateDoc)
Definition: iconcache.cpp:807
INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, UINT bSimulateDoc)
Definition: iconcache.cpp:825
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:140
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by Shell_GetCachedImageIndex().

◆ Shell_GetCachedImageIndexW()

INT WINAPI Shell_GetCachedImageIndexW ( LPCWSTR  szPath,
INT  nIndex,
UINT  bSimulateDoc 
)

Definition at line 825 of file iconcache.cpp.

826{
827 WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_w(szPath), nIndex, bSimulateDoc);
828
829 return SIC_GetIconIndex(szPath, nIndex, 0);
830}

Referenced by Shell_GetCachedImageIndexAW().

◆ Shell_GetImageLists()

BOOL WINAPI Shell_GetImageLists ( HIMAGELIST lpBigList,
HIMAGELIST lpSmallList 
)

Definition at line 683 of file iconcache.cpp.

684{
685 TRACE("(%p,%p)\n",lpBigList,lpSmallList);
686
687 if (!sic_hdpa)
689
690 if (lpBigList)
691 *lpBigList = ShellBigIconList;
692
693 if (lpSmallList)
694 *lpSmallList = ShellSmallIconList;
695
696 return TRUE;
697}
static HIMAGELIST ShellSmallIconList
Definition: iconcache.cpp:40
static HIMAGELIST ShellBigIconList
Definition: iconcache.cpp:41

Referenced by CShellBrowser::BrowseToPath(), DisplayImageList(), FileMenu_DrawItem(), InitializeTreeView(), CDefView::InitList(), CDefView::OnNotify(), SHGetFileInfoW(), SHGetImageList(), and test_SHGetImageList().

◆ SHGetIconOverlayIndexA()

EXTERN_C INT WINAPI SHGetIconOverlayIndexA ( LPCSTR  pszIconPath,
INT  iIconIndex 
)

Definition at line 1057 of file iconcache.cpp.

1058{
1059 FIXME("%s, %d\n", debugstr_a(pszIconPath), iIconIndex);
1060
1061 return -1;
1062}

◆ SHGetIconOverlayIndexW()

EXTERN_C INT WINAPI SHGetIconOverlayIndexW ( LPCWSTR  pszIconPath,
INT  iIconIndex 
)

Definition at line 1069 of file iconcache.cpp.

1070{
1071 FIXME("%s, %d\n", debugstr_w(pszIconPath), iIconIndex);
1072
1073 return -1;
1074}

◆ SHMapIDListToImageListIndexAsync()

EXTERN_C HRESULT WINAPI SHMapIDListToImageListIndexAsync ( IShellTaskScheduler pts,
IShellFolder psf,
LPCITEMIDLIST  pidl,
UINT  flags,
PFNASYNCICONTASKBALLBACK  pfn,
void pvData,
void pvHint,
int piIndex,
int piIndexSel 
)

Definition at line 793 of file iconcache.cpp.

797{
798 FIXME("(%p, %p, %p, 0x%08x, %p, %p, %p, %p, %p)\n",
799 pts, psf, pidl, flags, pfn, pvData, pvHint, piIndex, piIndexSel);
800 return E_FAIL;
801}
GLbitfield flags
Definition: glext.h:7161
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749

◆ SHMapPIDLToSystemImageListIndex()

int WINAPI SHMapPIDLToSystemImageListIndex ( IShellFolder sh,
LPCITEMIDLIST  pidl,
int pIndex 
)

Definition at line 766 of file iconcache.cpp.

770{
771 int Index;
772 UINT uGilFlags = 0;
773
774 TRACE("(SF=%p,pidl=%p,%p)\n",sh,pidl,pIndex);
775 pdump(pidl);
776
777 if (SHELL_IsShortcut(pidl))
778 uGilFlags |= GIL_FORSHORTCUT;
779
780 if (pIndex)
781 if (!PidlToSicIndex ( sh, pidl, 1, uGilFlags, pIndex))
782 *pIndex = -1;
783
784 if (!PidlToSicIndex ( sh, pidl, 0, uGilFlags, &Index))
785 return -1;
786
787 return Index;
788}
void pdump(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:311
BOOL PidlToSicIndex(IShellFolder *sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, int *pIndex)
Definition: iconcache.cpp:709
BOOL SHELL_IsShortcut(LPCITEMIDLIST pidlLast)
Definition: shell32_main.c:383
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by CAddressEditBox::AddComboBoxItem(), CShellBrowser::BrowseToPath(), CISFBand::CreateSimpleToolbar(), CMenuSFToolbar::FillToolbar(), CExplorerBand::InsertItem(), CDefView::LV_ProdItem(), CDefView::LV_RenameItem(), CDefView::OnNotify(), and CAddressEditBox::RefreshAddress().

◆ SIC_CompareEntries()

static INT CALLBACK SIC_CompareEntries ( LPVOID  p1,
LPVOID  p2,
LPARAM  lparam 
)
static

Definition at line 61 of file iconcache.cpp.

62{ LPSIC_ENTRY e1 = (LPSIC_ENTRY)p1, e2 = (LPSIC_ENTRY)p2;
63
64 TRACE("%p %p %8lx\n", p1, p2, lparam);
65
66 /* Icons in the cache are keyed by the name of the file they are
67 * loaded from, their resource index and the fact if they have a shortcut
68 * icon overlay or not.
69 */
70 /* first the faster one */
71 if (e1->dwSourceIndex != e2->dwSourceIndex)
72 return (e1->dwSourceIndex < e2->dwSourceIndex) ? -1 : 1;
73
74 if ((e1->dwFlags & GIL_FORSHORTCUT) != (e2->dwFlags & GIL_FORSHORTCUT))
75 return ((e1->dwFlags & GIL_FORSHORTCUT) < (e2->dwFlags & GIL_FORSHORTCUT)) ? -1 : 1;
76
77 return wcsicmp(e1->sSourceFile,e2->sSourceFile);
78}
@ lparam
Definition: SystemMenu.c:31
#define wcsicmp
Definition: compat.h:15
struct SIC_ENTRY * LPSIC_ENTRY
Definition: iconcache.cpp:30
DWORD dwFlags
Definition: iconcache.cpp:34
DWORD dwSourceIndex
Definition: iconcache.cpp:32
LPWSTR sSourceFile
Definition: iconcache.cpp:31

Referenced by SIC_GetIconIndex(), and SIC_IconAppend().

◆ SIC_Destroy()

void SIC_Destroy ( void  )

Definition at line 629 of file iconcache.cpp.

630{
631 TRACE("\n");
632
634
636
637 sic_hdpa = NULL;
642
644 //DeleteCriticalSection(&SHELL32_SicCS); //static
645}
void WINAPI DPA_DestroyCallback(HDPA hdpa, PFNDPAENUMCALLBACK enumProc, LPVOID lParam)
Definition: dpa.c:1003
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
static INT CALLBACK sic_free(LPVOID ptr, LPVOID lparam)
Definition: iconcache.cpp:622
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

◆ sic_free()

static INT CALLBACK sic_free ( LPVOID  ptr,
LPVOID  lparam 
)
static

Definition at line 622 of file iconcache.cpp.

623{
624 HeapFree(GetProcessHeap(), 0, ((LPSIC_ENTRY)ptr)->sSourceFile);
625 SHFree(ptr);
626 return TRUE;
627}
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
static PVOID ptr
Definition: dispmode.c:27

Referenced by SIC_Destroy().

◆ SIC_GetIconIndex()

INT SIC_GetIconIndex ( LPCWSTR  sSourceFile,
INT  dwSourceIndex,
DWORD  dwFlags 
)

Definition at line 440 of file iconcache.cpp.

441{
442 SIC_ENTRY sice;
445
446 TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex);
447
448 GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL);
449 sice.sSourceFile = path;
450 sice.dwSourceIndex = dwSourceIndex;
451 sice.dwFlags = dwFlags;
452
453 if (!sic_hdpa)
455
457
458 if (NULL != DPA_GetPtr (sic_hdpa, 0))
459 {
460 /* search linear from position 0*/
462 }
463
464 if ( INVALID_INDEX == index )
465 {
466 ret = SIC_LoadIcon (sSourceFile, dwSourceIndex, dwFlags);
467 }
468 else
469 {
470 TRACE("-- found\n");
471 ret = ((LPSIC_ENTRY)DPA_GetPtr(sic_hdpa, index))->dwListIndex;
472 }
473
475 return ret;
476}
INT WINAPI DPA_Search(HDPA hdpa, LPVOID pFind, INT nStart, PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
Definition: dpa.c:845
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
GLuint index
Definition: glext.h:6031
static INT CALLBACK SIC_CompareEntries(LPVOID p1, LPVOID p2, LPARAM lparam)
Definition: iconcache.cpp:61
#define DPAS_SORTED
Definition: commctrl.h:4862
#define DPA_GetPtr
Definition: commctrl.h:5

Referenced by PidlToSicIndex(), Shell_GetCachedImageIndexA(), Shell_GetCachedImageIndexW(), and SHGetFileInfoW().

◆ SIC_IconAppend()

static INT SIC_IconAppend ( LPCWSTR  sSourceFile,
INT  dwSourceIndex,
HICON  hSmallIcon,
HICON  hBigIcon,
DWORD  dwFlags 
)
static

Definition at line 323 of file iconcache.cpp.

324{
325 LPSIC_ENTRY lpsice;
326 INT ret, index, index1, indexDPA;
328 TRACE("%s %i %p %p\n", debugstr_w(sSourceFile), dwSourceIndex, hSmallIcon ,hBigIcon);
329
330 lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY));
331
332 GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL);
333 lpsice->sSourceFile = (LPWSTR)HeapAlloc( GetProcessHeap(), 0, (wcslen(path)+1)*sizeof(WCHAR) );
334 wcscpy( lpsice->sSourceFile, path );
335
336 lpsice->dwSourceIndex = dwSourceIndex;
337 lpsice->dwFlags = dwFlags;
338
340
342 indexDPA = DPA_InsertPtr(sic_hdpa, indexDPA, lpsice);
343 if ( -1 == indexDPA )
344 {
346 goto leave;
347 }
348
350 index1= ImageList_AddIcon (ShellBigIconList, hBigIcon);
351
352 /* Something went wrong when allocating a new image in the list. Abort. */
353 if((index == -1) || (index1 == -1))
354 {
355 WARN("Something went wrong when adding the icon to the list: small - 0x%x, big - 0x%x.\n",
356 index, index1);
358 if(index1 != -1) ImageList_Remove(ShellBigIconList, index1);
360 goto leave;
361 }
362
363 if (index!=index1)
364 {
365 FIXME("iconlists out of sync 0x%x 0x%x\n", index, index1);
366 /* What to do ???? */
367 }
368 lpsice->dwListIndex = index;
369 ret = lpsice->dwListIndex;
370
371leave:
372 if(ret == INVALID_INDEX)
373 {
374 if(indexDPA != -1) DPA_DeletePtr(sic_hdpa, indexDPA);
375 HeapFree(GetProcessHeap(), 0, lpsice->sSourceFile);
376 SHFree(lpsice);
377 }
379 return ret;
380}
#define index(s, c)
Definition: various.h:29
#define leave
Definition: btrfs_drv.h:138
LPVOID WINAPI DPA_DeletePtr(HDPA hdpa, INT i)
Definition: dpa.c:677
INT WINAPI DPA_InsertPtr(HDPA hdpa, INT i, LPVOID p)
Definition: dpa.c:591
BOOL WINAPI ImageList_Remove(HIMAGELIST himl, INT i)
Definition: imagelist.c:2568
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define DPAS_INSERTAFTER
Definition: commctrl.h:4864
DWORD dwListIndex
Definition: iconcache.cpp:33

Referenced by SIC_Initialize(), and SIC_LoadIcon().

◆ SIC_Initialize()

BOOL SIC_Initialize ( void  )

Definition at line 481 of file iconcache.cpp.

482{
483 HICON hSm = NULL, hLg = NULL;
484 INT cx_small, cy_small;
485 INT cx_large, cy_large;
486 HDC hDC;
487 INT bpp;
488 DWORD ilMask;
489 BOOL result = FALSE;
490
491 TRACE("Entered SIC_Initialize\n");
492
493 if (sic_hdpa)
494 {
495 TRACE("Icon cache already initialized\n");
496 return TRUE;
497 }
498
499 sic_hdpa = DPA_Create(16);
500 if (!sic_hdpa)
501 {
502 return FALSE;
503 }
504
505 hDC = CreateICW(L"DISPLAY", NULL, NULL, NULL);
506 if (!hDC)
507 {
508 ERR("Failed to create information context (error %d)\n", GetLastError());
509 goto end;
510 }
511
513 DeleteDC(hDC);
514
515 if (bpp <= 4)
516 ilMask = ILC_COLOR4;
517 else if (bpp <= 8)
518 ilMask = ILC_COLOR8;
519 else if (bpp <= 16)
520 ilMask = ILC_COLOR16;
521 else if (bpp <= 24)
522 ilMask = ILC_COLOR24;
523 else if (bpp <= 32)
524 ilMask = ILC_COLOR32;
525 else
526 ilMask = ILC_COLOR;
527
528 ilMask |= ILC_MASK;
529
530 cx_small = GetSystemMetrics(SM_CXSMICON);
531 cy_small = GetSystemMetrics(SM_CYSMICON);
532 cx_large = GetSystemMetrics(SM_CXICON);
533 cy_large = GetSystemMetrics(SM_CYICON);
534
536 cy_small,
537 ilMask,
538 100,
539 100);
541 {
542 ERR("Failed to create the small icon list.\n");
543 goto end;
544 }
545
547 cy_large,
548 ilMask,
549 100,
550 100);
551 if (!ShellBigIconList)
552 {
553 ERR("Failed to create the big icon list.\n");
554 goto end;
555 }
556
557 /* Load the document icon, which is used as the default if an icon isn't found. */
561 cx_small,
562 cy_small,
564 if (!hSm)
565 {
566 ERR("Failed to load small IDI_SHELL_DOCUMENT icon!\n");
567 goto end;
568 }
569
573 cx_large,
574 cy_large,
576 if (!hLg)
577 {
578 ERR("Failed to load large IDI_SHELL_DOCUMENT icon!\n");
579 goto end;
580 }
581
583 {
584 ERR("Failed to add IDI_SHELL_DOCUMENT icon to cache.\n");
585 goto end;
586 }
588 {
589 ERR("Failed to add IDI_SHELL_DOCUMENT icon to cache.\n");
590 goto end;
591 }
592
593 /* Everything went fine */
594 result = TRUE;
595
596end:
597 /* The image list keeps a copy of the icons, we must destroy them */
598 if(hSm) DestroyIcon(hSm);
599 if(hLg) DestroyIcon(hLg);
600
601 /* Clean everything if something went wrong */
602 if(!result)
603 {
607 sic_hdpa = NULL;
610 }
611
612 TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
613
614 return result;
615}
static HDC hDC
Definition: 3dtext.c:33
#define shell32_hInstance
#define ERR(fmt,...)
Definition: debug.h:110
DWORD bpp
Definition: surface.c:185
BOOL WINAPI DPA_Destroy(HDPA hdpa)
Definition: dpa.c:396
HDPA WINAPI DPA_Create(INT nGrow)
Definition: dpa.c:950
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint end
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
static INT SIC_IconAppend(LPCWSTR sSourceFile, INT dwSourceIndex, HICON hSmallIcon, HICON hBigIcon, DWORD dwFlags)
Definition: iconcache.cpp:323
static HDC
Definition: imagelist.c:92
#define L(x)
Definition: ntvdm.h:50
#define ILC_COLOR4
Definition: commctrl.h:354
#define ILC_COLOR16
Definition: commctrl.h:356
#define ILC_COLOR8
Definition: commctrl.h:355
#define ILC_COLOR32
Definition: commctrl.h:358
#define ILC_MASK
Definition: commctrl.h:351
#define ILC_COLOR24
Definition: commctrl.h:357
#define ILC_COLOR
Definition: commctrl.h:352
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:551
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HDC WINAPI CreateICW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ const DEVMODEW *)
#define BITSPIXEL
Definition: wingdi.h:720
BOOL WINAPI DeleteDC(_In_ HDC)
#define IMAGE_ICON
Definition: winuser.h:212
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2203
#define SM_CYSMICON
Definition: winuser.h:1013
#define SM_CXSMICON
Definition: winuser.h:1012
#define SM_CYICON
Definition: winuser.h:973
#define LR_SHARED
Definition: winuser.h:1100
#define SM_CXICON
Definition: winuser.h:972
int WINAPI GetSystemMetrics(_In_ int)

Referenced by FileIconInit(), PidlToSicIndex(), Shell_GetImageLists(), SIC_GetIconIndex(), and SIC_LoadOverlayIcon().

◆ SIC_LoadIcon()

static INT SIC_LoadIcon ( LPCWSTR  sSourceFile,
INT  dwSourceIndex,
DWORD  dwFlags 
)
static

Definition at line 387 of file iconcache.cpp.

388{
389 HICON hiconLarge=0;
390 HICON hiconSmall=0;
391 UINT ret;
392
393 PrivateExtractIconsW(sSourceFile, dwSourceIndex, 32, 32, &hiconLarge, NULL, 1, LR_COPYFROMRESOURCE);
394 PrivateExtractIconsW(sSourceFile, dwSourceIndex, 16, 16, &hiconSmall, NULL, 1, LR_COPYFROMRESOURCE);
395
396 if ( !hiconLarge || !hiconSmall)
397 {
398 WARN("failure loading icon %i from %s (%p %p)\n", dwSourceIndex, debugstr_w(sSourceFile), hiconLarge, hiconSmall);
399 if(hiconLarge) DestroyIcon(hiconLarge);
400 if(hiconSmall) DestroyIcon(hiconSmall);
401 return INVALID_INDEX;
402 }
403
404 if (0 != (dwFlags & GIL_FORSHORTCUT))
405 {
406 HICON hiconLargeShortcut = SIC_OverlayShortcutImage(hiconLarge, TRUE);
407 HICON hiconSmallShortcut = SIC_OverlayShortcutImage(hiconSmall, FALSE);
408 if (NULL != hiconLargeShortcut && NULL != hiconSmallShortcut)
409 {
410 DestroyIcon(hiconLarge);
411 DestroyIcon(hiconSmall);
412 hiconLarge = hiconLargeShortcut;
413 hiconSmall = hiconSmallShortcut;
414 }
415 else
416 {
417 WARN("Failed to create shortcut overlayed icons\n");
418 if (NULL != hiconLargeShortcut) DestroyIcon(hiconLargeShortcut);
419 if (NULL != hiconSmallShortcut) DestroyIcon(hiconSmallShortcut);
420 dwFlags &= ~ GIL_FORSHORTCUT;
421 }
422 }
423
424 ret = SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge, dwFlags);
425 DestroyIcon(hiconLarge);
426 DestroyIcon(hiconSmall);
427 return ret;
428}
static HICON SIC_OverlayShortcutImage(HICON SourceIcon, BOOL large)
Definition: iconcache.cpp:91
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1099

Referenced by PidlToSicIndex(), SIC_GetIconIndex(), and SIC_LoadOverlayIcon().

◆ SIC_LoadOverlayIcon()

static int SIC_LoadOverlayIcon ( int  icon_idx)
static

Definition at line 652 of file iconcache.cpp.

653{
654 WCHAR buffer[1024];
655 LPWSTR iconPath;
656 int iconIdx;
657
658 iconPath = swShell32Name; /* default: load icon from shell32.dll */
659 iconIdx = icon_idx;
660
661 if (HLM_GetIconW(icon_idx, buffer, _countof(buffer), &iconIdx))
662 {
663 iconPath = buffer;
664 }
665 else
666 {
667 WARN("Failed to load icon with index %d, using default one\n", icon_idx);
668 }
669
670 if (!sic_hdpa)
672
673 return SIC_LoadIcon(iconPath, iconIdx, 0);
674}
GLuint buffer
Definition: glext.h:5915
#define _countof(array)
Definition: sndvol32.h:68

Referenced by SIC_OverlayShortcutImage().

◆ SIC_OverlayShortcutImage()

static HICON SIC_OverlayShortcutImage ( HICON  SourceIcon,
BOOL  large 
)
static

Definition at line 91 of file iconcache.cpp.

92{
93 ICONINFO ShortcutIconInfo, TargetIconInfo;
94 HICON ShortcutIcon = NULL, TargetIcon;
95 BITMAP TargetBitmapInfo, ShortcutBitmapInfo;
96 HDC ShortcutDC = NULL,
97 TargetDC = NULL;
98 HBITMAP OldShortcutBitmap = NULL,
99 OldTargetBitmap = NULL;
100
101 static int s_imgListIdx = -1;
102 ZeroMemory(&ShortcutIconInfo, sizeof(ShortcutIconInfo));
103 ZeroMemory(&TargetIconInfo, sizeof(TargetIconInfo));
104
105 /* Get information about the source icon and shortcut overlay.
106 * We will write over the source bitmaps to get the final ones */
107 if (! GetIconInfo(SourceIcon, &TargetIconInfo))
108 return NULL;
109
110 /* Is it possible with the ImageList implementation? */
111 if(!TargetIconInfo.hbmColor)
112 {
113 /* Maybe we'll support this at some point */
114 FIXME("1bpp icon wants its overlay!\n");
115 goto fail;
116 }
117
118 if(!GetObjectW(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo))
119 {
120 goto fail;
121 }
122
123 /* search for the shortcut icon only once */
124 if (s_imgListIdx == -1)
125 s_imgListIdx = SIC_LoadOverlayIcon(IDI_SHELL_SHORTCUT - 1);
126
127 if (s_imgListIdx != -1)
128 {
129 if (large)
130 ShortcutIcon = ImageList_GetIcon(ShellBigIconList, s_imgListIdx, ILD_TRANSPARENT);
131 else
132 ShortcutIcon = ImageList_GetIcon(ShellSmallIconList, s_imgListIdx, ILD_TRANSPARENT);
133 } else
134 ShortcutIcon = NULL;
135
136 if (!ShortcutIcon || !GetIconInfo(ShortcutIcon, &ShortcutIconInfo))
137 {
138 goto fail;
139 }
140
141 /* Is it possible with the ImageLists ? */
142 if(!ShortcutIconInfo.hbmColor)
143 {
144 /* Maybe we'll support this at some point */
145 FIXME("Should draw 1bpp overlay!\n");
146 goto fail;
147 }
148
149 if(!GetObjectW(ShortcutIconInfo.hbmColor, sizeof(BITMAP), &ShortcutBitmapInfo))
150 {
151 goto fail;
152 }
153
154 /* Setup the masks */
155 ShortcutDC = CreateCompatibleDC(NULL);
156 if (NULL == ShortcutDC) goto fail;
157 OldShortcutBitmap = (HBITMAP)SelectObject(ShortcutDC, ShortcutIconInfo.hbmMask);
158 if (NULL == OldShortcutBitmap) goto fail;
159
160 TargetDC = CreateCompatibleDC(NULL);
161 if (NULL == TargetDC) goto fail;
162 OldTargetBitmap = (HBITMAP)SelectObject(TargetDC, TargetIconInfo.hbmMask);
163 if (NULL == OldTargetBitmap) goto fail;
164
165 /* Create the complete mask by ANDing the source and shortcut masks.
166 * NOTE: in an ImageList, all icons have the same dimensions */
167 if (!BitBlt(TargetDC, 0, 0, ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
168 ShortcutDC, 0, 0, SRCAND))
169 {
170 goto fail;
171 }
172
173 /*
174 * We must remove or add the alpha component to the shortcut overlay:
175 * If we don't, SRCCOPY will copy it to our resulting icon, resulting in a
176 * partially transparent icons where it shouldn't be, and to an invisible icon
177 * if the underlying icon don't have any alpha channel information. (16bpp only icon for instance).
178 * But if the underlying icon has alpha channel information, then we must mark the overlay information
179 * as opaque.
180 * NOTE: This code sucks(tm) and should belong to the ImageList implementation.
181 * NOTE2: there are better ways to do this.
182 */
183 if(ShortcutBitmapInfo.bmBitsPixel == 32)
184 {
185 BOOL add_alpha;
186 BYTE buffer[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
187 BITMAPINFO* lpbmi = (BITMAPINFO*)buffer;
188 PVOID bits;
189 PULONG pixel;
190 INT i, j;
191
192 /* Find if the source bitmap has an alpha channel */
193 if(TargetBitmapInfo.bmBitsPixel != 32) add_alpha = FALSE;
194 else
195 {
196 ZeroMemory(buffer, sizeof(buffer));
197 lpbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
198 lpbmi->bmiHeader.biWidth = TargetBitmapInfo.bmWidth;
199 lpbmi->bmiHeader.biHeight = TargetBitmapInfo.bmHeight;
200 lpbmi->bmiHeader.biPlanes = 1;
201 lpbmi->bmiHeader.biBitCount = 32;
202
203 bits = HeapAlloc(GetProcessHeap(), 0, TargetBitmapInfo.bmHeight * TargetBitmapInfo.bmWidthBytes);
204
205 if(!bits) goto fail;
206
207 if(!GetDIBits(TargetDC, TargetIconInfo.hbmColor, 0, TargetBitmapInfo.bmHeight, bits, lpbmi, DIB_RGB_COLORS))
208 {
209 ERR("GetBIBits failed!\n");
211 goto fail;
212 }
213
214 i = j = 0;
215 pixel = (PULONG)bits;
216
217 for(i=0; i<TargetBitmapInfo.bmHeight; i++)
218 {
219 for(j=0; j<TargetBitmapInfo.bmWidth; j++)
220 {
221 add_alpha = (*pixel++ & 0xFF000000) != 0;
222 if(add_alpha) break;
223 }
224 if(add_alpha) break;
225 }
227 }
228
229 /* Allocate the bits */
230 bits = HeapAlloc(GetProcessHeap(), 0, ShortcutBitmapInfo.bmHeight*ShortcutBitmapInfo.bmWidthBytes);
231 if(!bits) goto fail;
232
233 ZeroMemory(buffer, sizeof(buffer));
234 lpbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
235 lpbmi->bmiHeader.biWidth = ShortcutBitmapInfo.bmWidth;
236 lpbmi->bmiHeader.biHeight = ShortcutBitmapInfo.bmHeight;
237 lpbmi->bmiHeader.biPlanes = 1;
238 lpbmi->bmiHeader.biBitCount = 32;
239
240 if(!GetDIBits(TargetDC, ShortcutIconInfo.hbmColor, 0, ShortcutBitmapInfo.bmHeight, bits, lpbmi, DIB_RGB_COLORS))
241 {
242 ERR("GetBIBits failed!\n");
244 goto fail;
245 }
246
247 pixel = (PULONG)bits;
248 /* Remove alpha channel component or make it totally opaque */
249 for(i=0; i<ShortcutBitmapInfo.bmHeight; i++)
250 {
251 for(j=0; j<ShortcutBitmapInfo.bmWidth; j++)
252 {
253 if(add_alpha) *pixel++ |= 0xFF000000;
254 else *pixel++ &= 0x00FFFFFF;
255 }
256 }
257
258 /* GetDIBits return BI_BITFIELDS with masks set to 0, and SetDIBits fails when masks are 0. The irony... */
260
261 /* Set the bits again */
262 if(!SetDIBits(TargetDC, ShortcutIconInfo.hbmColor, 0, ShortcutBitmapInfo.bmHeight, bits, lpbmi, DIB_RGB_COLORS))
263 {
264 ERR("SetBIBits failed!, %lu\n", GetLastError());
266 goto fail;
267 }
269 }
270
271 /* Now do the copy. We overwrite the original icon data */
272 if (NULL == SelectObject(ShortcutDC, ShortcutIconInfo.hbmColor) ||
273 NULL == SelectObject(TargetDC, TargetIconInfo.hbmColor))
274 goto fail;
275 if (!MaskBlt(TargetDC, 0, 0, ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
276 ShortcutDC, 0, 0, ShortcutIconInfo.hbmMask, 0, 0,
277 MAKEROP4(0xAA0000, SRCCOPY)))
278 {
279 goto fail;
280 }
281
282 /* Clean up, we're not goto'ing to 'fail' after this so we can be lazy and not set
283 handles to NULL */
284 SelectObject(TargetDC, OldTargetBitmap);
285 DeleteDC(TargetDC);
286 SelectObject(ShortcutDC, OldShortcutBitmap);
287 DeleteDC(ShortcutDC);
288
289 /* Create the icon using the bitmaps prepared earlier */
290 TargetIcon = CreateIconIndirect(&TargetIconInfo);
291
292 /* CreateIconIndirect copies the bitmaps, so we can release our bitmaps now */
293 DeleteObject(TargetIconInfo.hbmColor);
294 DeleteObject(TargetIconInfo.hbmMask);
295 /* Delete what GetIconInfo gave us */
296 DeleteObject(ShortcutIconInfo.hbmColor);
297 DeleteObject(ShortcutIconInfo.hbmMask);
298 DestroyIcon(ShortcutIcon);
299
300 return TargetIcon;
301
302fail:
303 /* Clean up scratch resources we created */
304 if (NULL != OldTargetBitmap) SelectObject(TargetDC, OldTargetBitmap);
305 if (NULL != TargetDC) DeleteDC(TargetDC);
306 if (NULL != OldShortcutBitmap) SelectObject(ShortcutDC, OldShortcutBitmap);
307 if (NULL != ShortcutDC) DeleteDC(ShortcutDC);
308 if (NULL != TargetIconInfo.hbmColor) DeleteObject(TargetIconInfo.hbmColor);
309 if (NULL != TargetIconInfo.hbmMask) DeleteObject(TargetIconInfo.hbmMask);
310 if (NULL != ShortcutIconInfo.hbmColor) DeleteObject(ShortcutIconInfo.hbmColor);
311 if (NULL != ShortcutIconInfo.hbmMask) DeleteObject(ShortcutIconInfo.hbmMask);
312 if (NULL != ShortcutIcon) DestroyIcon(ShortcutIcon);
313
314 return NULL;
315}
HICON WINAPI ImageList_GetIcon(HIMAGELIST himl, INT i, UINT fStyle)
Definition: imagelist.c:1963
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
#define BI_RGB
Definition: precomp.h:56
ULONG RGBQUAD
Definition: precomp.h:59
pKey DeleteObject()
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static int SIC_LoadOverlayIcon(int icon_idx)
Definition: iconcache.cpp:652
#define bits
Definition: infblock.c:15
static HBITMAP
Definition: button.c:44
#define ILD_TRANSPARENT
Definition: commctrl.h:418
#define IDI_SHELL_SHORTCUT
Definition: shresdef.h:580
Definition: bl.h:1331
HBITMAP hbmColor
Definition: winuser.h:3127
HBITMAP hbmMask
Definition: winuser.h:3126
USHORT biBitCount
Definition: precomp.h:46
ULONG biCompression
Definition: precomp.h:47
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
uint32_t * PULONG
Definition: typedefs.h:59
#define ZeroMemory
Definition: winbase.h:1712
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
int WINAPI SetDIBits(_In_opt_ HDC, _In_ HBITMAP, _In_ UINT, _In_ UINT, _In_ CONST VOID *, _In_ CONST BITMAPINFO *, _In_ UINT)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI MaskBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ HDC, _In_ int, _In_ int, _In_ HBITMAP, _In_ int, _In_ int, _In_ DWORD)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
struct tagBITMAPINFO BITMAPINFO
#define SRCAND
Definition: wingdi.h:330
#define MAKEROP4(f, b)
Definition: wingdi.h:2946
HICON WINAPI CreateIconIndirect(_In_ PICONINFO)
Definition: cursoricon.c:2581
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2045
unsigned char BYTE
Definition: xxhash.c:193

Referenced by SIC_LoadIcon().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ ShellBigIconList

HIMAGELIST ShellBigIconList
static

◆ ShellSmallIconList

HIMAGELIST ShellSmallIconList
static

◆ sic_hdpa