Changeset 3683


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

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

Location:
trunk/libc/src/kNIX
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/src/kNIX/Makefile.kmk

    r2937 r3683  
    166166    $(PATH_LIBC_SRC)/kNIX/os2/safesems.c \
    167167    $(PATH_LIBC_SRC)/kNIX/os2/__libc_back_native2errno.c \
     168    $(PATH_LIBC_SRC)/kNIX/os2/__libc_back_errno2native.c \
    168169    $(PATH_LIBC_SRC)/kNIX/os2/sharedpm.c \
    169170    $(PATH_LIBC_SRC)/kNIX/os2/signals.c \
  • trunk/libc/src/kNIX/kNIX.h

    r2936 r3683  
    262262int __libc_back_sys_processGetResourceLimit(int iResId, struct rlimit *pLimit);
    263263int __libc_back_native2errno(int rc);
     264int __libc_back_errno2native(int rc);
    264265void __libc_back_hooksInit(const char *pszSpec, uintptr_t hmod);
    265266/** @} */
  • trunk/libc/src/kNIX/os2/b_ldrOpen.c

    r2929 r3683  
    4343    LIBCLOG_ENTER("pszLibrary=%p:{%s} fFlags=%#x ppvModule=%p pszError=%p cchError=%d\n",
    4444                  (void *)pszLibrary, pszLibrary, fFlags, (void *)ppvModule, (void *)pszError, cchError);
    45     HMODULE     hmod;
    46     FS_VAR();
    47     FS_SAVE_LOAD();
    48     int rc = DosLoadModuleEx((PSZ)pszError, cchError, (PCSZ)pszLibrary, &hmod);
    49     FS_RESTORE();
    50     if (!rc)
     45    const char *pszNativePath;
     46    char        szNativePath[PATH_MAX];
     47    int         rc;
     48
     49    /*
     50     * Resolve the path if one is given.  Ignore failures to resolve the file
     51     * name is it may lack the extension (I think) - DosLoadModule will fail,
     52     * so no problem.
     53     */
     54    if (!strpbrk(pszLibrary, ":/\\"))
    5155    {
    52         *ppvModule = (void *)hmod;
    53         LIBCLOG_RETURN_INT(0);
     56        pszNativePath = pszLibrary; /* no path, don't try resolve anything. */
     57        rc = 0;
    5458    }
     59    else
     60    {
     61        pszNativePath = szNativePath;
     62        rc = __libc_back_fsResolve(pszLibrary, BACKFS_FLAGS_RESOLVE_FULL_MAYBE, &szNativePath[0], NULL);
     63    }
     64    if (rc == 0)
     65    {
     66        HMODULE hmod;
     67        FS_VAR_SAVE_LOAD();
     68        rc = DosLoadModuleEx((PSZ)pszError, cchError, (PCSZ)pszLibrary, &hmod);
     69        FS_RESTORE();
     70        if (!rc)
     71        {
     72            *ppvModule = (void *)hmod;
     73            LIBCLOG_RETURN_INT(0);
     74        }
     75    }
     76    else
     77        rc = __libc_back_errno2native(-rc);
    5578    LIBCLOG_ERROR_RETURN_INT(rc);
    5679}
Note: See TracChangeset for help on using the changeset viewer.