*/
#include "videoprt.h"
-#include "internal/ps.h"
/* GLOBAL VARIABLES ***********************************************************/
ULONG CsrssInitialized = FALSE;
-PEPROCESS Csrss = NULL;
+PKPROCESS Csrss = NULL;
/* PRIVATE FUNCTIONS **********************************************************/
-NTSTATUS STDCALL
+NTSTATUS NTAPI
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
return STATUS_SUCCESS;
}
-PVOID STDCALL
+PVOID NTAPI
IntVideoPortImageDirectoryEntryToData(
PVOID BaseAddress,
ULONG Directory)
if (Va == 0)
return NULL;
- return (PVOID)(BaseAddress + Va);
+ return (PVOID)((ULONG_PTR)BaseAddress + Va);
}
-PVOID STDCALL
+PVOID NTAPI
IntVideoPortGetProcAddress(
IN PVOID HwDeviceExtension,
IN PUCHAR FunctionName)
{
- SYSTEM_LOAD_IMAGE GdiDriverInfo;
+ SYSTEM_GDI_DRIVER_INFORMATION GdiDriverInfo;
PVOID BaseAddress;
PIMAGE_EXPORT_DIRECTORY ExportDir;
PUSHORT OrdinalPtr;
DPRINT("VideoPortGetProcAddress(%s)\n", FunctionName);
- RtlInitUnicodeString(&GdiDriverInfo.ModuleName, L"videoprt");
+ RtlInitUnicodeString(&GdiDriverInfo.DriverName, L"videoprt");
Status = ZwSetSystemInformation(
- SystemLoadImage,
+ SystemLoadGdiDriverInformation,
&GdiDriverInfo,
- sizeof(SYSTEM_LOAD_IMAGE));
+ sizeof(SYSTEM_GDI_DRIVER_INFORMATION));
if (!NT_SUCCESS(Status))
{
DPRINT("Couldn't get our own module handle?\n");
return NULL;
}
- BaseAddress = GdiDriverInfo.ModuleBase;
+ BaseAddress = GdiDriverInfo.ImageAddress;
/* Get the pointer to the export directory */
ExportDir = (PIMAGE_EXPORT_DIRECTORY)IntVideoPortImageDirectoryEntryToData(
((ULONG_PTR)BaseAddress + (ULONG_PTR)ExportDir->AddressOfNames);
for (i = 0; i < ExportDir->NumberOfNames; i++, NamePtr++, OrdinalPtr++)
{
- if (!_strnicmp((PCHAR)FunctionName, (PCHAR)(BaseAddress + *NamePtr),
+ if (!_strnicmp((PCHAR)FunctionName, (PCHAR)((ULONG_PTR)BaseAddress + *NamePtr),
strlen((PCHAR)FunctionName)))
{
return (PVOID)((ULONG_PTR)BaseAddress +
return NULL;
}
-VOID STDCALL
+VOID NTAPI
IntVideoPortDeferredRoutine(
IN PKDPC Dpc,
IN PVOID DeferredContext,
((PMINIPORT_DPC_ROUTINE)SystemArgument1)(HwDeviceExtension, SystemArgument2);
}
-ULONG STDCALL
+ULONG NTAPI
IntVideoPortAllocateDeviceNumber(VOID)
{
NTSTATUS Status;
return DeviceNumber;
}
-NTSTATUS STDCALL
+NTSTATUS NTAPI
IntVideoPortCreateAdapterDeviceObject(
IN PDRIVER_OBJECT DriverObject,
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension);
DeviceExtension->DeviceNumber = DeviceNumber;
+ DeviceExtension->DriverObject = DriverObject;
DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
DeviceExtension->FunctionalDeviceObject = *DeviceObject;
DeviceExtension->DriverExtension = DriverExtension;
/* FIXME: we have to detach the device object in IntVideoPortFindAdapter if it fails */
-NTSTATUS STDCALL
+NTSTATUS NTAPI
IntVideoPortFindAdapter(
IN PDRIVER_OBJECT DriverObject,
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
{
ConfigInfo.SystemMemorySize =
SystemBasicInfo.NumberOfPhysicalPages *
- SystemBasicInfo.PhysicalPageSize;
+ SystemBasicInfo.PageSize;
}
/*
}
VOID FASTCALL
-IntAttachToCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess)
+IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
{
- *CallingProcess = PsGetCurrentProcess();
+ *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
if (*CallingProcess != Csrss)
{
- if (PsGetCurrentThread()->ThreadsProcess != *CallingProcess)
- {
- *PrevAttachedProcess = *CallingProcess;
- KeDetachProcess();
- }
- else
- {
- *PrevAttachedProcess = NULL;
- }
- KeAttachProcess(Csrss);
+ KeStackAttachProcess(Csrss, ApcState);
}
}
VOID FASTCALL
-IntDetachFromCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess)
+IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
{
if (*CallingProcess != Csrss)
{
- KeDetachProcess();
- if (NULL != *PrevAttachedProcess)
- {
- KeAttachProcess(*PrevAttachedProcess);
- }
+ KeUnstackDetachProcess(ApcState);
}
}
* @implemented
*/
-ULONG STDCALL
+ULONG NTAPI
VideoPortInitialize(
IN PVOID Context1,
IN PVOID Context2,
DPRINT("VideoPortInitialize\n");
+ /*
+ * As a first thing do parameter checks.
+ */
+
+ if (HwInitializationData->HwInitDataSize > sizeof(VIDEO_HW_INITIALIZATION_DATA))
+ {
+ return STATUS_REVISION_MISMATCH;
+ }
+
+ if (HwInitializationData->HwFindAdapter == NULL ||
+ HwInitializationData->HwInitialize == NULL ||
+ HwInitializationData->HwStartIO == NULL)
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
/*
* NOTE:
* The driver extension can be already allocated in case that we were
* called by legacy driver and failed detecting device. Some miniport
- * drivers in that case adjust parameters and calls VideoPortInitialize
+ * drivers in that case adjust parameters and call VideoPortInitialize
* again.
*/
{
return Status;
}
+
+ /*
+ * Save the registry path. This should be done only once even if
+ * VideoPortInitialize is called multiple times.
+ */
+
+ if (RegistryPath->Length != 0)
+ {
+ DriverExtension->RegistryPath.Length = 0;
+ DriverExtension->RegistryPath.MaximumLength =
+ RegistryPath->Length + sizeof(UNICODE_NULL);
+ DriverExtension->RegistryPath.Buffer =
+ ExAllocatePoolWithTag(
+ PagedPool,
+ DriverExtension->RegistryPath.MaximumLength,
+ TAG('U', 'S', 'T', 'R'));
+ if (DriverExtension->RegistryPath.Buffer == NULL)
+ {
+ RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ RtlCopyUnicodeString(&DriverExtension->RegistryPath, RegistryPath);
+ }
+ else
+ {
+ RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
+ }
}
/*
RtlCopyMemory(
&DriverExtension->InitializationData,
HwInitializationData,
- min(sizeof(VIDEO_HW_INITIALIZATION_DATA),
- HwInitializationData->HwInitDataSize));
- if (sizeof(VIDEO_HW_INITIALIZATION_DATA) > HwInitializationData->HwInitDataSize)
+ HwInitializationData->HwInitDataSize);
+ if (HwInitializationData->HwInitDataSize <
+ sizeof(VIDEO_HW_INITIALIZATION_DATA))
{
RtlZeroMemory((PVOID)((ULONG_PTR)&DriverExtension->InitializationData +
HwInitializationData->HwInitDataSize),
}
DriverExtension->HwContext = HwContext;
- /* we can't use RtlDuplicateUnicodeString because only ntdll exposes it... */
- if (RegistryPath->Length != 0)
- {
- DriverExtension->RegistryPath.Length = 0;
- DriverExtension->RegistryPath.MaximumLength = RegistryPath->Length + sizeof(UNICODE_NULL);
- DriverExtension->RegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool,
- DriverExtension->RegistryPath.MaximumLength,
- TAG('U', 'S', 'T', 'R'));
- if (DriverExtension->RegistryPath.Buffer == NULL)
- {
- RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- RtlCopyUnicodeString(&DriverExtension->RegistryPath, RegistryPath);
- }
- else
- {
- RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
- }
-
switch (HwInitializationData->HwInitDataSize)
{
/*
DriverObject->MajorFunction[IRP_MJ_CREATE] = IntVideoPortDispatchOpen;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = IntVideoPortDispatchClose;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IntVideoPortDispatchDeviceControl;
+ DriverObject->MajorFunction[IRP_MJ_WRITE] = IntVideoPortDispatchWrite;
DriverObject->DriverUnload = IntVideoPortUnload;
/*
* @unimplemented
*/
-VOID STDCALL
+VOID NTAPI
VideoPortLogError(
IN PVOID HwDeviceExtension,
IN PVIDEO_REQUEST_PACKET Vrp OPTIONAL,
* @implemented
*/
-UCHAR STDCALL
+UCHAR NTAPI
VideoPortGetCurrentIrql(VOID)
{
return KeGetCurrentIrql();
PMINIPORT_GET_REGISTRY_ROUTINE HwGetRegistryRoutine;
} QUERY_REGISTRY_CALLBACK_CONTEXT, *PQUERY_REGISTRY_CALLBACK_CONTEXT;
-static NTSTATUS STDCALL
+static NTSTATUS NTAPI
QueryRegistryCallback(
IN PWSTR ValueName,
IN ULONG ValueType,
* @unimplemented
*/
-VP_STATUS STDCALL
+VP_STATUS NTAPI
VideoPortGetRegistryParameters(
IN PVOID HwDeviceExtension,
IN PWSTR ParameterName,
* @implemented
*/
-VP_STATUS STDCALL
+VP_STATUS NTAPI
VideoPortSetRegistryParameters(
IN PVOID HwDeviceExtension,
IN PWSTR ValueName,
* @implemented
*/
-VP_STATUS STDCALL
+VP_STATUS NTAPI
VideoPortGetVgaStatus(
IN PVOID HwDeviceExtension,
OUT PULONG VgaStatus)
* @implemented
*/
-PVOID STDCALL
+PVOID NTAPI
VideoPortGetRomImage(
IN PVOID HwDeviceExtension,
IN PVOID Unused1,
IN ULONG Length)
{
static PVOID RomImageBuffer = NULL;
- PEPROCESS CallingProcess;
- PEPROCESS PrevAttachedProcess;
+ PKPROCESS CallingProcess;
+ KAPC_STATE ApcState;
DPRINT("VideoPortGetRomImage(HwDeviceExtension 0x%X Length 0x%X)\n",
HwDeviceExtension, Length);
return NULL;
}
- IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntAttachToCSRSS(&CallingProcess, &ApcState);
RtlCopyMemory(RomImageBuffer, (PUCHAR)0xC0000, Length);
- IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntDetachFromCSRSS(&CallingProcess, &ApcState);
return RomImageBuffer;
}
* @implemented
*/
-BOOLEAN STDCALL
+BOOLEAN NTAPI
VideoPortScanRom(
IN PVOID HwDeviceExtension,
IN PUCHAR RomBase,
* @implemented
*/
-BOOLEAN STDCALL
+BOOLEAN NTAPI
VideoPortSynchronizeExecution(
IN PVOID HwDeviceExtension,
IN VIDEO_SYNCHRONIZE_PRIORITY Priority,
* @implemented
*/
-VP_STATUS STDCALL
+VP_STATUS NTAPI
VideoPortEnumerateChildren(
IN PVOID HwDeviceExtension,
IN PVOID Reserved)
* @unimplemented
*/
-VP_STATUS STDCALL
+VP_STATUS NTAPI
VideoPortCreateSecondaryDisplay(
IN PVOID HwDeviceExtension,
IN OUT PVOID *SecondaryDeviceExtension,
* @implemented
*/
-BOOLEAN STDCALL
+BOOLEAN NTAPI
VideoPortQueueDpc(
IN PVOID HwDeviceExtension,
IN PMINIPORT_DPC_ROUTINE CallbackRoutine,
* @unimplemented
*/
-PVOID STDCALL
+PVOID NTAPI
VideoPortGetAssociatedDeviceExtension(IN PVOID DeviceObject)
{
DPRINT1("VideoPortGetAssociatedDeviceExtension: Unimplemented.\n");
* @implemented
*/
-VP_STATUS STDCALL
+VP_STATUS NTAPI
VideoPortGetVersion(
IN PVOID HwDeviceExtension,
IN OUT PVPOSVERSIONINFO VpOsVersionInfo)
* @unimplemented
*/
-BOOLEAN STDCALL
+BOOLEAN NTAPI
VideoPortCheckForDeviceExistence(
IN PVOID HwDeviceExtension,
IN USHORT VendorId,
* @unimplemented
*/
-VP_STATUS STDCALL
+VP_STATUS NTAPI
VideoPortRegisterBugcheckCallback(
IN PVOID HwDeviceExtension,
IN ULONG BugcheckCode,
* @implemented
*/
-LONGLONG STDCALL
+LONGLONG NTAPI
VideoPortQueryPerformanceCounter(
IN PVOID HwDeviceExtension,
OUT PLONGLONG PerformanceFrequency OPTIONAL)
* @implemented
*/
-VOID STDCALL
+VOID NTAPI
VideoPortAcquireDeviceLock(
IN PVOID HwDeviceExtension)
{
* @implemented
*/
-VOID STDCALL
+VOID NTAPI
VideoPortReleaseDeviceLock(
IN PVOID HwDeviceExtension)
{
ASSERT(Status == 0);
}
+/*
+ * @unimplemented
+ */
+
+VOID NTAPI
+VpNotifyEaData(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PVOID Data)
+{
+}