VirtualBox

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

Last change on this file since 23299 was 19143, checked in by vboxsync, 16 years ago

Compile fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.6 KB
Line 
1/* $Id: tstLdrObj.cpp 19143 2009-04-23 13:57:39Z vboxsync $ */
2/** @file
3 * IPRT - 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 Sun Microsystems, Inc.
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 (GPL) as published by the Free Software
18 * Foundation, in version 2 as it comes in the "COPYING" file of the
19 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
20 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
21 *
22 * The contents of this file may alternatively be used under the terms
23 * of the Common Development and Distribution License Version 1.0
24 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
25 * VirtualBox OSE distribution, in which case the provisions of the
26 * CDDL are applicable instead of those of the GPL.
27 *
28 * You may elect to license modified versions of this file under the
29 * terms and conditions of either the GPL or the CDDL or both.
30 *
31 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
32 * Clara, CA 95054 USA or visit http://www.sun.com if you need
33 * additional information or have any questions.
34 */
35
36
37
38/*******************************************************************************
39* Header Files *
40*******************************************************************************/
41#ifndef IN_RC
42# error "not IN_RC!"
43#endif
44#include <VBox/dis.h>
45#include <VBox/vm.h>
46#include <iprt/string.h>
47
48
49/*******************************************************************************
50* Global Variables *
51*******************************************************************************/
52static const char szStr1[] = "some readonly string";
53static char szStr2[6000] = "some read/write string";
54static char achBss[8192];
55
56#ifdef VBOX_SOME_IMPORT_FUNCTION
57extern "C" DECLIMPORT(int) SomeImportFunction(void);
58#endif
59
60
61extern "C" DECLEXPORT(int) Entrypoint(void)
62{
63 g_VM.fRawR0Enabled = true;
64 g_VM.fRawR3Enabled = true;
65 g_VM.fGlobalForcedActions = 0;
66 strcpy(achBss, szStr2);
67 memcpy(achBss, szStr1, sizeof(szStr1));
68 memcpy(achBss, &g_VM, RT_MIN(sizeof(g_VM), sizeof(achBss)));
69 memcpy(achBss, (void *)(uintptr_t)&Entrypoint, 32);
70#ifdef VBOX_SOME_IMPORT_FUNCTION
71 memcpy(achBss, (void *)(uintptr_t)&SomeImportFunction, 32);
72 return SomeImportFunction();
73#else
74 return 0;
75#endif
76}
77
78
79extern "C" DECLEXPORT(uint32_t) SomeExportFunction1(void *pvBuf)
80{
81 memcpy(pvBuf, &g_VM, sizeof(g_VM));
82 return g_VM.fGlobalForcedActions;
83}
84
85
86extern "C" DECLEXPORT(char *) SomeExportFunction2(void *pvBuf)
87{
88 return (char *)memcpy(achBss, szStr1, sizeof(szStr1));
89}
90
91
92extern "C" DECLEXPORT(char *) SomeExportFunction3(void *pvBuf)
93{
94 return (char *)memcpy(achBss, szStr2, strlen(szStr2));
95}
96
97
98extern "C" DECLEXPORT(void *) SomeExportFunction4(void)
99{
100 static unsigned cb;
101 DISCPUSTATE Cpu;
102 memset(&Cpu, 0, sizeof(Cpu));
103 Cpu.mode = CPUMODE_32BIT;
104 DISCoreOne(&Cpu, (RTGCUINTPTR)SomeExportFunction3, &cb);
105 return (void *)(uintptr_t)&SomeExportFunction1;
106}
107
108
109extern "C" DECLEXPORT(uintptr_t) SomeExportFunction5(void)
110{
111 return (uintptr_t)SomeExportFunction3(NULL) + (uintptr_t)SomeExportFunction2(NULL)
112 + (uintptr_t)SomeExportFunction1(NULL) + (uintptr_t)&SomeExportFunction4;
113}
114
115
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