VirtualBox

Changeset 74859 in vbox for trunk


Ignore:
Timestamp:
Oct 16, 2018 3:00:58 AM (6 years ago)
Author:
vboxsync
Message:

tstLdr-4: check data accessess too. bugref:9232

Location:
trunk/src/VBox/Runtime/testcase
Files:
2 edited

Legend:

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

    r74654 r74859  
    4040#include <iprt/string.h>
    4141
     42#include <VBox/sup.h>
     43
     44
     45/*********************************************************************************************************************************
     46*   Global Variables                                                                                                             *
     47*********************************************************************************************************************************/
     48static SUPGLOBALINFOPAGE g_MyGip = { SUPGLOBALINFOPAGE_MAGIC, SUPGLOBALINFOPAGE_VERSION, SUPGIPMODE_INVARIANT_TSC, 42 };
     49static PSUPGLOBALINFOPAGE g_pMyGip = &g_MyGip;
    4250
    4351extern "C" DECLEXPORT(int) DisasmTest1(void);
     52
     53
     54static DECLCALLBACK(int) testEnumSegment(RTLDRMOD hLdrMod, PCRTLDRSEG pSeg, void *pvUser)
     55{
     56    uint32_t *piSeg = (uint32_t *)pvUser;
     57    RTPrintf("  Seg#%02u: %RTptr LB %RTptr %s\n"
     58             "     link=%RTptr LB %RTptr align=%RTptr fProt=%#x offFile=%RTfoff\n"
     59             , *piSeg, pSeg->RVA, pSeg->cbMapped, pSeg->pszName,
     60             pSeg->LinkAddress, pSeg->cb, pSeg->Alignment, pSeg->fProt, pSeg->offFile);
     61    *piSeg += 1;
     62    RT_NOREF(hLdrMod);
     63    return VINF_SUCCESS;
     64}
    4465
    4566
     
    80101    else if (!strcmp(pszSymbol, "MyPrintf")             || !strcmp(pszSymbol, "_MyPrintf"))
    81102        *pValue = (uintptr_t)RTPrintf;
     103    else if (!strcmp(pszSymbol, "SUPR0Printf")          || !strcmp(pszSymbol, "_SUPR0Printf"))
     104        *pValue = (uintptr_t)RTPrintf;
    82105    else if (!strcmp(pszSymbol, "SomeImportFunction")   || !strcmp(pszSymbol, "_SomeImportFunction"))
    83106        *pValue = (uintptr_t)0;
     107    else if (!strcmp(pszSymbol, "g_pSUPGlobalInfoPage") || !strcmp(pszSymbol, "_g_pSUPGlobalInfoPage"))
     108        *pValue = (uintptr_t)&g_pMyGip;
     109    else if (!strcmp(pszSymbol, "g_SUPGlobalInfoPage")  || !strcmp(pszSymbol, "_g_SUPGlobalInfoPage"))
     110        *pValue = (uintptr_t)&g_MyGip;
    84111    else
    85112    {
     
    189216            DECLCALLBACKPTR(int, pfnDisasmTest1)(void) = (DECLCALLBACKPTR(int, RT_NOTHING)(void))(uintptr_t)Value; /* eeeh. */
    190217            RTPrintf("tstLdr-4: pfnDisasmTest1=%p / add-symbol-file %s %#x\n", pfnDisasmTest1, pszFilename, aLoads[i].pvBits);
     218            uint32_t iSeg = 0;
     219            RTLdrEnumSegments(aLoads[i].hLdrMod, testEnumSegment, &iSeg);
    191220
    192221            /* call the test function. */
  • trunk/src/VBox/Runtime/testcase/tstLdrDisasmTest.cpp

    r69111 r74859  
    3737#include <VBox/dis.h>
    3838#include <VBox/disopcode.h>
     39#include <VBox/sup.h>
    3940#include <iprt/string.h>
    4041
    41 #if defined(IN_RING0) && !defined(RT_OS_WINDOWS) /* Too lazy to make import libs. */
    42 extern "C" DECLIMPORT(int) MyPrintf(const char *pszFormat, ...);
    43 # define MY_PRINTF(a) MyPrintf a
     42#if defined(IN_RING0)
     43# define MY_PRINTF(a) SUPR0Printf a
    4444#else
    4545# define MY_PRINTF(a) do {} while (0)
     
    116116    MY_PRINTF(("DisasmTest1: %p\n", &DisasmTest1));
    117117
     118#if defined(IN_RING0)
     119    MY_PRINTF(("GIP: g_pSUPGlobalInfoPage=%p\n", g_pSUPGlobalInfoPage));
     120    MY_PRINTF(("GIP: magic=%#x version=%#x mode=%d cCpus=%d\n", g_pSUPGlobalInfoPage->u32Magic, g_pSUPGlobalInfoPage->u32Version,
     121               g_pSUPGlobalInfoPage->u32Mode, g_pSUPGlobalInfoPage->cCpus));
     122    if (g_pSUPGlobalInfoPage->u32Magic != SUPGLOBALINFOPAGE_MAGIC)
     123        return 0xc001;
     124    if (g_pSUPGlobalInfoPage->u32Version != SUPGLOBALINFOPAGE_VERSION)
     125        return 0xc002;
     126    if (g_pSUPGlobalInfoPage->u32Mode != SUPGIPMODE_INVARIANT_TSC)
     127        return 0xc003;
     128    if (g_pSUPGlobalInfoPage->cCpus != 42)
     129        return 0xc004;
     130#endif
     131
    118132    memset(&Cpu, 0, sizeof(Cpu));
    119133
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