VirtualBox

Ignore:
Timestamp:
Aug 21, 2024 5:27:35 PM (5 months ago)
Author:
vboxsync
Message:

IPRT: Added RTSystemQueryNtFeatureEnabled() API to query Windows (NT) features + testcase. Also includes internal code for querying Windows registry values. bugref:10753

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/system-get-nt-xxx-win.cpp

    r98103 r105786  
    4343
    4444#include "internal-r3-win.h"
     45#include "internal-r3-registry-win.h"
    4546#include <iprt/system.h>
    4647#include <iprt/assert.h>
     48#include <iprt/err.h>
    4749
    4850
     
    6769}
    6870
     71
     72RTDECL(int) RTSystemQueryNtFeatureEnabled(RTSYSNTFEATURE enmFeature, bool *pfEnabled)
     73{
     74    AssertPtrReturn(pfEnabled, VERR_INVALID_POINTER);
     75
     76    int rc;
     77
     78    switch (enmFeature)
     79    {
     80        case RTSYSNTFEATURE_CORE_ISOLATION_MEMORY_INTEGRITY: /* aka Code Integrity */
     81        {
     82            DWORD dwEnabled;
     83            rc = RTSystemWinRegistryQueryDWORD(HKEY_LOCAL_MACHINE,
     84                                    "SYSTEM\\CurrentControlSet\\Control\\DeviceGuard\\Scenarios\\HypervisorEnforcedCodeIntegrity",
     85                                    "Enabled", &dwEnabled);
     86            if (RT_SUCCESS(rc))
     87                *pfEnabled = RT_BOOL(dwEnabled);
     88            else if (rc == VERR_FILE_NOT_FOUND)
     89                rc = VERR_NOT_SUPPORTED;
     90            break;
     91        }
     92
     93        default:
     94            rc = VERR_NOT_IMPLEMENTED;
     95            break;
     96    }
     97
     98    return rc;
     99}
     100
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