VirtualBox

Changeset 915 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Feb 15, 2007 1:14:36 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18643
Message:

A new loader testcase.

Location:
trunk/src/VBox/Runtime/testcase
Files:
1 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/Makefile

    r894 r915  
    2929        tstLdr-2 \
    3030        tstLdr-3 \
     31        tstLdr-4 \
    3132        tstLdrLoad \
    3233        tstAvl \
     
    6465PROGRAMS.l4 = \
    6566        tstIoCtl
    66 SYSMODS = tstLdrObj
     67SYSMODS = \
     68        tstLdrObj \
     69        tstLdrObjR0
    6770# tstSems
    6871endif # VBOX_WITH_TESTCASES
     
    128131tstLdrObj_SYSSUFF  = .gc
    129132tstLdrObj_SOURCES  = tstLdrObj.cpp
    130 tstLdrObj_DEFS     = IN_DIS_GC IN_RT_GC
     133tstLdrObj_DEFS     = IN_DIS_GC IN_RT_GC DIS_CORE_ONLY
    131134ifeq ($(VBOX_LDR_FMT32),elf)
    132135tstLdrObj_DEFS    += VBOX_SOME_IMPORT_FUNCTION
     
    150153endif
    151154
     155
    152156tstLdr-3_SOURCES = tstLdr-3.cpp
    153157tstLdr-3_DEFS    = IN_DIS_R3
     
    155159        $(PATH_LIB)/DisasmR3$(VBOX_SUFF_LIB)
    156160
     161tstLdrObjR0_TEMPLATE = VBOXR0
     162tstLdrObjR0_INST     = $(INST_TESTCASE)
     163tstLdrObjR0_SYSSUFF  = .r0
     164tstLdrObjR0_SOURCES  = tstLdrObjR0.cpp tstLdrDisasmTest.cpp
     165tstLdrObjR0_DEFS     = IN_DIS_R0 IN_RT_R0 DIS_CORE_ONLY
     166ifeq ($(VBOX_LDR_FMT32),elf)
     167 tstLdrObjR0_DEFS   += VBOX_SOME_IMPORT_FUNCTION
     168endif
     169tstLdrObjR0_LIBS     = \
     170        $(PATH_LIB)/DisasmR0$(VBOX_SUFF_LIB) \
     171        $(PATH_LIB)/RuntimeR0$(VBOX_SUFF_LIB)
     172ifeq ($(VBOX_LDR_FMT),pe)
     173 tstLdrObjR0_LDFLAGS = -Entry:Entrypoint
     174 tstLdrObjR0_LIBS   += \
     175        $(PATH_LIB)/SUPR0$(VBOX_SUFF_LIB)
     176endif
     177ifeq ($(VBOX_LDR_FMT),elf)
     178 tstLdrObjR0_LDFLAGS = -entry=Entrypoint
     179endif
     180ifeq ($(VBOX_LDR_FMT),lx)
     181 tstLdrObjR0_LIBS   += \
     182        $(PATH_LIB)/SUPR0$(VBOX_SUFF_LIB)
     183endif
     184
     185tstLdr-4_SOURCES = tstLdr-4.cpp tstLdrDisasmTest.cpp
     186tstLdr-4_DEFS    = IN_DIS_R3
     187tstLdr-4_LIBS    = \
     188        $(PATH_LIB)/DisasmR3$(VBOX_SUFF_LIB)
     189
    157190tstLdrLoad_SOURCES = tstLdrLoad.cpp
    158191
  • trunk/src/VBox/Runtime/testcase/tstLdr-4.cpp

    r913 r915  
    11/* $Id$ */
    22/** @file
    3  * InnoTek Portable Runtime - Testcase for parts of RTLdr*.
     3 * InnoTek Portable Runtime - Testcase for RTLdrOpen using ldrLdrObjR0.r0.
    44 */
    55
     
    3333
    3434
    35 /*******************************************************************************
    36 *   Global Variables                                                           *
    37 *******************************************************************************/
    38 /** If set, don't bitch when failing to resolve symbols. */
    39 static bool g_fDontBitchOnResolveFailure = false;
     35extern "C" DECLEXPORT(int) DisasmTest1(void);
     36
    4037
    4138/**
     
    5249static DECLCALLBACK(int) testGetImport(RTLDRMOD hLdrMod, const char *pszModule, const char *pszSymbol, unsigned uSymbol, RTUINTPTR *pValue, void *pvUser)
    5350{
    54     /* check the name format and only permit certain names */
    55     *pValue = 0xabcdef0f;
     51    if (!strcmp(pszSymbol, "AssertMsg1"))
     52        *pValue = (uintptr_t)AssertMsg1;
     53    else if (!strcmp(pszSymbol, "AssertMsg2"))
     54        *pValue = (uintptr_t)AssertMsg2;
     55    else if (!strcmp(pszSymbol, "RTLogDefaultInstance"))
     56        *pValue = (uintptr_t)RTLogDefaultInstance;
     57    else if (!strcmp(pszSymbol, "MyPrintf"))
     58        *pValue = (uintptr_t)RTPrintf;
     59    else
     60    {
     61        RTPrintf("tstLdr-4: Unexpected import '%s'!\n", pszSymbol);
     62        return VERR_SYMBOL_NOT_FOUND;
     63    }
    5664    return VINF_SUCCESS;
    5765}
     
    7179static int testLdrOne(const char *pszFilename)
    7280{
    73     int             rcRet = 0;
     81    int             cErrors = 0;
    7482    size_t          cbImage = 0;
    7583    struct Load
     
    7785        RTLDRMOD    hLdrMod;
    7886        void       *pvBits;
    79         RTUINTPTR   Addr;
    8087        char       *pszName;
    8188    }   aLoads[6] =
    8289    {
    83         { NULL, NULL, 0xefefef00, "foo" },
    84         { NULL, NULL, 0x40404040, "bar" },
    85         { NULL, NULL, 0xefefef00, "foobar" },
    86         { NULL, NULL, 0xefefef00, "kLdr-foo" },
    87         { NULL, NULL, 0x40404040, "kLdr-bar" },
    88         { NULL, NULL, 0xefefef00, "kLdr-foobar" }
     90        { NULL, NULL, "foo" },
     91        { NULL, NULL, "bar" },
     92        { NULL, NULL, "foobar" },
     93        { NULL, NULL, "kLdr-foo" },
     94        { NULL, NULL, "kLdr-bar" },
     95        { NULL, NULL, "kLdr-foobar" }
    8996    };
    9097    unsigned i;
     98    int rc;
    9199
    92100    /*
     
    95103    for (i = 0; i < ELEMENTS(aLoads); i++)
    96104    {
    97         int rc;
    98105        if (!strncmp(aLoads[i].pszName, "kLdr-", sizeof("kLdr-") - 1))
    99106            rc = RTLdrOpenkLdr(pszFilename, &aLoads[i].hLdrMod);
     
    102109        if (RT_FAILURE(rc))
    103110        {
    104             RTPrintf("tstLdr: Failed to open '%s'/%d, rc=%Rrc. aborting test.\n", pszFilename, i, rc);
     111            RTPrintf("tstLdr-4: Failed to open '%s'/%d, rc=%Rrc. aborting test.\n", pszFilename, i, rc);
    105112            Assert(aLoads[i].hLdrMod == NIL_RTLDRMOD);
    106             rcRet++;
     113            cErrors++;
    107114            break;
    108115        }
     
    112119        if (cbImage && cb != cbImage)
    113120        {
    114             RTPrintf("tstLdr: Size mismatch '%s'/%d. aborting test.\n", pszFilename, i);
    115             rcRet++;
     121            RTPrintf("tstLdr-4: Size mismatch '%s'/%d. aborting test.\n", pszFilename, i);
     122            cErrors++;
    116123            break;
    117124        }
     
    122129        if (!aLoads[i].pvBits)
    123130        {
    124             RTPrintf("tstLdr: Out of memory '%s'/%d cbImage=%d. aborting test.\n", pszFilename, i, cbImage);
    125             rcRet++;
     131            RTPrintf("tstLdr-4: Out of memory '%s'/%d cbImage=%d. aborting test.\n", pszFilename, i, cbImage);
     132            cErrors++;
    126133            break;
    127134        }
    128135
    129136        /* Get the bits. */
    130         rc = RTLdrGetBits(aLoads[i].hLdrMod, aLoads[i].pvBits, aLoads[i].Addr, testGetImport, NULL);
     137        rc = RTLdrGetBits(aLoads[i].hLdrMod, aLoads[i].pvBits, (uintptr_t)aLoads[i].pvBits, testGetImport, NULL);
    131138        if (RT_FAILURE(rc))
    132139        {
    133             RTPrintf("tstLdr: Failed to get bits for '%s'/%d, rc=%Rrc. aborting test\n", pszFilename, i, rc);
    134             rcRet++;
    135             break;
    136         }
    137     }
    138 
    139     /*
    140      * Continue with the relocations and symbol resolving.
    141      */
    142     if (!rcRet)
    143     {
    144         static RTUINTPTR aRels[] =
    145         {
    146             0xefefef00,                 /* same. */
    147             0x40404040,                 /* the other. */
    148             0xefefef00,                 /* back. */
    149             0x40404040,                 /* the other. */
    150             0xefefef00,                 /* back again. */
    151             0x77773420,                 /* somewhere entirely else. */
    152             0xf0000000,                 /* somewhere entirely else. */
    153             0x40404040,                 /* the other. */
    154             0xefefef00                  /* back again. */
    155         };
    156         struct Symbols
    157         {
    158             /** The symbol offset. -1 indicates the first time. */
    159             unsigned    off;
    160             /** The symbol name. */
    161             const char *pszName;
    162         } aSyms[] =
    163         {
    164             { ~0, "Entrypoint" },
    165             { ~0, "SomeExportFunction1" },
    166             { ~0, "SomeExportFunction2" },
    167             { ~0, "SomeExportFunction3" },
    168             { ~0, "SomeExportFunction4" },
    169             { ~0, "SomeExportFunction5" },
    170             { ~0, "SomeExportFunction5" },
    171             { ~0, "DISCoreOne" }
    172         };
    173 
    174         unsigned iRel = 0;
    175         for (;;)
    176         {
    177             /* Compare all which are at the same address. */
    178             for (i = 0; i < ELEMENTS(aLoads) - 1; i++)
    179             {
    180                 for (unsigned j = i + 1; j < ELEMENTS(aLoads); j++)
    181                 {
    182                     if (aLoads[j].Addr == aLoads[i].Addr)
    183                     {
    184                         if (memcmp(aLoads[j].pvBits, aLoads[i].pvBits, cbImage))
    185                         {
    186                             RTPrintf("tstLdr: Mismatch between load %d and %d. ('%s')\n", j, i, pszFilename);
    187                             const uint8_t *pu8J = (const uint8_t *)aLoads[j].pvBits;
    188                             const uint8_t *pu8I = (const uint8_t *)aLoads[i].pvBits;
    189                             for (uint32_t off = 0; off < cbImage; off++, pu8J++, pu8I++)
    190                                 if (*pu8J != *pu8I)
    191                                     RTPrintf("  %08x  %02x != %02x\n", off, *pu8J, *pu8I);
    192                             rcRet++;
    193                         }
    194                     }
    195                 }
    196             }
    197 
    198             /* compare symbols. */
    199             for (i = 0; i < ELEMENTS(aLoads); i++)
    200             {
    201                 for (unsigned iSym = 0; iSym < ELEMENTS(aSyms); iSym++)
    202                 {
    203                     RTUINTPTR Value;
    204                     int rc = RTLdrGetSymbolEx(aLoads[i].hLdrMod, aLoads[i].pvBits, aLoads[i].Addr, aSyms[iSym].pszName, &Value);
    205                     if (RT_SUCCESS(rc))
    206                     {
    207                         unsigned off = Value - aLoads[i].Addr;
    208                         if (off < cbImage)
    209                         {
    210                             if (aSyms[iSym].off == ~0U)
    211                                 aSyms[iSym].off = off;
    212                             else if (off != aSyms[iSym].off)
    213                             {
    214                                 RTPrintf("tstLdr: Mismatching symbol '%s' in '%s'/%d. expected off=%d got %d\n",
    215                                          aSyms[iSym].pszName, pszFilename, i, aSyms[iSym].off, off);
    216                                 rcRet++;
    217                             }
    218                         }
    219                         else
    220                         {
    221                             RTPrintf("tstLdr: Invalid value for symbol '%s' in '%s'/%d. off=%#x Value=%#x\n",
    222                                      aSyms[iSym].pszName, pszFilename, i, off, Value);
    223                             rcRet++;
    224                         }
    225                     }
    226                     else if (!g_fDontBitchOnResolveFailure)
    227                     {
    228                         RTPrintf("tstLdr: Failed to resolve symbol '%s' in '%s'/%d.\n", aSyms[iSym].pszName, pszFilename, i);
    229                         rcRet++;
    230                     }
    231                 }
    232             }
    233 
    234             if (iRel >= ELEMENTS(aRels))
    235                 break;
    236 
    237             /* relocate it stuff. */
    238             int rc = RTLdrRelocate(aLoads[2].hLdrMod, aLoads[2].pvBits, aRels[iRel], aLoads[2].Addr, testGetImport, NULL);
     140            RTPrintf("tstLdr-4: Failed to get bits for '%s'/%d, rc=%Rrc. aborting test\n", pszFilename, i, rc);
     141            cErrors++;
     142            break;
     143        }
     144    }
     145
     146    /*
     147     * Execute the code.
     148     */
     149    if (!cErrors)
     150    {
     151        for (i = 0; i < ELEMENTS(aLoads); i += 1)
     152        {
     153            /* get the pointer. */
     154            RTUINTPTR Value;
     155            rc = RTLdrGetSymbolEx(aLoads[i].hLdrMod, aLoads[i].pvBits, (uintptr_t)aLoads[i].pvBits, "DisasmTest1", &Value);
    239156            if (RT_FAILURE(rc))
    240157            {
    241                 RTPrintf("tstLdr: Relocate of '%s' from %#x to %#x failed, rc=%Rrc. Aborting test.\n",
    242                          pszFilename, aRels[iRel], aLoads[2].Addr, rc);
    243                 rcRet++;
     158                RTPrintf("tstLdr-4: Failed to get symbol \"Test1\" from load #%d: %Rrc\n", i, rc);
     159                cErrors++;
    244160                break;
    245161            }
    246             aLoads[2].Addr = aRels[iRel];
    247 
    248             /* next */
    249             iRel++;
    250         }
    251     }
     162            DECLCALLBACKPTR(int, pfnDisasmTest1)(void) = (DECLCALLBACKPTR(int, )(void))(uintptr_t)Value; /* eeeh. */
     163            RTPrintf("tstLdr-4: pfnDisasmTest1=%p / add-symbol-file %s %#x\n", pfnDisasmTest1, pszFilename, aLoads[i].pvBits);
     164
     165            /* call the test function. */
     166            rc = pfnDisasmTest1();
     167            if (rc)
     168            {
     169                RTPrintf("tstLdr-4: load #%d Test1 -> %#x\n", i, rc);
     170                cErrors++;
     171            }
     172        }
     173    }
     174
    252175
    253176    /*
     
    263186            if (RT_FAILURE(rc))
    264187            {
    265                 RTPrintf("tstLdr: Failed to close '%s' i=%d, rc=%Rrc.\n", pszFilename, i, rc);
    266                 rcRet++;
     188                RTPrintf("tstLdr-4: Failed to close '%s' i=%d, rc=%Rrc.\n", pszFilename, i, rc);
     189                cErrors++;
    267190            }
    268191        }
    269192    }
    270193
    271     return rcRet;
     194    return cErrors;
    272195}
    273196
     
    276199int main(int argc, char **argv)
    277200{
     201    int cErrors = 0;
    278202    RTR3Init();
    279203
    280     int rcRet = 0;
    281     if (argc <= 1)
    282     {
    283         RTPrintf("usage: %s <module> [more modules]\n", argv[0]);
     204    /*
     205     * Sanity check.
     206     */
     207    int rc = DisasmTest1();
     208    if (rc)
     209    {
     210        RTPrintf("tstLdr-4: FATAL ERROR - DisasmTest1 is buggy: rc=%#x\n", rc);
    284211        return 1;
    285212    }
    286213
    287214    /*
    288      * Iterate the files.
    289      */
    290     for (int argi = 1; argi < argc; argi++)
    291     {
    292         if (argv[argi][0] == '-' && argv[argi][1] == 'n')
    293             g_fDontBitchOnResolveFailure = true;
    294         else
    295         {
    296             RTPrintf("tstLdr: TESTING '%s'...\n", argv[argi]);
    297             rcRet += testLdrOne(argv[argi]);
    298         }
     215     * Execute the test.
     216     */
     217    char szPath[RTPATH_MAX];
     218    rc = RTPathProgram(szPath, sizeof(szPath) - sizeof("/tstLdrObjR0.r0"));
     219    if (RT_SUCCESS(rc))
     220    {
     221        strcat(szPath, "/tstLdrObjR0.r0");
     222        RTPrintf("tstLdr-4: TESTING '%s'...\n", szPath);
     223        cErrors += testLdrOne(szPath);
     224    }
     225    else
     226    {
     227        RTPrintf("tstLdr-4: RTPathProgram -> %Rrc\n", rc);
     228        cErrors++;
    299229    }
    300230
     
    302232     * Test result summary.
    303233     */
    304     if (!rcRet)
    305         RTPrintf("tstLdr: SUCCESS\n");
     234    if (!cErrors)
     235        RTPrintf("tstLdr-4: SUCCESS\n");
    306236    else
    307         RTPrintf("tstLdr: FAILURE - %d errors\n", rcRet);
    308     return !!rcRet;
     237        RTPrintf("tstLdr-4: FAILURE - %d errors\n", cErrors);
     238    return !!cErrors;
    309239}
  • trunk/src/VBox/Runtime/testcase/tstLdrDisasmTest.cpp

    r913 r915  
    3030*   Header Files                                                               *
    3131*******************************************************************************/
    32 #ifndef IN_GC
    33 # error "not IN_GC!"
     32#include <VBox/dis.h>
     33#include <VBox/disopcode.h>
     34#include <iprt/string.h>
     35
     36#if 1 && defined(IN_RING0)
     37extern "C" DECLIMPORT(int) MyPrintf(const char *pszFormat, ...);
     38# define MY_PRINTF(a) MyPrintf a
     39#else
     40# define MY_PRINTF(a) do {} while (0)
    3441#endif
    35 #include <VBox/dis.h>
    36 #include <VBox/vm.h>
    37 #include <iprt/string.h>
    3842
    3943
     
    4145*   Global Variables                                                           *
    4246*******************************************************************************/
    43 static const char szStr1[] = "some readonly string";
    44 static char szStr2[6000] = "some read/write string";
    45 static char achBss[8192];
    4647
    47 #ifdef VBOX_SOME_IMPORT_FUNCTION
    48 extern "C" DECLIMPORT(int) SomeImportFunction(void);
    49 #endif
     48/* 32-bit code */
     49static uint8_t g_ab32BitCode[] =
     50{
     51    0x55,               // 1000ab50 55              push    ebp
     52    0x8b,0xec,          // 1000ab51 8bec            mov     ebp,esp
     53    0x8b,0x45,0x08,     // 1000ab53 8b4508          mov     eax,dword ptr [ebp+8]
     54    0x81,0x38,0x07,0x07,// 1000ab56 813807076419    cmp     dword ptr [eax],19640707h
     55    0x64,0x19,
     56    0x75,0x09,          // 1000ab5c 7509            jne     kLdr!kLdrModMap+0x17 (1000ab67)
     57    0x8b,0x4d,0x08,     // 1000ab5e 8b4d08          mov     ecx,dword ptr [ebp+8]
     58    0x83,0x79,0x2c,0x00,// 1000ab61 83792c00        cmp     dword ptr [ecx+2Ch],0
     59    0x75,0x07,          // 1000ab65 7507            jne     kLdr!kLdrModMap+0x1e (1000ab6e)
     60    0xb8,0xc0,0x68,0x06,// 1000ab67 b8c0680600      mov     eax,668C0h
     61    0x00,
     62    0xeb,0x14,          // 1000ab6c eb14            jmp     kLdr!kLdrModMap+0x32 (1000ab82)
     63    0x33,0xd2,          // 1000ab6e 33d2            xor     edx,edx
     64    0x75,0xe1,          // 1000ab70 75e1            jne     kLdr!kLdrModMap+0x3 (1000ab53)
     65    0x8b,0x45,0x08,     // 1000ab72 8b4508          mov     eax,dword ptr [ebp+8]
     66    0x50,               // 1000ab75 50              push    eax
     67    0x8b,0x4d,0x08,     // 1000ab76 8b4d08          mov     ecx,dword ptr [ebp+8]
     68    0x8b,0x51,0x2c,     // 1000ab79 8b512c          mov     edx,dword ptr [ecx+2Ch]
     69    0xff,0x52,0x3c,     // 1000ab7c ff523c          call    dword ptr [edx+3Ch]
     70    0x83,0xc4,0x04,     // 1000ab7f 83c404          add     esp,4
     71    0x5d,               // 1000ab82 5d              pop     ebp
     72    0xc3,               // 1000ab83 c3              ret
     73    0xcc
     74};
    5075
    5176
    52 extern "C" DECLEXPORT(int) Entrypoint(void)
     77
     78DECLCALLBACK(int32_t) DisasmTest1ReadCode(RTUINTPTR SrcAddr, uint8_t *pbDst, uint32_t cb, RTUINTPTR uUser)
    5379{
    54     g_VM.fRawR0Enabled = true;
    55     g_VM.fRawR3Enabled = true;
    56     g_VM.fForcedActions = 0;
    57     strcpy(achBss, szStr2);
    58     memcpy(achBss, szStr1, sizeof(szStr1));
    59     memcpy(achBss, &g_VM, RT_MIN(sizeof(g_VM), sizeof(achBss)));
    60     memcpy(achBss, (void *)(uintptr_t)&Entrypoint, 32);
    61 #ifdef VBOX_SOME_IMPORT_FUNCTION
    62     memcpy(achBss, (void *)(uintptr_t)&SomeImportFunction, 32);
    63     return SomeImportFunction();
    64 #else
     80    while (cb > 0)
     81    {
     82        *pbDst = g_ab32BitCode[SrcAddr];
     83        /* next */
     84        pbDst++;
     85        SrcAddr++;
     86        cb--;
     87    }
    6588    return 0;
    66 #endif
    6789}
    6890
    6991
    70 extern "C" DECLEXPORT(uint32_t) SomeExportFunction1(void *pvBuf)
     92extern "C" DECLEXPORT(int) DisasmTest1(void)
    7193{
    72     memcpy(pvBuf, &g_VM, sizeof(g_VM));
    73     return g_VM.fForcedActions;
     94    DISCPUSTATE Cpu = {0};
     95    uintptr_t CodeIndex = 0;
     96    uint32_t cb;
     97    int rc;
     98#define DISAS_AND_CHECK(cbInstr, enmOp) \
     99        do { \
     100            rc = DISCoreOneEx(CodeIndex, CPUMODE_32BIT, DisasmTest1ReadCode, 0, &Cpu, &cb); \
     101            MY_PRINTF(("%d: rc=%d cb=%d Cpu: opcode=%#x pCurInstr=%p pfnReadBytes=%p (42=42)\n", \
     102                       __LINE__, rc, cb, Cpu.opcode, Cpu.pCurInstr, Cpu.pfnReadBytes, 42)); \
     103            if (RT_FAILURE(rc)) \
     104                return CodeIndex | 0xf000; \
     105            if (Cpu.pCurInstr->opcode != (enmOp)) \
     106                return CodeIndex| 0xe000; \
     107            if (cb != (cbInstr)) \
     108                return CodeIndex | 0xd000; \
     109            CodeIndex += cb; \
     110        } while (0)
     111
     112    DISAS_AND_CHECK(1, OP_PUSH);
     113    DISAS_AND_CHECK(2, OP_MOV);
     114    DISAS_AND_CHECK(3, OP_MOV);
     115    DISAS_AND_CHECK(6, OP_CMP);
     116    DISAS_AND_CHECK(2, OP_JNE);
     117    DISAS_AND_CHECK(3, OP_MOV);
     118    DISAS_AND_CHECK(4, OP_CMP);
     119    DISAS_AND_CHECK(2, OP_JNE);
     120    DISAS_AND_CHECK(5, OP_MOV);
     121    DISAS_AND_CHECK(2, OP_JMP);
     122    DISAS_AND_CHECK(2, OP_XOR);
     123    DISAS_AND_CHECK(2, OP_JNE);
     124    DISAS_AND_CHECK(3, OP_MOV);
     125    DISAS_AND_CHECK(1, OP_PUSH);
     126    DISAS_AND_CHECK(3, OP_MOV);
     127    DISAS_AND_CHECK(3, OP_MOV);
     128    DISAS_AND_CHECK(3, OP_CALL);
     129    DISAS_AND_CHECK(3, OP_ADD);
     130    DISAS_AND_CHECK(1, OP_POP);
     131    DISAS_AND_CHECK(1, OP_RETN);
     132    DISAS_AND_CHECK(1, OP_INT3);
     133
     134    return rc;
    74135}
    75136
    76 
    77 extern "C" DECLEXPORT(char *) SomeExportFunction2(void *pvBuf)
    78 {
    79     return (char *)memcpy(achBss, szStr1, sizeof(szStr1));
    80 }
    81 
    82 
    83 extern "C" DECLEXPORT(char *) SomeExportFunction3(void *pvBuf)
    84 {
    85     return (char *)memcpy(achBss, szStr2, strlen(szStr2));
    86 }
    87 
    88 
    89 extern "C" DECLEXPORT(void *) SomeExportFunction4(void)
    90 {
    91     static unsigned cb;
    92     DISCPUSTATE Cpu = {0};
    93     DISCoreOne(&Cpu, (RTGCUINTPTR)SomeExportFunction3, &cb);
    94     return (void *)(uintptr_t)&SomeExportFunction1;
    95 }
    96 
    97 
    98 extern "C" DECLEXPORT(uintptr_t) SomeExportFunction5(void)
    99 {
    100     return (uintptr_t)SomeExportFunction3(NULL) + (uintptr_t)SomeExportFunction2(NULL)
    101          + (uintptr_t)SomeExportFunction1(NULL) + (uintptr_t)&SomeExportFunction4;
    102 }
    103 
    104 
  • trunk/src/VBox/Runtime/testcase/tstLdrObjR0.cpp

    r913 r915  
    3030*   Header Files                                                               *
    3131*******************************************************************************/
    32 #ifndef IN_GC
    33 # error "not IN_GC!"
     32#ifndef IN_RING0
     33# error "not IN_RING0!"
    3434#endif
    3535#include <VBox/dis.h>
    36 #include <VBox/vm.h>
     36#include <VBox/disopcode.h>
    3737#include <iprt/string.h>
    3838
     
    5252extern "C" DECLEXPORT(int) Entrypoint(void)
    5353{
    54     g_VM.fRawR0Enabled = true;
    55     g_VM.fRawR3Enabled = true;
    56     g_VM.fForcedActions = 0;
    5754    strcpy(achBss, szStr2);
    5855    memcpy(achBss, szStr1, sizeof(szStr1));
    59     memcpy(achBss, &g_VM, RT_MIN(sizeof(g_VM), sizeof(achBss)));
    6056    memcpy(achBss, (void *)(uintptr_t)&Entrypoint, 32);
    6157#ifdef VBOX_SOME_IMPORT_FUNCTION
     
    7066extern "C" DECLEXPORT(uint32_t) SomeExportFunction1(void *pvBuf)
    7167{
    72     memcpy(pvBuf, &g_VM, sizeof(g_VM));
    73     return g_VM.fForcedActions;
     68    return achBss[0] + achBss[16384];
    7469}
    7570
Note: See TracChangeset for help on using the changeset viewer.

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