Skip to content

Commit

Permalink
Merge pull request #1 from drvexplorer/io-create-device-secure
Browse files Browse the repository at this point in the history
Use IoCreateDeviceSecure(); Change .inf file
  • Loading branch information
drvexplorer authored Jul 27, 2023
2 parents 1ceda0c + 9b8a780 commit 3766455
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion WinRing0Sys/OpenLibSys.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//-----------------------------------------------------------------------------

#include "OpenLibSys.h"
#include <wdmsec.h>

static ULONG refCount;

Expand All @@ -24,13 +25,15 @@ NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING Registry

RtlInitUnicodeString(&ntDeviceName, NT_DEVICE_NAME);

NTSTATUS status = IoCreateDevice(
NTSTATUS status = IoCreateDeviceSecure(
DriverObject, // Our Driver Object
0, // We don't use a device extension
&ntDeviceName, // Device name
OLS_TYPE, // Device type
FILE_DEVICE_SECURE_OPEN, // Device characteristics
FALSE, // Not an exclusive device
&SDDL_DEVOBJ_SYS_ALL_ADM_ALL,
NULL,
&deviceObject); // Returned ptr to Device Object

if (!NT_SUCCESS(status))
Expand Down
4 changes: 2 additions & 2 deletions WinRing0Sys/WinRing0Sys.inf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ WinRing0Sys_Device_CoInstaller_CopyFiles = 11
1 = %DiskName%,,,""

[SourceDisksFiles]
WinRing0Sys.sys = 1,,
WinRing0x64.sys = 1,,
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1 ; make sure the number matches with SourceDisksNames

;*****************************************
Expand All @@ -36,7 +36,7 @@ WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1 ; make sure the number matches with
CopyFiles=Drivers_Dir

[Drivers_Dir]
WinRing0Sys.sys
WinRing0x64.sys

;-------------- Service installation
[WinRing0Sys_Device.NT.Services]
Expand Down
6 changes: 6 additions & 0 deletions WinRing0Sys/WinRing0Sys.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
<ClCompile>
<TreatWarningAsError>false</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>Wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<DriverSign>
Expand All @@ -71,6 +74,9 @@
<ClCompile>
<TreatWarningAsError>false</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>Wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Inf Include="WinRing0Sys.inf" />
Expand Down

0 comments on commit 3766455

Please sign in to comment.