VirtualBox

Ignore:
Timestamp:
Mar 21, 2019 12:01:49 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129490
Message:

SupHardNt: Made RTNtPathExpand8dot3Path() work correctly in kernel context (needs IPRT_NT_MAP_TO_ZW) and expand 8.3 names when comparing the executable image we found in the memory map with what NT returns for the process.

Location:
trunk/src/VBox/HostDrivers/Support/win
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp

    r76785 r77816  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
    31 #define IPRT_NT_MAP_TO_ZW
     31#ifndef IPRT_NT_MAP_TO_ZW
     32# define IPRT_NT_MAP_TO_ZW
     33#endif
    3234#define LOG_GROUP LOG_GROUP_SUP_DRV
    3335#include "../SUPDrvInternal.h"
  • trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp

    r76553 r77816  
    3030*********************************************************************************************************************************/
    3131#ifdef IN_RING0
    32 # define IPRT_NT_MAP_TO_ZW
     32# ifndef IPRT_NT_MAP_TO_ZW
     33#  define IPRT_NT_MAP_TO_ZW
     34# endif
    3335# include <iprt/nt/nt.h>
    3436# include <ntimage.h>
  • trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp

    r76818 r77816  
    3030*********************************************************************************************************************************/
    3131#ifdef IN_RING0
    32 # define IPRT_NT_MAP_TO_ZW
     32# ifndef IPRT_NT_MAP_TO_ZW
     33#  define IPRT_NT_MAP_TO_ZW
     34# endif
    3335# include <iprt/nt/nt.h>
    3436# include <ntimage.h>
     
    11661168            return true;
    11671169    }
     1170}
     1171
     1172
     1173/**
     1174 * Compares two paths, expanding 8.3 short names as needed.
     1175 *
     1176 * @returns true / false.
     1177 * @param   pUniStr1        The first path.  Must be zero terminated!
     1178 * @param   pUniStr2        The second path.  Must be zero terminated!
     1179 */
     1180static bool supHardNtVpArePathsEqual(PCUNICODE_STRING pUniStr1, PCUNICODE_STRING pUniStr2)
     1181{
     1182    /* Both strings must be null terminated. */
     1183    Assert(pUniStr1->Buffer[pUniStr1->Length / sizeof(WCHAR)] == '\0');
     1184    Assert(pUniStr2->Buffer[pUniStr1->Length / sizeof(WCHAR)] == '\0');
     1185
     1186    /* Simple compare first.*/
     1187    if (supHardNtVpAreUniStringsEqual(pUniStr1, pUniStr2))
     1188        return true;
     1189
     1190    /* Make long names if needed. */
     1191    UNICODE_STRING UniStrLong1 = { 0, 0, NULL };
     1192    if (RTNtPathFindPossible8dot3Name(pUniStr1->Buffer))
     1193    {
     1194        int rc = RTNtPathExpand8dot3PathA(pUniStr1, false /*fPathOnly*/, &UniStrLong1);
     1195        if (RT_SUCCESS(rc))
     1196            pUniStr1 = &UniStrLong1;
     1197    }
     1198
     1199    UNICODE_STRING UniStrLong2 = { 0, 0, NULL };
     1200    if (RTNtPathFindPossible8dot3Name(pUniStr2->Buffer))
     1201    {
     1202        int rc = RTNtPathExpand8dot3PathA(pUniStr2, false /*fPathOnly*/, &UniStrLong2);
     1203        if (RT_SUCCESS(rc))
     1204            pUniStr2 = &UniStrLong2;
     1205    }
     1206
     1207    /* Compare again. */
     1208    bool fCompare = supHardNtVpAreUniStringsEqual(pUniStr1, pUniStr2);
     1209
     1210    /* Clean up. */
     1211    if (UniStrLong1.Buffer)
     1212        RTUtf16Free(UniStrLong1.Buffer);
     1213    if (UniStrLong2.Buffer)
     1214        RTUtf16Free(UniStrLong2.Buffer);
     1215
     1216    return fCompare;
    11681217}
    11691218
     
    22642313    if (NT_SUCCESS(rcNt))
    22652314    {
    2266         if (supHardNtVpAreUniStringsEqual(pUniStr, &pImage->Name.UniStr))
     2315        pUniStr->Buffer[pUniStr->Length / sizeof(WCHAR)] = '\0';
     2316        if (supHardNtVpArePathsEqual(pUniStr, &pImage->Name.UniStr))
    22672317            rc = VINF_SUCCESS;
    22682318        else
    2269         {
    2270             pUniStr->Buffer[pUniStr->Length / sizeof(WCHAR)] = '\0';
    22712319            rc = supHardNtVpSetInfo2(pThis, VERR_SUP_VP_EXE_VS_PROC_NAME_MISMATCH,
    22722320                                     "Process image name does not match the exectuable we found: %ls vs %ls.",
    22732321                                     pUniStr->Buffer, pImage->Name.UniStr.Buffer);
    2274         }
    22752322    }
    22762323    else
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