VirtualBox

Changeset 45444 in vbox for trunk


Ignore:
Timestamp:
Apr 9, 2013 7:08:17 PM (12 years ago)
Author:
vboxsync
Message:

IPRT: Use MmIsAddressValid since the try/except stuff doesn't really work for everything (/anything useful).

File:
1 edited

Legend:

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

    r45443 r45444  
    141141    /*
    142142     * Do the CPU vendor test.
    143      */
     143     *
     144     * Note! The MmIsAddressValid call is the real #PF security here as the
     145     *       __try/__except has limited/no ability to catch everything we need.
     146     */
     147    char *pszPrcbVendorString = (char *)&pbPrcb[pSet->KPRCB.offVendorString];
     148    if (!MmIsAddressValid(&pszPrcbVendorString[4 * 3 - 1]))
     149    {
     150        DbgPrint("IPRT: #%d invalid vendor string address.\n", pSet - &g_artNtSdbSets[0]);
     151        return false;
     152    }
    144153    __try
    145154    {
    146         if (memcmp(&pbPrcb[pSet->KPRCB.offVendorString], pszVendor,
    147                    RT_MIN(4 * 3, pSet->KPRCB.cbVendorString)) != 0)
     155        if (memcmp(pszPrcbVendorString, pszVendor, RT_MIN(4 * 3, pSet->KPRCB.cbVendorString)) != 0)
    148156        {
    149             //DbgPrint("IPRT: #%d Vendor string mismatch.\n");
     157            DbgPrint("IPRT: #%d Vendor string mismatch.\n", pSet - &g_artNtSdbSets[0]);
    150158            return false;
    151159        }
    152160    }
    153     __except(EXCEPTION_EXECUTE_HANDLER) /** @todo this handler doesn't seem to work... Because of Irql? */
    154     {
    155         //DbgPrint("IPRT: Exception\n");
     161    __except(EXCEPTION_EXECUTE_HANDLER)
     162    {
     163        DbgPrint("IPRT: %#d Exception\n", pSet - &g_artNtSdbSets[0]);
    156164        return false;
    157165    }
     
    224232
    225233    /*
    226      * HACK ALERT (and déjà vu warning)!
     234     * HACK ALERT! (and déjà vu warning - remember win32k.sys?)
    227235     *
    228236     * Try find _KPRCB::QuantumEnd and _KPRCB::[DpcData.]DpcQueueDepth.
     
    230238     *
    231239     * The offsets was initially derived by poking around with windbg
    232      * (dt _KPRCB, !prcb ++, and such like). Systematic harvesting is now done
    233      * by means of dia2dump, grep and the symbol packs. Typically:
     240     * (dt _KPRCB, !prcb ++, and such like). Systematic harvesting was then
     241     * planned using dia2dump, grep and the symbol pack in a manner like this:
    234242     *      dia2dump -type _KDPC_DATA -type _KPRCB EXE\ntkrnlmp.pdb | grep -wE "QuantumEnd|DpcData|DpcQueueDepth|VendorString"
     243     *
     244     * The final solution ended up using a custom harvester program called
     245     * ntBldSymDb that recursively searches thru unpacked symbol packages for
     246     * the desired structure offsets.  The program assumes that the packages
     247     * are unpacked into directories with the same name as the package, with
     248     * exception of some of the w2k packages which requires a 'w2k' prefix to
     249     * be distinguishable from another.
    235250     */
    236251
     
    253268
    254269    uint8_t *pbPrcb;
    255     __try
     270    __try /* Warning. This try/except statement may provide some false safety. */
    256271    {
    257272#if defined(RT_ARCH_X86)
     
    266281#endif
    267282    }
    268     __except(EXCEPTION_EXECUTE_HANDLER) /** @todo this handler doesn't seem to work... Because of Irql? */
     283    __except(EXCEPTION_EXECUTE_HANDLER)
    269284    {
    270285        pbPrcb = NULL;
    271286    }
    272 
    273     KeLowerIrql(OldIrql); /* Lowering the IRQL early in the hope that we may catch exceptions below. */
    274287
    275288    /*
     
    310323            }
    311324        }
    312         iBest = RT_ELEMENTS(g_artNtSdbSets)-1;
    313325        if (iBest < RT_ELEMENTS(g_artNtSdbSets))
    314326        {
     
    333345        DbgPrint("IPRT: Failed to get PCBR pointer.\n");
    334346
     347    KeLowerIrql(OldIrql); /* Lowering the IRQL early in the hope that we may catch exceptions below. */
     348
    335349#ifndef IN_GUEST
    336350    if (!g_offrtNtPbQuantumEnd && !g_offrtNtPbDpcQueueDepth)
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