VirtualBox

Ignore:
Timestamp:
Oct 16, 2018 12:49:25 AM (6 years ago)
Author:
vboxsync
Message:

IPRT/ldr: Must check that JmpStubsRVA isn't NIL and not use it blindly now that everything isn't MH_OBJECT. Return VERR_LDR_ADDRESS_OVERFLOW if nil. bugref:9232

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstLdr-3.cpp

    r74647 r74856  
    4646static void     *g_pvBits;
    4747static uint8_t   g_cBits;
     48static uint8_t   g_fNearImports;
    4849
    4950/**
     
    215216{
    216217    RT_NOREF5(hLdrMod, pszModule, pszSymbol, uSymbol, pvUser);
    217 #if 1
    218218    RTUINTPTR BaseAddr = *(PCRTUINTPTR)pvUser;
    219     *pValue = BaseAddr + UINT32_C(0x604020f0);
    220 #else
    221     *pValue = UINT64_C(0xffffff7f820df000);
    222 #endif
     219    if (g_fNearImports)
     220        *pValue = BaseAddr + UINT32_C(0x604020f0);
     221    else if (   BaseAddr < UINT64_C(0xffffff7f820df000) - _4G
     222             || BaseAddr > UINT64_C(0xffffff7f820df000) + _4G)
     223        *pValue = UINT64_C(0xffffff7f820df000);
     224    else
     225        *pValue = UINT64_C(0xffffff7c820df000);
    223226    if (g_cBits == 32)
    224227        *pValue &= UINT32_MAX;
     
    289292    RTR3InitExe(argc, &argv, 0);
    290293
    291     int rcRet = 0;
    292     if (argc <= 2)
    293     {
    294         RTPrintf("usage: %s <load-addr> <module> [addr1 []]\n", argv[0]);
    295         return 1;
    296     }
    297 
    298294    /*
    299295     * Module & code bitness (optional).
    300296     */
    301297    g_cBits = ARCH_BITS;
    302     if (!strcmp(argv[1], "--32"))
    303     {
    304         g_cBits = 32;
     298#if !defined(RT_OS_WINDOWS) || defined(RT_OS_DARWIN)
     299    g_fNearImports = false;
     300#else
     301    g_fNearImports = true;
     302#endif
     303    while (argc > 1)
     304    {
     305        if (!strcmp(argv[1], "--32"))
     306            g_cBits = 32;
     307        else if (!strcmp(argv[1], "--64"))
     308            g_cBits = 64;
     309        else if (!strcmp(argv[1], "--near-imports"))
     310            g_fNearImports = true;
     311        else if (!strcmp(argv[1], "--wide-imports"))
     312            g_fNearImports = false;
     313        else
     314            break;
    305315        argc--;
    306316        argv++;
    307317    }
    308     else if (!strcmp(argv[1], "--64"))
    309     {
    310         g_cBits = 64;
    311         argc--;
    312         argv++;
     318
     319    int rcRet = 0;
     320    if (argc <= 2)
     321    {
     322        RTPrintf("usage: %s [--32|--64] [--<near|wide>-imports] <load-addr> <module> [addr1 []]\n", argv[0]);
     323        return 1;
    313324    }
    314325
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