VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstLdrObj.cpp@ 4071

Last change on this file since 4071 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1/* $Id: tstLdrObj.cpp 4071 2007-08-07 17:07:59Z vboxsync $ */
2/** @file
3 * innotek Portable Runtime - RTLdr test object.
4 *
5 * We use precompiled versions of this object for testing all the loaders.
6 *
7 * This is not supposed to be pretty or usable code, just something which
8 * make life difficult for the loader.
9 */
10
11/*
12 * Copyright (C) 2006-2007 innotek GmbH
13 *
14 * This file is part of VirtualBox Open Source Edition (OSE), as
15 * available from http://www.virtualbox.org. This file is free software;
16 * you can redistribute it and/or modify it under the terms of the GNU
17 * General Public License as published by the Free Software Foundation,
18 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
19 * distribution. VirtualBox OSE is distributed in the hope that it will
20 * be useful, but WITHOUT ANY WARRANTY of any kind.
21 */
22
23
24
25/*******************************************************************************
26* Header Files *
27*******************************************************************************/
28#ifndef IN_GC
29# error "not IN_GC!"
30#endif
31#include <VBox/dis.h>
32#include <VBox/vm.h>
33#include <iprt/string.h>
34
35
36/*******************************************************************************
37* Global Variables *
38*******************************************************************************/
39static const char szStr1[] = "some readonly string";
40static char szStr2[6000] = "some read/write string";
41static char achBss[8192];
42
43#ifdef VBOX_SOME_IMPORT_FUNCTION
44extern "C" DECLIMPORT(int) SomeImportFunction(void);
45#endif
46
47
48extern "C" DECLEXPORT(int) Entrypoint(void)
49{
50 g_VM.fRawR0Enabled = true;
51 g_VM.fRawR3Enabled = true;
52 g_VM.fForcedActions = 0;
53 strcpy(achBss, szStr2);
54 memcpy(achBss, szStr1, sizeof(szStr1));
55 memcpy(achBss, &g_VM, RT_MIN(sizeof(g_VM), sizeof(achBss)));
56 memcpy(achBss, (void *)(uintptr_t)&Entrypoint, 32);
57#ifdef VBOX_SOME_IMPORT_FUNCTION
58 memcpy(achBss, (void *)(uintptr_t)&SomeImportFunction, 32);
59 return SomeImportFunction();
60#else
61 return 0;
62#endif
63}
64
65
66extern "C" DECLEXPORT(uint32_t) SomeExportFunction1(void *pvBuf)
67{
68 memcpy(pvBuf, &g_VM, sizeof(g_VM));
69 return g_VM.fForcedActions;
70}
71
72
73extern "C" DECLEXPORT(char *) SomeExportFunction2(void *pvBuf)
74{
75 return (char *)memcpy(achBss, szStr1, sizeof(szStr1));
76}
77
78
79extern "C" DECLEXPORT(char *) SomeExportFunction3(void *pvBuf)
80{
81 return (char *)memcpy(achBss, szStr2, strlen(szStr2));
82}
83
84
85extern "C" DECLEXPORT(void *) SomeExportFunction4(void)
86{
87 static unsigned cb;
88 DISCPUSTATE Cpu = {0};
89 DISCoreOne(&Cpu, (RTGCUINTPTR)SomeExportFunction3, &cb);
90 return (void *)(uintptr_t)&SomeExportFunction1;
91}
92
93
94extern "C" DECLEXPORT(uintptr_t) SomeExportFunction5(void)
95{
96 return (uintptr_t)SomeExportFunction3(NULL) + (uintptr_t)SomeExportFunction2(NULL)
97 + (uintptr_t)SomeExportFunction1(NULL) + (uintptr_t)&SomeExportFunction4;
98}
99
100
Note: See TracBrowser for help on using the repository browser.

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