mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +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,11 +760,12 @@ VOID BiosPrintCharacter(CHAR Character, BYTE Attribute, BYTE Page)
|
|||
/* Default character */
|
||||
|
||||
/* Write the character */
|
||||
VgaWriteMemory(TO_LINEAR(TEXT_VIDEO_SEG,
|
||||
Page * Bda->VideoPageSize
|
||||
+ (Row * Bda->ScreenColumns + Column) * sizeof(WORD)),
|
||||
(LPVOID)&CharData,
|
||||
sizeof(WORD));
|
||||
EmulatorWriteMemory(&EmulatorContext,
|
||||
TO_LINEAR(TEXT_VIDEO_SEG,
|
||||
Page * Bda->VideoPageSize
|
||||
+ (Row * Bda->ScreenColumns + Column) * sizeof(WORD)),
|
||||
(LPVOID)&CharData,
|
||||
sizeof(WORD));
|
||||
|
||||
/* Advance the cursor */
|
||||
Column++;
|
||||
|
@ -789,6 +790,8 @@ VOID BiosPrintCharacter(CHAR Character, BYTE Attribute, BYTE Page)
|
|||
Rectangle,
|
||||
Page,
|
||||
DEFAULT_ATTRIBUTE);
|
||||
|
||||
Row--;
|
||||
}
|
||||
|
||||
/* Set the cursor position */
|
||||
|
|
|
@ -29,7 +29,7 @@ static BOOLEAN A20Line = FALSE;
|
|||
|
||||
/* 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);
|
||||
|
||||
|
@ -47,14 +47,16 @@ static VOID WINAPI EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID
|
|||
&& (Address < VgaGetVideoLimitAddress()))
|
||||
{
|
||||
DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress());
|
||||
DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress())
|
||||
- VgaAddress + 1;
|
||||
LPBYTE VgaBuffer = (LPBYTE)((ULONG_PTR)Buffer + VgaAddress - Address);
|
||||
|
||||
/* 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);
|
||||
|
||||
|
@ -75,14 +77,16 @@ static VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOI
|
|||
&& (Address < VgaGetVideoLimitAddress()))
|
||||
{
|
||||
DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress());
|
||||
DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress())
|
||||
- VgaAddress + 1;
|
||||
LPBYTE VgaBuffer = (LPBYTE)((ULONG_PTR)Buffer + VgaAddress - Address);
|
||||
|
||||
/* 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;
|
||||
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;
|
||||
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;
|
||||
LPWORD Stack;
|
||||
|
@ -286,7 +290,7 @@ static VOID WINAPI EmulatorBiosOperation(PFAST486_STATE State, UCHAR BopCode)
|
|||
DPRINT1("Invalid BOP code %u\n", BopCode);
|
||||
}
|
||||
|
||||
static UCHAR WINAPI EmulatorIntAcknowledge(PFAST486_STATE State)
|
||||
UCHAR WINAPI EmulatorIntAcknowledge(PFAST486_STATE State)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(State);
|
||||
|
||||
|
|
|
@ -86,6 +86,51 @@ extern FAST486_STATE EmulatorContext;
|
|||
|
||||
/* 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);
|
||||
VOID EmulatorSetStack(WORD Segment, DWORD Offset);
|
||||
VOID EmulatorExecute(WORD Segment, WORD Offset);
|
||||
|
|
Loading…
Reference in a new issue