Author: aandrejevic Date: Sat Jan 25 00:53:10 2014 New Revision: 61797
URL: http://svn.reactos.org/svn/reactos?rev=61797&view=rev Log: [NTVDM] Add two general-purpose variables to the interrupt handler stub stack. Fix INT 29h so that it works correctly when the INT 10h, AH = 0Eh call is hooked.
Modified: branches/ntvdm/subsystems/ntvdm/dos/dos.c branches/ntvdm/subsystems/ntvdm/emulator.h branches/ntvdm/subsystems/ntvdm/int32.c
Modified: branches/ntvdm/subsystems/ntvdm/dos/dos.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/dos/dos.c... ============================================================================== --- branches/ntvdm/subsystems/ntvdm/dos/dos.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/dos/dos.c [iso-8859-1] Sat Jan 25 00:53:10 2014 @@ -2675,15 +2675,31 @@ * See Ralf Brown: http://www.ctyme.com/intr/rb-4124.htm * for more information. */ - UNREFERENCED_PARAMETER(Stack); - - /* - * The default handler under DOS 2.x and 3.x simply calls INT 10/AH=0Eh. - * Do better and call directly VidBiosPrintCharacter: it's what INT 10/AH=0Eh - * does. Otherwise we would have to set BL to DOS_CHAR_ATTRIBUTE and - * BH to Bda->VideoPage. - */ - VidBiosPrintCharacter(getAL(), DOS_CHAR_ATTRIBUTE, Bda->VideoPage); + + if (Stack[STACK_COUNTER] == 0) + { + Stack[STACK_COUNTER]++; + + /* Save AX and BX */ + Stack[STACK_VAR_A] = getAX(); + Stack[STACK_VAR_B] = getBX(); + + /* Rewind the BOP manually, we can't use CF because the interrupt could modify it */ + EmulatorExecute(getCS(), getIP() - 4); + + /* Call INT 0x10, AH = 0x0E */ + setAH(0x0E); + setBL(DOS_CHAR_ATTRIBUTE); + setBH(Bda->VideoPage); + + EmulatorInterrupt(0x10); + } + else + { + /* Restore AX and BX */ + setAX(Stack[STACK_VAR_A]); + setBX(Stack[STACK_VAR_B]); + } }
VOID WINAPI DosInt2Fh(LPWORD Stack)
Modified: branches/ntvdm/subsystems/ntvdm/emulator.h URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator.... ============================================================================== --- branches/ntvdm/subsystems/ntvdm/emulator.h [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/emulator.h [iso-8859-1] Sat Jan 25 00:53:10 2014 @@ -34,11 +34,13 @@ #define EMULATOR_FLAG_VIP (1 << 20) #define EMULATOR_FLAG_ID (1 << 21)
-#define STACK_COUNTER 0 -#define STACK_INT_NUM 1 -#define STACK_IP 2 -#define STACK_CS 3 -#define STACK_FLAGS 4 +#define STACK_VAR_B 0 +#define STACK_VAR_A 1 +#define STACK_COUNTER 2 +#define STACK_INT_NUM 3 +#define STACK_IP 4 +#define STACK_CS 5 +#define STACK_FLAGS 6
/* Basic Memory Management */
Modified: branches/ntvdm/subsystems/ntvdm/int32.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/int32.c?r... ============================================================================== --- branches/ntvdm/subsystems/ntvdm/int32.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/int32.c [iso-8859-1] Sat Jan 25 00:53:10 2014 @@ -74,8 +74,14 @@ BiosCode[Offset++] = 0x6A; // push i BiosCode[Offset++] = (UCHAR)i;
+ /* The counter variable (initialized to 0) */ BiosCode[Offset++] = 0x6A; // push 0 BiosCode[Offset++] = 0x00; + + /* Stack variables */ + BiosCode[Offset++] = 0x83; // sub sp, 4 + BiosCode[Offset++] = 0xEC; + BiosCode[Offset++] = 0x04;
BopSeqOffset = COMMON_STUB_OFFSET - (Offset + 3);
@@ -107,9 +113,9 @@ BiosCode[Offset++] = 0xF5;
// EXIT: - BiosCode[Offset++] = 0x83; // add sp, 4 + BiosCode[Offset++] = 0x83; // add sp, 8 BiosCode[Offset++] = 0xC4; - BiosCode[Offset++] = 0x04; + BiosCode[Offset++] = 0x08;
BiosCode[Offset++] = 0xCF; // iret