ReactOS 0.4.16-dev-125-g798ea90
serenum.h File Reference
#include <ntifs.h>
#include <ntddser.h>
Include dependency graph for serenum.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _COMMON_DEVICE_EXTENSION
 
struct  _FDO_DEVICE_EXTENSION
 
struct  _PDO_DEVICE_EXTENSION
 

Macros

#define SERENUM_TAG   'ereS'
 
#define FLAG_ENUMERATION_DONE   0x01
 

Typedefs

typedef struct _COMMON_DEVICE_EXTENSION COMMON_DEVICE_EXTENSION
 
typedef struct _COMMON_DEVICE_EXTENSIONPCOMMON_DEVICE_EXTENSION
 
typedef struct _FDO_DEVICE_EXTENSION FDO_DEVICE_EXTENSION
 
typedef struct _FDO_DEVICE_EXTENSIONPFDO_DEVICE_EXTENSION
 
typedef struct _PDO_DEVICE_EXTENSION PDO_DEVICE_EXTENSION
 
typedef struct _PDO_DEVICE_EXTENSIONPPDO_DEVICE_EXTENSION
 

Enumerations

enum  SERENUM_DEVICE_STATE {
  dsStopped , dsStarted , dsPaused , dsRemoved ,
  dsSurpriseRemoved
}
 

Functions

NTSTATUS SerenumDetectPnpDevice (IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT LowerDevice)
 
NTSTATUS SerenumDetectLegacyDevice (IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT LowerDevice)
 
NTSTATUS SerenumFdoPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS SerenumInitMultiSzString (OUT PUNICODE_STRING Destination,...)
 
NTSTATUS ForwardIrpAndWait (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI ForwardIrpToLowerDeviceAndForget (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI ForwardIrpToAttachedFdoAndForget (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI ForwardIrpAndForget (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS DuplicateUnicodeString (IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
 
NTSTATUS SerenumPdoPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegPath)
 

Variables

DRIVER_ADD_DEVICE SerenumAddDevice
 

Macro Definition Documentation

◆ FLAG_ENUMERATION_DONE

#define FLAG_ENUMERATION_DONE   0x01

Definition at line 61 of file serenum.h.

◆ SERENUM_TAG

#define SERENUM_TAG   'ereS'

Definition at line 58 of file serenum.h.

Typedef Documentation

◆ COMMON_DEVICE_EXTENSION

◆ FDO_DEVICE_EXTENSION

◆ PCOMMON_DEVICE_EXTENSION

◆ PDO_DEVICE_EXTENSION

◆ PFDO_DEVICE_EXTENSION

◆ PPDO_DEVICE_EXTENSION

Enumeration Type Documentation

◆ SERENUM_DEVICE_STATE

Enumerator
dsStopped 
dsStarted 
dsPaused 
dsRemoved 
dsSurpriseRemoved 

Definition at line 16 of file serenum.h.

17{
SERENUM_DEVICE_STATE
Definition: serenum.h:17
@ dsSurpriseRemoved
Definition: serenum.h:22
@ dsStopped
Definition: serenum.h:18
@ dsPaused
Definition: serenum.h:20
@ dsStarted
Definition: serenum.h:19
@ dsRemoved
Definition: serenum.h:21

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegPath 
)

Definition at line 367 of file beep.c.

369{
370 PDEVICE_EXTENSION DeviceExtension;
374
376
377 /* Create the device */
379 sizeof(DEVICE_EXTENSION),
380 &DeviceName,
382 0,
383 FALSE,
384 &DeviceObject);
385 if (!NT_SUCCESS(Status)) return Status;
386
387 /* Make it use buffered I/O */
389
390 /* Setup the Driver Object */
391 DriverObject->MajorFunction[IRP_MJ_CREATE] = BeepCreate;
392 DriverObject->MajorFunction[IRP_MJ_CLOSE] = BeepClose;
393 DriverObject->MajorFunction[IRP_MJ_CLEANUP] = BeepCleanup;
395 DriverObject->DriverUnload = BeepUnload;
396 DriverObject->DriverStartIo = BeepStartIo;
397
398 /* Set up device extension */
399 DeviceExtension = DeviceObject->DeviceExtension;
400 DeviceExtension->ReferenceCount = 0;
401 DeviceExtension->TimerActive = FALSE;
403 KeInitializeTimer(&DeviceExtension->Timer);
404 ExInitializeFastMutex(&DeviceExtension->Mutex);
405
406 /* Page the entire driver */
408 return STATUS_SUCCESS;
409}
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
DRIVER_STARTIO BeepStartIo
Definition: beep.c:295
VOID NTAPI BeepDPC(IN PKDPC Dpc, IN PDEVICE_OBJECT DeviceObject, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: beep.c:34
DRIVER_DISPATCH BeepClose
Definition: beep.c:78
DRIVER_DISPATCH BeepCleanup
Definition: beep.c:145
DRIVER_UNLOAD BeepUnload
Definition: beep.c:268
DRIVER_DISPATCH BeepCreate
Definition: beep.c:52
DRIVER_DISPATCH BeepDeviceControl
Definition: beep.c:206
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
Status
Definition: gdiplustypes.h:25
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
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 L(x)
Definition: ntvdm.h:50
#define FILE_DEVICE_BEEP
Definition: winioctl.h:46
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_SUCCESS
Definition: shellext.h:65
FAST_MUTEX Mutex
Definition: beep.c:24
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
Definition: sysldr.c:3557
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
FORCEINLINE VOID IoInitializeDpcRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIO_DPC_ROUTINE DpcRoutine)
Definition: iofuncs.h:2840
IO_DPC_ROUTINE * PIO_DPC_ROUTINE
Definition: iotypes.h:2847
#define IRP_MJ_CLEANUP

◆ DuplicateUnicodeString()

NTSTATUS DuplicateUnicodeString ( IN ULONG  Flags,
IN PCUNICODE_STRING  SourceString,
OUT PUNICODE_STRING  DestinationString 
)

Definition at line 31 of file misc.c.

35{
40 {
42 }
43
44
45 if ((SourceString->Length == 0)
48 {
52 }
53 else
54 {
55 USHORT DestMaxLength = SourceString->Length;
56
58 DestMaxLength += sizeof(UNICODE_NULL);
59
62 return STATUS_NO_MEMORY;
63
66 DestinationString->MaximumLength = DestMaxLength;
67
70 }
71
72 return STATUS_SUCCESS;
73}
#define NULL
Definition: types.h:112
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING
Definition: green.h:16
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
#define I8042PRT_TAG
Definition: i8042prt.h:12
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1922
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1921
#define UNICODE_NULL
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
unsigned short USHORT
Definition: pedump.c:61
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
unsigned short MaximumLength
Definition: sprintf.c:452
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ ForwardIrpAndForget()

NTSTATUS NTAPI ForwardIrpAndForget ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 18 of file misc.c.

21{
22 PDEVICE_OBJECT LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
23
24 ASSERT(LowerDevice);
25
27 return IoCallDriver(LowerDevice, Irp);
28}
_In_ PIRP Irp
Definition: csq.h:116
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define ASSERT(a)
Definition: mode.c:44
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCallDriver
Definition: irp.c:1225

◆ ForwardIrpAndWait()

NTSTATUS ForwardIrpAndWait ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

◆ ForwardIrpToAttachedFdoAndForget()

NTSTATUS NTAPI ForwardIrpToAttachedFdoAndForget ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 108 of file misc.c.

111{
112 PPDO_DEVICE_EXTENSION DeviceExtension;
114
115 DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
116 ASSERT(!DeviceExtension->Common.IsFDO);
117
118 Fdo = DeviceExtension->AttachedFdo;
119 ASSERT(Fdo);
120 TRACE_(SERENUM, "Calling attached Fdo 0x%p\n", Fdo);
122 return IoCallDriver(Fdo, Irp);
123}
#define TRACE_(x)
Definition: compat.h:76
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:59
PDEVICE_OBJECT AttachedFdo
Definition: parport.h:59
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461

Referenced by IrpStub(), and SerenumPdoPnp().

◆ ForwardIrpToLowerDeviceAndForget()

NTSTATUS NTAPI ForwardIrpToLowerDeviceAndForget ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 90 of file misc.c.

93{
94 PFDO_DEVICE_EXTENSION DeviceExtension;
95 PDEVICE_OBJECT LowerDevice;
96
97 DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
98 ASSERT(DeviceExtension->Common.IsFDO);
99
100 LowerDevice = DeviceExtension->LowerDevice;
101 ASSERT(LowerDevice);
102 TRACE_(SERENUM, "Calling lower device 0x%p\n", LowerDevice);
104 return IoCallDriver(LowerDevice, Irp);
105}
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:84

Referenced by IrpStub().

◆ SerenumDetectLegacyDevice()

NTSTATUS SerenumDetectLegacyDevice ( IN PDEVICE_OBJECT  DeviceObject,
IN PDEVICE_OBJECT  LowerDevice 
)

Definition at line 444 of file detect.c.

447{
449 ULONG Fcr, Mcr;
450 ULONG BaudRate;
452 SERIAL_TIMEOUTS Timeouts;
454 ULONG i, Count = 0;
455 UCHAR Buffer[16];
457 UNICODE_STRING DeviceId;
459 UNICODE_STRING HardwareIds;
460 UNICODE_STRING CompatibleIds;
462
463 TRACE_(SERENUM, "SerenumDetectLegacyDevice(DeviceObject %p, LowerDevice %p)\n",
465 LowerDevice);
466
467 RtlZeroMemory(Buffer, sizeof(Buffer));
468
469 /* Open port */
471 LowerDevice,
473 NULL,
474 0,
475 NULL,
477 &Handle);
478 if (!NT_SUCCESS(Status)) return Status;
479
480 /* Reset UART */
481 TRACE_(SERENUM, "Reset UART\n");
482 Mcr = 0; /* MCR: DTR/RTS/OUT2 off */
484 &Mcr, sizeof(Mcr), NULL, NULL);
485 if (!NT_SUCCESS(Status)) goto ByeBye;
486
487 /* Set communications parameters */
488 TRACE_(SERENUM, "Set communications parameters\n");
489 /* DLAB off */
490 Fcr = 0;
492 &Fcr, sizeof(Fcr), NULL, NULL);
493 if (!NT_SUCCESS(Status)) goto ByeBye;
494 /* Set serial port speed */
495 BaudRate = 1200;
497 &BaudRate, sizeof(BaudRate), NULL, NULL);
498 if (!NT_SUCCESS(Status)) goto ByeBye;
499 /* Set LCR */
500 LCR.WordLength = 7;
501 LCR.Parity = NO_PARITY;
502 LCR.StopBits = STOP_BITS_2;
504 &LCR, sizeof(LCR), NULL, NULL);
505 if (!NT_SUCCESS(Status)) goto ByeBye;
506
507 /* Flush receive buffer */
508 TRACE_(SERENUM, "Flush receive buffer\n");
511 &Command, sizeof(Command), NULL, NULL);
512 if (!NT_SUCCESS(Status)) goto ByeBye;
513 /* Wait 100 ms */
514 Wait(100);
515
516 /* Enable DTR/RTS */
517 TRACE_(SERENUM, "Enable DTR/RTS\n");
519 NULL, 0, NULL, NULL);
520 if (!NT_SUCCESS(Status)) goto ByeBye;
522 NULL, 0, NULL, NULL);
523 if (!NT_SUCCESS(Status)) goto ByeBye;
524
525 /* Set timeout to 500 microseconds */
526 TRACE_(SERENUM, "Set timeout to 500 microseconds\n");
527 Timeouts.ReadIntervalTimeout = 100;
528 Timeouts.ReadTotalTimeoutMultiplier = 0;
529 Timeouts.ReadTotalTimeoutConstant = 500;
532 &Timeouts, sizeof(Timeouts), NULL, NULL);
533 if (!NT_SUCCESS(Status)) goto ByeBye;
534
535 /* Fill the read buffer */
536 TRACE_(SERENUM, "Fill the read buffer\n");
537 Status = ReadBytes(LowerDevice, Buffer, sizeof(Buffer)/sizeof(Buffer[0]), (PVOID)&Count);
538 if (!NT_SUCCESS(Status)) goto ByeBye;
539
540 RtlInitUnicodeString(&DeviceId, L"Serenum\\Mouse");
541 RtlInitUnicodeString(&InstanceId, L"0000"); /* FIXME */
542 for (i = 0; i < Count; i++)
543 {
544 if (Buffer[i] == 'B')
545 {
546 /* Sign for Microsoft Ballpoint */
547 /* Hardware id: *PNP0F09
548 * Compatible id: *PNP0F0F, SERIAL_MOUSE
549 */
550 RtlInitUnicodeString(&DeviceDescription, L"Microsoft Ballpoint device");
551 SerenumInitMultiSzString(&HardwareIds, "*PNP0F09", NULL);
552 SerenumInitMultiSzString(&CompatibleIds, "*PNP0F0F", "SERIAL_MOUSE", NULL);
554 &DeviceDescription, &DeviceId, &InstanceId, &HardwareIds, &CompatibleIds);
555 RtlFreeUnicodeString(&HardwareIds);
556 RtlFreeUnicodeString(&CompatibleIds);
557 goto ByeBye;
558 }
559 else if (Buffer[i] == 'M')
560 {
561 /* Sign for Microsoft Mouse protocol followed by button specifier */
562 if (i == sizeof(Buffer) - 1)
563 {
564 /* Overflow Error */
566 goto ByeBye;
567 }
568 switch (Buffer[i + 1])
569 {
570 case '3':
571 /* Hardware id: *PNP0F08
572 * Compatible id: SERIAL_MOUSE
573 */
574 RtlInitUnicodeString(&DeviceDescription, L"Microsoft Mouse with 3-buttons");
575 SerenumInitMultiSzString(&HardwareIds, "*PNP0F08", NULL);
576 SerenumInitMultiSzString(&CompatibleIds, "SERIAL_MOUSE", NULL);
577 break;
578 default:
579 /* Hardware id: *PNP0F01
580 * Compatible id: SERIAL_MOUSE
581 */
582 RtlInitUnicodeString(&DeviceDescription, L"Microsoft Mouse with 2-buttons or Microsoft Wheel Mouse");
583 SerenumInitMultiSzString(&HardwareIds, "*PNP0F01", NULL);
584 SerenumInitMultiSzString(&CompatibleIds, "SERIAL_MOUSE", NULL);
585 break;
586 }
588 &DeviceDescription, &DeviceId, &InstanceId, &HardwareIds, &CompatibleIds);
589 RtlFreeUnicodeString(&HardwareIds);
590 RtlFreeUnicodeString(&CompatibleIds);
591 goto ByeBye;
592 }
593 }
594
596
597ByeBye:
598 /* Close port */
599 if (Handle)
601 return Status;
602}
Definition: bufpool.h:45
static NTSTATUS DeviceIoControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG CtlCode, IN PVOID InputBuffer OPTIONAL, IN SIZE_T InputBufferSize, IN OUT PVOID OutputBuffer OPTIONAL, IN OUT PSIZE_T OutputBufferSize)
Definition: detect.c:19
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
NTSTATUS SerenumInitMultiSzString(OUT PUNICODE_STRING Destination,...)
Definition: misc.c:18
ULONG ReportDetectedDevice
Definition: ramdisk.c:117
_Must_inspect_result_ _In_opt_ PVOID _In_opt_ PVOID InstanceId
Definition: fsrtlfuncs.h:908
ULONG Handle
Definition: gdb_input.c:15
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 OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define STOP_BITS_2
Definition: serial.c:87
#define SERIAL_PURGE_RXCLEAR
Definition: serial.c:96
#define NO_PARITY
Definition: serial.c:89
#define KernelMode
Definition: asm.h:34
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
int Count
Definition: noreturn.cpp:7
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define IOCTL_SERIAL_SET_LINE_CONTROL
Definition: ntddser.h:96
#define IOCTL_SERIAL_SET_TIMEOUTS
Definition: ntddser.h:104
#define IOCTL_SERIAL_SET_MODEM_CONTROL
Definition: ntddser.h:98
#define IOCTL_SERIAL_SET_FIFO_CONTROL
Definition: ntddser.h:92
#define IOCTL_SERIAL_SET_BAUD_RATE
Definition: ntddser.h:82
#define IOCTL_SERIAL_SET_DTR
Definition: ntddser.h:90
#define IOCTL_SERIAL_SET_RTS
Definition: ntddser.h:102
NTSTATUS NTAPI ObOpenObjectByPointer(IN PVOID Object, IN ULONG HandleAttributes, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PHANDLE Handle)
Definition: obhandle.c:2742
Definition: shell.h:41
ULONG WriteTotalTimeoutMultiplier
Definition: ntddser.h:306
ULONG ReadTotalTimeoutConstant
Definition: ntddser.h:305
ULONG WriteTotalTimeoutConstant
Definition: ntddser.h:307
ULONG ReadTotalTimeoutMultiplier
Definition: ntddser.h:304
ULONG ReadIntervalTimeout
Definition: ntddser.h:303
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:432
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by SerenumFdoQueryBusRelations().

◆ SerenumDetectPnpDevice()

NTSTATUS SerenumDetectPnpDevice ( IN PDEVICE_OBJECT  DeviceObject,
IN PDEVICE_OBJECT  LowerDevice 
)

Definition at line 223 of file detect.c.

226{
228 UCHAR Buffer[256];
229 ULONG BaudRate;
230 ULONG_PTR TotalBytesReceived = 0;
232 ULONG Msr, Purge;
233 ULONG i;
234 BOOLEAN BufferContainsBeginId = FALSE;
235 BOOLEAN BufferContainsEndId = FALSE;
237 SERIAL_TIMEOUTS Timeouts;
238 SERIALPERF_STATS PerfStats;
240
241 /* Open port */
243 LowerDevice,
245 NULL,
246 0,
247 NULL,
249 &Handle);
250 if (!NT_SUCCESS(Status)) goto ByeBye;
251
252 /* 1. COM port initialization, check for device enumerate */
253 TRACE_(SERENUM, "COM port initialization, check for device enumerate\n");
255 NULL, 0, NULL, NULL);
256 if (!NT_SUCCESS(Status)) goto ByeBye;
258 NULL, 0, NULL, NULL);
259 if (!NT_SUCCESS(Status)) goto ByeBye;
260 Wait(200);
261 Size = sizeof(Msr);
263 NULL, 0, &Msr, &Size);
264 if (!NT_SUCCESS(Status)) goto ByeBye;
265 if ((Msr & SERIAL_DSR_STATE) == 0) goto DisconnectIdle;
266
267 /* 2. COM port setup, 1st phase */
268 TRACE_(SERENUM, "COM port setup, 1st phase\n");
269 BaudRate = 1200;
271 &BaudRate, sizeof(BaudRate), NULL, 0);
272 if (!NT_SUCCESS(Status)) goto ByeBye;
273 Lcr.WordLength = 7;
274 Lcr.Parity = NO_PARITY;
275 Lcr.StopBits = STOP_BIT_1;
277 &Lcr, sizeof(Lcr), NULL, NULL);
278 if (!NT_SUCCESS(Status)) goto ByeBye;
280 NULL, 0, NULL, NULL);
281 if (!NT_SUCCESS(Status)) goto ByeBye;
283 NULL, 0, NULL, NULL);
284 if (!NT_SUCCESS(Status)) goto ByeBye;
285 Wait(200);
287 NULL, 0, NULL, NULL);
288 if (!NT_SUCCESS(Status)) goto ByeBye;
289 Wait(200);
290
291 /* 3. Wait for response, 1st phase */
292 TRACE_(SERENUM, "Wait for response, 1st phase\n");
294 NULL, 0, NULL, NULL);
295 if (!NT_SUCCESS(Status)) goto ByeBye;
296 Timeouts.ReadIntervalTimeout = 0;
297 Timeouts.ReadTotalTimeoutMultiplier = 0;
298 Timeouts.ReadTotalTimeoutConstant = 200;
301 &Timeouts, sizeof(Timeouts), NULL, NULL);
302 if (!NT_SUCCESS(Status)) goto ByeBye;
303 Status = ReadBytes(LowerDevice, Buffer, sizeof(Buffer), &Size);
304 if (!NT_SUCCESS(Status)) goto ByeBye;
305 if (Size != 0) goto CollectPnpComDeviceId;
306
307 /* 4. COM port setup, 2nd phase */
308 TRACE_(SERENUM, "COM port setup, 2nd phase\n");
310 NULL, 0, NULL, NULL);
311 if (!NT_SUCCESS(Status)) goto ByeBye;
313 NULL, 0, NULL, NULL);
314 if (!NT_SUCCESS(Status)) goto ByeBye;
317 &Purge, sizeof(ULONG), NULL, NULL);
318 if (!NT_SUCCESS(Status)) goto ByeBye;
319 Wait(200);
320
321 /* 5. Wait for response, 2nd phase */
322 TRACE_(SERENUM, "Wait for response, 2nd phase\n");
324 NULL, 0, NULL, NULL);
325 if (!NT_SUCCESS(Status)) goto ByeBye;
327 NULL, 0, NULL, NULL);
328 if (!NT_SUCCESS(Status)) goto ByeBye;
329 Status = ReadBytes(LowerDevice, Buffer, 1, &TotalBytesReceived);
330 if (!NT_SUCCESS(Status)) goto ByeBye;
331 if (TotalBytesReceived != 0) goto CollectPnpComDeviceId;
332 Size = sizeof(Msr);
334 NULL, 0, &Msr, &Size);
335 if (!NT_SUCCESS(Status)) goto ByeBye;
336 if ((Msr & SERIAL_DSR_STATE) == 0) goto VerifyDisconnect; else goto ConnectIdle;
337
338 /* 6. Collect PnP COM device ID */
339CollectPnpComDeviceId:
340 TRACE_(SERENUM, "Collect PnP COM device ID\n");
341 Timeouts.ReadIntervalTimeout = 200;
342 Timeouts.ReadTotalTimeoutMultiplier = 0;
343 Timeouts.ReadTotalTimeoutConstant = 2200;
345 &Timeouts, sizeof(Timeouts), NULL, NULL);
346 if (!NT_SUCCESS(Status)) goto ByeBye;
347 Status = ReadBytes(LowerDevice, &Buffer[TotalBytesReceived], sizeof(Buffer) - TotalBytesReceived, &Size);
348 if (!NT_SUCCESS(Status)) goto ByeBye;
349 TotalBytesReceived += Size;
350 Size = sizeof(PerfStats);
352 NULL, 0, &PerfStats, &Size);
353 if (!NT_SUCCESS(Status)) goto ByeBye;
354 if (PerfStats.FrameErrorCount + PerfStats.ParityErrorCount != 0) goto ConnectIdle;
355 for (i = 0; i < TotalBytesReceived; i++)
356 {
357 if (Buffer[i] == BEGIN_ID) BufferContainsBeginId = TRUE;
358 if (Buffer[i] == END_ID) BufferContainsEndId = TRUE;
359 }
360 if (TotalBytesReceived == 1 || BufferContainsEndId)
361 {
362 if (IsValidPnpIdString(Buffer, TotalBytesReceived))
363 {
364 Status = ReportDetectedPnpDevice(Buffer, TotalBytesReceived);
365 goto ByeBye;
366 }
367 goto ConnectIdle;
368 }
369 if (!BufferContainsBeginId) goto ConnectIdle;
370 if (!BufferContainsEndId) goto ConnectIdle;
371 Size = sizeof(Msr);
373 NULL, 0, &Msr, &Size);
374 if (!NT_SUCCESS(Status)) goto ByeBye;
375 if ((Msr & SERIAL_DSR_STATE) == 0) goto VerifyDisconnect;
376
377 /* 7. Verify disconnect */
378VerifyDisconnect:
379 TRACE_(SERENUM, "Verify disconnect\n");
381 NULL, 0, NULL, NULL);
382 if (!NT_SUCCESS(Status)) goto ByeBye;
384 NULL, 0, NULL, NULL);
385 if (!NT_SUCCESS(Status)) goto ByeBye;
386 Wait(5000);
387 goto DisconnectIdle;
388
389 /* 8. Connect idle */
390ConnectIdle:
391 TRACE_(SERENUM, "Connect idle\n");
393 NULL, 0, NULL, NULL);
394 if (!NT_SUCCESS(Status)) goto ByeBye;
396 NULL, 0, NULL, NULL);
397 if (!NT_SUCCESS(Status)) goto ByeBye;
398 BaudRate = 300;
400 &BaudRate, sizeof(BaudRate), NULL, NULL);
401 if (!NT_SUCCESS(Status)) goto ByeBye;
402 Lcr.WordLength = 7;
403 Lcr.Parity = NO_PARITY;
404 Lcr.StopBits = STOP_BIT_1;
406 &Lcr, sizeof(Lcr), NULL, NULL);
407 if (!NT_SUCCESS(Status)) goto ByeBye;
408 if (TotalBytesReceived == 0)
410 else
412 goto ByeBye;
413
414 /* 9. Disconnect idle */
415DisconnectIdle:
416 TRACE_(SERENUM, "Disconnect idle\n");
417 /* FIXME: report to OS device removal, if it was present */
419 NULL, 0, NULL, NULL);
420 if (!NT_SUCCESS(Status)) goto ByeBye;
422 NULL, 0, NULL, NULL);
423 if (!NT_SUCCESS(Status)) goto ByeBye;
424 BaudRate = 300;
426 &BaudRate, sizeof(BaudRate), NULL, NULL);
427 if (!NT_SUCCESS(Status)) goto ByeBye;
428 Lcr.WordLength = 7;
429 Lcr.Parity = NO_PARITY;
430 Lcr.StopBits = STOP_BIT_1;
432 &Lcr, sizeof(Lcr), NULL, NULL);
433 if (!NT_SUCCESS(Status)) goto ByeBye;
435
436ByeBye:
437 /* Close port */
438 if (Handle)
440 return Status;
441}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
static NTSTATUS ReportDetectedPnpDevice(IN PUCHAR Buffer, IN ULONG BufferLength)
Definition: detect.c:191
static BOOLEAN IsValidPnpIdString(IN PUCHAR Buffer, IN ULONG BufferLength)
Definition: detect.c:176
#define BEGIN_ID
Definition: detect.c:206
#define END_ID
Definition: detect.c:207
#define SERIAL_PURGE_RXABORT
Definition: serial.c:94
#define STOP_BIT_1
Definition: ntddser.h:215
#define SERIAL_DSR_STATE
Definition: ntddser.h:430
#define IOCTL_SERIAL_GET_STATS
Definition: ntddser.h:68
#define IOCTL_SERIAL_CLR_DTR
Definition: ntddser.h:44
#define IOCTL_SERIAL_CLR_RTS
Definition: ntddser.h:46
#define IOCTL_SERIAL_GET_MODEMSTATUS
Definition: ntddser.h:64
#define IOCTL_SERIAL_PURGE
Definition: ntddser.h:78
ULONG ParityErrorCount
Definition: ntddser.h:299
ULONG FrameErrorCount
Definition: ntddser.h:296
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by SerenumFdoQueryBusRelations().

◆ SerenumFdoPnp()

NTSTATUS SerenumFdoPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 152 of file fdo.c.

155{
161
163 MinorFunction = Stack->MinorFunction;
164
165 switch (MinorFunction)
166 {
167 /* FIXME: do all these minor functions
168 IRP_MN_QUERY_REMOVE_DEVICE 0x1
169 IRP_MN_REMOVE_DEVICE 0x2
170 IRP_MN_CANCEL_REMOVE_DEVICE 0x3
171 IRP_MN_STOP_DEVICE 0x4
172 IRP_MN_QUERY_STOP_DEVICE 0x5
173 IRP_MN_CANCEL_STOP_DEVICE 0x6
174 IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations (optional) 0x7
175 IRP_MN_QUERY_INTERFACE (optional) 0x8
176 IRP_MN_QUERY_CAPABILITIES (optional) 0x9
177 IRP_MN_QUERY_PNP_DEVICE_STATE (optional) 0x14
178 IRP_MN_DEVICE_USAGE_NOTIFICATION (required or optional) 0x16
179 IRP_MN_SURPRISE_REMOVAL 0x17
180 */
181 case IRP_MN_START_DEVICE: /* 0x0 */
182 {
183 TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
184 /* Call lower driver */
185 FdoExtension = DeviceObject->DeviceExtension;
187
188 if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
189 {
190 Status = Irp->IoStatus.Status;
191 if (NT_SUCCESS(Status))
192 {
194 }
195 }
196
197 break;
198 }
199 case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */
200 {
201 switch (Stack->Parameters.QueryDeviceRelations.Type)
202 {
203 case BusRelations:
204 {
205 PDEVICE_RELATIONS DeviceRelations = NULL;
206 TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
208 Information = (ULONG_PTR)DeviceRelations;
209 break;
210 }
211 default:
212 TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
213 Stack->Parameters.QueryDeviceRelations.Type);
215 }
216 break;
217 }
219 {
220 TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
222 }
223 default:
224 {
225 TRACE_(SERENUM, "IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction);
227 }
228 }
229
230 Irp->IoStatus.Information = Information;
231 Irp->IoStatus.Status = Status;
233 return Status;
234}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define ULONG_PTR
Definition: config.h:101
@ FdoExtension
Definition: precomp.h:48
DRIVER_DISPATCH ForwardIrpAndForget
Definition: i8042prt.h:341
#define IoCompleteRequest
Definition: irp.c:1240
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1625
static NTSTATUS SerenumFdoQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: fdo.c:102
static NTSTATUS NTAPI SerenumFdoStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:77
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1699
_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_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_DEVICE_RELATIONS

Referenced by SerenumPnp().

◆ SerenumInitMultiSzString()

NTSTATUS SerenumInitMultiSzString ( OUT PUNICODE_STRING  Destination,
  ... 
)

Definition at line 18 of file misc.c.

21{
26 ULONG DestinationSize = 0;
28
30
31 /* Calculate length needed for destination unicode string */
34 while (Source != NULL)
35 {
37 DestinationSize += RtlAnsiStringToUnicodeSize(&AnsiString)
38 + sizeof(WCHAR) /* final NULL */;
40 }
41 va_end(args);
42 if (DestinationSize == 0)
43 {
45 return STATUS_SUCCESS;
46 }
47
48 /* Initialize destination string */
49 DestinationSize += sizeof(WCHAR); // final NULL
51 if (!Destination->Buffer)
54 Destination->MaximumLength = (USHORT)DestinationSize;
55
56 /* Copy arguments to destination string */
57 /* Use a temporary unicode string, which buffer is shared with
58 * destination string, to copy arguments */
64 while (Source != NULL)
65 {
68 if (!NT_SUCCESS(Status))
69 {
71 break;
72 }
73 Destination->Length += UnicodeString.Length + sizeof(WCHAR);
74 UnicodeString.MaximumLength -= UnicodeString.Length + sizeof(WCHAR);
75 UnicodeString.Buffer += UnicodeString.Length / sizeof(WCHAR) + 1;
76 UnicodeString.Length = 0;
78 }
79 va_end(args);
80 if (NT_SUCCESS(Status))
81 {
82 /* Finish multi-sz string */
83 Destination->Buffer[Destination->Length / sizeof(WCHAR)] = L'\0';
84 Destination->Length += sizeof(WCHAR);
85 }
86 return Status;
87}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define va_arg(ap, T)
Definition: acmsvcex.h:89
@ AnsiString
Definition: dnslib.h:19
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3016
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define RtlAnsiStringToUnicodeSize(STRING)
Definition: nt_native.h:404
#define args
Definition: format.c:66
#define SERENUM_TAG
Definition: serenum.h:58
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: match.c:390
uint16_t * PWSTR
Definition: typedefs.h:56
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
CONST char * PCSZ
Definition: umtypes.h:125

Referenced by SerenumDetectLegacyDevice().

◆ SerenumPdoPnp()

NTSTATUS SerenumPdoPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 109 of file pdo.c.

112{
117
119 MinorFunction = Stack->MinorFunction;
120
121 switch (MinorFunction)
122 {
123 /* FIXME: do all these minor functions
124 IRP_MN_QUERY_REMOVE_DEVICE 0x1
125 IRP_MN_REMOVE_DEVICE 0x2
126 IRP_MN_CANCEL_REMOVE_DEVICE 0x3
127 IRP_MN_STOP_DEVICE 0x4
128 IRP_MN_QUERY_STOP_DEVICE 0x5
129 IRP_MN_CANCEL_STOP_DEVICE 0x6
130 IRP_MN_QUERY_DEVICE_RELATIONS / EjectionRelations (optional) 0x7
131 IRP_MN_QUERY_INTERFACE (required or optional) 0x8
132 IRP_MN_READ_CONFIG (required or optional) 0xf
133 IRP_MN_WRITE_CONFIG (required or optional) 0x10
134 IRP_MN_EJECT (required or optional) 0x11
135 IRP_MN_SET_LOCK (required or optional) 0x12
136 IRP_MN_QUERY_ID / BusQueryDeviceID 0x13
137 IRP_MN_QUERY_ID / BusQueryCompatibleIDs (optional) 0x13
138 IRP_MN_QUERY_ID / BusQueryInstanceID (optional) 0x13
139 IRP_MN_QUERY_PNP_DEVICE_STATE (optional) 0x14
140 IRP_MN_DEVICE_USAGE_NOTIFICATION (required or optional) 0x16
141 IRP_MN_SURPRISE_REMOVAL 0x17
142 */
143 case IRP_MN_START_DEVICE: /* 0x0 */
144 {
145 TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
147 break;
148 }
149 case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */
150 {
151 switch (Stack->Parameters.QueryDeviceRelations.Type)
152 {
153 case RemovalRelations:
154 {
156 }
158 {
159 PDEVICE_RELATIONS DeviceRelations = NULL;
160 TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / TargetDeviceRelation\n");
162 Information = (ULONG_PTR)DeviceRelations;
163 break;
164 }
165 default:
166 {
167 WARN_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
168 Stack->Parameters.QueryDeviceRelations.Type);
169 ASSERT(FALSE);
171 break;
172 }
173 }
174 break;
175 }
176 case IRP_MN_QUERY_CAPABILITIES: /* 0x9 */
177 {
179 ULONG i;
180 TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
181
182 DeviceCapabilities = (PDEVICE_CAPABILITIES)Stack->Parameters.DeviceCapabilities.Capabilities;
183 /* FIXME: capabilities can change with connected device */
184 DeviceCapabilities->LockSupported = FALSE;
185 DeviceCapabilities->EjectSupported = FALSE;
186 DeviceCapabilities->Removable = TRUE;
187 DeviceCapabilities->DockDevice = FALSE;
188 DeviceCapabilities->UniqueID = FALSE;
189 DeviceCapabilities->SilentInstall = FALSE;
190 DeviceCapabilities->RawDeviceOK = TRUE;
191 DeviceCapabilities->SurpriseRemovalOK = TRUE;
192 DeviceCapabilities->HardwareDisabled = FALSE; /* FIXME */
193 //DeviceCapabilities->NoDisplayInUI = FALSE; /* FIXME */
194 DeviceCapabilities->DeviceState[0] = PowerDeviceD0; /* FIXME */
195 for (i = 0; i < PowerSystemMaximum; i++)
196 DeviceCapabilities->DeviceState[i] = PowerDeviceD3; /* FIXME */
197 //DeviceCapabilities->DeviceWake = PowerDeviceUndefined; /* FIXME */
198 DeviceCapabilities->D1Latency = 0; /* FIXME */
199 DeviceCapabilities->D2Latency = 0; /* FIXME */
200 DeviceCapabilities->D3Latency = 0; /* FIXME */
202 break;
203 }
204 case IRP_MN_QUERY_RESOURCES: /* 0xa */
205 {
206 TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_RESOURCES\n");
207 /* Serial devices don't need resources, except the ones of
208 * the serial port. This PDO is the serial device PDO, so
209 * report no resource by not changing Information and
210 * Status
211 */
212 Information = Irp->IoStatus.Information;
213 Status = Irp->IoStatus.Status;
214 break;
215 }
217 {
218 TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
219 /* Serial devices don't need resources, except the ones of
220 * the serial port. This PDO is the serial device PDO, so
221 * report no resource by not changing Information and
222 * Status
223 */
224 Information = Irp->IoStatus.Information;
225 Status = Irp->IoStatus.Status;
226 break;
227 }
228 case IRP_MN_QUERY_DEVICE_TEXT: /* 0xc */
229 {
230 switch (Stack->Parameters.QueryDeviceText.DeviceTextType)
231 {
233 {
236 TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
237
238 Source = &((PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->DeviceDescription;
240 if (!Description)
242 else
243 {
244 RtlCopyMemory(Description, Source->Buffer, Source->Length);
245 Description[Source->Length / sizeof(WCHAR)] = L'\0';
248 }
249 break;
250 }
252 {
253 /* We don't have any text location to report,
254 * and this query is optional, so ignore it.
255 */
256 Information = Irp->IoStatus.Information;
257 Status = Irp->IoStatus.Status;
258 break;
259 }
260 default:
261 {
262 WARN_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown type 0x%lx\n",
263 Stack->Parameters.QueryDeviceText.DeviceTextType);
264 ASSERT(FALSE);
266 }
267 }
268 break;
269 }
271 {
273 }
274 case IRP_MN_QUERY_ID: /* 0x13 */
275 {
277 break;
278 }
279 case IRP_MN_QUERY_BUS_INFORMATION: /* 0x15 */
280 {
281 PPNP_BUS_INFORMATION BusInfo;
282 TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_BUS_INFORMATION\n");
283
285 if (!BusInfo)
287 else
288 {
289 memcpy(
290 &BusInfo->BusTypeGuid,
291 &GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR,
292 sizeof(BusInfo->BusTypeGuid));
293 BusInfo->LegacyBusType = PNPBus;
294 /* We're the only serial bus enumerator on the computer */
295 BusInfo->BusNumber = 0;
296 Information = (ULONG_PTR)BusInfo;
298 }
299 break;
300 }
301 default:
302 {
303 /* We can't forward request to the lower driver, because
304 * we are a Pdo, so we don't have lower driver... */
305 WARN_(SERENUM, "IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction);
306 ASSERT(FALSE);
307 Information = Irp->IoStatus.Information;
308 Status = Irp->IoStatus.Status;
309 }
310 }
311
312 Irp->IoStatus.Information = Information;
313 Irp->IoStatus.Status = Status;
315 return Status;
316}
static const WCHAR Description[]
Definition: oid.c:1266
NTSTATUS NTAPI ForwardIrpToAttachedFdoAndForget(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: misc.c:108
@ PNPBus
Definition: hwresource.cpp:152
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define for
Definition: utility.h:88
@ PowerSystemMaximum
Definition: ntpoapi.h:42
@ PowerDeviceD0
Definition: ntpoapi.h:49
@ PowerDeviceD3
Definition: ntpoapi.h:52
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define WARN_(ch,...)
Definition: debug.h:157
static NTSTATUS SerenumPdoQueryId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, OUT ULONG_PTR *Information)
Definition: pdo.c:29
static NTSTATUS SerenumPdoQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: pdo.c:83
static NTSTATUS SerenumPdoStartDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: pdo.c:15
INTERFACE_TYPE LegacyBusType
Definition: cmtypes.h:365
#define DeviceCapabilities
Definition: wingdi.h:4449
struct _PNP_BUS_INFORMATION * PPNP_BUS_INFORMATION
@ RemovalRelations
Definition: iotypes.h:2155
@ TargetDeviceRelation
Definition: iotypes.h:2156
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_ID
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_CAPABILITIES
#define IRP_MN_QUERY_RESOURCES
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965
@ DeviceTextLocationInformation
Definition: iotypes.h:2946
@ DeviceTextDescription
Definition: iotypes.h:2945
#define IRP_MN_QUERY_BUS_INFORMATION

Referenced by SerenumPnp().

Variable Documentation

◆ SerenumAddDevice

DRIVER_ADD_DEVICE SerenumAddDevice

Definition at line 77 of file serenum.h.

Referenced by DriverEntry().