Ignore:
Timestamp:
Mar 26, 2000, 6:34:57 PM (25 years ago)
Author:
cbratschi
Message:

merged with Corel WINE 20000324

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 phaller Exp $ */
     1/* $Id: iconcache.cpp,v 1.4 2000-03-26 16:34:41 cbratschi Exp $ */
    22
    33/*
     
    99 * shell icon cache (SIC)
    1010 *
     11 * Corel WINE 20000324 level
    1112 */
    1213
     
    2728#include "winuser.h"
    2829#include "wingdi.h"
    29 //#include "wine/winuser16.h"
    30 //#include "wine/winbase16.h"
    3130//#include "neexe.h"
    3231#include "cursoricon.h"
     
    137136
    138137//@@@PH no NE support
    139 #if 0
     138#if 1
    140139     if( size > sizeof(NE_TYPEINFO) )
    141140     { pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
     
    159158 */
    160159//@@@PH no NE support
    161 #if 0
     160#if 1
    162161static BYTE * SHELL_LoadResource( HFILE hFile, NE_NAMEINFO* pNInfo, WORD sizeShift, ULONG *uSize)
    163162{  BYTE*  ptr;
     
    166165
    167166   *uSize = (DWORD)pNInfo->length << sizeShift;
    168    if( (ptr = (BYTE*)HeapAlloc(GetProcessHeap(),0, *uSize) ))
     167   ptr = (BYTE*)HeapAlloc(GetProcessHeap(),0, *uSize);
     168   if(ptr)
    169169   { _llseek( hFile, (DWORD)pNInfo->offset << sizeShift, SEEK_SET);
    170170     _lread( hFile, (char*)ptr, pNInfo->length << sizeShift);
     
    184184
    185185   *uSize = lpiIDE->dwBytesInRes;
    186    if( (ptr = (BYTE*)HeapAlloc(GetProcessHeap(),0, *uSize)) )
     186   ptr = (BYTE*)HeapAlloc(GetProcessHeap(),0, *uSize);
     187   if(ptr)
    187188   { _llseek( hFile, lpiIDE->dwImageOffset, SEEK_SET);
    188189     _lread( hFile, (char*)ptr, lpiIDE->dwBytesInRes);
     
    222223   { CURSORICONDIR * lpID;                     /* icon resource in resource format */
    223224     *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)
    225227     {
    226228       /* copy the header */
     
    253255 *
    254256 */
    255 #define ICO_INVALID_FILE                 1
    256 #define ICO_NO_ICONS                        0
    257 
    258257HGLOBAL WINAPI ICO_ExtractIconEx(LPCSTR lpszExeFileName, HICON * RetPtr, UINT nIconIndex, UINT n, UINT cxDesired, UINT cyDesired )
     258// @@@PH turned off
     259#if 0
    259260{
    260261  dprintf (("SHELL32: ICO_ExtractIconEx not implemented.\n"));
    261262  return 0;
    262263}
    263 
    264 // @@@PH turned off
    265 #if 0
    266 {  HGLOBAL  hRet = ICO_NO_ICONS;
     264#else
     265{  HGLOBAL  hRet = 0;
    267266   LPBYTE      pData;
    268267   OFSTRUCT ofs;
     
    277276
    278277   if( hFile == HFILE_ERROR || !n )
    279      return ICO_INVALID_FILE;
     278     return hRet;
    280279
    281280   sig = SHELL_GetResourceTable(hFile,&pData);
    282281
    283282//@@@PH no NE support
    284 #if 0
     283#if 1
    285284/* ico file */
    286285   if( sig==IMAGE_OS2_SIGNATURE || sig==1 ) /* .ICO file */
     
    374373     if ( !(fmapping = CreateFileMappingA(hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL)))
    375374     { WARN("failed to create filemap.\n"); /* FIXME, INVALID_HANDLE_VALUE? */
    376        hRet = ICO_INVALID_FILE;
    377375       goto end_2;                          /* failure */
    378376     }
     
    380378     if ( !(peimage = (BYTE*)MapViewOfFile(fmapping,FILE_MAP_READ,0,0,0)))
    381379     { WARN("failed to mmap filemap.\n");
    382        hRet = ICO_INVALID_FILE;
    383380       goto end_2;                          /* failure */
    384381     }
     
    401398     if (!rootresdir)
    402399     { WARN("haven't found section for resource directory.\n");
    403        goto end_4;                          /* failure */
     400       goto end_3;                          /* failure */
    404401     }
    405402  /* search the group icon dir*/
    406403     if (!(icongroupresdir = GetResDirEntryW(rootresdir,RT_GROUP_ICONW, (DWORD)rootresdir,FALSE)))
    407404     { WARN("No Icongroupresourcedirectory!\n");
    408        goto end_4;                          /* failure */
     405       goto end_3;                          /* failure */
    409406     }
    410407     iconDirCount = icongroupresdir->NumberOfNamedEntries+icongroupresdir->NumberOfIdEntries;
     
    416413     }
    417414
     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
    418437     if (nIconIndex >= iconDirCount)
    419438     { WARN("nIconIndex %d is larger than iconDirCount %d\n",nIconIndex,iconDirCount);
    420        goto end_4;                          /* failure */
     439       goto end_3;                          /* failure */
    421440     }
    422441
     
    452471       if (!igdata)
    453472       { WARN("no matching real address for icongroup!\n");
    454          goto end_4;                     /* failure */
     473         goto end_3;                     /* failure */
    455474       }
    456475       RetPtr[i] = (HICON)pLookupIconIdFromDirectoryEx(igdata, TRUE, cxDesired, cyDesired, LR_DEFAULTCOLOR);
     
    459478     if (!(iconresdir=GetResDirEntryW(rootresdir,RT_ICONW,(DWORD)rootresdir,FALSE)))
    460479     { WARN("No Iconresourcedirectory!\n");
    461        goto end_4;                          /* failure */
     480       goto end_3;                          /* failure */
    462481     }
    463482
     
    487506     goto end_3;                         /* sucess */
    488507   }
    489    hRet = ICO_INVALID_FILE;
    490508   goto end_1;    /* unknown filetype */
    491509
    492510/* cleaning up (try & catch would be nicer:-) ) */
    493 end_4:   hRet = 0;                       /* failure */
    494511end_3:   UnmapViewOfFile(peimage);       /* success */
    495512end_2:   CloseHandle(fmapping);
     
    915932   return ret;
    916933}
     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 */
     955PIMAGE_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.