Changeset 1879


Ignore:
Timestamp:
Nov 29, 1999, 9:43:02 PM (25 years ago)
Author:
sandervl
Message:

EnumResourceTypesA/W changes

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/include/winimagebase.h

    r1872 r1879  
    1 /* $Id: winimagebase.h,v 1.6 1999-11-29 00:05:03 bird Exp $ */
     1/* $Id: winimagebase.h,v 1.7 1999-11-29 20:42:20 sandervl Exp $ */
    22
    33/*
     
    7070virtual BOOL  enumResourceNamesA(HMODULE hmod, LPCTSTR  lpszType, ENUMRESNAMEPROCA lpEnumFunc, LONG lParam);
    7171virtual BOOL  enumResourceNamesW(HMODULE hmod, LPCWSTR  lpszType, ENUMRESNAMEPROCW lpEnumFunc, LONG lParam);
     72virtual BOOL  enumResourceTypesA(HMODULE hmod, ENUMRESTYPEPROCA lpEnumFunc,
     73                                 LONG lParam);
     74virtual BOOL  enumResourceTypesW(HMODULE hmod, ENUMRESTYPEPROCW lpEnumFunc,
     75                                 LONG lParam);
    7276
    7377virtual ULONG getVersionSize();
  • TabularUnified trunk/src/kernel32/resource.cpp

    r1872 r1879  
    1 /* $Id: resource.cpp,v 1.10 1999-11-29 00:04:05 bird Exp $ */
     1/* $Id: resource.cpp,v 1.11 1999-11-29 20:43:01 sandervl Exp $ */
    22
    33/*
     
    163163}
    164164
     165/*****************************************************************************
     166 * Name      : BOOL WIN32API EnumResourceLanguagesA
     167 * Purpose   : The EnumResourceLanguagesA function searches a module for each
     168 *             resource of the specified type and name and passes the language
     169 *             of each resource it locates to a defined callback function
     170 * Parameters: HMODULE hModule                  resource-module handle
     171 *             LPCTSTR lpType                   pointer to resource type
     172 *             LPCTSTR lpName,                  pointer to resource name
     173 *             ENUMRESLANGPROC lpEnumFunc       pointer to callback function
     174 *             LONG lParam                  application-defined parameter
     175 * Variables :
     176 * Result    : If the function succeeds, the return value is nonzero.
     177 *             If the function fails, the return value is zero.
     178 * Remark    : The EnumResourceLanguages function continues to enumerate
     179 *             resource languages until the callback function returns FALSE
     180 *             or all resource languages have been enumerated.
     181 * Status    : UNTESTED STUB
     182 *
     183 * Author    : Markus Montkowski [Tha, 1998/05/21 17:46]
     184 *****************************************************************************/
     185
     186BOOL WIN32API EnumResourceLanguagesA(HMODULE hModule, LPCSTR lpType,
     187                                     LPCSTR lpName,
     188                                     ENUMRESLANGPROCA lpEnumFunc,
     189                                     LONG lParam)
     190{
     191
     192  dprintf(("KERNEL32:EnumResourceLanguagesA(%08x,%08x,%08x,%08x,%08x)\n not implemented",
     193           hModule, lpType, lpName, lpEnumFunc, lParam
     194          ));
     195
     196  return (FALSE);
     197}
     198
     199/*****************************************************************************
     200 * Name      : BOOL WIN32API EnumResourceLanguagesW
     201 * Purpose   : The EnumResourceLanguagesW function searches a module for each
     202 *             resource of the specified type and name and passes the language
     203 *             of each resource it locates to a defined callback function
     204 * Parameters: HMODULE hModule                  resource-module handle
     205 *             LPCTSTR lpType                   pointer to resource type
     206 *             LPCTSTR lpName,                  pointer to resource name
     207 *             ENUMRESLANGPROC lpEnumFunc       pointer to callback function
     208 *             LONG lParam                  application-defined parameter
     209 * Variables :
     210 * Result    : If the function succeeds, the return value is nonzero.
     211 *             If the function fails, the return value is zero.
     212 * Remark    : The EnumResourceLanguages function continues to enumerate
     213 *             resource languages until the callback function returns FALSE
     214 *             or all resource languages have been enumerated.
     215 * Status    : UNTESTED STUB
     216 *
     217 * Author    : Markus Montkowski [Tha, 1998/05/21 17:46]
     218 *****************************************************************************/
     219
     220BOOL WIN32API EnumResourceLanguagesW(HMODULE hModule, LPCWSTR lpType,
     221                                     LPCWSTR lpName,
     222                                     ENUMRESLANGPROCW lpEnumFunc,
     223                                     LONG lParam)
     224{
     225
     226  dprintf(("KERNEL32:EnumResourceLanguagesW(%08x,%08x,%08x,%08x,%08x)\n not implemented",
     227           hModule, lpType, lpName, lpEnumFunc, lParam
     228          ));
     229
     230  return (FALSE);
     231}
     232
     233
     234
     235/*****************************************************************************
     236 * Name      : BOOL WIN32API EnumResourceTypesA
     237 * Purpose   : The EnumResourceTypesA function searches a module for resources
     238 *             and passes each resource type it finds to an application-defined
     239 *             callback function
     240 * Parameters: HMODULE hModule,                    resource-module handle
     241 *             ENUMRESTYPEPROC lpEnumFunc          pointer to callback function
     242 *             LONG lParam                         application-defined parameter
     243 * Variables :
     244 * Result    : If the function succeeds, the return value is nonzero.
     245 * If the function fails, the return value is zero
     246 * Remark    :
     247 * Status    : UNTESTED STUB
     248 *
     249 * Author    : Markus Montkowski [Tha, 1998/05/21 17:46]
     250 *****************************************************************************/
     251
     252BOOL WIN32API EnumResourceTypesA(HMODULE hModule,
     253                                 ENUMRESTYPEPROCA lpEnumFunc, LONG lParam)
     254{
     255    Win32ImageBase *pModule;
     256
     257    dprintf(("KERNEL32:EnumResourceTypesA(%08x,%08x,%08x)\n",
     258              hModule, lpEnumFunc, lParam));
     259
     260    pModule = Win32ImageBase::findModule(hModule);
     261    if (pModule == NULL)
     262    {
     263        SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
     264        return FALSE;
     265    }
     266
     267    return pModule->enumResourceTypesA(hModule, lpEnumFunc, lParam);
     268}
     269
     270/*****************************************************************************
     271 * Name      : BOOL WIN32API EnumResourceTypesW
     272 * Purpose   : The EnumResourceTypesW function searches a module for resources
     273 *             and passes each resource type it finds to an application-defined
     274 *             callback function
     275 * Parameters: HMODULE hModule,                    resource-module handle
     276 *             ENUMRESTYPEPROC lpEnumFunc          pointer to callback function
     277 *             LONG lParam                         application-defined parameter
     278 * Variables :
     279 * Result    : If the function succeeds, the return value is nonzero.
     280 * If the function fails, the return value is zero
     281 * Remark    :
     282 * Status    : UNTESTED STUB
     283 *
     284 * Author    : Markus Montkowski [Tha, 1998/05/21 17:46]
     285 *****************************************************************************/
     286
     287BOOL WIN32API EnumResourceTypesW(HMODULE hModule,
     288                                 ENUMRESTYPEPROCW lpEnumFunc, LONG lParam)
     289{
     290    Win32ImageBase *pModule;
     291
     292    dprintf(("KERNEL32:EnumResourceTypesW(%08x,%08x,%08x)\n",
     293              hModule, lpEnumFunc, lParam));
     294
     295    pModule = Win32ImageBase::findModule(hModule);
     296    if (pModule == NULL)
     297    {
     298        SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
     299        return FALSE;
     300    }
     301
     302    return pModule->enumResourceTypesW(hModule, lpEnumFunc, lParam);
     303}
  • TabularUnified trunk/src/kernel32/stubs.cpp

    r1872 r1879  
    1 /* $Id: stubs.cpp,v 1.8 1999-11-29 00:04:05 bird Exp $ */
     1/* $Id: stubs.cpp,v 1.9 1999-11-29 20:43:01 sandervl Exp $ */
    22
    33/*
     
    14501450
    14511451/*****************************************************************************
    1452  * Name      : BOOL WIN32API EnumResourceLanguagesA
    1453  * Purpose   : The EnumResourceLanguagesA function searches a module for each
    1454  *             resource of the specified type and name and passes the language
    1455  *             of each resource it locates to a defined callback function
    1456  * Parameters: HMODULE hModule                  resource-module handle
    1457  *             LPCTSTR lpType                   pointer to resource type
    1458  *             LPCTSTR lpName,                  pointer to resource name
    1459  *             ENUMRESLANGPROC lpEnumFunc       pointer to callback function
    1460  *             LONG lParam                  application-defined parameter
    1461  * Variables :
    1462  * Result    : If the function succeeds, the return value is nonzero.
    1463  *             If the function fails, the return value is zero.
    1464  * Remark    : The EnumResourceLanguages function continues to enumerate
    1465  *             resource languages until the callback function returns FALSE
    1466  *             or all resource languages have been enumerated.
    1467  * Status    : UNTESTED STUB
    1468  *
    1469  * Author    : Markus Montkowski [Tha, 1998/05/21 17:46]
    1470  *****************************************************************************/
    1471 
    1472 BOOL WIN32API EnumResourceLanguagesA(HMODULE hModule, LPCSTR lpType,
    1473                                      LPCSTR lpName,
    1474                                      ENUMRESLANGPROCA lpEnumFunc,
    1475                                      LONG lParam)
    1476 {
    1477 
    1478   dprintf(("KERNEL32:EnumResourceLanguagesA(%08x,%08x,%08x,%08x,%08x)\n not implemented",
    1479            hModule, lpType, lpName, lpEnumFunc, lParam
    1480           ));
    1481 
    1482   return (FALSE);
    1483 }
    1484 
    1485 /*****************************************************************************
    1486  * Name      : BOOL WIN32API EnumResourceLanguagesW
    1487  * Purpose   : The EnumResourceLanguagesW function searches a module for each
    1488  *             resource of the specified type and name and passes the language
    1489  *             of each resource it locates to a defined callback function
    1490  * Parameters: HMODULE hModule                  resource-module handle
    1491  *             LPCTSTR lpType                   pointer to resource type
    1492  *             LPCTSTR lpName,                  pointer to resource name
    1493  *             ENUMRESLANGPROC lpEnumFunc       pointer to callback function
    1494  *             LONG lParam                  application-defined parameter
    1495  * Variables :
    1496  * Result    : If the function succeeds, the return value is nonzero.
    1497  *             If the function fails, the return value is zero.
    1498  * Remark    : The EnumResourceLanguages function continues to enumerate
    1499  *             resource languages until the callback function returns FALSE
    1500  *             or all resource languages have been enumerated.
    1501  * Status    : UNTESTED STUB
    1502  *
    1503  * Author    : Markus Montkowski [Tha, 1998/05/21 17:46]
    1504  *****************************************************************************/
    1505 
    1506 BOOL WIN32API EnumResourceLanguagesW(HMODULE hModule, LPCWSTR lpType,
    1507                                      LPCWSTR lpName,
    1508                                      ENUMRESLANGPROCW lpEnumFunc,
    1509                                      LONG lParam)
    1510 {
    1511 
    1512   dprintf(("KERNEL32:EnumResourceLanguagesW(%08x,%08x,%08x,%08x,%08x)\n not implemented",
    1513            hModule, lpType, lpName, lpEnumFunc, lParam
    1514           ));
    1515 
    1516   return (FALSE);
    1517 }
    1518 
    1519 
    1520 
    1521 /*****************************************************************************
    1522  * Name      : BOOL WIN32API EnumResourceTypesA
    1523  * Purpose   : The EnumResourceTypesA function searches a module for resources
    1524  *             and passes each resource type it finds to an application-defined
    1525  *             callback function
    1526  * Parameters: HMODULE hModule,                    resource-module handle
    1527  *             ENUMRESTYPEPROC lpEnumFunc          pointer to callback function
    1528  *             LONG lParam                         application-defined parameter
    1529  * Variables :
    1530  * Result    : If the function succeeds, the return value is nonzero.
    1531  * If the function fails, the return value is zero
    1532  * Remark    :
    1533  * Status    : UNTESTED STUB
    1534  *
    1535  * Author    : Markus Montkowski [Tha, 1998/05/21 17:46]
    1536  *****************************************************************************/
    1537 
    1538 BOOL WIN32API EnumResourceTypesA(HMODULE hModule,
    1539                                  ENUMRESTYPEPROCA lpEnumFunc, LONG lParam)
    1540 {
    1541 
    1542   dprintf(("KERNEL32:  EnumResourceTypesA(%08x,%08x,%08x) not implemented\n",
    1543            hModule, lpEnumFunc, lParam
    1544           ));
    1545 
    1546   return (FALSE);
    1547 }
    1548 
    1549 /*****************************************************************************
    1550  * Name      : BOOL WIN32API EnumResourceTypesW
    1551  * Purpose   : The EnumResourceTypesW function searches a module for resources
    1552  *             and passes each resource type it finds to an application-defined
    1553  *             callback function
    1554  * Parameters: HMODULE hModule,                    resource-module handle
    1555  *             ENUMRESTYPEPROC lpEnumFunc          pointer to callback function
    1556  *             LONG lParam                         application-defined parameter
    1557  * Variables :
    1558  * Result    : If the function succeeds, the return value is nonzero.
    1559  * If the function fails, the return value is zero
    1560  * Remark    :
    1561  * Status    : UNTESTED STUB
    1562  *
    1563  * Author    : Markus Montkowski [Tha, 1998/05/21 17:46]
    1564  *****************************************************************************/
    1565 
    1566 BOOL WIN32API EnumResourceTypesW(HMODULE hModule,
    1567                                  ENUMRESTYPEPROCW lpEnumFunc, LONG lParam)
    1568 {
    1569 
    1570   dprintf(("KERNEL32:  EnumResourceTypesW(%08x,%08x,%08x) not implemented\n",
    1571            hModule, lpEnumFunc, lParam
    1572           ));
    1573 
    1574   return (FALSE);
    1575 }
    1576 
    1577 /*****************************************************************************
    15781452 * Name      : BOOL WIN32API EnumSystemCodePagesA
    15791453 * Purpose   : The EnumSystemCodePagesA function enumerates the code pages that
  • TabularUnified trunk/src/kernel32/winimgres.cpp

    r1872 r1879  
    1 /* $Id: winimgres.cpp,v 1.27 1999-11-29 00:04:07 bird Exp $ */
     1/* $Id: winimgres.cpp,v 1.28 1999-11-29 20:43:02 sandervl Exp $ */
    22
    33/*
     
    270270    //for the resource section (images loaded by the pe.exe and pe2lx/win32k)
    271271    //For LX images, this is 0 as OffsetToData contains a relative offset
    272     char *resdata = (char *)((char *)pResDir + pData->OffsetToData - ulRVAResourceSection);
     272    char *resdata = (char *)((char *)pResDir + (pData->OffsetToData - ulRVAResourceSection));
    273273    res = new Win32Resource(this, id, type, pData->Size, resdata);
    274274
     
    299299    return(hres);
    300300}
    301 //******************************************************************************
    302 //TODO:
    303 //******************************************************************************
    304 #if 0
    305 ULONG Win32Pe2LxImage::getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
    306 {
    307     DebugInt3();
    308     return 0;
    309 }
    310 #endif
    311301//******************************************************************************
    312302//******************************************************************************
     
    356346    if(getVersionId() == -1) {
    357347        dprintf(("GetVersionStruct: %s has no version resource!\n", szModule));
     348        SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
    358349        return(FALSE);
    359350    }
     
    380371    if(pData == NULL) {
    381372        dprintf(("Win32PeLdrImage::getVersionStruct: couldn't find version resource!"));
     373        SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
    382374        return 0;
    383375    }
     
    432424    if (pResDir == NULL)
    433425    {
    434         /* SetLastError(?);? */
     426        SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
    435427        return FALSE;
    436428    }
     
    702694    return pResDirRet;
    703695}
    704 
     696//******************************************************************************
     697//******************************************************************************
     698BOOL Win32ImageBase::enumResourceTypesA(HMODULE hmod, ENUMRESTYPEPROCA lpEnumFunc,
     699                                        LONG lParam)
     700{
     701 PIMAGE_RESOURCE_DIRECTORY       prdType;
     702 PIMAGE_RESOURCE_DIRECTORY_ENTRY prde;
     703 PIMAGE_RESOURCE_DIR_STRING_U    pstring;
     704 ULONG  i, nameOffset;
     705 BOOL   fRet;
     706
     707    if (pResDir == NULL)
     708    {
     709        SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
     710        return FALSE;
     711    }
     712
     713    if ((unsigned)lpEnumFunc < 0x10000 || (unsigned)lpEnumFunc >= 0xc0000000)
     714    {
     715        SetLastError(ERROR_NOACCESS);
     716        return FALSE;
     717    }
     718
     719    //reminder:
     720    //1st level -> types
     721    //2nd level -> names
     722    //3rd level -> language
     723
     724    /* set pointer to first resource type entry */
     725    prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResDir + sizeof(IMAGE_RESOURCE_DIRECTORY));
     726
     727    for (i=0; i<pResDir->NumberOfNamedEntries+pResDir->NumberOfIdEntries && fRet; i++)
     728    {
     729        /* locate directory or each resource type */
     730        prdType = (PIMAGE_RESOURCE_DIRECTORY)((int)pResDir + (int)prde->u2.OffsetToData);
     731
     732        if (prde->u1.s.NameIsString)
     733        {//name or id entry?
     734                //SvL: 30-10-'97, high bit is set, so clear to get real offset
     735                nameOffset = prde->u1.Name & ~0x80000000;
     736       
     737                pstring = (PIMAGE_RESOURCE_DIR_STRING_U)((ULONG)pResDir + nameOffset);
     738                char *typename = (char *)malloc(pstring->Length+1);
     739                lstrcpynWtoA(typename, pstring->NameString, pstring->Length+1);
     740                typename[pstring->Length] = 0;
     741
     742                fRet = lpEnumFunc(hmod, typename, lParam);
     743                free(typename);
     744        }
     745        else {
     746                fRet = lpEnumFunc(hmod, (LPSTR)prde->u1.Id, lParam);
     747        }
     748
     749        /* increment to next entry */
     750        prde++;
     751    }
     752    return fRet > 0 ? TRUE : FALSE;
     753}
     754//******************************************************************************
     755//******************************************************************************
     756BOOL Win32ImageBase::enumResourceTypesW(HMODULE hmod, ENUMRESTYPEPROCW lpEnumFunc,
     757                                        LONG lParam)
     758{
     759 PIMAGE_RESOURCE_DIRECTORY       prdType;
     760 PIMAGE_RESOURCE_DIRECTORY_ENTRY prde;
     761 PIMAGE_RESOURCE_DIR_STRING_U    pstring;
     762 ULONG  i, nameOffset;
     763 BOOL   fRet;
     764
     765    if (pResDir == NULL)
     766    {
     767        SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
     768        return FALSE;
     769    }
     770
     771    if ((unsigned)lpEnumFunc < 0x10000 || (unsigned)lpEnumFunc >= 0xc0000000)
     772    {
     773        SetLastError(ERROR_NOACCESS);
     774        return FALSE;
     775    }
     776
     777    //reminder:
     778    //1st level -> types
     779    //2nd level -> names
     780    //3rd level -> language
     781
     782    /* set pointer to first resource type entry */
     783    prde = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResDir + sizeof(IMAGE_RESOURCE_DIRECTORY));
     784
     785    for (i=0; i<pResDir->NumberOfNamedEntries+pResDir->NumberOfIdEntries && fRet; i++)
     786    {
     787        /* locate directory or each resource type */
     788        prdType = (PIMAGE_RESOURCE_DIRECTORY)((int)pResDir + (int)prde->u2.OffsetToData);
     789
     790        if (prde->u1.s.NameIsString)
     791        {//name or id entry?
     792                //SvL: 30-10-'97, high bit is set, so clear to get real offset
     793                nameOffset = prde->u1.Name & ~0x80000000;
     794       
     795                pstring = (PIMAGE_RESOURCE_DIR_STRING_U)((ULONG)pResDir + nameOffset);
     796                fRet = lpEnumFunc(hmod, pstring->NameString, lParam);
     797        }
     798        else    fRet = lpEnumFunc(hmod, (LPWSTR)prde->u1.Id, lParam);
     799
     800        /* increment to next entry */
     801        prde++;
     802    }
     803    return fRet > 0 ? TRUE : FALSE;
     804}
     805//******************************************************************************
     806//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.