diff -r 763675f19ff4 -r 9bf70d316cea Hardware/KernelDriver.cs --- a/Hardware/KernelDriver.cs Sun Oct 31 22:08:47 2010 +0000 +++ b/Hardware/KernelDriver.cs Mon Nov 01 20:44:21 2010 +0000 @@ -36,7 +36,9 @@ */ using System; +using System.IO; using System.Runtime.InteropServices; +using System.Security.AccessControl; using Microsoft.Win32.SafeHandles; namespace OpenHardwareMonitor.Hardware { @@ -78,7 +80,16 @@ NativeMethods.CloseServiceHandle(service); NativeMethods.CloseServiceHandle(manager); - + + try { + // restrict the driver access to system (SY) and builtin admins (BA) + // TODO: replace with a call to IoCreateDeviceSecure in the driver + FileSecurity fileSecurity = File.GetAccessControl(@"\\.\" + id); + fileSecurity.SetSecurityDescriptorSddlForm( + "O:BAG:SYD:(A;;FA;;;SY)(A;;FA;;;BA)"); + File.SetAccessControl(@"\\.\" + id, fileSecurity); + } catch { } + return true; }