287{
289 UINT cx1, cx2, cy1, cy2;
293 UINT16 iconDirCount = 0,iconCount = 0;
297#ifdef __REACTOS__
299#endif
301 DWORD dwSearchReturn;
302
303 TRACE(
"%s, %d, %d %p 0x%08x\n",
debugstr_w(lpszExeFileName), nIconIndex, nIcons, pIconId,
flags);
304
305#ifdef __REACTOS__
306 if (RetPtr)
308
310 lpszExeFileName = szExpandedExePath;
311#endif
312
314 if ((dwSearchReturn == 0) || (dwSearchReturn >
ARRAY_SIZE(szExePath)))
315 {
316 WARN(
"File %s not found or path too long\n",
debugstr_w(lpszExeFileName));
317 return -1;
318 }
319
323
324
327 if (!fmapping)
328 {
330 return 0xFFFFFFFF;
331 }
332
334 {
337 return 0xFFFFFFFF;
338 }
340
341#ifdef __REACTOS__
342
343
344
345 if ((fsizel >= 52) && !
memcmp(peimage,
"RIFF", 4))
346 {
349
351
352
353 if ((uSize <
strlen(
"anih")) || (uSize > fsizel))
355
356
357 anihMax = uSize -
strlen(
"anih");
358
359 for (anihOffset = 0; anihOffset < anihMax; anihOffset++)
360 {
361 if (
memcmp(&peimage[anihOffset],
"anih", 4) == 0)
362 break;
363 }
364
365 if (anihOffset +
sizeof(
aniheader) > fsizel)
367
368
369 ret =
MAKEWORD(peimage[anihOffset + 12], peimage[anihOffset + 13]);
370
371 TRACE(
"RIFF File with '%u' images at Offset '%u'.\n",
ret, anihOffset);
372
375
376 if (RetPtr)
377 {
379 }
381 }
382#endif
383
388
389 if (pIconId)
390 *pIconId = 0xFFFFFFFF;
391
392 if (!pIconId)
393 pIconId = (
UINT*)RetPtr;
394
396
397
399 {
406
407 TRACE(
"-- OS2/icon Signature (0x%08x)\n", sig);
408
410 {
412 if (pCIDir)
413 {
414 iconDirCount = 1; iconCount = lpiID->
idCount;
415 TRACE(
"-- icon found %p 0x%08x 0x%08x 0x%08x\n", pCIDir, uSize, iconDirCount, iconCount);
416 }
417 }
418 else while (pTInfo->
type_id && !(pIconStorage && pIconDir))
419 {
421 {
422 iconDirCount = pTInfo->
count;
424 TRACE(
"\tfound directory - %i icon families\n", iconDirCount);
425 }
427 {
428 iconCount = pTInfo->
count;
430 TRACE(
"\ttotal icons - %i\n", iconCount);
431 }
433 }
434
435 if ((pIconStorage && pIconDir) || lpiID)
436 {
437 if (nIcons == 0)
438 {
440 if (lpiID)
442 }
443 else if (nIconIndex < iconDirCount)
444 {
446 if (nIcons > iconDirCount - nIconIndex)
447 nIcons = iconDirCount - nIconIndex;
448
449 for (
i = 0;
i < nIcons;
i++)
450 {
451
456 }
457 if (lpiID)
459
460 for (icon = 0; icon < nIcons; icon++)
461 {
463 if (lpiID)
465 else
466 for (
i = 0;
i < iconCount;
i++)
467 if (pIconStorage[
i].
id == ((
int)pIconId[icon] | 0x8000) )
469
470 if (pCIDir)
471 {
474 if (cx2 && cy2)
477 }
478 else
479 RetPtr[icon] = 0;
480 }
482 }
483 }
484 }
485 else
486 if (sig == 1 || sig == 2)
487 {
488 TRACE(
"-- icon Signature (0x%08x)\n", sig);
489
491 {
492 INT cx[2] = {cx1, cx2},
cy[2] = {cy1, cy2};
494
496 {
500#ifndef __REACTOS__
502#endif
503
505
506 if (dataOffset)
507 {
510#ifdef __REACTOS__
512 DWORD cbColorTable = 0, cbTotal;
513#endif
514
515 imageData = peimage + dataOffset;
516#ifdef __REACTOS__
517
521 {
523 {
527 else
529 }
531 {
533 }
534 }
535
536
537
539 {
540
541#define WIDTHBYTES(width, bits) (((width) * (bits) + 31) / 32 * 4)
544#undef WIDTHBYTES
545 }
546
547
549#else
551#endif
552
553 if(sig == 2)
554 {
555
556#ifdef __REACTOS__
558#else
560#endif
561
562 if(!cursorData)
563 continue;
564
565 cursorData[0] = hotSpot.
x;
566 cursorData[1] = hotSpot.
y;
567
568#ifdef __REACTOS__
569 CopyMemory(cursorData + 2, imageData, cbTotal);
570#else
571 memcpy(cursorData + 2, imageData,
entry->icHeader.biSizeImage);
572#endif
573
574 imageData = (
LPBYTE)cursorData;
575 }
576
577#ifdef __REACTOS__
579#else
581#endif
582
584
585 if (icon)
586 {
587 if (RetPtr)
588 RetPtr[
index] = icon;
589 else
591
592 iconCount = 1;
593 break;
594 }
595 }
596 }
597 }
599 }
600
601
602
604 {
605 BYTE *idata, *igdata;
611
613 if (!rootresdir)
614 {
615 WARN(
"haven't found section for resource directory.\n");
617 }
618
619#ifdef __REACTOS__
620
623 {
625 }
626#endif
627
628
630 {
631 WARN(
"No Icongroupresourcedirectory!\n");
633 }
635
636
637 if( !pIconId )
638 {
641 }
642
643 if( nIconIndex < 0 )
644 {
645
647 int iId =
abs(nIconIndex);
649
650 while(
n<iconDirCount && xprdeTmp)
651 {
652 if(xprdeTmp->
Id == iId)
653 {
655 break;
656 }
658 xprdeTmp++;
659 }
660 if (nIconIndex < 0)
661 {
662 WARN(
"resource id %d not found\n", iId);
664 }
665 }
666 else
667 {
668
669 if (nIconIndex >= iconDirCount)
670 {
671 WARN(
"nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount);
673 }
674 }
675
676
677 if( nIcons > iconDirCount - nIconIndex )
678 nIcons = iconDirCount - nIconIndex;
679
680
682
683 for (
i=0;
i < nIcons;
i++,xresent++)
684 {
686
687
689
690
693
694
696 if (!igdata)
697 {
698 FIXME(
"no matching real address for icongroup!\n");
700 }
703 }
704
706 {
707 WARN(
"No Iconresourcedirectory!\n");
709 }
710
711 for (
i=0;
i<nIcons;
i++)
712 {
715 if( !xresdir )
716 {
717 WARN(
"icon entry %d not found\n",
LOWORD(pIconId[
i]));
719 continue;
720 }
723
725 if (!idata)
726 {
727 WARN(
"no matching real address found for icondata!\n");
729 continue;
730 }
732 if (cx2 && cy2)
734 }
736 }
737
741}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
#define INVALID_HANDLE_VALUE
#define CreateFileMappingW(a, b, c, d, e, f)
#define RtlImageDirectoryEntryToData
#define HeapFree(x, y, z)
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)
static BYTE * USER32_LoadResource(LPBYTE peimage, NE_NAMEINFO *pNInfo, WORD sizeShift, ULONG *uSize)
static BYTE * ICO_GetIconDirectory(LPBYTE peimage, LPicoICONDIR *lplpiID, ULONG *uSize)
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)
static const IMAGE_RESOURCE_DIRECTORY * find_entry_by_id(const IMAGE_RESOURCE_DIRECTORY *dir, WORD id, const void *root)
#define NE_RSCTYPE_GROUP_ICON
static BYTE * ICO_LoadIcon(LPBYTE peimage, LPicoICONDIRENTRY lpiIDE, ULONG *uSize)
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_DIRECTORY_ENTRY_RESOURCE
_Out_opt_ int _Out_opt_ int * cy
WORD NumberOfNamedEntries
icoICONDIRENTRY idEntries[1]
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
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)
BOOL WINAPI DestroyIcon(_In_ HICON)