46#if (NTDDI_VERSION < NTDDI_VISTA) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA)
89#if (NTDDI_VERSION < NTDDI_VISTA) && (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA)
91#define LOAD_IMPORT(func) \
92 (RtlInitUnicodeString(&ImportName, L ## #func), \
93 (func) = MmGetSystemRoutineAddress(&ImportName))
113#define IsLowV86Mem(_Seg, _Off) ((((_Seg) << 4) + (_Off)) < (0xa0000))
118ProtectLowV86Mem(
VOID)
140UnprotectLowV86Mem(
VOID)
163IntInitializeVideoAddressSpace(
VOID)
172 CHAR IVTAndBda[1024 + 256];
202 DPRINT1(
"Couldn't open \\Device\\PhysicalMemory\n");
207 Offset.QuadPart = 0xa0000;
210 Status = ZwMapViewOfSection(PhysMemHandle,
232 DPRINT1(
"Couldn't map physical memory at the right address (was %x)\n",
250 DPRINT1(
"Failed to allocate virtual memory (Status %x)\n",
Status);
255 DPRINT1(
"Failed to allocate virtual memory at right address (was %x)\n",
272 VDMAddressSpaceInitialized =
TRUE;
282typedef struct _INT10_INTERFACE
292static const INT10_INTERFACE *Int10Vtbl;
293#define INT10(func) Int10Vtbl->Int10##func
295#define INT10(func) IntInt10##func##Emu
318IntInt10AllocateBufferV86(
337 MemoryAddress = (
PVOID)0x20000;
347 WARN_(VIDEOPRT,
"- ZwAllocateVirtualMemory failed\n");
352 if (MemoryAddress > (
PVOID)(0x100000 -
Size))
358 WARN_(VIDEOPRT,
"- Unacceptable memory allocated\n");
383 TRACE_(VIDEOPRT,
"IntInt10AllocateBuffer\n");
388 INFO_(VIDEOPRT,
"- Segment: 0x%x\n", *Seg);
389 INFO_(VIDEOPRT,
"- Offset : 0x%x\n", *
Off);
414IntInt10FreeBufferV86(
449 TRACE_(VIDEOPRT,
"IntInt10FreeBuffer\n");
450 INFO_(VIDEOPRT,
"- Segment: 0x%x\n", Seg);
451 INFO_(VIDEOPRT,
"- Offset : 0x%x\n",
Off);
477IntInt10ReadMemoryV86(
493 if (IsLowV86Mem(Seg,
Off))
494 UnprotectLowV86Mem();
496 if (IsLowV86Mem(Seg,
Off))
514 TRACE_(VIDEOPRT,
"IntInt10ReadMemory\n");
515 INFO_(VIDEOPRT,
"- Segment: 0x%x\n", Seg);
516 INFO_(VIDEOPRT,
"- Offset : 0x%x\n",
Off);
544IntInt10WriteMemoryV86(
560 if (IsLowV86Mem(Seg,
Off))
561 UnprotectLowV86Mem();
563 if (IsLowV86Mem(Seg,
Off))
581 TRACE_(VIDEOPRT,
"IntInt10WriteMemory\n");
582 INFO_(VIDEOPRT,
"- Segment: 0x%x\n", Seg);
583 INFO_(VIDEOPRT,
"- Offset : 0x%x\n",
Off);
603 if (!VDMAddressSpaceInitialized)
610 ERR_(VIDEOPRT,
"Warning: Attempt to call %s before Int10 support is initialized.\n",
__FUNCTION__);
666 if (!VDMAddressSpaceInitialized)
673 ERR_(VIDEOPRT,
"Warning: Attempt to call %s before Int10 support is initialized.\n",
__FUNCTION__);
701 UnprotectLowV86Mem();
746static const INT10_INTERFACE Int10IFace[2] =
753 { IntInt10AllocateBufferV86,
754 IntInt10FreeBufferV86,
755 IntInt10ReadMemoryV86,
756 IntInt10WriteMemoryV86,
757 IntInt10CallBiosV86 }
759static const INT10_INTERFACE *Int10Vtbl = &Int10IFace[0];
770 if (!FirstInitialization)
772 FirstInitialization =
TRUE;
775 if (!VideoPortDisableX86Emulator)
781 DPRINT1(
"Could not initialize the x86 emulator; falling back to V86 mode\n");
782 VideoPortDisableX86Emulator =
TRUE;
786 Int10Vtbl = &Int10IFace[1];
797 return IntInitializeVideoAddressSpace();
819 RtlCopyMemory(&Int10BiosArguments, BiosArguments,
sizeof(*BiosArguments));
820 Int10BiosArguments.
SegDs = 0;
821 Int10BiosArguments.
SegEs = 0;
827 RtlCopyMemory(BiosArguments, &Int10BiosArguments,
sizeof(*BiosArguments));
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define STATUS_NOT_SUPPORTED
#define ERROR_NOT_ENOUGH_MEMORY
#define NT_SUCCESS(StatCode)
#define RTL_CONSTANT_STRING(s)
#define ERROR_INVALID_PARAMETER
#define EXCEPTION_EXECUTE_HANDLER
NTSTATUS IntInitializeInt10(VOID)
VP_STATUS NTAPI IntInt10CallBios(_In_ PVOID Context, _Inout_ PINT10_BIOS_ARGUMENTS BiosArguments)
VP_STATUS NTAPI IntInt10WriteMemory(_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
VP_STATUS NTAPI VideoPortInt10(IN PVOID HwDeviceExtension, IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments)
static VP_STATUS NTAPI IntInt10AllocateBufferEmu(_In_ PVOID Context, _Out_ PUSHORT Seg, _Out_ PUSHORT Off, _Inout_ PULONG Length)
VP_STATUS NTAPI IntInt10AllocateBuffer(_In_ PVOID Context, _Out_ PUSHORT Seg, _Out_ PUSHORT Off, _Inout_ PULONG Length)
static VP_STATUS NTAPI IntInt10ReadMemoryEmu(_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
static VP_STATUS NTAPI IntInt10FreeBufferEmu(_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off)
static BOOLEAN IntInitializeX86Emu(VOID)
static VP_STATUS NTAPI IntInt10WriteMemoryEmu(_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
KMUTEX VideoPortInt10Mutex
VP_STATUS NTAPI IntInt10ReadMemory(_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
VP_STATUS NTAPI IntInt10FreeBuffer(_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off)
static VP_STATUS NTAPI IntInt10CallBiosEmu(_In_ PVOID Context, _Inout_ PINT10_BIOS_ARGUMENTS BiosArguments)
#define InitializeObjectAttributes(p, n, a, r, s)
NTSYSAPI NTSTATUS NTAPI ZwOpenSection(_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define _In_reads_bytes_(s)
#define _Out_writes_bytes_(s)
#define SECTION_ALL_ACCESS
#define NtCurrentProcess()
#define PAGE_EXECUTE_READWRITE
#define UNREFERENCED_PARAMETER(P)
_In_ ULONG _In_ ULONG Offset
_In_ ULONG _In_ ULONG _In_ ULONG Length
_Out_ PKAPC_STATE ApcState
NTSTATUS NTAPI NtVdmControl(IN ULONG ControlCode, IN PVOID ControlData)
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
VP_STATUS(NTAPI * PINT10_CALL_BIOS)(IN PVOID Context, IN OUT PINT10_BIOS_ARGUMENTS BiosArguments)
VP_STATUS(NTAPI * PINT10_ALLOCATE_BUFFER)(IN PVOID Context, OUT PUSHORT Seg, OUT PUSHORT Off, IN OUT PULONG Length)
VP_STATUS(NTAPI * PINT10_FREE_BUFFER)(IN PVOID Context, IN USHORT Seg, IN USHORT Off)
VP_STATUS(NTAPI * PINT10_WRITE_MEMORY)(IN PVOID Context, IN USHORT Seg, IN USHORT Off, IN PVOID Buffer, IN ULONG Length)
VP_STATUS(NTAPI * PINT10_READ_MEMORY)(IN PVOID Context, IN USHORT Seg, IN USHORT Off, OUT PVOID Buffer, IN ULONG Length)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_UNSUCCESSFUL
NTSTATUS NTAPI Ke386CallBios(IN ULONG Int, OUT PCONTEXT Context)
VOID FASTCALL IntDetachFromCSRSS(_In_ PKPROCESS CallingProcess, _In_ PKAPC_STATE ApcState)
Detach the current thread from the CSRSS process. This routine is to be invoked after a previous succ...
BOOLEAN FASTCALL IntAttachToCSRSS(_Outptr_ PKPROCESS *CallingProcess, _Out_ PKAPC_STATE ApcState)
Attach the current thread to the CSRSS process. The caller must detach from the process by invoking I...
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFUSBPIPE _In_ WDFREQUEST _In_opt_ WDFMEMORY ReadMemory
_Must_inspect_result_ _In_ WDFUSBPIPE _In_ WDFREQUEST _In_opt_ WDFMEMORY WriteMemory
NTSTATUS NTAPI x86BiosAllocateBuffer(_Inout_ ULONG *Size, _Out_ USHORT *Segment, _Out_ USHORT *Offset)
NTSTATUS NTAPI x86BiosFreeBuffer(_In_ USHORT Segment, _In_ USHORT Offset)
NTSTATUS NTAPI x86BiosReadMemory(_In_ USHORT Segment, _In_ USHORT Offset, _Out_writes_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
BOOLEAN NTAPI x86BiosCall(_In_ ULONG InterruptNumber, _Inout_ PX86_BIOS_REGISTERS Registers)
NTSTATUS NTAPI x86BiosWriteMemory(_In_ USHORT Segment, _In_ USHORT Offset, _In_reads_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
#define KeWaitForMutexObject
#define PsGetCurrentProcess