ReactOS  0.4.15-dev-4603-gb922b6d
stub.c File Reference
#include "isapnp.h"
#include <debug.h>
Include dependency graph for stub.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 _Dispatch_type_ (IRP_MJ_CREATE)
 
 _Dispatch_type_ (IRP_MJ_DEVICE_CONTROL)
 
 _Dispatch_type_ (IRP_MJ_PNP)
 
 _Dispatch_type_ (IRP_MJ_POWER)
 
static CODE_SEG ("PAGE")
 
NTSTATUS NTAPI DriverEntry (_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 18 of file stub.c.

Function Documentation

◆ _Dispatch_type_() [1/4]

_Dispatch_type_ ( IRP_MJ_CREATE  )

Definition at line 23 of file stub.c.

34 {
36 
37  PAGED_CODE();
38 
39  Irp->IoStatus.Status = STATUS_SUCCESS;
41 
42  return STATUS_SUCCESS;
43 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65
#define PAGED_CODE()

◆ _Dispatch_type_() [2/4]

_Dispatch_type_ ( IRP_MJ_DEVICE_CONTROL  )

Definition at line 45 of file stub.c.

56 {
57  PISAPNP_FDO_EXTENSION FdoExt = DeviceObject->DeviceExtension;
58 
59  PAGED_CODE();
60 
62  return IoCallDriver(FdoExt->Ldo, Irp);
63 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
PDEVICE_OBJECT Ldo
Definition: isapnp.h:158
#define PAGED_CODE()

◆ _Dispatch_type_() [3/4]

_Dispatch_type_ ( IRP_MJ_PNP  )

Definition at line 65 of file stub.c.

75 {
76  PISAPNP_FDO_EXTENSION FdoExt = DeviceObject->DeviceExtension;
79 
80  PAGED_CODE();
81 
82  DPRINT("%s(%p, %p) Minor - %X\n",
84  FdoExt,
85  Irp,
87 
88  switch (IrpSp->MinorFunction)
89  {
91  {
92  if (IoForwardIrpSynchronously(FdoExt->Ldo, Irp))
93  Status = Irp->IoStatus.Status;
94  else
96 
97  goto CompleteIrp;
98  }
99 
101  {
102  PDEVICE_RELATIONS DeviceRelations;
103 
104  if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
105  break;
106 
107  DeviceRelations = ExAllocatePoolWithTag(PagedPool,
108  FIELD_OFFSET(DEVICE_RELATIONS, Objects),
109  TAG_ISAPNP);
110  if (!DeviceRelations)
111  {
113  goto CompleteIrp;
114  }
115 
116  DeviceRelations->Count = 0;
117 
118  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
119  Irp->IoStatus.Status = STATUS_SUCCESS;
120  break;
121  }
122 
124  {
125  Irp->IoStatus.Status = STATUS_SUCCESS;
127  Status = IoCallDriver(FdoExt->Ldo, Irp);
128 
129  IoDetachDevice(FdoExt->Ldo);
130  IoDeleteDevice(FdoExt->Common.Self);
131 
132  return Status;
133  }
134 
136  {
137  Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
138  Irp->IoStatus.Status = STATUS_SUCCESS;
139  break;
140  }
141 
143  {
144  Status = IsaFdoQueryInterface(FdoExt, IrpSp);
146  {
147  break;
148  }
149  else if (!NT_SUCCESS(Status))
150  {
151  goto CompleteIrp;
152  }
153 
154  Irp->IoStatus.Status = Status;
155  break;
156  }
157 
162  case IRP_MN_STOP_DEVICE:
164  {
165  Irp->IoStatus.Status = STATUS_SUCCESS;
166  break;
167  }
168 
169  default:
170  break;
171  }
172 
174  return IoCallDriver(FdoExt->Ldo, Irp);
175 
177  Irp->IoStatus.Status = Status;
179  return Status;
180 }
#define IRP_MN_CANCEL_REMOVE_DEVICE
return STATUS_NOT_SUPPORTED
#define IRP_MN_REMOVE_DEVICE
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1625
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
VOID CompleteIrp(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: pnp.c:12
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_QUERY_REMOVE_DEVICE
#define IoCompleteRequest
Definition: irp.c:1240
#define IRP_MN_QUERY_STOP_DEVICE
Status
Definition: gdiplustypes.h:24
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_STOP_DEVICE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ISAPNP_COMMON_EXTENSION Common
Definition: isapnp.h:157
#define IRP_MN_START_DEVICE
#define PNP_DEVICE_NOT_DISABLEABLE
Definition: iotypes.h:1006
#define IRP_MN_QUERY_INTERFACE
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
NTSTATUS IsaFdoQueryInterface(_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PIO_STACK_LOCATION IrpSp)
Definition: interface.c:19
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define ULONG_PTR
Definition: config.h:101
#define IRP_MN_CANCEL_STOP_DEVICE
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
PDEVICE_OBJECT Ldo
Definition: isapnp.h:158
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define __FUNCTION__
Definition: types.h:112
PDEVICE_OBJECT Self
Definition: isapnp.h:151
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define TAG_ISAPNP
Definition: isapnp.h:24
#define PAGED_CODE()

◆ _Dispatch_type_() [4/4]

_Dispatch_type_ ( IRP_MJ_POWER  )

Definition at line 182 of file stub.c.

191 {
192  PISAPNP_FDO_EXTENSION FdoExt = DeviceObject->DeviceExtension;
193 
196  return PoCallDriver(FdoExt->Ldo, Irp);
197 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:746
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
PDEVICE_OBJECT Ldo
Definition: isapnp.h:158

◆ CODE_SEG()

static CODE_SEG ( "PAGE"  )
static

Definition at line 199 of file stub.c.

208 {
210  PISAPNP_FDO_EXTENSION FdoExt;
212 
213  PAGED_CODE();
214 
216 
218  sizeof(ISAPNP_FDO_EXTENSION),
219  NULL,
222  FALSE,
223  &Fdo);
224  if (!NT_SUCCESS(Status))
225  {
226  DPRINT1("Failed to create FDO (0x%08lx)\n", Status);
227  return Status;
228  }
229 
230  FdoExt = Fdo->DeviceExtension;
231 
232  RtlZeroMemory(FdoExt, sizeof(ISAPNP_FDO_EXTENSION));
233  FdoExt->Common.Self = Fdo;
234  FdoExt->Common.Signature = IsaPnpBus;
235  FdoExt->DriverObject = DriverObject;
236  FdoExt->Pdo = PhysicalDeviceObject;
238  if (!FdoExt->Ldo)
239  {
241  return STATUS_DEVICE_REMOVED;
242  }
243 
244  Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
245 
246  return STATUS_SUCCESS;
247 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define STATUS_DEVICE_REMOVED
Definition: ntstatus.h:809
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1149
PDEVICE_OBJECT Pdo
Definition: isapnp.h:159
#define FALSE
Definition: types.h:117
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ISAPNP_COMMON_EXTENSION Common
Definition: isapnp.h:157
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
PDRIVER_OBJECT DriverObject
Definition: isapnp.h:170
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
ISAPNP_SIGNATURE Signature
Definition: isapnp.h:150
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
PDEVICE_OBJECT Ldo
Definition: isapnp.h:158
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:148
#define __FUNCTION__
Definition: types.h:112
PDEVICE_OBJECT Self
Definition: isapnp.h:151
#define PAGED_CODE()

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PUNICODE_STRING  RegistryPath 
)

Definition at line 268 of file stub.c.

271 {
272  DPRINT("%s(%p, %wZ)\n", __FUNCTION__, DriverObject, RegistryPath);
273 
274  DriverObject->MajorFunction[IRP_MJ_CREATE] = IsaStubCreateClose;
275  DriverObject->MajorFunction[IRP_MJ_CLOSE] = IsaStubCreateClose;
276  DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IsaStubForward;
277  DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = IsaStubForward;
278  DriverObject->MajorFunction[IRP_MJ_PNP] = IsaStubPnp;
279  DriverObject->MajorFunction[IRP_MJ_POWER] = IsaStubPower;
280  DriverObject->DriverExtension->AddDevice = IsaStubAddDevice;
281  DriverObject->DriverUnload = IsaStubUnload;
282 
283  return STATUS_SUCCESS;
284 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IRP_MJ_POWER
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_SYSTEM_CONTROL
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define __FUNCTION__
Definition: types.h:112
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52