@@ -127,7 +127,6 @@ Return Value:
127127{
128128 NTSTATUS status = STATUS_SUCCESS;
129129 size_t bufSize;
130- struct CursorData * cptr = NULL ;
131130 struct KMDF_IOCTL_Response * resp = NULL ;
132131 WDFDEVICE Device = WdfIoQueueGetDevice (Queue);
133132 PDEVICE_CONTEXT pDeviceContext = DeviceGetContext (Device);
@@ -169,14 +168,32 @@ Return Value:
169168
170169
171170 case IOCTL_DVSERVER_CURSOR_DATA:
172- status = WdfRequestRetrieveInputBuffer (Request, 0 , (PVOID*)&cptr, &bufSize);
171+
172+ status = IoctlSetPointerShape (pDeviceContext, InputBufferLength, Request);
173+ if (status != STATUS_SUCCESS) {
174+ ERR (" IoctlSetPointerShape failed with status = %d\n " , status);
175+ return ;
176+ }
177+
178+ status = WdfRequestRetrieveOutputBuffer (Request, 0 , (PVOID*)&resp, &bufSize);
173179 if (!NT_SUCCESS (status)) {
174- ERR (" Couldn't retrieve Input buffer\n " );
180+ ERR (" Couldn't retrieve Output buffer\n " );
175181 WdfRequestComplete (Request, STATUS_INSUFFICIENT_RESOURCES);
176182 return ;
177183 }
178184
179- PRINT_CURSOR_DATA ((" x=%d, y=%d" , cptr->cursor_x , cptr->cursor_y ));
185+ // Return value from the KMDF DVServer
186+ resp->retval = DVSERVERKMD_SUCCESS;
187+ WdfRequestSetInformation (Request, sizeof (struct KMDF_IOCTL_Response ));
188+ break ;
189+
190+ case IOCTL_DVSERVER_CURSOR_POS:
191+ status = IoctlSetPointerPosition (pDeviceContext, InputBufferLength, Request);
192+ if (status != STATUS_SUCCESS) {
193+ ERR (" IoctlSetPointerPosition failed with status = %d\n " , status);
194+ WdfRequestComplete (Request, STATUS_INSUFFICIENT_RESOURCES);
195+ return ;
196+ }
180197
181198 status = WdfRequestRetrieveOutputBuffer (Request, 0 , (PVOID*)&resp, &bufSize);
182199 if (!NT_SUCCESS (status)) {
@@ -589,4 +606,100 @@ static NTSTATUS IoctlRequestHPEventInfo(
589606 WdfRequestSetInformation (Request, sizeof (struct hp_info ));
590607
591608 return STATUS_SUCCESS;
592- }
609+ }
610+
611+ static NTSTATUS IoctlSetPointerShape (
612+ const PDEVICE_CONTEXT DeviceContext,
613+ const size_t InputBufferLength,
614+ const WDFREQUEST Request)
615+ {
616+ POINTER_SHAPE pointerShape;
617+ struct CursorData * cptr = NULL ;
618+ size_t bufSize;
619+ NTSTATUS status = STATUS_UNSUCCESSFUL;
620+
621+ TRACING ();
622+
623+ VioGpuAdapterLite* pAdapter =
624+ (VioGpuAdapterLite*)(DeviceContext ? DeviceContext->pvDeviceExtension : nullptr );
625+
626+ if (!pAdapter) {
627+ ERR (" Couldnt' find adapter\n " );
628+ return status;
629+ }
630+
631+ status = WdfRequestRetrieveInputBuffer (Request, InputBufferLength, (PVOID*)&cptr, &bufSize);
632+ if (!NT_SUCCESS (status)) {
633+ ERR (" Couldn't retrieve Input buffer\n " );
634+ WdfRequestComplete (Request, STATUS_INSUFFICIENT_RESOURCES);
635+ return STATUS_INVALID_USER_BUFFER;
636+ }
637+
638+ if (cptr == NULL ) {
639+ return STATUS_UNSUCCESSFUL;
640+ }
641+
642+ RtlZeroMemory (&pointerShape, sizeof (POINTER_SHAPE));
643+ pointerShape.pointer .VidPnSourceId = cptr->screen_num ;
644+ pointerShape.pointer .Height = cptr->height ;
645+ pointerShape.pointer .Width = cptr->width ;
646+ pointerShape.pointer .Pitch = cptr->pitch ;
647+ pointerShape.pointer .pPixels = cptr->data ;
648+ pointerShape.pointer .XHot = cptr->x_hot ;
649+ pointerShape.pointer .YHot = cptr->y_hot ;
650+ pointerShape.X = cptr->cursor_x ;
651+ pointerShape.Y = cptr->cursor_y ;
652+
653+ status = pAdapter->SetPointerShape (&pointerShape, cptr->color_format , cptr->iscursorvisible );
654+
655+ if (status != STATUS_SUCCESS) {
656+ ERR (" SetPointerShape failed with status = %d\n " , status);
657+ return STATUS_UNSUCCESSFUL;
658+ }
659+ return STATUS_SUCCESS;
660+ }
661+
662+ static NTSTATUS IoctlSetPointerPosition (
663+ const PDEVICE_CONTEXT DeviceContext,
664+ const size_t InputBufferLength,
665+ const WDFREQUEST Request)
666+ {
667+ DXGKARG_SETPOINTERPOSITION pointerPosition;
668+ struct CursorData * cptr = NULL ;
669+ size_t bufSize;
670+ NTSTATUS status = STATUS_UNSUCCESSFUL;
671+
672+ TRACING ();
673+
674+ VioGpuAdapterLite* pAdapter =
675+ (VioGpuAdapterLite*)(DeviceContext ? DeviceContext->pvDeviceExtension : 0 );
676+
677+ if (!pAdapter) {
678+ ERR (" Couldnt' find adapter\n " );
679+ return status;
680+ }
681+
682+ status = WdfRequestRetrieveInputBuffer (Request, InputBufferLength, (PVOID*)&cptr, &bufSize);
683+ if (!NT_SUCCESS (status)) {
684+ ERR (" Couldn't retrieve Input buffer\n " );
685+ WdfRequestComplete (Request, STATUS_INSUFFICIENT_RESOURCES);
686+ return STATUS_INVALID_USER_BUFFER;
687+ }
688+
689+ if (cptr == NULL ) {
690+ return STATUS_UNSUCCESSFUL;
691+ }
692+
693+ RtlZeroMemory (&pointerPosition, sizeof (DXGKARG_SETPOINTERPOSITION));
694+ pointerPosition.X = cptr->cursor_x ;
695+ pointerPosition.Y = cptr->cursor_y ;
696+ pointerPosition.VidPnSourceId = cptr->screen_num ;
697+
698+ status = pAdapter->SetPointerPosition (&pointerPosition);
699+
700+ if (status != STATUS_SUCCESS) {
701+ ERR (" SetPointerPosition failed with status = %d\n " , status);
702+ return STATUS_UNSUCCESSFUL;
703+ }
704+ return STATUS_SUCCESS;
705+ }
0 commit comments