VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp@ 70152

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

iprt/r0drv/nt: Reduce #ifdef'ing TARGET_NT4.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 20.0 KB
Line 
1/* $Id: initterm-r0drv-nt.cpp 70152 2017-12-15 14:51:54Z vboxsync $ */
2/** @file
3 * IPRT - Initialization & Termination, R0 Driver, NT.
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#include "the-nt-kernel.h"
32#include <iprt/asm-amd64-x86.h>
33#include <iprt/dbg.h>
34#include <iprt/err.h>
35#include <iprt/string.h>
36#include "internal/initterm.h"
37#include "internal-r0drv-nt.h"
38#include "symdb.h"
39#include "symdbdata.h"
40
41
42/*********************************************************************************************************************************
43* Global Variables *
44*********************************************************************************************************************************/
45/** ExSetTimerResolution, introduced in W2K. */
46PFNMYEXSETTIMERRESOLUTION g_pfnrtNtExSetTimerResolution;
47/** KeFlushQueuedDpcs, introduced in XP. */
48PFNMYKEFLUSHQUEUEDDPCS g_pfnrtNtKeFlushQueuedDpcs;
49/** HalRequestIpi, version introduced with windows 7. */
50PFNHALREQUESTIPI_W7PLUS g_pfnrtHalRequestIpiW7Plus;
51/** HalRequestIpi, version valid up to windows vista?? */
52PFNHALREQUESTIPI_PRE_W7 g_pfnrtHalRequestIpiPreW7;
53/** Worker for RTMpPokeCpu. */
54PFNRTSENDIPI g_pfnrtMpPokeCpuWorker;
55/** KeIpiGenericCall - Introduced in Windows Server 2003. */
56PFNRTKEIPIGENERICCALL g_pfnrtKeIpiGenericCall;
57/** KeSetTargetProcessorDpcEx - Introduced in Windows 7. */
58PFNKESETTARGETPROCESSORDPCEX g_pfnrtKeSetTargetProcessorDpcEx;
59/** KeInitializeAffinityEx - Introducted in Windows 7. */
60PFNKEINITIALIZEAFFINITYEX g_pfnrtKeInitializeAffinityEx;
61/** KeAddProcessorAffinityEx - Introducted in Windows 7. */
62PFNKEADDPROCESSORAFFINITYEX g_pfnrtKeAddProcessorAffinityEx;
63/** KeGetProcessorIndexFromNumber - Introducted in Windows 7. */
64PFNKEGETPROCESSORINDEXFROMNUMBER g_pfnrtKeGetProcessorIndexFromNumber;
65/** KeGetProcessorNumberFromIndex - Introducted in Windows 7. */
66PFNKEGETPROCESSORNUMBERFROMINDEX g_pfnrtKeGetProcessorNumberFromIndex;
67/** KeGetCurrentProcessorNumberEx - Introducted in Windows 7. */
68PFNKEGETCURRENTPROCESSORNUMBEREX g_pfnrtKeGetCurrentProcessorNumberEx;
69/** KeQueryActiveProcessors - Introducted in Windows 2000. */
70PFNKEQUERYACTIVEPROCESSORS g_pfnrtKeQueryActiveProcessors;
71/** KeQueryMaximumProcessorCount - Introducted in Vista and obsoleted W7. */
72PFNKEQUERYMAXIMUMPROCESSORCOUNT g_pfnrtKeQueryMaximumProcessorCount;
73/** KeQueryMaximumProcessorCountEx - Introducted in Windows 7. */
74PFNKEQUERYMAXIMUMPROCESSORCOUNTEX g_pfnrtKeQueryMaximumProcessorCountEx;
75/** KeQueryMaximumGroupCount - Introducted in Windows 7. */
76PFNKEQUERYMAXIMUMGROUPCOUNT g_pfnrtKeQueryMaximumGroupCount;
77/** KeQueryActiveProcessorCount - Introducted in Vista and obsoleted W7. */
78PFNKEQUERYACTIVEPROCESSORCOUNT g_pfnrtKeQueryActiveProcessorCount;
79/** KeQueryActiveProcessorCountEx - Introducted in Windows 7. */
80PFNKEQUERYACTIVEPROCESSORCOUNTEX g_pfnrtKeQueryActiveProcessorCountEx;
81/** KeQueryLogicalProcessorRelationship - Introducted in Windows 7. */
82PFNKEQUERYLOGICALPROCESSORRELATIONSHIP g_pfnrtKeQueryLogicalProcessorRelationship;
83/** KeRegisterProcessorChangeCallback - Introducted in Windows 7. */
84PFNKEREGISTERPROCESSORCHANGECALLBACK g_pfnrtKeRegisterProcessorChangeCallback;
85/** KeDeregisterProcessorChangeCallback - Introducted in Windows 7. */
86PFNKEDEREGISTERPROCESSORCHANGECALLBACK g_pfnrtKeDeregisterProcessorChangeCallback;
87/** Pointer to the MmProtectMdlSystemAddress kernel function if it's available.
88 * This API was introduced in XP. */
89decltype(MmProtectMdlSystemAddress) *g_pfnrtMmProtectMdlSystemAddress;
90/** MmAllocatePagesForMdl - Introduced in Windows 2000. */
91decltype(MmAllocatePagesForMdl) *g_pfnrtMmAllocatePagesForMdl;
92/** MmFreePagesFromMdl - Introduced in Windows 2000. */
93decltype(MmFreePagesFromMdl) *g_pfnrtMmFreePagesFromMdl;
94/** MmMapLockedPagesSpecifyCache - Introduced in Windows NT4 SP4. */
95decltype(MmMapLockedPagesSpecifyCache) *g_pfnrtMmMapLockedPagesSpecifyCache;
96/** MmAllocateContiguousMemorySpecifyCache - Introduced in Windows 2000. */
97decltype(MmAllocateContiguousMemorySpecifyCache) *g_pfnrtMmAllocateContiguousMemorySpecifyCache;
98/** RtlGetVersion, introduced in ??. */
99PFNRTRTLGETVERSION g_pfnrtRtlGetVersion;
100#ifndef RT_ARCH_AMD64
101/** KeQueryInterruptTime - exported/new in Windows 2000. */
102PFNRTKEQUERYINTERRUPTTIME g_pfnrtKeQueryInterruptTime;
103/** KeQuerySystemTime - exported/new in Windows 2000. */
104PFNRTKEQUERYSYSTEMTIME g_pfnrtKeQuerySystemTime;
105#endif
106/** KeQueryInterruptTimePrecise - new in Windows 8. */
107PFNRTKEQUERYINTERRUPTTIMEPRECISE g_pfnrtKeQueryInterruptTimePrecise;
108/** KeQuerySystemTimePrecise - new in Windows 8. */
109PFNRTKEQUERYSYSTEMTIMEPRECISE g_pfnrtKeQuerySystemTimePrecise;
110
111/** Offset of the _KPRCB::QuantumEnd field. 0 if not found. */
112uint32_t g_offrtNtPbQuantumEnd;
113/** Size of the _KPRCB::QuantumEnd field. 0 if not found. */
114uint32_t g_cbrtNtPbQuantumEnd;
115/** Offset of the _KPRCB::DpcQueueDepth field. 0 if not found. */
116uint32_t g_offrtNtPbDpcQueueDepth;
117
118/** The combined NT version, see RTNT_MAKE_VERSION. */
119uint32_t g_uRtNtVersion;
120/** The major version number. */
121uint8_t g_uRtNtMajorVer;
122/** The minor version number. */
123uint8_t g_uRtNtMinorVer;
124/** The build number. */
125uint32_t g_uRtNtBuildNo;
126
127/** Pointer to the MmHighestUserAddress kernel variable - can be NULL. */
128uintptr_t const *g_puRtMmHighestUserAddress;
129/** Pointer to the MmSystemRangeStart kernel variable - can be NULL. */
130uintptr_t const *g_puRtMmSystemRangeStart;
131
132
133/**
134 * Determines the NT kernel verison information.
135 *
136 * @param pOsVerInfo Where to return the version information.
137 *
138 * @remarks pOsVerInfo->fSmp is only definitive if @c true.
139 * @remarks pOsVerInfo->uCsdNo is set to MY_NIL_CSD if it cannot be determined.
140 */
141static void rtR0NtGetOsVersionInfo(PRTNTSDBOSVER pOsVerInfo)
142{
143 ULONG ulMajorVersion = 0;
144 ULONG ulMinorVersion = 0;
145 ULONG ulBuildNumber = 0;
146
147 pOsVerInfo->fChecked = PsGetVersion(&ulMajorVersion, &ulMinorVersion, &ulBuildNumber, NULL) == TRUE;
148 pOsVerInfo->uMajorVer = (uint8_t)ulMajorVersion;
149 pOsVerInfo->uMinorVer = (uint8_t)ulMinorVersion;
150 pOsVerInfo->uBuildNo = ulBuildNumber;
151#define MY_NIL_CSD 0x3f
152 pOsVerInfo->uCsdNo = MY_NIL_CSD;
153
154 if (g_pfnrtRtlGetVersion)
155 {
156 RTL_OSVERSIONINFOEXW VerInfo;
157 RT_ZERO(VerInfo);
158 VerInfo.dwOSVersionInfoSize = sizeof(VerInfo);
159
160 NTSTATUS rcNt = g_pfnrtRtlGetVersion(&VerInfo);
161 if (NT_SUCCESS(rcNt))
162 pOsVerInfo->uCsdNo = VerInfo.wServicePackMajor;
163 }
164
165 /* Note! We cannot quite say if something is MP or UNI. So, fSmp is
166 redefined to indicate that it must be MP.
167 Note! RTMpGetCount is not available here. */
168 pOsVerInfo->fSmp = ulMajorVersion >= 6; /* Vista and later has no UNI kernel AFAIK. */
169 if (!pOsVerInfo->fSmp)
170 {
171 if ( g_pfnrtKeQueryMaximumProcessorCountEx
172 && g_pfnrtKeQueryMaximumProcessorCountEx(ALL_PROCESSOR_GROUPS) > 1)
173 pOsVerInfo->fSmp = true;
174 else if ( g_pfnrtKeQueryMaximumProcessorCount
175 && g_pfnrtKeQueryMaximumProcessorCount() > 1)
176 pOsVerInfo->fSmp = true;
177 else if ( g_pfnrtKeQueryActiveProcessors
178 && g_pfnrtKeQueryActiveProcessors() > 1)
179 pOsVerInfo->fSmp = true;
180 else if (KeNumberProcessors > 1)
181 pOsVerInfo->fSmp = true;
182 }
183}
184
185
186/**
187 * Tries a set against the current kernel.
188 *
189 * @retval true if it matched up, global variables are updated.
190 * @retval false otherwise (no globals updated).
191 * @param pSet The data set.
192 * @param pbPrcb Pointer to the processor control block.
193 * @param pszVendor Pointer to the processor vendor string.
194 * @param pOsVerInfo The OS version info.
195 */
196static bool rtR0NtTryMatchSymSet(PCRTNTSDBSET pSet, uint8_t *pbPrcb, const char *pszVendor, PCRTNTSDBOSVER pOsVerInfo)
197{
198 /*
199 * Don't bother trying stuff where the NT kernel version number differs, or
200 * if the build type or SMPness doesn't match up.
201 */
202 if ( pSet->OsVerInfo.uMajorVer != pOsVerInfo->uMajorVer
203 || pSet->OsVerInfo.uMinorVer != pOsVerInfo->uMinorVer
204 || pSet->OsVerInfo.fChecked != pOsVerInfo->fChecked
205 || (!pSet->OsVerInfo.fSmp && pOsVerInfo->fSmp /*must-be-smp*/) )
206 {
207 //DbgPrint("IPRT: #%d Version/type mismatch.\n", pSet - &g_artNtSdbSets[0]);
208 return false;
209 }
210
211 /*
212 * Do the CPU vendor test.
213 *
214 * Note! The MmIsAddressValid call is the real #PF security here as the
215 * __try/__except has limited/no ability to catch everything we need.
216 */
217 char *pszPrcbVendorString = (char *)&pbPrcb[pSet->KPRCB.offVendorString];
218 if (!MmIsAddressValid(&pszPrcbVendorString[4 * 3 - 1]))
219 {
220 //DbgPrint("IPRT: #%d invalid vendor string address.\n", pSet - &g_artNtSdbSets[0]);
221 return false;
222 }
223 __try
224 {
225 if (memcmp(pszPrcbVendorString, pszVendor, RT_MIN(4 * 3, pSet->KPRCB.cbVendorString)) != 0)
226 {
227 //DbgPrint("IPRT: #%d Vendor string mismatch.\n", pSet - &g_artNtSdbSets[0]);
228 return false;
229 }
230 }
231 __except(EXCEPTION_EXECUTE_HANDLER)
232 {
233 DbgPrint("IPRT: %#d Exception\n", pSet - &g_artNtSdbSets[0]);
234 return false;
235 }
236
237 /*
238 * Got a match, update the global variables and report succcess.
239 */
240 g_offrtNtPbQuantumEnd = pSet->KPRCB.offQuantumEnd;
241 g_cbrtNtPbQuantumEnd = pSet->KPRCB.cbQuantumEnd;
242 g_offrtNtPbDpcQueueDepth = pSet->KPRCB.offDpcQueueDepth;
243
244#if 0
245 DbgPrint("IPRT: Using data set #%u for %u.%usp%u build %u %s %s.\n",
246 pSet - &g_artNtSdbSets[0],
247 pSet->OsVerInfo.uMajorVer,
248 pSet->OsVerInfo.uMinorVer,
249 pSet->OsVerInfo.uCsdNo,
250 pSet->OsVerInfo.uBuildNo,
251 pSet->OsVerInfo.fSmp ? "smp" : "uni",
252 pSet->OsVerInfo.fChecked ? "checked" : "free");
253#endif
254 return true;
255}
256
257
258DECLHIDDEN(int) rtR0InitNative(void)
259{
260 /*
261 * Initialize the function pointers.
262 */
263 RTDBGKRNLINFO hKrnlInfo;
264 int rc = RTR0DbgKrnlInfoOpen(&hKrnlInfo, 0/*fFlags*/);
265 AssertRCReturn(rc, rc);
266
267#define GET_SYSTEM_ROUTINE_EX(a_Prf, a_Name, a_pfnType) \
268 do { RT_CONCAT3(g_pfnrt, a_Prf, a_Name) = (a_pfnType)RTR0DbgKrnlInfoGetSymbol(hKrnlInfo, NULL, #a_Name); } while (0)
269#define GET_SYSTEM_ROUTINE(a_Name) GET_SYSTEM_ROUTINE_EX(RT_NOTHING, a_Name, decltype(a_Name) *)
270#define GET_SYSTEM_ROUTINE_PRF(a_Prf,a_Name) GET_SYSTEM_ROUTINE_EX(a_Prf, a_Name, decltype(a_Name) *)
271#define GET_SYSTEM_ROUTINE_TYPE(a_Name, a_pfnType) GET_SYSTEM_ROUTINE_EX(RT_NOTHING, a_Name, a_pfnType)
272
273 GET_SYSTEM_ROUTINE_PRF(Nt,ExSetTimerResolution);
274 GET_SYSTEM_ROUTINE_PRF(Nt,KeFlushQueuedDpcs);
275 GET_SYSTEM_ROUTINE(KeIpiGenericCall);
276 GET_SYSTEM_ROUTINE(KeSetTargetProcessorDpcEx);
277 GET_SYSTEM_ROUTINE(KeInitializeAffinityEx);
278 GET_SYSTEM_ROUTINE(KeAddProcessorAffinityEx);
279 GET_SYSTEM_ROUTINE_TYPE(KeGetProcessorIndexFromNumber, PFNKEGETPROCESSORINDEXFROMNUMBER);
280 GET_SYSTEM_ROUTINE(KeGetProcessorNumberFromIndex);
281 GET_SYSTEM_ROUTINE_TYPE(KeGetCurrentProcessorNumberEx, PFNKEGETCURRENTPROCESSORNUMBEREX);
282 GET_SYSTEM_ROUTINE(KeQueryActiveProcessors);
283 GET_SYSTEM_ROUTINE(KeQueryMaximumProcessorCount);
284 GET_SYSTEM_ROUTINE(KeQueryMaximumProcessorCountEx);
285 GET_SYSTEM_ROUTINE(KeQueryMaximumGroupCount);
286 GET_SYSTEM_ROUTINE(KeQueryActiveProcessorCount);
287 GET_SYSTEM_ROUTINE(KeQueryActiveProcessorCountEx);
288 GET_SYSTEM_ROUTINE(KeQueryLogicalProcessorRelationship);
289 GET_SYSTEM_ROUTINE(KeRegisterProcessorChangeCallback);
290 GET_SYSTEM_ROUTINE(KeDeregisterProcessorChangeCallback);
291 GET_SYSTEM_ROUTINE(MmProtectMdlSystemAddress);
292 GET_SYSTEM_ROUTINE(MmAllocatePagesForMdl);
293 GET_SYSTEM_ROUTINE(MmFreePagesFromMdl);
294 GET_SYSTEM_ROUTINE(MmMapLockedPagesSpecifyCache);
295 GET_SYSTEM_ROUTINE(MmAllocateContiguousMemorySpecifyCache);
296
297 GET_SYSTEM_ROUTINE_TYPE(RtlGetVersion, PFNRTRTLGETVERSION);
298#ifndef RT_ARCH_AMD64
299 GET_SYSTEM_ROUTINE(KeQueryInterruptTime);
300 GET_SYSTEM_ROUTINE(KeQuerySystemTime);
301#endif
302 GET_SYSTEM_ROUTINE_TYPE(KeQueryInterruptTimePrecise, PFNRTKEQUERYINTERRUPTTIMEPRECISE);
303 GET_SYSTEM_ROUTINE_TYPE(KeQuerySystemTimePrecise, PFNRTKEQUERYSYSTEMTIMEPRECISE);
304
305 g_pfnrtHalRequestIpiW7Plus = (PFNHALREQUESTIPI_W7PLUS)RTR0DbgKrnlInfoGetSymbol(hKrnlInfo, NULL, "HalRequestIpi");
306 g_pfnrtHalRequestIpiPreW7 = (PFNHALREQUESTIPI_PRE_W7)g_pfnrtHalRequestIpiW7Plus;
307
308 g_puRtMmHighestUserAddress = (uintptr_t const *)RTR0DbgKrnlInfoGetSymbol(hKrnlInfo, NULL, "MmHighestUserAddress");
309 g_puRtMmSystemRangeStart = (uintptr_t const *)RTR0DbgKrnlInfoGetSymbol(hKrnlInfo, NULL, "MmSystemRangeStart");
310
311 RTR0DbgKrnlInfoRelease(hKrnlInfo);
312
313 /*
314 * HACK ALERT! (and déjà vu warning - remember win32k.sys?)
315 *
316 * Try find _KPRCB::QuantumEnd and _KPRCB::[DpcData.]DpcQueueDepth.
317 * For purpose of verification we use the VendorString member (12+1 chars).
318 *
319 * The offsets was initially derived by poking around with windbg
320 * (dt _KPRCB, !prcb ++, and such like). Systematic harvesting was then
321 * planned using dia2dump, grep and the symbol pack in a manner like this:
322 * dia2dump -type _KDPC_DATA -type _KPRCB EXE\ntkrnlmp.pdb | grep -wE "QuantumEnd|DpcData|DpcQueueDepth|VendorString"
323 *
324 * The final solution ended up using a custom harvester program called
325 * ntBldSymDb that recursively searches thru unpacked symbol packages for
326 * the desired structure offsets. The program assumes that the packages
327 * are unpacked into directories with the same name as the package, with
328 * exception of some of the w2k packages which requires a 'w2k' prefix to
329 * be distinguishable from another.
330 */
331
332 RTNTSDBOSVER OsVerInfo;
333 rtR0NtGetOsVersionInfo(&OsVerInfo);
334
335 /* Publish the version info in globals. */
336 g_uRtNtVersion = RTNT_MAKE_VERSION(OsVerInfo.uMajorVer, OsVerInfo.uMinorVer);
337 g_uRtNtMinorVer = OsVerInfo.uMinorVer;
338 g_uRtNtMajorVer = OsVerInfo.uMajorVer;
339 g_uRtNtBuildNo = OsVerInfo.uBuildNo;
340
341 /*
342 * Gather consistent CPU vendor string and PRCB pointers.
343 */
344 KIRQL OldIrql;
345 KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); /* make sure we stay on the same cpu */
346
347 union
348 {
349 uint32_t auRegs[4];
350 char szVendor[4*3+1];
351 } u;
352 ASMCpuId(0, &u.auRegs[3], &u.auRegs[0], &u.auRegs[2], &u.auRegs[1]);
353 u.szVendor[4*3] = '\0';
354
355 uint8_t *pbPrcb;
356 __try /* Warning. This try/except statement may provide some false safety. */
357 {
358#if defined(RT_ARCH_X86)
359 PKPCR pPcr = (PKPCR)__readfsdword(RT_OFFSETOF(KPCR,SelfPcr));
360 pbPrcb = (uint8_t *)pPcr->Prcb;
361#elif defined(RT_ARCH_AMD64)
362 PKPCR pPcr = (PKPCR)__readgsqword(RT_OFFSETOF(KPCR,Self));
363 pbPrcb = (uint8_t *)pPcr->CurrentPrcb;
364#else
365# error "port me"
366 pbPrcb = NULL;
367#endif
368 }
369 __except(EXCEPTION_EXECUTE_HANDLER)
370 {
371 pbPrcb = NULL;
372 }
373
374 /*
375 * Search the database
376 */
377 if (pbPrcb)
378 {
379 /* Find the best matching kernel version based on build number. */
380 uint32_t iBest = UINT32_MAX;
381 int32_t iBestDelta = INT32_MAX;
382 for (uint32_t i = 0; i < RT_ELEMENTS(g_artNtSdbSets); i++)
383 {
384 if (g_artNtSdbSets[i].OsVerInfo.fChecked != OsVerInfo.fChecked)
385 continue;
386 if (OsVerInfo.fSmp /*must-be-smp*/ && !g_artNtSdbSets[i].OsVerInfo.fSmp)
387 continue;
388
389 int32_t iDelta = RT_ABS((int32_t)OsVerInfo.uBuildNo - (int32_t)g_artNtSdbSets[i].OsVerInfo.uBuildNo);
390 if ( iDelta == 0
391 && (g_artNtSdbSets[i].OsVerInfo.uCsdNo == OsVerInfo.uCsdNo || OsVerInfo.uCsdNo == MY_NIL_CSD))
392 {
393 /* prefect */
394 iBestDelta = iDelta;
395 iBest = i;
396 break;
397 }
398 if ( iDelta < iBestDelta
399 || iBest == UINT32_MAX
400 || ( iDelta == iBestDelta
401 && OsVerInfo.uCsdNo != MY_NIL_CSD
402 && RT_ABS(g_artNtSdbSets[i ].OsVerInfo.uCsdNo - (int32_t)OsVerInfo.uCsdNo)
403 < RT_ABS(g_artNtSdbSets[iBest].OsVerInfo.uCsdNo - (int32_t)OsVerInfo.uCsdNo)
404 )
405 )
406 {
407 iBestDelta = iDelta;
408 iBest = i;
409 }
410 }
411 if (iBest < RT_ELEMENTS(g_artNtSdbSets))
412 {
413 /* Try all sets: iBest -> End; iBest -> Start. */
414 bool fDone = false;
415 int32_t i = iBest;
416 while ( i < RT_ELEMENTS(g_artNtSdbSets)
417 && !(fDone = rtR0NtTryMatchSymSet(&g_artNtSdbSets[i], pbPrcb, u.szVendor, &OsVerInfo)))
418 i++;
419 if (!fDone)
420 {
421 i = (int32_t)iBest - 1;
422 while ( i >= 0
423 && !(fDone = rtR0NtTryMatchSymSet(&g_artNtSdbSets[i], pbPrcb, u.szVendor, &OsVerInfo)))
424 i--;
425 }
426 }
427 else
428 DbgPrint("IPRT: Failed to locate data set.\n");
429 }
430 else
431 DbgPrint("IPRT: Failed to get PCBR pointer.\n");
432
433 KeLowerIrql(OldIrql); /* Lowering the IRQL early in the hope that we may catch exceptions below. */
434
435#ifndef IN_GUEST
436 if (!g_offrtNtPbQuantumEnd && !g_offrtNtPbDpcQueueDepth)
437 DbgPrint("IPRT: Neither _KPRCB::QuantumEnd nor _KPRCB::DpcQueueDepth was not found! Kernel %u.%u %u %s\n",
438 OsVerInfo.uMajorVer, OsVerInfo.uMinorVer, OsVerInfo.uBuildNo, OsVerInfo.fChecked ? "checked" : "free");
439# ifdef DEBUG
440 else
441 DbgPrint("IPRT: _KPRCB:{.QuantumEnd=%x/%d, .DpcQueueDepth=%x/%d} Kernel %u.%u %u %s\n",
442 g_offrtNtPbQuantumEnd, g_cbrtNtPbQuantumEnd, g_offrtNtPbDpcQueueDepth, g_offrtNtPbDpcQueueDepth,
443 OsVerInfo.uMajorVer, OsVerInfo.uMinorVer, OsVerInfo.uBuildNo, OsVerInfo.fChecked ? "checked" : "free");
444# endif
445#endif
446
447 /*
448 * Initialize multi processor stuff. This registers a callback, so
449 * we call rtR0TermNative to do the deregistration on failure.
450 */
451 rc = rtR0MpNtInit(&OsVerInfo);
452 if (RT_FAILURE(rc))
453 {
454 rtR0TermNative();
455 DbgPrint("IPRT: Fatal: rtR0MpNtInit failed: %d\n", rc);
456 return rc;
457 }
458
459 return VINF_SUCCESS;
460}
461
462
463DECLHIDDEN(void) rtR0TermNative(void)
464{
465 rtR0MpNtTerm();
466}
467
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