VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/nt/nt3fakes-r0drv-nt.cpp@ 70206

Last change on this file since 70206 was 70192, checked in by vboxsync, 7 years ago

IPRT/r0drv/nt: Tricks for working with NT 3.51.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1/* $Id: nt3fakes-r0drv-nt.cpp 70192 2017-12-18 13:34:19Z vboxsync $ */
2/** @file
3 * IPRT - NT 3.x fakes for NT 4.0 KPIs.
4 */
5
6/*
7 * Copyright (C) 2006-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#define PsGetVersion PsGetVersion_Nt4Plus
32#define ZwQuerySystemInformation ZwQuerySystemInformation_Nt4Plus
33#define KeInitializeTimerEx KeInitializeTimerEx_Nt4Plus
34#define KeSetTimerEx KeSetTimerEx_Nt4Plus
35#define IoAttachDeviceToDeviceStack IoAttachDeviceToDeviceStack_Nt4Plus
36#define PsGetCurrentProcessId PsGetCurrentProcessId_Nt4Plus
37#define ZwYieldExecution ZwYieldExecution_Nt4Plus
38
39#include "the-nt-kernel.h"
40#include <iprt/mem.h>
41
42#include <iprt/assert.h>
43#include <iprt/err.h>
44#include "internal-r0drv-nt.h"
45
46#undef PsGetVersion
47#undef ZwQuerySystemInformation
48#undef KeInitializeTimerEx
49#undef KeSetTimerEx
50#undef IoAttachDeviceToDeviceStack
51#undef PsGetCurrentProcessId
52#undef ZwYieldExecution
53
54
55/*********************************************************************************************************************************
56* Global Variables *
57*********************************************************************************************************************************/
58static uint32_t g_uNt3Version = 351;
59
60
61
62extern "C" DECLEXPORT(BOOLEAN) __stdcall
63PsGetVersion(ULONG *puMajor, ULONG *puMinor, ULONG *puBuildNo, UNICODE_STRING *pCsdStr)
64{
65 if (puMajor)
66 *puMajor = 3;
67 if (puMinor)
68 *puMinor = 51;
69 if (puBuildNo)
70 *puMinor = 1057;
71 if (pCsdStr)
72 {
73 pCsdStr->Buffer[0] = '\0';
74 pCsdStr->Length = 0;
75 }
76 return FALSE; /* not checked. */
77}
78
79
80extern "C" DECLEXPORT(NTSTATUS) __stdcall
81ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS enmClass, PVOID pvBuf, ULONG cbBuf, PULONG pcbActual)
82{
83 switch (enmClass)
84 {
85 case SystemModuleInformation:
86 {
87 PRTL_PROCESS_MODULES pInfo = (PRTL_PROCESS_MODULES)pvBuf;
88 ULONG cbNeeded = RT_UOFFSETOF(RTL_PROCESS_MODULES, Modules[2]);
89 if (pcbActual)
90 *pcbActual = cbNeeded;
91 if (cbBuf < cbNeeded)
92 return STATUS_INFO_LENGTH_MISMATCH;
93
94 pInfo->NumberOfModules = 2;
95
96 /* ntoskrnl.exe */
97 pInfo->Modules[0].Section = NULL;
98 pInfo->Modules[0].MappedBase = (PVOID)UINT32_C(0x80100000);
99 pInfo->Modules[0].ImageBase = (PVOID)UINT32_C(0x80100000);
100 pInfo->Modules[0].ImageSize = UINT32_C(0x80400000) - UINT32_C(0x80100000);
101 pInfo->Modules[0].Flags = 0;
102 pInfo->Modules[0].LoadOrderIndex = 0;
103 pInfo->Modules[0].InitOrderIndex = 0;
104 pInfo->Modules[0].LoadCount = 1024;
105 pInfo->Modules[0].OffsetToFileName = sizeof("\\SystemRoot\\System32\\") - 1;
106 memcpy(pInfo->Modules[0].FullPathName, RT_STR_TUPLE("\\SystemRoot\\System32\\ntoskrnl.exe"));
107
108 /* hal.dll */
109 pInfo->Modules[1].Section = NULL;
110 pInfo->Modules[1].MappedBase = (PVOID)UINT32_C(0x80400000);
111 pInfo->Modules[1].ImageBase = (PVOID)UINT32_C(0x80400000);
112 pInfo->Modules[1].ImageSize = _512K;
113 pInfo->Modules[1].Flags = 0;
114 pInfo->Modules[1].LoadOrderIndex = 1;
115 pInfo->Modules[1].InitOrderIndex = 0;
116 pInfo->Modules[1].LoadCount = 1024;
117 pInfo->Modules[1].OffsetToFileName = sizeof("\\SystemRoot\\System32\\") - 1;
118 memcpy(pInfo->Modules[1].FullPathName, RT_STR_TUPLE("\\SystemRoot\\System32\\hal.dll"));
119
120 return STATUS_SUCCESS;
121 }
122
123 default:
124 return STATUS_INVALID_INFO_CLASS;
125 }
126}
127
128
129extern "C" DECLEXPORT(VOID)
130KeInitializeTimerEx(PKTIMER pTimer, TIMER_TYPE enmType)
131{
132 KeInitializeTimer(pTimer);
133 NOREF(enmType);
134 /** @todo Default is NotificationTimer, for SyncrhonizationTimer we need to
135 * do more work. timer-r0drv-nt.cpp is using the latter. :/ */
136}
137
138
139extern "C" DECLEXPORT(BOOLEAN) __stdcall
140KeSetTimerEx(PKTIMER pTimer, LARGE_INTEGER DueTime, LONG cMsPeriod, PKDPC pDpc)
141{
142 AssertReturn(cMsPeriod == 0, FALSE);
143 return KeSetTimer(pTimer, DueTime, pDpc);
144}
145
146
147extern "C" DECLEXPORT(PDEVICE_OBJECT)
148IoAttachDeviceToDeviceStack(PDEVICE_OBJECT pSourceDevice, PDEVICE_OBJECT pTargetDevice)
149{
150 NOREF(pSourceDevice); NOREF(pTargetDevice);
151 return NULL;
152}
153
154
155extern "C" DECLEXPORT(HANDLE)
156PsGetCurrentProcessId(void)
157{
158 uint8_t const *pbProcess = (uint8_t const *)IoGetCurrentProcess();
159 if (g_uNt3Version >= 350)
160 return *(HANDLE const *)&pbProcess[0x94];
161 return *(HANDLE const *)&pbProcess[0xb0];
162}
163
164
165extern "C" DECLEXPORT(NTSTATUS)
166ZwYieldExecution(VOID)
167{
168 LARGE_INTEGER Interval;
169 Interval.QuadPart = 0;
170 KeDelayExecutionThread(KernelMode, FALSE, &Interval);
171 return STATUS_SUCCESS;
172}
173
Note: See TracBrowser for help on using the repository browser.

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