ReactOS 0.4.16-dev-340-g0540c21
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;
26
28
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 */
55 NULL,
57 NULL,
59 if (!NT_SUCCESS(Status))
60 {
61 DPRINT("ObOpenObjectByName() failed with status %08lx\n", Status);
62 goto cleanup;
63 }
67 NULL,
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
116cleanup:
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}
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static void cleanup(void)
Definition: main.c:1335
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
Status
Definition: gdiplustypes.h:25
@ GreenFDO
Definition: green.h:26
struct _GREEN_DEVICE_EXTENSION * PGREEN_DEVICE_EXTENSION
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
HLOCAL NTAPI LocalHandle(LPCVOID pMem)
Definition: heapmem.c:1605
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define NO_PARITY
Definition: serial.c:89
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:34
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define FILE_ANY_ACCESS
Definition: nt_native.h:609
#define IOCTL_SERIAL_SET_LINE_CONTROL
Definition: ntddser.h:96
#define IOCTL_SERIAL_SET_TIMEOUTS
Definition: ntddser.h:104
#define STOP_BIT_1
Definition: ntddser.h:215
#define IOCTL_SERIAL_SET_FIFO_CONTROL
Definition: ntddser.h:92
#define IOCTL_SERIAL_SET_BAUD_RATE
Definition: ntddser.h:82
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
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
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1904
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:2532
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:494
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
#define FILE_DEVICE_TERMSRV
Definition: winioctl.h:101
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
GREEN_DEVICE_TYPE Type
Definition: green.h:40
SERIAL_LINE_CONTROL LineControl
Definition: green.h:86
PDEVICE_OBJECT Serial
Definition: green.h:84
COMMON_FDO_DEVICE_EXTENSION Common
Definition: green.h:83
SERIAL_TIMEOUTS Timeouts
Definition: green.h:87
ULONG ReadIntervalTimeout
Definition: ntddser.h:303
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define DO_POWER_PAGABLE
#define ObDereferenceObject
Definition: obfuncs.h:203

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 KeyboardAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
Definition: keyboard.c:109
NTSTATUS ScreenAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
Definition: screen.c:111
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44
static NTSTATUS ReportGreenPdo(IN PDRIVER_OBJECT DriverObject, IN PGREEN_DRIVER_EXTENSION DriverExtension)
Definition: pnp.c:141
static NTSTATUS CreateGreenFdo(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT GreenPdo)
Definition: pnp.c:15
PDEVICE_OBJECT KeyboardPdo
Definition: green.h:89
PDEVICE_OBJECT ScreenPdo
Definition: green.h:90
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:72

Referenced by DriverEntry().

◆ GreenPnp()

NTSTATUS GreenPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 408 of file pnp.c.

411{
414 ULONG_PTR Information = Irp->IoStatus.Information;
415 NTSTATUS Status = Irp->IoStatus.Status;
416
417 Type = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
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 }
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}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
Type
Definition: Type.h:7
#define DPRINT1
Definition: precomp.h:8
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_PENDING
Definition: d3dkmdt.h:43
static const WCHAR Description[]
Definition: oid.c:1266
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
#define ULONG_PTR
Definition: config.h:101
#define PagedPool
Definition: env_spec_w32.h:308
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
GREEN_DEVICE_TYPE
Definition: green.h:22
@ KeyboardPDO
Definition: green.h:25
@ ScreenPDO
Definition: green.h:24
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static NTSTATUS GreenQueryId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, OUT ULONG_PTR *Information)
Definition: pnp.c:313
static NTSTATUS GreenQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: pnp.c:220
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3016
#define UNICODE_NULL
#define IoCompleteRequest
Definition: irp.c:1240
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
DEVICE_RELATION_TYPE Type
Definition: iotypes.h:3242
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
@ BusRelations
Definition: iotypes.h:2152
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_ID
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_RESOURCES
@ DeviceTextLocationInformation
Definition: iotypes.h:2946
@ DeviceTextDescription
Definition: iotypes.h:2945
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

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
228 DeviceExtension = (PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
229
230 /* Create PDOs for keyboard and screen */
231 if (DeviceExtension->KeyboardPdo == NULL)
232 {
234 DeviceObject->DriverObject,
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,
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
288cleanup:
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}
struct _DEVICE_OBJECT * PDEVICE_OBJECT
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
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
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
#define FILE_DEVICE_SCREEN
Definition: winioctl.h:73
#define FILE_DEVICE_KEYBOARD
Definition: winioctl.h:56
PVOID DeviceExtension
Definition: env_spec_w32.h:418
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
#define DO_BUS_ENUMERATED_DEVICE
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
#define ObReferenceObject
Definition: obfuncs.h:204

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{
320 NTSTATUS Status = Irp->IoStatus.Status;
321
322 Type = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
324
325 switch (IdType)
326 {
327 case BusQueryDeviceID:
328 {
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 }
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 }
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}
_In_ BUS_QUERY_ID_TYPE IdType
Definition: classpnp.h:374
NTSTATUS GreenDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: green.c:71
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
union _IO_STACK_LOCATION::@1581 Parameters
struct _IO_STACK_LOCATION::@3980::@4011 QueryId
USHORT MaximumLength
Definition: env_spec_w32.h:370
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
@ BusQueryCompatibleIDs
Definition: iotypes.h:2938
@ BusQueryInstanceID
Definition: iotypes.h:2939
@ BusQueryDeviceID
Definition: iotypes.h:2936
@ BusQueryHardwareIDs
Definition: iotypes.h:2937

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 */
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 */
162
164
165 /* FIXME: Update registry, set "DeviceReported" to 1 */
166
168
169cleanup:
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
@ InterfaceTypeUndefined
Definition: hwresource.cpp:136
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:1772
NTSTATUS NTAPI IoReportDetectedDevice(_In_ PDRIVER_OBJECT DriverObject, _In_ INTERFACE_TYPE LegacyBusType, _In_ ULONG BusNumber, _In_ ULONG SlotNumber, _In_opt_ PCM_RESOURCE_LIST ResourceList, _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements, _In_ BOOLEAN ResourceAssigned, _Inout_ PDEVICE_OBJECT *DeviceObject)
Definition: pnpreport.c:148

Referenced by GreenAddDevice().