mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-29 13:28:04 +00:00
Restricted the access to the kernel driver to system and built-in administrators.
This commit is contained in:
parent
f238f35eff
commit
0e435cafc6
@ -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 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user