Skip to content

Commit

Permalink
Fix dxgkrnl loading on Vista->11 and ReactOS Longhorn - extend a little
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFire01 committed Apr 13, 2023
1 parent 8072bca commit e38324b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dxgk.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ DxgkInitialize(


//TODO: build a IO Contro request

RDDM_SetupIoControlReq(DeviceObject);

//TODO: windows seems to unload if the following above fails
return Status;
Expand Down
56 changes: 50 additions & 6 deletions Dxgk_manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,63 @@ RDDM_LoadDxgkrnl(FILE_OBJECT **FileObject, DEVICE_OBJECT **DeviceObject)
NTSTATUS Status;
UNICODE_STRING DriverServiceName;
UNICODE_STRING DriverSourceName;
PCWSTR DriverNameString = L"DXGKrnl"; /* Taken from windows Vista->11 registry */

/* Attempt to load DXGKRNL.SYS via the Service string */
RtlInitUnicodeString(&DriverServiceName, DriverNameString);
// DPRINT1("RDDM_LoadDxgkrnl: Attempting to load DXGKRNL\n");
RtlInitUnicodeString(&DriverServiceName, L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\DXGKrnl");
Status = ZwLoadDriver(&DriverServiceName);
if (Status != STATUS_SUCCESS)
{
DPRINT1("Failed to load DXGKrnl From WDDM miniport driver\n");
DPRINT1("Failed to load DXGKrnl From WDDM miniport driver %d\n", Status);
return Status;
}
RtlInitUnicodeString(&DriverSourceName, L"\\Device\\DxgKrnl"); /* Taken from windows Vista->11 registry */

Status = IoGetDeviceObjectPointer(&DriverSourceName, 0xc0000000,
FileObject, DeviceObject);
// DPRINT1("RDDM_LoadDxgkrnl: Sucessfully Loaded DXGKRNL\n");
return Status;
}
}


NTSTATUS
RDDM_DeviceIoControlConfiguration(ULONG IoControlCode,
DEVICE_OBJECT *DeviceObject,
PDXGKRNL_INTERFACE DriverInitData)
{
NTSTATUS Status = 0;
PIRP Irp;
IO_STATUS_BLOCK IoStatusBlock = {0};
KEVENT Event = {0};

KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp = IoBuildDeviceIoControlRequest(0x230047, //TODO: name this, was gathered via windbg (FROM VISTA RTM)
DeviceObject,
NULL,
0,
DriverInitData,
sizeof(DXGKRNL_INTERFACE),
TRUE,
&Event,
&IoStatusBlock);

Status = IofCallDriver(DeviceObject, Irp);
if (Status < 0) {
// DPRINT1("Failed to setup dxgkrnl function pointers: %d\n", Status);
return Status;
}

return STATUS_SUCCESS;
}

VOID
RDDM_SetupIoControlReq(DEVICE_OBJECT *DeviceObject)
{
NTSTATUS Status;
DXGKRNL_INTERFACE DriverInitData; //TODO: This isn't correct
Status = RDDM_DeviceIoControlConfiguration(0x230047, //TODO: name this, was gathered via windbg (FROM VISTA RTM)
DeviceObject,
&DriverInitData);
//DPRINT1("RDDM_DeviceIoControlConfiguration left with Status %d\n", Status);
//DPRINT1("Miniport has detected DXGKRNL_INTERFACE size: 0x%X\n",DriverInitData.Size);
//DPRINT1("Miniport has detected WDDM version 0x%X\n",DriverInitData.Version);
//DPRINT1("Pointer to first function pointer is %X\n",DriverInitData.DxgkCbEvalAcpiMethod);
}

0 comments on commit e38324b

Please sign in to comment.