28#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
77typedef struct taganiheader
91#define NE_RSCTYPE_ICON 0x8003
92#define NE_RSCTYPE_GROUP_ICON 0x800e
99 TRACE(
"width = 0x%08x height = 0x%08x\n",
entry->bWidth,
entry->bHeight);
100 TRACE(
"colors = 0x%08x planes = 0x%08x\n",
entry->bColorCount,
entry->wPlanes);
101 TRACE(
"bitcount = 0x%08x bytesinres = 0x%08lx offset = 0x%08lx\n",
106 TRACE(
"type = 0x%08x count = 0x%08x\n",
entry->idType,
entry->idCount);
133 min =
dir->NumberOfNamedEntries;
167 TRACE(
"%p %p\n", peimage, retptr);
183 if (mz_header->
e_lfanew >= pesize) {
212 TRACE(
"%p %p 0x%08x\n", peimage, pNInfo, sizeShift);
215 return peimage + ((
DWORD)pNInfo->
offset << sizeShift);
223 TRACE(
"%p %p\n", peimage, lpiIDE);
240 TRACE(
"%p %p\n", peimage, lplpiID);
303 UINT cx1, cx2, cy1, cy2;
307 UINT16 iconDirCount = 0,iconCount = 0;
315 DWORD dwSearchReturn;
318 TRACE(
"%s, %d, %d, %p, 0x%08x, %d\n",
debugstr_w(lpszExeFileName), nIconIndex, nIcons, pIconId,
flags, fIconEx);
320 TRACE(
"%s, %d, %d %p 0x%08x\n",
debugstr_w(lpszExeFileName), nIconIndex, nIcons, pIconId,
flags);
328 lpszExeFileName = szExpandedExePath;
332 if ((dwSearchReturn == 0) || (dwSearchReturn >
ARRAY_SIZE(szExePath)))
335 WARN(
"File %s not found or path too long and fIconEx is '%d'\n",
337 if (fIconEx && !RetPtr && !pIconId)
342 WARN(
"File %s not found or path too long\n",
debugstr_w(lpszExeFileName));
372 if ((fsizel >= 52) && !
memcmp(peimage,
"RIFF", 4))
380 if ((uSize <
strlen(
"anih")) || (uSize > fsizel))
384 anihMax = uSize -
strlen(
"anih");
386 for (anihOffset = 0; anihOffset < anihMax; anihOffset++)
388 if (
memcmp(&peimage[anihOffset],
"anih", 4) == 0)
392 if (anihOffset +
sizeof(aniheader) > fsizel)
396 ret =
MAKEWORD(peimage[anihOffset + 12], peimage[anihOffset + 13]);
398 TRACE(
"RIFF File with '%u' images at Offset '%u'.\n",
ret, anihOffset);
417 *pIconId = 0xFFFFFFFF;
420 pIconId = (
UINT*)RetPtr;
434 TRACE(
"-- OS2/icon Signature (0x%08x)\n", sig);
441 iconDirCount = 1; iconCount = lpiID->
idCount;
442 TRACE(
"-- icon found %p 0x%08x 0x%08x 0x%08x\n", pCIDir, uSize, iconDirCount, iconCount);
445 else while (pTInfo->
type_id && !(pIconStorage && pIconDir))
449 iconDirCount = pTInfo->
count;
451 TRACE(
"\tfound directory - %i icon families\n", iconDirCount);
455 iconCount = pTInfo->
count;
457 TRACE(
"\ttotal icons - %i\n", iconCount);
462 if ((pIconStorage && pIconDir) || lpiID)
470 else if (nIconIndex < iconDirCount)
473 if (nIcons > iconDirCount - nIconIndex)
474 nIcons = iconDirCount - nIconIndex;
476 for (
i = 0;
i < nIcons;
i++)
487 for (icon = 0; icon < nIcons; icon++)
493 for (
i = 0;
i < iconCount;
i++)
494 if (pIconStorage[
i].
id == ((
int)pIconId[icon] | 0x8000) )
513 if (sig == 1 || sig == 2)
515 TRACE(
"-- icon Signature (0x%08x)\n", sig);
519 INT cx[2] = {cx1, cx2},
cy[2] = {cy1, cy2};
539 DWORD cbColorTable = 0, cbTotal;
542 imageData = peimage + dataOffset;
568#define WIDTHBYTES(width, bits) (((width) * (bits) + 31) / 32 * 4)
592 cursorData[0] = hotSpot.
x;
593 cursorData[1] = hotSpot.
y;
596 CopyMemory(cursorData + 2, imageData, cbTotal);
598 memcpy(cursorData + 2, imageData,
entry->icHeader.biSizeImage);
601 imageData = (
LPBYTE)cursorData;
606 if (fIconEx && sig == 1)
617 RetPtr[
index] = icon;
634 BYTE *idata, *igdata;
644 WARN(
"haven't found section for resource directory.\n");
660 WARN(
"No Icongroupresourcedirectory!\n");
676 int iId =
abs(nIconIndex);
679 while(
n<iconDirCount && xprdeTmp)
681 if(xprdeTmp->
Id == iId)
691 WARN(
"resource id %d not found\n", iId);
698 if (nIconIndex >= iconDirCount)
700 WARN(
"nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount);
706 if( nIcons > iconDirCount - nIconIndex )
707 nIcons = iconDirCount - nIconIndex;
712 for (
i=0;
i < nIcons;
i++,xresent++)
727 FIXME(
"no matching real address for icongroup!\n");
736 WARN(
"No Iconresourcedirectory!\n");
740 for (
i=0;
i<nIcons;
i++)
751 WARN(
"icon entry %d not found\n",
LOWORD(pIconId[
i]));
814 WARN(
"icon entry %d not found\n",
LOWORD(pIconId[
i]));
825 WARN(
"no matching real address found for icondata!\n");
867 TRACE(
"%s %d %dx%d %p %p %d 0x%08x\n",
868 debugstr_w(lpwstrFile), nIndex, sizeX, sizeY, phicon, pIconId, nIcons,
flags);
872 WARN(
"Uneven number %d of icons requested for small and large icons!\n", nIcons);
900 if (lpwstrFile ==
NULL)
923 DWORD cyicon, cysmicon, cxicon, cxsmicon;
926 TRACE(
"%s %d %p %p %d\n",
927 debugstr_w(lpwstrFile),nIndex,phIconLarge, phIconSmall, nIcons);
930 if (nIndex == -1 || (!phIconSmall && !phIconLarge))
940 if (nIcons == 1 && phIconSmall && phIconLarge)
950 cxicon | (cxsmicon<<16),
951 cyicon | (cysmicon<<16),
NULL,
957 *phIconLarge =
hIcon[0];
958 *phIconSmall =
hIcon[1];
1005 if (lpwstrFile ==
NULL)
1009 TRACE(
"%s %d %p %p %d\n", lpstrFile, nIndex, phIconLarge, phIconSmall, nIcons);
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
#define INVALID_HANDLE_VALUE
#define CreateFileMappingW(a, b, c, d, e, f)
#define RtlImageDirectoryEntryToData
#define HeapFree(x, y, z)
#define MultiByteToWideChar
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
static const IMAGE_RESOURCE_DIRECTORY * find_entry_default(const IMAGE_RESOURCE_DIRECTORY *dir, const void *root)
struct icoICONDIRENTRY * LPicoICONDIRENTRY
UINT WINAPI PrivateExtractIconExW(LPCWSTR lpwstrFile, int nIndex, HICON *phIconLarge, HICON *phIconSmall, UINT nIcons)
static BYTE * USER32_LoadResource(LPBYTE peimage, NE_NAMEINFO *pNInfo, WORD sizeShift, ULONG *uSize)
UINT WINAPI PrivateExtractIconsA(LPCSTR lpstrFile, int nIndex, int sizeX, int sizeY, HICON *phicon, UINT *piconid, UINT nIcons, UINT flags)
static BYTE * ICO_GetIconDirectory(LPBYTE peimage, LPicoICONDIR *lplpiID, ULONG *uSize)
static UINT ICO_ExtractIconExW(LPCWSTR lpszExeFileName, HICON *RetPtr, INT nIconIndex, UINT nIcons, UINT cxDesired, UINT cyDesired, UINT *pIconId, UINT flags)
static DWORD USER32_GetResourceTable(LPBYTE peimage, DWORD pesize, LPBYTE *retptr)
DWORD get_best_icon_file_offset(const LPBYTE dir, DWORD dwFileSize, int cxDesired, int cyDesired, BOOL bIcon, DWORD fuLoad, POINT *ptHotSpot)
UINT WINAPI PrivateExtractIconsW(LPCWSTR lpwstrFile, int nIndex, int sizeX, int sizeY, HICON *phicon, UINT *pIconId, UINT nIcons, UINT flags)
static const IMAGE_RESOURCE_DIRECTORY * find_entry_by_id(const IMAGE_RESOURCE_DIRECTORY *dir, WORD id, const void *root)
struct icoICONDIR * LPicoICONDIR
#define NE_RSCTYPE_GROUP_ICON
static BYTE * ICO_LoadIcon(LPBYTE peimage, LPicoICONDIRENTRY lpiIDE, ULONG *uSize)
UINT WINAPI PrivateExtractIconExA(LPCSTR lpstrFile, int nIndex, HICON *phIconLarge, HICON *phIconSmall, UINT nIcons)
GLuint GLuint GLsizei count
GLuint GLsizei GLsizei * length
GLsizeiptr const GLvoid GLenum usage
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
#define memcpy(s1, s2, n)
struct _ICONIMAGE * LPICONIMAGE
#define IMAGE_NT_SIGNATURE
#define IMAGE_OS2_SIGNATURE
#define IMAGE_DOS_SIGNATURE
#define IMAGE_DIRECTORY_ENTRY_RESOURCE
_Out_opt_ int _Out_opt_ int * cy
CURSORICONDIRENTRY idEntries[1]
WORD NumberOfNamedEntries
icoICONDIRENTRY idEntries[1]
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
DWORD WINAPI GetLastError(void)
HICON WINAPI CreateIconFromResourceEx(_In_reads_bytes_(dwResSize) PBYTE presbits, _In_ DWORD dwResSize, _In_ BOOL fIcon, _In_ DWORD dwVer, _In_ int cxDesired, _In_ int cyDesired, _In_ UINT Flags)
int WINAPI LookupIconIdFromDirectoryEx(_In_reads_bytes_(sizeof(NEWHEADER)) PBYTE, _In_ BOOL, _In_ int, _In_ int, _In_ UINT)
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI DestroyIcon(_In_ HICON)