Ejemplo n.º 1
0
        private void RetrieveInfo()
        {
            WriteConsoleVerbose($"Retrieving {Name} info ...");

            var sysInfoLength = Marshal.SizeOf(typeof(VsmProtectionInfo));

            WriteConsoleDebug($"Size of {nameof(VsmProtectionInfo)} structure: {sysInfoLength} bytes");

            var ntStatus = NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS.SystemVsmProtectionInformation,
                                                    out var sysInfo,
                                                    (uint)sysInfoLength,
                                                    IntPtr.Zero);

            switch (ntStatus)
            {
            case 0:
                SystemInfo = sysInfo;
                return;

            // STATUS_INVALID_INFO_CLASS || STATUS_NOT_IMPLEMENTED
            case -1073741821:
            case -1073741822:
                throw new NotImplementedException($"System support for querying {Name} information not present.");
            }

            WriteConsoleVerbose($"Error requesting {Name} information: {ntStatus}");
            var symbolicNtStatus = GetSymbolicNtStatus(ntStatus);

            throw new Win32Exception(symbolicNtStatus);
        }
Ejemplo n.º 2
0
 private static extern int NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS systemInformationClass,
                                                    out VsmProtectionInfo systemInformation,
                                                    uint systemInformationLength,
                                                    IntPtr returnLength);