OpenCBM
Functions
nt4/LoadUnload.c File Reference

Load and unload the driver. More...

#include <ntddk.h>
#include "cbm_driver.h"
#include "cbmioctl.h"

Go to the source code of this file.

Functions

NTSTATUS AddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PdoUNUSED, IN PCWSTR ParallelPortName)
 create functional device object (FDO) for enumerated device More...
 
VOID DriverUnload (IN PDRIVER_OBJECT DriverObject)
 Unload routine of the driver. More...
 
NTSTATUS DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 Start routine of the driver. More...
 

Detailed Description

Load and unload the driver.



Author
Spiro Trikaliotis

Definition in file nt4/LoadUnload.c.

Function Documentation

NTSTATUS AddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  PdoUNUSED,
IN PCWSTR  ParallelPortName 
)

create functional device object (FDO) for enumerated device

AddDevice is responsible for creating functional device objects (FDO) or filter device objects (filter DO) for devices enumerated by the Plug and Play (PnP) Manager.

Parameters
DriverObjectPointer to a DRIVER_OBJECT structure. This is the driver's driver object.
PdoUNUSEDPointer to a DEVICE_OBJECT structure representing a physical device object (PDO) created by a lower-level driver.
Todo:
Parameter is currently unused
Parameters
ParallelPortNamePointer to the name of the parallel port to attach to
Todo:
Will be removed for WDM
Returns
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values.

A driver's AddDevice routine executes in a system thread context at IRQL PASSIVE_LEVEL.

As long as we are an NT4 style device driver, AddDevice is not automatically called by the system as we don't have an INF file. Thus, it is called from our DriverEntry by ourself.

Todo:
Remove this

Definition at line 55 of file nt4/LoadUnload.c.

References AddDeviceCommonInit(), DBG_ERROR, DBG_PREFIX, DebugNtStatus(), FUNC_ENTER, LogErrorString, and MTAG_DEVNAME.

Referenced by DriverEntry().

NTSTATUS DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath 
)

Start routine of the driver.

DriverEntry is the first routine called after a driver is loaded, and it is responsible for initializing the driver.

Parameters
DriverObjectCaller-supplied pointer to a DRIVER_OBJECT structure. This is the driver's driver object.
RegistryPathPointer to a counted Unicode string specifying the path to the driver's registry key.
Returns
If the routine succeeds, it must return STATUS_SUCCESS. Otherwise, it must return one of the error status values defined in ntstatus.h.

The DriverObject parameter supplies the DriverEntry routine with a pointer to the driver's driver object, which is allocated by the I/O Manager. The DriverEntry routine must fill in the driver object with entry points for the driver's standard routines.

Definition at line 271 of file nt4/LoadUnload.c.

References AddDevice(), DBG_PREFIX, DBG_PRINT, DBG_SUCCESS, DbgAllocateMemoryBuffer(), DriverCommonInit(), FUNC_ENTER, ParPortEnumerate(), ParPortEnumerateClose(), and ParPortEnumerateOpen().

VOID DriverUnload ( IN PDRIVER_OBJECT  DriverObject)

Unload routine of the driver.

DriverUnload performs any operations that are necessary before the system unloads the driver.

Parameters
DriverObjectCaller-supplied pointer to a DRIVER_OBJECT structure. This is the driver's driver object.

A driver's Unload routine executes in a system thread context at IRQL PASSIVE_LEVEL. The driver's DriverEntry routine must store the Unload routine's address in DriverObject->DriverUnload. (If no routine is supplied, this pointer must be NULL.)

Definition at line 178 of file nt4/LoadUnload.c.

References cbm_stop_thread(), cbm_unlock_parport(), DBG_ASSERT, DbgFreeMemoryBuffer(), DriverCommonUninit(), FUNC_ENTER, FUNC_LEAVE, and ParPortDeinit().