Author: hbelusca
Date: Sat Aug 9 13:22:50 2014
New Revision: 63844
URL:
http://svn.reactos.org/svn/reactos?rev=63844&view=rev
Log:
[NTVDM]: Add a compile-time-defined switch to be able to use the RegisterConsoleVDM API of
ReactOS/Windows, or an emulated one.
Modified:
trunk/reactos/subsystems/ntvdm/hardware/vga.c
Modified: trunk/reactos/subsystems/ntvdm/hardware/vga.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/hardware/…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/hardware/vga.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/hardware/vga.c [iso-8859-1] Sat Aug 9 13:22:50 2014
@@ -20,6 +20,12 @@
static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
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_DOSBOX_COLORS
@@ -288,44 +294,12 @@
#include <ntddvdeo.h>
-typedef
-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
-BOOL
-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;
-pRegisterConsoleVDM RegisterConsoleVDM = NULL;
-#endif
+#ifdef USE_REAL_REGISTERCONSOLEVDM
+
+#define __RegisterConsoleVDM RegisterConsoleVDM
+#define __InvalidateConsoleDIBits InvalidateConsoleDIBits
+
+#else
/*
* This private buffer, per-console, is used by
@@ -340,49 +314,49 @@
BOOL
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,
- PCHAR *lpVDMBuffer)
-{
- UNREFERENCED_PARAMETER(EventHandle_3);
+__RegisterConsoleVDM(IN DWORD dwDosVDMFlag,
+ IN HANDLE hEventHandle1,
+ IN HANDLE hEventHandle2,
+ IN HANDLE hEventHandle3,
+ IN DWORD Unused1,
+ OUT PULONG returned_val_1,
+ OUT PVOID* returned_val_2,
+ IN PVOID lpUnknownBuffer,
+ IN DWORD dwUnknownBufferLength,
+ IN COORD dwVDMBufferSize,
+ OUT PVOID* lpVDMBuffer)
+{
+ UNREFERENCED_PARAMETER(hEventHandle3);
UNREFERENCED_PARAMETER(Unused1);
UNREFERENCED_PARAMETER(returned_val_1);
UNREFERENCED_PARAMETER(returned_val_2);
UNREFERENCED_PARAMETER(lpUnknownBuffer);
- UNREFERENCED_PARAMETER(theUnknownBufferLength);
+ UNREFERENCED_PARAMETER(dwUnknownBufferLength);
SetLastError(0);
- DPRINT1("__RegisterConsoleVDM(%d)\n", IsDosVDM_flag);
+ DPRINT1("__RegisterConsoleVDM(%d)\n", dwDosVDMFlag);
if (lpVDMBuffer == NULL) return FALSE;
- if (IsDosVDM_flag)
+ if (dwDosVDMFlag != 0)
{
// if (EventHandle_1 == NULL || EventHandle_2 == NULL) return FALSE;
if (VDMBuffer != NULL) return FALSE;
- VDMBufferSize = theVDMBufferSize;
+ VDMBufferSize = dwVDMBufferSize;
/* HACK: Cache -- to be removed in the real implementation */
CharBuff = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
- theVDMBufferSize.X * theVDMBufferSize.Y
- * sizeof(CHAR_INFO));
+ VDMBufferSize.X * VDMBufferSize.Y
+ * sizeof(CHAR_INFO));
ASSERT(CharBuff);
VDMBuffer = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
- theVDMBufferSize.X * theVDMBufferSize.Y
- * sizeof(CHAR_CELL));
- *lpVDMBuffer = (PCHAR)VDMBuffer;
+ VDMBufferSize.X * VDMBufferSize.Y
+ * sizeof(CHAR_CELL));
+ *lpVDMBuffer = VDMBuffer;
return (VDMBuffer != NULL);
}
else
@@ -432,6 +406,8 @@
return InvalidateConsoleDIBits(hConsoleOutput, lpRect);
}
+#endif
+
/* PRIVATE FUNCTIONS **********************************************************/
static inline DWORD VgaGetAddressSize(VOID);
@@ -458,6 +434,9 @@
ULONG Length = 0;
PVIDEO_HARDWARE_STATE_HEADER State;
+#ifdef USE_REAL_REGISTERCONSOLEVDM
+ PCHAR_INFO CharBuff = NULL;
+#endif
SHORT i, j;
DWORD AddressSize, ScanlineSize;
DWORD Address = 0;
@@ -492,13 +471,21 @@
NULL,
0,
TextResolution,
- (PCHAR*)&TextFramebuffer);
+ (PVOID*)&TextFramebuffer);
if (!Success)
{
DisplayMessage(L"RegisterConsoleVDM failed with error %d\n",
GetLastError());
EmulatorTerminate();
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
@@ -559,6 +546,10 @@
/* Move to the next scanline */
Address += ScanlineSize;
}
+
+#ifdef USE_REAL_REGISTERCONSOLEVDM
+ if (CharBuff) HeapFree(GetProcessHeap(), 0, CharBuff);
+#endif
VgaUpdateCursorPosition();
@@ -1950,7 +1941,7 @@
NULL,
0,
dummySize,
- (PCHAR*)&dummyPtr);
+ &dummyPtr);
TextFramebuffer = NULL;
@@ -2039,11 +2030,6 @@
CloseHandle(AnotherEvent);
CloseHandle(EndEvent);
CloseHandle(StartEvent);
-
-#if 0
- RegisterConsoleVDM = NULL;
- FreeLibrary(hKernel32);
-#endif
}
/* EOF */