ReactOS  0.4.13-dev-455-g28ed234
green.h File Reference
#include <ntddk.h>
#include <ntifs.h>
#include <ntndk.h>
#include <windef.h>
#include <ntddser.h>
#include <kbdmou.h>
#include <wincon.h>
#include <drivers/blue/ntddblue.h>
Include dependency graph for green.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  _COMMON_FDO_DEVICE_EXTENSION
 
struct  _KEYBOARD_DEVICE_EXTENSION
 
struct  _SCREEN_DEVICE_EXTENSION
 
struct  _GREEN_DEVICE_EXTENSION
 
struct  _GREEN_DRIVER_EXTENSION
 

Macros

#define WINBASEAPI
 
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE   1
 
#define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING   2
 
#define INFINITE   -1
 
#define KEYBOARD_BUFFER_SIZE   100
 

Typedefs

typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
 
typedef struct _SECURITY_ATTRIBUTESPSECURITY_ATTRIBUTES
 
typedef struct _COMMON_DEVICE_EXTENSION COMMON_DEVICE_EXTENSION
 
typedef struct _COMMON_DEVICE_EXTENSIONPCOMMON_DEVICE_EXTENSION
 
typedef struct _COMMON_FDO_DEVICE_EXTENSION COMMON_FDO_DEVICE_EXTENSION
 
typedef struct _COMMON_FDO_DEVICE_EXTENSIONPCOMMON_FDO_DEVICE_EXTENSION
 
typedef struct _KEYBOARD_DEVICE_EXTENSION KEYBOARD_DEVICE_EXTENSION
 
typedef struct _KEYBOARD_DEVICE_EXTENSIONPKEYBOARD_DEVICE_EXTENSION
 
typedef struct _SCREEN_DEVICE_EXTENSION SCREEN_DEVICE_EXTENSION
 
typedef struct _SCREEN_DEVICE_EXTENSIONPSCREEN_DEVICE_EXTENSION
 
typedef struct _GREEN_DEVICE_EXTENSION GREEN_DEVICE_EXTENSION
 
typedef struct _GREEN_DEVICE_EXTENSIONPGREEN_DEVICE_EXTENSION
 
typedef struct _GREEN_DRIVER_EXTENSION GREEN_DRIVER_EXTENSION
 
typedef struct _GREEN_DRIVER_EXTENSIONPGREEN_DRIVER_EXTENSION
 

Enumerations

enum  GREEN_DEVICE_TYPE {
  GreenPDO, ScreenPDO, KeyboardPDO, GreenFDO,
  ScreenFDO, KeyboardFDO, PassThroughFDO
}
 

Functions

NTSTATUS GreenCreate (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS GreenClose (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI GreenDispatch (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS KeyboardAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
 
NTSTATUS KeyboardInternalDeviceControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
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)
 
NTSTATUS ReadRegistryEntries (IN PUNICODE_STRING RegistryPath, IN PGREEN_DRIVER_EXTENSION DriverExtension)
 
NTSTATUS NTAPI GreenAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
 
NTSTATUS GreenPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS GreenPower (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS ScreenAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
 
NTSTATUS ScreenWrite (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS ScreenDeviceControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS GreenDuplicateUnicodeString (IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
 

Macro Definition Documentation

◆ INFINITE

#define INFINITE   -1

Definition at line 18 of file green.h.

◆ KEYBOARD_BUFFER_SIZE

#define KEYBOARD_BUFFER_SIZE   100

Definition at line 19 of file green.h.

◆ RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING

#define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING   2

Definition at line 16 of file green.h.

◆ RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE

#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE   1

Definition at line 15 of file green.h.

◆ WINBASEAPI

#define WINBASEAPI

Definition at line 8 of file green.h.

Typedef Documentation

◆ COMMON_DEVICE_EXTENSION

◆ COMMON_FDO_DEVICE_EXTENSION

◆ GREEN_DEVICE_EXTENSION

◆ GREEN_DRIVER_EXTENSION

◆ KEYBOARD_DEVICE_EXTENSION

◆ PCOMMON_DEVICE_EXTENSION

◆ PCOMMON_FDO_DEVICE_EXTENSION

◆ PGREEN_DEVICE_EXTENSION

◆ PGREEN_DRIVER_EXTENSION

◆ PKEYBOARD_DEVICE_EXTENSION

◆ PSCREEN_DEVICE_EXTENSION

◆ PSECURITY_ATTRIBUTES

Definition at line 9 of file green.h.

◆ SCREEN_DEVICE_EXTENSION

◆ SECURITY_ATTRIBUTES

Definition at line 9 of file green.h.

Enumeration Type Documentation

◆ GREEN_DEVICE_TYPE

Enumerator
GreenPDO 
ScreenPDO 
KeyboardPDO 
GreenFDO 
ScreenFDO 
KeyboardFDO 
PassThroughFDO 

Definition at line 21 of file green.h.

22 {
23  GreenPDO,
24  ScreenPDO,
26  GreenFDO,
27  ScreenFDO,
Definition: green.h:23
Definition: green.h:26
GREEN_DEVICE_TYPE
Definition: green.h:21

Function Documentation

◆ 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:2777

Referenced by DriverEntry().

◆ GreenClose()

NTSTATUS GreenClose ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 28 of file createclose.c.

31 {
32  DPRINT("IRP_MJ_CLOSE\n");
33 
34  Irp->IoStatus.Status = STATUS_SUCCESS;
35  Irp->IoStatus.Information = 0;
37  return STATUS_SUCCESS;
38 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define IO_NO_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by GreenDispatch().

◆ GreenCreate()

NTSTATUS GreenCreate ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 15 of file createclose.c.

18 {
19  DPRINT("IRP_MJ_CREATE\n");
20 
21  Irp->IoStatus.Status = STATUS_SUCCESS;
22  Irp->IoStatus.Information = 0;
24  return STATUS_SUCCESS;
25 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define IO_NO_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by GreenDispatch().

◆ GreenDeviceIoControl()

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 at line 15 of file misc.c.

22 {
23  KEVENT Event;
24  PIRP Irp;
27 
29 
33  InputBufferSize,
35  (OutputBufferSize) ? *OutputBufferSize : 0,
36  FALSE,
37  &Event,
38  &IoStatus);
39  if (Irp == NULL)
40  {
41  DPRINT("IoBuildDeviceIoControlRequest() failed\n");
43  }
44 
46 
47  if (Status == STATUS_PENDING)
48  {
49  DPRINT("Operation pending\n");
51  Status = IoStatus.Status;
52  }
53 
54  if (OutputBufferSize)
55  {
56  *OutputBufferSize = IoStatus.Information;
57  }
58 
59  return Status;
60 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
CHAR InputBuffer[80]
Definition: conmgr.c:33
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
#define STATUS_PENDING
Definition: ntstatus.h:82
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881

Referenced by CreateGreenFdo().

◆ GreenDispatch()

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

Definition at line 15 of file dispatch.c.

18 {
19  ULONG MajorFunction;
23 
26 
27  Information = Irp->IoStatus.Information;
28  Status = Irp->IoStatus.Status;
29 
30  DPRINT("Dispatching major function 0x%lx, DeviceType %u\n",
31  MajorFunction, DeviceType);
32 
34  {
37  }
38  else if (MajorFunction == IRP_MJ_CREATE && (DeviceType == GreenFDO || DeviceType == KeyboardPDO || DeviceType == ScreenPDO))
39  return GreenCreate(DeviceObject, Irp);
40  else if (MajorFunction == IRP_MJ_CLOSE && (DeviceType == GreenFDO || DeviceType == KeyboardPDO || DeviceType == ScreenPDO))
41  return GreenClose(DeviceObject, Irp);
42  else if ((MajorFunction == IRP_MJ_CREATE || MajorFunction == IRP_MJ_CLOSE || MajorFunction == IRP_MJ_CLEANUP)
44  {
47  }
48  else if (MajorFunction == IRP_MJ_INTERNAL_DEVICE_CONTROL && DeviceType == GreenFDO)
49  {
52  Irp);
53  }
54  else if (MajorFunction == IRP_MJ_INTERNAL_DEVICE_CONTROL && DeviceType == KeyboardFDO)
56  else if (MajorFunction == IRP_MJ_DEVICE_CONTROL && DeviceType == GreenFDO)
57  {
58  return ScreenDeviceControl(
60  Irp);
61  }
62  else if (MajorFunction == IRP_MJ_DEVICE_CONTROL && DeviceType == ScreenFDO)
64  else if (MajorFunction == IRP_MJ_WRITE && DeviceType == ScreenFDO)
65  return ScreenWrite(DeviceObject, Irp);
66  else if (MajorFunction == IRP_MJ_PNP && (DeviceType == KeyboardFDO || DeviceType == ScreenFDO))
67  {
70  }
71  else if (MajorFunction == IRP_MJ_PNP && (DeviceType == GreenFDO || DeviceType == KeyboardPDO || DeviceType == ScreenPDO))
72  return GreenPnp(DeviceObject, Irp);
73  else if (MajorFunction == IRP_MJ_POWER && DeviceType == GreenFDO)
74  return GreenPower(DeviceObject, Irp);
75  else
76  {
77  DPRINT1("Unknown combination: MajorFunction 0x%lx, DeviceType %d\n",
78  MajorFunction, DeviceType);
79  switch (DeviceType)
80  {
81  case KeyboardFDO:
82  case ScreenFDO:
83  {
86  }
87  case GreenFDO:
88  {
91  DriverObject = DeviceObject->DriverObject;
94  return IoCallDriver(DriverExtension->LowerDevice, Irp);
95  }
96  default:
97  ASSERT(FALSE);
98  }
99  }
100 
101  Irp->IoStatus.Information = Information;
102  Irp->IoStatus.Status = Status;
104  return Status;
105 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_In_ PIRP Irp
Definition: csq.h:116
DeviceType
Definition: mmdrv.h:41
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
uint32_t ULONG_PTR
Definition: typedefs.h:63
PVOID DeviceExtension
Definition: env_spec_w32.h:418
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS GreenClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: createclose.c:28
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
Definition: green.h:26
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
NTSTATUS ScreenWrite(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: screen.c:265
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IRP_MJ_POWER
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
NTSTATUS ScreenDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: screen.c:408
Status
Definition: gdiplustypes.h:24
NTSTATUS GreenPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: power.c:15
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
NTSTATUS KeyboardInternalDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: keyboard.c:272
NTSTATUS GreenPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pnp.c:408
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
NTSTATUS GreenCreate(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: createclose.c:15
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_CLEANUP
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
Iosb Information
Definition: create.c:4377
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

Referenced by DriverEntry().

◆ GreenDuplicateUnicodeString()

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

Definition at line 71 of file green.c.

75 {
80  {
82  }
83 
84 
85  if ((SourceString->Length == 0)
88  {
92  }
93  else
94  {
95  USHORT DestMaxLength = SourceString->Length;
96 
98  DestMaxLength += sizeof(UNICODE_NULL);
99 
101  if (DestinationString->Buffer == NULL)
102  return STATUS_NO_MEMORY;
103 
106  DestinationString->MaximumLength = DestMaxLength;
107 
110  }
111 
112  return STATUS_SUCCESS;
113 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING
Definition: green.h:16
unsigned short Length
Definition: sprintf.c:451
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
void * Buffer
Definition: sprintf.c:453
#define UNICODE_NULL
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
return STATUS_SUCCESS
Definition: btrfs.c:2777
unsigned short MaximumLength
Definition: sprintf.c:452

Referenced by DriverEntry(), and GreenQueryId().

◆ 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:2875
#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:565
#define ULONG_PTR
Definition: config.h:101
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2777
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().

◆ GreenPower()

NTSTATUS GreenPower ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 15 of file power.c.

18 {
20  PIO_STACK_LOCATION Stack;
21  ULONG_PTR Information = Irp->IoStatus.Information;
22  NTSTATUS Status = Irp->IoStatus.Status;
23 
26 
27  switch (Stack->MinorFunction)
28  {
29  case IRP_MN_SET_POWER: /* 0x02 */
30  {
31  DPRINT("IRP_MJ_POWER / IRP_MN_SET_POWER\n");
32  if (Type == GreenFDO)
33  {
36  }
37  else
38  {
39  DPRINT1("IRP_MJ_POWER / IRP_MN_SET_POWER / Unknown type 0x%lx\n",
40  Type);
41  ASSERT(FALSE);
42  }
43  break;
44  }
45  default:
46  {
47  DPRINT1("IRP_MJ_POWER / unknown minor function 0x%lx\n", Stack->MinorFunction);
48  break;
49  }
50  }
51 
52  Irp->IoStatus.Status = Status;
53  Irp->IoStatus.Information = Information;
54  if (Status != STATUS_PENDING)
56 
57  return Status;
58 }
Type
Definition: Type.h:6
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
uint32_t ULONG_PTR
Definition: typedefs.h:63
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_PENDING
Definition: ntstatus.h:82
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
Definition: green.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IRP_MN_SET_POWER
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
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
GREEN_DEVICE_TYPE
Definition: green.h:21
#define DPRINT1
Definition: precomp.h:8
#define IO_NO_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2777
Iosb Information
Definition: create.c:4377

Referenced by GreenDispatch().

◆ KeyboardAddDevice()

NTSTATUS KeyboardAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  Pdo 
)

Definition at line 109 of file keyboard.c.

112 {
113  PDEVICE_OBJECT Fdo;
114  PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
116 
117  DPRINT("KeyboardInitialize() called\n");
118 
121  NULL,
124  TRUE,
125  &Fdo);
126  if (!NT_SUCCESS(Status))
127  return Status;
128 
129  DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)Fdo->DeviceExtension;
130  RtlZeroMemory(DeviceExtension, sizeof(KEYBOARD_DEVICE_EXTENSION));
131  DeviceExtension->Common.Type = KeyboardFDO;
132  DeviceExtension->Common.LowerDevice = IoAttachDeviceToDeviceStack(Fdo, Pdo);
134  ((PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension)->KeyboardFdo = Fdo;
136  Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
137 
138  return STATUS_SUCCESS;
139 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define DO_POWER_PAGABLE
#define TRUE
Definition: types.h:120
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:301
struct _GREEN_DRIVER_EXTENSION * PGREEN_DRIVER_EXTENSION
LONG NTSTATUS
Definition: precomp.h:26
struct _KEYBOARD_DEVICE_EXTENSION * PKEYBOARD_DEVICE_EXTENSION
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
PVOID DeviceExtension
Definition: env_spec_w32.h:418
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
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
PDEVICE_OBJECT Green
Definition: green.h:48
Status
Definition: gdiplustypes.h:24
COMMON_FDO_DEVICE_EXTENSION Common
Definition: green.h:47
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 FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
return STATUS_SUCCESS
Definition: btrfs.c:2777
PDEVICE_OBJECT LowerDevice
Definition: green.h:41
#define FILE_DEVICE_KEYBOARD
Definition: winioctl.h:116

Referenced by GreenAddDevice().

◆ KeyboardInternalDeviceControl()

NTSTATUS KeyboardInternalDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 272 of file keyboard.c.

275 {
276  PIO_STACK_LOCATION Stack;
277  PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
279 
281  Irp->IoStatus.Information = 0;
283 
284  switch (Stack->Parameters.DeviceIoControl.IoControlCode)
285  {
287  {
288  DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_INTERNAL_KEYBOARD_CONNECT\n");
289  if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
290  {
292  break;
293  }
294 
295  DeviceExtension->ClassInformation =
296  *((PCONNECT_DATA)Stack->Parameters.DeviceIoControl.Type3InputBuffer);
297 
298  /* Start read loop */
300  &DeviceExtension->WorkerThreadHandle,
301  (ACCESS_MASK)0L,
302  NULL,
303  NULL,
304  NULL,
306  DeviceObject);
307  break;
308  }
309  default:
310  {
311  DPRINT("IRP_MJ_INTERNAL_DEVICE_CONTROL / unknown ioctl code 0x%lx\n",
312  Stack->Parameters.DeviceIoControl.IoControlCode);
314  }
315  }
316 
317  Irp->IoStatus.Status = Status;
319  return Status;
320 }
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
CONNECT_DATA ClassInformation
Definition: green.h:50
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
struct _KEYBOARD_DEVICE_EXTENSION * PKEYBOARD_DEVICE_EXTENSION
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
switch(r->id)
Definition: btrfs.c:2743
static VOID NTAPI KeyboardDeviceWorker(PVOID Context)
Definition: keyboard.c:166
#define IOCTL_INTERNAL_KEYBOARD_CONNECT
Definition: kbdmou.h:56
static const WCHAR L[]
Definition: oid.c:1250
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
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
#define IO_NO_INCREMENT
Definition: iotypes.h:565
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
struct _CONNECT_DATA * PCONNECT_DATA
ULONG ACCESS_MASK
Definition: nt_native.h:40

Referenced by GreenDispatch().

◆ ReadRegistryEntries()

NTSTATUS ReadRegistryEntries ( IN PUNICODE_STRING  RegistryPath,
IN PGREEN_DRIVER_EXTENSION  DriverExtension 
)

Definition at line 63 of file misc.c.

66 {
67  UNICODE_STRING ParametersRegistryKey;
70 
71  ULONG DefaultDeviceReported = 0;
72  ULONG DefaultSampleRate = 1200;
73 
74  ParametersRegistryKey.Length = 0;
75  ParametersRegistryKey.MaximumLength = RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(UNICODE_NULL);
76  ParametersRegistryKey.Buffer = ExAllocatePool(PagedPool, ParametersRegistryKey.MaximumLength);
77  if (!ParametersRegistryKey.Buffer)
78  {
79  DPRINT("ExAllocatePool() failed\n");
81  }
82  RtlCopyUnicodeString(&ParametersRegistryKey, RegistryPath);
83  RtlAppendUnicodeToString(&ParametersRegistryKey, L"\\Parameters");
84  ParametersRegistryKey.Buffer[ParametersRegistryKey.Length / sizeof(WCHAR)] = UNICODE_NULL;
85 
87 
89  Parameters[0].Name = L"AttachedDevice";
90  Parameters[0].EntryContext = &DriverExtension->AttachedDeviceName;
91 
93  Parameters[1].Name = L"DeviceReported";
94  Parameters[1].EntryContext = &DriverExtension->DeviceReported;
95  Parameters[1].DefaultType = REG_DWORD;
96  Parameters[1].DefaultData = &DefaultDeviceReported;
97  Parameters[1].DefaultLength = sizeof(ULONG);
98 
100  Parameters[2].Name = L"SampleRate";
101  Parameters[2].EntryContext = &DriverExtension->SampleRate;
102  Parameters[2].DefaultType = REG_DWORD;
103  Parameters[2].DefaultData = &DefaultSampleRate;
104  Parameters[2].DefaultLength = sizeof(ULONG);
105 
108  ParametersRegistryKey.Buffer,
109  Parameters,
110  NULL,
111  NULL);
112 
113  return Status;
114 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT MaximumLength
Definition: env_spec_w32.h:370
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define RTL_REGISTRY_OPTIONAL
Definition: nt_native.h:169
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:871
static const WCHAR L[]
Definition: oid.c:1250
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
#define REG_DWORD
Definition: sdbapi.c:596
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144

◆ ScreenAddDevice()

NTSTATUS ScreenAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  Pdo 
)

Definition at line 111 of file screen.c.

114 {
115  /* We want to be an upper filter of Blue, if it is existing.
116  * We also *have to* create a Fdo on top of the given Pdo.
117  * Hence, we have 2 cases:
118  * - Blue doesn't exist -> Create a unique Fdo (named Blue) at
119  * the top of the given Pdo
120  * - Blue does exist -> Create a Fdo at the top of the existing
121  * DO, and create a "pass to Green" FDO at the top of the Pdo
122  */
123  PDEVICE_OBJECT Fdo = NULL;
124  PDEVICE_OBJECT PassThroughFdo = NULL;
125  PDEVICE_OBJECT LowerDevice = NULL;
126  PDEVICE_OBJECT PreviousBlue = NULL;
127  PSCREEN_DEVICE_EXTENSION DeviceExtension = NULL;
128  UNICODE_STRING BlueScreenName = RTL_CONSTANT_STRING(L"\\Device\\BlueScreen");
130 
131  DPRINT("ScreenInitialize() called\n");
132 
133  /* Try to create a unique Fdo */
135  DriverObject,
136  sizeof(SCREEN_DEVICE_EXTENSION),
137  &BlueScreenName,
140  TRUE,
141  &Fdo);
142 
144  {
145  DPRINT("Attaching to old blue\n");
146 
147  /* Suggested by hpoussin .. Hide previous blue device
148  * This makes us able to coexist with blue, and install
149  * when loaded */
151  DriverObject,
152  sizeof(SCREEN_DEVICE_EXTENSION),
153  NULL,
156  TRUE,
157  &Fdo);
158  if (!NT_SUCCESS(Status))
159  {
160  DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status);
161  goto cleanup;
162  }
163 
164  /* Initialize some fields, as IoAttachDevice will trigger the
165  * sending of IRP_MJ_CLEANUP/IRP_MJ_CLOSE. We have to know where to
166  * dispatch these IRPs... */
167  ((PSCREEN_DEVICE_EXTENSION)Fdo->DeviceExtension)->Common.Type = ScreenPDO;
169  Fdo,
170  &BlueScreenName,
171  &LowerDevice);
172  if (!NT_SUCCESS(Status))
173  {
174  DPRINT("IoAttachDevice() failed with status 0x%08lx\n", Status);
175  goto cleanup;
176  }
177  PreviousBlue = LowerDevice;
178 
179  /* Attach a faked FDO to PDO */
181  DriverObject,
183  NULL,
186  TRUE,
187  &PassThroughFdo);
188  if (!NT_SUCCESS(Status))
189  {
190  DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status);
191  goto cleanup;
192  }
194  ((PCOMMON_FDO_DEVICE_EXTENSION)PassThroughFdo->DeviceExtension)->LowerDevice = Fdo;
195  PassThroughFdo->StackSize = Fdo->StackSize + 1;
196  }
197  else if (NT_SUCCESS(Status))
198  {
199  /* Attach the named Fdo on top of Pdo */
200  LowerDevice = IoAttachDeviceToDeviceStack(Fdo, Pdo);
201  }
202  else
203  {
204  DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status);
205  return Status;
206  }
207 
208  /* We definately have a device object. PreviousBlue may or may
209  * not be null */
210  DeviceExtension = (PSCREEN_DEVICE_EXTENSION)Fdo->DeviceExtension;
211  RtlZeroMemory(DeviceExtension, sizeof(SCREEN_DEVICE_EXTENSION));
212  DeviceExtension->Common.Type = ScreenFDO;
213  DeviceExtension->Common.LowerDevice = LowerDevice;
215  ((PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension)->ScreenFdo = Fdo;
216  DeviceExtension->PreviousBlue = PreviousBlue;
217  IoAttachDeviceToDeviceStack(PassThroughFdo ? PassThroughFdo : Fdo, Pdo);
218 
219  /* initialize screen */
220  DeviceExtension->Columns = 80;
221  DeviceExtension->Rows = 25;
222  DeviceExtension->ScanLines = 16;
223  DeviceExtension->VideoMemory = (PUCHAR)ExAllocatePool(
224  PagedPool,
225  2 * DeviceExtension->Columns * DeviceExtension->Rows * sizeof(UCHAR));
226  if (!DeviceExtension->VideoMemory)
227  {
228  DPRINT("ExAllocatePool() failed\n");
230  goto cleanup;
231  }
232  DeviceExtension->TabWidth = 8;
233 
234  /* more initialization */
235  DeviceExtension->Mode = ENABLE_PROCESSED_OUTPUT |
237 
238  /* initialize screen at next write */
239  AddToSendBuffer(DeviceExtension, 2, ESC, 'c'); /* reset device */
240  AddToSendBuffer(DeviceExtension, 4, ESC, '[', '7', 'l'); /* disable line wrap */
241  AddToSendBuffer(DeviceExtension, 4, ESC, '[', '3', 'g'); /* clear all tabs */
242 
243  Fdo->Flags |= DO_POWER_PAGABLE;
244  Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
245 
247 
248 cleanup:
249  if (!NT_SUCCESS(Status))
250  {
251  if (DeviceExtension)
252  ExFreePool(DeviceExtension->VideoMemory);
253  if (LowerDevice)
254  IoDetachDevice(LowerDevice);
255  if (Fdo)
256  IoDeleteDevice(Fdo);
257  if (PassThroughFdo)
258  IoDeleteDevice(PassThroughFdo);
259  }
260 
261  return Status;
262 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define DO_POWER_PAGABLE
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI IoAttachDevice(PDEVICE_OBJECT SourceDevice, PUNICODE_STRING TargetDeviceName, PDEVICE_OBJECT *AttachedDevice)
Definition: device.c:913
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define FILE_DEVICE_SCREEN
Definition: winioctl.h:133
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:301
struct _GREEN_DRIVER_EXTENSION * PGREEN_DRIVER_EXTENSION
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1295
struct _SCREEN_DEVICE_EXTENSION * PSCREEN_DEVICE_EXTENSION
#define ENABLE_WRAP_AT_EOL_OUTPUT
Definition: blue.h:45
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
PVOID DeviceExtension
Definition: env_spec_w32.h:418
struct _COMMON_FDO_DEVICE_EXTENSION * PCOMMON_FDO_DEVICE_EXTENSION
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
static VOID AddToSendBuffer(IN PSCREEN_DEVICE_EXTENSION DeviceExtension, IN ULONG NumberOfChars,...)
Definition: screen.c:27
#define ESC
Definition: screen.c:16
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
Status
Definition: gdiplustypes.h:24
#define ENABLE_PROCESSED_OUTPUT
Definition: blue.h:44
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
PDEVICE_OBJECT PreviousBlue
Definition: green.h:77
PDEVICE_OBJECT Green
Definition: green.h:63
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
char * cleanup(char *str)
Definition: wpickclick.c:99
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
COMMON_FDO_DEVICE_EXTENSION Common
Definition: green.h:62
return STATUS_SUCCESS
Definition: btrfs.c:2777
PDEVICE_OBJECT LowerDevice
Definition: green.h:41
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by GreenAddDevice().

◆ ScreenDeviceControl()

NTSTATUS ScreenDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 408 of file screen.c.

411 {
412  PIO_STACK_LOCATION Stack;
413  PSCREEN_DEVICE_EXTENSION DeviceExtension;
416 
419  SerialDevice = ((PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension)->Serial;
420  if (!SerialDevice)
421  {
422  DPRINT1("Calling blue\n");
424  return IoCallDriver(DeviceExtension->PreviousBlue, Irp);
425  }
426 
427  switch (Stack->Parameters.DeviceIoControl.IoControlCode)
428  {
429 #if 0
431  {
433  DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO\n");
434 
435  pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
436 
437  pcsbi->dwSize.X = DeviceExtension->Columns;
438  pcsbi->dwSize.Y = DeviceExtension->Rows;
439 
440  pcsbi->dwCursorPosition.X = (SHORT)(DeviceExtension->LogicalOffset % DeviceExtension->Columns);
441  pcsbi->dwCursorPosition.Y = (SHORT)(DeviceExtension->LogicalOffset / DeviceExtension->Columns);
442 
443  pcsbi->wAttributes = DeviceExtension->CharAttribute;
444 
445  pcsbi->srWindow.Left = 1;
446  pcsbi->srWindow.Right = DeviceExtension->Columns;
447  pcsbi->srWindow.Top = 1;
448  pcsbi->srWindow.Bottom = DeviceExtension->Rows;
449 
450  pcsbi->dwMaximumWindowSize.X = DeviceExtension->Columns;
451  pcsbi->dwMaximumWindowSize.Y = DeviceExtension->Rows;
452 
453  Irp->IoStatus.Information = sizeof(CONSOLE_SCREEN_BUFFER_INFO);
455  break;
456  }
458  {
460  DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO\n");
461 
462  pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
463  /* FIXME: remove */ { pcsbi->dwCursorPosition.X++; }
464  /* FIXME: remove */ { pcsbi->dwCursorPosition.Y++; }
465  ASSERT(pcsbi->dwCursorPosition.X >= 1);
466  ASSERT(pcsbi->dwCursorPosition.Y >= 1);
467  ASSERT(pcsbi->dwCursorPosition.X <= DeviceExtension->Columns);
468  ASSERT(pcsbi->dwCursorPosition.Y <= DeviceExtension->Rows);
469 
470  DeviceExtension->LogicalOffset = (
471  (pcsbi->dwCursorPosition.Y-1) * DeviceExtension->Columns +
472  (pcsbi->dwCursorPosition.X-1)) * 2;
473  AddToSendBuffer(DeviceExtension, 6, ESC, '[',
474  -(int)pcsbi->dwCursorPosition.Y, ';',
475  -(int)pcsbi->dwCursorPosition.X, 'H');
476 
477  /* flush buffer */
478  AddToSendBuffer(DeviceExtension, 0);
479 
480  DeviceExtension->CharAttribute = pcsbi->wAttributes;
481 
482  Irp->IoStatus.Information = 0;
484  break;
485  }
487  {
488  PCONSOLE_CURSOR_INFO pcci = (PCONSOLE_CURSOR_INFO)Irp->AssociatedIrp.SystemBuffer;
489  DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_CURSOR_INFO\n");
490 
491  pcci->dwSize = 1;
492  pcci->bVisible = TRUE;
493 
494  Irp->IoStatus.Information = sizeof (CONSOLE_CURSOR_INFO);
496  break;
497  }
499  {
500  PCONSOLE_MODE pcm = (PCONSOLE_MODE)Irp->AssociatedIrp.SystemBuffer;
501  DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_MODE\n");
502 
503  pcm->dwMode = DeviceExtension->Mode;
504 
505  Irp->IoStatus.Information = sizeof(CONSOLE_MODE);
507  break;
508  }
510  {
511  PCONSOLE_MODE pcm = (PCONSOLE_MODE)Irp->AssociatedIrp.SystemBuffer;
512  DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_MODE\n");
513 
514  DeviceExtension->Mode = pcm->dwMode;
515 
516  Irp->IoStatus.Information = 0;
518  break;
519  }
521  {
522  DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE\n");
523  Status = STATUS_NOT_IMPLEMENTED; /* FIXME: IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE */
524  break;
525  }
527  {
528  DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE\n");
529  Status = STATUS_NOT_IMPLEMENTED; /* FIXME: IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE */
530  break;
531  }
533  {
534  DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE\n");
535  Status = STATUS_NOT_IMPLEMENTED; /* FIXME: IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE */
536  break;
537  }
539  {
540  DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE\n");
541 
542  DeviceExtension->CharAttribute = (WORD)*(PWORD)Irp->AssociatedIrp.SystemBuffer;
543  Irp->IoStatus.Information = 0;
545  break;
546  }
548  {
549  DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER\n");
550  Status = STATUS_NOT_IMPLEMENTED; /* FIXME:IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER */
551  break;
552  }
554  {
555  DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_READ_OUTPUT_CHARACTER\n");
556  Status = STATUS_NOT_IMPLEMENTED; /* FIXME: IOCTL_CONSOLE_READ_OUTPUT_CHARACTER */
557  break;
558  }
560  {
561  DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER\n");
562  Status = STATUS_NOT_IMPLEMENTED; /* FIXME: IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER */
563  break;
564  }
565  case IOCTL_CONSOLE_DRAW:
566  {
567  PCONSOLE_DRAW ConsoleDraw;
568  PUCHAR Video;
569  ULONG x, y;
570  BOOLEAN DoOptimization = FALSE;
571  DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_DRAW\n");
572 
573  ConsoleDraw = (PCONSOLE_DRAW)MmGetSystemAddressForMdl(Irp->MdlAddress);
574  /* FIXME: remove */ { ConsoleDraw->X++; ConsoleDraw->CursorX++; }
575  /* FIXME: remove */ { ConsoleDraw->Y++; ConsoleDraw->CursorY++; }
576  DPRINT1("%lu %lu %lu %lu\n",
577  ConsoleDraw->X, ConsoleDraw->Y,
578  ConsoleDraw->SizeX, ConsoleDraw->SizeY);
579  ASSERT(ConsoleDraw->X >= 1);
580  ASSERT(ConsoleDraw->Y >= 1);
581  ASSERT(ConsoleDraw->X <= DeviceExtension->Columns);
582  ASSERT(ConsoleDraw->Y <= DeviceExtension->Rows);
583  ASSERT(ConsoleDraw->X + ConsoleDraw->SizeX >= 1);
584  ASSERT(ConsoleDraw->Y + ConsoleDraw->SizeY >= 1);
585  ASSERT(ConsoleDraw->X + ConsoleDraw->SizeX - 1 <= DeviceExtension->Columns);
586  ASSERT(ConsoleDraw->Y + ConsoleDraw->SizeY - 1 <= DeviceExtension->Rows);
587  ASSERT(ConsoleDraw->CursorX >= 1);
588  ASSERT(ConsoleDraw->CursorY >= 1);
589  ASSERT(ConsoleDraw->CursorX <= DeviceExtension->Columns);
590  ASSERT(ConsoleDraw->CursorY <= DeviceExtension->Rows);
591 
592 #if 0
593  if (ConsoleDraw->X == 1
594  && ConsoleDraw->Y == 1
595  && ConsoleDraw->SizeX == DeviceExtension->Columns
596  && ConsoleDraw->SizeY == DeviceExtension->Rows)
597  {
598  /* search if we need to clear all screen */
599  DoOptimization = TRUE;
600  Video = (PUCHAR)(ConsoleDraw + 1);
601  x = 0;
602  while (DoOptimization && x < DeviceExtension->Columns * DeviceExtension->Rows)
603  {
604  if (Video[x++] != ' ')
605  {
606  DoOptimization = FALSE;
607  }
608  /*if (Video[x++] != DeviceExtension->CharAttribute) DoOptimization = FALSE; */
609  }
610  if (DoOptimization)
611  {
612  AddToSendBuffer(DeviceExtension, 4, ESC, '[', '2', 'J');
613  }
614  }
615 #endif
616  /* add here more optimizations if needed */
617 
618  if (!DoOptimization)
619  {
620  for (y = 0; y < ConsoleDraw->SizeY; y++)
621  {
622  AddToSendBuffer(DeviceExtension, 6, ESC, '[',
623  -(int)(ConsoleDraw->Y + y), ';',
624  -(int)(ConsoleDraw->X), 'H');
625  Video = (PUCHAR)(ConsoleDraw + 1);
626  Video = &Video[((ConsoleDraw->Y + y) * /*DeviceExtension->Columns +*/ ConsoleDraw->X) * 2];
627  for (x = 0; x < ConsoleDraw->SizeX; x++)
628  {
629  AddToSendBuffer(DeviceExtension, 1, Video[x * 2]);
630  }
631  }
632  }
633 
634  DeviceExtension->LogicalOffset = (
635  (ConsoleDraw->CursorY-1) * DeviceExtension->Columns +
636  (ConsoleDraw->CursorX-1)) * 2;
637  AddToSendBuffer(DeviceExtension, 6, ESC, '[',
638  -(int)(ConsoleDraw->CursorY), ';',
639  -(int)(ConsoleDraw->CursorX), 'H');
640 
641  /* flush buffer */
642  AddToSendBuffer(DeviceExtension, 0);
643 
644  Irp->IoStatus.Information = 0;
646  break;
647  }
648 #endif
649  default:
650  {
651  DPRINT1("IRP_MJ_DEVICE_CONTROL / unknown ioctl code 0x%lx\n",
652  Stack->Parameters.DeviceIoControl.IoControlCode);
653  /* Call lower driver */
655  return IoCallDriver(DeviceExtension->Common.LowerDevice, Irp);
656  }
657  }
658 
659  if (!NT_SUCCESS(Status))
660  {
661  /* Don't call blue (if any), as we encountered an error */
662  Irp->IoStatus.Status = Status;
664  return Status;
665  }
666  else
667  {
668  /* Call lower driver */
670  return IoCallDriver(DeviceExtension->Common.LowerDevice, Irp);
671  }
672 }
struct tagCONSOLE_CURSOR_INFO * PCONSOLE_CURSOR_INFO
#define IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE
Definition: ntddblue.h:14
#define TRUE
Definition: types.h:120
#define IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO
Definition: ntddblue.h:5
#define IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE
Definition: ntddblue.h:15
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
struct tagCONSOLE_SCREEN_BUFFER_INFO CONSOLE_SCREEN_BUFFER_INFO
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
struct tagCONSOLE_MODE * PCONSOLE_MODE
struct _SCREEN_DEVICE_EXTENSION * PSCREEN_DEVICE_EXTENSION
#define IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER
Definition: ntddblue.h:18
short SHORT
Definition: pedump.c:59
#define IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE
Definition: ntddblue.h:12
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
#define IoCompleteRequest
Definition: irp.c:1240
#define IOCTL_CONSOLE_GET_CURSOR_INFO
Definition: ntddblue.h:6
void DPRINT(...)
Definition: polytest.cpp:61
#define IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE
Definition: ntddblue.h:13
SHORT Left
Definition: blue.h:25
ULONG CursorY
Definition: ntddblue.h:61
ULONG X
Definition: bl.h:1340
WORD * PWORD
Definition: pedump.c:67
BOOLEAN bVisible
Definition: blue.h:41
SHORT Bottom
Definition: blue.h:28
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static VOID AddToSendBuffer(IN PSCREEN_DEVICE_EXTENSION DeviceExtension, IN ULONG NumberOfChars,...)
Definition: screen.c:27
struct tagCONSOLE_DRAW * PCONSOLE_DRAW
#define IOCTL_CONSOLE_GET_MODE
Definition: ntddblue.h:8
#define ESC
Definition: screen.c:16
unsigned short WORD
Definition: ntddk_ex.h:93
SHORT Top
Definition: blue.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IOCTL_CONSOLE_DRAW
Definition: ntddblue.h:22
Status
Definition: gdiplustypes.h:24
ULONG dwMode
Definition: ntddblue.h:32
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
static const COLUMN_LIST Columns[]
Definition: listview.c:19
PDEVICE_OBJECT PreviousBlue
Definition: green.h:77
#define IOCTL_CONSOLE_SET_MODE
Definition: ntddblue.h:9
struct tagCONSOLE_MODE CONSOLE_MODE
#define IOCTL_CONSOLE_READ_OUTPUT_CHARACTER
Definition: ntddblue.h:19
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO
Definition: ntddblue.h:4
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define DPRINT1
Definition: precomp.h:8
PDEVICE_OBJECT Green
Definition: green.h:63
ULONG CursorX
Definition: ntddblue.h:60
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define MmGetSystemAddressForMdl(Mdl)
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER
Definition: ntddblue.h:20
COMMON_FDO_DEVICE_EXTENSION Common
Definition: green.h:62
SHORT Right
Definition: blue.h:27
struct tagCONSOLE_SCREEN_BUFFER_INFO * PCONSOLE_SCREEN_BUFFER_INFO
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2777
ULONG Y
Definition: bl.h:1341
struct tagCONSOLE_CURSOR_INFO CONSOLE_CURSOR_INFO
PDEVICE_OBJECT LowerDevice
Definition: green.h:41

Referenced by GreenDispatch().

◆ ScreenWrite()

NTSTATUS ScreenWrite ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 265 of file screen.c.

268 {
269  PIO_STACK_LOCATION Stack;
270  PUCHAR Buffer;
271  PSCREEN_DEVICE_EXTENSION DeviceExtension;
273  PUCHAR VideoMemory; /* FIXME: is it useful? */
274  ULONG VideoMemorySize; /* FIXME: is it useful? */
275 
276  ULONG Columns, Rows;
278  ULONG i, j;
279  DBG_UNREFERENCED_LOCAL_VARIABLE(VideoMemory);
280  DBG_UNREFERENCED_LOCAL_VARIABLE(VideoMemorySize);
281 
282  DPRINT("ScreenWrite() called\n");
283 
285  Buffer = Irp->UserBuffer;
287  VideoMemory = DeviceExtension->VideoMemory;
288 
289  SerialDevice = ((PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension)->Serial;
290  if (!SerialDevice)
291  {
292  DPRINT1("Calling blue\n");
294  return IoCallDriver(DeviceExtension->PreviousBlue, Irp);
295  }
296 
297  Columns = DeviceExtension->Columns;
298  Rows = DeviceExtension->Rows;
299  CursorX = (DeviceExtension->LogicalOffset / 2) % Columns + 1;
300  CursorY = (DeviceExtension->LogicalOffset / 2) / Columns + 1;
301  VideoMemorySize = Columns * Rows * 2 * sizeof(UCHAR);
302 
303  if (!(DeviceExtension->Mode & ENABLE_PROCESSED_OUTPUT))
304  {
305  /* raw output mode */
306  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
308 
309  return STATUS_NOT_SUPPORTED;
310  }
311  else
312  {
313  for (i = 0; i < Stack->Parameters.Write.Length; i++, Buffer++)
314  {
315  switch (*Buffer)
316  {
317  case '\b':
318  {
319  if (CursorX > 1)
320  {
321  CursorX--;
322  AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
323  AddToSendBuffer(DeviceExtension, 1, ' ');
324  AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
325  }
326  else if (CursorY > 1)
327  {
328  CursorX = Columns;
329  CursorY--;
330  AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
331  }
332  break;
333  }
334  case '\n':
335  {
336  CursorY++;
337  CursorX = 1;
338  AddToSendBuffer(DeviceExtension, 1, '\n');
339  AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', '1', 'H');
340  break;
341  }
342  case '\r':
343  {
344  if (CursorX > 1)
345  {
346  AddToSendBuffer(DeviceExtension, 4, ESC, '[', -(int)(CursorX-1), 'D');
347  CursorX = 1;
348  }
349  break;
350  }
351  case '\t':
352  {
353  ULONG Offset = DeviceExtension->TabWidth - (CursorX % DeviceExtension->TabWidth);
354  for (j = 0; j < Offset; j++)
355  {
356 #ifdef FORCE_POSITION
357  AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
358 #endif
359  AddToSendBuffer(DeviceExtension, 1, ' ');
360  CursorX++;
361  if (CursorX > Columns)
362  {
363  CursorX = 1;
364  CursorY++;
365  }
366  }
367  break;
368  }
369  default:
370  {
371 #ifdef FORCE_POSITION
372  AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
373 #endif
374  AddToSendBuffer(DeviceExtension, 1, *Buffer);
375  CursorX++;
376  if (CursorX > Columns)
377  {
378  CursorX = 1;
379  DPRINT("Y: %lu -> %lu\n", CursorY, CursorY + 1);
380  CursorY++;
381  AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', '1', 'H');
382 
383  }
384  }
385  }
386  if (CursorY >= Rows)
387  {
388  DPRINT("Y: %lu -> %lu\n", CursorY, CursorY - 1);
389  CursorY--;
390  AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)1, ';', -(int)(Rows), 'r');
391  AddToSendBuffer(DeviceExtension, 2, ESC, 'D');
392  AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', -(int)CursorX, 'H');
393  }
394  }
395  }
396 
397  DeviceExtension->LogicalOffset = ((CursorX-1) + (CursorY-1) * Columns) * 2;
398 
399  /* flush output buffer */
400  AddToSendBuffer(DeviceExtension, 0);
401 
402  /* Call lower driver */
404  return IoCallDriver(DeviceExtension->Common.LowerDevice, Irp);
405 }
_In_ PIRP Irp
Definition: csq.h:116
unsigned char * PUCHAR
Definition: retypes.h:3
static ULONG CursorY
Definition: display.c:137
struct _SCREEN_DEVICE_EXTENSION * PSCREEN_DEVICE_EXTENSION
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
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
PVOID DeviceExtension
Definition: env_spec_w32.h:418
_In_ ULONG Rows
Definition: haltypes.h:7
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
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 GLint GLint j
Definition: glfuncs.h:250
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:326
static VOID AddToSendBuffer(IN PSCREEN_DEVICE_EXTENSION DeviceExtension, IN ULONG NumberOfChars,...)
Definition: screen.c:27
#define ESC
Definition: screen.c:16
unsigned char UCHAR
Definition: xmlstorage.h:181
static ULONG CursorX
Definition: display.c:136
#define ENABLE_PROCESSED_OUTPUT
Definition: blue.h:44
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
static const COLUMN_LIST Columns[]
Definition: listview.c:19
PDEVICE_OBJECT PreviousBlue
Definition: green.h:77
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define DPRINT1
Definition: precomp.h:8
PDEVICE_OBJECT Green
Definition: green.h:63
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
COMMON_FDO_DEVICE_EXTENSION Common
Definition: green.h:62
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
PDEVICE_OBJECT LowerDevice
Definition: green.h:41

Referenced by GreenDispatch().