ReactOS  0.4.15-dev-5122-g72bdbdd
usbccgp.c File Reference
#include "usbccgp.h"
#include <debug.h>
Include dependency graph for usbccgp.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI USBCCGP_AddDevice (PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PhysicalDeviceObject)
 
NTSTATUS NTAPI USBCCGP_CreateClose (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI USBCCGP_Dispatch (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
VOID NTAPI USBCCGP_Unload (PDRIVER_OBJECT DriverObject)
 
NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 

Variables

DRIVER_ADD_DEVICE USBCCGP_AddDevice
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file usbccgp.c.

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 152 of file usbccgp.c.

155 {
156 
157  /* Initialize driver object */
158  DPRINT("[USBCCGP] DriverEntry\n");
159  DriverObject->DriverExtension->AddDevice = USBCCGP_AddDevice;
160  DriverObject->MajorFunction[IRP_MJ_CREATE] = USBCCGP_Dispatch;
161  DriverObject->MajorFunction[IRP_MJ_CLOSE] = USBCCGP_Dispatch;
164  DriverObject->MajorFunction[IRP_MJ_POWER] = USBCCGP_Dispatch;
165  DriverObject->MajorFunction[IRP_MJ_PNP] = USBCCGP_Dispatch;
167  DriverObject->DriverUnload = USBCCGP_Unload;
168 
169  /* FIMXE query GenericCompositeUSBDeviceString */
170 
171  return STATUS_SUCCESS;
172 }
NTSTATUS NTAPI USBCCGP_Dispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: usbccgp.c:112
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
VOID NTAPI USBCCGP_Unload(PDRIVER_OBJECT DriverObject)
Definition: usbccgp.c:145
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
#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
DRIVER_ADD_DEVICE USBCCGP_AddDevice
Definition: usbccgp.c:18
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

◆ USBCCGP_AddDevice()

NTSTATUS NTAPI USBCCGP_AddDevice ( PDRIVER_OBJECT  DriverObject,
PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 22 of file usbccgp.c.

25 {
28  PFDO_DEVICE_EXTENSION FDODeviceExtension;
29 
30  /* Lets create the device */
32  sizeof(FDO_DEVICE_EXTENSION),
33  NULL,
36  FALSE,
37  &DeviceObject);
38  if (!NT_SUCCESS(Status))
39  {
40  /* Failed to create device */
41  DPRINT1("USBCCGP_AddDevice failed to create device with %x\n", Status);
42  return Status;
43  }
44 
45  /* Get device extension */
46  FDODeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
47 
48  /* Init device extension */
49  RtlZeroMemory(FDODeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
50  FDODeviceExtension->Common.IsFDO = TRUE;
51  FDODeviceExtension->DriverObject = DriverObject;
52  FDODeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
53  InitializeListHead(&FDODeviceExtension->ResetPortListHead);
54  InitializeListHead(&FDODeviceExtension->CyclePortListHead);
55  KeInitializeSpinLock(&FDODeviceExtension->Lock);
56 
57  FDODeviceExtension->NextDeviceObject = IoAttachDeviceToDeviceStack(DeviceObject,
59  if (!FDODeviceExtension->NextDeviceObject)
60  {
61  /* Failed to attach */
62  DPRINT1("USBCCGP_AddDevice failed to attach device\n");
64  return STATUS_DEVICE_REMOVED;
65  }
66 
67  /* Set device flags */
69 
70  /* Device is initialized */
72 
73  /* Device initialized */
74  return Status;
75 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define DO_POWER_PAGABLE
#define STATUS_DEVICE_REMOVED
Definition: ntstatus.h:809
#define TRUE
Definition: types.h:120
#define FILE_DEVICE_USB
Definition: usbiodef.h:71
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:240
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:84
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
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

◆ USBCCGP_CreateClose()

NTSTATUS NTAPI USBCCGP_CreateClose ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 79 of file usbccgp.c.

82 {
83  PCOMMON_DEVICE_EXTENSION DeviceExtension;
84  PFDO_DEVICE_EXTENSION FDODeviceExtension;
85 
86  /* Get common device extension */
87  DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
88 
89  /* Is it a fdo */
90  if (DeviceExtension->IsFDO)
91  {
92  /* Forward and forget */
94 
95  /* Get fdo */
96  FDODeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
97 
98  /* Call lower driver */
99  return IoCallDriver(FDODeviceExtension->NextDeviceObject, Irp);
100  }
101  else
102  {
103  /* Pdo not supported */
104  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
106  return STATUS_NOT_SUPPORTED;
107  }
108 }
return STATUS_NOT_SUPPORTED
if(dx==0 &&dy==0)
Definition: linetemp.h:174
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by USBCCGP_Dispatch().

◆ USBCCGP_Dispatch()

NTSTATUS NTAPI USBCCGP_Dispatch ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 112 of file usbccgp.c.

115 {
116  PCOMMON_DEVICE_EXTENSION DeviceExtension;
117  PIO_STACK_LOCATION IoStack;
118 
119  /* Get common device extension */
120  DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
121 
122  /* Get current stack location */
124 
125  if (IoStack->MajorFunction == IRP_MJ_CREATE || IoStack->MajorFunction == IRP_MJ_CLOSE)
126  {
127  /* Dispatch to default handler */
129  }
130 
131  if (DeviceExtension->IsFDO)
132  {
133  /* Handle request for FDO */
134  return FDO_Dispatch(DeviceObject, Irp);
135  }
136  else
137  {
138  /* Handle request for PDO */
139  return PDO_Dispatch(DeviceObject, Irp);
140  }
141 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI USBCCGP_CreateClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: usbccgp.c:79
NTSTATUS FDO_Dispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: fdo.c:633
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
NTSTATUS PDO_Dispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pdo.c:1125
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793

Referenced by DriverEntry().

◆ USBCCGP_Unload()

VOID NTAPI USBCCGP_Unload ( PDRIVER_OBJECT  DriverObject)

Definition at line 145 of file usbccgp.c.

146 {
147  DPRINT("[USBCCGP] Unload\n");
148 }
#define DPRINT
Definition: sndvol32.h:71

Referenced by DriverEntry().

Variable Documentation

◆ USBCCGP_AddDevice

DRIVER_ADD_DEVICE USBCCGP_AddDevice

Definition at line 18 of file usbccgp.c.

Referenced by DriverEntry().