301{
303 UINT cx1, cx2, cy1, cy2;
307 UINT16 iconDirCount = 0,iconCount = 0;
311#ifdef __REACTOS__
313#endif
315 DWORD dwSearchReturn;
316
317#ifdef __REACTOS__
318 TRACE(
"%s, %d, %d, %p, 0x%08x, %d\n",
debugstr_w(lpszExeFileName), nIconIndex, nIcons, pIconId,
flags, fIconEx);
319#else
320 TRACE(
"%s, %d, %d %p 0x%08x\n",
debugstr_w(lpszExeFileName), nIconIndex, nIcons, pIconId,
flags);
321#endif
322
323#ifdef __REACTOS__
324 if (RetPtr)
326
328 lpszExeFileName = szExpandedExePath;
329#endif
330
332 if ((dwSearchReturn == 0) || (dwSearchReturn >
ARRAY_SIZE(szExePath)))
333 {
334#ifdef __REACTOS__
335 WARN(
"File %s not found or path too long and fIconEx is '%d'\n",
337 if (fIconEx && !RetPtr && !pIconId)
338 return 0;
339 else
340 return -1;
341#else
342 WARN(
"File %s not found or path too long\n",
debugstr_w(lpszExeFileName));
343 return -1;
344#endif
345 }
346
350#ifdef __REACTOS__
351 if (!(fsizel | fsizeh))
352 {
353
355 return 0;
356 }
357#endif
358
359
362 if (!fmapping)
363 {
365 return 0xFFFFFFFF;
366 }
367
369 {
372 return 0xFFFFFFFF;
373 }
375
376#ifdef __REACTOS__
377
378
379
380 if ((fsizel >= 52) && !
memcmp(peimage,
"RIFF", 4))
381 {
384
386
387
388 if ((uSize <
strlen(
"anih")) || (uSize > fsizel))
390
391
392 anihMax = uSize -
strlen(
"anih");
393
394 for (anihOffset = 0; anihOffset < anihMax; anihOffset++)
395 {
396 if (
memcmp(&peimage[anihOffset],
"anih", 4) == 0)
397 break;
398 }
399
400 if (anihOffset + sizeof(aniheader) > fsizel)
402
403
404 ret =
MAKEWORD(peimage[anihOffset + 12], peimage[anihOffset + 13]);
405
406 TRACE(
"RIFF File with '%u' images at Offset '%u'.\n",
ret, anihOffset);
407
410
411 if (RetPtr)
412 {
414 }
416 }
417#endif
418
423
424 if (pIconId)
425 *pIconId = 0xFFFFFFFF;
426
427 if (!pIconId)
428 pIconId = (
UINT*)RetPtr;
429
431
432
434 {
441
442 TRACE(
"-- OS2/icon Signature (0x%08x)\n", sig);
443
445 {
447 if (pCIDir)
448 {
449 iconDirCount = 1; iconCount = lpiID->
idCount;
450 TRACE(
"-- icon found %p 0x%08x 0x%08x 0x%08x\n", pCIDir, uSize, iconDirCount, iconCount);
451 }
452 }
453 else while (pTInfo->
type_id && !(pIconStorage && pIconDir))
454 {
456 {
457 iconDirCount = pTInfo->
count;
459 TRACE(
"\tfound directory - %i icon families\n", iconDirCount);
460 }
462 {
463 iconCount = pTInfo->
count;
465 TRACE(
"\ttotal icons - %i\n", iconCount);
466 }
468 }
469
470 if ((pIconStorage && pIconDir) || lpiID)
471 {
472 if (nIcons == 0)
473 {
475 if (lpiID)
477 }
478 else if (nIconIndex < iconDirCount)
479 {
481 if (nIcons > iconDirCount - nIconIndex)
482 nIcons = iconDirCount - nIconIndex;
483
484 for (
i = 0;
i < nIcons;
i++)
485 {
486
491 }
492 if (lpiID)
494
495 for (icon = 0; icon < nIcons; icon++)
496 {
498 if (lpiID)
500 else
501 for (
i = 0;
i < iconCount;
i++)
502 if (pIconStorage[
i].
id == ((
int)pIconId[icon] | 0x8000) )
504
505 if (pCIDir)
506 {
509 if (cx2 && cy2)
512 }
513 else
514 RetPtr[icon] = 0;
515 }
517 }
518 }
519 }
520 else
521 if (sig == 1 || sig == 2)
522 {
523 TRACE(
"-- icon Signature (0x%08x)\n", sig);
524
526 {
527 INT cx[2] = {cx1, cx2},
cy[2] = {cy1, cy2};
529
531 {
535#ifndef __REACTOS__
537#endif
538
540
541 if (dataOffset)
542 {
545#ifdef __REACTOS__
547 DWORD cbColorTable = 0, cbTotal;
548#endif
549
550 imageData = peimage + dataOffset;
551#ifdef __REACTOS__
552
556 {
558 {
562 else
564 }
566 {
568 }
569 }
570
571
572
574 {
575
576#define WIDTHBYTES(width, bits) (((width) * (bits) + 31) / 32 * 4)
579#undef WIDTHBYTES
580 }
581
582
584#else
586#endif
587
588 if(sig == 2)
589 {
590
591#ifdef __REACTOS__
593#else
595#endif
596
597 if(!cursorData)
598 continue;
599
600 cursorData[0] = hotSpot.
x;
601 cursorData[1] = hotSpot.
y;
602
603#ifdef __REACTOS__
604 CopyMemory(cursorData + 2, imageData, cbTotal);
605#else
606 memcpy(cursorData + 2, imageData,
entry->icHeader.biSizeImage);
607#endif
608
609 imageData = (
LPBYTE)cursorData;
610 }
611
612#ifdef __REACTOS__
614 if (fIconEx && sig == 1)
615 iconCount = 1;
616#else
618#endif
619
621
622 if (icon)
623 {
624 if (RetPtr)
625 RetPtr[
index] = icon;
626 else
628
629 iconCount = 1;
630 break;
631 }
632 }
633 }
634 }
636 }
637
638
639
641 {
642 BYTE *idata, *igdata;
648
650 if (!rootresdir)
651 {
652 WARN(
"haven't found section for resource directory.\n");
654 }
655
656#ifdef __REACTOS__
657
660 {
662 }
663#endif
664
665
667 {
668 WARN(
"No Icongroupresourcedirectory!\n");
670 }
672
673
674 if( !pIconId )
675 {
678 }
679
680 if( nIconIndex < 0 )
681 {
682
684 int iId =
abs(nIconIndex);
686
687 while(
n<iconDirCount && xprdeTmp)
688 {
689 if(xprdeTmp->
Id == iId)
690 {
692 break;
693 }
695 xprdeTmp++;
696 }
697 if (nIconIndex < 0)
698 {
699 WARN(
"resource id %d not found\n", iId);
701 }
702 }
703 else
704 {
705
706 if (nIconIndex >= iconDirCount)
707 {
708 WARN(
"nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount);
710 }
711 }
712
713
714 if( nIcons > iconDirCount - nIconIndex )
715 nIcons = iconDirCount - nIconIndex;
716
717
719
720 for (
i=0;
i < nIcons;
i++,xresent++)
721 {
723
724
726
727
730
731
733 if (!igdata)
734 {
735 FIXME(
"no matching real address for icongroup!\n");
737 }
740 }
741
743 {
744 WARN(
"No Iconresourcedirectory!\n");
746 }
747
748 for (
i=0;
i<nIcons;
i++)
749 {
752 if( !xresdir )
753 {
754#ifdef __REACTOS__
755
756
757
759 WARN(
"icon entry %d not found\n",
LOWORD(pIconId[
i]));
760
761
763 {
766 }
767 else
768 {
770 continue;
771 }
772
773
776
778 {
781 }
782 else
783 {
785 continue;
786 }
787
788
793 if (!idata)
794 {
796 continue;
797 }
798
799
801 {
804
806 {
809 if (cx2 && cy2)
814 }
815 }
816 else
817 {
819 continue;
820 }
821#else
822 WARN(
"icon entry %d not found\n",
LOWORD(pIconId[
i]));
824 continue;
825#endif
826 }
829
831 if (!idata)
832 {
833 WARN(
"no matching real address found for icondata!\n");
835 continue;
836 }
838 if (cx2 && cy2)
840 }
842 }
843
847}
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
#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)
BOOL WINAPI DestroyIcon(_In_ HICON)