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
351
354 if (!fmapping)
355 {
357 return 0xFFFFFFFF;
358 }
359
361 {
364 return 0xFFFFFFFF;
365 }
367
368#ifdef __REACTOS__
369
370
371
372 if ((fsizel >= 52) && !
memcmp(peimage,
"RIFF", 4))
373 {
376
378
379
380 if ((uSize <
strlen(
"anih")) || (uSize > fsizel))
382
383
384 anihMax = uSize -
strlen(
"anih");
385
386 for (anihOffset = 0; anihOffset < anihMax; anihOffset++)
387 {
388 if (
memcmp(&peimage[anihOffset],
"anih", 4) == 0)
389 break;
390 }
391
392 if (anihOffset + sizeof(aniheader) > fsizel)
394
395
396 ret =
MAKEWORD(peimage[anihOffset + 12], peimage[anihOffset + 13]);
397
398 TRACE(
"RIFF File with '%u' images at Offset '%u'.\n",
ret, anihOffset);
399
402
403 if (RetPtr)
404 {
406 }
408 }
409#endif
410
415
416 if (pIconId)
417 *pIconId = 0xFFFFFFFF;
418
419 if (!pIconId)
420 pIconId = (
UINT*)RetPtr;
421
423
424
426 {
433
434 TRACE(
"-- OS2/icon Signature (0x%08x)\n", sig);
435
437 {
439 if (pCIDir)
440 {
441 iconDirCount = 1; iconCount = lpiID->
idCount;
442 TRACE(
"-- icon found %p 0x%08x 0x%08x 0x%08x\n", pCIDir, uSize, iconDirCount, iconCount);
443 }
444 }
445 else while (pTInfo->
type_id && !(pIconStorage && pIconDir))
446 {
448 {
449 iconDirCount = pTInfo->
count;
451 TRACE(
"\tfound directory - %i icon families\n", iconDirCount);
452 }
454 {
455 iconCount = pTInfo->
count;
457 TRACE(
"\ttotal icons - %i\n", iconCount);
458 }
460 }
461
462 if ((pIconStorage && pIconDir) || lpiID)
463 {
464 if (nIcons == 0)
465 {
467 if (lpiID)
469 }
470 else if (nIconIndex < iconDirCount)
471 {
473 if (nIcons > iconDirCount - nIconIndex)
474 nIcons = iconDirCount - nIconIndex;
475
476 for (
i = 0;
i < nIcons;
i++)
477 {
478
483 }
484 if (lpiID)
486
487 for (icon = 0; icon < nIcons; icon++)
488 {
490 if (lpiID)
492 else
493 for (
i = 0;
i < iconCount;
i++)
494 if (pIconStorage[
i].
id == ((
int)pIconId[icon] | 0x8000) )
496
497 if (pCIDir)
498 {
501 if (cx2 && cy2)
504 }
505 else
506 RetPtr[icon] = 0;
507 }
509 }
510 }
511 }
512 else
513 if (sig == 1 || sig == 2)
514 {
515 TRACE(
"-- icon Signature (0x%08x)\n", sig);
516
518 {
519 INT cx[2] = {cx1, cx2},
cy[2] = {cy1, cy2};
521
523 {
527#ifndef __REACTOS__
529#endif
530
532
533 if (dataOffset)
534 {
537#ifdef __REACTOS__
539 DWORD cbColorTable = 0, cbTotal;
540#endif
541
542 imageData = peimage + dataOffset;
543#ifdef __REACTOS__
544
548 {
550 {
554 else
556 }
558 {
560 }
561 }
562
563
564
566 {
567
568#define WIDTHBYTES(width, bits) (((width) * (bits) + 31) / 32 * 4)
571#undef WIDTHBYTES
572 }
573
574
576#else
578#endif
579
580 if(sig == 2)
581 {
582
583#ifdef __REACTOS__
585#else
587#endif
588
589 if(!cursorData)
590 continue;
591
592 cursorData[0] = hotSpot.
x;
593 cursorData[1] = hotSpot.
y;
594
595#ifdef __REACTOS__
596 CopyMemory(cursorData + 2, imageData, cbTotal);
597#else
598 memcpy(cursorData + 2, imageData,
entry->icHeader.biSizeImage);
599#endif
600
601 imageData = (
LPBYTE)cursorData;
602 }
603
604#ifdef __REACTOS__
606 if (fIconEx && sig == 1)
607 iconCount = 1;
608#else
610#endif
611
613
614 if (icon)
615 {
616 if (RetPtr)
617 RetPtr[
index] = icon;
618 else
620
621 iconCount = 1;
622 break;
623 }
624 }
625 }
626 }
628 }
629
630
631
633 {
634 BYTE *idata, *igdata;
640
642 if (!rootresdir)
643 {
644 WARN(
"haven't found section for resource directory.\n");
646 }
647
648#ifdef __REACTOS__
649
652 {
654 }
655#endif
656
657
659 {
660 WARN(
"No Icongroupresourcedirectory!\n");
662 }
664
665
666 if( !pIconId )
667 {
670 }
671
672 if( nIconIndex < 0 )
673 {
674
676 int iId =
abs(nIconIndex);
678
679 while(
n<iconDirCount && xprdeTmp)
680 {
681 if(xprdeTmp->
Id == iId)
682 {
684 break;
685 }
687 xprdeTmp++;
688 }
689 if (nIconIndex < 0)
690 {
691 WARN(
"resource id %d not found\n", iId);
693 }
694 }
695 else
696 {
697
698 if (nIconIndex >= iconDirCount)
699 {
700 WARN(
"nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount);
702 }
703 }
704
705
706 if( nIcons > iconDirCount - nIconIndex )
707 nIcons = iconDirCount - nIconIndex;
708
709
711
712 for (
i=0;
i < nIcons;
i++,xresent++)
713 {
715
716
718
719
722
723
725 if (!igdata)
726 {
727 FIXME(
"no matching real address for icongroup!\n");
729 }
732 }
733
735 {
736 WARN(
"No Iconresourcedirectory!\n");
738 }
739
740 for (
i=0;
i<nIcons;
i++)
741 {
744 if( !xresdir )
745 {
746#ifdef __REACTOS__
747
748
749
751 WARN(
"icon entry %d not found\n",
LOWORD(pIconId[
i]));
752
753
755 {
758 }
759 else
760 {
762 continue;
763 }
764
765
768
770 {
773 }
774 else
775 {
777 continue;
778 }
779
780
785 if (!idata)
786 {
788 continue;
789 }
790
791
793 {
796
798 {
801 if (cx2 && cy2)
806 }
807 }
808 else
809 {
811 continue;
812 }
813#else
814 WARN(
"icon entry %d not found\n",
LOWORD(pIconId[
i]));
816 continue;
817#endif
818 }
821
823 if (!idata)
824 {
825 WARN(
"no matching real address found for icondata!\n");
827 continue;
828 }
830 if (cx2 && cy2)
832 }
834 }
835
839}
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)