Changeset 3685


Ignore:
Timestamp:
Mar 14, 2011, 11:25:04 PM (14 years ago)
Author:
bird
Message:

kNIX/os2: Resolve the dll path passed to DosLoadModule[Ex]. Fixes #181.

Location:
branches/libc-0.6/src/emx/src/lib/sys
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • TabularUnified branches/libc-0.6/src/emx/src/lib/sys/b_ldrOpen.c

    r2254 r3685  
    5353    LIBCLOG_ENTER("pszLibrary=%p:{%s} fFlags=%#x ppvModule=%p pszError=%p cchError=%d\n",
    5454                  (void *)pszLibrary, pszLibrary, fFlags, (void *)ppvModule, (void *)pszError, cchError);
    55     HMODULE     hmod;
    56     FS_VAR();
    57     FS_SAVE_LOAD();
    58     int rc = DosLoadModuleEx((PSZ)pszError, cchError, (PCSZ)pszLibrary, &hmod);
    59     FS_RESTORE();
    60     if (!rc)
     55    const char *pszNativePath;
     56    char        szNativePath[PATH_MAX];
     57    int         rc;
     58
     59    /*
     60     * Resolve the path if one is given.  Ignore failures to resolve the file
     61     * name is it may lack the extension (I think) - DosLoadModule will fail,
     62     * so no problem.
     63     */
     64    if (!strpbrk(pszLibrary, ":/\\"))
    6165    {
    62         *ppvModule = (void *)hmod;
    63         LIBCLOG_RETURN_INT(0);
     66        pszNativePath = pszLibrary; /* no path, don't try resolve anything. */
     67        rc = 0;
    6468    }
     69    else
     70    {
     71        pszNativePath = szNativePath;
     72        rc = __libc_back_fsResolve(pszLibrary, BACKFS_FLAGS_RESOLVE_FULL_MAYBE, &szNativePath[0], NULL);
     73    }
     74    if (rc == 0)
     75    {
     76        HMODULE hmod;
     77        FS_VAR_SAVE_LOAD();
     78        rc = DosLoadModuleEx((PSZ)pszError, cchError, (PCSZ)pszNativePath, &hmod);
     79        FS_RESTORE();
     80        if (!rc)
     81        {
     82            *ppvModule = (void *)hmod;
     83            LIBCLOG_RETURN_INT(0);
     84        }
     85    }
     86    else
     87        rc = __libc_back_errno2native(-rc);
    6588    LIBCLOG_ERROR_RETURN_INT(rc);
    6689}
Note: See TracChangeset for help on using the changeset viewer.