windows-nt/Source/XPSP1/NT/printscan/wia/kernel/serscan/open.c
2020-09-26 16:20:57 +08:00

164 lines
3.1 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*++
Copyright (c) 1998 Microsoft Corporation
Module Name:
serscan.c
Abstract:
This module contains the code for a serial imaging devices driver
Open and Create routines
Author:
Vlad Sadovsky vlads 10-April-1998
Environment:
Kernel mode
Revision History :
vlads 04/10/1998 Created first draft
--*/
#include "serscan.h"
#include "serlog.h"
#if DBG
extern ULONG SerScanDebugLevel;
#endif
NTSTATUS
SerScanCreateOpen(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
/*++
Routine Description:
This routine is the dispatch for a create requests.
Arguments:
DeviceObject - Supplies the device object.
Irp - Supplies the I/O request packet.
Return Value:
STATUS_SUCCESS - Success.
!STATUS_SUCCESS - Failure.
--*/
{
NTSTATUS Status;
PDEVICE_EXTENSION Extension;
PIO_STACK_LOCATION IrpSp;
PFILE_OBJECT FileObject;
PAGED_CODE();
Extension = DeviceObject->DeviceExtension;
//
// From the FileObject determine what mode we are running in.
//
// If FileObject->DeviceObject == DeviceObject, the user opened our device
// and we will process each of the callbacks (Filter mode).
//
// If FileObject->DeviceObject != DeviceObject, the user opened PORTx
// and we will get out of the way (PassThrough mode).
//
IrpSp = IoGetCurrentIrpStackLocation (Irp);
FileObject = IrpSp->FileObject;
// ASSERT (FileObject == NULL);
//
// Are the DeviceObjects equal...
//
Extension->PassThrough = !(FileObject->DeviceObject == DeviceObject);
//
// Call down to the parent and wait on the CreateOpen IRP to complete...
//
Status = SerScanCallParent(Extension,
Irp,
WAIT,
NULL);
DebugDump(SERIRPPATH,
("SerScan: [CreateOpen] After CallParent Status = %x\n",
Status));
//
// WORKWORK: If we are in filter mode, we'll connect here...
//
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
NTSTATUS
SerScanClose(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
/*++
Routine Description:
This routine is the dispatch for a close requests.
Arguments:
DeviceObject - Supplies the device object.
Irp - Supplies the I/O request packet.
Return Value:
STATUS_SUCCESS - Success.
--*/
{
NTSTATUS Status;
PDEVICE_EXTENSION Extension;
PAGED_CODE();
Extension = DeviceObject->DeviceExtension;
//
// Call down to the parent and wait on the Close IRP to complete...
//
Status = SerScanCallParent(Extension,
Irp,
WAIT,
NULL);
DebugDump(SERIRPPATH,
("SerScan: [Close] After CallParent Status = %x\n",
Status));
//
// WORKWORK: If we are in filter mode we need to disconnect here...
//
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}