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));
351 if (!(fsizel | fsizeh))
380 if ((fsizel >= 52) && !
memcmp(peimage,
"RIFF", 4))
388 if ((uSize <
strlen(
"anih")) || (uSize > fsizel))
392 anihMax = uSize -
strlen(
"anih");
394 for (anihOffset = 0; anihOffset < anihMax; anihOffset++)
396 if (
memcmp(&peimage[anihOffset],
"anih", 4) == 0)
400 if (anihOffset +
sizeof(aniheader) > fsizel)
404 ret =
MAKEWORD(peimage[anihOffset + 12], peimage[anihOffset + 13]);
406 TRACE(
"RIFF File with '%u' images at Offset '%u'.\n",
ret, anihOffset);
425 *pIconId = 0xFFFFFFFF;
428 pIconId = (
UINT*)RetPtr;
442 TRACE(
"-- OS2/icon Signature (0x%08x)\n", sig);
449 iconDirCount = 1; iconCount = lpiID->
idCount;
450 TRACE(
"-- icon found %p 0x%08x 0x%08x 0x%08x\n", pCIDir, uSize, iconDirCount, iconCount);
453 else while (pTInfo->
type_id && !(pIconStorage && pIconDir))
457 iconDirCount = pTInfo->
count;
459 TRACE(
"\tfound directory - %i icon families\n", iconDirCount);
463 iconCount = pTInfo->
count;
465 TRACE(
"\ttotal icons - %i\n", iconCount);
470 if ((pIconStorage && pIconDir) || lpiID)
478 else if (nIconIndex < iconDirCount)
481 if (nIcons > iconDirCount - nIconIndex)
482 nIcons = iconDirCount - nIconIndex;
484 for (
i = 0;
i < nIcons;
i++)
495 for (icon = 0; icon < nIcons; icon++)
501 for (
i = 0;
i < iconCount;
i++)
502 if (pIconStorage[
i].
id == ((
int)pIconId[icon] | 0x8000) )
521 if (sig == 1 || sig == 2)
523 TRACE(
"-- icon Signature (0x%08x)\n", sig);
527 INT cx[2] = {cx1, cx2},
cy[2] = {cy1, cy2};
547 DWORD cbColorTable = 0, cbTotal;
550 imageData = peimage + dataOffset;
576#define WIDTHBYTES(width, bits) (((width) * (bits) + 31) / 32 * 4)
600 cursorData[0] = hotSpot.
x;
601 cursorData[1] = hotSpot.
y;
604 CopyMemory(cursorData + 2, imageData, cbTotal);
606 memcpy(cursorData + 2, imageData,
entry->icHeader.biSizeImage);
609 imageData = (
LPBYTE)cursorData;
614 if (fIconEx && sig == 1)
625 RetPtr[
index] = icon;
642 BYTE *idata, *igdata;
652 WARN(
"haven't found section for resource directory.\n");
668 WARN(
"No Icongroupresourcedirectory!\n");
684 int iId =
abs(nIconIndex);
687 while(
n<iconDirCount && xprdeTmp)
689 if(xprdeTmp->
Id == iId)
699 WARN(
"resource id %d not found\n", iId);
706 if (nIconIndex >= iconDirCount)
708 WARN(
"nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount);
714 if( nIcons > iconDirCount - nIconIndex )
715 nIcons = iconDirCount - nIconIndex;
720 for (
i=0;
i < nIcons;
i++,xresent++)
735 FIXME(
"no matching real address for icongroup!\n");
744 WARN(
"No Iconresourcedirectory!\n");
748 for (
i=0;
i<nIcons;
i++)
759 WARN(
"icon entry %d not found\n",
LOWORD(pIconId[
i]));
822 WARN(
"icon entry %d not found\n",
LOWORD(pIconId[
i]));
833 WARN(
"no matching real address found for icondata!\n");
875 TRACE(
"%s %d %dx%d %p %p %d 0x%08x\n",
876 debugstr_w(lpwstrFile), nIndex, sizeX, sizeY, phicon, pIconId, nIcons,
flags);
880 WARN(
"Uneven number %d of icons requested for small and large icons!\n", nIcons);
908 if (lpwstrFile ==
NULL)
931 DWORD cyicon, cysmicon, cxicon, cxsmicon;
934 TRACE(
"%s %d %p %p %d\n",
935 debugstr_w(lpwstrFile),nIndex,phIconLarge, phIconSmall, nIcons);
938 if (nIndex == -1 || (!phIconSmall && !phIconLarge))
948 if (nIcons == 1 && phIconSmall && phIconLarge)
958 cxicon | (cxsmicon<<16),
959 cyicon | (cysmicon<<16),
NULL,
965 *phIconLarge =
hIcon[0];
966 *phIconSmall =
hIcon[1];
1005 HICON * phIconLarge,
1006 HICON * phIconSmall,
1013 if (lpwstrFile ==
NULL)
1017 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)