diff --git a/DerpingDrivers/DerpingDrivers.csproj b/DerpingDrivers/DerpingDrivers.csproj
index ebe53bc..c86e7bb 100644
--- a/DerpingDrivers/DerpingDrivers.csproj
+++ b/DerpingDrivers/DerpingDrivers.csproj
@@ -61,6 +61,12 @@
..\packages\Markdig.Wpf.0.2.5\lib\net452\Markdig.Wpf.dll
+
+ ..\packages\PInvoke.Kernel32.0.5.155\lib\net45\PInvoke.Kernel32.dll
+
+
+ ..\packages\PInvoke.Windows.Core.0.5.155\lib\net35\PInvoke.Windows.Core.dll
+
diff --git a/DerpingDrivers/MainWindow.xaml b/DerpingDrivers/MainWindow.xaml
index 52be0e8..6a65c5c 100644
--- a/DerpingDrivers/MainWindow.xaml
+++ b/DerpingDrivers/MainWindow.xaml
@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:DerpingDrivers"
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
mc:Ignorable="d"
- Title="Derping Drivers - Windows driver settings detection tool"
+ Title="Derping Drivers - Windows driver compatibility detection tool"
Height="400" Width="700"
ShowMaxRestoreButton="False"
ResizeMode="NoResize"
@@ -37,34 +37,41 @@
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
diff --git a/DerpingDrivers/MainWindow.xaml.cs b/DerpingDrivers/MainWindow.xaml.cs
index c6f1ae9..60ed4c7 100644
--- a/DerpingDrivers/MainWindow.xaml.cs
+++ b/DerpingDrivers/MainWindow.xaml.cs
@@ -7,6 +7,8 @@ using DerpingDrivers.Util;
using MahApps.Metro.Controls;
using Markdig;
using Markdig.Wpf;
+using Markdown = Markdig.Wpf.Markdown;
+using XamlReader = System.Windows.Markup.XamlReader;
namespace DerpingDrivers
{
@@ -54,7 +56,7 @@ namespace DerpingDrivers
public string OsUpgradeStatus =>
OsUpgradeDetection.IsGrandfathered ? "In-place upgraded" : "Clean installation";
- public string CodeIntegrityStatus => "";
+ public string CodeIntegrityStatus => CodeIntegrityHelper.IsSystemCodeIntegrityEnabled ? "Enabled" : "Disabled";
public string SummaryText =>
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
@@ -66,17 +68,14 @@ namespace DerpingDrivers
var markdown = "*None available*";
// Convert Markdown to XAML
- var xaml = Markdig.Wpf.Markdown.ToXaml(markdown, BuildPipeline());
+ var xaml = Markdown.ToXaml(markdown, BuildPipeline());
// Render XAML for FlowDocument Control
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xaml)))
{
var reader = new XamlXmlReader(stream, new MyXamlSchemaContext());
- if (System.Windows.Markup.XamlReader.Load(reader) is FlowDocument document)
- {
- return document;
- }
+ if (XamlReader.Load(reader) is FlowDocument document) return document;
}
return null;
@@ -97,9 +96,11 @@ namespace DerpingDrivers
{
if (xamlNamespace.Equals("clr-namespace:Markdig.Wpf"))
{
- compatibleNamespace = $"clr-namespace:Markdig.Wpf;assembly={Assembly.GetAssembly(typeof(Markdig.Wpf.Styles)).FullName}";
+ compatibleNamespace =
+ $"clr-namespace:Markdig.Wpf;assembly={Assembly.GetAssembly(typeof(Styles)).FullName}";
return true;
}
+
return base.TryGetCompatibleXamlNamespace(xamlNamespace, out compatibleNamespace);
}
}
diff --git a/DerpingDrivers/Util/CodeIntegrityHelper.cs b/DerpingDrivers/Util/CodeIntegrityHelper.cs
index d2f613e..7a62887 100644
--- a/DerpingDrivers/Util/CodeIntegrityHelper.cs
+++ b/DerpingDrivers/Util/CodeIntegrityHelper.cs
@@ -1,8 +1,62 @@
-namespace DerpingDrivers.Util
-{
+using PInvoke;
+using System;
+using System.Runtime.InteropServices;
+namespace DerpingDrivers.Util
+{
public static class CodeIntegrityHelper
{
-
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate Int32 NtQuerySystemInformation(
+ UInt32 SystemInformationClass,
+ IntPtr SystemInformation,
+ UInt32 SystemInformationLength,
+ out UInt32 ReturnLength);
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct SYSTEM_CODEINTEGRITY_INFORMATION
+ {
+ public UInt32 Length;
+ public UInt32 CodeIntegrityOptions;
+ };
+
+ public static bool IsSystemCodeIntegrityEnabled
+ {
+ get
+ {
+ var pIntegrity = Marshal.AllocHGlobal(Marshal.SizeOf());
+
+ try
+ {
+ var fptr = Kernel32.GetProcAddress(Kernel32.GetModuleHandle("ntdll.dll"),
+ "NtQuerySystemInformation");
+
+ var ntQuerySystemInformation =
+ Marshal.GetDelegateForFunctionPointer(fptr);
+
+ SYSTEM_CODEINTEGRITY_INFORMATION integrity;
+ integrity.Length = (uint)Marshal.SizeOf();
+ integrity.CodeIntegrityOptions = 0;
+
+
+ Marshal.StructureToPtr(integrity, pIntegrity, false);
+
+ var status = ntQuerySystemInformation(
+ 103,
+ pIntegrity,
+ integrity.Length,
+ out _
+ );
+
+ integrity = Marshal.PtrToStructure(pIntegrity);
+
+ return (status == 0) && ((integrity.CodeIntegrityOptions & 1) == 1);
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(pIntegrity);
+ }
+ }
+ }
}
}
\ No newline at end of file
diff --git a/DerpingDrivers/packages.config b/DerpingDrivers/packages.config
index ee2ba38..45e4f40 100644
--- a/DerpingDrivers/packages.config
+++ b/DerpingDrivers/packages.config
@@ -6,4 +6,6 @@
+
+
\ No newline at end of file