Changeset 3243 for trunk/src/shell32/iconcache.cpp
- Timestamp:
- Mar 26, 2000, 6:34:57 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/shell32/iconcache.cpp
r1399 r3243 1 /* $Id: iconcache.cpp,v 1. 3 1999-10-22 13:35:21 phallerExp $ */1 /* $Id: iconcache.cpp,v 1.4 2000-03-26 16:34:41 cbratschi Exp $ */ 2 2 3 3 /* … … 9 9 * shell icon cache (SIC) 10 10 * 11 * Corel WINE 20000324 level 11 12 */ 12 13 … … 27 28 #include "winuser.h" 28 29 #include "wingdi.h" 29 //#include "wine/winuser16.h"30 //#include "wine/winbase16.h"31 30 //#include "neexe.h" 32 31 #include "cursoricon.h" … … 137 136 138 137 //@@@PH no NE support 139 #if 0138 #if 1 140 139 if( size > sizeof(NE_TYPEINFO) ) 141 140 { pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size); … … 159 158 */ 160 159 //@@@PH no NE support 161 #if 0160 #if 1 162 161 static BYTE * SHELL_LoadResource( HFILE hFile, NE_NAMEINFO* pNInfo, WORD sizeShift, ULONG *uSize) 163 162 { BYTE* ptr; … … 166 165 167 166 *uSize = (DWORD)pNInfo->length << sizeShift; 168 if( (ptr = (BYTE*)HeapAlloc(GetProcessHeap(),0, *uSize) )) 167 ptr = (BYTE*)HeapAlloc(GetProcessHeap(),0, *uSize); 168 if(ptr) 169 169 { _llseek( hFile, (DWORD)pNInfo->offset << sizeShift, SEEK_SET); 170 170 _lread( hFile, (char*)ptr, pNInfo->length << sizeShift); … … 184 184 185 185 *uSize = lpiIDE->dwBytesInRes; 186 if( (ptr = (BYTE*)HeapAlloc(GetProcessHeap(),0, *uSize)) ) 186 ptr = (BYTE*)HeapAlloc(GetProcessHeap(),0, *uSize); 187 if(ptr) 187 188 { _llseek( hFile, lpiIDE->dwImageOffset, SEEK_SET); 188 189 _lread( hFile, (char*)ptr, lpiIDE->dwBytesInRes); … … 222 223 { CURSORICONDIR * lpID; /* icon resource in resource format */ 223 224 *uSize = lpcid.idCount * sizeof(CURSORICONDIRENTRY) + HEADER_SIZE; 224 if( (lpID = (CURSORICONDIR*)HeapAlloc(GetProcessHeap(),0, *uSize) )) 225 lpID = (CURSORICONDIR*)HeapAlloc(GetProcessHeap(),0, *uSize); 226 if(lpID) 225 227 { 226 228 /* copy the header */ … … 253 255 * 254 256 */ 255 #define ICO_INVALID_FILE 1256 #define ICO_NO_ICONS 0257 258 257 HGLOBAL WINAPI ICO_ExtractIconEx(LPCSTR lpszExeFileName, HICON * RetPtr, UINT nIconIndex, UINT n, UINT cxDesired, UINT cyDesired ) 258 // @@@PH turned off 259 #if 0 259 260 { 260 261 dprintf (("SHELL32: ICO_ExtractIconEx not implemented.\n")); 261 262 return 0; 262 263 } 263 264 // @@@PH turned off 265 #if 0 266 { HGLOBAL hRet = ICO_NO_ICONS; 264 #else 265 { HGLOBAL hRet = 0; 267 266 LPBYTE pData; 268 267 OFSTRUCT ofs; … … 277 276 278 277 if( hFile == HFILE_ERROR || !n ) 279 return ICO_INVALID_FILE;278 return hRet; 280 279 281 280 sig = SHELL_GetResourceTable(hFile,&pData); 282 281 283 282 //@@@PH no NE support 284 #if 0283 #if 1 285 284 /* ico file */ 286 285 if( sig==IMAGE_OS2_SIGNATURE || sig==1 ) /* .ICO file */ … … 374 373 if ( !(fmapping = CreateFileMappingA(hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL))) 375 374 { WARN("failed to create filemap.\n"); /* FIXME, INVALID_HANDLE_VALUE? */ 376 hRet = ICO_INVALID_FILE;377 375 goto end_2; /* failure */ 378 376 } … … 380 378 if ( !(peimage = (BYTE*)MapViewOfFile(fmapping,FILE_MAP_READ,0,0,0))) 381 379 { WARN("failed to mmap filemap.\n"); 382 hRet = ICO_INVALID_FILE;383 380 goto end_2; /* failure */ 384 381 } … … 401 398 if (!rootresdir) 402 399 { WARN("haven't found section for resource directory.\n"); 403 goto end_ 4; /* failure */400 goto end_3; /* failure */ 404 401 } 405 402 /* search the group icon dir*/ 406 403 if (!(icongroupresdir = GetResDirEntryW(rootresdir,RT_GROUP_ICONW, (DWORD)rootresdir,FALSE))) 407 404 { WARN("No Icongroupresourcedirectory!\n"); 408 goto end_ 4; /* failure */405 goto end_3; /* failure */ 409 406 } 410 407 iconDirCount = icongroupresdir->NumberOfNamedEntries+icongroupresdir->NumberOfIdEntries; … … 416 413 } 417 414 415 /* if nIconIndex is negative we have to extract the icon whose resource 416 id is equal to the absolute value of nIconIndex */ 417 if( nIconIndex < 0 ) 418 { 419 int n = 0; 420 int iId = abs(nIconIndex); 421 PIMAGE_RESOURCE_DIRECTORY_ENTRY xprdeTmp = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(icongroupresdir+1); 422 nIconIndex = iconDirCount + 1; /* Initialise to get an error at 423 the condition nIconIndex >= iconDirCount 424 below if nothing is found */ 425 while(i<iconDirCount && xprdeTmp) 426 { 427 if(xprdeTmp->u1.Id == iId) 428 { 429 nIconIndex = n; 430 break; 431 } 432 n++; 433 xprdeTmp++; 434 } 435 } 436 418 437 if (nIconIndex >= iconDirCount) 419 438 { WARN("nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount); 420 goto end_ 4; /* failure */439 goto end_3; /* failure */ 421 440 } 422 441 … … 452 471 if (!igdata) 453 472 { WARN("no matching real address for icongroup!\n"); 454 goto end_ 4; /* failure */473 goto end_3; /* failure */ 455 474 } 456 475 RetPtr[i] = (HICON)pLookupIconIdFromDirectoryEx(igdata, TRUE, cxDesired, cyDesired, LR_DEFAULTCOLOR); … … 459 478 if (!(iconresdir=GetResDirEntryW(rootresdir,RT_ICONW,(DWORD)rootresdir,FALSE))) 460 479 { WARN("No Iconresourcedirectory!\n"); 461 goto end_ 4; /* failure */480 goto end_3; /* failure */ 462 481 } 463 482 … … 487 506 goto end_3; /* sucess */ 488 507 } 489 hRet = ICO_INVALID_FILE;490 508 goto end_1; /* unknown filetype */ 491 509 492 510 /* cleaning up (try & catch would be nicer:-) ) */ 493 end_4: hRet = 0; /* failure */494 511 end_3: UnmapViewOfFile(peimage); /* success */ 495 512 end_2: CloseHandle(fmapping); … … 915 932 return ret; 916 933 } 934 935 /* 936 * PE (Portable Execute) File Resources 937 * 938 * Copyright 1995 Thomas Sandford 939 * Copyright 1996 Martin von Loewis 940 * 941 * Based on the Win16 resource handling code in loader/resource.c 942 * Copyright 1993 Robert J. Amstadt 943 * Copyright 1995 Alexandre Julliard 944 * Copyright 1997 Marcus Meissner 945 */ 946 947 //CB: from loader/pe_resource.c 948 949 /********************************************************************** 950 * GetResDirEntryW 951 * 952 * Helper function - goes down one level of PE resource tree 953 * 954 */ 955 PIMAGE_RESOURCE_DIRECTORY GetResDirEntryW(PIMAGE_RESOURCE_DIRECTORY resdirptr, 956 LPCWSTR name,DWORD root, 957 BOOL allowdefault) 958 { 959 int entrynum; 960 PIMAGE_RESOURCE_DIRECTORY_ENTRY entryTable; 961 int namelen; 962 963 if (HIWORD(name)) { 964 if (name[0]=='#') { 965 char buf[10]; 966 967 lstrcpynWtoA(buf,name+1,10); 968 return GetResDirEntryW(resdirptr,(LPCWSTR)atoi(buf),root,allowdefault); 969 } 970 entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) ( 971 (BYTE *) resdirptr + 972 sizeof(IMAGE_RESOURCE_DIRECTORY)); 973 namelen = lstrlenW(name); 974 for (entrynum = 0; entrynum < resdirptr->NumberOfNamedEntries; entrynum++) 975 { 976 PIMAGE_RESOURCE_DIR_STRING_U str = 977 (PIMAGE_RESOURCE_DIR_STRING_U) (root + 978 entryTable[entrynum].u1.s.NameOffset); 979 if(namelen != str->Length) 980 continue; 981 if(lstrncmpiW(name,str->NameString,str->Length)==0) 982 return (PIMAGE_RESOURCE_DIRECTORY) ( 983 root + 984 entryTable[entrynum].u2.s.OffsetToDirectory); 985 } 986 return NULL; 987 } else { 988 entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) ( 989 (BYTE *) resdirptr + 990 sizeof(IMAGE_RESOURCE_DIRECTORY) + 991 resdirptr->NumberOfNamedEntries * sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY)); 992 for (entrynum = 0; entrynum < resdirptr->NumberOfIdEntries; entrynum++) 993 if ((DWORD)entryTable[entrynum].u1.Name == (DWORD)name) 994 return (PIMAGE_RESOURCE_DIRECTORY) ( 995 root + 996 entryTable[entrynum].u2.s.OffsetToDirectory); 997 /* just use first entry if no default can be found */ 998 if (allowdefault && !name && resdirptr->NumberOfIdEntries) 999 return (PIMAGE_RESOURCE_DIRECTORY) ( 1000 root + 1001 entryTable[0].u2.s.OffsetToDirectory); 1002 return NULL; 1003 } 1004 } 1005
Note:
See TracChangeset
for help on using the changeset viewer.