VirtualBox

Changeset 65239 in vbox for trunk/src


Ignore:
Timestamp:
Jan 11, 2017 10:38:38 AM (8 years ago)
Author:
vboxsync
Message:

IPRT: Added RTLdrOpenEx that takes an optional RTERRINFO.

Location:
trunk/src/VBox/Runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/ldr/ldrFile.cpp

    r62477 r65239  
    243243
    244244/**
    245  * Open a binary image file, extended version.
     245 * Open a binary image file.
    246246 *
    247247 * @returns iprt status code.
    248248 * @param   pszFilename Image filename.
    249  * @param   fFlags      Reserved, MBZ.
     249 * @param   fFlags      Valid RTLDR_O_XXX combination.
    250250 * @param   enmArch     CPU architecture specifier for the image to be loaded.
    251251 * @param   phLdrMod    Where to store the handle to the loader module.
     
    253253RTDECL(int) RTLdrOpen(const char *pszFilename, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod)
    254254{
    255     LogFlow(("RTLdrOpen: pszFilename=%p:{%s} fFlags=%#x enmArch=%d phLdrMod=%p\n",
     255    return RTLdrOpenEx(pszFilename, fFlags, enmArch, phLdrMod, NULL /*pErrInfo*/);
     256}
     257RT_EXPORT_SYMBOL(RTLdrOpen);
     258
     259
     260/**
     261 * Open a binary image file, extended version.
     262 *
     263 * @returns iprt status code.
     264 * @param   pszFilename Image filename.
     265 * @param   fFlags      Valid RTLDR_O_XXX combination.
     266 * @param   enmArch     CPU architecture specifier for the image to be loaded.
     267 * @param   phLdrMod    Where to store the handle to the loader module.
     268 * @param   pErrInfo    Where to return extended error information. Optional.
     269 */
     270RTDECL(int) RTLdrOpenEx(const char *pszFilename, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
     271{
     272    LogFlow(("RTLdrOpenEx: pszFilename=%p:{%s} fFlags=%#x enmArch=%d phLdrMod=%p\n",
    256273             pszFilename, pszFilename, fFlags, enmArch, phLdrMod));
    257274    AssertMsgReturn(!(fFlags & ~RTLDR_O_VALID_MASK), ("%#x\n", fFlags), VERR_INVALID_PARAMETER);
     
    265282    if (RT_SUCCESS(rc))
    266283    {
    267         rc = RTLdrOpenWithReader(pReader, fFlags, enmArch, phLdrMod, NULL);
     284        rc = RTLdrOpenWithReader(pReader, fFlags, enmArch, phLdrMod, pErrInfo);
    268285        if (RT_SUCCESS(rc))
    269286        {
    270             LogFlow(("RTLdrOpen: return %Rrc *phLdrMod=%p\n", rc, *phLdrMod));
     287            LogFlow(("RTLdrOpenEx: return %Rrc *phLdrMod=%p\n", rc, *phLdrMod));
    271288            return rc;
    272289        }
     
    274291    }
    275292    *phLdrMod = NIL_RTLDRMOD;
    276     LogFlow(("RTLdrOpen: return %Rrc\n", rc));
    277     return rc;
    278 }
    279 RT_EXPORT_SYMBOL(RTLdrOpen);
     293    LogFlow(("RTLdrOpenEx: return %Rrc\n", rc));
     294    return rc;
     295}
     296RT_EXPORT_SYMBOL(RTLdrOpenEx);
    280297
    281298
  • trunk/src/VBox/Runtime/testcase/tstLdr-2.cpp

    r62724 r65239  
    9494static int testLdrOne(const char *pszFilename)
    9595{
     96    RTERRINFOSTATIC ErrInfo;
    9697    RTLDRMOD hLdrMod;
    97     int rc = RTLdrOpen(pszFilename, 0, RTLDRARCH_WHATEVER, &hLdrMod);
     98    int rc = RTLdrOpenEx(pszFilename, 0, RTLDRARCH_WHATEVER, &hLdrMod, RTErrInfoInitStatic(&ErrInfo));
    9899    if (RT_FAILURE(rc))
    99100    {
    100101        RTPrintf("tstLdr: Failed to open '%s', rc=%Rrc. aborting test.\n", pszFilename, rc);
     102        if (ErrInfo.szMsg[0])
     103            RTPrintf("tstLdr: %s\n", ErrInfo.szMsg);
    101104        Assert(hLdrMod == NIL_RTLDRMOD);
    102105        return 1;
  • trunk/src/VBox/Runtime/testcase/tstLdr-3.cpp

    r63063 r65239  
    302302     * Load the module.
    303303     */
     304    RTERRINFOSTATIC ErrInfo;
    304305    g_uLoadAddr = (RTUINTPTR)RTStrToUInt64(argv[1]);
    305     int rc = RTLdrOpen(argv[2], 0, RTLDRARCH_WHATEVER, &g_hLdrMod);
     306    int rc = RTLdrOpenEx(argv[2], 0, RTLDRARCH_WHATEVER, &g_hLdrMod, RTErrInfoInitStatic(&ErrInfo));
    306307    if (RT_FAILURE(rc))
    307308    {
    308309        RTPrintf("tstLdr-3: Failed to open '%s': %Rra\n", argv[2], rc);
     310        if (ErrInfo.szMsg[0])
     311            RTPrintf("tstLdr-3: %s\n", ErrInfo.szMsg);
    309312        return 1;
    310313    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette