VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstLdrObjR0.cpp@ 2981

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

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1/* $Id: tstLdrObjR0.cpp 2981 2007-06-01 16:01:28Z 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 * If you received this file as part of a commercial VirtualBox
23 * distribution, then only the terms of your commercial VirtualBox
24 * license agreement apply instead of the previous paragraph.
25 */
26
27
28
29/*******************************************************************************
30* Header Files *
31*******************************************************************************/
32#ifndef IN_RING0
33# error "not IN_RING0!"
34#endif
35#include <VBox/dis.h>
36#include <VBox/disopcode.h>
37#include <iprt/string.h>
38
39
40/*******************************************************************************
41* Global Variables *
42*******************************************************************************/
43static const char szStr1[] = "some readonly string";
44static char szStr2[6000] = "some read/write string";
45static char achBss[8192];
46
47#ifdef VBOX_SOME_IMPORT_FUNCTION
48extern "C" DECLIMPORT(int) SomeImportFunction(void);
49#endif
50
51
52extern "C" DECLEXPORT(int) Entrypoint(void)
53{
54 strcpy(achBss, szStr2);
55 memcpy(achBss, szStr1, sizeof(szStr1));
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 return achBss[0] + achBss[16384];
69}
70
71
72extern "C" DECLEXPORT(char *) SomeExportFunction2(void *pvBuf)
73{
74 return (char *)memcpy(achBss, szStr1, sizeof(szStr1));
75}
76
77
78extern "C" DECLEXPORT(char *) SomeExportFunction3(void *pvBuf)
79{
80 return (char *)memcpy(achBss, szStr2, strlen(szStr2));
81}
82
83
84extern "C" DECLEXPORT(void *) SomeExportFunction4(void)
85{
86 static unsigned cb;
87 DISCPUSTATE Cpu = {0};
88 DISCoreOne(&Cpu, (uintptr_t)SomeExportFunction3, &cb);
89 return (void *)(uintptr_t)&SomeExportFunction1;
90}
91
92
93extern "C" DECLEXPORT(uintptr_t) SomeExportFunction5(void)
94{
95 return (uintptr_t)SomeExportFunction3(NULL) + (uintptr_t)SomeExportFunction2(NULL)
96 + (uintptr_t)SomeExportFunction1(NULL) + (uintptr_t)&SomeExportFunction4;
97}
98
99
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