ReactOS  0.4.14-dev-293-g2b39b42
pnp.c File Reference
#include "green.h"
#include <debug.h>
Include dependency graph for pnp.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS CreateGreenFdo (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT GreenPdo)
 
static NTSTATUS ReportGreenPdo (IN PDRIVER_OBJECT DriverObject, IN PGREEN_DRIVER_EXTENSION DriverExtension)
 
NTSTATUS NTAPI GreenAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
 
static NTSTATUS GreenQueryBusRelations (IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *pDeviceRelations)
 
static NTSTATUS GreenQueryId (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, OUT ULONG_PTR *Information)
 
NTSTATUS GreenPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file pnp.c.

Function Documentation

◆ CreateGreenFdo()

static NTSTATUS CreateGreenFdo ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  GreenPdo 
)
static

Definition at line 15 of file pnp.c.

18 {
20  PGREEN_DEVICE_EXTENSION DeviceExtension = NULL;
22  ULONG Fcr;
23  HANDLE LocalHandle = 0;
26 
28 
31  sizeof(GREEN_DEVICE_EXTENSION),
32  NULL,
35  FALSE,
36  &DriverExtension->GreenMainDO);
37  if (!NT_SUCCESS(Status))
38  {
39  DPRINT("IoCreateDevice() failed with status %08lx\n", Status);
40  goto cleanup;
41  }
42 
43  DeviceExtension = (PGREEN_DEVICE_EXTENSION)DriverExtension->GreenMainDO->DeviceExtension;
44  RtlZeroMemory(DeviceExtension, sizeof(GREEN_DEVICE_EXTENSION));
45  DeviceExtension->Common.Type = GreenFDO;
46  DriverExtension->GreenMainDO->Flags |= DO_POWER_PAGABLE;
47  DriverExtension->LowerDevice = IoAttachDeviceToDeviceStack(DriverExtension->GreenMainDO, GreenPdo);
48 
49  /* Initialize serial port */
54  KernelMode,
55  NULL,
57  NULL,
58  &LocalHandle);
59  if (!NT_SUCCESS(Status))
60  {
61  DPRINT("ObOpenObjectByName() failed with status %08lx\n", Status);
62  goto cleanup;
63  }
67  NULL,
68  KernelMode,
69  (PVOID*)&DeviceExtension->Serial,
70  NULL);
71  if (!NT_SUCCESS(Status))
72  {
73  DPRINT("ObReferenceObjectByHandle() failed with status %08lx\n", Status);
74  goto cleanup;
75  }
76  Fcr = 0;
78  &Fcr, sizeof(Fcr), NULL, NULL);
79  if (!NT_SUCCESS(Status))
80  {
81  DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
82  goto cleanup;
83  }
85  &DriverExtension->SampleRate, sizeof(DriverExtension->SampleRate), NULL, NULL);
86  if (!NT_SUCCESS(Status))
87  {
88  DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
89  goto cleanup;
90  }
91  DeviceExtension->LineControl.WordLength = 8;
92  DeviceExtension->LineControl.Parity = NO_PARITY;
93  DeviceExtension->LineControl.StopBits = STOP_BIT_1;
95  &DeviceExtension->LineControl, sizeof(SERIAL_LINE_CONTROL), NULL, NULL);
96  if (!NT_SUCCESS(Status))
97  {
98  DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
99  goto cleanup;
100  }
101  RtlZeroMemory(&DeviceExtension->Timeouts, sizeof(SERIAL_TIMEOUTS));
102  DeviceExtension->Timeouts.ReadIntervalTimeout = 100;
104  &DeviceExtension->Timeouts, sizeof(SERIAL_TIMEOUTS), NULL, NULL);
105  if (!NT_SUCCESS(Status))
106  {
107  DPRINT("GreenDeviceIoControl() failed with status %08lx\n", Status);
108  goto cleanup;
109  }
110 
111  DriverExtension->GreenMainDO->Flags |= DO_BUFFERED_IO;
112  DriverExtension->GreenMainDO->Flags &= ~DO_DEVICE_INITIALIZING;
113 
115 
116 cleanup:
117  if (LocalHandle != 0)
119  if (!NT_SUCCESS(Status))
120  {
121  if (DeviceExtension && DeviceExtension->Serial)
122  ObDereferenceObject(DeviceExtension->Serial);
123  if (DriverExtension)
124  {
125  if (DriverExtension->LowerDevice)
126  {
127  IoDetachDevice(DriverExtension->LowerDevice);
128  DriverExtension->LowerDevice = NULL;
129  }
130  if (DriverExtension->GreenMainDO)
131  {
132  IoDeleteDevice(DriverExtension->GreenMainDO);
133  DriverExtension->GreenMainDO = NULL;
134  }
135  }
136  }
137  return Status;
138 }
NTSTATUS NTAPI ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN OUT PVOID ParseContext, OUT PHANDLE Handle)
Definition: obhandle.c:2529
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define DO_POWER_PAGABLE
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSTATUS GreenDeviceIoControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG CtlCode, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer OPTIONAL, IN OUT PULONG OutputBufferSize)
Definition: misc.c:15
#define STOP_BIT_1
Definition: ntddser.h:215
#define FILE_ANY_ACCESS
Definition: nt_native.h:609
#define IOCTL_SERIAL_SET_BAUD_RATE
Definition: ntddser.h:82
#define IOCTL_SERIAL_SET_FIFO_CONTROL
Definition: ntddser.h:92
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
#define FILE_DEVICE_TERMSRV
Definition: winioctl.h:161
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define IOCTL_SERIAL_SET_LINE_CONTROL
Definition: ntddser.h:96
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
smooth NULL
Definition: ftsmooth.c:416
GREEN_DEVICE_TYPE Type
Definition: green.h:40
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
void DPRINT(...)
Definition: polytest.cpp:61
struct _GREEN_DEVICE_EXTENSION * PGREEN_DEVICE_EXTENSION
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PDEVICE_OBJECT Serial
Definition: green.h:84
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
ULONG ReadIntervalTimeout
Definition: ntddser.h:303
Definition: green.h:26
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
Status
Definition: gdiplustypes.h:24
SERIAL_LINE_CONTROL LineControl
Definition: green.h:86
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define NO_PARITY
Definition: serial.c:89
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
SERIAL_TIMEOUTS Timeouts
Definition: green.h:87
COMMON_FDO_DEVICE_EXTENSION Common
Definition: green.h:83
unsigned int ULONG
Definition: retypes.h:1
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:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
char * cleanup(char *str)
Definition: wpickclick.c:99
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
HLOCAL NTAPI LocalHandle(LPCVOID pMem)
Definition: heapmem.c:1588
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define IOCTL_SERIAL_SET_TIMEOUTS
Definition: ntddser.h:104

Referenced by GreenAddDevice(), and ReportGreenPdo().

◆ GreenAddDevice()

NTSTATUS NTAPI GreenAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  Pdo 
)

Definition at line 179 of file pnp.c.

182 {
184 
185  DPRINT("AddDevice(DriverObject %p, Pdo %p)\n", DriverObject, Pdo);
186 
188 
189  if (Pdo == NULL)
190  {
191  if (DriverExtension->DeviceReported)
192  /* Green Pdo has already been reported during a previous boot.
193  * We will get another AddDevice call soon.
194  */
195  return STATUS_SUCCESS;
196  else
198  }
199  else if (DriverExtension->GreenMainDO == NULL)
200  {
202  }
203  else
204  {
205  PGREEN_DEVICE_EXTENSION GreenDeviceExtension;
206 
207  GreenDeviceExtension = (PGREEN_DEVICE_EXTENSION)DriverExtension->GreenMainDO->DeviceExtension;
208  if (Pdo == GreenDeviceExtension->KeyboardPdo)
210  else if (Pdo == GreenDeviceExtension->ScreenPdo)
212  else
213  /* Strange PDO. We don't know it */
214  ASSERT(FALSE);
215  return STATUS_UNSUCCESSFUL;
216  }
217 }
NTSTATUS ScreenAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
Definition: screen.c:111
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:301
static NTSTATUS ReportGreenPdo(IN PDRIVER_OBJECT DriverObject, IN PGREEN_DRIVER_EXTENSION DriverExtension)
Definition: pnp.c:141
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
void DPRINT(...)
Definition: polytest.cpp:61
PDEVICE_OBJECT ScreenPdo
Definition: green.h:90
struct _GREEN_DEVICE_EXTENSION * PGREEN_DEVICE_EXTENSION
if(!(yy_init))
Definition: macro.lex.yy.c:714
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PDEVICE_OBJECT KeyboardPdo
Definition: green.h:89
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
NTSTATUS KeyboardAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
Definition: keyboard.c:109
static NTSTATUS CreateGreenFdo(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT GreenPdo)
Definition: pnp.c:15
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by DriverEntry().

◆ GreenPnp()

NTSTATUS GreenPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 408 of file pnp.c.

411 {
413  PIO_STACK_LOCATION Stack;
414  ULONG_PTR Information = Irp->IoStatus.Information;
415  NTSTATUS Status = Irp->IoStatus.Status;
416 
419 
420  switch (Stack->MinorFunction)
421  {
422  case IRP_MN_START_DEVICE: /* 0x00 */
423  {
424  DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
425  if (Type == GreenFDO || Type == KeyboardPDO || Type == ScreenPDO)
427  else
428  {
429  DPRINT1("IRP_MJ_PNP / IRP_MN_START_DEVICE / Unknown type 0x%lx\n",
430  Type);
431  ASSERT(FALSE);
432  }
433  break;
434  }
435  case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x07 */
436  {
437  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS\n");
438  switch (Stack->Parameters.QueryDeviceRelations.Type)
439  {
440  case BusRelations:
441  {
442  if (Type == GreenFDO)
443  {
444  PDEVICE_RELATIONS DeviceRelations = NULL;
445  Status = GreenQueryBusRelations(DeviceObject, &DeviceRelations);
446  Information = (ULONG_PTR)DeviceRelations;
447  }
448  else if (Type == KeyboardPDO || Type == ScreenPDO)
449  {
450  PDEVICE_RELATIONS DeviceRelations = NULL;
451  DeviceRelations = ExAllocatePool(PagedPool, FIELD_OFFSET(DEVICE_RELATIONS, Objects));
452  if (!DeviceRelations)
454  else
455  {
456  DeviceRelations->Count = 0;
458  Information = (ULONG_PTR)DeviceRelations;
459  }
460  }
461  else
462  {
463  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations / Unknown type 0x%lx\n",
464  Type);
465  ASSERT(FALSE);
466  }
467  break;
468  }
469  default:
470  {
471  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
472  Stack->Parameters.QueryDeviceRelations.Type);
473  break;
474  }
475  }
476  break;
477  }
478  case IRP_MN_QUERY_RESOURCES: /* 0x0a */
479  {
480  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_RESOURCES\n");
481  /* We don't need resources */
482  break;
483  }
484  case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: /* 0x0b */
485  {
486  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
487  /* We don't need resources */
488  break;
489  }
490  case IRP_MN_QUERY_DEVICE_TEXT: /* 0x0c */
491  {
492  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT\n");
493  switch (Stack->Parameters.QueryDeviceText.DeviceTextType)
494  {
496  {
498  if (Type == GreenFDO)
499  Description = L"Green device";
500  else if (Type == ScreenPDO)
501  Description = L"Green screen";
502  else if (Type == KeyboardPDO)
503  Description = L"Green keyboard";
504 
505  if (Description != NULL)
506  {
508  if (!Destination)
510  else
511  {
515  }
516  }
517  else
518  {
519  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription / Unknown type 0x%lx\n",
520  Type);
521  ASSERT(FALSE);
522  }
523  break;
524  }
526  {
527  /* We don't have any text location to report,
528  * and this query is optional, so ignore it.
529  */
530  break;
531  }
532  default:
533  {
534  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown type 0x%lx\n",
535  Stack->Parameters.QueryDeviceText.DeviceTextType);
536  ASSERT(FALSE);
537  break;
538  }
539  }
540  break;
541  }
542  case IRP_MN_QUERY_ID: /* 0x13 */
543  {
544  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID\n");
546  break;
547  }
548  default:
549  {
550  DPRINT1("IRP_MJ_PNP / unknown minor function 0x%lx\n", Stack->MinorFunction);
551  break;
552  }
553  }
554 
555  Irp->IoStatus.Status = Status;
556  Irp->IoStatus.Information = Information;
557  if (Status != STATUS_PENDING)
559 
560  return Status;
561 }
#define IRP_MN_QUERY_RESOURCES
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IRP_MN_QUERY_ID
Type
Definition: Type.h:6
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
static const WCHAR Description[]
Definition: oid.c:1266
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define UNICODE_NULL
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IRP_MN_START_DEVICE
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
Definition: green.h:26
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2891
#define IRP_MN_QUERY_DEVICE_TEXT
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
GREEN_DEVICE_TYPE
Definition: green.h:21
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define DPRINT1
Definition: precomp.h:8
static NTSTATUS GreenQueryId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, OUT ULONG_PTR *Information)
Definition: pnp.c:313
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ULONG_PTR
Definition: config.h:101
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static NTSTATUS GreenQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: pnp.c:220
Iosb Information
Definition: create.c:4377

Referenced by GreenDispatch().

◆ GreenQueryBusRelations()

static NTSTATUS GreenQueryBusRelations ( IN PDEVICE_OBJECT  DeviceObject,
OUT PDEVICE_RELATIONS pDeviceRelations 
)
static

Definition at line 220 of file pnp.c.

223 {
224  PGREEN_DEVICE_EXTENSION DeviceExtension;
225  PDEVICE_RELATIONS DeviceRelations = NULL;
227 
229 
230  /* Create PDOs for keyboard and screen */
231  if (DeviceExtension->KeyboardPdo == NULL)
232  {
234  DeviceObject->DriverObject,
235  sizeof(COMMON_DEVICE_EXTENSION),
236  NULL,
239  FALSE,
240  &DeviceExtension->KeyboardPdo);
241  if (!NT_SUCCESS(Status))
242  {
243  DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
244  goto cleanup;
245  }
248  DeviceExtension->KeyboardPdo->Flags &= ~DO_DEVICE_INITIALIZING;
249  }
250 
251  if (DeviceExtension->ScreenPdo == NULL)
252  {
254  DeviceObject->DriverObject,
255  sizeof(COMMON_DEVICE_EXTENSION),
256  NULL,
259  FALSE,
260  &DeviceExtension->ScreenPdo);
261  if (!NT_SUCCESS(Status))
262  {
263  DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
264  goto cleanup;
265  }
266  ((PCOMMON_DEVICE_EXTENSION)DeviceExtension->ScreenPdo->DeviceExtension)->Type = ScreenPDO;
268  DeviceExtension->ScreenPdo->Flags &= ~DO_DEVICE_INITIALIZING;
269  }
270 
271  /* Allocate return structure */
272  DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePool(
273  PagedPool,
274  FIELD_OFFSET(DEVICE_RELATIONS, Objects) + 2 * sizeof(PDEVICE_OBJECT));
275  if (!DeviceRelations)
277 
278  /* Fill return structure */
279  DeviceRelations->Count = 2;
280  ObReferenceObject(DeviceExtension->KeyboardPdo);
281  ObReferenceObject(DeviceExtension->ScreenPdo);
282  DeviceRelations->Objects[0] = DeviceExtension->KeyboardPdo;
283  DeviceRelations->Objects[1] = DeviceExtension->ScreenPdo;
284 
285  *pDeviceRelations = DeviceRelations;
287 
288 cleanup:
289  if (!NT_SUCCESS(Status))
290  {
291  if (DeviceRelations)
292  {
293  ULONG i;
294  for (i = 0; i < DeviceRelations->Count; i++)
295  ObDereferenceObject(DeviceRelations->Objects[i]);
296  ExFreePool(DeviceRelations);
297  }
298  if (DeviceExtension->KeyboardPdo)
299  {
300  IoDeleteDevice(DeviceExtension->KeyboardPdo);
301  DeviceExtension->KeyboardPdo = NULL;
302  }
303  if (DeviceExtension->ScreenPdo)
304  {
305  IoDeleteDevice(DeviceExtension->ScreenPdo);
306  DeviceExtension->ScreenPdo = NULL;
307  }
308  }
309  return Status;
310 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define DO_POWER_PAGABLE
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define FILE_DEVICE_SCREEN
Definition: winioctl.h:133
struct _DEVICE_OBJECT * PDEVICE_OBJECT
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2055
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define DO_BUS_ENUMERATED_DEVICE
void DPRINT(...)
Definition: polytest.cpp:61
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
PDEVICE_OBJECT ScreenPdo
Definition: green.h:90
struct _GREEN_DEVICE_EXTENSION * PGREEN_DEVICE_EXTENSION
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
PDEVICE_OBJECT KeyboardPdo
Definition: green.h:89
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define ObReferenceObject
Definition: obfuncs.h:204
unsigned int ULONG
Definition: retypes.h:1
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
char * cleanup(char *str)
Definition: wpickclick.c:99
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define FILE_DEVICE_KEYBOARD
Definition: winioctl.h:116
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by GreenPnp().

◆ GreenQueryId()

static NTSTATUS GreenQueryId ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
OUT ULONG_PTR Information 
)
static

Definition at line 313 of file pnp.c.

317 {
319  ULONG IdType;
320  NTSTATUS Status = Irp->IoStatus.Status;
321 
324 
325  switch (IdType)
326  {
327  case BusQueryDeviceID:
328  {
329  LPCWSTR Source = NULL;
330 
331  if (Type == ScreenPDO)
332  Source = L"GREEN\\SCREEN";
333  else if (Type == KeyboardPDO)
334  Source = L"GREEN\\KEYBOARD";
335  else
336  {
337  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceId / Unknown type 0x%lx\n",
338  Type);
339  ASSERT(FALSE);
340  }
341 
342  if (Source)
343  {
344  UNICODE_STRING SourceU, String;
345  RtlInitUnicodeString(&SourceU, Source);
348  &SourceU,
349  &String);
350  *Information = (ULONG_PTR)String.Buffer;
351  }
352  break;
353  }
354  case BusQueryHardwareIDs:
355  {
356  UNICODE_STRING SourceU = { 0, };
357 
358  if (Type == ScreenPDO)
359  {
360  RtlInitUnicodeString(&SourceU, L"GREEN\\SCREEN\0");
361  /* We can add the two \0 that are at the end of the string */
362  SourceU.Length = SourceU.MaximumLength = SourceU.Length + 2 * sizeof(WCHAR);
363  }
364  else if (Type == KeyboardPDO)
365  {
366  RtlInitUnicodeString(&SourceU, L"GREEN\\KEYBOARD\0");
367  /* We can add the two \0 that are at the end of the string */
368  SourceU.Length = SourceU.MaximumLength = SourceU.Length + 2 * sizeof(WCHAR);
369  }
370  else
371  {
372  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs / Unknown type 0x%lx\n",
373  Type);
374  ASSERT(FALSE);
375  }
376 
377  if (SourceU.Length)
378  {
382  &SourceU,
383  &String);
384  *Information = (ULONG_PTR)String.Buffer;
385  }
386  break;
387  }
389  {
390  /* We don't have any compatible ID */
391  break;
392  }
393  case BusQueryInstanceID:
394  {
395  /* We don't have any instance ID */
396  break;
397  }
398  default:
399  {
400  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n", IdType);
401  }
402  }
403 
404  return Status;
405 }
Type
Definition: Type.h:6
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
USHORT MaximumLength
Definition: env_spec_w32.h:370
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
static WCHAR String[]
Definition: stringtable.c:55
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
_In_ BUS_QUERY_ID_TYPE IdType
Definition: classpnp.h:357
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS GreenDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: green.c:71
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
GREEN_DEVICE_TYPE
Definition: green.h:21
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ULONG_PTR
Definition: config.h:101
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
Iosb Information
Definition: create.c:4377

Referenced by GreenPnp().

◆ ReportGreenPdo()

static NTSTATUS ReportGreenPdo ( IN PDRIVER_OBJECT  DriverObject,
IN PGREEN_DRIVER_EXTENSION  DriverExtension 
)
static

Definition at line 141 of file pnp.c.

144 {
145  PDEVICE_OBJECT GreenPdo = NULL;
147 
148  /* Create green PDO */
150  DriverObject,
151  InterfaceTypeUndefined, -1, -1,
152  NULL, NULL, TRUE,
153  &GreenPdo);
154  if (!NT_SUCCESS(Status))
155  {
156  DPRINT("IoReportDetectedDevice() failed with status 0x%lx\n", Status);
157  goto cleanup;
158  }
159 
160  /* Create green FDO */
161  Status = CreateGreenFdo(DriverObject, GreenPdo);
162 
164 
165  /* FIXME: Update registry, set "DeviceReported" to 1 */
166 
168 
169 cleanup:
170  if (!NT_SUCCESS(Status))
171  {
172  if (DriverExtension->GreenMainDO)
173  IoDeleteDevice(DriverExtension->GreenMainDO);
174  }
175  return Status;
176 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject, IN INTERFACE_TYPE LegacyBusType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PCM_RESOURCE_LIST ResourceList, IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL, IN BOOLEAN ResourceAssigned, IN OUT PDEVICE_OBJECT *DeviceObject OPTIONAL)
Definition: pnpreport.c:162
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:5108
char * cleanup(char *str)
Definition: wpickclick.c:99
static NTSTATUS CreateGreenFdo(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT GreenPdo)
Definition: pnp.c:15
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by GreenAddDevice().