mirror of
https://github.com/reactos/reactos.git
synced 2024-07-31 08:39:05 +00:00
[NTVDM]: Add a compile-time-defined switch to be able to use the RegisterConsoleVDM API of ReactOS/Windows, or an emulated one.
svn path=/trunk/; revision=63844
This commit is contained in:
parent
3a6aa828e4
commit
f9a6eb7bc4
|
@ -21,6 +21,12 @@
|
||||||
static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
|
static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
|
||||||
static CONST DWORD MemoryLimit[] = { 0xAFFFF, 0xAFFFF, 0xB7FFF, 0xBFFFF };
|
static CONST DWORD MemoryLimit[] = { 0xAFFFF, 0xAFFFF, 0xB7FFF, 0xBFFFF };
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Activate this line if you want to use the real
|
||||||
|
* RegisterConsoleVDM API of Windows/ReactOS.
|
||||||
|
*/
|
||||||
|
// #define USE_REAL_REGISTERCONSOLEVDM
|
||||||
|
|
||||||
#define USE_REACTOS_COLORS
|
#define USE_REACTOS_COLORS
|
||||||
// #define USE_DOSBOX_COLORS
|
// #define USE_DOSBOX_COLORS
|
||||||
|
|
||||||
|
@ -288,44 +294,12 @@ static SMALL_RECT UpdateRectangle = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
#include <ntddvdeo.h>
|
#include <ntddvdeo.h>
|
||||||
|
|
||||||
typedef
|
#ifdef USE_REAL_REGISTERCONSOLEVDM
|
||||||
BOOL
|
|
||||||
(WINAPI *pRegisterConsoleVDM)
|
|
||||||
(
|
|
||||||
BOOL IsDosVDM_flag,
|
|
||||||
HANDLE EventHandle_1,
|
|
||||||
HANDLE EventHandle_2,
|
|
||||||
HANDLE EventHandle_3,
|
|
||||||
int Unused1,
|
|
||||||
PVOID returned_val_1,
|
|
||||||
PVOID *returned_val_2,
|
|
||||||
PVOID lpUnknownBuffer,
|
|
||||||
DWORD theUnknownBufferLength,
|
|
||||||
COORD theVDMBufferSize,
|
|
||||||
PCHAR *lpVDMBuffer
|
|
||||||
);
|
|
||||||
|
|
||||||
#if 0
|
#define __RegisterConsoleVDM RegisterConsoleVDM
|
||||||
BOOL
|
#define __InvalidateConsoleDIBits InvalidateConsoleDIBits
|
||||||
WINAPI
|
|
||||||
RegisterConsoleVDM
|
|
||||||
(
|
|
||||||
BOOL IsDosVDM_flag,
|
|
||||||
HANDLE EventHandle_1,
|
|
||||||
HANDLE EventHandle_2,
|
|
||||||
HANDLE EventHandle_3,
|
|
||||||
int Unused1,
|
|
||||||
PVOID returned_val_1,
|
|
||||||
PVOID *returned_val_2,
|
|
||||||
PVOID lpUnknownBuffer,
|
|
||||||
DWORD theUnknownBufferLength,
|
|
||||||
COORD theVDMBufferSize,
|
|
||||||
PVOID *lpVDMBuffer
|
|
||||||
);
|
|
||||||
|
|
||||||
HMODULE hKernel32 = NULL;
|
#else
|
||||||
pRegisterConsoleVDM RegisterConsoleVDM = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This private buffer, per-console, is used by
|
* This private buffer, per-console, is used by
|
||||||
|
@ -340,49 +314,49 @@ static PCHAR_INFO CharBuff = NULL; // This is a hack, which is unneeded
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
__RegisterConsoleVDM(BOOL IsDosVDM_flag,
|
__RegisterConsoleVDM(IN DWORD dwDosVDMFlag,
|
||||||
HANDLE EventHandle_1,
|
IN HANDLE hEventHandle1,
|
||||||
HANDLE EventHandle_2,
|
IN HANDLE hEventHandle2,
|
||||||
HANDLE EventHandle_3,
|
IN HANDLE hEventHandle3,
|
||||||
int Unused1,
|
IN DWORD Unused1,
|
||||||
PVOID returned_val_1,
|
OUT PULONG returned_val_1,
|
||||||
PVOID *returned_val_2,
|
OUT PVOID* returned_val_2,
|
||||||
PVOID lpUnknownBuffer,
|
IN PVOID lpUnknownBuffer,
|
||||||
DWORD theUnknownBufferLength,
|
IN DWORD dwUnknownBufferLength,
|
||||||
COORD theVDMBufferSize,
|
IN COORD dwVDMBufferSize,
|
||||||
PCHAR *lpVDMBuffer)
|
OUT PVOID* lpVDMBuffer)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(EventHandle_3);
|
UNREFERENCED_PARAMETER(hEventHandle3);
|
||||||
UNREFERENCED_PARAMETER(Unused1);
|
UNREFERENCED_PARAMETER(Unused1);
|
||||||
UNREFERENCED_PARAMETER(returned_val_1);
|
UNREFERENCED_PARAMETER(returned_val_1);
|
||||||
UNREFERENCED_PARAMETER(returned_val_2);
|
UNREFERENCED_PARAMETER(returned_val_2);
|
||||||
UNREFERENCED_PARAMETER(lpUnknownBuffer);
|
UNREFERENCED_PARAMETER(lpUnknownBuffer);
|
||||||
UNREFERENCED_PARAMETER(theUnknownBufferLength);
|
UNREFERENCED_PARAMETER(dwUnknownBufferLength);
|
||||||
|
|
||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
DPRINT1("__RegisterConsoleVDM(%d)\n", IsDosVDM_flag);
|
DPRINT1("__RegisterConsoleVDM(%d)\n", dwDosVDMFlag);
|
||||||
|
|
||||||
if (lpVDMBuffer == NULL) return FALSE;
|
if (lpVDMBuffer == NULL) return FALSE;
|
||||||
|
|
||||||
if (IsDosVDM_flag)
|
if (dwDosVDMFlag != 0)
|
||||||
{
|
{
|
||||||
// if (EventHandle_1 == NULL || EventHandle_2 == NULL) return FALSE;
|
// if (EventHandle_1 == NULL || EventHandle_2 == NULL) return FALSE;
|
||||||
if (VDMBuffer != NULL) return FALSE;
|
if (VDMBuffer != NULL) return FALSE;
|
||||||
|
|
||||||
VDMBufferSize = theVDMBufferSize;
|
VDMBufferSize = dwVDMBufferSize;
|
||||||
|
|
||||||
/* HACK: Cache -- to be removed in the real implementation */
|
/* HACK: Cache -- to be removed in the real implementation */
|
||||||
CharBuff = HeapAlloc(GetProcessHeap(),
|
CharBuff = HeapAlloc(GetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
theVDMBufferSize.X * theVDMBufferSize.Y
|
VDMBufferSize.X * VDMBufferSize.Y
|
||||||
* sizeof(CHAR_INFO));
|
* sizeof(CHAR_INFO));
|
||||||
ASSERT(CharBuff);
|
ASSERT(CharBuff);
|
||||||
|
|
||||||
VDMBuffer = HeapAlloc(GetProcessHeap(),
|
VDMBuffer = HeapAlloc(GetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
theVDMBufferSize.X * theVDMBufferSize.Y
|
VDMBufferSize.X * VDMBufferSize.Y
|
||||||
* sizeof(CHAR_CELL));
|
* sizeof(CHAR_CELL));
|
||||||
*lpVDMBuffer = (PCHAR)VDMBuffer;
|
*lpVDMBuffer = VDMBuffer;
|
||||||
return (VDMBuffer != NULL);
|
return (VDMBuffer != NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -432,6 +406,8 @@ __InvalidateConsoleDIBits(IN HANDLE hConsoleOutput,
|
||||||
return InvalidateConsoleDIBits(hConsoleOutput, lpRect);
|
return InvalidateConsoleDIBits(hConsoleOutput, lpRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS **********************************************************/
|
/* PRIVATE FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
static inline DWORD VgaGetAddressSize(VOID);
|
static inline DWORD VgaGetAddressSize(VOID);
|
||||||
|
@ -458,6 +434,9 @@ static BOOL VgaAttachToConsoleInternal(PCOORD Resolution)
|
||||||
ULONG Length = 0;
|
ULONG Length = 0;
|
||||||
PVIDEO_HARDWARE_STATE_HEADER State;
|
PVIDEO_HARDWARE_STATE_HEADER State;
|
||||||
|
|
||||||
|
#ifdef USE_REAL_REGISTERCONSOLEVDM
|
||||||
|
PCHAR_INFO CharBuff = NULL;
|
||||||
|
#endif
|
||||||
SHORT i, j;
|
SHORT i, j;
|
||||||
DWORD AddressSize, ScanlineSize;
|
DWORD AddressSize, ScanlineSize;
|
||||||
DWORD Address = 0;
|
DWORD Address = 0;
|
||||||
|
@ -492,7 +471,7 @@ static BOOL VgaAttachToConsoleInternal(PCOORD Resolution)
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
TextResolution,
|
TextResolution,
|
||||||
(PCHAR*)&TextFramebuffer);
|
(PVOID*)&TextFramebuffer);
|
||||||
if (!Success)
|
if (!Success)
|
||||||
{
|
{
|
||||||
DisplayMessage(L"RegisterConsoleVDM failed with error %d\n", GetLastError());
|
DisplayMessage(L"RegisterConsoleVDM failed with error %d\n", GetLastError());
|
||||||
|
@ -500,6 +479,14 @@ static BOOL VgaAttachToConsoleInternal(PCOORD Resolution)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_REAL_REGISTERCONSOLEVDM
|
||||||
|
CharBuff = HeapAlloc(GetProcessHeap(),
|
||||||
|
HEAP_ZERO_MEMORY,
|
||||||
|
TextResolution.X * TextResolution.Y
|
||||||
|
* sizeof(CHAR_INFO));
|
||||||
|
ASSERT(CharBuff);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Resize the console
|
* Resize the console
|
||||||
*/
|
*/
|
||||||
|
@ -560,6 +547,10 @@ static BOOL VgaAttachToConsoleInternal(PCOORD Resolution)
|
||||||
Address += ScanlineSize;
|
Address += ScanlineSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_REAL_REGISTERCONSOLEVDM
|
||||||
|
if (CharBuff) HeapFree(GetProcessHeap(), 0, CharBuff);
|
||||||
|
#endif
|
||||||
|
|
||||||
VgaUpdateCursorPosition();
|
VgaUpdateCursorPosition();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1950,7 +1941,7 @@ VOID VgaDetachFromConsole(BOOL ChangingMode)
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
dummySize,
|
dummySize,
|
||||||
(PCHAR*)&dummyPtr);
|
&dummyPtr);
|
||||||
|
|
||||||
TextFramebuffer = NULL;
|
TextFramebuffer = NULL;
|
||||||
|
|
||||||
|
@ -2039,11 +2030,6 @@ VOID VgaCleanup(VOID)
|
||||||
CloseHandle(AnotherEvent);
|
CloseHandle(AnotherEvent);
|
||||||
CloseHandle(EndEvent);
|
CloseHandle(EndEvent);
|
||||||
CloseHandle(StartEvent);
|
CloseHandle(StartEvent);
|
||||||
|
|
||||||
#if 0
|
|
||||||
RegisterConsoleVDM = NULL;
|
|
||||||
FreeLibrary(hKernel32);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue