ReactOS 0.4.15-dev-5664-g3bf4ef6
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{
GREEN_DEVICE_TYPE
Definition: green.h:22
@ KeyboardFDO
Definition: green.h:28
@ KeyboardPDO
Definition: green.h:25
@ ScreenPDO
Definition: green.h:24
@ GreenPDO
Definition: green.h:23
@ GreenFDO
Definition: green.h:26
@ PassThroughFDO
Definition: green.h:29
@ ScreenFDO
Definition: green.h:27

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}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
struct _GREEN_DEVICE_EXTENSION * PGREEN_DEVICE_EXTENSION
NTSTATUS KeyboardAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
Definition: keyboard.c:109
NTSTATUS ScreenAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
Definition: screen.c:111
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44
static NTSTATUS ReportGreenPdo(IN PDRIVER_OBJECT DriverObject, IN PGREEN_DRIVER_EXTENSION DriverExtension)
Definition: pnp.c:141
static NTSTATUS CreateGreenFdo(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT GreenPdo)
Definition: pnp.c:15
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1889
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
PDEVICE_OBJECT KeyboardPdo
Definition: green.h:89
PDEVICE_OBJECT ScreenPdo
Definition: green.h:90
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:72

Referenced by DriverEntry().

◆ 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
#define IO_NO_INCREMENT
Definition: iotypes.h:598

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}

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{
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
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}
LONG NTSTATUS
Definition: precomp.h:26
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
Status
Definition: gdiplustypes.h:25
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define KernelMode
Definition: asm.h:34
@ NotificationEvent
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
#define IoCallDriver
Definition: irp.c:1225
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
@ Suspended
Definition: ketypes.h:408

Referenced by CreateGreenFdo().

◆ GreenDispatch()

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

Definition at line 15 of file dispatch.c.

18{
23
25 DeviceType = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
26
27 Information = Irp->IoStatus.Information;
28 Status = Irp->IoStatus.Status;
29
30 DPRINT("Dispatching major function 0x%lx, DeviceType %u\n",
32
34 {
36 return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
37 }
44 {
46 return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
47 }
49 {
51 ((PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->KeyboardFdo,
52 Irp);
53 }
57 {
59 ((PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->ScreenFdo,
60 Irp);
61 }
67 {
69 return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
70 }
72 return GreenPnp(DeviceObject, Irp);
75 else
76 {
77 DPRINT1("Unknown combination: MajorFunction 0x%lx, DeviceType %d\n",
79 switch (DeviceType)
80 {
81 case KeyboardFDO:
82 case ScreenFDO:
83 {
85 return IoCallDriver(((PCOMMON_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice, Irp);
86 }
87 case GreenFDO:
88 {
91 DriverObject = DeviceObject->DriverObject;
94 return IoCallDriver(DriverExtension->LowerDevice, Irp);
95 }
96 default:
98 }
99 }
100
101 Irp->IoStatus.Information = Information;
102 Irp->IoStatus.Status = Status;
104 return Status;
105}
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
NTSTATUS ScreenWrite(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: screen.c:265
NTSTATUS KeyboardInternalDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: keyboard.c:272
NTSTATUS GreenPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: power.c:15
NTSTATUS GreenPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pnp.c:408
NTSTATUS ScreenDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: screen.c:408
unsigned int ULONG
Definition: retypes.h:1
DeviceType
Definition: mmdrv.h:42
NTSTATUS GreenCreate(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: createclose.c:15
NTSTATUS GreenClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: createclose.c:28
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
#define IRP_MJ_POWER
#define IRP_MJ_CLEANUP

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
102 return STATUS_NO_MEMORY;
103
106 DestinationString->MaximumLength = DestMaxLength;
107
110 }
111
112 return STATUS_SUCCESS;
113}
#define PagedPool
Definition: env_spec_w32.h:308
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING
Definition: green.h:16
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1910
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1909
#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

Referenced by DriverEntry(), and GreenQueryId().

◆ GreenPnp()

NTSTATUS GreenPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 408 of file pnp.c.

411{
414 ULONG_PTR Information = Irp->IoStatus.Information;
415 NTSTATUS Status = Irp->IoStatus.Status;
416
417 Type = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
419
420 switch (Stack->MinorFunction)
421 {
422 case IRP_MN_START_DEVICE: /* 0x00 */
423 {
424 DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
425 if (Type == GreenFDO || Type == KeyboardPDO || Type == ScreenPDO)
427 else
428 {
429 DPRINT1("IRP_MJ_PNP / IRP_MN_START_DEVICE / Unknown type 0x%lx\n",
430 Type);
431 ASSERT(FALSE);
432 }
433 break;
434 }
435 case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x07 */
436 {
437 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS\n");
438 switch (Stack->Parameters.QueryDeviceRelations.Type)
439 {
440 case BusRelations:
441 {
442 if (Type == GreenFDO)
443 {
444 PDEVICE_RELATIONS DeviceRelations = NULL;
445 Status = GreenQueryBusRelations(DeviceObject, &DeviceRelations);
446 Information = (ULONG_PTR)DeviceRelations;
447 }
448 else if (Type == KeyboardPDO || Type == ScreenPDO)
449 {
450 PDEVICE_RELATIONS DeviceRelations = NULL;
451 DeviceRelations = ExAllocatePool(PagedPool, FIELD_OFFSET(DEVICE_RELATIONS, Objects));
452 if (!DeviceRelations)
454 else
455 {
456 DeviceRelations->Count = 0;
458 Information = (ULONG_PTR)DeviceRelations;
459 }
460 }
461 else
462 {
463 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations / Unknown type 0x%lx\n",
464 Type);
465 ASSERT(FALSE);
466 }
467 break;
468 }
469 default:
470 {
471 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
472 Stack->Parameters.QueryDeviceRelations.Type);
473 break;
474 }
475 }
476 break;
477 }
478 case IRP_MN_QUERY_RESOURCES: /* 0x0a */
479 {
480 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_RESOURCES\n");
481 /* We don't need resources */
482 break;
483 }
485 {
486 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
487 /* We don't need resources */
488 break;
489 }
490 case IRP_MN_QUERY_DEVICE_TEXT: /* 0x0c */
491 {
492 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT\n");
493 switch (Stack->Parameters.QueryDeviceText.DeviceTextType)
494 {
496 {
498 if (Type == GreenFDO)
499 Description = L"Green device";
500 else if (Type == ScreenPDO)
501 Description = L"Green screen";
502 else if (Type == KeyboardPDO)
503 Description = L"Green keyboard";
504
505 if (Description != NULL)
506 {
508 if (!Destination)
510 else
511 {
515 }
516 }
517 else
518 {
519 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription / Unknown type 0x%lx\n",
520 Type);
521 ASSERT(FALSE);
522 }
523 break;
524 }
526 {
527 /* We don't have any text location to report,
528 * and this query is optional, so ignore it.
529 */
530 break;
531 }
532 default:
533 {
534 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown type 0x%lx\n",
535 Stack->Parameters.QueryDeviceText.DeviceTextType);
536 ASSERT(FALSE);
537 break;
538 }
539 }
540 break;
541 }
542 case IRP_MN_QUERY_ID: /* 0x13 */
543 {
544 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID\n");
546 break;
547 }
548 default:
549 {
550 DPRINT1("IRP_MJ_PNP / unknown minor function 0x%lx\n", Stack->MinorFunction);
551 break;
552 }
553 }
554
555 Irp->IoStatus.Status = Status;
556 Irp->IoStatus.Information = Information;
557 if (Status != STATUS_PENDING)
559
560 return Status;
561}
Type
Definition: Type.h:7
static const WCHAR Description[]
Definition: oid.c:1266
#define ULONG_PTR
Definition: config.h:101
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static NTSTATUS GreenQueryId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, OUT ULONG_PTR *Information)
Definition: pnp.c:313
static NTSTATUS GreenQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: pnp.c:220
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2992
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
DEVICE_RELATION_TYPE Type
Definition: iotypes.h:3242
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
@ BusRelations
Definition: iotypes.h:2152
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_ID
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_RESOURCES
@ DeviceTextLocationInformation
Definition: iotypes.h:2946
@ DeviceTextDescription
Definition: iotypes.h:2945
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by GreenDispatch().

◆ GreenPower()

NTSTATUS GreenPower ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 15 of file power.c.

18{
21 ULONG_PTR Information = Irp->IoStatus.Information;
22 NTSTATUS Status = Irp->IoStatus.Status;
23
24 Type = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
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);
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;
56
57 return Status;
58}
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:746
#define IRP_MN_SET_POWER

Referenced by GreenDispatch().

◆ KeyboardAddDevice()

NTSTATUS KeyboardAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  Pdo 
)

Definition at line 109 of file keyboard.c.

112{
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;
134 ((PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension)->KeyboardFdo = Fdo;
136 Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
137
138 return STATUS_SUCCESS;
139}
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
struct _GREEN_DRIVER_EXTENSION * PGREEN_DRIVER_EXTENSION
struct _KEYBOARD_DEVICE_EXTENSION * PKEYBOARD_DEVICE_EXTENSION
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define FILE_DEVICE_KEYBOARD
Definition: winioctl.h:117
GREEN_DEVICE_TYPE Type
Definition: green.h:40
PDEVICE_OBJECT LowerDevice
Definition: green.h:41
PVOID DeviceExtension
Definition: env_spec_w32.h:418
COMMON_FDO_DEVICE_EXTENSION Common
Definition: green.h:47
PDEVICE_OBJECT Green
Definition: green.h:48
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
#define DO_POWER_PAGABLE

Referenced by GreenAddDevice().

◆ KeyboardInternalDeviceControl()

NTSTATUS KeyboardInternalDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 272 of file keyboard.c.

275{
277 PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
279
281 Irp->IoStatus.Information = 0;
282 DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
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,
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}
switch(r->id)
Definition: btrfs.c:3046
struct _CONNECT_DATA * PCONNECT_DATA
#define IOCTL_INTERNAL_KEYBOARD_CONNECT
Definition: kbdmou.h:56
static VOID NTAPI KeyboardDeviceWorker(PVOID Context)
Definition: keyboard.c:166
ULONG ACCESS_MASK
Definition: nt_native.h:40
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
CONNECT_DATA ClassInformation
Definition: green.h:50
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138

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,
110 NULL,
111 NULL);
112
113 return Status;
114}
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
#define RTL_REGISTRY_OPTIONAL
Definition: nt_native.h:169
#define REG_DWORD
Definition: sdbapi.c:596
USHORT MaximumLength
Definition: env_spec_w32.h:370
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869

◆ 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 */
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 */
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 */
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 */
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
248cleanup:
249 if (!NT_SUCCESS(Status))
250 {
251 if (DeviceExtension)
252 ExFreePool(DeviceExtension->VideoMemory);
253 if (LowerDevice)
254 IoDetachDevice(LowerDevice);
255 if (Fdo)
257 if (PassThroughFdo)
258 IoDeleteDevice(PassThroughFdo);
259 }
260
261 return Status;
262}
#define ENABLE_WRAP_AT_EOL_OUTPUT
Definition: blue.h:54
#define ENABLE_PROCESSED_OUTPUT
Definition: blue.h:53
static void cleanup(void)
Definition: main.c:1335
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
struct _COMMON_FDO_DEVICE_EXTENSION * PCOMMON_FDO_DEVICE_EXTENSION
struct _SCREEN_DEVICE_EXTENSION * PSCREEN_DEVICE_EXTENSION
unsigned char * PUCHAR
Definition: retypes.h:3
#define ESC
Definition: screen.c:16
static VOID AddToSendBuffer(IN PSCREEN_DEVICE_EXTENSION DeviceExtension, IN ULONG NumberOfChars,...)
Definition: screen.c:27
NTSTATUS NTAPI IoAttachDevice(PDEVICE_OBJECT SourceDevice, PUNICODE_STRING TargetDeviceName, PDEVICE_OBJECT *AttachedDevice)
Definition: device.c:913
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define FILE_DEVICE_SCREEN
Definition: winioctl.h:134
PDEVICE_OBJECT Green
Definition: green.h:63
COMMON_FDO_DEVICE_EXTENSION Common
Definition: green.h:62
PDEVICE_OBJECT PreviousBlue
Definition: green.h:77
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by GreenAddDevice().

◆ ScreenDeviceControl()

NTSTATUS ScreenDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 408 of file screen.c.

411{
413 PSCREEN_DEVICE_EXTENSION DeviceExtension;
416
418 DeviceExtension = (PSCREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
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 }
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}
unsigned char BOOLEAN
static const COLUMN_LIST Columns[]
Definition: listview.c:19
@ SerialDevice
Definition: bl.h:249
struct tagCONSOLE_SCREEN_BUFFER_INFO CONSOLE_SCREEN_BUFFER_INFO
struct tagCONSOLE_CURSOR_INFO CONSOLE_CURSOR_INFO
struct tagCONSOLE_CURSOR_INFO * PCONSOLE_CURSOR_INFO
struct tagCONSOLE_SCREEN_BUFFER_INFO * PCONSOLE_SCREEN_BUFFER_INFO
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define IOCTL_CONSOLE_DRAW
Definition: ntddblue.h:22
#define IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE
Definition: ntddblue.h:14
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER
Definition: ntddblue.h:20
#define IOCTL_CONSOLE_GET_MODE
Definition: ntddblue.h:10
#define IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER
Definition: ntddblue.h:18
#define IOCTL_CONSOLE_READ_OUTPUT_CHARACTER
Definition: ntddblue.h:19
#define IOCTL_CONSOLE_SET_MODE
Definition: ntddblue.h:11
#define IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE
Definition: ntddblue.h:15
struct tagCONSOLE_MODE CONSOLE_MODE
struct tagCONSOLE_DRAW * PCONSOLE_DRAW
#define IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE
Definition: ntddblue.h:16
struct tagCONSOLE_MODE * PCONSOLE_MODE
#define IOCTL_CONSOLE_GET_CURSOR_INFO
Definition: ntddblue.h:8
#define IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO
Definition: ntddblue.h:7
#define IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO
Definition: ntddblue.h:6
#define IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE
Definition: ntddblue.h:13
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
WORD * PWORD
Definition: pedump.c:67
short SHORT
Definition: pedump.c:59
USHORT CursorY
Definition: ntddblue.h:56
USHORT SizeX
Definition: ntddblue.h:53
USHORT SizeY
Definition: ntddblue.h:54
USHORT CursorX
Definition: ntddblue.h:55
ULONG dwMode
Definition: ntddblue.h:30
SHORT Y
Definition: blue.h:27
SHORT X
Definition: blue.h:26
SHORT Right
Definition: blue.h:34
SHORT Left
Definition: blue.h:32
SHORT Top
Definition: blue.h:33
SHORT Bottom
Definition: blue.h:35
#define MmGetSystemAddressForMdl(Mdl)

Referenced by GreenDispatch().

◆ ScreenWrite()

NTSTATUS ScreenWrite ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 265 of file screen.c.

268{
271 PSCREEN_DEVICE_EXTENSION DeviceExtension;
273 PUCHAR VideoMemory; /* FIXME: is it useful? */
274 ULONG VideoMemorySize; /* FIXME: is it useful? */
275
277 ULONG CursorX, CursorY;
278 ULONG i, j;
280 DBG_UNREFERENCED_LOCAL_VARIABLE(VideoMemorySize);
281
282 DPRINT("ScreenWrite() called\n");
283
285 Buffer = Irp->UserBuffer;
286 DeviceExtension = (PSCREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
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
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}
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 i
Definition: glfuncs.h:248
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:319
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
_In_ ULONG Rows
Definition: haltypes.h:7

Referenced by GreenDispatch().