Ignore:
Timestamp:
Jul 7, 2001, 6:39:11 AM (24 years ago)
Author:
bird
Message:

Corrected bad search. DBE.DLL migth return the DBEQ.DLL mte. Corrected bad implementation of the loader name bug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/ldr/myldrFindModule.cpp

    r5086 r6192  
    1 /* $Id: myldrFindModule.cpp,v 1.2 2001-02-10 11:11:46 bird Exp $
     1/* $Id: myldrFindModule.cpp,v 1.3 2001-07-07 04:39:11 bird Exp $
    22 *
    33 * ldrFindModule - ldrFindModule replacement with support for long DLL names
     
    4848extern  PPMTE pspecific_l;
    4949
     50/*******************************************************************************
     51*   Internal Functions                                                         *
     52*******************************************************************************/
     53int     mymemicmp(void *pv1, void *pv2, unsigned int cch);
     54
    5055
    5156/**
     
    5661 *
    5762 * @returns     NO_ERROR on success.
     63 *              If not found we'll still return NO_ERROR, but *ppMTE is NULL.
    5864 *              OS/2 errorcode on error.
    5965 * @param       pachFilename    Pointer to module filename.
     
    7379ULONG LDRCALL myldrFindModule(PCHAR pachFilename, USHORT cchFilename, USHORT usClass, PPMTE ppMTE)
    7480{
     81    /*
     82     * Log.
     83     */
     84    kprintf(("myldrFindModule: fn=%.*s  len=%d  class=0x%02x  ppMTE=0x%08x\n", cchFilename, pachFilename, cchFilename, usClass, ppMTE));
     85
    7586    /* Check if this feature is enabled */
    7687    if (isDllFixesDisabled())
     
    7889        #ifdef DEBUG
    7990        APIRET rc = ldrFindModule(pachFilename, cchFilename, usClass, ppMTE);
    80         kprintf(("ldrFindModule: fn=%.*s  len=%d  class=0x%02x  ppMTE=0x%08x rc=%d (original)\n", cchFilename, pachFilename, cchFilename, usClass, ppMTE, rc));
     91        if (rc == NO_ERROR && *ppMTE == NULL)
     92            kprintf(("myldrFindModule: Not Found\n"));
     93        else
     94            kprintf((usClass == CLASS_GLOBAL
     95                     ? "myldrFindModule: Found pmte=0x%08x  hmte=0x%04x  modname=%.8s  path=%s (GLOBAL)\n"
     96                     : "myldrFindModule: Found pmte=0x%08x  hmte=0x%04x  modname=%.8s  path=%s (%x)\n",
     97                     *ppMTE, (*ppMTE)->mte_handle, (*ppMTE)->mte_modname,
     98                     (*ppMTE)->mte_swapmte->smte_path, (*ppMTE)->mte_flags1 & CLASS_MASK));
    8199        return rc;
    82100        #else
     
    105123    int     cchExt;                     /* Length of the extention part of pachFilename. (not dot!) */
    106124    int     cchName8;                   /* Length of modname in MTE. */
     125    int     fDllExt = FALSE;            /* Set if we have a .DLL extention. */
    107126
    108127    /*
     
    123142    }
    124143
    125     /*
    126      * Log.
    127      */
    128     kprintf(("myldrFindModule: fn=%.*s  len=%d  class=0x%02x  ppMTE=0x%08x\n", cchFilename, pachFilename, cchFilename, usClass, ppMTE));
    129144
    130145    /*
     
    194209            pachExt = "DLL";
    195210            cchExt = 3;
     211            fDllExt = TRUE;
    196212        }
    197213        else
    198214        {
    199215            cchName = pachExt - pachName;
     216            cchExt = cchFilename - cchName - 1;
     217            if (    cchExt == 3 && !memcmp(pachExt, ".DLL", 4)
     218                ||  cchName < 8 && !memcmp(pachExt, ".DLL", min(3, cchExt))
     219                )
     220                fDllExt = TRUE;
    200221            pachExt++;
    201             cchExt = cchFilename - cchName - 1;
    202         }
    203 
    204         cchName8 = cchName > 8 ? 8 : cchName;
     222        }
     223
     224        if (fDllExt)
     225            cchName8 = cchName > 8 ? 8 : cchName;
     226        else
     227            cchName8 = cchFilename > 8 ? 8 : cchFilename;
    205228
    206229        #ifdef DEBUG
     
    264287         */
    265288        if (usClass == CLASS_GLOBAL)
    266         {   /*
     289        {
     290            #if 0 /* fault code... Search for DBE.DLL may hit DBEQ.DLL.. */
     291            /*
    267292             * DLLs, match name only:
    268293             *  Check the module name from the resident MTE.
     
    292317                     )
    293318                )
     319            #else
     320            BOOL    fFound;             /* Flag which is set if this mte match the name we're searching for. */
     321
     322            if (cchName <= 8 && fDllExt)
     323            {   /*
     324                 * Compatability code.
     325                 *      Well only near compatible. If the internalname contains .DLL we will be able
     326                 *      to find a few modules which OS2 normally won't find. Disable the latest check
     327                 *      to make us 100% compatible.
     328                 */
     329                fFound =    !memcmp(pmte->mte_modname, pachFilename, cchName)
     330                         && (   cchName == 8
     331                             || pmte->mte_modname[cchName] == '\0'
     332                             || !memcmp(&pmte->mte_modname[cchName], ".DLL", min(5, 8 - cchName)) /* extra feature */
     333                             );
     334            }
     335            else
     336            {   /*
     337                 * Extention code.
     338                 *      There is a part of the name in the mte_modname. Check that first to eliminate
     339                 *        the next step where we access swappable code.
     340                 *      fDllExt:
     341                 *          These may or may not include the .DLL extention in the internal name.
     342                 *      !fDllExt:
     343                 *          These should contain the entire name in the internal name.
     344                 *          If no filename extension, then the internal name should end with a '.'.
     345                 *      NB! We have an issue of casesensitivity here... (ARG!!!)
     346                 *          That make this stuff a bit more expensive...
     347                 *          Possible fix is to use the filename, or to require an uppercased internal name...
     348                 */
     349                fFound = !memcmp(pmte->mte_modname, pachFilename, cchName8);
     350                if (fFound)
     351                {
     352                    PCHAR   pachResName;                /* Pointer to the internal name - resname.0 */
     353                    pachResName = (PCHAR)pmte->mte_swapmte->smte_restab;
     354                    if ((char*)pachResName < (char*)0x10000)
     355                    {
     356                        kprintf(("myldrFindModule: Holy Hand Grenade! there aint any resident names for this mte (0x%x)\n", pmte));
     357                        pachResName = "\0";
     358                    }
     359                    if (fDllExt)
     360                        fFound =    (   *pachResName == cchName
     361                                     || (   *pachResName == cchName + 4
     362                                         && !mymemicmp(&pachResName[1+cchName], ".DLL", 4)
     363                                         )
     364                                     )
     365                                 && !mymemicmp(pachResName + 1, pachFilename, cchName);
     366                    else
     367                        fFound =    *pachResName == cchName + cchExt + 1
     368                                 && !mymemicmp(pachResName+1, pachFilename, cchName + cchExt + 1);
     369                }
     370            }
     371
     372            if (fFound)
     373            #endif
    294374            {
    295375                *ppMTE = pmte;
    296376                kprintf(("myldrFindModule: Found pmte=0x%08x  hmte=0x%04x  modname=%.8s  path=%s (GLOBAL)\n",
    297                          pmte, pmte->mte_handle, pmte->mte_modname, pSMTE->smte_path));
     377                         pmte, pmte->mte_handle, pmte->mte_modname, pmte->mte_swapmte->smte_path));
    298378                return NO_ERROR;
    299379            }
     
    306386             */
    307387            PSMTE   pSMTE = pmte->mte_swapmte;
    308             if ((   cchName8 == 0           /* This is 0 if we should not check the mte_modname. */
    309                  || !memcmp(pmte->mte_modname, pachName, cchName8)
    310                  )
     388            if (   (   cchName8 == 0           /* This is 0 if we should not check the mte_modname. */
     389                    || !memcmp(pmte->mte_modname, pachName, cchName8)
     390                    )
    311391                &&  pSMTE->smte_pathlen == cchFilename - 1
    312392                &&  !memcmp(pSMTE->smte_path, pachFilename, cchFilename)    /* checks the '\0' too. */
     
    330410}
    331411
     412
     413
     414/**
     415 * This function is needed since pv1 might be a mixed case name.
     416 * @returns same as memcmp.
     417 * @param   pv1 Pointer to resident name or part of that. Might be mixed cased.
     418                This is uppercased.
     419 * @param   pv2 Pointer to name. ASSUMES Uppercase.
     420 * @param   cch Length
     421 * @remark
     422 */
     423int mymemicmp(void *pv1, void *pv2, unsigned int cch)
     424{
     425#if 0 /* safe code which doesn't modify the resident name... */
     426    if (!memcmp(pv1, pv2, cch))
     427        return 0;
     428    char *pach = (char*)SSToDS(alloca(cch));
     429    memcpy(pach, pv2, cch);
     430    ldrUCaseString(pach, cch);
     431    return memcmp(pv1, pach, cch);
     432#else
     433    if (!memcmp(pv1, pv2, cch))
     434        return 0;
     435    ldrUCaseString((PCHAR)pv1, cch);
     436    return memcmp(pv1, pv2, cch);
     437#endif
     438}
Note: See TracChangeset for help on using the changeset viewer.