ReactOS 0.4.16-dev-747-gbc52d5f
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 SIC_GetMetricsValue (_In_ PCWSTR pszValueName, _In_ INT nDefaultValue)
 
static INT SIC_GetLargeIconSize (VOID)
 
static INT SIC_GetSmallIconSize (VOID)
 
static INT SIC_GetIconBPP (VOID)
 
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
 
INT ShellSmallIconSize = 0
 
INT ShellLargeIconSize = 0
 
INT ShellIconBPP = 0
 
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 15 of file iconcache.cpp.

Typedef Documentation

◆ LPSIC_ENTRY

Function Documentation

◆ ExtractAssociatedIconA()

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

Definition at line 914 of file iconcache.cpp.

915{
916 HICON hIcon = NULL;
917 INT len = MultiByteToWideChar(CP_ACP, 0, lpIconPath, -1, NULL, 0);
918 /* Note that we need to allocate MAX_PATH, since we are supposed to fill
919 * the correct executable if there is no icon in lpIconPath directly.
920 * lpIconPath itself is supposed to be large enough, so make sure lpIconPathW
921 * is large enough too. Yes, I am puking too.
922 */
923 LPWSTR lpIconPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
924
925 TRACE("%p %s %p\n", hInst, debugstr_a(lpIconPath), lpiIcon);
926
927 if (lpIconPathW)
928 {
929 MultiByteToWideChar(CP_ACP, 0, lpIconPath, -1, lpIconPathW, len);
930 hIcon = ExtractAssociatedIconW(hInst, lpIconPathW, lpiIcon);
931 WideCharToMultiByte(CP_ACP, 0, lpIconPathW, -1, lpIconPath, MAX_PATH , NULL, NULL);
932 HeapFree(GetProcessHeap(), 0, lpIconPathW);
933 }
934 return hIcon;
935}
#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:943
#define debugstr_a
Definition: kernel32.h:31
static HICON
Definition: imagelist.c:80
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 997 of file iconcache.cpp.

998{
999 HICON ret;
1000 INT len = MultiByteToWideChar( CP_ACP, 0, lpIconPath, -1, NULL, 0 );
1001 LPWSTR lpwstrFile = (LPWSTR)HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1002
1003 TRACE("%p %s %p %p)\n", hInst, lpIconPath, lpiIconIdx, lpiIconId);
1004
1005 MultiByteToWideChar( CP_ACP, 0, lpIconPath, -1, lpwstrFile, len );
1006 ret = ExtractAssociatedIconExW(hInst, lpwstrFile, lpiIconIdx, lpiIconId);
1007 HeapFree(GetProcessHeap(), 0, lpwstrFile);
1008 return ret;
1009}
EXTERN_C HICON WINAPI ExtractAssociatedIconExW(HINSTANCE hInst, LPWSTR lpIconPath, LPWORD lpiIconIdx, LPWORD lpiIconId)
Definition: iconcache.cpp:985
int ret

◆ ExtractAssociatedIconExW()

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

Definition at line 985 of file iconcache.cpp.

986{
987 FIXME("%p %s %p %p): stub\n", hInst, debugstr_w(lpIconPath), lpiIconIdx, lpiIconId);
988 return 0;
989}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define debugstr_w
Definition: kernel32.h:32

Referenced by ExtractAssociatedIconExA().

◆ ExtractAssociatedIconW()

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

Definition at line 943 of file iconcache.cpp.

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

Referenced by ExtractAssociatedIconA().

◆ ExtractIconExA()

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

Definition at line 891 of file iconcache.cpp.

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

◆ ExtractIconExW()

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

Definition at line 855 of file iconcache.cpp.

856{
857 UINT ret = 0;
858
859 /* get entry point of undocumented function PrivateExtractIconExW() in user32 */
860#if defined(__CYGWIN__) || defined (__MINGW32__) || defined(_MSC_VER)
862
864 HMODULE hUser32 = GetModuleHandleA("user32");
865 PrivateExtractIconExW = (UINT(WINAPI*)(LPCWSTR,int,HICON*,HICON*,UINT)) GetProcAddress(hUser32, "PrivateExtractIconExW");
866
868 return ret;
869 }
870#endif
871
872 TRACE("%s %i %p %p %i\n", debugstr_w(lpszFile), nIconIndex, phiconLarge, phiconSmall, nIcons);
873 ret = PrivateExtractIconExW(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
874
875 /* PrivateExtractIconExW() may return -1 if the provided file is not a valid PE image file or the said
876 * file couldn't be found. The behaviour is correct although ExtractIconExW() only returns the successfully
877 * extracted icons from a file. In such scenario, simply return 0.
878 */
879 if (ret == 0xFFFFFFFF)
880 {
881 WARN("Invalid file or couldn't be found - %s\n", debugstr_w(lpszFile));
882 ret = 0;
883 }
884
885 return ret;
886}
#define WARN(fmt,...)
Definition: precomp.h:61
#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 AsyncLoadIconProc(), CShellLink::CreateShortcutIcon(), CTrayShowDesktopButton::DoCreate(), DoLoadIcons(), ExtractIconExA(), FileTypesDlg_OnItemChanging(), GetCustomIconPath(), 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 715 of file iconcache.cpp.

721{
723 WCHAR szIconFile[MAX_PATH]; /* file containing the icon */
724 INT iSourceIndex; /* index or resID(negated) in this file */
725 BOOL ret = FALSE;
726 UINT dwFlags = 0;
727 int iShortcutDefaultIndex = INVALID_INDEX;
728
729 TRACE("sf=%p pidl=%p %s\n", sh, pidl, bBigIcon?"Big":"Small");
730
731 if (!sic_hdpa)
733
734 if (SUCCEEDED (sh->GetUIObjectOf(0, 1, &pidl, IID_NULL_PPV_ARG(IExtractIconW, &ei))))
735 {
736 if (SUCCEEDED(ei->GetIconLocation(uFlags &~ GIL_FORSHORTCUT, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags)))
737 {
738 *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex, uFlags);
739 ret = TRUE;
740 }
741 }
742
743 if (INVALID_INDEX == *pIndex) /* default icon when failed */
744 {
745 if (0 == (uFlags & GIL_FORSHORTCUT))
746 {
747 *pIndex = 0;
748 }
749 else
750 {
751 if (INVALID_INDEX == iShortcutDefaultIndex)
752 {
753 iShortcutDefaultIndex = SIC_LoadIcon(swShell32Name, 0, GIL_FORSHORTCUT);
754 }
755 *pIndex = (INVALID_INDEX != iShortcutDefaultIndex ? iShortcutDefaultIndex : 0);
756 }
757 }
758
759 return ret;
760
761}
#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:474
static HDPA sic_hdpa
Definition: iconcache.cpp:26
BOOL SIC_Initialize(void)
Definition: iconcache.cpp:515
static INT SIC_LoadIcon(LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags)
Definition: iconcache.cpp:420
#define INVALID_INDEX
Definition: iconcache.cpp:15
#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 1043 of file iconcache.cpp.

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

◆ SHDefExtractIconW()

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

Definition at line 1015 of file iconcache.cpp.

1017{
1018 UINT ret;
1019 HICON hIcons[2];
1020 WARN("%s %d 0x%08x %p %p %d, semi-stub\n", debugstr_w(pszIconFile), iIndex, uFlags, phiconLarge, phiconSmall, nIconSize);
1021
1022 ret = PrivateExtractIconsW(pszIconFile, iIndex, nIconSize, nIconSize, hIcons, NULL, 2, LR_DEFAULTCOLOR);
1023 /* FIXME: deal with uFlags parameter which contains GIL_ flags */
1024 if (ret == 0xFFFFFFFF)
1025 return E_FAIL;
1026 if (ret > 0) {
1027 if (phiconLarge)
1028 *phiconLarge = hIcons[0];
1029 else
1030 DestroyIcon(hIcons[0]);
1031 if (phiconSmall)
1032 *phiconSmall = hIcons[1];
1033 else
1034 DestroyIcon(hIcons[1]);
1035 return S_OK;
1036 }
1037 return S_FALSE;
1038}
#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:1090
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2139

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 844 of file iconcache.cpp.

845{
846 return Shell_GetCachedImageIndexAW(szPath, nIndex, bSimulateDoc);
847}
EXTERN_C INT WINAPI Shell_GetCachedImageIndexAW(LPCVOID szPath, INT nIndex, BOOL bSimulateDoc)
Definition: iconcache.cpp:838
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 813 of file iconcache.cpp.

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

Referenced by Shell_GetCachedImageIndexAW().

◆ Shell_GetCachedImageIndexAW()

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

Definition at line 838 of file iconcache.cpp.

839{ if( SHELL_OsIsUnicode())
840 return Shell_GetCachedImageIndexW((LPCWSTR)szPath, nIndex, bSimulateDoc);
841 return Shell_GetCachedImageIndexA((LPCSTR)szPath, nIndex, bSimulateDoc);
842}
INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, UINT bSimulateDoc)
Definition: iconcache.cpp:813
INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, UINT bSimulateDoc)
Definition: iconcache.cpp:831
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:148
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 831 of file iconcache.cpp.

832{
833 WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_w(szPath), nIndex, bSimulateDoc);
834
835 return SIC_GetIconIndex(szPath, nIndex, 0);
836}

Referenced by Shell_GetCachedImageIndexAW().

◆ Shell_GetImageLists()

BOOL WINAPI Shell_GetImageLists ( HIMAGELIST lpBigList,
HIMAGELIST lpSmallList 
)

Definition at line 689 of file iconcache.cpp.

690{
691 TRACE("(%p,%p)\n",lpBigList,lpSmallList);
692
693 if (!sic_hdpa)
695
696 if (lpBigList)
697 *lpBigList = ShellBigIconList;
698
699 if (lpSmallList)
700 *lpSmallList = ShellSmallIconList;
701
702 return TRUE;
703}
static HIMAGELIST ShellSmallIconList
Definition: iconcache.cpp:28
static HIMAGELIST ShellBigIconList
Definition: iconcache.cpp:29

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

◆ SHGetIconOverlayIndexA()

EXTERN_C INT WINAPI SHGetIconOverlayIndexA ( LPCSTR  pszIconPath,
INT  iIconIndex 
)

Definition at line 1063 of file iconcache.cpp.

1064{
1065 FIXME("%s, %d\n", debugstr_a(pszIconPath), iIconIndex);
1066
1067 return -1;
1068}

◆ SHGetIconOverlayIndexW()

EXTERN_C INT WINAPI SHGetIconOverlayIndexW ( LPCWSTR  pszIconPath,
INT  iIconIndex 
)

Definition at line 1075 of file iconcache.cpp.

1076{
1077 FIXME("%s, %d\n", debugstr_w(pszIconPath), iIconIndex);
1078
1079 return -1;
1080}

◆ 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 799 of file iconcache.cpp.

803{
804 FIXME("(%p, %p, %p, 0x%08x, %p, %p, %p, %p, %p)\n",
805 pts, psf, pidl, flags, pfn, pvData, pvHint, piIndex, piIndexSel);
806 return E_FAIL;
807}
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 772 of file iconcache.cpp.

776{
777 int Index;
778 UINT uGilFlags = 0;
779
780 TRACE("(SF=%p,pidl=%p,%p)\n",sh,pidl,pIndex);
781 pdump(pidl);
782
783 if (SHELL_IsShortcut(pidl))
784 uGilFlags |= GIL_FORSHORTCUT;
785
786 if (pIndex)
787 if (!PidlToSicIndex ( sh, pidl, 1, uGilFlags, pIndex))
788 *pIndex = -1;
789
790 if (!PidlToSicIndex ( sh, pidl, 0, uGilFlags, &Index))
791 return -1;
792
793 return Index;
794}
void pdump(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:322
BOOL PidlToSicIndex(IShellFolder *sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, int *pIndex)
Definition: iconcache.cpp:715
BOOL SHELL_IsShortcut(LPCITEMIDLIST pidlLast)
Definition: shell32_main.c:404
_In_ WDFCOLLECTION _In_ ULONG Index

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

◆ SIC_CompareEntries()

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

Definition at line 94 of file iconcache.cpp.

95{ LPSIC_ENTRY e1 = (LPSIC_ENTRY)p1, e2 = (LPSIC_ENTRY)p2;
96
97 TRACE("%p %p %8lx\n", p1, p2, lparam);
98
99 /* Icons in the cache are keyed by the name of the file they are
100 * loaded from, their resource index and the fact if they have a shortcut
101 * icon overlay or not.
102 */
103 /* first the faster one */
104 if (e1->dwSourceIndex != e2->dwSourceIndex)
105 return (e1->dwSourceIndex < e2->dwSourceIndex) ? -1 : 1;
106
107 if ((e1->dwFlags & GIL_FORSHORTCUT) != (e2->dwFlags & GIL_FORSHORTCUT))
108 return ((e1->dwFlags & GIL_FORSHORTCUT) < (e2->dwFlags & GIL_FORSHORTCUT)) ? -1 : 1;
109
110 return _wcsicmp(e1->sSourceFile,e2->sSourceFile);
111}
@ lparam
Definition: SystemMenu.c:31
struct SIC_ENTRY * LPSIC_ENTRY
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
Definition: iconcache.cpp:18
DWORD dwFlags
Definition: iconcache.cpp:22
DWORD dwSourceIndex
Definition: iconcache.cpp:20
LPWSTR sSourceFile
Definition: iconcache.cpp:19

Referenced by SIC_GetIconIndex(), and SIC_IconAppend().

◆ SIC_Destroy()

void SIC_Destroy ( void  )

Definition at line 635 of file iconcache.cpp.

636{
637 TRACE("\n");
638
640
642
643 sic_hdpa = NULL;
648
650 //DeleteCriticalSection(&SHELL32_SicCS); //static
651}
void WINAPI DPA_DestroyCallback(HDPA hdpa, PFNDPAENUMCALLBACK enumProc, LPVOID lParam)
Definition: dpa.c:1003
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:935
static INT CALLBACK sic_free(LPVOID ptr, LPVOID lparam)
Definition: iconcache.cpp:628
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 628 of file iconcache.cpp.

629{
630 HeapFree(GetProcessHeap(), 0, ((LPSIC_ENTRY)ptr)->sSourceFile);
631 SHFree(ptr);
632 return TRUE;
633}
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
static PVOID ptr
Definition: dispmode.c:27

Referenced by SIC_Destroy().

◆ SIC_GetIconBPP()

static INT SIC_GetIconBPP ( VOID  )
static

Definition at line 81 of file iconcache.cpp.

82{
83 INT nDefaultBPP = SHGetCurColorRes();
84 INT nIconBPP = SIC_GetMetricsValue(L"Shell Icon BPP", nDefaultBPP);
85 return (nIconBPP > 0) ? nIconBPP : nDefaultBPP;
86}
DWORD WINAPI SHGetCurColorRes(void)
Definition: ordinal.c:2023
static INT SIC_GetMetricsValue(_In_ PCWSTR pszValueName, _In_ INT nDefaultValue)
Definition: iconcache.cpp:48
#define L(x)
Definition: ntvdm.h:50

Referenced by SIC_Initialize().

◆ SIC_GetIconIndex()

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

Definition at line 474 of file iconcache.cpp.

475{
476 SIC_ENTRY sice;
479
480 TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex);
481
482 GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL);
483 sice.sSourceFile = path;
484 sice.dwSourceIndex = dwSourceIndex;
485 sice.dwFlags = dwFlags;
486
487 if (!sic_hdpa)
489
491
492 if (NULL != DPA_GetPtr (sic_hdpa, 0))
493 {
494 /* search linear from position 0*/
496 }
497
498 if ( INVALID_INDEX == index )
499 {
500 ret = SIC_LoadIcon (sSourceFile, dwSourceIndex, dwFlags);
501 }
502 else
503 {
504 TRACE("-- found\n");
505 ret = ((LPSIC_ENTRY)DPA_GetPtr(sic_hdpa, index))->dwListIndex;
506 }
507
509 return ret;
510}
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:94
#define DPAS_SORTED
Definition: commctrl.h:4867
#define DPA_GetPtr
Definition: commctrl.h:5

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

◆ SIC_GetLargeIconSize()

static INT SIC_GetLargeIconSize ( VOID  )
static

Definition at line 63 of file iconcache.cpp.

64{
65 // NOTE: Shell icon size is always square
66 INT nDefaultSize = GetSystemMetrics(SM_CXICON);
67 INT nIconSize = SIC_GetMetricsValue(L"Shell Icon Size", nDefaultSize);
68 return (nIconSize > 0) ? nIconSize : nDefaultSize;
69}
#define SM_CXICON
Definition: winuser.h:975
int WINAPI GetSystemMetrics(_In_ int)

Referenced by SIC_Initialize().

◆ SIC_GetMetricsValue()

static INT SIC_GetMetricsValue ( _In_ PCWSTR  pszValueName,
_In_ INT  nDefaultValue 
)
static

Definition at line 48 of file iconcache.cpp.

51{
52 WCHAR szValue[64];
53 DWORD cbValue = sizeof(szValue);
54 DWORD error = SHGetValueW(HKEY_CURRENT_USER, L"Control Panel\\Desktop\\WindowMetrics",
55 pszValueName, NULL, szValue, &cbValue);
56 if (error)
57 return nDefaultValue;
58 szValue[_countof(szValue) - 1] = UNICODE_NULL; // Avoid buffer overrun
59 return _wtoi(szValue);
60}
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
unsigned long DWORD
Definition: ntddk_ex.h:95
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define error(str)
Definition: mkdosfs.c:1605
#define UNICODE_NULL
#define _countof(array)
Definition: sndvol32.h:70
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by SIC_GetIconBPP(), SIC_GetLargeIconSize(), and SIC_GetSmallIconSize().

◆ SIC_GetSmallIconSize()

static INT SIC_GetSmallIconSize ( VOID  )
static

Definition at line 72 of file iconcache.cpp.

73{
74 // NOTE: Shell icon size is always square
75 INT nDefaultSize = GetSystemMetrics(SM_CXSMICON);
76 INT nIconSize = SIC_GetMetricsValue(L"Shell Small Icon Size", nDefaultSize);
77 return (nIconSize > 0) ? nIconSize : nDefaultSize;
78}
#define SM_CXSMICON
Definition: winuser.h:1015

Referenced by SIC_Initialize().

◆ SIC_IconAppend()

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

Definition at line 356 of file iconcache.cpp.

357{
358 LPSIC_ENTRY lpsice;
359 INT ret, index, index1, indexDPA;
361 TRACE("%s %i %p %p\n", debugstr_w(sSourceFile), dwSourceIndex, hSmallIcon ,hBigIcon);
362
363 lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY));
364
365 GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL);
366 lpsice->sSourceFile = (LPWSTR)HeapAlloc( GetProcessHeap(), 0, (wcslen(path)+1)*sizeof(WCHAR) );
367 wcscpy( lpsice->sSourceFile, path );
368
369 lpsice->dwSourceIndex = dwSourceIndex;
370 lpsice->dwFlags = dwFlags;
371
373
375 indexDPA = DPA_InsertPtr(sic_hdpa, indexDPA, lpsice);
376 if ( -1 == indexDPA )
377 {
379 goto leave;
380 }
381
383 index1= ImageList_AddIcon (ShellBigIconList, hBigIcon);
384
385 /* Something went wrong when allocating a new image in the list. Abort. */
386 if((index == -1) || (index1 == -1))
387 {
388 WARN("Something went wrong when adding the icon to the list: small - 0x%x, big - 0x%x.\n",
389 index, index1);
391 if(index1 != -1) ImageList_Remove(ShellBigIconList, index1);
393 goto leave;
394 }
395
396 if (index!=index1)
397 {
398 FIXME("iconlists out of sync 0x%x 0x%x\n", index, index1);
399 /* What to do ???? */
400 }
401 lpsice->dwListIndex = index;
402 ret = lpsice->dwListIndex;
403
404leave:
405 if(ret == INVALID_INDEX)
406 {
407 if(indexDPA != -1) DPA_DeletePtr(sic_hdpa, indexDPA);
408 HeapFree(GetProcessHeap(), 0, lpsice->sSourceFile);
409 SHFree(lpsice);
410 }
412 return ret;
413}
#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:2604
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:4869
DWORD dwListIndex
Definition: iconcache.cpp:21

Referenced by SIC_Initialize(), and SIC_LoadIcon().

◆ SIC_Initialize()

BOOL SIC_Initialize ( void  )

Definition at line 515 of file iconcache.cpp.

516{
517 HICON hSm = NULL, hLg = NULL;
518 INT bpp;
519 DWORD ilMask;
520 BOOL result = FALSE;
521
522 TRACE("Entered SIC_Initialize\n");
523
524 if (sic_hdpa)
525 {
526 TRACE("Icon cache already initialized\n");
527 return TRUE;
528 }
529
530 sic_hdpa = DPA_Create(16);
531 if (!sic_hdpa)
532 {
533 return FALSE;
534 }
535
538
539 bpp = ShellIconBPP = SIC_GetIconBPP(); // Bits Per Pixel
540 if (bpp <= 4)
541 ilMask = ILC_COLOR4;
542 else if (bpp <= 8)
543 ilMask = ILC_COLOR8;
544 else if (bpp <= 16)
545 ilMask = ILC_COLOR16;
546 else if (bpp <= 24)
547 ilMask = ILC_COLOR24;
548 else if (bpp <= 32)
549 ilMask = ILC_COLOR32;
550 else
551 ilMask = ILC_COLOR;
552
553 ilMask |= ILC_MASK;
554
557 {
558 ERR("Failed to create the small icon list.\n");
559 goto end;
560 }
561
563 if (!ShellBigIconList)
564 {
565 ERR("Failed to create the big icon list.\n");
566 goto end;
567 }
568
569 /* Load the document icon, which is used as the default if an icon isn't found. */
573 if (!hSm)
574 {
575 ERR("Failed to load small IDI_SHELL_DOCUMENT icon!\n");
576 goto end;
577 }
578
582 if (!hLg)
583 {
584 ERR("Failed to load large IDI_SHELL_DOCUMENT icon!\n");
585 goto end;
586 }
587
589 {
590 ERR("Failed to add IDI_SHELL_DOCUMENT icon to cache.\n");
591 goto end;
592 }
594 {
595 ERR("Failed to add IDI_SHELL_DOCUMENT icon to cache.\n");
596 goto end;
597 }
598
599 /* Everything went fine */
600 result = TRUE;
601
602end:
603 /* The image list keeps a copy of the icons, we must destroy them */
604 if(hSm) DestroyIcon(hSm);
605 if(hLg) DestroyIcon(hLg);
606
607 /* Clean everything if something went wrong */
608 if(!result)
609 {
613 sic_hdpa = NULL;
616 }
617
618 TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
619
620 return result;
621}
#define shell32_hInstance
#define ERR(fmt,...)
Definition: precomp.h:57
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:808
GLuint GLuint end
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
INT ShellSmallIconSize
Definition: iconcache.cpp:30
static INT SIC_GetLargeIconSize(VOID)
Definition: iconcache.cpp:63
static INT SIC_IconAppend(LPCWSTR sSourceFile, INT dwSourceIndex, HICON hSmallIcon, HICON hBigIcon, DWORD dwFlags)
Definition: iconcache.cpp:356
INT ShellIconBPP
Definition: iconcache.cpp:32
static INT SIC_GetIconBPP(VOID)
Definition: iconcache.cpp:81
static INT SIC_GetSmallIconSize(VOID)
Definition: iconcache.cpp:72
INT ShellLargeIconSize
Definition: iconcache.cpp:31
#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:553
#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:2289
#define LR_SHARED
Definition: winuser.h:1103

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 420 of file iconcache.cpp.

421{
422 HICON hiconLarge = NULL, hiconSmall = NULL;
423 UINT ret;
424
426 &hiconLarge, NULL, 1, LR_COPYFROMRESOURCE);
428 &hiconSmall, NULL, 1, LR_COPYFROMRESOURCE);
429
430 if (!hiconLarge || !hiconSmall)
431 {
432 WARN("failure loading icon %i from %s (%p %p)\n", dwSourceIndex, debugstr_w(sSourceFile), hiconLarge, hiconSmall);
433 if(hiconLarge) DestroyIcon(hiconLarge);
434 if(hiconSmall) DestroyIcon(hiconSmall);
435 return INVALID_INDEX;
436 }
437
438 if (0 != (dwFlags & GIL_FORSHORTCUT))
439 {
440 HICON hiconLargeShortcut = SIC_OverlayShortcutImage(hiconLarge, TRUE);
441 HICON hiconSmallShortcut = SIC_OverlayShortcutImage(hiconSmall, FALSE);
442 if (NULL != hiconLargeShortcut && NULL != hiconSmallShortcut)
443 {
444 DestroyIcon(hiconLarge);
445 DestroyIcon(hiconSmall);
446 hiconLarge = hiconLargeShortcut;
447 hiconSmall = hiconSmallShortcut;
448 }
449 else
450 {
451 WARN("Failed to create shortcut overlayed icons\n");
452 if (NULL != hiconLargeShortcut) DestroyIcon(hiconLargeShortcut);
453 if (NULL != hiconSmallShortcut) DestroyIcon(hiconSmallShortcut);
454 dwFlags &= ~ GIL_FORSHORTCUT;
455 }
456 }
457
458 ret = SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge, dwFlags);
459 DestroyIcon(hiconLarge);
460 DestroyIcon(hiconSmall);
461 return ret;
462}
static HICON SIC_OverlayShortcutImage(HICON SourceIcon, BOOL large)
Definition: iconcache.cpp:124
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1102

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

◆ SIC_LoadOverlayIcon()

static int SIC_LoadOverlayIcon ( int  icon_idx)
static

Definition at line 658 of file iconcache.cpp.

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

Referenced by SIC_OverlayShortcutImage().

◆ SIC_OverlayShortcutImage()

static HICON SIC_OverlayShortcutImage ( HICON  SourceIcon,
BOOL  large 
)
static

Definition at line 124 of file iconcache.cpp.

125{
126 ICONINFO ShortcutIconInfo, TargetIconInfo;
127 HICON ShortcutIcon = NULL, TargetIcon;
128 BITMAP TargetBitmapInfo, ShortcutBitmapInfo;
129 HDC ShortcutDC = NULL,
130 TargetDC = NULL;
131 HBITMAP OldShortcutBitmap = NULL,
132 OldTargetBitmap = NULL;
133
134 static int s_imgListIdx = -1;
135 ZeroMemory(&ShortcutIconInfo, sizeof(ShortcutIconInfo));
136 ZeroMemory(&TargetIconInfo, sizeof(TargetIconInfo));
137
138 /* Get information about the source icon and shortcut overlay.
139 * We will write over the source bitmaps to get the final ones */
140 if (! GetIconInfo(SourceIcon, &TargetIconInfo))
141 return NULL;
142
143 /* Is it possible with the ImageList implementation? */
144 if(!TargetIconInfo.hbmColor)
145 {
146 /* Maybe we'll support this at some point */
147 FIXME("1bpp icon wants its overlay!\n");
148 goto fail;
149 }
150
151 if(!GetObjectW(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo))
152 {
153 goto fail;
154 }
155
156 /* search for the shortcut icon only once */
157 if (s_imgListIdx == -1)
158 s_imgListIdx = SIC_LoadOverlayIcon(IDI_SHELL_SHORTCUT - 1);
159
160 if (s_imgListIdx != -1)
161 {
162 if (large)
163 ShortcutIcon = ImageList_GetIcon(ShellBigIconList, s_imgListIdx, ILD_TRANSPARENT);
164 else
165 ShortcutIcon = ImageList_GetIcon(ShellSmallIconList, s_imgListIdx, ILD_TRANSPARENT);
166 } else
167 ShortcutIcon = NULL;
168
169 if (!ShortcutIcon || !GetIconInfo(ShortcutIcon, &ShortcutIconInfo))
170 {
171 goto fail;
172 }
173
174 /* Is it possible with the ImageLists ? */
175 if(!ShortcutIconInfo.hbmColor)
176 {
177 /* Maybe we'll support this at some point */
178 FIXME("Should draw 1bpp overlay!\n");
179 goto fail;
180 }
181
182 if(!GetObjectW(ShortcutIconInfo.hbmColor, sizeof(BITMAP), &ShortcutBitmapInfo))
183 {
184 goto fail;
185 }
186
187 /* Setup the masks */
188 ShortcutDC = CreateCompatibleDC(NULL);
189 if (NULL == ShortcutDC) goto fail;
190 OldShortcutBitmap = (HBITMAP)SelectObject(ShortcutDC, ShortcutIconInfo.hbmMask);
191 if (NULL == OldShortcutBitmap) goto fail;
192
193 TargetDC = CreateCompatibleDC(NULL);
194 if (NULL == TargetDC) goto fail;
195 OldTargetBitmap = (HBITMAP)SelectObject(TargetDC, TargetIconInfo.hbmMask);
196 if (NULL == OldTargetBitmap) goto fail;
197
198 /* Create the complete mask by ANDing the source and shortcut masks.
199 * NOTE: in an ImageList, all icons have the same dimensions */
200 if (!BitBlt(TargetDC, 0, 0, ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
201 ShortcutDC, 0, 0, SRCAND))
202 {
203 goto fail;
204 }
205
206 /*
207 * We must remove or add the alpha component to the shortcut overlay:
208 * If we don't, SRCCOPY will copy it to our resulting icon, resulting in a
209 * partially transparent icons where it shouldn't be, and to an invisible icon
210 * if the underlying icon don't have any alpha channel information. (16bpp only icon for instance).
211 * But if the underlying icon has alpha channel information, then we must mark the overlay information
212 * as opaque.
213 * NOTE: This code sucks(tm) and should belong to the ImageList implementation.
214 * NOTE2: there are better ways to do this.
215 */
216 if(ShortcutBitmapInfo.bmBitsPixel == 32)
217 {
218 BOOL add_alpha;
219 BYTE buffer[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
220 BITMAPINFO* lpbmi = (BITMAPINFO*)buffer;
221 PVOID bits;
222 PULONG pixel;
223 INT i, j;
224
225 /* Find if the source bitmap has an alpha channel */
226 if(TargetBitmapInfo.bmBitsPixel != 32) add_alpha = FALSE;
227 else
228 {
229 ZeroMemory(buffer, sizeof(buffer));
230 lpbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
231 lpbmi->bmiHeader.biWidth = TargetBitmapInfo.bmWidth;
232 lpbmi->bmiHeader.biHeight = TargetBitmapInfo.bmHeight;
233 lpbmi->bmiHeader.biPlanes = 1;
234 lpbmi->bmiHeader.biBitCount = 32;
235
236 bits = HeapAlloc(GetProcessHeap(), 0, TargetBitmapInfo.bmHeight * TargetBitmapInfo.bmWidthBytes);
237
238 if(!bits) goto fail;
239
240 if(!GetDIBits(TargetDC, TargetIconInfo.hbmColor, 0, TargetBitmapInfo.bmHeight, bits, lpbmi, DIB_RGB_COLORS))
241 {
242 ERR("GetBIBits failed!\n");
244 goto fail;
245 }
246
247 i = j = 0;
248 pixel = (PULONG)bits;
249
250 for(i=0; i<TargetBitmapInfo.bmHeight; i++)
251 {
252 for(j=0; j<TargetBitmapInfo.bmWidth; j++)
253 {
254 add_alpha = (*pixel++ & 0xFF000000) != 0;
255 if(add_alpha) break;
256 }
257 if(add_alpha) break;
258 }
260 }
261
262 /* Allocate the bits */
263 bits = HeapAlloc(GetProcessHeap(), 0, ShortcutBitmapInfo.bmHeight*ShortcutBitmapInfo.bmWidthBytes);
264 if(!bits) goto fail;
265
266 ZeroMemory(buffer, sizeof(buffer));
267 lpbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
268 lpbmi->bmiHeader.biWidth = ShortcutBitmapInfo.bmWidth;
269 lpbmi->bmiHeader.biHeight = ShortcutBitmapInfo.bmHeight;
270 lpbmi->bmiHeader.biPlanes = 1;
271 lpbmi->bmiHeader.biBitCount = 32;
272
273 if(!GetDIBits(TargetDC, ShortcutIconInfo.hbmColor, 0, ShortcutBitmapInfo.bmHeight, bits, lpbmi, DIB_RGB_COLORS))
274 {
275 ERR("GetBIBits failed!\n");
277 goto fail;
278 }
279
280 pixel = (PULONG)bits;
281 /* Remove alpha channel component or make it totally opaque */
282 for(i=0; i<ShortcutBitmapInfo.bmHeight; i++)
283 {
284 for(j=0; j<ShortcutBitmapInfo.bmWidth; j++)
285 {
286 if(add_alpha) *pixel++ |= 0xFF000000;
287 else *pixel++ &= 0x00FFFFFF;
288 }
289 }
290
291 /* GetDIBits return BI_BITFIELDS with masks set to 0, and SetDIBits fails when masks are 0. The irony... */
293
294 /* Set the bits again */
295 if(!SetDIBits(TargetDC, ShortcutIconInfo.hbmColor, 0, ShortcutBitmapInfo.bmHeight, bits, lpbmi, DIB_RGB_COLORS))
296 {
297 ERR("SetBIBits failed!, %lu\n", GetLastError());
299 goto fail;
300 }
302 }
303
304 /* Now do the copy. We overwrite the original icon data */
305 if (NULL == SelectObject(ShortcutDC, ShortcutIconInfo.hbmColor) ||
306 NULL == SelectObject(TargetDC, TargetIconInfo.hbmColor))
307 goto fail;
308 if (!MaskBlt(TargetDC, 0, 0, ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
309 ShortcutDC, 0, 0, ShortcutIconInfo.hbmMask, 0, 0,
310 MAKEROP4(0xAA0000, SRCCOPY)))
311 {
312 goto fail;
313 }
314
315 /* Clean up, we're not goto'ing to 'fail' after this so we can be lazy and not set
316 handles to NULL */
317 SelectObject(TargetDC, OldTargetBitmap);
318 DeleteDC(TargetDC);
319 SelectObject(ShortcutDC, OldShortcutBitmap);
320 DeleteDC(ShortcutDC);
321
322 /* Create the icon using the bitmaps prepared earlier */
323 TargetIcon = CreateIconIndirect(&TargetIconInfo);
324
325 /* CreateIconIndirect copies the bitmaps, so we can release our bitmaps now */
326 DeleteObject(TargetIconInfo.hbmColor);
327 DeleteObject(TargetIconInfo.hbmMask);
328 /* Delete what GetIconInfo gave us */
329 DeleteObject(ShortcutIconInfo.hbmColor);
330 DeleteObject(ShortcutIconInfo.hbmMask);
331 DestroyIcon(ShortcutIcon);
332
333 return TargetIcon;
334
335fail:
336 /* Clean up scratch resources we created */
337 if (NULL != OldTargetBitmap) SelectObject(TargetDC, OldTargetBitmap);
338 if (NULL != TargetDC) DeleteDC(TargetDC);
339 if (NULL != OldShortcutBitmap) SelectObject(ShortcutDC, OldShortcutBitmap);
340 if (NULL != ShortcutDC) DeleteDC(ShortcutDC);
341 if (NULL != TargetIconInfo.hbmColor) DeleteObject(TargetIconInfo.hbmColor);
342 if (NULL != TargetIconInfo.hbmMask) DeleteObject(TargetIconInfo.hbmMask);
343 if (NULL != ShortcutIconInfo.hbmColor) DeleteObject(ShortcutIconInfo.hbmColor);
344 if (NULL != ShortcutIconInfo.hbmMask) DeleteObject(ShortcutIconInfo.hbmMask);
345 if (NULL != ShortcutIcon) DestroyIcon(ShortcutIcon);
346
347 return NULL;
348}
HICON WINAPI ImageList_GetIcon(HIMAGELIST himl, INT i, UINT fStyle)
Definition: imagelist.c:1970
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:658
#define bits
Definition: infblock.c:15
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
#define ILD_TRANSPARENT
Definition: commctrl.h:418
#define IDI_SHELL_SHORTCUT
Definition: shresdef.h:582
Definition: bl.h:1331
HBITMAP hbmColor
Definition: winuser.h:3130
HBITMAP hbmMask
Definition: winuser.h:3129
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:1737
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#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:1546
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
BOOL WINAPI DeleteDC(_In_ HDC)
#define SRCAND
Definition: wingdi.h:330
#define MAKEROP4(f, b)
Definition: wingdi.h:2946
HICON WINAPI CreateIconIndirect(_In_ PICONINFO)
Definition: cursoricon.c:2667
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2131
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

◆ ShellIconBPP

INT ShellIconBPP = 0

Definition at line 32 of file iconcache.cpp.

Referenced by SIC_Initialize().

◆ ShellLargeIconSize

INT ShellLargeIconSize = 0

Definition at line 31 of file iconcache.cpp.

Referenced by SHGetFileInfoW(), SIC_Initialize(), and SIC_LoadIcon().

◆ ShellSmallIconList

HIMAGELIST ShellSmallIconList
static

◆ ShellSmallIconSize

INT ShellSmallIconSize = 0

Definition at line 30 of file iconcache.cpp.

Referenced by SHGetFileInfoW(), SIC_Initialize(), and SIC_LoadIcon().

◆ sic_hdpa