VirtualBox

Changeset 70149 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Dec 15, 2017 2:09:47 PM (7 years ago)
Author:
vboxsync
Message:

iprt/r0drv/nt: Use RTR0DbgKrnlInfoOpen and friends for resolving kernel APIs during initialization.

Location:
trunk/src/VBox/Runtime/r0drv/nt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/nt/dbgkrnlinfo-r0drv-nt.cpp

    r70136 r70149  
    11/* $Id$ */
    22/** @file
    3  * IPRT - Initialization & Termination, R0 Driver, NT.
     3 * IPRT - Kernel Debug Information, R0 Driver, NT.
    44 */
    55
     
    142142*   Global Variables                                                                                                             *
    143143*********************************************************************************************************************************/
    144 /** Pointer to MmGetSystemRoutineAddress. */
    145 #ifdef RT_ARCH_X86
     144/** Pointer to MmGetSystemRoutineAddress.
     145 * @note Added in NT v5.0. */
     146#ifdef IPRT_TARGET_NT4
    146147static decltype(MmGetSystemRoutineAddress) *g_pfnMmGetSystemRoutineAddress = NULL;
    147148#else
  • trunk/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp

    r69111 r70149  
    3131#include "the-nt-kernel.h"
    3232#include <iprt/asm-amd64-x86.h>
     33#include <iprt/dbg.h>
    3334#include <iprt/err.h>
    3435#include <iprt/string.h>
     
    8485/** KeDeregisterProcessorChangeCallback - Introducted in Windows 7. */
    8586PFNKEDEREGISTERPROCESSORCHANGECALLBACK  g_pfnrtKeDeregisterProcessorChangeCallback;
     87/** Pointer to the MmProtectMdlSystemAddress kernel function if it's available.
     88 * This API was introduced in XP. */
     89decltype(MmProtectMdlSystemAddress)    *g_pfnrtMmProtectMdlSystemAddress;
    8690/** RtlGetVersion, introduced in ??. */
    8791PFNRTRTLGETVERSION                      g_pfnrtRtlGetVersion;
     
    244248     * Initialize the function pointers.
    245249     */
    246 #ifdef IPRT_TARGET_NT4
    247 # define GET_SYSTEM_ROUTINE_EX(a_Prf, a_Name, a_pfnType) do { RT_CONCAT3(g_pfnrt, a_Prf, a_Name) = NULL; } while (0)
    248 #else
    249     UNICODE_STRING RoutineName;
    250 # define GET_SYSTEM_ROUTINE_EX(a_Prf, a_Name, a_pfnType) \
    251     do { \
    252         RtlInitUnicodeString(&RoutineName, L#a_Name); \
    253         RT_CONCAT3(g_pfnrt, a_Prf, a_Name) = (a_pfnType)MmGetSystemRoutineAddress(&RoutineName); \
    254     } while (0)
    255 #endif
     250    RTDBGKRNLINFO hKrnlInfo;
     251    int rc = RTR0DbgKrnlInfoOpen(&hKrnlInfo, 0/*fFlags*/);
     252    AssertRCReturn(rc, rc);
     253
     254#define GET_SYSTEM_ROUTINE_EX(a_Prf, a_Name, a_pfnType) \
     255    do { RT_CONCAT3(g_pfnrt, a_Prf, a_Name) = (a_pfnType)RTR0DbgKrnlInfoGetSymbol(hKrnlInfo, NULL, #a_Name); } while (0)
    256256#define GET_SYSTEM_ROUTINE(a_Name)                 GET_SYSTEM_ROUTINE_EX(RT_NOTHING, a_Name, decltype(a_Name) *)
    257257#define GET_SYSTEM_ROUTINE_PRF(a_Prf,a_Name)       GET_SYSTEM_ROUTINE_EX(a_Prf, a_Name, decltype(a_Name) *)
     
    276276    GET_SYSTEM_ROUTINE(KeRegisterProcessorChangeCallback);
    277277    GET_SYSTEM_ROUTINE(KeDeregisterProcessorChangeCallback);
     278    GET_SYSTEM_ROUTINE(MmProtectMdlSystemAddress);
    278279
    279280    GET_SYSTEM_ROUTINE_TYPE(RtlGetVersion, PFNRTRTLGETVERSION);
     
    285286    GET_SYSTEM_ROUTINE_TYPE(KeQuerySystemTimePrecise, PFNRTKEQUERYSYSTEMTIMEPRECISE);
    286287
    287 #ifdef IPRT_TARGET_NT4
    288     g_pfnrtHalRequestIpiW7Plus = NULL;
    289     g_pfnrtHalRequestIpiPreW7 = NULL;
    290 #else
    291     RtlInitUnicodeString(&RoutineName, L"HalRequestIpi");
    292     g_pfnrtHalRequestIpiW7Plus = (PFNHALREQUESTIPI_W7PLUS)MmGetSystemRoutineAddress(&RoutineName);
     288    g_pfnrtHalRequestIpiW7Plus = (PFNHALREQUESTIPI_W7PLUS)RTR0DbgKrnlInfoGetSymbol(hKrnlInfo, NULL, "HalRequestIpi");
    293289    g_pfnrtHalRequestIpiPreW7 = (PFNHALREQUESTIPI_PRE_W7)g_pfnrtHalRequestIpiW7Plus;
    294 #endif
     290
     291    RTR0DbgKrnlInfoRelease(hKrnlInfo);
    295292
    296293    /*
     
    432429     * we call rtR0TermNative to do the deregistration on failure.
    433430     */
    434     int rc = rtR0MpNtInit(&OsVerInfo);
     431    rc = rtR0MpNtInit(&OsVerInfo);
    435432    if (RT_FAILURE(rc))
    436433    {
Note: See TracChangeset for help on using the changeset viewer.

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