Changeset 4607 for trunk/src/shell32
- Timestamp:
- Nov 17, 2000, 10:57:35 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/shell32/iconcache.c
r4121 r4607 1 /* $Id: iconcache.c,v 1. 1 2000-08-30 13:52:51sandervl Exp $ */1 /* $Id: iconcache.c,v 1.2 2000-11-17 09:57:35 sandervl Exp $ */ 2 2 /* 3 3 * shell icon cache (SIC) … … 63 63 TRACE("width = 0x%08x height = 0x%08x\n", entry->bWidth, entry->bHeight); 64 64 TRACE("colors = 0x%08x planes = 0x%08x\n", entry->bColorCount, entry->wPlanes); 65 TRACE("bitcount = 0x%08x bytesinres = 0x%08lx offset = 0x%08lx\n", 65 TRACE("bitcount = 0x%08x bytesinres = 0x%08lx offset = 0x%08lx\n", 66 66 entry->wBitCount, entry->dwBytesInRes, entry->dwImageOffset); 67 67 } … … 83 83 int size; 84 84 85 TRACE("0x%08x %p\n", hFile, retptr); 85 TRACE("0x%08x %p\n", hFile, retptr); 86 86 87 87 *retptr = NULL; … … 119 119 if( size > sizeof(NE_TYPEINFO) ) 120 120 { pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size); 121 if( pTypeInfo ) 121 if( pTypeInfo ) 122 122 { _llseek(hFile, mz_header.e_lfanew+ne_header.ne_rsrctab, SEEK_SET); 123 123 if( _lread( hFile, (char*)pTypeInfo, size) != size ) 124 { HeapFree( GetProcessHeap(), 0, pTypeInfo); 124 { HeapFree( GetProcessHeap(), 0, pTypeInfo); 125 125 pTypeInfo = NULL; 126 126 } … … 176 176 #define HEADER_SIZE_FILE (sizeof(icoICONDIR) - sizeof (icoICONDIRENTRY)) 177 177 178 static BYTE * ICO_GetIconDirectory( HFILE hFile, LPicoICONDIR* lplpiID, ULONG *uSize ) 178 static BYTE * ICO_GetIconDirectory( HFILE hFile, LPicoICONDIR* lplpiID, ULONG *uSize ) 179 179 { CURSORICONDIR lpcid; /* icon resource in resource-dir format */ 180 180 LPicoICONDIR lpiID; /* icon resource in file format */ 181 181 int i; 182 182 183 TRACE("0x%08x %p\n", hFile, lplpiID); 183 TRACE("0x%08x %p\n", hFile, lplpiID); 184 184 185 185 _llseek( hFile, 0, SEEK_SET ); … … 254 254 if( pData == (BYTE*)-1 ) 255 255 { pCIDir = ICO_GetIconDirectory(hFile, &lpiID, &uSize); /* check for .ICO file */ 256 if( pCIDir ) 256 if( pCIDir ) 257 257 { iconDirCount = 1; iconCount = lpiID->idCount; 258 258 TRACE("-- icon found %p 0x%08lx 0x%08x 0x%08x\n", pCIDir, uSize, iconDirCount, iconCount); … … 265 265 TRACE("\tfound directory - %i icon families\n", iconDirCount); 266 266 } 267 if( pTInfo->type_id == NE_RSCTYPE_ICON ) 267 if( pTInfo->type_id == NE_RSCTYPE_ICON ) 268 268 { iconCount = pTInfo->count; 269 269 pIconStorage = ((NE_NAMEINFO*)(pTInfo + 1)); … … 279 279 else if( nIconIndex < iconDirCount ) 280 280 { UINT16 i, icon; 281 if( n > iconDirCount - nIconIndex ) 281 if( n > iconDirCount - nIconIndex ) 282 282 n = iconDirCount - nIconIndex; 283 283 284 for( i = nIconIndex; i < nIconIndex + n; i++ ) 284 for( i = nIconIndex; i < nIconIndex + n; i++ ) 285 285 { /* .ICO files have only one icon directory */ 286 286 … … 288 288 pCIDir = SHELL_LoadResource( hFile, pIconDir + i, *(WORD*)pData, &uSize ); 289 289 RetPtr[i-nIconIndex] = pLookupIconIdFromDirectoryEx( pCIDir, TRUE, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0); 290 HeapFree(GetProcessHeap(), 0, pCIDir); 290 HeapFree(GetProcessHeap(), 0, pCIDir); 291 291 } 292 292 … … 312 312 } 313 313 } 314 if( lpiID ) 314 if( lpiID ) 315 315 HeapFree( GetProcessHeap(), 0, lpiID); 316 else 316 else 317 317 HeapFree( GetProcessHeap(), 0, pData); 318 } 318 } 319 319 /* end ico file */ 320 320 … … 329 329 PIMAGE_RESOURCE_DIRECTORY_ENTRY xresent; 330 330 int i,j; 331 332 if ( !(fmapping = CreateFileMappingA(hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL))) 331 332 if ( !(fmapping = CreateFileMappingA(hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL))) 333 333 { WARN("failed to create filemap.\n"); /* FIXME, INVALID_HANDLE_VALUE? */ 334 334 goto end_2; /* failure */ 335 335 } 336 336 337 if ( !(peimage = MapViewOfFile(fmapping,FILE_MAP_READ,0,0,0))) 337 if ( !(peimage = MapViewOfFile(fmapping,FILE_MAP_READ,0,0,0))) 338 338 { WARN("failed to mmap filemap.\n"); 339 339 goto end_2; /* failure */ … … 345 345 rootresdir = NULL; 346 346 347 for (i=0;i<pe_header->FileHeader.NumberOfSections;i++) 347 for (i=0;i<pe_header->FileHeader.NumberOfSections;i++) 348 348 { if (pe_sections[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) 349 349 continue; 350 350 /* FIXME: doesn't work when the resources are not in a seperate section */ 351 if (pe_sections[i].VirtualAddress == pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress) 351 if (pe_sections[i].VirtualAddress == pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress) 352 352 { rootresdir = (PIMAGE_RESOURCE_DIRECTORY)((char*)peimage+pe_sections[i].PointerToRawData); 353 353 break; … … 355 355 } 356 356 357 if (!rootresdir) 357 if (!rootresdir) 358 358 { WARN("haven't found section for resource directory.\n"); 359 359 goto end_3; /* failure */ 360 360 } 361 361 /* search the group icon dir*/ 362 if (!(icongroupresdir = GetResDirEntryW(rootresdir,RT_GROUP_ICONW, (DWORD)rootresdir,FALSE))) 362 if (!(icongroupresdir = GetResDirEntryW(rootresdir,RT_GROUP_ICONW, (DWORD)rootresdir,FALSE))) 363 363 { WARN("No Icongroupresourcedirectory!\n"); 364 364 goto end_3; /* failure */ … … 380 380 381 381 while(n<iconDirCount && xprdeTmp) 382 { 382 { 383 383 if(xprdeTmp->u1.Id == iId) 384 384 { … … 387 387 } 388 388 n++; 389 xprdeTmp++; 389 xprdeTmp++; 390 390 } 391 391 if (nIconIndex < 0) … … 397 397 398 398 /* check nIconIndex to be in range */ 399 if (nIconIndex >= iconDirCount) 399 if (nIconIndex >= iconDirCount) 400 400 { 401 401 WARN("nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount); … … 411 411 xresent = xresent+nIconIndex; /* starting from specified index ... */ 412 412 413 for (i=0;i<n;i++,xresent++) 413 for (i=0;i<n;i++,xresent++) 414 414 { PIMAGE_RESOURCE_DIRECTORY resdir; 415 415 … … 424 424 igdata = NULL; 425 425 426 for (j=0;j<pe_header->FileHeader.NumberOfSections;j++) 426 for (j=0;j<pe_header->FileHeader.NumberOfSections;j++) 427 427 { if (igdataent->OffsetToData < pe_sections[j].VirtualAddress) 428 428 continue; … … 432 432 } 433 433 434 if (!igdata) 434 if (!igdata) 435 435 { WARN("no matching real address for icongroup!\n"); 436 436 goto end_3; /* failure */ … … 439 439 } 440 440 441 if (!(iconresdir=GetResDirEntryW(rootresdir,RT_ICONW,(DWORD)rootresdir,FALSE))) 441 if (!(iconresdir=GetResDirEntryW(rootresdir,RT_ICONW,(DWORD)rootresdir,FALSE))) 442 442 { WARN("No Iconresourcedirectory!\n"); 443 443 goto end_3; /* failure */ 444 444 } 445 445 446 for (i=0;i<n;i++) 446 for (i=0;i<n;i++) 447 447 { PIMAGE_RESOURCE_DIRECTORY xresdir; 448 448 xresdir = GetResDirEntryW(iconresdir,(LPWSTR)(DWORD)RetPtr[i],(DWORD)rootresdir,FALSE); … … 452 452 453 453 /* map virtual to address in image */ 454 for (j=0;j<pe_header->FileHeader.NumberOfSections;j++) 454 for (j=0;j<pe_header->FileHeader.NumberOfSections;j++) 455 455 { if (idataent->OffsetToData < pe_sections[j].VirtualAddress) 456 456 continue; … … 459 459 idata = peimage+(idataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData); 460 460 } 461 if (!idata) 461 if (!idata) 462 462 { WARN("no matching real address found for icondata!\n"); 463 463 RetPtr[i]=0; … … 469 469 goto end_3; /* sucess */ 470 470 } 471 #ifdef __WIN32OS2__ 472 else 473 { 474 if( nIconIndex == -1 ) 475 { 476 TRACE( "ICO_ExtractIconEx : iconcount not implemented!\n" ); 477 } 478 else 479 { 480 /* Try to get icon(s) using LoadImageA. This works for 481 LX images, like Odin's shell32.dll! */ 482 HINSTANCE hInst = LoadLibraryA( lpszExeFileName ); 483 if ( hInst ) 484 { 485 INT icon; 486 for( icon = nIconIndex; icon < nIconIndex + n; icon++ ) 487 { 488 RetPtr[ icon - nIconIndex ] 489 = LoadImageA( hInst, 490 MAKEINTRESOURCEA( icon ), 491 IMAGE_ICON, 492 cxDesired, 493 cyDesired, 494 LR_DEFAULTCOLOR ); 495 } 496 hRet = RetPtr[ 0 ]; 497 FreeLibrary( hInst ); 498 } 499 } 500 } 501 #endif 471 502 goto end_1; /* unknown filetype */ 472 503 … … 508 539 return 1; 509 540 510 return 0; 541 return 0; 511 542 } 512 543 /***************************************************************************** … … 639 670 * 640 671 * NOTES 641 * hack to load the resources from the shell32.dll under a different dll name 672 * hack to load the resources from the shell32.dll under a different dll name 642 673 * will be removed when the resource-compiler is ready 643 674 */ … … 651 682 if (sic_hdpa) /* already initialized?*/ 652 683 return TRUE; 653 684 654 685 sic_hdpa = pDPA_Create(16); 655 686 … … 700 731 for (i=0; i < pDPA_GetPtrCount(sic_hdpa); ++i) 701 732 { 702 lpsice = pDPA_GetPtr(sic_hdpa, i); 733 lpsice = pDPA_GetPtr(sic_hdpa, i); 703 734 SHFree(lpsice); 704 735 } … … 776 807 * 777 808 * PARAMETERS 778 * sh [IN] pointer to an instance of IShellFolder 809 * sh [IN] pointer to an instance of IShellFolder 779 810 * pidl [IN] 780 811 * pIndex [OUT][OPTIONAL] SIC index for big icon … … 801 832 * 802 833 */ 803 INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, BOOL bSimulateDoc) 834 INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, BOOL bSimulateDoc) 804 835 { 805 836 WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_a(szPath), nIndex, bSimulateDoc); … … 807 838 } 808 839 809 INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, BOOL bSimulateDoc) 840 INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, BOOL bSimulateDoc) 810 841 { INT ret; 811 842 LPSTR sTemp = HEAP_strdupWtoA (GetProcessHeap(),0,szPath); … … 835 866 * ExtractIconExA [shell32.190] 836 867 * RETURNS 837 * 0 no icon found 868 * 0 no icon found 838 869 * 1 file is not valid 839 870 * HICON handle of a icon (phiconLarge/Small == NULL) … … 846 877 if (nIconIndex==-1) /* Number of icons requested */ 847 878 return ICO_ExtractIconEx(lpszFile, NULL, -1, 0, 0, 0 ); 848 879 849 880 850 881 if (phiconLarge) 851 882 { ret = ICO_ExtractIconEx(lpszFile, phiconLarge, nIconIndex, nIcons, 32, 32 ); 852 883 if ( nIcons==1) 853 { ret = phiconLarge[0]; 884 { ret = phiconLarge[0]; 854 885 } 855 886 }
Note:
See TracChangeset
for help on using the changeset viewer.