VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/SharedFolders/driver/Win2kWorkarounds.c

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.5 KB
Line 
1/* $Id: Win2kWorkarounds.c 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VirtualBox Windows Guest Shared Folders - Windows 2000 Hacks.
4 */
5
6/*
7 * Copyright (C) 2012-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#define FsRtlTeardownPerStreamContexts FsRtlTeardownPerStreamContexts_AvoidIt
33#define RtlGetVersion RtlGetVersion_AvoidIt
34#define PsGetProcessImageFileName PsGetProcessImageFileName_AvoidIt
35#include "vbsf.h"
36
37#include <iprt/asm.h>
38
39
40#if 0
41/*
42 * FsRtlTeardownPerStreamContexts.
43 */
44static VOID __stdcall Resolve_FsRtlTeardownPerStreamContexts(PFSRTL_ADVANCED_FCB_HEADER);
45static volatile PFN_FSRTLTEARDOWNPERSTREAMCONTEXTS g_pfnFsRtlTeardownPerStreamContexts = Resolve_FsRtlTeardownPerStreamContexts;
46
47
48static VOID __stdcall Fake_FsRtlTeardownPerStreamContexts(PFSRTL_ADVANCED_FCB_HEADER pAdvancedHeader)
49{
50 PLIST_ENTRY pCur;
51
52 ExAcquireFastMutex(pAdvancedHeader->FastMutex);
53
54 pCur = pAdvancedHeader->FilterContexts.Flink;
55 while (pCur != &pAdvancedHeader->FilterContexts)
56 {
57 PLIST_ENTRY pNext = pCur->Flink;
58 PFSRTL_PER_STREAM_CONTEXT pCtx = CONTAINING_RECORD(pCur, FSRTL_PER_STREAM_CONTEXT, Links);
59 Log(("Fake_FsRtlTeardownPerStreamContexts: %p\n", pCtx));
60 pCtx->FreeCallback(pCtx);
61 pCur = pNext;
62 }
63 InitializeListHead(&pAdvancedHeader->FilterContexts);
64
65 ExReleaseFastMutex(pAdvancedHeader->FastMutex);
66 return;
67}
68
69
70static VOID __stdcall Resolve_FsRtlTeardownPerStreamContexts(PFSRTL_ADVANCED_FCB_HEADER pAdvancedHeader)
71{
72 UNICODE_STRING RoutineName;
73 PFN_FSRTLTEARDOWNPERSTREAMCONTEXTS pfn;
74 Log(("Resolve_FsRtlTeardownPerStreamContexts: %p\n", pAdvancedHeader));
75
76 RtlInitUnicodeString(&RoutineName, L"KeIpiGenericCall");
77 pfn = (PFN_FSRTLTEARDOWNPERSTREAMCONTEXTS)MmGetSystemRoutineAddress(&RoutineName);
78 if (!pfn)
79 pfn = Fake_FsRtlTeardownPerStreamContexts;
80 ASMAtomicWritePtr(&g_pfnFsRtlTeardownPerStreamContexts, pfn);
81 pfn(pAdvancedHeader);
82}
83
84
85#undef FsRtlTeardownPerStreamContexts
86__declspec(dllexport) VOID
87FsRtlTeardownPerStreamContexts(PFSRTL_ADVANCED_FCB_HEADER pAdvancedHeader)
88{
89 Log(("FsRtlTeardownPerStreamContexts: %p\n", pAdvancedHeader));
90 g_pfnFsRtlTeardownPerStreamContexts(pAdvancedHeader);
91 Log(("FsRtlTeardownPerStreamContexts: returns\n"));
92}
93#endif
94
95
96/*
97 * RtlGetVersion
98 */
99typedef NTSTATUS (__stdcall * PFNRTLGETVERSION)(PRTL_OSVERSIONINFOW);
100static NTSTATUS __stdcall Resolve_RtlGetVersion(PRTL_OSVERSIONINFOW pVerInfo);
101static volatile PFNRTLGETVERSION g_pfnRtlGetVersion = Resolve_RtlGetVersion;
102
103
104static NTSTATUS __stdcall Fake_RtlGetVersion(PRTL_OSVERSIONINFOW pVerInfo)
105{
106 Log(("Fake_RtlGetVersion: %p\n", pVerInfo));
107 if (pVerInfo->dwOSVersionInfoSize < sizeof(*pVerInfo))
108 {
109 Log(("Fake_RtlGetVersion: -> STATUS_INVALID_PARAMETER (size = %#x)\n", pVerInfo->dwOSVersionInfoSize));
110 return STATUS_INVALID_PARAMETER;
111 }
112
113 /* Report Windows 2000 w/o SP. */
114 pVerInfo->dwMajorVersion = 5;
115 pVerInfo->dwMinorVersion = 0;
116 pVerInfo->dwBuildNumber = 2195;
117 pVerInfo->dwPlatformId = VER_PLATFORM_WIN32_NT;
118 pVerInfo->szCSDVersion[0] = '\0';
119
120 if (pVerInfo->dwOSVersionInfoSize >= sizeof(RTL_OSVERSIONINFOEXW))
121 {
122 PRTL_OSVERSIONINFOEXW pVerInfoEx = (PRTL_OSVERSIONINFOEXW)pVerInfo;
123 pVerInfoEx->wServicePackMajor = 0;
124 pVerInfoEx->wServicePackMinor = 0;
125 pVerInfoEx->wSuiteMask = 0;
126 pVerInfoEx->wProductType = VER_NT_WORKSTATION;
127 pVerInfoEx->wReserved = 0;
128 }
129
130 return STATUS_SUCCESS;
131}
132
133
134static NTSTATUS __stdcall Resolve_RtlGetVersion(PRTL_OSVERSIONINFOW pVerInfo)
135{
136 UNICODE_STRING RoutineName;
137 PFNRTLGETVERSION pfn;
138 Log(("Resolve_RtlGetVersion: %p\n", pVerInfo));
139
140 RtlInitUnicodeString(&RoutineName, L"RtlGetVersion");
141 pfn = (PFNRTLGETVERSION)(uintptr_t)MmGetSystemRoutineAddress(&RoutineName);
142 if (!pfn)
143 pfn = Fake_RtlGetVersion;
144 ASMAtomicWritePtr((void * volatile *)&g_pfnRtlGetVersion, (void *)(uintptr_t)pfn);
145
146 return pfn(pVerInfo);
147}
148
149
150#undef RtlGetVersion
151__declspec(dllexport) NTSTATUS __stdcall
152RtlGetVersion(PRTL_OSVERSIONINFOW pVerInfo)
153{
154 return g_pfnRtlGetVersion(pVerInfo);
155}
156
157
158/*
159 * PsGetProcessImageFileName
160 */
161
162typedef LPSTR (__stdcall * PFNPSGETPROCESSIMAGEFILENAME)(PEPROCESS pProcess);
163static LPSTR __stdcall Resolve_PsGetProcessImageFileName(PEPROCESS pProcess);
164static volatile PFNPSGETPROCESSIMAGEFILENAME g_pfnPsGetProcessImageFileName = Resolve_PsGetProcessImageFileName;
165
166
167static LPSTR __stdcall Fake_PsGetProcessImageFileName(PEPROCESS pProcess)
168{
169 RT_NOREF(pProcess);
170 Log(("Fake_PsGetProcessImageFileName: %p\n", pProcess));
171 return "Fake_PsGetProcessImageFileName";
172}
173
174
175static LPSTR __stdcall Resolve_PsGetProcessImageFileName(PEPROCESS pProcess)
176{
177 UNICODE_STRING RoutineName;
178 PFNPSGETPROCESSIMAGEFILENAME pfn;
179 Log(("Resolve_PsGetProcessImageFileName: %p\n", pProcess));
180
181 RtlInitUnicodeString(&RoutineName, L"PsGetProcessImageFileName");
182 pfn = (PFNPSGETPROCESSIMAGEFILENAME)(uintptr_t)MmGetSystemRoutineAddress(&RoutineName);
183 if (!pfn)
184 pfn = Fake_PsGetProcessImageFileName;
185 ASMAtomicWritePtr((void * volatile *)&g_pfnPsGetProcessImageFileName, (void *)(uintptr_t)pfn);
186
187 return pfn(pProcess);
188}
189
190
191#undef PsGetProcessImageFileName
192__declspec(dllexport) LPSTR __stdcall
193PsGetProcessImageFileName(PEPROCESS pProcess)
194{
195 return g_pfnPsGetProcessImageFileName(pProcess);
196}
197
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use