Changeset 163 for trunk/src


Ignore:
Timestamp:
Jun 23, 1999, 9:36:24 PM (26 years ago)
Author:
phaller
Message:

Fix: Someone with strong stomach should take care of the resource loader code

Location:
trunk/src/kernel32
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/unicode.cpp

    r100 r163  
    1 /* $Id: unicode.cpp,v 1.7 1999-06-10 20:47:54 phaller Exp $ */
     1/* $Id: unicode.cpp,v 1.8 1999-06-23 19:36:24 phaller Exp $ */
    22
    33/*
     
    230230  AsciiToUnicodeN(ascii, unicode, strlen(ascii));
    231231}
    232 //******************************************************************************
    233 //TODO: use OS/2 unicode stuff
    234 //******************************************************************************
    235 char *UnicodeToAscii(int length, WCHAR *NameString)
    236 {
    237 static char asciistring[256];
    238 int i;
    239 
    240   if(length >= 255) length = 255;
    241   for(i=0;i<length;i++) {
    242     asciistring[i] = NameString[i] & 0xFF;
    243   }
    244   asciistring[length] = 0;
    245   return(asciistring);
    246 }
    247 //******************************************************************************
    248 //******************************************************************************
     232
  • trunk/src/kernel32/winimgres.cpp

    r99 r163  
    1 /* $Id: winimgres.cpp,v 1.3 1999-06-10 19:09:04 phaller Exp $ */
     1/* $Id: winimgres.cpp,v 1.4 1999-06-23 19:36:24 phaller Exp $ */
    22
    33/*
     
    3030       "GROUP_CURSOR", "niks", "GROUP_ICON", "niks", "VERSION"};
    3131
     32
     33//******************************************************************************
     34//TODO: use OS/2 unicode stuff
     35//******************************************************************************
     36char *extremelyuglyUnicodeToAscii(int length, WCHAR *NameString)
     37{
     38static char asciistring[256];
     39int i;
     40
     41  if(length >= 255) length = 255;
     42  for(i=0;i<length;i++) {
     43    asciistring[i] = NameString[i] & 0xFF;
     44  }
     45  asciistring[length] = 0;
     46  return(asciistring);
     47}
     48//******************************************************************************
     49//******************************************************************************
     50
    3251//******************************************************************************
    3352//Assuming names are case insensitive
     
    94113        //SvL: 30-10-'97, high bit is set, so clear to get real offset
    95114        prde->u1.Name &= ~0x80000000;
    96         char *resname = UnicodeToAscii(*(WCHAR *)((ULONG)pResDir + (ULONG)prde->u1.Name), (WCHAR *)((ULONG)pResDir + (ULONG)prde->u1.Name + sizeof(WCHAR)));  // first word = string length
     115        char *resname = extremelyuglyUnicodeToAscii(*(WCHAR *)((ULONG)pResDir + (ULONG)prde->u1.Name), (WCHAR *)((ULONG)pResDir + (ULONG)prde->u1.Name + sizeof(WCHAR)));  // first word = string length
    97116        if(!fNumId) {
    98117            if(stricmp(resname, (char *)type) == 0) {
     
    186205    if(!fNumId) {//name or id entry?
    187206        if(prde->u1.s.NameIsString) //unicode directory string /*PLF Sat  97-06-21 22:30:35*/
    188                 prde->u1.Name &= ~0x80000000;
    189                 pstring = (PIMAGE_RESOURCE_DIR_STRING_U)((ULONG)pResDir + (ULONG)prde->u1.Name);
    190                 resname = UnicodeToAscii(pstring->Length, pstring->NameString);
    191                 if(stricmp(resname, (char *)*nodeData) == 0) {
    192                         fFound = TRUE;
    193                 }
    194         }
    195         else {
    196                 if(*nodeData == prde->u1.Id)
    197                         fFound = TRUE;
    198         }
    199         if(*nodeData == LANG_GETFIRST)
    200                 fFound = TRUE;
    201 
    202         if(fFound) {
    203                 if((ULONG)prdType2 & 0x80000000) {//subdirectory?
    204                     ProcessResSubDir(prdType2, nodeData+1);
    205                 }
    206                 else {
    207                     pData = (PIMAGE_RESOURCE_DATA_ENTRY)prdType2;
    208                     if(pData->Size) {//winamp17 winzip archive has resource with size 0
    209                         return(pData);
    210                     }
    211                     else    return(NULL);
    212                 }
    213         }
    214         prde++;
     207               prde->u1.Name &= ~0x80000000;
     208           pstring = (PIMAGE_RESOURCE_DIR_STRING_U)((ULONG)pResDir + (ULONG)prde->u1.Name);
     209         resname = extremelyuglyUnicodeToAscii(pstring->Length, pstring->NameString);
     210         if(stricmp(resname, (char *)*nodeData) == 0) {
     211                  fFound = TRUE;
     212         }
     213      }
     214      else {
     215         if(*nodeData == prde->u1.Id)
     216                  fFound = TRUE;
     217      }
     218      if(*nodeData == LANG_GETFIRST)
     219         fFound = TRUE;
     220
     221   if(fFound) {
     222         if((ULONG)prdType2 & 0x80000000) {//subdirectory?
     223               ProcessResSubDir(prdType2, nodeData+1);
     224           }
     225           else {
     226             pData = (PIMAGE_RESOURCE_DATA_ENTRY)prdType2;
     227               if(pData->Size) {//winamp17 winzip archive has resource with size 0
     228                 return(pData);
     229               }
     230             else    return(NULL);
     231         }
     232      }
     233      prde++;
    215234  }
    216235  return(NULL);
     
    237256        if(i == MAX_RES) {//custom resource type, stored as rcdata
    238257                dprintf(("FindResourceA custom type %s\n", lpszType));
    239                 lpszType = (LPSTR)NTRT_RCDATA;
     258               lpszType = (LPSTR)NTRT_RCDATA;
    240259        }
    241260        else    lpszType = (LPSTR)i;
     
    271290    if((int)lpszName >> 16 != 0) {//convert string name identifier to numeric id
    272291        dprintf(("FindResource %s\n", lpszName));
    273         if(lpszName[0] == '#') {// #344
    274                 lpszName = (LPCSTR)atoi(&lpszName[1]);
    275         }
    276         else    lpszName = (LPCSTR)ConvertNameId(hinstance, (char *)lpszName);
     292      if(lpszName[0] == '#') {// #344
     293            lpszName = (LPCSTR)atoi(&lpszName[1]);
     294      }
     295      else  lpszName = (LPCSTR)ConvertNameId(hinstance, (char *)lpszName);
    277296    }
    278297    else dprintf(("FindResource %d\n", (int)lpszName));
     
    280299    hres = O32_FindResource(hinstance, lpszName, szType);
    281300    if(hres) {
    282         res = new Win32Resource(this, hres, (ULONG)lpszName, (ULONG)szType);
     301      res = new Win32Resource(this, hres, (ULONG)lpszName, (ULONG)szType);
    283302    }
    284303
    285304    if(hres == NULL && (int)lpszName >> 16 == 0 && (int)szType == NTRT_STRING) {
    286         hres = O32_FindResource(hinstance, (LPCSTR)(((int)lpszName - 1)*16), (LPCSTR)NTRT_RCDATA);
    287         if(hres) {
    288                 res = new Win32Resource(this, hres, (ULONG)lpszName, (ULONG)szType);
    289         }
    290         else    dprintf(("FindResourceA can't find string %d\n", (int)lpszName));
     305      hres = O32_FindResource(hinstance, (LPCSTR)(((int)lpszName - 1)*16), (LPCSTR)NTRT_RCDATA);
     306      if(hres) {
     307         res = new Win32Resource(this, hres, (ULONG)lpszName, (ULONG)szType);
     308      }
     309      else    dprintf(("FindResourceA can't find string %d\n", (int)lpszName));
    291310    }
    292311    dprintf(("FindResourceA returned %X (%X)\n", hres, GetLastError()));
     
    364383
    365384    if((int)lpszName >> 16 != 0) {//convert string name identifier to numeric id
    366         astring1 = UnicodeToAsciiString(lpszName);
     385      astring1 = UnicodeToAsciiString(lpszName);
    367386        dprintf(("FindResourceW %X %s\n", hinstance, astring1));
    368         if(astring1[0] == '#') {// #344
    369                 lpszName = (LPWSTR)atoi(&astring1[1]);
    370         }
    371         else    lpszName = (LPWSTR)ConvertNameId(hinstance, (char *)astring1);
     387      if(astring1[0] == '#') {// #344
     388            lpszName = (LPWSTR)atoi(&astring1[1]);
     389      }
     390      else  lpszName = (LPWSTR)ConvertNameId(hinstance, (char *)astring1);
    372391    }
    373392    else dprintf(("FindResourceW %X %d\n", hinstance, (int)lpszName));
     
    375394    hres = O32_FindResource(hinstance, (LPCSTR)lpszName, (LPCSTR)szType);
    376395    if(hres) {
    377         res = new Win32Resource(this, hres, (ULONG)lpszName, (ULONG)szType);
     396      res = new Win32Resource(this, hres, (ULONG)lpszName, (ULONG)szType);
    378397    }
    379398
    380399    if(hres == NULL && (int)lpszName >> 16 == 0 && (int)szType == NTRT_STRING) {
    381         hres = O32_FindResource(hinstance, (LPCSTR)(((ULONG)lpszName - 1)*16), (LPCSTR)NTRT_RCDATA);
    382         if(hres) {
    383                 res = new Win32Resource(this, hres, (ULONG)lpszName, (ULONG)szType);
    384         }
    385         else    dprintf(("FindResourceW can't find string %d\n", (int)lpszName));
     400      hres = O32_FindResource(hinstance, (LPCSTR)(((ULONG)lpszName - 1)*16), (LPCSTR)NTRT_RCDATA);
     401      if(hres) {
     402         res = new Win32Resource(this, hres, (ULONG)lpszName, (ULONG)szType);
     403      }
     404      else    dprintf(("FindResourceW can't find string %d\n", (int)lpszName));
    386405    }
    387406    if(astring1)    FreeAsciiString(astring1);
Note: See TracChangeset for help on using the changeset viewer.