VirtualBox

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


Ignore:
Timestamp:
Jun 14, 2024 9:20:58 PM (11 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163532
Message:

IPRT/process-win.cpp: Resolve GetUserObjectSecurity and SetUserObjectSecurity dynamically to avoid trigger AV heuristics.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/process-win.cpp

    r103232 r104930  
    152152/* user32.dll: */
    153153static decltype(OpenWindowStationW)    *g_pfnOpenWindowStationW         = NULL;
    154 static decltype(CloseWindowStation)    *g_pfnCloseWindowStation        = NULL;
     154static decltype(CloseWindowStation)    *g_pfnCloseWindowStation         = NULL;
     155/* user32.dll: (for reasons of bad AV heuristics) */
     156static decltype(GetUserObjectSecurity) *g_pfnGetUserObjectSecurity     = NULL;
     157static decltype(SetUserObjectSecurity) *g_pfnSetUserObjectSecurity     = NULL;
    155158/* userenv.dll: */
    156159static PFNCREATEENVIRONMENTBLOCK        g_pfnCreateEnvironmentBlock     = NULL;
     
    377380        rc = RTLdrGetSymbol(hMod, "CloseWindowStation", (void **)&g_pfnCloseWindowStation);
    378381        if (RT_FAILURE(rc)) { g_pfnCloseWindowStation = NULL; Assert(g_enmWinVer <= kRTWinOSType_NT310); }
     382
     383        /* These are only imported to workaround bad AV detection heuristics. */
     384        rc = RTLdrGetSymbol(hMod, "GetUserObjectSecurity", (void **)&g_pfnGetUserObjectSecurity);
     385        AssertRC(rc);
     386
     387        rc = RTLdrGetSymbol(hMod, "SetUserObjectSecurity", (void **)&g_pfnSetUserObjectSecurity);
     388        AssertRC(rc);
    379389
    380390        RTLdrClose(hMod);
     
    9951005    DWORD                cbNeeded;
    9961006    AssertReturn(pSecDesc, false);
    997     if (!GetUserObjectSecurity(hUserObj, &SecInfo, pSecDesc, cbSecDesc, &cbNeeded))
     1007    AssertReturn(g_pfnGetUserObjectSecurity, false);
     1008    if (!g_pfnGetUserObjectSecurity(hUserObj, &SecInfo, pSecDesc, cbSecDesc, &cbNeeded))
    9981009    {
    9991010        RTMemTmpFree(pSecDesc);
     
    10021013        pSecDesc  = (PSECURITY_DESCRIPTOR)RTMemTmpAlloc(cbSecDesc);
    10031014        AssertReturn(pSecDesc, false);
    1004         if (!GetUserObjectSecurity(hUserObj, &SecInfo, pSecDesc, cbSecDesc, &cbNeeded))
     1015        if (!g_pfnGetUserObjectSecurity(hUserObj, &SecInfo, pSecDesc, cbSecDesc, &cbNeeded))
    10051016        {
    10061017            RTMemTmpFree(pSecDesc);
     
    11481159    DWORD                cbNeeded;
    11491160    AssertReturn(pSecDesc, NULL);
    1150     if (!GetUserObjectSecurity(hUserObj, &SecInfo, pSecDesc, cbSecDesc, &cbNeeded))
     1161    AssertReturn(g_pfnGetUserObjectSecurity, NULL);
     1162    if (!g_pfnGetUserObjectSecurity(hUserObj, &SecInfo, pSecDesc, cbSecDesc, &cbNeeded))
    11511163    {
    11521164        RTMemTmpFree(pSecDesc);
     
    11551167        pSecDesc  = (PSECURITY_DESCRIPTOR)RTMemTmpAlloc(cbSecDesc);
    11561168        AssertReturn(pSecDesc, NULL);
    1157         if (!GetUserObjectSecurity(hUserObj, &SecInfo, pSecDesc, cbSecDesc, &cbNeeded))
     1169        if (!g_pfnGetUserObjectSecurity(hUserObj, &SecInfo, pSecDesc, cbSecDesc, &cbNeeded))
    11581170        {
    11591171            RTMemTmpFree(pSecDesc);
     
    12681280{
    12691281    bool fRet = false;
     1282    AssertReturn(g_pfnSetUserObjectSecurity, fRet);
    12701283
    12711284    /*
     
    13061319                    {
    13071320                        SECURITY_INFORMATION SecInfo = DACL_SECURITY_INFORMATION;
    1308                         if (SetUserObjectSecurity(hWinStation, &SecInfo, pNewSecDesc))
     1321                        if (g_pfnSetUserObjectSecurity(hWinStation, &SecInfo, pNewSecDesc))
    13091322                            fRet = true;
    13101323                        else
     
    13401353{
    13411354    bool fRet = false;
     1355    AssertReturn(g_pfnSetUserObjectSecurity, fRet);
    13421356
    13431357    /*
     
    13761390                    {
    13771391                        SECURITY_INFORMATION SecInfo = DACL_SECURITY_INFORMATION;
    1378                         if (SetUserObjectSecurity(hDesktop, &SecInfo, pNewSecDesc))
     1392                        if (g_pfnSetUserObjectSecurity(hDesktop, &SecInfo, pNewSecDesc))
    13791393                            fRet = true;
    13801394                        else
Note: See TracChangeset for help on using the changeset viewer.

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