Commit 7c4bee56 authored by Ove Kaaven's avatar Ove Kaaven Committed by Alexandre Julliard

Implemented DOS INT21 AH=4B (EXEC).

parent 7b0bf0f0
......@@ -14,7 +14,7 @@
struct _DOSEVENT;
typedef struct _DOSTASK {
WORD psp_seg;
WORD psp_seg, retval;
WORD dpmi_flag;
} DOSTASK, *LPDOSTASK;
......@@ -31,6 +31,8 @@ typedef struct _DOSTASK {
#define V86_FLAG 0x00020000
extern BOOL MZ_LoadImage( HMODULE module, HANDLE hFile, LPCSTR filename );
extern BOOL MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk );
extern void MZ_Exit( CONTEXT86 *context, BOOL cs_psp, WORD retval );
extern LPDOSTASK MZ_Current( void );
extern LPDOSTASK MZ_AllocDPMITask( void );
extern int DOSVM_Enter( CONTEXT86 *context );
......
......@@ -26,7 +26,7 @@ typedef struct
WORD parentPSP; /* 16 Selector of parent PSP */
BYTE fileHandles[20]; /* 18 Open file handles */
HANDLE16 environment; /* 2c Selector of environment */
WORD reserved2[2];
DWORD saveStack; /* 2e SS:SP on last int21 call */
WORD nbFiles; /* 32 Number of file handles */
SEGPTR fileHandlesPtr; /* 34 Pointer to file handle table */
HANDLE16 hFileHandles; /* 38 Handle to fileHandlesPtr */
......
......@@ -8,6 +8,7 @@
/* #define DEBUG_INT */
#include "debugtools.h"
#include "task.h"
#include "dosexe.h"
/**********************************************************************
* INT_Int20Handler
......@@ -16,5 +17,5 @@
*/
void WINAPI INT_Int20Handler( CONTEXT86 *context )
{
ExitThread( 0 );
MZ_Exit( context, TRUE, 0 );
}
......@@ -954,7 +954,7 @@ static void INT21_SetCurrentPSP(WORD psp)
ERR("Cannot change PSP for non-DOS task!\n");
}
static WORD INT21_GetCurrentPSP()
static WORD INT21_GetCurrentPSP(void)
{
LPDOSTASK lpDosTask = MZ_Current();
if (lpDosTask)
......@@ -963,6 +963,15 @@ static WORD INT21_GetCurrentPSP()
return GetCurrentPDB16();
}
static WORD INT21_GetReturnCode(void)
{
LPDOSTASK lpDosTask = MZ_Current();
if (lpDosTask) {
WORD ret = lpDosTask->retval;
lpDosTask->retval = 0;
return ret;
} else return 0;
}
/***********************************************************************
* INT21_GetExtendedError
......@@ -1136,7 +1145,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x00: /* TERMINATE PROGRAM */
TRACE("TERMINATE PROGRAM\n");
ExitThread( 0 );
MZ_Exit( context, FALSE, 0 );
break;
case 0x01: /* READ CHARACTER FROM STANDARD INPUT, WITH ECHO */
......@@ -1835,21 +1844,27 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x4b: /* "EXEC" - LOAD AND/OR EXECUTE PROGRAM */
TRACE("EXEC %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx ));
AX_reg(context) = WinExec16( CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx ),
SW_NORMAL );
if (AX_reg(context) < 32) SET_CFLAG(context);
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx ));
if (ISV86(context)) {
if (!MZ_Exec( context, CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx),
AL_reg(context), CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx) ))
bSetDOSExtendedError = TRUE;
} else {
AX_reg(context) = WinExec16( CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx ),
SW_NORMAL );
if (AX_reg(context) < 32) SET_CFLAG(context);
}
break;
case 0x4c: /* "EXIT" - TERMINATE WITH RETURN CODE */
TRACE("EXIT with return code %d\n",AL_reg(context));
ExitThread( AL_reg(context) );
MZ_Exit( context, FALSE, AL_reg(context) );
break;
case 0x4d: /* GET RETURN CODE */
TRACE("GET RETURN CODE (ERRORLEVEL)\n");
AX_reg(context) = 0; /* normal exit */
AX_reg(context) = INT21_GetReturnCode();
break;
case 0x4e: /* "FINDFIRST" - FIND FIRST MATCHING FILE */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment