mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Simplified driver initialization
svn path=/trunk/; revision=1221
This commit is contained in:
parent
73437d2939
commit
add4b2d35b
3 changed files with 45 additions and 57 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: beep.c,v 1.4 1999/10/16 12:41:42 ekohl Exp $
|
||||
/* $Id: beep.c,v 1.5 2000/07/02 10:54:12 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -227,7 +227,8 @@ NTSTATUS BeepUnload(PDRIVER_OBJECT DriverObject)
|
|||
}
|
||||
|
||||
|
||||
STDCALL NTSTATUS
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||
/*
|
||||
* FUNCTION: Called by the system to initalize the driver
|
||||
|
@ -237,35 +238,14 @@ DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
|||
* RETURNS: Success or failure
|
||||
*/
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
PDEVICE_EXTENSION DeviceExtension;
|
||||
NTSTATUS ret;
|
||||
ANSI_STRING ansi_device_name;
|
||||
UNICODE_STRING device_name;
|
||||
ANSI_STRING asymlink_name;
|
||||
UNICODE_STRING symlink_name;
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
UNICODE_STRING DeviceName;
|
||||
UNICODE_STRING SymlinkName;
|
||||
NTSTATUS Status;
|
||||
|
||||
DbgPrint ("Beep Device Driver 0.0.2\n");
|
||||
|
||||
RtlInitAnsiString (&ansi_device_name, "\\Device\\Beep");
|
||||
RtlAnsiStringToUnicodeString (&device_name, &ansi_device_name, TRUE);
|
||||
ret = IoCreateDevice (DriverObject,
|
||||
sizeof(DEVICE_EXTENSION),
|
||||
&device_name,
|
||||
FILE_DEVICE_BEEP,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
if (ret!=STATUS_SUCCESS)
|
||||
{
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* prelininary */
|
||||
RtlInitAnsiString (&asymlink_name, "\\??\\Beep");
|
||||
RtlAnsiStringToUnicodeString (&symlink_name, &asymlink_name, TRUE);
|
||||
IoCreateSymbolicLink (&symlink_name, &device_name);
|
||||
|
||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = BeepCreate;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = BeepClose;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = BeepCleanup;
|
||||
|
@ -284,6 +264,20 @@ DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
|||
SynchronizationEvent,
|
||||
FALSE);
|
||||
|
||||
RtlInitUnicodeString (&DeviceName, L"\\Device\\Beep");
|
||||
Status = IoCreateDevice (DriverObject,
|
||||
sizeof(DEVICE_EXTENSION),
|
||||
&DeviceName,
|
||||
FILE_DEVICE_BEEP,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
if (NT_SUCCESS(Status))
|
||||
return Status;
|
||||
|
||||
RtlInitUnicodeString (&SymlinkName, L"\\??\\Beep");
|
||||
IoCreateSymbolicLink (&SymlinkName, &DeviceName);
|
||||
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: blue.c,v 1.24 2000/06/29 23:35:47 dwelch Exp $
|
||||
/* $Id: blue.c,v 1.25 2000/07/02 10:54:23 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -599,14 +599,13 @@ ScrDispatch (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
/*
|
||||
* Module entry point
|
||||
*/
|
||||
NTSTATUS STDCALL
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
ANSI_STRING adevice_name;
|
||||
UNICODE_STRING device_name;
|
||||
ANSI_STRING asymlink_name;
|
||||
UNICODE_STRING symlink_name;
|
||||
UNICODE_STRING DeviceName;
|
||||
UNICODE_STRING SymlinkName;
|
||||
|
||||
DbgPrint ("Screen Driver 0.0.6\n");
|
||||
|
||||
|
@ -616,22 +615,17 @@ DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
|||
DriverObject->MajorFunction[IRP_MJ_WRITE] = ScrWrite;
|
||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL ] = ScrIoControl;
|
||||
|
||||
RtlInitAnsiString (&adevice_name, "\\Device\\BlueScreen");
|
||||
RtlAnsiStringToUnicodeString (&device_name, &adevice_name, TRUE);
|
||||
RtlInitUnicodeString (&DeviceName, L"\\Device\\BlueScreen");
|
||||
IoCreateDevice (DriverObject,
|
||||
sizeof(DEVICE_EXTENSION),
|
||||
&device_name,
|
||||
&DeviceName,
|
||||
FILE_DEVICE_SCREEN,
|
||||
0,
|
||||
TRUE,
|
||||
&DeviceObject);
|
||||
|
||||
RtlInitAnsiString (&asymlink_name, "\\??\\BlueScreen");
|
||||
RtlAnsiStringToUnicodeString (&symlink_name, &asymlink_name, TRUE);
|
||||
IoCreateSymbolicLink (&symlink_name, &device_name);
|
||||
|
||||
RtlFreeUnicodeString (&device_name);
|
||||
RtlFreeUnicodeString (&symlink_name);
|
||||
RtlInitUnicodeString (&SymlinkName, L"\\??\\BlueScreen");
|
||||
IoCreateSymbolicLink (&SymlinkName, &DeviceName);
|
||||
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: null.c,v 1.3 1999/12/04 20:58:39 ea Exp $
|
||||
/* $Id: null.c,v 1.4 2000/07/02 10:54:41 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -68,7 +68,8 @@ NTSTATUS NullUnload(PDRIVER_OBJECT DriverObject)
|
|||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||
/*
|
||||
* FUNCTION: Called by the system to initalize the driver
|
||||
|
@ -79,21 +80,11 @@ DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
|||
*/
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
NTSTATUS ret;
|
||||
ANSI_STRING ansi_device_name;
|
||||
UNICODE_STRING device_name;
|
||||
UNICODE_STRING DeviceName;
|
||||
NTSTATUS Status;
|
||||
|
||||
DbgPrint("Null Device Driver 0.0.2\n");
|
||||
|
||||
RtlInitAnsiString(&ansi_device_name,"\\Device\\NUL");
|
||||
RtlAnsiStringToUnicodeString(&device_name,&ansi_device_name,TRUE);
|
||||
ret = IoCreateDevice(DriverObject,0,&device_name,
|
||||
FILE_DEVICE_NULL,0,FALSE,&DeviceObject);
|
||||
if (ret!=STATUS_SUCCESS)
|
||||
{
|
||||
return(ret);
|
||||
}
|
||||
|
||||
DeviceObject->Flags=0;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = NullDispatch;
|
||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = NullDispatch;
|
||||
|
@ -101,6 +92,15 @@ DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
|||
DriverObject->MajorFunction[IRP_MJ_READ] = NullDispatch;
|
||||
DriverObject->DriverUnload = NullUnload;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
RtlInitUnicodeString(&DeviceName,
|
||||
L"\\Device\\Null");
|
||||
Status = IoCreateDevice(DriverObject,
|
||||
0,
|
||||
&DeviceName,
|
||||
FILE_DEVICE_NULL,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue