Changeset 22040


Ignore:
Timestamp:
Oct 25, 2012, 10:39:39 AM (8 years ago)
Author:
dmik
Message:

kernel32: Fix Win32ImageBase::matchModName().

As opposed to the declared functionality, it was comparing the name part
of the argument with the full path of the stored module name and this would
obviously not work if the module name were a full path.

One of the failig cases was a frequent attempt to retrieve the resources of the
current executable by doing LoadLibraryEx?() with the full executable name.

Location:
trunk/src/kernel32
Files:
4 edited

Legend:

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

    r22025 r22040  
    13481348
    13491349    HMFileInfo *fileInfo = (HMFileInfo *)pHMHandleData->dwUserData;
    1350     dprintf(("*** %s", fileInfo->lpszFileName));
    13511350    if(OSLibDosGetFileInformationByHandle(fileInfo->lpszFileName,
    13521351                                          INVALID_HANDLE_VALUE,
  • trunk/src/kernel32/oslibmisc.cpp

    r21648 r22040  
    267267//******************************************************************************
    268268//******************************************************************************
    269 char *OSLibStripPath(char *path)
    270 {
    271   /* @@@PH what does this function do ? Strip the path from a FQFN name ? */
    272   char *pszFilename;
    273   char *pszFilename1;
    274 
    275   pszFilename  = strrchr(path, '\\');                 /* find rightmost backslash */
    276   pszFilename1 = strrchr(path, '/');                  /* find rightmost slash */
    277   if(pszFilename > pszFilename1 && pszFilename != NULL)
    278     return (++pszFilename);              /* return pointer to next character */
    279 
    280   if (pszFilename1 != NULL)
    281     return (++pszFilename1);              /* return pointer to next character */
    282 
    283   return (path);                                     /* default return value */
     269const char *OSLibStripPath(const char *path)
     270{
     271    const char *pszName;
     272    register char ch;
     273
     274    /*
     275     * Search the filename string finding the modulename start and end.
     276     * The loop ends when we have passed one char left of the module name.
     277     */
     278    pszName = path + strlen(path) - 1;
     279    while (pszName >= path
     280           && (ch = *pszName) != '\\'
     281           && ch != '/'
     282           && ch != ':'
     283           )
     284    {
     285        pszName--;
     286    }
     287    pszName++;
     288
     289    return pszName;
    284290}
    285291//******************************************************************************
  • trunk/src/kernel32/oslibmisc.h

    r21308 r22040  
    1818#endif
    1919
    20 char *OSLibStripPath(char *path);
     20const char *OSLibStripPath(const char *path);
    2121
    2222ULONG OSLibiGetModuleHandleA(char *pszModule);
     
    109109#endif
    110110
     111#ifdef __cplusplus
     112inline char *OSLibStripPath(char *path)
     113{
     114    return (char *)OSLibStripPath((const char *)path);
     115}
    111116#endif
     117
     118#endif
  • trunk/src/kernel32/winimagebase.cpp

    r21916 r22040  
    557557BOOL Win32ImageBase::matchModName(const char *pszFilename) const
    558558{
    559     const char *pszModName;             /* Pointer to the modulename. */
    560     const char *pszModNameEnd = NULL;   /* Pointer to the dot starting the extention. (if any) */
    561     register char ch;
    562 
    563     /** @sketch
    564      * Search the filename string finding the modulename start and end.
    565      * The loop ends when we have passed one char left of the module name.
    566      */
    567     pszModName = pszFilename + strlen(pszFilename) - 1;
    568     while (pszModName >= pszFilename
    569            && (ch = *pszModName) != '\\'
    570            && ch != '/'
    571            && ch != ':'
    572            )
    573     {
    574         pszModName--;
    575     }
    576     pszModName++;
    577 
    578     /** @sketch
     559    /*
    579560     * Compare the names caseinsensitivly.
    580561     */
    581     return stricmp(pszModName, szModule) == 0;
     562    return stricmp(OSLibStripPath(pszFilename), OSLibStripPath(szModule)) == 0;
    582563}
    583564
Note: See TracChangeset for help on using the changeset viewer.