4 * taken and slightly changed from shell
5 * this should replace the icon extraction code in shell32 and shell16 once
6 * it needs a serious test for compliance with the native API
8 * Copyright 2000 Juergen Schmied
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include <wine/debug.h>
29 /* Start of Hack section */
31 WINE_DEFAULT_DEBUG_CHANNEL(icon
);
34 static void dumpIcoDirEnty ( LPicoICONDIRENTRY entry
)
36 TRACE("width = 0x%08x height = 0x%08x\n", entry
->bWidth
, entry
->bHeight
);
37 TRACE("colors = 0x%08x planes = 0x%08x\n", entry
->bColorCount
, entry
->wPlanes
);
38 TRACE("bitcount = 0x%08x bytesinres = 0x%08lx offset = 0x%08lx\n",
39 entry
->wBitCount
, entry
->dwBytesInRes
, entry
->dwImageOffset
);
41 static void dumpIcoDir ( LPicoICONDIR entry
)
43 TRACE("type = 0x%08x count = 0x%08x\n", entry
->idType
, entry
->idCount
);
47 /**********************************************************************
50 * Find an entry by id in a resource directory
51 * Copied from loader/pe_resource.c (FIXME: should use exported resource functions)
53 static const IMAGE_RESOURCE_DIRECTORY
*find_entry_by_id( const IMAGE_RESOURCE_DIRECTORY
*dir
,
54 WORD id
, const void *root
)
56 const IMAGE_RESOURCE_DIRECTORY_ENTRY
*entry
;
59 entry
= (const IMAGE_RESOURCE_DIRECTORY_ENTRY
*)(dir
+ 1);
60 min
= dir
->NumberOfNamedEntries
;
61 max
= min
+ dir
->NumberOfIdEntries
- 1;
64 pos
= (min
+ max
) / 2;
65 if (entry
[pos
].Id
== id
)
66 return (const IMAGE_RESOURCE_DIRECTORY
*)((const char *)root
+ entry
[pos
].OffsetToDirectory
);
67 if (entry
[pos
].Id
> id
) max
= pos
- 1;
73 /**********************************************************************
76 * Find a default entry in a resource directory
77 * Copied from loader/pe_resource.c (FIXME: should use exported resource functions)
79 static const IMAGE_RESOURCE_DIRECTORY
*find_entry_default( const IMAGE_RESOURCE_DIRECTORY
*dir
,
82 const IMAGE_RESOURCE_DIRECTORY_ENTRY
*entry
;
83 entry
= (const IMAGE_RESOURCE_DIRECTORY_ENTRY
*)(dir
+ 1);
84 return (const IMAGE_RESOURCE_DIRECTORY
*)((const char *)root
+ entry
->OffsetToDirectory
);
87 /*************************************************************************
88 * USER32_GetResourceTable
90 static DWORD
USER32_GetResourceTable(LPBYTE peimage
,DWORD pesize
,LPBYTE
*retptr
)
92 IMAGE_DOS_HEADER
* mz_header
;
94 TRACE("%p %p\n", peimage
, retptr
);
98 mz_header
= (IMAGE_DOS_HEADER
*) peimage
;
100 if (mz_header
->e_magic
!= IMAGE_DOS_SIGNATURE
)
102 if (mz_header
->e_cblp
== 1) /* .ICO file ? */
104 *retptr
= (LPBYTE
)-1; /* ICONHEADER.idType, must be 1 */
108 return 0; /* failed */
110 if (mz_header
->e_lfanew
>= pesize
) {
111 return 0; /* failed, happens with PKZIP DOS Exes for instance. */
113 if (*((DWORD
*)(peimage
+ mz_header
->e_lfanew
)) == IMAGE_NT_SIGNATURE
)
114 return IMAGE_NT_SIGNATURE
;
116 if (*((WORD
*)(peimage
+ mz_header
->e_lfanew
)) == IMAGE_OS2_SIGNATURE
)
118 IMAGE_OS2_HEADER
* ne_header
;
120 ne_header
= (IMAGE_OS2_HEADER
*)(peimage
+ mz_header
->e_lfanew
);
122 if (ne_header
->ne_magic
!= IMAGE_OS2_SIGNATURE
)
125 if( (ne_header
->ne_restab
- ne_header
->ne_rsrctab
) <= sizeof(NE_TYPEINFO
) )
126 *retptr
= (LPBYTE
)-1;
128 *retptr
= peimage
+ mz_header
->e_lfanew
+ ne_header
->ne_rsrctab
;
130 return IMAGE_OS2_SIGNATURE
;
133 return 0; /* failed */
136 /*************************************************************************
137 * USER32_LoadResource
139 static BYTE
* USER32_LoadResource( LPBYTE peimage
, NE_NAMEINFO
* pNInfo
, WORD sizeShift
, ULONG
*uSize
)
141 TRACE("%p %p 0x%08x\n", peimage
, pNInfo
, sizeShift
);
143 *uSize
= (DWORD
)pNInfo
->length
<< sizeShift
;
144 return peimage
+ ((DWORD
)pNInfo
->offset
<< sizeShift
);
147 /*************************************************************************
150 static BYTE
* ICO_LoadIcon( LPBYTE peimage
, LPicoICONDIRENTRY lpiIDE
, ULONG
*uSize
)
152 TRACE("%p %p\n", peimage
, lpiIDE
);
154 *uSize
= lpiIDE
->dwBytesInRes
;
155 return peimage
+ lpiIDE
->dwImageOffset
;
158 /*************************************************************************
159 * ICO_GetIconDirectory
161 * Reads .ico file and build phony ICONDIR struct
163 #define HEADER_SIZE (sizeof(CURSORICONDIR) - sizeof (CURSORICONDIRENTRY))
164 #define HEADER_SIZE_FILE (sizeof(icoICONDIR) - sizeof (icoICONDIRENTRY))
166 static BYTE
* ICO_GetIconDirectory( LPBYTE peimage
, LPicoICONDIR
* lplpiID
, ULONG
*uSize
)
168 CURSORICONDIR
* lpcid
; /* icon resource in resource-dir format */
169 CURSORICONDIR
* lpID
; /* icon resource in resource format */
172 TRACE("%p %p\n", peimage
, lplpiID
);
174 lpcid
= (CURSORICONDIR
*)peimage
;
176 if( lpcid
->idReserved
|| (lpcid
->idType
!= 1) || (!lpcid
->idCount
) )
179 /* allocate the phony ICONDIR structure */
180 *uSize
= lpcid
->idCount
* sizeof(CURSORICONDIRENTRY
) + HEADER_SIZE
;
181 if( (lpID
= HeapAlloc(GetProcessHeap(),0, *uSize
) ))
183 /* copy the header */
184 lpID
->idReserved
= lpcid
->idReserved
;
185 lpID
->idType
= lpcid
->idType
;
186 lpID
->idCount
= lpcid
->idCount
;
188 /* copy the entries */
189 for( i
=0; i
< lpcid
->idCount
; i
++ )
191 memcpy(&lpID
->idEntries
[i
], &lpcid
->idEntries
[i
], sizeof(CURSORICONDIRENTRY
) - 2);
192 lpID
->idEntries
[i
].wResId
= i
;
195 *lplpiID
= (LPicoICONDIR
)peimage
;
201 /*************************************************************************
202 * ICO_ExtractIconExW [internal]
205 * nIcons = 0: returns number of Icons in file
210 * success: number of icons in file (nIcons = 0) or nr of icons retrieved
212 static UINT
ICO_ExtractIconExW(
213 LPCWSTR lpszExeFileName
,
223 UINT cx1
, cx2
, cy1
, cy2
;
227 UINT16 iconDirCount
= 0; //,iconCount = 0;
231 WCHAR szExePath
[MAX_PATH
];
232 DWORD dwSearchReturn
;
234 TRACE("%s, %d, %d %p 0x%08x\n", debugstr_w(lpszExeFileName
), nIconIndex
, nIcons
, pIconId
, flags
);
236 dwSearchReturn
= SearchPathW(NULL
, lpszExeFileName
, NULL
, sizeof(szExePath
) / sizeof(szExePath
[0]), szExePath
, NULL
);
237 if ((dwSearchReturn
== 0) || (dwSearchReturn
> sizeof(szExePath
) / sizeof(szExePath
[0])))
239 WARN("File %s not found or path too long\n", debugstr_w(lpszExeFileName
));
243 hFile
= CreateFileW(szExePath
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, 0);
244 if (hFile
== INVALID_HANDLE_VALUE
) return ret
;
245 fsizel
= GetFileSize(hFile
,&fsizeh
);
248 fmapping
= CreateFileMappingW(hFile
, NULL
, PAGE_READONLY
| SEC_COMMIT
, 0, 0, NULL
);
252 WARN("CreateFileMapping error %ld\n", GetLastError() );
256 if (!(peimage
= MapViewOfFile(fmapping
, FILE_MAP_READ
, 0, 0, 0)))
258 WARN("MapViewOfFile error %ld\n", GetLastError() );
259 CloseHandle(fmapping
);
262 CloseHandle(fmapping
);
264 cx1
= LOWORD(cxDesired
);
265 cx2
= HIWORD(cxDesired
);
266 cy1
= LOWORD(cyDesired
);
267 cy2
= HIWORD(cyDesired
);
269 if (pIconId
) /* Invalidate first icon identifier */
270 *pIconId
= 0xFFFFFFFF;
272 if (!pIconId
) /* if no icon identifier array present use the icon handle array as intermediate storage */
273 pIconId
= (UINT
*)RetPtr
;
275 sig
= USER32_GetResourceTable(peimage
, fsizel
, &pData
);
277 /* ico file or NE exe/dll*/
279 if (sig
==IMAGE_OS2_SIGNATURE
|| sig
==1) /* .ICO file */
282 NE_TYPEINFO
*pTInfo
= (NE_TYPEINFO
*)(pData
+ 2);
283 NE_NAMEINFO
*pIconStorage
= NULL
;
284 NE_NAMEINFO
*pIconDir
= NULL
;
285 LPicoICONDIR lpiID
= NULL
;
287 TRACE("-- OS2/icon Signature (0x%08lx)\n", sig
);
289 if (pData
== (BYTE
*)-1)
291 pCIDir
= ICO_GetIconDirectory(peimage
, &lpiID
, &uSize
); /* check for .ICO file */
294 iconDirCount
= 1; iconCount
= lpiID
->idCount
;
295 TRACE("-- icon found %p 0x%08lx 0x%08x 0x%08x\n", pCIDir
, uSize
, iconDirCount
, iconCount
);
298 else while (pTInfo
->type_id
&& !(pIconStorage
&& pIconDir
))
300 if (pTInfo
->type_id
== NE_RSCTYPE_GROUP_ICON
) /* find icon directory and icon repository */
302 iconDirCount
= pTInfo
->count
;
303 pIconDir
= ((NE_NAMEINFO
*)(pTInfo
+ 1));
304 TRACE("\tfound directory - %i icon families\n", iconDirCount
);
306 if (pTInfo
->type_id
== NE_RSCTYPE_ICON
)
308 iconCount
= pTInfo
->count
;
309 pIconStorage
= ((NE_NAMEINFO
*)(pTInfo
+ 1));
310 TRACE("\ttotal icons - %i\n", iconCount
);
312 pTInfo
= (NE_TYPEINFO
*)((char*)(pTInfo
+1)+pTInfo
->count
*sizeof(NE_NAMEINFO
));
315 if ((pIconStorage
&& pIconDir
) || lpiID
) /* load resources and create icons */
320 if (lpiID
&& pCIDir
) /* *.ico file, deallocate heap pointer*/
321 HeapFree(GetProcessHeap(), 0, pCIDir
);
323 else if (nIconIndex
< iconDirCount
)
326 if (nIcons
> iconDirCount
- nIconIndex
)
327 nIcons
= iconDirCount
- nIconIndex
;
329 for (i
= 0; i
< nIcons
; i
++)
331 /* .ICO files have only one icon directory */
332 if (lpiID
== NULL
) /* not *.ico */
333 pCIDir
= USER32_LoadResource(peimage
, pIconDir
+ i
+ nIconIndex
, *(WORD
*)pData
, &uSize
);
334 pIconId
[i
] = LookupIconIdFromDirectoryEx(pCIDir
, TRUE
, (i
& 1) ? cx2
: cx1
, (i
& 1) ? cy2
: cy1
, flags
);
336 if (lpiID
&& pCIDir
) /* *.ico file, deallocate heap pointer*/
337 HeapFree(GetProcessHeap(), 0, pCIDir
);
339 for (icon
= 0; icon
< nIcons
; icon
++)
343 pCIDir
= ICO_LoadIcon(peimage
, lpiID
->idEntries
+ (int)pIconId
[icon
], &uSize
);
345 for (i
= 0; i
< iconCount
; i
++)
346 if (pIconStorage
[i
].id
== ((int)pIconId
[icon
] | 0x8000) )
347 pCIDir
= USER32_LoadResource(peimage
, pIconStorage
+ i
, *(WORD
*)pData
, &uSize
);
350 RetPtr
[icon
] = (HICON
)CreateIconFromResourceEx(pCIDir
, uSize
, TRUE
, 0x00030000,
351 (icon
& 1) ? cx2
: cx1
, (icon
& 1) ? cy2
: cy1
, flags
);
355 ret
= icon
; /* return number of retrieved icons */
362 else if( sig
== IMAGE_NT_SIGNATURE
)
364 if( sig
== IMAGE_NT_SIGNATURE
)
367 PIMAGE_DOS_HEADER dheader
;
368 PIMAGE_NT_HEADERS pe_header
;
369 PIMAGE_SECTION_HEADER pe_sections
;
370 const IMAGE_RESOURCE_DIRECTORY
*rootresdir
,*iconresdir
,*icongroupresdir
;
371 const IMAGE_RESOURCE_DATA_ENTRY
*idataent
,*igdataent
;
372 const IMAGE_RESOURCE_DIRECTORY_ENTRY
*xresent
;
375 dheader
= (PIMAGE_DOS_HEADER
)peimage
;
376 pe_header
= (PIMAGE_NT_HEADERS
)(peimage
+dheader
->e_lfanew
); /* it is a pe header, USER32_GetResourceTable checked that */
377 pe_sections
= (PIMAGE_SECTION_HEADER
)(((char*)pe_header
) + sizeof(DWORD
) + sizeof(IMAGE_FILE_HEADER
)
378 + pe_header
->FileHeader
.SizeOfOptionalHeader
);
381 /* search for the root resource directory */
382 for (i
=0;i
<pe_header
->FileHeader
.NumberOfSections
;i
++)
384 if (pe_sections
[i
].Characteristics
& IMAGE_SCN_CNT_UNINITIALIZED_DATA
)
386 if (fsizel
< pe_sections
[i
].PointerToRawData
+pe_sections
[i
].SizeOfRawData
) {
387 FIXME("File %s too short (section is at %ld bytes, real size is %ld)\n",
388 debugstr_w(lpszExeFileName
),
389 pe_sections
[i
].PointerToRawData
+pe_sections
[i
].SizeOfRawData
,
394 /* FIXME: doesn't work when the resources are not in a separate section */
395 if (pe_sections
[i
].VirtualAddress
== pe_header
->OptionalHeader
.DataDirectory
[IMAGE_DIRECTORY_ENTRY_RESOURCE
].VirtualAddress
)
397 rootresdir
= (PIMAGE_RESOURCE_DIRECTORY
)(peimage
+pe_sections
[i
].PointerToRawData
);
404 WARN("haven't found section for resource directory.\n");
405 goto end
; /* failure */
408 /* search for the group icon directory */
409 if (!(icongroupresdir
= find_entry_by_id(rootresdir
, LOWORD(RT_GROUP_ICON
), rootresdir
)))
411 WARN("No Icongroupresourcedirectory!\n");
412 goto end
; /* failure */
414 iconDirCount
= icongroupresdir
->NumberOfNamedEntries
+ icongroupresdir
->NumberOfIdEntries
;
416 /* only number of icons requested */
420 goto end
; /* success */
425 /* search resource id */
427 int iId
= abs(nIconIndex
);
428 const IMAGE_RESOURCE_DIRECTORY_ENTRY
* xprdeTmp
= (const IMAGE_RESOURCE_DIRECTORY_ENTRY
*)(icongroupresdir
+1);
430 while(n
<iconDirCount
&& xprdeTmp
)
432 if(xprdeTmp
->Id
== iId
)
442 WARN("resource id %d not found\n", iId
);
443 goto end
; /* failure */
448 /* check nIconIndex to be in range */
449 if (nIconIndex
>= iconDirCount
)
451 WARN("nIconIndex %d is larger than iconDirCount %d\n",nIconIndex
,iconDirCount
);
452 goto end
; /* failure */
456 /* assure we don't get too much */
457 if( nIcons
> iconDirCount
- nIconIndex
)
458 nIcons
= iconDirCount
- nIconIndex
;
460 /* starting from specified index */
461 xresent
= (const IMAGE_RESOURCE_DIRECTORY_ENTRY
*)(icongroupresdir
+1) + nIconIndex
;
463 for (i
=0; i
< nIcons
; i
++,xresent
++)
465 const IMAGE_RESOURCE_DIRECTORY
*resdir
;
467 /* go down this resource entry, name */
468 resdir
= (const IMAGE_RESOURCE_DIRECTORY
*)((const char *)rootresdir
+(xresent
->OffsetToDirectory
));
470 /* default language (0) */
471 resdir
= find_entry_default(resdir
,rootresdir
);
472 igdataent
= (const IMAGE_RESOURCE_DATA_ENTRY
*)resdir
;
474 /* lookup address in mapped image for virtual address */
477 for (j
=0;j
<pe_header
->FileHeader
.NumberOfSections
;j
++)
479 if (igdataent
->OffsetToData
< pe_sections
[j
].VirtualAddress
)
481 if (igdataent
->OffsetToData
+igdataent
->Size
> pe_sections
[j
].VirtualAddress
+pe_sections
[j
].SizeOfRawData
)
484 if (igdataent
->OffsetToData
-pe_sections
[j
].VirtualAddress
+pe_sections
[j
].PointerToRawData
+igdataent
->Size
> fsizel
) {
485 FIXME("overflow in PE lookup (%s has len %ld, have offset %ld), short file?\n", debugstr_w(lpszExeFileName
), fsizel
,
486 igdataent
->OffsetToData
- pe_sections
[j
].VirtualAddress
+ pe_sections
[j
].PointerToRawData
+ igdataent
->Size
);
487 goto end
; /* failure */
489 igdata
= peimage
+(igdataent
->OffsetToData
-pe_sections
[j
].VirtualAddress
+pe_sections
[j
].PointerToRawData
);
494 FIXME("no matching real address for icongroup!\n");
495 goto end
; /* failure */
497 pIconId
[i
] = LookupIconIdFromDirectoryEx(igdata
, TRUE
, cx1
, cy1
, flags
);
498 if (cx2
&& cy2
) pIconId
[++i
] = LookupIconIdFromDirectoryEx(igdata
, TRUE
, cx2
, cy2
, flags
);
501 if (!(iconresdir
=find_entry_by_id(rootresdir
,LOWORD(RT_ICON
),rootresdir
)))
503 WARN("No Iconresourcedirectory!\n");
504 goto end
; /* failure */
507 for (i
=0; i
<nIcons
; i
++)
509 const IMAGE_RESOURCE_DIRECTORY
*xresdir
;
510 xresdir
= find_entry_by_id(iconresdir
, LOWORD(pIconId
[i
]), rootresdir
);
513 WARN("icon entry %d not found\n", LOWORD(pIconId
[i
]));
517 xresdir
= find_entry_default(xresdir
, rootresdir
);
520 WARN("icon entry %d not found\n", LOWORD(pIconId
[i
]));
524 idataent
= (const IMAGE_RESOURCE_DATA_ENTRY
*)xresdir
;
527 /* map virtual to address in image */
528 for (j
=0;j
<pe_header
->FileHeader
.NumberOfSections
;j
++)
530 if (idataent
->OffsetToData
< pe_sections
[j
].VirtualAddress
)
532 if (idataent
->OffsetToData
+idataent
->Size
> pe_sections
[j
].VirtualAddress
+pe_sections
[j
].SizeOfRawData
)
534 idata
= peimage
+(idataent
->OffsetToData
-pe_sections
[j
].VirtualAddress
+pe_sections
[j
].PointerToRawData
);
538 WARN("no matching real address found for icondata!\n");
542 RetPtr
[i
] = CreateIconFromResourceEx(idata
, idataent
->Size
, TRUE
, 0x00030000, cx1
, cy1
, flags
);
544 RetPtr
[++i
] = CreateIconFromResourceEx(idata
, idataent
->Size
, TRUE
, 0x00030000, cx2
, cy2
, flags
);
546 ret
= i
; /* return number of retrieved icons */
547 } /* if(sig == IMAGE_NT_SIGNATURE) */
550 UnmapViewOfFile(peimage
); /* success */
554 /***********************************************************************
555 * PrivateExtractIconsW [USER32.@]
558 * If HIWORD(sizeX) && HIWORD(sizeY) 2 * ((nIcons + 1) MOD 2) icons are
559 * returned, with the LOWORD size icon first and the HIWORD size icon
561 * Also the Windows equivalent does extract icons in a strange way if
562 * nIndex is negative. Our implementation treats a negative nIndex as
563 * looking for that resource identifier for the first icon to retrieve.
566 * should also support 16 bit EXE + DLLs, cursor and animated cursor as
567 * well as bitmap files.
570 UINT WINAPI
PrivateExtractIconsW (
575 HICON
* phicon
, /* [out] pointer to array of nIcons HICON handles */
576 UINT
* pIconId
, /* [out] pointer to array of nIcons icon identifiers or NULL */
577 UINT nIcons
, /* [in] number of icons to retrieve */
578 UINT flags
) /* [in] LR_* flags used by LoadImage */
580 TRACE("%s %d %dx%d %p %p %d 0x%08x\n",
581 debugstr_w(lpwstrFile
), nIndex
, sizeX
, sizeY
, phicon
, pIconId
, nIcons
, flags
);
583 if ((nIcons
& 1) && HIWORD(sizeX
) && HIWORD(sizeY
))
585 WARN("Uneven number %d of icons requested for small and large icons!\n", nIcons
);
587 return ICO_ExtractIconExW(lpwstrFile
, phicon
, nIndex
, nIcons
, sizeX
, sizeY
, pIconId
, flags
);
590 /***********************************************************************
591 * PrivateExtractIconsA [USER32.@]
594 UINT WINAPI
PrivateExtractIconsA (
599 HICON
* phicon
, /* [out] pointer to array of nIcons HICON handles */
600 UINT
* piconid
, /* [out] pointer to array of nIcons icon identifiers or NULL */
601 UINT nIcons
, /* [in] number of icons to retrieve */
602 UINT flags
) /* [in] LR_* flags used by LoadImage */
605 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpstrFile
, -1, NULL
, 0);
606 LPWSTR lpwstrFile
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
607 if (lpwstrFile
== NULL
)
610 MultiByteToWideChar(CP_ACP
, 0, lpstrFile
, -1, lpwstrFile
, len
);
611 ret
= PrivateExtractIconsW(lpwstrFile
, nIndex
, sizeX
, sizeY
, phicon
, piconid
, nIcons
, flags
);
613 HeapFree(GetProcessHeap(), 0, lpwstrFile
);
617 /***********************************************************************
618 * PrivateExtractIconExW [USER32.@]
620 * if nIndex == -1 it returns the number of icons in any case !!!
622 UINT WINAPI
PrivateExtractIconExW (
629 DWORD cyicon
, cysmicon
, cxicon
, cxsmicon
;
632 TRACE("%s %d %p %p %d\n",
633 debugstr_w(lpwstrFile
),nIndex
,phIconLarge
, phIconSmall
, nIcons
);
636 /* get the number of icons */
637 return ICO_ExtractIconExW(lpwstrFile
, NULL
, 0, 0, 0, 0, NULL
, LR_DEFAULTCOLOR
);
639 if (nIcons
== 1 && phIconSmall
&& phIconLarge
)
642 cxicon
= GetSystemMetrics(SM_CXICON
);
643 cyicon
= GetSystemMetrics(SM_CYICON
);
644 cxsmicon
= GetSystemMetrics(SM_CXSMICON
);
645 cysmicon
= GetSystemMetrics(SM_CYSMICON
);
647 ret
= ICO_ExtractIconExW(lpwstrFile
, hIcon
, nIndex
, 2, cxicon
| (cxsmicon
<<16),
648 cyicon
| (cysmicon
<<16), NULL
, LR_DEFAULTCOLOR
);
649 *phIconLarge
= hIcon
[0];
650 *phIconSmall
= hIcon
[1];
656 /* extract n small icons */
657 cxsmicon
= GetSystemMetrics(SM_CXSMICON
);
658 cysmicon
= GetSystemMetrics(SM_CYSMICON
);
659 ret
= ICO_ExtractIconExW(lpwstrFile
, phIconSmall
, nIndex
, nIcons
, cxsmicon
,
660 cysmicon
, NULL
, LR_DEFAULTCOLOR
);
664 /* extract n large icons */
665 cxicon
= GetSystemMetrics(SM_CXICON
);
666 cyicon
= GetSystemMetrics(SM_CYICON
);
667 ret
= ICO_ExtractIconExW(lpwstrFile
, phIconLarge
, nIndex
, nIcons
, cxicon
,
668 cyicon
, NULL
, LR_DEFAULTCOLOR
);
673 /***********************************************************************
674 * PrivateExtractIconExA [USER32.@]
676 UINT WINAPI
PrivateExtractIconExA (
684 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpstrFile
, -1, NULL
, 0);
685 LPWSTR lpwstrFile
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
686 if (lpwstrFile
== NULL
)
689 TRACE("%s %d %p %p %d\n", lpstrFile
, nIndex
, phIconLarge
, phIconSmall
, nIcons
);
691 MultiByteToWideChar(CP_ACP
, 0, lpstrFile
, -1, lpwstrFile
, len
);
692 ret
= PrivateExtractIconExW(lpwstrFile
, nIndex
, phIconLarge
, phIconSmall
, nIcons
);
693 HeapFree(GetProcessHeap(), 0, lpwstrFile
);