mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 12:04:51 +00:00
[NTVDM]
Make the emulator callbacks non-static. In BiosPrintCallback, use EmulatorWriteMemory instead of VgaWriteMemory, because VgaWriteMemory does not do any input validation. Improve EmulatorWriteMemory input validation and bound checking. svn path=/branches/ntvdm/; revision=60903
This commit is contained in:
parent
53d6212640
commit
f4f6809d67
3 changed files with 65 additions and 13 deletions
|
@ -760,7 +760,8 @@ VOID BiosPrintCharacter(CHAR Character, BYTE Attribute, BYTE Page)
|
||||||
/* Default character */
|
/* Default character */
|
||||||
|
|
||||||
/* Write the character */
|
/* Write the character */
|
||||||
VgaWriteMemory(TO_LINEAR(TEXT_VIDEO_SEG,
|
EmulatorWriteMemory(&EmulatorContext,
|
||||||
|
TO_LINEAR(TEXT_VIDEO_SEG,
|
||||||
Page * Bda->VideoPageSize
|
Page * Bda->VideoPageSize
|
||||||
+ (Row * Bda->ScreenColumns + Column) * sizeof(WORD)),
|
+ (Row * Bda->ScreenColumns + Column) * sizeof(WORD)),
|
||||||
(LPVOID)&CharData,
|
(LPVOID)&CharData,
|
||||||
|
@ -789,6 +790,8 @@ VOID BiosPrintCharacter(CHAR Character, BYTE Attribute, BYTE Page)
|
||||||
Rectangle,
|
Rectangle,
|
||||||
Page,
|
Page,
|
||||||
DEFAULT_ATTRIBUTE);
|
DEFAULT_ATTRIBUTE);
|
||||||
|
|
||||||
|
Row--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the cursor position */
|
/* Set the cursor position */
|
||||||
|
|
|
@ -29,7 +29,7 @@ static BOOLEAN A20Line = FALSE;
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS **********************************************************/
|
/* PRIVATE FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
static VOID WINAPI EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
|
VOID WINAPI EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(State);
|
UNREFERENCED_PARAMETER(State);
|
||||||
|
|
||||||
|
@ -47,14 +47,16 @@ static VOID WINAPI EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID
|
||||||
&& (Address < VgaGetVideoLimitAddress()))
|
&& (Address < VgaGetVideoLimitAddress()))
|
||||||
{
|
{
|
||||||
DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress());
|
DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress());
|
||||||
|
DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress())
|
||||||
|
- VgaAddress + 1;
|
||||||
LPBYTE VgaBuffer = (LPBYTE)((ULONG_PTR)Buffer + VgaAddress - Address);
|
LPBYTE VgaBuffer = (LPBYTE)((ULONG_PTR)Buffer + VgaAddress - Address);
|
||||||
|
|
||||||
/* Read from the VGA memory */
|
/* Read from the VGA memory */
|
||||||
VgaReadMemory(VgaAddress, VgaBuffer, Size);
|
VgaReadMemory(VgaAddress, VgaBuffer, ActualSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
|
VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(State);
|
UNREFERENCED_PARAMETER(State);
|
||||||
|
|
||||||
|
@ -75,14 +77,16 @@ static VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOI
|
||||||
&& (Address < VgaGetVideoLimitAddress()))
|
&& (Address < VgaGetVideoLimitAddress()))
|
||||||
{
|
{
|
||||||
DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress());
|
DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress());
|
||||||
|
DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress())
|
||||||
|
- VgaAddress + 1;
|
||||||
LPBYTE VgaBuffer = (LPBYTE)((ULONG_PTR)Buffer + VgaAddress - Address);
|
LPBYTE VgaBuffer = (LPBYTE)((ULONG_PTR)Buffer + VgaAddress - Address);
|
||||||
|
|
||||||
/* Write to the VGA memory */
|
/* Write to the VGA memory */
|
||||||
VgaWriteMemory(VgaAddress, VgaBuffer, Size);
|
VgaWriteMemory(VgaAddress, VgaBuffer, ActualSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID WINAPI EmulatorReadIo(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize)
|
VOID WINAPI EmulatorReadIo(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize)
|
||||||
{
|
{
|
||||||
INT i, j;
|
INT i, j;
|
||||||
LPBYTE Address = (LPBYTE)Buffer;
|
LPBYTE Address = (LPBYTE)Buffer;
|
||||||
|
@ -169,7 +173,7 @@ static VOID WINAPI EmulatorReadIo(PFAST486_STATE State, ULONG Port, PVOID Buffer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID WINAPI EmulatorWriteIo(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize)
|
VOID WINAPI EmulatorWriteIo(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize)
|
||||||
{
|
{
|
||||||
INT i, j;
|
INT i, j;
|
||||||
LPBYTE Address = (LPBYTE)Buffer;
|
LPBYTE Address = (LPBYTE)Buffer;
|
||||||
|
@ -268,7 +272,7 @@ static VOID WINAPI EmulatorWriteIo(PFAST486_STATE State, ULONG Port, PVOID Buffe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID WINAPI EmulatorBiosOperation(PFAST486_STATE State, UCHAR BopCode)
|
VOID WINAPI EmulatorBiosOperation(PFAST486_STATE State, UCHAR BopCode)
|
||||||
{
|
{
|
||||||
WORD StackSegment, StackPointer;
|
WORD StackSegment, StackPointer;
|
||||||
LPWORD Stack;
|
LPWORD Stack;
|
||||||
|
@ -286,7 +290,7 @@ static VOID WINAPI EmulatorBiosOperation(PFAST486_STATE State, UCHAR BopCode)
|
||||||
DPRINT1("Invalid BOP code %u\n", BopCode);
|
DPRINT1("Invalid BOP code %u\n", BopCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UCHAR WINAPI EmulatorIntAcknowledge(PFAST486_STATE State)
|
UCHAR WINAPI EmulatorIntAcknowledge(PFAST486_STATE State)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(State);
|
UNREFERENCED_PARAMETER(State);
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,51 @@ extern FAST486_STATE EmulatorContext;
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
|
VOID WINAPI EmulatorReadMemory
|
||||||
|
(
|
||||||
|
PFAST486_STATE State,
|
||||||
|
ULONG Address,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG Size
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID WINAPI EmulatorWriteMemory
|
||||||
|
(
|
||||||
|
PFAST486_STATE State,
|
||||||
|
ULONG Address,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG Size
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID WINAPI EmulatorReadIo
|
||||||
|
(
|
||||||
|
PFAST486_STATE State,
|
||||||
|
ULONG Port,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG DataCount,
|
||||||
|
UCHAR DataSize
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID WINAPI EmulatorWriteIo
|
||||||
|
(
|
||||||
|
PFAST486_STATE State,
|
||||||
|
ULONG Port,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG DataCount,
|
||||||
|
UCHAR DataSize
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID WINAPI EmulatorBiosOperation
|
||||||
|
(
|
||||||
|
PFAST486_STATE State,
|
||||||
|
UCHAR BopCode
|
||||||
|
);
|
||||||
|
|
||||||
|
UCHAR WINAPI EmulatorIntAcknowledge
|
||||||
|
(
|
||||||
|
PFAST486_STATE State
|
||||||
|
);
|
||||||
|
|
||||||
BOOLEAN EmulatorInitialize(VOID);
|
BOOLEAN EmulatorInitialize(VOID);
|
||||||
VOID EmulatorSetStack(WORD Segment, DWORD Offset);
|
VOID EmulatorSetStack(WORD Segment, DWORD Offset);
|
||||||
VOID EmulatorExecute(WORD Segment, WORD Offset);
|
VOID EmulatorExecute(WORD Segment, WORD Offset);
|
||||||
|
|
Loading…
Reference in a new issue