Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
giveio.c File Reference
#include <ntddk.h>
+ Include dependency graph for giveio.c:

Go to the source code of this file.

Macros

#define DEVICE_NAME_STRING   L"giveio"
 
#define IOPM_SIZE   0x2000
 

Typedefs

typedef UCHAR IOPM[IOPM_SIZE]
 

Functions

void Ke386SetIoAccessMap (int, IOPM *)
 
void Ke386QueryIoAccessMap (int, IOPM *)
 
void Ke386IoSetAccessProcess (PEPROCESS, int)
 
VOID GiveioUnload (IN PDRIVER_OBJECT DriverObject)
 
VOID SetIOPermissionMap (int OnFlag)
 
void GiveIO (void)
 
NTSTATUS GiveioCreateDispatch (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 

Variables

IOPMIOPM_local = 0
 

Macro Definition Documentation

◆ DEVICE_NAME_STRING

#define DEVICE_NAME_STRING   L"giveio"

◆ IOPM_SIZE

#define IOPM_SIZE   0x2000

Typedef Documentation

◆ IOPM

typedef UCHAR IOPM[IOPM_SIZE]

Function Documentation

◆ DriverEntry()

NTSTATUS DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath 
)
126{
127 PDEVICE_OBJECT deviceObject;
128 NTSTATUS status;
129 WCHAR NameBuffer[] = L"\\Device\\" DEVICE_NAME_STRING;
130 WCHAR DOSNameBuffer[] = L"\\DosDevices\\" DEVICE_NAME_STRING;
131 UNICODE_STRING uniNameString, uniDOSString;
132
133 //
134 // Allocate a buffer for the local IOPM and zero it.
135 //
136 IOPM_local = MmAllocateNonCachedMemory(sizeof(IOPM));
137 if(IOPM_local == 0)
138 return STATUS_INSUFFICIENT_RESOURCES;
139 RtlZeroMemory(IOPM_local, sizeof(IOPM));
140
141 //
142 // Set up device driver name and device object.
143 //
144 RtlInitUnicodeString(&uniNameString, NameBuffer);
145 RtlInitUnicodeString(&uniDOSString, DOSNameBuffer);
146
147 status = IoCreateDevice(DriverObject, 0,
148 &uniNameString,
149 FILE_DEVICE_UNKNOWN,
150 0, FALSE, &deviceObject);
151
152 if(!NT_SUCCESS(status))
153 return status;
154
155 status = IoCreateSymbolicLink (&uniDOSString, &uniNameString);
156
157 if (!NT_SUCCESS(status))
158 return status;
159
160 //
161 // Initialize the Driver Object with driver's entry points.
162 // All we require are the Create and Unload operations.
163 //
164 DriverObject->MajorFunction[IRP_MJ_CREATE] = GiveioCreateDispatch;
165 DriverObject->DriverUnload = GiveioUnload;
166 return STATUS_SUCCESS;
167}
UCHAR IOPM[IOPM_SIZE]
Definition giveio.c:28
NTSTATUS GiveioCreateDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition giveio.c:98
#define DEVICE_NAME_STRING
Definition giveio.c:16
IOPM * IOPM_local
Definition giveio.c:35
VOID GiveioUnload(IN PDRIVER_OBJECT DriverObject)
Definition giveio.c:55
#define FALSE
Definition mesh.c:45
#define L(s)
Definition I18N.hpp:18
LONG NTSTATUS
Definition hid.c:26

References DEVICE_NAME_STRING, FALSE, GiveioCreateDispatch(), GiveioUnload(), IOPM_local, and L.

+ Here is the call graph for this function:

◆ GiveIO()

void GiveIO ( void  )
81{
83}
VOID SetIOPermissionMap(int OnFlag)
Definition giveio.c:74

References SetIOPermissionMap().

Referenced by GiveioCreateDispatch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GiveioCreateDispatch()

NTSTATUS GiveioCreateDispatch ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
102{
103 GiveIO(); // give the calling process I/O access
104
105 Irp->IoStatus.Information = 0;
106 Irp->IoStatus.Status = STATUS_SUCCESS;
107 IoCompleteRequest(Irp, IO_NO_INCREMENT);
108 return STATUS_SUCCESS;
109}
void GiveIO(void)
Definition giveio.c:80

References GiveIO().

Referenced by DriverEntry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GiveioUnload()

VOID GiveioUnload ( IN PDRIVER_OBJECT  DriverObject)
56{
57 WCHAR DOSNameBuffer[] = L"\\DosDevices\\" DEVICE_NAME_STRING;
58 UNICODE_STRING uniDOSString;
59
60 if(IOPM_local)
61 MmFreeNonCachedMemory(IOPM_local, sizeof(IOPM));
62
63 RtlInitUnicodeString(&uniDOSString, DOSNameBuffer);
64 IoDeleteSymbolicLink (&uniDOSString);
65 IoDeleteDevice(DriverObject->DeviceObject);
66}

References DEVICE_NAME_STRING, IOPM_local, and L.

Referenced by DriverEntry().

+ Here is the caller graph for this function:

◆ Ke386IoSetAccessProcess()

void Ke386IoSetAccessProcess ( PEPROCESS  ,
int   
)

Referenced by SetIOPermissionMap().

+ Here is the caller graph for this function:

◆ Ke386QueryIoAccessMap()

void Ke386QueryIoAccessMap ( int  ,
IOPM  
)

◆ Ke386SetIoAccessMap()

void Ke386SetIoAccessMap ( int  ,
IOPM  
)

Referenced by SetIOPermissionMap().

+ Here is the caller graph for this function:

◆ SetIOPermissionMap()

VOID SetIOPermissionMap ( int  OnFlag)
75{
76 Ke386IoSetAccessProcess(PsGetCurrentProcess(), OnFlag);
78}
void Ke386IoSetAccessProcess(PEPROCESS, int)
void Ke386SetIoAccessMap(int, IOPM *)

References IOPM_local, Ke386IoSetAccessProcess(), and Ke386SetIoAccessMap().

Referenced by GiveIO().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ IOPM_local

IOPM* IOPM_local = 0