Removed some of the XXX_reg macros now that we are using the standard

CONTEXT86 structure everywhere.
This commit is contained in:
Alexandre Julliard 2000-09-25 23:53:07 +00:00
parent 072dfb57e3
commit d8fab2e67c
36 changed files with 936 additions and 966 deletions

View File

@ -138,12 +138,12 @@ BOOL DEBUG_ValidateRegisters(void)
cs = __get_cs();
ds = __get_ds();
if (CS_reg(DEBUG_context) != cs) CHECK_SEG(CS_reg(DEBUG_context), "CS");
if (SS_reg(DEBUG_context) != ds) CHECK_SEG(SS_reg(DEBUG_context), "SS");
if (DS_reg(DEBUG_context) != ds) CHECK_SEG(DS_reg(DEBUG_context), "DS");
if (ES_reg(DEBUG_context) != ds) CHECK_SEG(ES_reg(DEBUG_context), "ES");
if (FS_reg(DEBUG_context) != ds) CHECK_SEG(FS_reg(DEBUG_context), "FS");
if (GS_reg(DEBUG_context) != ds) CHECK_SEG(GS_reg(DEBUG_context), "GS");
if (DEBUG_context.SegCs != cs) CHECK_SEG(DEBUG_context.SegCs, "CS");
if (DEBUG_context.SegSs != ds) CHECK_SEG(DEBUG_context.SegSs, "SS");
if (DEBUG_context.SegDs != ds) CHECK_SEG(DEBUG_context.SegDs, "DS");
if (DEBUG_context.SegEs != ds) CHECK_SEG(DEBUG_context.SegEs, "ES");
if (DEBUG_context.SegFs != ds) CHECK_SEG(DEBUG_context.SegFs, "FS");
if (DEBUG_context.SegGs != ds) CHECK_SEG(DEBUG_context.SegGs, "GS");
#endif
/* Check that CS and SS are not NULL */

View File

@ -294,22 +294,22 @@ void WINAPI QT_Thunk( CONTEXT86 *context )
memcpy(&context16,context,sizeof(context16));
CS_reg(&context16) = HIWORD(EDX_reg(context));
EIP_reg(&context16) = LOWORD(EDX_reg(context));
EBP_reg(&context16) = OFFSETOF( NtCurrentTeb()->cur_stack )
context16.SegCs = HIWORD(context->Edx);
context16.Eip = LOWORD(context->Edx);
context16.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack )
+ (WORD)&((STACK16FRAME*)0)->bp;
argsize = EBP_reg(context)-ESP_reg(context)-0x40;
argsize = context->Ebp-context->Esp-0x40;
memcpy( (LPBYTE)CURRENT_STACK16 - argsize,
(LPBYTE)ESP_reg(context), argsize );
(LPBYTE)context->Esp, argsize );
CallTo16RegisterShort( &context16, argsize );
EAX_reg(context) = EAX_reg(&context16);
EDX_reg(context) = EDX_reg(&context16);
ECX_reg(context) = ECX_reg(&context16);
context->Eax = context16.Eax;
context->Edx = context16.Edx;
context->Ecx = context16.Ecx;
ESP_reg(context) += LOWORD(ESP_reg(&context16)) -
context->Esp += LOWORD(context16.Esp) -
( OFFSETOF( NtCurrentTeb()->cur_stack ) - argsize );
}
@ -361,22 +361,22 @@ void WINAPI QT_Thunk( CONTEXT86 *context )
void WINAPI FT_Prolog( CONTEXT86 *context )
{
/* Build stack frame */
stack32_push(context, EBP_reg(context));
EBP_reg(context) = ESP_reg(context);
stack32_push(context, context->Ebp);
context->Ebp = context->Esp;
/* Allocate 64-byte Thunk Buffer */
ESP_reg(context) -= 64;
memset((char *)ESP_reg(context), '\0', 64);
context->Esp -= 64;
memset((char *)context->Esp, '\0', 64);
/* Store Flags (ECX) and Target Address (EDX) */
/* Save other registers to be restored later */
*(DWORD *)(EBP_reg(context) - 4) = EBX_reg(context);
*(DWORD *)(EBP_reg(context) - 8) = ESI_reg(context);
*(DWORD *)(EBP_reg(context) - 12) = EDI_reg(context);
*(DWORD *)(EBP_reg(context) - 16) = ECX_reg(context);
*(DWORD *)(context->Ebp - 4) = context->Ebx;
*(DWORD *)(context->Ebp - 8) = context->Esi;
*(DWORD *)(context->Ebp - 12) = context->Edi;
*(DWORD *)(context->Ebp - 16) = context->Ecx;
*(DWORD *)(EBP_reg(context) - 48) = EAX_reg(context);
*(DWORD *)(EBP_reg(context) - 52) = EDX_reg(context);
*(DWORD *)(context->Ebp - 48) = context->Eax;
*(DWORD *)(context->Ebp - 52) = context->Edx;
}
/**********************************************************************
@ -402,8 +402,8 @@ void WINAPI FT_Prolog( CONTEXT86 *context )
void WINAPI FT_Thunk( CONTEXT86 *context )
{
DWORD mapESPrelative = *(DWORD *)(EBP_reg(context) - 20);
DWORD callTarget = *(DWORD *)(EBP_reg(context) - 52);
DWORD mapESPrelative = *(DWORD *)(context->Ebp - 20);
DWORD callTarget = *(DWORD *)(context->Ebp - 52);
CONTEXT86 context16;
DWORD i, argsize;
@ -411,14 +411,14 @@ void WINAPI FT_Thunk( CONTEXT86 *context )
memcpy(&context16,context,sizeof(context16));
CS_reg(&context16) = HIWORD(callTarget);
EIP_reg(&context16) = LOWORD(callTarget);
EBP_reg(&context16) = OFFSETOF( NtCurrentTeb()->cur_stack )
context16.SegCs = HIWORD(callTarget);
context16.Eip = LOWORD(callTarget);
context16.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack )
+ (WORD)&((STACK16FRAME*)0)->bp;
argsize = EBP_reg(context)-ESP_reg(context)-0x40;
argsize = context->Ebp-context->Esp-0x40;
newstack = (LPBYTE)CURRENT_STACK16 - argsize;
oldstack = (LPBYTE)ESP_reg(context);
oldstack = (LPBYTE)context->Esp;
memcpy( newstack, oldstack, argsize );
@ -432,11 +432,11 @@ void WINAPI FT_Thunk( CONTEXT86 *context )
}
CallTo16RegisterShort( &context16, argsize );
EAX_reg(context) = EAX_reg(&context16);
EDX_reg(context) = EDX_reg(&context16);
ECX_reg(context) = ECX_reg(&context16);
context->Eax = context16.Eax;
context->Edx = context16.Edx;
context->Ecx = context16.Ecx;
ESP_reg(context) += LOWORD(ESP_reg(&context16)) -
context->Esp += LOWORD(context16.Esp) -
( OFFSETOF( NtCurrentTeb()->cur_stack ) - argsize );
/* Copy modified buffers back to 32-bit stack */
@ -458,21 +458,21 @@ void WINAPI FT_Thunk( CONTEXT86 *context )
static void FT_Exit(CONTEXT86 *context, int nPopArgs)
{
/* Return value is in EBX */
EAX_reg(context) = EBX_reg(context);
context->Eax = context->Ebx;
/* Restore EBX, ESI, and EDI registers */
EBX_reg(context) = *(DWORD *)(EBP_reg(context) - 4);
ESI_reg(context) = *(DWORD *)(EBP_reg(context) - 8);
EDI_reg(context) = *(DWORD *)(EBP_reg(context) - 12);
context->Ebx = *(DWORD *)(context->Ebp - 4);
context->Esi = *(DWORD *)(context->Ebp - 8);
context->Edi = *(DWORD *)(context->Ebp - 12);
/* Clean up stack frame */
ESP_reg(context) = EBP_reg(context);
EBP_reg(context) = stack32_pop(context);
context->Esp = context->Ebp;
context->Ebp = stack32_pop(context);
/* Pop return address to CALLER of thunk code */
EIP_reg(context) = stack32_pop(context);
context->Eip = stack32_pop(context);
/* Remove arguments */
ESP_reg(context) += nPopArgs;
context->Esp += nPopArgs;
}
/***********************************************************************
@ -623,26 +623,26 @@ void WINAPI Common32ThkLS( CONTEXT86 *context )
memcpy(&context16,context,sizeof(context16));
DI_reg(&context16) = CX_reg(context);
CS_reg(&context16) = HIWORD(EAX_reg(context));
EIP_reg(&context16) = LOWORD(EAX_reg(context));
EBP_reg(&context16) = OFFSETOF( NtCurrentTeb()->cur_stack )
context16.Edi = LOWORD(context->Ecx);
context16.SegCs = HIWORD(context->Eax);
context16.Eip = LOWORD(context->Eax);
context16.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack )
+ (WORD)&((STACK16FRAME*)0)->bp;
argsize = HIWORD(EDX_reg(context)) * 4;
argsize = HIWORD(context->Edx) * 4;
/* FIXME: hack for stupid USER32 CallbackGlueLS routine */
if (EDX_reg(context) == EIP_reg(context))
if (context->Edx == context->Eip)
argsize = 6 * 4;
memcpy( (LPBYTE)CURRENT_STACK16 - argsize,
(LPBYTE)ESP_reg(context), argsize );
(LPBYTE)context->Esp, argsize );
CallTo16RegisterLong(&context16, argsize + 32);
EAX_reg(context) = EAX_reg(&context16);
context->Eax = context16.Eax;
/* Clean up caller's stack frame */
ESP_reg(context) += BL_reg(&context16);
context->Esp += BL_reg(&context16);
}
/***********************************************************************
@ -679,25 +679,25 @@ void WINAPI OT_32ThkLSF( CONTEXT86 *context )
memcpy(&context16,context,sizeof(context16));
CS_reg(&context16) = HIWORD(EDX_reg(context));
EIP_reg(&context16) = LOWORD(EDX_reg(context));
EBP_reg(&context16) = OFFSETOF( NtCurrentTeb()->cur_stack )
context16.SegCs = HIWORD(context->Edx);
context16.Eip = LOWORD(context->Edx);
context16.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack )
+ (WORD)&((STACK16FRAME*)0)->bp;
argsize = 2 * *(WORD *)ESP_reg(context) + 2;
argsize = 2 * *(WORD *)context->Esp + 2;
memcpy( (LPBYTE)CURRENT_STACK16 - argsize,
(LPBYTE)ESP_reg(context), argsize );
(LPBYTE)context->Esp, argsize );
CallTo16RegisterShort(&context16, argsize);
EAX_reg(context) = EAX_reg(&context16);
EDX_reg(context) = EDX_reg(&context16);
context->Eax = context16.Eax;
context->Edx = context16.Edx;
/* Copy modified buffers back to 32-bit stack */
memcpy( (LPBYTE)ESP_reg(context),
memcpy( (LPBYTE)context->Esp,
(LPBYTE)CURRENT_STACK16 - argsize, argsize );
ESP_reg(context) += LOWORD(ESP_reg(&context16)) -
context->Esp += LOWORD(context16.Esp) -
( OFFSETOF( NtCurrentTeb()->cur_stack ) - argsize );
}
@ -790,7 +790,7 @@ void WINAPI FT_PrologPrime( CONTEXT86 *context )
/* Compensate for the fact that the Wine register relay code thought
we were being called, although we were in fact jumped to */
ESP_reg(context) -= 4;
context->Esp -= 4;
/* Write FT_Prolog call stub */
targetTableOffset = stack32_pop(context);
@ -798,7 +798,7 @@ void WINAPI FT_PrologPrime( CONTEXT86 *context )
_write_ftprolog( relayCode, *(DWORD **)(relayCode+targetTableOffset) );
/* Jump to the call stub just created */
EIP_reg(context) = (DWORD)relayCode;
context->Eip = (DWORD)relayCode;
}
/***********************************************************************
@ -819,15 +819,15 @@ void WINAPI QT_ThunkPrime( CONTEXT86 *context )
/* Compensate for the fact that the Wine register relay code thought
we were being called, although we were in fact jumped to */
ESP_reg(context) -= 4;
context->Esp -= 4;
/* Write QT_Thunk call stub */
targetTableOffset = EDX_reg(context);
relayCode = (LPBYTE)EAX_reg(context);
targetTableOffset = context->Edx;
relayCode = (LPBYTE)context->Eax;
_write_qtthunk( relayCode, *(DWORD **)(relayCode+targetTableOffset) );
/* Jump to the call stub just created */
EIP_reg(context) = (DWORD)relayCode;
context->Eip = (DWORD)relayCode;
}
/***********************************************************************
@ -955,13 +955,13 @@ DWORD WINAPIV SSCall(
*/
void WINAPI W32S_BackTo32( CONTEXT86 *context )
{
LPDWORD stack = (LPDWORD)ESP_reg( context );
FARPROC proc = (FARPROC)EIP_reg(context);
LPDWORD stack = (LPDWORD)context->Esp;
FARPROC proc = (FARPROC)context->Eip;
EAX_reg( context ) = proc( stack[1], stack[2], stack[3], stack[4], stack[5],
context->Eax = proc( stack[1], stack[2], stack[3], stack[4], stack[5],
stack[6], stack[7], stack[8], stack[9], stack[10] );
EIP_reg( context ) = stack32_pop(context);
context->Eip = stack32_pop(context);
}
/**********************************************************************
@ -1083,7 +1083,7 @@ BOOL16 WINAPI IsPeFormat16(
*/
void WINAPI K32Thk1632Prolog( CONTEXT86 *context )
{
LPBYTE code = (LPBYTE)EIP_reg(context) - 5;
LPBYTE code = (LPBYTE)context->Eip - 5;
/* Arrrgh! SYSTHUNK.DLL just has to re-implement another method
of 16->32 thunks instead of using one of the standard methods!
@ -1112,26 +1112,26 @@ void WINAPI K32Thk1632Prolog( CONTEXT86 *context )
WORD stackSel = NtCurrentTeb()->stack_sel;
DWORD stackBase = GetSelectorBase(stackSel);
DWORD argSize = EBP_reg(context) - ESP_reg(context);
char *stack16 = (char *)ESP_reg(context) - 4;
DWORD argSize = context->Ebp - context->Esp;
char *stack16 = (char *)context->Esp - 4;
char *stack32 = (char *)NtCurrentTeb()->cur_stack - argSize;
STACK16FRAME *frame16 = (STACK16FRAME *)stack16 - 1;
TRACE("before SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %08lx\n",
EBP_reg(context), ESP_reg(context), NtCurrentTeb()->cur_stack);
context->Ebp, context->Esp, NtCurrentTeb()->cur_stack);
memset(frame16, '\0', sizeof(STACK16FRAME));
frame16->frame32 = (STACK32FRAME *)NtCurrentTeb()->cur_stack;
frame16->ebp = EBP_reg(context);
frame16->ebp = context->Ebp;
memcpy(stack32, stack16, argSize);
NtCurrentTeb()->cur_stack = PTR_SEG_OFF_TO_SEGPTR(stackSel, (DWORD)frame16 - stackBase);
ESP_reg(context) = (DWORD)stack32 + 4;
EBP_reg(context) = ESP_reg(context) + argSize;
context->Esp = (DWORD)stack32 + 4;
context->Ebp = context->Esp + argSize;
TRACE("after SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %08lx\n",
EBP_reg(context), ESP_reg(context), NtCurrentTeb()->cur_stack);
context->Ebp, context->Esp, NtCurrentTeb()->cur_stack);
}
SYSLEVEL_ReleaseWin16Lock();
@ -1142,7 +1142,7 @@ void WINAPI K32Thk1632Prolog( CONTEXT86 *context )
*/
void WINAPI K32Thk1632Epilog( CONTEXT86 *context )
{
LPBYTE code = (LPBYTE)EIP_reg(context) - 13;
LPBYTE code = (LPBYTE)context->Eip - 13;
SYSLEVEL_RestoreWin16Lock();
@ -1156,18 +1156,18 @@ void WINAPI K32Thk1632Epilog( CONTEXT86 *context )
DWORD argSize = frame16->ebp - (DWORD)stack16;
char *stack32 = (char *)frame16->frame32 - argSize;
DWORD nArgsPopped = ESP_reg(context) - (DWORD)stack32;
DWORD nArgsPopped = context->Esp - (DWORD)stack32;
TRACE("before SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %08lx\n",
EBP_reg(context), ESP_reg(context), NtCurrentTeb()->cur_stack);
context->Ebp, context->Esp, NtCurrentTeb()->cur_stack);
NtCurrentTeb()->cur_stack = (DWORD)frame16->frame32;
ESP_reg(context) = (DWORD)stack16 + nArgsPopped;
EBP_reg(context) = frame16->ebp;
context->Esp = (DWORD)stack16 + nArgsPopped;
context->Ebp = frame16->ebp;
TRACE("after SYSTHUNK hack: EBP: %08lx ESP: %08lx cur_stack: %08lx\n",
EBP_reg(context), ESP_reg(context), NtCurrentTeb()->cur_stack);
context->Ebp, context->Esp, NtCurrentTeb()->cur_stack);
}
}
@ -1288,7 +1288,7 @@ UINT WINAPI ThunkConnect16(
void WINAPI C16ThkSL(CONTEXT86 *context)
{
LPBYTE stub = PTR_SEG_TO_LIN(EAX_reg(context)), x = stub;
LPBYTE stub = PTR_SEG_TO_LIN(context->Eax), x = stub;
WORD cs = __get_cs();
WORD ds = __get_ds();
@ -1309,7 +1309,7 @@ void WINAPI C16ThkSL(CONTEXT86 *context)
*x++ = 0x8E; *x++ = 0xC0;
*x++ = 0x66; *x++ = 0x0F; *x++ = 0xB7; *x++ = 0xC9;
*x++ = 0x67; *x++ = 0x66; *x++ = 0x26; *x++ = 0x8B;
*x++ = 0x91; *((DWORD *)x)++ = EDX_reg(context);
*x++ = 0x91; *((DWORD *)x)++ = context->Edx;
*x++ = 0x55;
*x++ = 0x66; *x++ = 0x52;
@ -1319,12 +1319,12 @@ void WINAPI C16ThkSL(CONTEXT86 *context)
*((WORD *)x)++ = cs;
/* Jump to the stub code just created */
EIP_reg(context) = LOWORD(EAX_reg(context));
CS_reg(context) = HIWORD(EAX_reg(context));
context->Eip = LOWORD(context->Eax);
context->SegCs = HIWORD(context->Eax);
/* Since C16ThkSL got called by a jmp, we need to leave the
original return address on the stack */
ESP_reg(context) -= 4;
context->Esp -= 4;
}
/***********************************************************************
@ -1333,11 +1333,11 @@ void WINAPI C16ThkSL(CONTEXT86 *context)
void WINAPI C16ThkSL01(CONTEXT86 *context)
{
LPBYTE stub = PTR_SEG_TO_LIN(EAX_reg(context)), x = stub;
LPBYTE stub = PTR_SEG_TO_LIN(context->Eax), x = stub;
if (stub)
{
struct ThunkDataSL16 *SL16 = PTR_SEG_TO_LIN(EDX_reg(context));
struct ThunkDataSL16 *SL16 = PTR_SEG_TO_LIN(context->Edx);
struct ThunkDataSL *td = SL16->fpData;
DWORD procAddress = (DWORD)GetProcAddress16(GetModuleHandle16("KERNEL"), 631);
@ -1376,16 +1376,16 @@ void WINAPI C16ThkSL01(CONTEXT86 *context)
*((WORD *)x)++ = cs;
/* Jump to the stub code just created */
EIP_reg(context) = LOWORD(EAX_reg(context));
CS_reg(context) = HIWORD(EAX_reg(context));
context->Eip = LOWORD(context->Eax);
context->SegCs = HIWORD(context->Eax);
/* Since C16ThkSL01 got called by a jmp, we need to leave the
orginal return address on the stack */
ESP_reg(context) -= 4;
context->Esp -= 4;
}
else
{
struct ThunkDataSL *td = (struct ThunkDataSL *)EDX_reg(context);
struct ThunkDataSL *td = (struct ThunkDataSL *)context->Edx;
DWORD targetNr = CX_reg(context) / 4;
struct SLTargetDB *tdb;
@ -1408,18 +1408,18 @@ void WINAPI C16ThkSL01(CONTEXT86 *context)
if (tdb)
{
EDX_reg(context) = tdb->targetTable[targetNr];
context->Edx = tdb->targetTable[targetNr];
TRACE("Call target is %08lx\n", EDX_reg(context));
TRACE("Call target is %08lx\n", context->Edx);
}
else
{
WORD *stack = PTR_SEG_OFF_TO_LIN(SS_reg(context), LOWORD(ESP_reg(context)));
WORD *stack = PTR_SEG_OFF_TO_LIN(context->SegSs, LOWORD(context->Esp));
DX_reg(context) = HIWORD(td->apiDB[targetNr].errorReturnValue);
AX_reg(context) = LOWORD(td->apiDB[targetNr].errorReturnValue);
EIP_reg(context) = stack[2];
CS_reg(context) = stack[3];
ESP_reg(context) += td->apiDB[targetNr].nrArgBytes + 4;
context->Eip = stack[2];
context->SegCs = stack[3];
context->Esp += td->apiDB[targetNr].nrArgBytes + 4;
ERR("Process %08lx did not ThunkConnect32 %s to %s\n",
GetCurrentProcessId(), td->pszDll32, td->pszDll16);
@ -1798,17 +1798,17 @@ void WINAPI CBClientGlueSL( CONTEXT86 *context )
stackLin[3] = BP_reg( context );
stackLin[2] = SI_reg( context );
stackLin[1] = DI_reg( context );
stackLin[0] = DS_reg( context );
stackLin[0] = context->SegDs;
EBP_reg( context ) = OFFSETOF( stackSeg ) + 6;
ESP_reg( context ) = OFFSETOF( stackSeg ) - 4;
GS_reg( context ) = 0;
context->Ebp = OFFSETOF( stackSeg ) + 6;
context->Esp = OFFSETOF( stackSeg ) - 4;
context->SegGs = 0;
/* Jump to 16-bit relay code */
glueTab = PTR_SEG_TO_LIN( CBClientRelay16[ stackLin[5] ] );
glue = glueTab[ stackLin[4] ];
CS_reg ( context ) = SELECTOROF( glue );
EIP_reg( context ) = OFFSETOF ( glue );
context->SegCs = SELECTOROF( glue );
context->Eip = OFFSETOF ( glue );
}
/***********************************************************************
@ -1819,10 +1819,10 @@ void WINAPI CBClientThunkSL( CONTEXT86 *context )
{
/* Call 32-bit relay code */
LPWORD args = PTR_SEG_OFF_TO_LIN( SS_reg( context ), BP_reg( context ) );
LPWORD args = PTR_SEG_OFF_TO_LIN( context->SegSs, BP_reg( context ) );
FARPROC proc = CBClientRelay32[ args[2] ][ args[1] ];
EAX_reg(context) = CALL32_CBClient( proc, args, &ESI_reg( context ) );
context->Eax = CALL32_CBClient( proc, args, &context->Esi );
}
/***********************************************************************
@ -1833,24 +1833,24 @@ void WINAPI CBClientThunkSLEx( CONTEXT86 *context )
{
/* Call 32-bit relay code */
LPWORD args = PTR_SEG_OFF_TO_LIN( SS_reg( context ), BP_reg( context ) );
LPWORD args = PTR_SEG_OFF_TO_LIN( context->SegSs, BP_reg( context ) );
FARPROC proc = CBClientRelay32[ args[2] ][ args[1] ];
INT nArgs;
LPWORD stackLin;
EAX_reg(context) = CALL32_CBClientEx( proc, args, &ESI_reg( context ), &nArgs );
context->Eax = CALL32_CBClientEx( proc, args, &context->Esi, &nArgs );
/* Restore registers saved by CBClientGlueSL */
stackLin = (LPWORD)((LPBYTE)CURRENT_STACK16 + sizeof(STACK16FRAME) - 4);
BP_reg( context ) = stackLin[3];
SI_reg( context ) = stackLin[2];
DI_reg( context ) = stackLin[1];
DS_reg( context ) = stackLin[0];
ESP_reg( context ) += 16+nArgs;
context->SegDs = stackLin[0];
context->Esp += 16+nArgs;
/* Return to caller of CBClient thunklet */
CS_reg ( context ) = stackLin[9];
EIP_reg( context ) = stackLin[8];
context->SegCs = stackLin[9];
context->Eip = stackLin[8];
}
@ -1905,19 +1905,19 @@ LPVOID WINAPI GetPK16SysVar(void)
*/
void WINAPI CommonUnimpStub( CONTEXT86 *context )
{
if (EAX_reg(context))
MESSAGE( "*** Unimplemented Win32 API: %s\n", (LPSTR)EAX_reg(context) );
if (context->Eax)
MESSAGE( "*** Unimplemented Win32 API: %s\n", (LPSTR)context->Eax );
switch ((ECX_reg(context) >> 4) & 0x0f)
switch ((context->Ecx >> 4) & 0x0f)
{
case 15: EAX_reg(context) = -1; break;
case 14: EAX_reg(context) = 0x78; break;
case 13: EAX_reg(context) = 0x32; break;
case 1: EAX_reg(context) = 1; break;
default: EAX_reg(context) = 0; break;
case 15: context->Eax = -1; break;
case 14: context->Eax = 0x78; break;
case 13: context->Eax = 0x32; break;
case 1: context->Eax = 1; break;
default: context->Eax = 0; break;
}
ESP_reg(context) += (ECX_reg(context) & 0x0f) * 4;
context->Esp += (context->Ecx & 0x0f) * 4;
}
/**********************************************************************
@ -1972,16 +1972,16 @@ void WINAPI Catch16( LPCATCHBUF lpbuf, CONTEXT86 *context )
* lpbuf[8] = ss
*/
lpbuf[0] = LOWORD(EIP_reg(context));
lpbuf[1] = CS_reg(context);
lpbuf[0] = LOWORD(context->Eip);
lpbuf[1] = context->SegCs;
/* Windows pushes 4 more words before saving sp */
lpbuf[2] = LOWORD(ESP_reg(context)) - 4 * sizeof(WORD);
lpbuf[3] = LOWORD(EBP_reg(context));
lpbuf[4] = LOWORD(ESI_reg(context));
lpbuf[5] = LOWORD(EDI_reg(context));
lpbuf[6] = DS_reg(context);
lpbuf[2] = LOWORD(context->Esp) - 4 * sizeof(WORD);
lpbuf[3] = LOWORD(context->Ebp);
lpbuf[4] = LOWORD(context->Esi);
lpbuf[5] = LOWORD(context->Edi);
lpbuf[6] = context->SegDs;
lpbuf[7] = 0;
lpbuf[8] = SS_reg(context);
lpbuf[8] = context->SegSs;
AX_reg(context) = 0; /* Return 0 */
}
@ -2016,14 +2016,14 @@ void WINAPI Throw16( LPCATCHBUF lpbuf, INT16 retval, CONTEXT86 *context )
frame32 = ((STACK16FRAME *)PTR_SEG_TO_LIN(frame32->frame16))->frame32;
}
EIP_reg(context) = lpbuf[0];
CS_reg(context) = lpbuf[1];
ESP_reg(context) = lpbuf[2] + 4 * sizeof(WORD) - sizeof(WORD) /*extra arg*/;
EBP_reg(context) = lpbuf[3];
ESI_reg(context) = lpbuf[4];
EDI_reg(context) = lpbuf[5];
DS_reg(context) = lpbuf[6];
context->Eip = lpbuf[0];
context->SegCs = lpbuf[1];
context->Esp = lpbuf[2] + 4 * sizeof(WORD) - sizeof(WORD) /*extra arg*/;
context->Ebp = lpbuf[3];
context->Esi = lpbuf[4];
context->Edi = lpbuf[5];
context->SegDs = lpbuf[6];
if (lpbuf[8] != SS_reg(context))
if (lpbuf[8] != context->SegSs)
ERR("Switching stack segment with Throw() not supported; expect crash now\n" );
}

View File

@ -84,8 +84,8 @@ void WIN87_Init( CONTEXT86 *context )
void WINAPI WIN87_fpmath( CONTEXT86 *context )
{
TRACE("(cs:eip=%x:%lx es=%x bx=%04x ax=%04x dx==%04x)\n",
(WORD)CS_reg(context), EIP_reg(context),
(WORD)ES_reg(context), BX_reg(context),
(WORD)context->SegCs, context->Eip,
(WORD)context->SegEs, BX_reg(context),
AX_reg(context), DX_reg(context) );
switch(BX_reg(context))

View File

@ -363,11 +363,11 @@ BOOLEAN WINAPI RtlGetNtProductType(LPDWORD type)
*/
void WINAPI NTDLL_chkstk( CONTEXT86 *context )
{
ESP_reg(context) -= EAX_reg(context);
context->Esp -= context->Eax;
}
void WINAPI NTDLL_alloca_probe( CONTEXT86 *context )
{
ESP_reg(context) -= EAX_reg(context);
context->Esp -= context->Eax;
}
/******************************************************************************

View File

@ -73,14 +73,14 @@ static VOID WINAPI MOUSE_CallMouseEventProc( FARPROC16 proc,
CONTEXT86 context;
memset( &context, 0, sizeof(context) );
CS_reg(&context) = SELECTOROF( proc );
EIP_reg(&context) = OFFSETOF( proc );
AX_reg(&context) = (WORD)dwFlags;
BX_reg(&context) = (WORD)dx;
CX_reg(&context) = (WORD)dy;
DX_reg(&context) = (WORD)cButtons;
SI_reg(&context) = LOWORD( dwExtraInfo );
DI_reg(&context) = HIWORD( dwExtraInfo );
context.SegCs = SELECTOROF( proc );
context.Eip = OFFSETOF( proc );
context.Eax = (WORD)dwFlags;
context.Ebx = (WORD)dx;
context.Ecx = (WORD)dy;
context.Edx = (WORD)cButtons;
context.Esi = LOWORD( dwExtraInfo );
context.Edi = HIWORD( dwExtraInfo );
CallTo16RegisterShort( &context, 0 );
}

View File

@ -212,7 +212,7 @@ void RELAY_DebugCallFrom16( CONTEXT86 *context )
DPRINTF(" AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
(WORD)ES_reg(context), EFL_reg(context) );
(WORD)context->SegEs, context->EFlags );
SYSLEVEL_CheckNotLevel( 2 );
}
@ -249,11 +249,11 @@ void RELAY_DebugCallFrom16Ret( CONTEXT86 *context, int ret_val )
|| memcmp( args+2, "intr_", 5 ) == 0 )
{
DPRINTF("retval=none ret=%04x:%04x ds=%04x\n",
(WORD)CS_reg(context), LOWORD(EIP_reg(context)), (WORD)DS_reg(context));
(WORD)context->SegCs, LOWORD(context->Eip), (WORD)context->SegDs);
DPRINTF(" AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
(WORD)ES_reg(context), EFL_reg(context) );
(WORD)context->SegEs, context->EFlags );
}
SYSLEVEL_CheckNotLevel( 2 );
@ -302,14 +302,14 @@ void RELAY_DebugCallTo16( LPVOID target, int nb_args, BOOL reg_func )
CONTEXT86 *context = (CONTEXT86 *)target;
DPRINTF("CallTo16(func=%04lx:%04x,ds=%04lx",
CS_reg(context), LOWORD(EIP_reg(context)), DS_reg(context) );
context->SegCs, LOWORD(context->Eip), context->SegDs );
while (nb_args--) DPRINTF( ",0x%04x", *--stack16 );
DPRINTF(") ss:sp=%04x:%04x\n", SELECTOROF(teb->cur_stack),
OFFSETOF(teb->cur_stack) );
DPRINTF(" AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x BP=%04x ES=%04x FS=%04x\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
BP_reg(context), (WORD)ES_reg(context), (WORD)FS_reg(context) );
BP_reg(context), (WORD)context->SegEs, (WORD)context->SegFs );
}
else
{
@ -346,7 +346,7 @@ void RELAY_DebugCallTo16Ret( BOOL reg_func, int ret_val )
OFFSETOF(NtCurrentTeb()->cur_stack));
DPRINTF(" AX=%04x BX=%04x CX=%04x DX=%04x BP=%04x SP=%04x\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), BP_reg(context), LOWORD(ESP_reg(context)));
DX_reg(context), BP_reg(context), LOWORD(context->Esp));
}
SYSLEVEL_CheckNotLevel( 2 );

View File

@ -207,11 +207,11 @@ SNOOP16_GetProcAddress16(HMODULE16 hmod,DWORD ordinal,FARPROC16 origfun) {
return (FARPROC16)(SEGPTR)MAKELONG(((char*)fun-(char*)dll->funs),dll->funhandle);
}
#define CALLER1REF (*(DWORD*)(PTR_SEG_OFF_TO_LIN(SS_reg(context),LOWORD(ESP_reg(context))+4)))
#define CALLER1REF (*(DWORD*)(PTR_SEG_OFF_TO_LIN(context->SegSs,LOWORD(context->Esp)+4)))
void WINAPI SNOOP16_Entry(FARPROC proc, LPBYTE args, CONTEXT86 *context) {
DWORD ordinal=0;
DWORD entry=(DWORD)PTR_SEG_OFF_TO_LIN(CS_reg(context),LOWORD(EIP_reg(context)))-5;
WORD xcs = CS_reg(context);
DWORD entry=(DWORD)PTR_SEG_OFF_TO_LIN(context->SegCs,LOWORD(context->Eip))-5;
WORD xcs = context->SegCs;
SNOOP16_DLL *dll = firstdll;
SNOOP16_FUN *fun = NULL;
SNOOP16_RETURNENTRIES **rets = &firstrets;
@ -253,10 +253,10 @@ void WINAPI SNOOP16_Entry(FARPROC proc, LPBYTE args, CONTEXT86 *context) {
ret->dll = dll;
ret->args = NULL;
ret->ordinal = ordinal;
ret->origSP = LOWORD(ESP_reg(context));
ret->origSP = LOWORD(context->Esp);
EIP_reg(context)= LOWORD(fun->origfun);
CS_reg(context) = HIWORD(fun->origfun);
context->Eip= LOWORD(fun->origfun);
context->SegCs = HIWORD(fun->origfun);
DPRINTF("CALL %s.%ld: %s(",dll->name,ordinal,fun->name);
@ -264,19 +264,19 @@ void WINAPI SNOOP16_Entry(FARPROC proc, LPBYTE args, CONTEXT86 *context) {
max = fun->nrofargs;
if (max>16) max=16;
for (i=max;i--;)
DPRINTF("%04x%s",*(WORD*)((char *) PTR_SEG_OFF_TO_LIN(SS_reg(context),LOWORD(ESP_reg(context)))+8+sizeof(WORD)*i),i?",":"");
DPRINTF("%04x%s",*(WORD*)((char *) PTR_SEG_OFF_TO_LIN(context->SegSs,LOWORD(context->Esp))+8+sizeof(WORD)*i),i?",":"");
if (max!=fun->nrofargs)
DPRINTF(" ...");
} else if (fun->nrofargs<0) {
DPRINTF("<unknown, check return>");
ret->args = HeapAlloc(GetProcessHeap(),0,16*sizeof(WORD));
memcpy(ret->args,(LPBYTE)((char *) PTR_SEG_OFF_TO_LIN(SS_reg(context),LOWORD(ESP_reg(context)))+8),sizeof(WORD)*16);
memcpy(ret->args,(LPBYTE)((char *) PTR_SEG_OFF_TO_LIN(context->SegSs,LOWORD(context->Esp))+8),sizeof(WORD)*16);
}
DPRINTF(") ret=%04x:%04x\n",HIWORD(ret->origreturn),LOWORD(ret->origreturn));
}
void WINAPI SNOOP16_Return(FARPROC proc, LPBYTE args, CONTEXT86 *context) {
SNOOP16_RETURNENTRY *ret = (SNOOP16_RETURNENTRY*)((char *) PTR_SEG_OFF_TO_LIN(CS_reg(context),LOWORD(EIP_reg(context)))-5);
SNOOP16_RETURNENTRY *ret = (SNOOP16_RETURNENTRY*)((char *) PTR_SEG_OFF_TO_LIN(context->SegCs,LOWORD(context->Eip))-5);
/* We haven't found out the nrofargs yet. If we called a cdecl
* function it is too late anyway and we can just set '0' (which
@ -284,10 +284,10 @@ void WINAPI SNOOP16_Return(FARPROC proc, LPBYTE args, CONTEXT86 *context) {
* If pascal -> everything ok.
*/
if (ret->dll->funs[ret->ordinal].nrofargs<0) {
ret->dll->funs[ret->ordinal].nrofargs=(LOWORD(ESP_reg(context))-ret->origSP-4)/2;
ret->dll->funs[ret->ordinal].nrofargs=(LOWORD(context->Esp)-ret->origSP-4)/2;
}
EIP_reg(context) = LOWORD(ret->origreturn);
CS_reg(context) = HIWORD(ret->origreturn);
context->Eip = LOWORD(ret->origreturn);
context->SegCs = HIWORD(ret->origreturn);
if (ret->args) {
int i,max;

View File

@ -268,8 +268,8 @@ extern void ASPI_DOS_HandleInt(CONTEXT86 *context);
ERR( "int%x: unknown/not implemented parameters:\n" \
"int%x: AX %04x, BX %04x, CX %04x, DX %04x, " \
"SI %04x, DI %04x, DS %04x, ES %04x\n", \
(num), (num), AX_reg(context), BX_reg(context), CX_reg(context), \
DX_reg(context), SI_reg(context), DI_reg(context), \
(WORD)DS_reg(context), (WORD)ES_reg(context) )
(num), (num), LOWORD((context)->Eax), LOWORD((context)->Ebx), \
LOWORD((context)->Ecx), LOWORD((context)->Edx), LOWORD((context)->Esi), \
LOWORD((context)->Edi), (WORD)(context)->SegDs, (WORD)(context)->SegEs )
#endif /* __WINE_MISCEMU_H */

View File

@ -688,48 +688,28 @@ typedef HANDLE *PHANDLE;
/* Macros for easier access to i386 context registers */
#define EAX_reg(context) ((context)->Eax)
#define EBX_reg(context) ((context)->Ebx)
#define ECX_reg(context) ((context)->Ecx)
#define EDX_reg(context) ((context)->Edx)
#define ESI_reg(context) ((context)->Esi)
#define EDI_reg(context) ((context)->Edi)
#define EBP_reg(context) ((context)->Ebp)
#define AX_reg(context) (*(WORD*)&(context)->Eax)
#define BX_reg(context) (*(WORD*)&(context)->Ebx)
#define CX_reg(context) (*(WORD*)&(context)->Ecx)
#define DX_reg(context) (*(WORD*)&(context)->Edx)
#define SI_reg(context) (*(WORD*)&(context)->Esi)
#define DI_reg(context) (*(WORD*)&(context)->Edi)
#define BP_reg(context) (*(WORD*)&(context)->Ebp)
#define CS_reg(context) ((context)->SegCs)
#define DS_reg(context) ((context)->SegDs)
#define ES_reg(context) ((context)->SegEs)
#define FS_reg(context) ((context)->SegFs)
#define GS_reg(context) ((context)->SegGs)
#define SS_reg(context) ((context)->SegSs)
#define AL_reg(context) (*(BYTE*)&(context)->Eax)
#define AH_reg(context) (*((BYTE*)&(context)->Eax + 1))
#define BL_reg(context) (*(BYTE*)&(context)->Ebx)
#define BH_reg(context) (*((BYTE*)&(context)->Ebx + 1))
#define CL_reg(context) (*(BYTE*)&(context)->Ecx)
#define CH_reg(context) (*((BYTE*)&(context)->Ecx + 1))
#define DL_reg(context) (*(BYTE*)&(context)->Edx)
#define DH_reg(context) (*((BYTE*)&(context)->Edx + 1))
#define EFL_reg(context) ((context)->EFlags)
#define EIP_reg(context) ((context)->Eip)
#define ESP_reg(context) ((context)->Esp)
#define AX_reg(context) (*(WORD*)&EAX_reg(context))
#define BX_reg(context) (*(WORD*)&EBX_reg(context))
#define CX_reg(context) (*(WORD*)&ECX_reg(context))
#define DX_reg(context) (*(WORD*)&EDX_reg(context))
#define SI_reg(context) (*(WORD*)&ESI_reg(context))
#define DI_reg(context) (*(WORD*)&EDI_reg(context))
#define BP_reg(context) (*(WORD*)&EBP_reg(context))
#define AL_reg(context) (*(BYTE*)&EAX_reg(context))
#define AH_reg(context) (*((BYTE*)&EAX_reg(context)+1))
#define BL_reg(context) (*(BYTE*)&EBX_reg(context))
#define BH_reg(context) (*((BYTE*)&EBX_reg(context)+1))
#define CL_reg(context) (*(BYTE*)&ECX_reg(context))
#define CH_reg(context) (*((BYTE*)&ECX_reg(context)+1))
#define DL_reg(context) (*(BYTE*)&EDX_reg(context))
#define DH_reg(context) (*((BYTE*)&EDX_reg(context)+1))
#define SET_CFLAG(context) (EFL_reg(context) |= 0x0001)
#define RESET_CFLAG(context) (EFL_reg(context) &= ~0x0001)
#define SET_ZFLAG(context) (EFL_reg(context) |= 0x0040)
#define RESET_ZFLAG(context) (EFL_reg(context) &= ~0x0040)
#define ISV86(context) (EFL_reg(context) & 0x00020000)
#define SET_CFLAG(context) ((context)->EFlags |= 0x0001)
#define RESET_CFLAG(context) ((context)->EFlags &= ~0x0001)
#define SET_ZFLAG(context) ((context)->EFlags |= 0x0040)
#define RESET_ZFLAG(context) ((context)->EFlags &= ~0x0040)
#define ISV86(context) ((context)->EFlags & 0x00020000)
/* Macros to retrieve the current context */

View File

@ -50,11 +50,11 @@ DECLARE_DEBUG_CHANNEL(relay)
# include <sys/mman.h>
#endif
#define IF_CLR(ctx) EFL_reg(ctx) &= ~VIF_MASK
#define IF_ENABLED(ctx) (EFL_reg(ctx) & VIF_MASK)
#define SET_PEND(ctx) EFL_reg(ctx) |= VIP_MASK
#define CLR_PEND(ctx) EFL_reg(ctx) &= ~VIP_MASK
#define IS_PEND(ctx) (EFL_reg(ctx) & VIP_MASK)
#define IF_CLR(ctx) ((ctx)->EFlags &= ~VIF_MASK)
#define IF_ENABLED(ctx) ((ctx)->EFlags & VIF_MASK)
#define SET_PEND(ctx) ((ctx)->EFlags |= VIP_MASK)
#define CLR_PEND(ctx) ((ctx)->EFlags &= ~VIP_MASK)
#define IS_PEND(ctx) ((ctx)->EFlags & VIP_MASK)
#undef TRY_PICRETURN
@ -87,7 +87,7 @@ static void do_exception( int signal, CONTEXT86 *context )
rec.ExceptionFlags = EH_NONCONTINUABLE;
}
rec.ExceptionRecord = NULL;
rec.ExceptionAddress = (LPVOID)EIP_reg(context);
rec.ExceptionAddress = (LPVOID)context->Eip;
rec.NumberParameters = 0;
EXC_RtlRaiseException( &rec, context );
}
@ -129,7 +129,7 @@ static void DOSVM_Dump( int fn, int sig, struct vm86plus_struct*VM86 )
static int DOSVM_Int( int vect, CONTEXT86 *context )
{
if (vect==0x31) {
if (CS_reg(context)==DOSMEM_wrap_seg) {
if (context->SegCs==DOSMEM_wrap_seg) {
/* exit from real-mode wrapper */
return -1;
}
@ -148,17 +148,17 @@ static void DOSVM_SimulateInt( int vect, CONTEXT86 *context )
INT_RealModeInterrupt(vect,context);
} else {
WORD*stack= PTR_REAL_TO_LIN( context->SegSs, context->Esp );
WORD flag=LOWORD(EFL_reg(context));
WORD flag=LOWORD(context->EFlags);
if (IF_ENABLED(context)) flag|=IF_MASK;
else flag&=~IF_MASK;
*(--stack)=flag;
*(--stack)=CS_reg(context);
*(--stack)=LOWORD(EIP_reg(context));
ESP_reg(context)-=6;
CS_reg(context)=SELECTOROF(handler);
EIP_reg(context)=OFFSETOF(handler);
*(--stack)=context->SegCs;
*(--stack)=LOWORD(context->Eip);
context->Esp-=6;
context->SegCs=SELECTOROF(handler);
context->Eip=OFFSETOF(handler);
IF_CLR(context);
}
}
@ -250,23 +250,23 @@ void DOSVM_QueueEvent( int irq, int priority, void (*relay)(CONTEXT86*,void*), v
}
}
#define CV CP(eax,EAX); CP(ecx,ECX); CP(edx,EDX); CP(ebx,EBX); \
CP(esi,ESI); CP(edi,EDI); CP(esp,ESP); CP(ebp,EBP); \
CP(cs,CS); CP(ds,DS); CP(es,ES); \
CP(ss,SS); CP(fs,FS); CP(gs,GS); \
CP(eip,EIP); CP(eflags,EFL)
#define CV do { CP(eax,Eax); CP(ecx,Ecx); CP(edx,Edx); CP(ebx,Ebx); \
CP(esi,Esi); CP(edi,Edi); CP(esp,Esp); CP(ebp,Ebp); \
CP(cs,SegCs); CP(ds,SegDs); CP(es,SegEs); \
CP(ss,SegSs); CP(fs,SegFs); CP(gs,SegGs); \
CP(eip,Eip); CP(eflags,EFlags); } while(0)
static int DOSVM_Process( int fn, int sig, struct vm86plus_struct*VM86 )
{
CONTEXT86 context;
int ret=0;
#define CP(x,y) y##_reg(&context) = VM86->regs.x
#define CP(x,y) context.y = VM86->regs.x
CV;
#undef CP
if (VM86_TYPE(fn)==VM86_UNKNOWN) {
ret=INSTR_EmulateInstruction(&context);
#define CP(x,y) VM86->regs.x = y##_reg(&context)
#define CP(x,y) VM86->regs.x = context.y
CV;
#undef CP
if (ret) return 0;
@ -333,7 +333,7 @@ static int DOSVM_Process( int fn, int sig, struct vm86plus_struct*VM86 )
ret=-1;
}
#define CP(x,y) VM86->regs.x = y##_reg(&context)
#define CP(x,y) VM86->regs.x = context.y
CV;
#undef CP
#ifdef TRY_PICRETURN
@ -456,7 +456,7 @@ int DOSVM_Enter( CONTEXT86 *context )
struct vm86plus_struct VM86;
int stat,len,sig;
#define CP(x,y) VM86.regs.x = y##_reg(context)
#define CP(x,y) VM86.regs.x = context->y
CV;
#undef CP
if (VM86.regs.eflags & IF_MASK)
@ -517,11 +517,9 @@ int DOSVM_Enter( CONTEXT86 *context )
} while (DOSVM_Process(stat,sig,&VM86)>=0);
entered--;
if (context) {
#define CP(x,y) y##_reg(context) = VM86.regs.x
#define CP(x,y) context->y = VM86.regs.x
CV;
#undef CP
}
return 0;
}

View File

@ -1177,24 +1177,24 @@ static void NE_InitProcess(void)
* sp top of the stack
*/
memset( &context, 0, sizeof(context) );
CS_reg(&context) = GlobalHandleToSel16(pSegTable[pModule->cs - 1].hSeg);
DS_reg(&context) = GlobalHandleToSel16(pTask->hInstance);
ES_reg(&context) = pTask->hPDB;
EIP_reg(&context) = pModule->ip;
EBX_reg(&context) = pModule->stack_size;
ECX_reg(&context) = pModule->heap_size;
EDI_reg(&context) = pTask->hInstance;
ESI_reg(&context) = pTask->hPrevInstance;
context.SegCs = GlobalHandleToSel16(pSegTable[pModule->cs - 1].hSeg);
context.SegDs = GlobalHandleToSel16(pTask->hInstance);
context.SegEs = pTask->hPDB;
context.Eip = pModule->ip;
context.Ebx = pModule->stack_size;
context.Ecx = pModule->heap_size;
context.Edi = pTask->hInstance;
context.Esi = pTask->hPrevInstance;
/* Now call 16-bit entry point */
TRACE("Starting main program: cs:ip=%04lx:%04lx ds=%04lx ss:sp=%04x:%04x\n",
CS_reg(&context), EIP_reg(&context), DS_reg(&context),
context.SegCs, context.Eip, context.SegDs,
SELECTOROF(pTask->teb->cur_stack),
OFFSETOF(pTask->teb->cur_stack) );
CallTo16RegisterShort( &context, 0 );
ExitThread( AX_reg( &context ) );
ExitThread( LOWORD(context.Eax) );
}
SYSLEVEL_LeaveWin16Lock();
@ -1473,13 +1473,13 @@ HMODULE16 WINAPI GetModuleHandle16( LPCSTR name )
if (pModule->flags & NE_FFLAGS_WIN32) continue;
name_table = (BYTE *)pModule + pModule->name_table;
/* FIXME: the lstrncmpiA is WRONG. It should not be case insensitive,
/* FIXME: the strncasecmp is WRONG. It should not be case insensitive,
* but case sensitive! (Unfortunately Winword 6 and subdlls have
* lowercased module names, but try to load uppercase DLLs, so this
* 'i' compare is just a quickfix until the loader handles that
* correctly. -MM 990705
*/
if ((*name_table == len) && !lstrncmpiA(tmpstr, name_table+1, len))
if ((*name_table == len) && !strncasecmp(tmpstr, name_table+1, len))
return hModule;
}
@ -1611,7 +1611,7 @@ static HMODULE16 NE_GetModuleByFilename( LPCSTR name )
if (pModule->flags & NE_FFLAGS_WIN32) continue;
name_table = (BYTE *)pModule + pModule->name_table;
if ((*name_table == len) && !lstrncmpiA(s, name_table+1, len))
if ((*name_table == len) && !strncasecmp(s, name_table+1, len))
return hModule;
}
@ -1729,7 +1729,7 @@ HMODULE WINAPI MapHModuleSL(HMODULE16 hmod) {
*/
void WINAPI MapHInstLS( CONTEXT86 *context )
{
EAX_reg(context) = MapHModuleLS(EAX_reg(context));
context->Eax = MapHModuleLS(context->Eax);
}
/***************************************************************************
@ -1737,7 +1737,7 @@ void WINAPI MapHInstLS( CONTEXT86 *context )
*/
void WINAPI MapHInstSL( CONTEXT86 *context )
{
EAX_reg(context) = MapHModuleSL(EAX_reg(context));
context->Eax = MapHModuleSL(context->Eax);
}
/***************************************************************************
@ -1745,8 +1745,7 @@ void WINAPI MapHInstSL( CONTEXT86 *context )
*/
void WINAPI MapHInstLS_PN( CONTEXT86 *context )
{
if (EAX_reg(context))
EAX_reg(context) = MapHModuleLS(EAX_reg(context));
if (context->Eax) context->Eax = MapHModuleLS(context->Eax);
}
/***************************************************************************
@ -1754,7 +1753,6 @@ void WINAPI MapHInstLS_PN( CONTEXT86 *context )
*/
void WINAPI MapHInstSL_PN( CONTEXT86 *context )
{
if (EAX_reg(context))
EAX_reg(context) = MapHModuleSL(EAX_reg(context));
if (context->Eax) context->Eax = MapHModuleSL(context->Eax);
}

View File

@ -613,20 +613,20 @@ static BOOL NE_InitDLL( TDB* pTask, NE_MODULE *pModule )
NE_GetDLLInitParams( pModule, &hInst, &ds, &heap );
ECX_reg(&context) = heap;
EDI_reg(&context) = hInst;
DS_reg(&context) = ds;
ES_reg(&context) = ds; /* who knows ... */
context.Ecx = heap;
context.Edi = hInst;
context.SegDs = ds;
context.SegEs = ds; /* who knows ... */
CS_reg(&context) = SEL(pSegTable[pModule->cs-1].hSeg);
EIP_reg(&context) = pModule->ip;
EBP_reg(&context) = OFFSETOF(NtCurrentTeb()->cur_stack) + (WORD)&((STACK16FRAME*)0)->bp;
context.SegCs = SEL(pSegTable[pModule->cs-1].hSeg);
context.Eip = pModule->ip;
context.Ebp = OFFSETOF(NtCurrentTeb()->cur_stack) + (WORD)&((STACK16FRAME*)0)->bp;
pModule->cs = 0; /* Don't initialize it twice */
TRACE_(dll)("Calling LibMain, cs:ip=%04lx:%04lx ds=%04lx di=%04x cx=%04x\n",
CS_reg(&context), EIP_reg(&context), DS_reg(&context),
DI_reg(&context), CX_reg(&context) );
context.SegCs, context.Eip, context.SegDs,
LOWORD(context.Edi), LOWORD(context.Ecx) );
CallTo16RegisterShort( &context, 0 );
return TRUE;
}
@ -697,12 +697,12 @@ static void NE_CallDllEntryPoint( NE_MODULE *pModule, DWORD dwReason )
CONTEXT86 context;
memset( &context, 0, sizeof(context) );
DS_reg(&context) = ds;
ES_reg(&context) = ds; /* who knows ... */
context.SegDs = ds;
context.SegEs = ds; /* who knows ... */
CS_reg(&context) = HIWORD(entryPoint);
EIP_reg(&context) = LOWORD(entryPoint);
EBP_reg(&context) = OFFSETOF( NtCurrentTeb()->cur_stack )
context.SegCs = HIWORD(entryPoint);
context.Eip = LOWORD(entryPoint);
context.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack )
+ (WORD)&((STACK16FRAME*)0)->bp;
*(DWORD *)(stack - 4) = dwReason; /* dwReason */

View File

@ -631,7 +631,7 @@ void WINAPI InitTask16( CONTEXT86 *context )
INSTANCEDATA *pinstance;
SEGPTR ptr;
EAX_reg(context) = 0;
context->Eax = 0;
if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return;
/* Note: we need to trust that BX/CX contain the stack/heap sizes,
@ -642,12 +642,12 @@ void WINAPI InitTask16( CONTEXT86 *context )
pinstance = (INSTANCEDATA *)PTR_SEG_OFF_TO_LIN(CURRENT_DS, 0);
pinstance->stackmin = OFFSETOF( pTask->teb->cur_stack ) + sizeof( STACK16FRAME );
pinstance->stackbottom = pinstance->stackmin; /* yup, that's right. Confused me too. */
pinstance->stacktop = ( pinstance->stackmin > BX_reg(context)?
pinstance->stackmin - BX_reg(context) : 0 ) + 150;
pinstance->stacktop = ( pinstance->stackmin > LOWORD(context->Ebx) ?
pinstance->stackmin - LOWORD(context->Ebx) : 0 ) + 150;
/* Initialize the local heap */
if ( CX_reg(context) )
LocalInit16( GlobalHandleToSel16(pTask->hInstance), 0, CX_reg(context) );
if (LOWORD(context->Ecx))
LocalInit16( GlobalHandleToSel16(pTask->hInstance), 0, LOWORD(context->Ecx) );
/* Initialize implicitly loaded DLLs */
NE_InitializeDLLs( pTask->hModule );
@ -665,22 +665,22 @@ void WINAPI InitTask16( CONTEXT86 *context )
*/
ptr = stack16_push( sizeof(WORD) );
*(WORD *)PTR_SEG_TO_LIN(ptr) = 0;
ESP_reg(context) -= 2;
context->Esp -= 2;
EAX_reg(context) = 1;
context->Eax = 1;
if (!pTask->pdb.cmdLine[0]) EBX_reg(context) = 0x80;
if (!pTask->pdb.cmdLine[0]) context->Ebx = 0x80;
else
{
LPBYTE p = &pTask->pdb.cmdLine[1];
while ((*p == ' ') || (*p == '\t')) p++;
EBX_reg(context) = 0x80 + (p - pTask->pdb.cmdLine);
context->Ebx = 0x80 + (p - pTask->pdb.cmdLine);
}
ECX_reg(context) = pinstance->stacktop;
EDX_reg(context) = pTask->nCmdShow;
ESI_reg(context) = (DWORD)pTask->hPrevInstance;
EDI_reg(context) = (DWORD)pTask->hInstance;
ES_reg (context) = (WORD)pTask->hPDB;
context->Ecx = pinstance->stacktop;
context->Edx = pTask->nCmdShow;
context->Esi = (DWORD)pTask->hPrevInstance;
context->Edi = (DWORD)pTask->hInstance;
context->SegEs = (WORD)pTask->hPDB;
}
@ -1229,8 +1229,8 @@ void WINAPI SwitchStackBack16( CONTEXT86 *context )
/* Switch back to the old stack */
NtCurrentTeb()->cur_stack = pData->old_ss_sp - sizeof(STACK16FRAME);
SS_reg(context) = SELECTOROF(pData->old_ss_sp);
ESP_reg(context) = OFFSETOF(pData->old_ss_sp) - sizeof(DWORD); /*ret addr*/
context->SegSs = SELECTOROF(pData->old_ss_sp);
context->Esp = OFFSETOF(pData->old_ss_sp) - sizeof(DWORD); /*ret addr*/
pData->old_ss_sp = 0;
/* Build a stack frame for the return */

View File

@ -61,9 +61,9 @@ static BOOL INSTR_ReplaceSelector( CONTEXT86 *context, WORD *sel )
{
extern char Call16_Start, Call16_End;
if (IS_SELECTOR_SYSTEM(CS_reg(context)))
if ( (char *)EIP_reg(context) >= &Call16_Start
&& (char *)EIP_reg(context) < &Call16_End )
if (IS_SELECTOR_SYSTEM(context->SegCs))
if ( (char *)context->Eip >= &Call16_Start
&& (char *)context->Eip < &Call16_End )
{
/* Saved selector may have become invalid when the relay code */
/* tries to restore it. We simply clear it. */
@ -107,14 +107,14 @@ static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
{
switch(rm)
{
case 0: return (BYTE *)&EAX_reg(context);
case 1: return (BYTE *)&ECX_reg(context);
case 2: return (BYTE *)&EDX_reg(context);
case 3: return (BYTE *)&EBX_reg(context);
case 4: return (BYTE *)&ESP_reg(context);
case 5: return (BYTE *)&EBP_reg(context);
case 6: return (BYTE *)&ESI_reg(context);
case 7: return (BYTE *)&EDI_reg(context);
case 0: return (BYTE *)&context->Eax;
case 1: return (BYTE *)&context->Ecx;
case 2: return (BYTE *)&context->Edx;
case 3: return (BYTE *)&context->Ebx;
case 4: return (BYTE *)&context->Esp;
case 5: return (BYTE *)&context->Ebp;
case 6: return (BYTE *)&context->Esi;
case 7: return (BYTE *)&context->Edi;
}
}
@ -128,27 +128,27 @@ static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
ss = sib >> 6;
switch(sib >> 3)
{
case 0: index = EAX_reg(context); break;
case 1: index = ECX_reg(context); break;
case 2: index = EDX_reg(context); break;
case 3: index = EBX_reg(context); break;
case 0: index = context->Eax; break;
case 1: index = context->Ecx; break;
case 2: index = context->Edx; break;
case 3: index = context->Ebx; break;
case 4: index = 0; break;
case 5: index = EBP_reg(context); break;
case 6: index = ESI_reg(context); break;
case 7: index = EDI_reg(context); break;
case 5: index = context->Ebp; break;
case 6: index = context->Esi; break;
case 7: index = context->Edi; break;
}
}
switch(rm)
{
case 0: base = EAX_reg(context); seg = DS_reg(context); break;
case 1: base = ECX_reg(context); seg = DS_reg(context); break;
case 2: base = EDX_reg(context); seg = DS_reg(context); break;
case 3: base = EBX_reg(context); seg = DS_reg(context); break;
case 4: base = ESP_reg(context); seg = SS_reg(context); break;
case 5: base = EBP_reg(context); seg = SS_reg(context); break;
case 6: base = ESI_reg(context); seg = DS_reg(context); break;
case 7: base = EDI_reg(context); seg = DS_reg(context); break;
case 0: base = context->Eax; seg = context->SegDs; break;
case 1: base = context->Ecx; seg = context->SegDs; break;
case 2: base = context->Edx; seg = context->SegDs; break;
case 3: base = context->Ebx; seg = context->SegDs; break;
case 4: base = context->Esp; seg = context->SegSs; break;
case 5: base = context->Ebp; seg = context->SegSs; break;
case 6: base = context->Esi; seg = context->SegDs; break;
case 7: base = context->Edi; seg = context->SegDs; break;
}
switch (mod)
{
@ -156,7 +156,7 @@ static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
if (rm == 5) /* special case: ds:(disp32) */
{
GET_VAL( &base, DWORD );
seg = DS_reg(context);
seg = context->SegDs;
}
break;
@ -176,36 +176,36 @@ static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
switch(rm)
{
case 0: /* ds:(bx,si) */
base = LOWORD(EBX_reg(context)) + LOWORD(ESI_reg(context));
seg = DS_reg(context);
base = LOWORD(context->Ebx) + LOWORD(context->Esi);
seg = context->SegDs;
break;
case 1: /* ds:(bx,di) */
base = LOWORD(EBX_reg(context)) + LOWORD(EDI_reg(context));
seg = DS_reg(context);
base = LOWORD(context->Ebx) + LOWORD(context->Edi);
seg = context->SegDs;
break;
case 2: /* ss:(bp,si) */
base = LOWORD(EBP_reg(context)) + LOWORD(ESI_reg(context));
seg = SS_reg(context);
base = LOWORD(context->Ebp) + LOWORD(context->Esi);
seg = context->SegSs;
break;
case 3: /* ss:(bp,di) */
base = LOWORD(EBP_reg(context)) + LOWORD(EDI_reg(context));
seg = SS_reg(context);
base = LOWORD(context->Ebp) + LOWORD(context->Edi);
seg = context->SegSs;
break;
case 4: /* ds:(si) */
base = LOWORD(ESI_reg(context));
seg = DS_reg(context);
base = LOWORD(context->Esi);
seg = context->SegDs;
break;
case 5: /* ds:(di) */
base = LOWORD(EDI_reg(context));
seg = DS_reg(context);
base = LOWORD(context->Edi);
seg = context->SegDs;
break;
case 6: /* ss:(bp) */
base = LOWORD(EBP_reg(context));
seg = SS_reg(context);
base = LOWORD(context->Ebp);
seg = context->SegSs;
break;
case 7: /* ds:(bx) */
base = LOWORD(EBX_reg(context));
seg = DS_reg(context);
base = LOWORD(context->Ebx);
seg = context->SegDs;
break;
}
@ -215,7 +215,7 @@ static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
if (rm == 6) /* special case: ds:(disp16) */
{
GET_VAL( &base, WORD );
seg = DS_reg(context);
seg = context->SegDs;
}
break;
@ -266,36 +266,36 @@ static BOOL INSTR_EmulateLDS( CONTEXT86 *context, BYTE *instr, int long_op,
switch((*regmodrm >> 3) & 7)
{
case 0:
if (long_op) EAX_reg(context) = *(DWORD *)addr;
else SET_LOWORD(EAX_reg(context),*(WORD *)addr);
if (long_op) context->Eax = *(DWORD *)addr;
else SET_LOWORD(context->Eax,*(WORD *)addr);
break;
case 1:
if (long_op) ECX_reg(context) = *(DWORD *)addr;
else SET_LOWORD(ECX_reg(context),*(WORD *)addr);
if (long_op) context->Ecx = *(DWORD *)addr;
else SET_LOWORD(context->Ecx,*(WORD *)addr);
break;
case 2:
if (long_op) EDX_reg(context) = *(DWORD *)addr;
else SET_LOWORD(EDX_reg(context),*(WORD *)addr);
if (long_op) context->Edx = *(DWORD *)addr;
else SET_LOWORD(context->Edx,*(WORD *)addr);
break;
case 3:
if (long_op) EBX_reg(context) = *(DWORD *)addr;
else SET_LOWORD(EBX_reg(context),*(WORD *)addr);
if (long_op) context->Ebx = *(DWORD *)addr;
else SET_LOWORD(context->Ebx,*(WORD *)addr);
break;
case 4:
if (long_op) ESP_reg(context) = *(DWORD *)addr;
else SET_LOWORD(ESP_reg(context),*(WORD *)addr);
if (long_op) context->Esp = *(DWORD *)addr;
else SET_LOWORD(context->Esp,*(WORD *)addr);
break;
case 5:
if (long_op) EBP_reg(context) = *(DWORD *)addr;
else SET_LOWORD(EBP_reg(context),*(WORD *)addr);
if (long_op) context->Ebp = *(DWORD *)addr;
else SET_LOWORD(context->Ebp,*(WORD *)addr);
break;
case 6:
if (long_op) ESI_reg(context) = *(DWORD *)addr;
else SET_LOWORD(ESI_reg(context),*(WORD *)addr);
if (long_op) context->Esi = *(DWORD *)addr;
else SET_LOWORD(context->Esi,*(WORD *)addr);
break;
case 7:
if (long_op) EDI_reg(context) = *(DWORD *)addr;
else SET_LOWORD(EDI_reg(context),*(WORD *)addr);
if (long_op) context->Edi = *(DWORD *)addr;
else SET_LOWORD(context->Edi,*(WORD *)addr);
break;
}
@ -303,13 +303,13 @@ static BOOL INSTR_EmulateLDS( CONTEXT86 *context, BYTE *instr, int long_op,
switch(*instr)
{
case 0xc4: ES_reg(context) = seg; break; /* les */
case 0xc5: DS_reg(context) = seg; break; /* lds */
case 0xc4: context->SegEs = seg; break; /* les */
case 0xc5: context->SegDs = seg; break; /* lds */
case 0x0f: switch(instr[1])
{
case 0xb2: SS_reg(context) = seg; break; /* lss */
case 0xb4: FS_reg(context) = seg; break; /* lfs */
case 0xb5: GS_reg(context) = seg; break; /* lgs */
case 0xb2: context->SegSs = seg; break; /* lss */
case 0xb4: context->SegFs = seg; break; /* lfs */
case 0xb5: context->SegGs = seg; break; /* lgs */
}
break;
}
@ -334,15 +334,15 @@ static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context )
{
case 1:
DPRINTF( "0x%x < %02x @ %04x:%04x\n", port, LOBYTE(res),
(WORD)CS_reg(context), LOWORD(EIP_reg(context)));
(WORD)context->SegCs, LOWORD(context->Eip));
break;
case 2:
DPRINTF( "0x%x < %04x @ %04x:%04x\n", port, LOWORD(res),
(WORD)CS_reg(context), LOWORD(EIP_reg(context)));
(WORD)context->SegCs, LOWORD(context->Eip));
break;
case 4:
DPRINTF( "0x%x < %08lx @ %04x:%04x\n", port, res,
(WORD)CS_reg(context), LOWORD(EIP_reg(context)));
(WORD)context->SegCs, LOWORD(context->Eip));
break;
}
}
@ -364,15 +364,15 @@ static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context )
{
case 1:
DPRINTF("0x%x > %02x @ %04x:%04x\n", port, LOBYTE(val),
(WORD)CS_reg(context), LOWORD(EIP_reg(context)));
(WORD)context->SegCs, LOWORD(context->Eip));
break;
case 2:
DPRINTF("0x%x > %04x @ %04x:%04x\n", port, LOWORD(val),
(WORD)CS_reg(context), LOWORD(EIP_reg(context)));
(WORD)context->SegCs, LOWORD(context->Eip));
break;
case 4:
DPRINTF("0x%x > %08lx @ %04x:%04x\n", port, val,
(WORD)CS_reg(context), LOWORD(EIP_reg(context)));
(WORD)context->SegCs, LOWORD(context->Eip));
break;
}
}
@ -405,22 +405,22 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
switch(*instr)
{
case 0x2e:
segprefix = CS_reg(context);
segprefix = context->SegCs;
break;
case 0x36:
segprefix = SS_reg(context);
segprefix = context->SegSs;
break;
case 0x3e:
segprefix = DS_reg(context);
segprefix = context->SegDs;
break;
case 0x26:
segprefix = ES_reg(context);
segprefix = context->SegEs;
break;
case 0x64:
segprefix = FS_reg(context);
segprefix = context->SegFs;
break;
case 0x65:
segprefix = GS_reg(context);
segprefix = context->SegGs;
break;
case 0x66:
long_op = !long_op; /* opcode size prefix */
@ -460,12 +460,12 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
{
switch(*instr)
{
case 0x07: ES_reg(context) = seg; break;
case 0x17: SS_reg(context) = seg; break;
case 0x1f: DS_reg(context) = seg; break;
case 0x07: context->SegEs = seg; break;
case 0x17: context->SegSs = seg; break;
case 0x1f: context->SegDs = seg; break;
}
add_stack(context, long_op ? 4 : 2);
EIP_reg(context) += prefixlen + 1;
context->Eip += prefixlen + 1;
return TRUE;
}
}
@ -478,8 +478,8 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
switch (instr[2]) {
case 0xc0:
ERR("mov eax,cr0 at 0x%08lx, EAX=0x%08lx\n",
EIP_reg(context),EAX_reg(context) );
EIP_reg(context) += prefixlen+3;
context->Eip,context->Eax );
context->Eip += prefixlen+3;
return TRUE;
default:
break; /*fallthrough to bad instruction handling */
@ -499,14 +499,14 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
* bit 7: PGE Enable global pages
* bit 8: PCE Enable performance counters at IPL3
*/
ERR("mov cr4,eax at 0x%08lx\n",EIP_reg(context));
EAX_reg(context) = 0;
EIP_reg(context) += prefixlen+3;
ERR("mov cr4,eax at 0x%08lx\n",context->Eip);
context->Eax = 0;
context->Eip += prefixlen+3;
return TRUE;
case 0xc0: /* mov cr0, eax */
ERR("mov cr0,eax at 0x%08lx\n",EIP_reg(context));
EAX_reg(context) = 0x10; /* FIXME: set more bits ? */
EIP_reg(context) += prefixlen+3;
ERR("mov cr0,eax at 0x%08lx\n",context->Eip);
context->Eax = 0x10; /* FIXME: set more bits ? */
context->Eip += prefixlen+3;
return TRUE;
default: /* fallthrough to illegal instruction */
break;
@ -518,9 +518,9 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
WORD seg = *(WORD *)get_stack( context );
if (INSTR_ReplaceSelector( context, &seg ))
{
FS_reg(context) = seg;
context->SegFs = seg;
add_stack(context, long_op ? 4 : 2);
EIP_reg(context) += prefixlen + 2;
context->Eip += prefixlen + 2;
return TRUE;
}
}
@ -530,9 +530,9 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
WORD seg = *(WORD *)get_stack( context );
if (INSTR_ReplaceSelector( context, &seg ))
{
GS_reg(context) = seg;
context->SegGs = seg;
add_stack(context, long_op ? 4 : 2);
EIP_reg(context) += prefixlen + 2;
context->Eip += prefixlen + 2;
return TRUE;
}
}
@ -543,7 +543,7 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
if (INSTR_EmulateLDS( context, instr, long_op,
long_addr, segprefix, &len ))
{
EIP_reg(context) += prefixlen + len;
context->Eip += prefixlen + len;
return TRUE;
}
break;
@ -558,10 +558,10 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
int typ = *instr; /* Just in case it's overwritten. */
int outp = (typ >= 0x6e);
unsigned long count = repX ?
(long_addr ? ECX_reg(context) : LOWORD(ECX_reg(context))) : 1;
(long_addr ? context->Ecx : LOWORD(context->Ecx)) : 1;
int opsize = (typ & 1) ? (long_op ? 4 : 2) : 1;
int step = (EFL_reg(context) & 0x400) ? -opsize : +opsize;
int seg = outp ? DS_reg(context) : ES_reg(context); /* FIXME: is this right? */
int step = (context->EFlags & 0x400) ? -opsize : +opsize;
int seg = outp ? context->SegDs : context->SegEs; /* FIXME: is this right? */
if (outp)
/* FIXME: Check segment readable. */
@ -572,25 +572,25 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
if (repX)
{
if (long_addr) ECX_reg(context) = 0;
else SET_LOWORD(ECX_reg(context),0);
if (long_addr) context->Ecx = 0;
else SET_LOWORD(context->Ecx,0);
}
while (count-- > 0)
{
void *data;
WORD dx = LOWORD(EDX_reg(context));
WORD dx = LOWORD(context->Edx);
if (outp)
{
data = make_ptr( context, seg, context->Esi, long_addr );
if (long_addr) ESI_reg(context) += step;
else ADD_LOWORD(ESI_reg(context),step);
if (long_addr) context->Esi += step;
else ADD_LOWORD(context->Esi,step);
}
else
{
data = make_ptr( context, seg, context->Edi, long_addr );
if (long_addr) EDI_reg(context) += step;
else ADD_LOWORD(EDI_reg(context),step);
if (long_addr) context->Edi += step;
else ADD_LOWORD(context->Edi,step);
}
switch (typ)
@ -615,7 +615,7 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
break;
}
}
EIP_reg(context) += prefixlen + 1;
context->Eip += prefixlen + 1;
}
return TRUE;
@ -633,26 +633,26 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
switch((instr[1] >> 3) & 7)
{
case 0:
ES_reg(context) = seg;
EIP_reg(context) += prefixlen + len + 1;
context->SegEs = seg;
context->Eip += prefixlen + len + 1;
return TRUE;
case 1: /* cs */
break;
case 2:
SS_reg(context) = seg;
EIP_reg(context) += prefixlen + len + 1;
context->SegSs = seg;
context->Eip += prefixlen + len + 1;
return TRUE;
case 3:
DS_reg(context) = seg;
EIP_reg(context) += prefixlen + len + 1;
context->SegDs = seg;
context->Eip += prefixlen + len + 1;
return TRUE;
case 4:
FS_reg(context) = seg;
EIP_reg(context) += prefixlen + len + 1;
context->SegFs = seg;
context->Eip += prefixlen + len + 1;
return TRUE;
case 5:
GS_reg(context) = seg;
EIP_reg(context) += prefixlen + len + 1;
context->SegGs = seg;
context->Eip += prefixlen + len + 1;
return TRUE;
case 6: /* unused */
case 7: /* unused */
@ -666,7 +666,7 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
if (INSTR_EmulateLDS( context, instr, long_op,
long_addr, segprefix, &len ))
{
EIP_reg(context) += prefixlen + len;
context->Eip += prefixlen + len;
return TRUE;
}
break; /* Unable to emulate it */
@ -684,17 +684,17 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
if (!addr)
{
FIXME("no handler for interrupt %02x, ignoring it\n", instr[1]);
EIP_reg(context) += prefixlen + 2;
context->Eip += prefixlen + 2;
return TRUE;
}
/* Push the flags and return address on the stack */
*(--stack) = LOWORD(EFL_reg(context));
*(--stack) = CS_reg(context);
*(--stack) = LOWORD(EIP_reg(context)) + prefixlen + 2;
*(--stack) = LOWORD(context->EFlags);
*(--stack) = context->SegCs;
*(--stack) = LOWORD(context->Eip) + prefixlen + 2;
add_stack(context, -3 * sizeof(WORD));
/* Jump to the interrupt handler */
CS_reg(context) = HIWORD(addr);
EIP_reg(context) = LOWORD(addr);
context->SegCs = HIWORD(addr);
context->Eip = LOWORD(addr);
}
return TRUE;
@ -702,95 +702,94 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
if (long_op)
{
DWORD *stack = get_stack( context );
EIP_reg(context) = *stack++;
CS_reg(context) = *stack++;
EFL_reg(context) = *stack;
context->Eip = *stack++;
context->SegCs = *stack++;
context->EFlags = *stack;
add_stack(context, 3*sizeof(DWORD)); /* Pop the return address and flags */
}
else
{
WORD *stack = get_stack( context );
EIP_reg(context) = *stack++;
CS_reg(context) = *stack++;
SET_LOWORD(EFL_reg(context),*stack);
context->Eip = *stack++;
context->SegCs = *stack++;
SET_LOWORD(context->EFlags,*stack);
add_stack(context, 3*sizeof(WORD)); /* Pop the return address and flags */
}
return TRUE;
case 0xe4: /* inb al,XX */
SET_LOBYTE(EAX_reg(context),INSTR_inport( instr[1], 1, context ));
EIP_reg(context) += prefixlen + 2;
SET_LOBYTE(context->Eax,INSTR_inport( instr[1], 1, context ));
context->Eip += prefixlen + 2;
return TRUE;
case 0xe5: /* in (e)ax,XX */
if (long_op)
EAX_reg(context) = INSTR_inport( instr[1], 4, context );
context->Eax = INSTR_inport( instr[1], 4, context );
else
SET_LOWORD(EAX_reg(context), INSTR_inport( instr[1], 2, context ));
EIP_reg(context) += prefixlen + 2;
SET_LOWORD(context->Eax, INSTR_inport( instr[1], 2, context ));
context->Eip += prefixlen + 2;
return TRUE;
case 0xe6: /* outb XX,al */
INSTR_outport( instr[1], 1, LOBYTE(EAX_reg(context)), context );
EIP_reg(context) += prefixlen + 2;
INSTR_outport( instr[1], 1, LOBYTE(context->Eax), context );
context->Eip += prefixlen + 2;
return TRUE;
case 0xe7: /* out XX,(e)ax */
if (long_op)
INSTR_outport( instr[1], 4, EAX_reg(context), context );
INSTR_outport( instr[1], 4, context->Eax, context );
else
INSTR_outport( instr[1], 2, LOWORD(EAX_reg(context)), context );
EIP_reg(context) += prefixlen + 2;
INSTR_outport( instr[1], 2, LOWORD(context->Eax), context );
context->Eip += prefixlen + 2;
return TRUE;
case 0xec: /* inb al,dx */
SET_LOBYTE(EAX_reg(context), INSTR_inport( LOWORD(EDX_reg(context)), 1, context ) );
EIP_reg(context) += prefixlen + 1;
SET_LOBYTE(context->Eax, INSTR_inport( LOWORD(context->Edx), 1, context ) );
context->Eip += prefixlen + 1;
return TRUE;
case 0xed: /* in (e)ax,dx */
if (long_op)
EAX_reg(context) = INSTR_inport( LOWORD(EDX_reg(context)), 4, context );
context->Eax = INSTR_inport( LOWORD(context->Edx), 4, context );
else
SET_LOWORD(EAX_reg(context), INSTR_inport( LOWORD(EDX_reg(context)), 2, context ));
EIP_reg(context) += prefixlen + 1;
SET_LOWORD(context->Eax, INSTR_inport( LOWORD(context->Edx), 2, context ));
context->Eip += prefixlen + 1;
return TRUE;
case 0xee: /* outb dx,al */
INSTR_outport( LOWORD(EDX_reg(context)), 1, LOBYTE(EAX_reg(context)), context );
EIP_reg(context) += prefixlen + 1;
INSTR_outport( LOWORD(context->Edx), 1, LOBYTE(context->Eax), context );
context->Eip += prefixlen + 1;
return TRUE;
case 0xef: /* out dx,(e)ax */
if (long_op)
INSTR_outport( LOWORD(EDX_reg(context)), 4, EAX_reg(context), context );
INSTR_outport( LOWORD(context->Edx), 4, context->Eax, context );
else
INSTR_outport( LOWORD(EDX_reg(context)), 2, LOWORD(EAX_reg(context)), context );
EIP_reg(context) += prefixlen + 1;
INSTR_outport( LOWORD(context->Edx), 2, LOWORD(context->Eax), context );
context->Eip += prefixlen + 1;
return TRUE;
case 0xfa: /* cli, ignored */
EIP_reg(context) += prefixlen + 1;
context->Eip += prefixlen + 1;
return TRUE;
case 0xfb: /* sti, ignored */
EIP_reg(context) += prefixlen + 1;
context->Eip += prefixlen + 1;
return TRUE;
}
/* Check for Win16 __GP handler */
gpHandler = HasGPHandler16( PTR_SEG_OFF_TO_SEGPTR( CS_reg(context),
EIP_reg(context) ) );
gpHandler = HasGPHandler16( PTR_SEG_OFF_TO_SEGPTR( context->SegCs, context->Eip ) );
if (gpHandler)
{
WORD *stack = get_stack( context );
*--stack = CS_reg(context);
*--stack = EIP_reg(context);
*--stack = context->SegCs;
*--stack = context->Eip;
add_stack(context, -2*sizeof(WORD));
CS_reg(context) = SELECTOROF( gpHandler );
EIP_reg(context) = OFFSETOF( gpHandler );
context->SegCs = SELECTOROF( gpHandler );
context->Eip = OFFSETOF( gpHandler );
return TRUE;
}
return FALSE; /* Unable to emulate it */

View File

@ -690,15 +690,15 @@ static void
x_SMapLS_IP_EBP_x(CONTEXT86 *context,int argoff) {
DWORD val,ptr;
val =*(DWORD*)(EBP_reg(context)+argoff);
val =*(DWORD*)(context->Ebp + argoff);
if (val<0x10000) {
ptr=val;
*(DWORD*)(EBP_reg(context)+argoff) = 0;
*(DWORD*)(context->Ebp + argoff) = 0;
} else {
ptr = MapLS((LPVOID)val);
*(DWORD*)(EBP_reg(context)+argoff) = ptr;
*(DWORD*)(context->Ebp + argoff) = ptr;
}
EAX_reg(context) = ptr;
context->Eax = ptr;
}
/***********************************************************************
@ -751,11 +751,12 @@ void WINAPI SMapLS_IP_EBP_40(CONTEXT86 *context) {x_SMapLS_IP_EBP_x(context,40);
*/
void WINAPI SMapLS( CONTEXT86 *context )
{
if (EAX_reg(context)>=0x10000) {
EAX_reg(context) = MapLS((LPVOID)EAX_reg(context));
EDX_reg(context) = EAX_reg(context);
if (HIWORD(context->Eax))
{
context->Eax = MapLS( (LPVOID)context->Eax );
context->Edx = context->Eax;
} else {
EDX_reg(context) = 0;
context->Edx = 0;
}
}
@ -765,15 +766,17 @@ void WINAPI SMapLS( CONTEXT86 *context )
void WINAPI SUnMapLS( CONTEXT86 *context )
{
if (EAX_reg(context)>=0x10000)
UnMapLS((SEGPTR)EAX_reg(context));
if (HIWORD(context->Eax)) UnMapLS( (SEGPTR)context->Eax );
}
static void
x_SUnMapLS_IP_EBP_x(CONTEXT86 *context,int argoff) {
if (*(DWORD*)(EBP_reg(context)+argoff))
UnMapLS(*(DWORD*)(EBP_reg(context)+argoff));
*(DWORD*)(EBP_reg(context)+argoff)=0;
inline static void x_SUnMapLS_IP_EBP_x(CONTEXT86 *context,int argoff)
{
SEGPTR *ptr = (SEGPTR *)(context->Ebp + argoff);
if (*ptr)
{
UnMapLS( *ptr );
*ptr = 0;
}
}
/***********************************************************************
@ -842,7 +845,7 @@ void WINAPI SUnMapLS_IP_EBP_40(CONTEXT86 *context) { x_SUnMapLS_IP_EBP_x(context
void WINAPI AllocMappedBuffer( CONTEXT86 *context )
{
HGLOBAL handle = GlobalAlloc(0, EDI_reg(context) + 8);
HGLOBAL handle = GlobalAlloc(0, context->Edi + 8);
DWORD *buffer = (DWORD *)GlobalLock(handle);
SEGPTR ptr = 0;
@ -854,14 +857,14 @@ void WINAPI AllocMappedBuffer( CONTEXT86 *context )
}
if (!ptr)
EAX_reg(context) = EDI_reg(context) = 0;
context->Eax = context->Edi = 0;
else
{
buffer[0] = handle;
buffer[1] = ptr;
EAX_reg(context) = (DWORD) ptr;
EDI_reg(context) = (DWORD)(buffer + 2);
context->Eax = (DWORD) ptr;
context->Edi = (DWORD)(buffer + 2);
}
}
@ -875,9 +878,9 @@ void WINAPI AllocMappedBuffer( CONTEXT86 *context )
void WINAPI FreeMappedBuffer( CONTEXT86 *context )
{
if (EDI_reg(context))
if (context->Edi)
{
DWORD *buffer = (DWORD *)EDI_reg(context) - 2;
DWORD *buffer = (DWORD *)context->Edi - 2;
UnMapLS(buffer[1]);

View File

@ -162,11 +162,9 @@ void WINAPI LogParamError16(UINT16 uErr, FARPROC16 lpfn, LPVOID lpvParam)
*/
void WINAPI HandleParamError( CONTEXT86 *context )
{
UINT16 uErr = BX_reg( context );
FARPROC16 lpfn = (FARPROC16)PTR_SEG_OFF_TO_SEGPTR( CS_reg(context),
EIP_reg(context) );
LPVOID lpvParam = (LPVOID)MAKELONG( AX_reg( context ),
CX_reg( context ) );
UINT16 uErr = LOWORD(context->Ebx);
FARPROC16 lpfn = (FARPROC16)PTR_SEG_OFF_TO_SEGPTR( context->SegCs, context->Eip );
LPVOID lpvParam = (LPVOID)MAKELONG( LOWORD(context->Eax), LOWORD(context->Ecx) );
LogParamError16( uErr, lpfn, lpvParam );
@ -175,15 +173,14 @@ void WINAPI HandleParamError( CONTEXT86 *context )
/* Abort current procedure: Unwind stack frame and jump
to error handler (location at [bp-2]) */
WORD *stack = PTR_SEG_OFF_TO_LIN( SS_reg( context ),
LOWORD(EBP_reg( context )) );
ESP_reg( context ) = LOWORD(EBP_reg( context )) - 2;
EBP_reg( context ) = stack[0] & 0xfffe;
WORD *stack = PTR_SEG_OFF_TO_LIN( context->SegSs, LOWORD(context->Ebp) );
context->Esp = LOWORD(context->Ebp) - 2;
context->Ebp = stack[0] & 0xfffe;
EIP_reg( context ) = stack[-1];
context->Eip = stack[-1];
EAX_reg( context ) = ECX_reg( context ) = EDX_reg( context ) = 0;
ES_reg( context) = 0;
context->Eax = context->Ecx = context->Edx = 0;
context->SegEs = 0;
}
}

View File

@ -129,9 +129,9 @@ static void SYSTEM_CallSystemTimerProc( FARPROC16 proc, WORD timer )
CONTEXT86 context;
memset( &context, '\0', sizeof(context) );
CS_reg( &context ) = SELECTOROF( proc );
EIP_reg( &context ) = OFFSETOF( proc );
EBP_reg( &context ) = OFFSETOF( NtCurrentTeb()->cur_stack )
context.SegCs = SELECTOROF( proc );
context.Eip = OFFSETOF( proc );
context.Ebp = OFFSETOF( NtCurrentTeb()->cur_stack )
+ (WORD)&((STACK16FRAME*)0)->bp;
AX_reg( &context ) = timer;

View File

@ -141,16 +141,16 @@ DWORD DOS_LOLSeg;
/* the device implementations */
static void do_lret(CONTEXT86*ctx)
{
WORD *stack = CTX_SEG_OFF_TO_LIN(ctx, SS_reg(ctx), ESP_reg(ctx));
WORD *stack = CTX_SEG_OFF_TO_LIN(ctx, ctx->SegSs, ctx->Esp);
EIP_reg(ctx) = *(stack++);
CS_reg(ctx) = *(stack++);
ESP_reg(ctx) += 2*sizeof(WORD);
ctx->Eip = *(stack++);
ctx->SegCs = *(stack++);
ctx->Esp += 2*sizeof(WORD);
}
static void do_strategy(CONTEXT86*ctx, int id, int extra)
{
REQUEST_HEADER *hdr = CTX_SEG_OFF_TO_LIN(ctx, ES_reg(ctx), EBX_reg(ctx));
REQUEST_HEADER *hdr = CTX_SEG_OFF_TO_LIN(ctx, ctx->SegEs, ctx->Ebx);
void **hdr_ptr = strategy_data[id];
if (!hdr_ptr) {
@ -527,17 +527,17 @@ static void DOSDEV_DoReq(void*req, DWORD dev)
memset(&ctx, 0, sizeof(ctx));
/* ES:BX points to request for strategy routine */
ES_reg(&ctx) = HIWORD(DOS_LOLSeg);
EBX_reg(&ctx) = DOS_DATASEG_OFF(req);
ctx.SegEs = HIWORD(DOS_LOLSeg);
ctx.Ebx = DOS_DATASEG_OFF(req);
/* call strategy routine */
CS_reg(&ctx) = SELECTOROF(dev);
EIP_reg(&ctx) = dhdr->strategy;
ctx.SegCs = SELECTOROF(dev);
ctx.Eip = dhdr->strategy;
DPMI_CallRMProc(&ctx, 0, 0, 0);
/* call interrupt routine */
CS_reg(&ctx) = SELECTOROF(dev);
EIP_reg(&ctx) = dhdr->interrupt;
ctx.SegCs = SELECTOROF(dev);
ctx.Eip = dhdr->interrupt;
DPMI_CallRMProc(&ctx, 0, 0, 0);
/* completed, copy request back */

View File

@ -66,8 +66,8 @@ DOSASPI_PostProc( SRB_ExecSCSICmd *lpPRB )
/* Zero everything */
memset(&ctx, 0, sizeof(ctx));
/* CS:IP is routine to call */
CS_reg(&ctx) = SELECTOROF(lpSRB16->cmd.SRB_PostProc);
EIP_reg(&ctx) = OFFSETOF(lpSRB16->cmd.SRB_PostProc);
ctx.SegCs = SELECTOROF(lpSRB16->cmd.SRB_PostProc);
ctx.Eip = OFFSETOF(lpSRB16->cmd.SRB_PostProc);
/* DPMI_CallRMProc will push the pointer to the stack
* it is given (in this case &ptrSRB) with length
* 2*sizeof(WORD), that is, it copies the the contents
@ -156,22 +156,22 @@ DWORD ASPI_SendASPIDOSCommand(DWORD ptrSRB)
void WINAPI ASPI_DOS_func(CONTEXT86 *context)
{
WORD *stack = CTX_SEG_OFF_TO_LIN(context, SS_reg(context), ESP_reg(context));
WORD *stack = CTX_SEG_OFF_TO_LIN(context, context->SegSs, context->Esp);
DWORD ptrSRB = *(DWORD *)&stack[2];
ASPI_SendASPIDOSCommand(ptrSRB);
/* simulate a normal RETF sequence as required by DPMI CallRMProcFar */
EIP_reg(context) = *(stack++);
CS_reg(context) = *(stack++);
ESP_reg(context) += 2*sizeof(WORD);
context->Eip = *(stack++);
context->SegCs = *(stack++);
context->Esp += 2*sizeof(WORD);
}
/* returns the address of a real mode callback to ASPI_DOS_func() */
void ASPI_DOS_HandleInt(CONTEXT86 *context)
{
FARPROC16 *p = (FARPROC16 *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
FARPROC16 *p = (FARPROC16 *)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
TRACE("DOS ASPI opening\n");
if ((CX_reg(context) == 4) || (CX_reg(context) == 5))
{

View File

@ -139,22 +139,22 @@ DPMI_xrealloc(LPVOID ptr,int newsize) {
*/
static void INT_GetRealModeContext( REALMODECALL *call, CONTEXT86 *context )
{
EAX_reg(context) = call->eax;
EBX_reg(context) = call->ebx;
ECX_reg(context) = call->ecx;
EDX_reg(context) = call->edx;
ESI_reg(context) = call->esi;
EDI_reg(context) = call->edi;
EBP_reg(context) = call->ebp;
EFL_reg(context) = call->fl | V86_FLAG;
EIP_reg(context) = call->ip;
ESP_reg(context) = call->sp;
CS_reg(context) = call->cs;
DS_reg(context) = call->ds;
ES_reg(context) = call->es;
FS_reg(context) = call->fs;
GS_reg(context) = call->gs;
SS_reg(context) = call->ss;
context->Eax = call->eax;
context->Ebx = call->ebx;
context->Ecx = call->ecx;
context->Edx = call->edx;
context->Esi = call->esi;
context->Edi = call->edi;
context->Ebp = call->ebp;
context->EFlags = call->fl | V86_FLAG;
context->Eip = call->ip;
context->Esp = call->sp;
context->SegCs = call->cs;
context->SegDs = call->ds;
context->SegEs = call->es;
context->SegFs = call->fs;
context->SegGs = call->gs;
context->SegSs = call->ss;
}
@ -163,22 +163,22 @@ static void INT_GetRealModeContext( REALMODECALL *call, CONTEXT86 *context )
*/
static void INT_SetRealModeContext( REALMODECALL *call, CONTEXT86 *context )
{
call->eax = EAX_reg(context);
call->ebx = EBX_reg(context);
call->ecx = ECX_reg(context);
call->edx = EDX_reg(context);
call->esi = ESI_reg(context);
call->edi = EDI_reg(context);
call->ebp = EBP_reg(context);
call->fl = LOWORD(EFL_reg(context));
call->ip = LOWORD(EIP_reg(context));
call->sp = LOWORD(ESP_reg(context));
call->cs = CS_reg(context);
call->ds = DS_reg(context);
call->es = ES_reg(context);
call->fs = FS_reg(context);
call->gs = GS_reg(context);
call->ss = SS_reg(context);
call->eax = context->Eax;
call->ebx = context->Ebx;
call->ecx = context->Ecx;
call->edx = context->Edx;
call->esi = context->Esi;
call->edi = context->Edi;
call->ebp = context->Ebp;
call->fl = LOWORD(context->EFlags);
call->ip = LOWORD(context->Eip);
call->sp = LOWORD(context->Esp);
call->cs = context->SegCs;
call->ds = context->SegDs;
call->es = context->SegEs;
call->fs = context->SegFs;
call->gs = context->SegGs;
call->ss = context->SegSs;
}
#ifdef __i386__
@ -260,8 +260,8 @@ static void DPMI_CallRMCBProc( CONTEXT86 *context, RMCB *rmcb, WORD flag )
DWORD esp,edi;
INT_SetRealModeContext((REALMODECALL *)PTR_SEG_OFF_TO_LIN( rmcb->regs_sel, rmcb->regs_ofs ), context);
ss = SELECTOR_AllocBlock( (void *)(SS_reg(context)<<4), 0x10000, SEGMENT_DATA, FALSE, FALSE );
esp = ESP_reg(context);
ss = SELECTOR_AllocBlock( (void *)(context->SegSs<<4), 0x10000, SEGMENT_DATA, FALSE, FALSE );
esp = context->Esp;
FIXME("untested!\n");
@ -278,16 +278,16 @@ static void DPMI_CallRMCBProc( CONTEXT86 *context, RMCB *rmcb, WORD flag )
} else {
/* 16-bit DPMI client */
CONTEXT86 ctx = *context;
CS_reg(&ctx) = rmcb->proc_sel;
EIP_reg(&ctx) = rmcb->proc_ofs;
DS_reg(&ctx) = ss;
ESI_reg(&ctx) = esp;
ES_reg(&ctx) = rmcb->regs_sel;
EDI_reg(&ctx) = rmcb->regs_ofs;
ctx.SegCs = rmcb->proc_sel;
ctx.Eip = rmcb->proc_ofs;
ctx.SegDs = ss;
ctx.Esi = esp;
ctx.SegEs = rmcb->regs_sel;
ctx.Edi = rmcb->regs_ofs;
/* FIXME: I'm pretty sure this isn't right - should push flags first */
CallTo16RegisterShort(&ctx, 0);
es = ES_reg(&ctx);
edi = EDI_reg(&ctx);
es = ctx.SegEs;
edi = ctx.Edi;
}
SELECTOR_FreeBlock(ss, 1);
INT_GetRealModeContext((REALMODECALL*)PTR_SEG_OFF_TO_LIN( es, edi ), context);
@ -315,41 +315,41 @@ int DPMI_CallRMProc( CONTEXT86 *context, LPWORD stack, int args, int iret )
GlobalUnlock16( GetCurrentTask() );
TRACE("EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n",
EAX_reg(context), EBX_reg(context), ECX_reg(context), EDX_reg(context) );
context->Eax, context->Ebx, context->Ecx, context->Edx );
TRACE("ESI=%08lx EDI=%08lx ES=%04lx DS=%04lx CS:IP=%04lx:%04x, %d WORD arguments, %s\n",
ESI_reg(context), EDI_reg(context), ES_reg(context), DS_reg(context),
CS_reg(context), LOWORD(EIP_reg(context)), args, iret?"IRET":"FAR" );
context->Esi, context->Edi, context->SegEs, context->SegDs,
context->SegCs, LOWORD(context->Eip), args, iret?"IRET":"FAR" );
callrmproc_again:
/* there might be some code that just jumps to RMCBs or the like,
in which case following the jumps here might get us to a shortcut */
code = CTX_SEG_OFF_TO_LIN(context, CS_reg(context), EIP_reg(context));
code = CTX_SEG_OFF_TO_LIN(context, context->SegCs, context->Eip);
switch (*code) {
case 0xe9: /* JMP NEAR */
EIP_reg(context) += 3 + *(WORD *)(code+1);
context->Eip += 3 + *(WORD *)(code+1);
/* yeah, I know these gotos don't look good... */
goto callrmproc_again;
case 0xea: /* JMP FAR */
EIP_reg(context) = *(WORD *)(code+1);
CS_reg(context) = *(WORD *)(code+3);
context->Eip = *(WORD *)(code+1);
context->SegCs = *(WORD *)(code+3);
/* ...but since the label is there anyway... */
goto callrmproc_again;
case 0xeb: /* JMP SHORT */
EIP_reg(context) += 2 + *(signed char *)(code+1);
context->Eip += 2 + *(signed char *)(code+1);
/* ...because of other gotos below, so... */
goto callrmproc_again;
}
/* shortcut for chaining to internal interrupt handlers */
if ((CS_reg(context) == 0xF000) && iret) {
return INT_RealModeInterrupt( LOWORD(EIP_reg(context))/4, context);
if ((context->SegCs == 0xF000) && iret) {
return INT_RealModeInterrupt( LOWORD(context->Eip)/4, context);
}
/* shortcut for RMCBs */
CurrRMCB = FirstRMCB;
while (CurrRMCB && (HIWORD(CurrRMCB->address) != CS_reg(context)))
while (CurrRMCB && (HIWORD(CurrRMCB->address) != context->SegCs))
CurrRMCB = CurrRMCB->next;
if (!(CurrRMCB || lpDosTask)) {
@ -361,31 +361,31 @@ callrmproc_again:
}
}
if (!already) {
if (!SS_reg(context)) {
if (!context->SegSs) {
alloc = 1; /* allocate default stack */
stack16 = addr = DOSMEM_GetBlock( 64, (UINT16 *)&(SS_reg(context)) );
ESP_reg(context) = 64-2;
stack16 = addr = DOSMEM_GetBlock( 64, (UINT16 *)&(context->SegSs) );
context->Esp = 64-2;
stack16 += 32-1;
if (!addr) {
ERR("could not allocate default stack\n");
return 1;
}
} else {
stack16 = CTX_SEG_OFF_TO_LIN(context, SS_reg(context), ESP_reg(context));
stack16 = CTX_SEG_OFF_TO_LIN(context, context->SegSs, context->Esp);
}
ESP_reg(context) -= (args + (iret?1:0)) * sizeof(WORD);
context->Esp -= (args + (iret?1:0)) * sizeof(WORD);
stack16 -= args;
if (args) memcpy(stack16, stack, args*sizeof(WORD) );
/* push flags if iret */
if (iret) {
stack16--; args++;
*stack16 = LOWORD(EFL_reg(context));
*stack16 = LOWORD(context->EFlags);
}
/* push return address (return to interrupt wrapper) */
*(--stack16) = DOSMEM_wrap_seg;
*(--stack16) = 0;
/* adjust stack */
ESP_reg(context) -= 2*sizeof(WORD);
context->Esp -= 2*sizeof(WORD);
already = 1;
}
@ -393,8 +393,8 @@ callrmproc_again:
/* RMCB call, invoke protected-mode handler directly */
DPMI_CallRMCBProc(context, CurrRMCB, lpDosTask ? lpDosTask->dpmi_flag : 0);
/* check if we returned to where we thought we would */
if ((CS_reg(context) != DOSMEM_wrap_seg) ||
(LOWORD(EIP_reg(context)) != 0)) {
if ((context->SegCs != DOSMEM_wrap_seg) ||
(LOWORD(context->Eip) != 0)) {
/* we need to continue at different address in real-mode space,
so we need to set it all up for real mode again */
goto callrmproc_again;
@ -416,15 +416,15 @@ static void CallRMInt( CONTEXT86 *context )
{
CONTEXT86 realmode_ctx;
FARPROC16 rm_int = INT_GetRMHandler( BL_reg(context) );
REALMODECALL *call = (REALMODECALL *)PTR_SEG_OFF_TO_LIN( ES_reg(context),
REALMODECALL *call = (REALMODECALL *)PTR_SEG_OFF_TO_LIN( context->SegEs,
DI_reg(context) );
INT_GetRealModeContext( call, &realmode_ctx );
/* we need to check if a real-mode program has hooked the interrupt */
if (HIWORD(rm_int)!=0xF000) {
/* yup, which means we need to switch to real mode... */
CS_reg(&realmode_ctx) = HIWORD(rm_int);
EIP_reg(&realmode_ctx) = LOWORD(rm_int);
realmode_ctx.SegCs = HIWORD(rm_int);
realmode_ctx.Eip = LOWORD(rm_int);
if (DPMI_CallRMProc( &realmode_ctx, NULL, 0, TRUE))
SET_CFLAG(context);
} else {
@ -433,13 +433,13 @@ static void CallRMInt( CONTEXT86 *context )
decide to move interrupts around for whatever reason... */
if (INT_RealModeInterrupt( LOWORD(rm_int)/4, &realmode_ctx ))
SET_CFLAG(context);
if (EFL_reg(context)&1) {
if (context->EFlags & 1) {
FIXME("%02x: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n",
BL_reg(context), EAX_reg(&realmode_ctx), EBX_reg(&realmode_ctx),
ECX_reg(&realmode_ctx), EDX_reg(&realmode_ctx));
BL_reg(context), realmode_ctx.Eax, realmode_ctx.Ebx,
realmode_ctx.Ecx, realmode_ctx.Edx);
FIXME(" ESI=%08lx EDI=%08lx DS=%04lx ES=%04lx\n",
ESI_reg(&realmode_ctx), EDI_reg(&realmode_ctx),
DS_reg(&realmode_ctx), ES_reg(&realmode_ctx) );
realmode_ctx.Esi, realmode_ctx.Edi,
realmode_ctx.SegDs, realmode_ctx.SegEs );
}
}
INT_SetRealModeContext( call, &realmode_ctx );
@ -448,7 +448,7 @@ static void CallRMInt( CONTEXT86 *context )
static void CallRMProc( CONTEXT86 *context, int iret )
{
REALMODECALL *p = (REALMODECALL *)PTR_SEG_OFF_TO_LIN( ES_reg(context), DI_reg(context) );
REALMODECALL *p = (REALMODECALL *)PTR_SEG_OFF_TO_LIN( context->SegEs, DI_reg(context) );
CONTEXT86 context16;
TRACE("RealModeCall: EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n",
@ -463,7 +463,7 @@ static void CallRMProc( CONTEXT86 *context, int iret )
return;
}
INT_GetRealModeContext(p, &context16);
DPMI_CallRMProc( &context16, ((LPWORD)PTR_SEG_OFF_TO_LIN(SS_reg(context), LOWORD(ESP_reg(context))))+3,
DPMI_CallRMProc( &context16, ((LPWORD)PTR_SEG_OFF_TO_LIN(context->SegSs, LOWORD(context->Esp)))+3,
CX_reg(context), iret );
INT_SetRealModeContext(p, &context16);
}
@ -497,21 +497,21 @@ static void AllocRMCB( CONTEXT86 *context )
{
RMCB *NewRMCB = DPMI_AllocRMCB();
TRACE("Function to call: %04x:%04x\n", (WORD)DS_reg(context), SI_reg(context) );
TRACE("Function to call: %04x:%04x\n", (WORD)context->SegDs, SI_reg(context) );
if (NewRMCB)
{
/* FIXME: if 32-bit DPMI client, use ESI and EDI */
NewRMCB->proc_ofs = SI_reg(context);
NewRMCB->proc_sel = DS_reg(context);
NewRMCB->regs_ofs = DI_reg(context);
NewRMCB->regs_sel = ES_reg(context);
SET_LOWORD( ECX_reg(context), HIWORD(NewRMCB->address) );
SET_LOWORD( EDX_reg(context), LOWORD(NewRMCB->address) );
NewRMCB->proc_ofs = LOWORD(context->Esi);
NewRMCB->proc_sel = context->SegDs;
NewRMCB->regs_ofs = LOWORD(context->Edi);
NewRMCB->regs_sel = context->SegEs;
SET_LOWORD( context->Ecx, HIWORD(NewRMCB->address) );
SET_LOWORD( context->Edx, LOWORD(NewRMCB->address) );
}
else
{
SET_LOWORD( EAX_reg(context), 0x8015 ); /* callback unavailable */
SET_LOWORD( context->Eax, 0x8015 ); /* callback unavailable */
SET_CFLAG(context);
}
}
@ -562,7 +562,7 @@ static void FreeRMCB( CONTEXT86 *context )
CX_reg(context), DX_reg(context));
if (DPMI_FreeRMCB(MAKELONG(DX_reg(context), CX_reg(context)))) {
SET_LOWORD( EAX_reg(context), 0x8024 ); /* invalid callback address */
SET_LOWORD( context->Eax, 0x8024 ); /* invalid callback address */
SET_CFLAG(context);
}
}
@ -594,24 +594,24 @@ static void StartPM( CONTEXT86 *context, LPDOSTASK lpDosTask )
can be used in 32-bit code. Otherwise, these CPUs may not set the high word of esp during a
ring transition (from kernel code) to the 16-bit stack, and this causes trouble if executing
32-bit code using this stack. */
ss = SELECTOR_AllocBlock( (void *)(SS_reg(context)<<4), 0x10000, SEGMENT_DATA, is32, FALSE );
ss = SELECTOR_AllocBlock( (void *)(context->SegSs<<4), 0x10000, SEGMENT_DATA, is32, FALSE );
/* do the same for the data segments, just in case */
if (DS_reg(context) == SS_reg(context)) ds = ss;
else ds = SELECTOR_AllocBlock( (void *)(DS_reg(context)<<4), 0x10000, SEGMENT_DATA, is32, FALSE );
if (context->SegDs == context->SegSs) ds = ss;
else ds = SELECTOR_AllocBlock( (void *)(context->SegDs<<4), 0x10000, SEGMENT_DATA, is32, FALSE );
es = SELECTOR_AllocBlock( psp, 0x100, SEGMENT_DATA, is32, FALSE );
/* convert environment pointer, as the spec says, but we're a bit lazy about the size here... */
psp->environment = SELECTOR_AllocBlock( (void *)(env_seg<<4),
0x10000, SEGMENT_DATA, FALSE, FALSE );
pm_ctx = *context;
CS_reg(&pm_ctx) = DOSMEM_dpmi_sel;
pm_ctx.SegCs = DOSMEM_dpmi_sel;
/* our mode switch wrapper expects the new CS in DX, and the new SS in AX */
EAX_reg(&pm_ctx) = ss;
EDX_reg(&pm_ctx) = cs;
DS_reg(&pm_ctx) = ds;
ES_reg(&pm_ctx) = es;
FS_reg(&pm_ctx) = 0;
GS_reg(&pm_ctx) = 0;
pm_ctx.Eax = ss;
pm_ctx.Edx = cs;
pm_ctx.SegDs = ds;
pm_ctx.SegEs = es;
pm_ctx.SegFs = 0;
pm_ctx.SegGs = 0;
TRACE("DOS program is now entering protected mode\n");
CallTo16RegisterShort(&pm_ctx, 0);
@ -644,20 +644,19 @@ void WINAPI DPMI_RawModeSwitch( SIGCONTEXT *context )
}
/* initialize real-mode context as per spec */
memset(&rm_ctx, 0, sizeof(rm_ctx));
DS_reg(&rm_ctx) = AX_sig(context);
ES_reg(&rm_ctx) = CX_sig(context);
SS_reg(&rm_ctx) = DX_sig(context);
ESP_reg(&rm_ctx) = EBX_sig(context);
CS_reg(&rm_ctx) = SI_sig(context);
EIP_reg(&rm_ctx) = EDI_sig(context);
EBP_reg(&rm_ctx) = EBP_sig(context);
FS_reg(&rm_ctx) = 0;
GS_reg(&rm_ctx) = 0;
EFL_reg(&rm_ctx) = EFL_sig(context); /* at least we need the IF flag */
rm_ctx.SegDs = AX_sig(context);
rm_ctx.SegEs = CX_sig(context);
rm_ctx.SegSs = DX_sig(context);
rm_ctx.Esp = EBX_sig(context);
rm_ctx.SegCs = SI_sig(context);
rm_ctx.Eip = EDI_sig(context);
rm_ctx.Ebp = EBP_sig(context);
rm_ctx.SegFs = 0;
rm_ctx.SegGs = 0;
rm_ctx.EFlags = EFL_sig(context); /* at least we need the IF flag */
/* enter real mode again */
TRACE("re-entering real mode at %04lx:%04lx\n",
CS_reg(&rm_ctx),EIP_reg(&rm_ctx));
TRACE("re-entering real mode at %04lx:%04lx\n",rm_ctx.SegCs,rm_ctx.Eip);
ret = DOSVM_Enter( &rm_ctx );
/* when the real-mode stuff call its mode switch address,
DOSVM_Enter will return and we will continue here */
@ -668,13 +667,13 @@ void WINAPI DPMI_RawModeSwitch( SIGCONTEXT *context )
}
/* alter protected-mode context as per spec */
DS_sig(context) = AX_reg(&rm_ctx);
ES_sig(context) = CX_reg(&rm_ctx);
SS_sig(context) = DX_reg(&rm_ctx);
ESP_sig(context) = EBX_reg(&rm_ctx);
CS_sig(context) = SI_reg(&rm_ctx);
EIP_sig(context) = EDI_reg(&rm_ctx);
EBP_sig(context) = EBP_reg(&rm_ctx);
DS_sig(context) = LOWORD(rm_ctx.Eax);
ES_sig(context) = LOWORD(rm_ctx.Ecx);
SS_sig(context) = LOWORD(rm_ctx.Edx);
ESP_sig(context) = rm_ctx.Ebx;
CS_sig(context) = LOWORD(rm_ctx.Esi);
EIP_sig(context) = rm_ctx.Edi;
EBP_sig(context) = rm_ctx.Ebp;
FS_sig(context) = 0;
GS_sig(context) = 0;
@ -708,12 +707,12 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
if (ISV86(context) && lpDosTask) {
/* Called from real mode, check if it's our wrapper */
TRACE("called from real mode\n");
if (CS_reg(context)==DOSMEM_dpmi_seg) {
if (context->SegCs==DOSMEM_dpmi_seg) {
/* This is the protected mode switch */
StartPM(context,lpDosTask);
return;
} else
if (CS_reg(context)==DOSMEM_xms_seg) {
if (context->SegCs==DOSMEM_xms_seg) {
/* This is the XMS driver entry point */
XMS_Handler(context);
return;
@ -722,7 +721,7 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
/* Check for RMCB */
RMCB *CurrRMCB = FirstRMCB;
while (CurrRMCB && (HIWORD(CurrRMCB->address) != CS_reg(context)))
while (CurrRMCB && (HIWORD(CurrRMCB->address) != context->SegCs))
CurrRMCB = CurrRMCB->next;
if (CurrRMCB) {
@ -738,10 +737,10 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
{
case 0x0000: /* Allocate LDT descriptors */
TRACE("allocate LDT descriptors (%d)\n",CX_reg(context));
if (!(EAX_reg(context) = AllocSelectorArray16( CX_reg(context) )))
if (!(context->Eax = AllocSelectorArray16( CX_reg(context) )))
{
TRACE("failed\n");
EAX_reg(context) = 0x8011; /* descriptor unavailable */
context->Eax = 0x8011; /* descriptor unavailable */
SET_CFLAG(context);
}
TRACE("success, array starts at 0x%04x\n",AX_reg(context));
@ -751,17 +750,17 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
TRACE("free LDT descriptor (0x%04x)\n",BX_reg(context));
if (FreeSelector16( BX_reg(context) ))
{
EAX_reg(context) = 0x8022; /* invalid selector */
context->Eax = 0x8022; /* invalid selector */
SET_CFLAG(context);
}
else
{
/* If a segment register contains the selector being freed, */
/* set it to zero. */
if (!((DS_reg(context)^BX_reg(context)) & ~3)) DS_reg(context) = 0;
if (!((ES_reg(context)^BX_reg(context)) & ~3)) ES_reg(context) = 0;
if (!((FS_reg(context)^BX_reg(context)) & ~3)) FS_reg(context) = 0;
if (!((GS_reg(context)^BX_reg(context)) & ~3)) GS_reg(context) = 0;
if (!((context->SegDs^BX_reg(context)) & ~3)) context->SegDs = 0;
if (!((context->SegEs^BX_reg(context)) & ~3)) context->SegEs = 0;
if (!((context->SegFs^BX_reg(context)) & ~3)) context->SegFs = 0;
if (!((context->SegGs^BX_reg(context)) & ~3)) context->SegGs = 0;
}
break;
@ -781,35 +780,35 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
case 0xe000: entryPoint = 190; break; /* __E000H */
case 0xf000: entryPoint = 194; break; /* __F000H */
default:
EAX_reg(context) = DOSMEM_AllocSelector(BX_reg(context));
context->Eax = DOSMEM_AllocSelector(BX_reg(context));
break;
}
if (entryPoint)
EAX_reg(context) = LOWORD(NE_GetEntryPoint( GetModuleHandle16( "KERNEL" ),
context->Eax = LOWORD(NE_GetEntryPoint( GetModuleHandle16( "KERNEL" ),
entryPoint ));
}
break;
case 0x0003: /* Get next selector increment */
TRACE("get selector increment (__AHINCR)\n");
EAX_reg(context) = __AHINCR;
context->Eax = __AHINCR;
break;
case 0x0004: /* Lock selector (not supported) */
FIXME("lock selector not supported\n");
EAX_reg(context) = 0; /* FIXME: is this a correct return value? */
context->Eax = 0; /* FIXME: is this a correct return value? */
break;
case 0x0005: /* Unlock selector (not supported) */
FIXME("unlock selector not supported\n");
EAX_reg(context) = 0; /* FIXME: is this a correct return value? */
context->Eax = 0; /* FIXME: is this a correct return value? */
break;
case 0x0006: /* Get selector base address */
TRACE("get selector base address (0x%04x)\n",BX_reg(context));
if (!(dw = GetSelectorBase( BX_reg(context) )))
{
EAX_reg(context) = 0x8022; /* invalid selector */
context->Eax = 0x8022; /* invalid selector */
SET_CFLAG(context);
}
else
@ -855,7 +854,7 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
entry.base = W32S_WINE2APP(entry.base, offset);
/* FIXME: should use ES:EDI for 32-bit clients */
LDT_EntryToBytes( PTR_SEG_OFF_TO_LIN( ES_reg(context),
LDT_EntryToBytes( PTR_SEG_OFF_TO_LIN( context->SegEs,
DI_reg(context) ), &entry );
}
break;
@ -864,7 +863,7 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
TRACE("set descriptor (0x%04x)\n",BX_reg(context));
{
ldt_entry entry;
LDT_BytesToEntry( PTR_SEG_OFF_TO_LIN( ES_reg(context),
LDT_BytesToEntry( PTR_SEG_OFF_TO_LIN( context->SegEs,
DI_reg(context) ), &entry );
entry.base = W32S_APP2WINE(entry.base, offset);
LDT_SetEntry( SELECTOR_TO_ENTRY( BX_reg(context) ), &entry );
@ -946,21 +945,21 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
AX_reg(context) = 0;
/* real mode: just point to the lret */
BX_reg(context) = DOSMEM_wrap_seg;
ECX_reg(context) = 2;
context->Ecx = 2;
/* protected mode: don't have any handler yet... */
FIXME("no protected-mode dummy state save/restore handler yet\n");
SI_reg(context) = 0;
EDI_reg(context) = 0;
context->Edi = 0;
break;
case 0x0306: /* Get Raw Mode Switch Addresses */
TRACE("get raw mode switch addresses\n");
/* real mode, point to standard DPMI return wrapper */
BX_reg(context) = DOSMEM_wrap_seg;
ECX_reg(context) = 0;
context->Ecx = 0;
/* protected mode, point to DPMI call wrapper */
SI_reg(context) = DOSMEM_dpmi_sel;
EDI_reg(context) = 8; /* offset of the INT 0x31 call */
context->Edi = 8; /* offset of the INT 0x31 call */
break;
case 0x0400: /* Get DPMI version */
TRACE("get DPMI version\n");
@ -981,7 +980,7 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
mmi.dwSize = sizeof(mmi);
MemManInfo16(&mmi);
ptr = (BYTE *)PTR_SEG_OFF_TO_LIN(ES_reg(context),DI_reg(context));
ptr = (BYTE *)PTR_SEG_OFF_TO_LIN(context->SegEs,DI_reg(context));
/* the layout is just the same as MEMMANINFO, but without
* the dwSize entry.
*/

View File

@ -722,9 +722,9 @@ else {
{
AL_reg(context) = 0x1b;
if (ISV86(context)) /* real */
ES_reg(context) = 0xf000;
context->SegEs = 0xf000;
else
ES_reg(context) = DOSMEM_BiosSysSeg;
context->SegEs = DOSMEM_BiosSysSeg;
BX_reg(context) = 0xe000;
}
break;
@ -736,7 +736,7 @@ else {
case 0x4f: /* Get SuperVGA INFORMATION */
{
BYTE *p =
CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EDI_reg(context));
CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edi);
/* BOOL16 vesa20 = (*(DWORD *)p == *(DWORD *)"VBE2"); */
TRACE("Get SuperVGA information\n");

View File

@ -118,7 +118,7 @@ void WINAPI INT_Int13Handler( CONTEXT86 *context )
CX_reg(context) = 0x4f24;
break;
}
ES_reg(context) = 0x0000; /* FIXME: drive parameter table */
context->SegEs = 0x0000; /* FIXME: drive parameter table */
DI_reg(context) = 0x0000;
#else
AH_reg(context) = 0x01;

View File

@ -49,9 +49,9 @@ void WINAPI INT_Int15Handler( CONTEXT86 *context )
case 0xc0: /* GET CONFIGURATION */
if (ISV86(context)) /* real */
ES_reg(context) = 0xf000;
context->SegEs = 0xf000;
else
ES_reg(context) = DOSMEM_BiosSysSeg;
context->SegEs = DOSMEM_BiosSysSeg;
BX_reg(context) = 0xe6f5;
AH_reg(context) = 0x0;
RESET_CFLAG(context);

View File

@ -198,7 +198,7 @@ static int INT21_GetDriveAllocInfo( CONTEXT86 *context )
if (!INT21_GetFreeDiskSpace( context )) return 0;
if (!heap && !INT21_CreateHeap()) return 0;
heap->mediaID = 0xf0;
DS_reg(context) = DosHeapHandle;
context->SegDs = DosHeapHandle;
BX_reg(context) = (int)&heap->mediaID - (int)heap;
return 1;
}
@ -247,7 +247,7 @@ static void GetDrivePB( CONTEXT86 *context, int drive )
if (FillInDrivePB( drive ))
{
AL_reg(context) = 0x00;
DS_reg(context) = SELECTOROF(dpbsegptr);
context->SegDs = SELECTOROF(dpbsegptr);
BX_reg(context) = OFFSETOF(dpbsegptr);
}
else
@ -288,7 +288,7 @@ static void ioctlGetDeviceInfo( CONTEXT86 *context )
static BOOL ioctlGenericBlkDevReq( CONTEXT86 *context )
{
BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
int drive = DOS_GET_DRIVE( BL_reg(context) );
if (!DRIVE_IsValid(drive))
@ -396,9 +396,9 @@ static BOOL ioctlGenericBlkDevReq( CONTEXT86 *context )
static void INT21_ParseFileNameIntoFCB( CONTEXT86 *context )
{
char *filename =
CTX_SEG_OFF_TO_LIN(context, DS_reg(context), ESI_reg(context) );
CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Esi );
char *fcb =
CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EDI_reg(context) );
CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edi );
char *buffer, *s, *d;
AL_reg(context) = 0xff; /* failed */
@ -466,8 +466,8 @@ char *INT21_DriveName(int drive)
}
static BOOL INT21_CreateFile( CONTEXT86 *context )
{
AX_reg(context) = _lcreat16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context) ), CX_reg(context) );
AX_reg(context) = _lcreat16( CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx ), CX_reg(context) );
return (AX_reg(context) == (WORD)HFILE_ERROR16);
}
@ -482,7 +482,7 @@ static HFILE16 _lcreat16_uniq( LPCSTR path, INT attr )
static void OpenExistingFile( CONTEXT86 *context )
{
AX_reg(context) = _lopen16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)),
AX_reg(context) = _lopen16( CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx),
AL_reg(context) );
if (AX_reg(context) == (WORD)HFILE_ERROR16)
{
@ -502,7 +502,7 @@ static BOOL INT21_ExtendedOpenCreateFile(CONTEXT86 *context )
/* BX,CX and DX should be preserved */
OpenExistingFile(context);
if ((EFL_reg(context) & 0x0001) == 0) /* File exists */
if ((context->EFlags & 0x0001) == 0) /* File exists */
{
UINT16 uReturnCX = 0;
@ -543,7 +543,7 @@ static BOOL INT21_ExtendedOpenCreateFile(CONTEXT86 *context )
DX_reg(context) = SI_reg(context);
bExtendedError = INT21_CreateFile(context);
if (EFL_reg(context) & 0x0001) /*no file open, flags set */
if (context->EFlags & 0x0001) /*no file open, flags set */
{
WARN("extended open/create: trunc failed\n");
return bExtendedError;
@ -572,7 +572,7 @@ static BOOL INT21_ExtendedOpenCreateFile(CONTEXT86 *context )
/* CX should still be the same */
DX_reg(context) = SI_reg(context);
bExtendedError = INT21_CreateFile(context);
if (EFL_reg(context) & 0x0001) /*no file open, flags set */
if (context->EFlags & 0x0001) /*no file open, flags set */
{
WARN("extended open/create: create failed\n");
return bExtendedError;
@ -588,7 +588,7 @@ static BOOL INT21_ExtendedOpenCreateFile(CONTEXT86 *context )
static BOOL INT21_ChangeDir( CONTEXT86 *context )
{
int drive;
char *dirname = CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context));
char *dirname = CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx);
TRACE("changedir %s\n", dirname);
if (dirname[0] && (dirname[1] == ':'))
@ -608,7 +608,7 @@ static int INT21_FindFirst( CONTEXT86 *context )
DOS_FULL_NAME full_name;
FINDFILE_DTA *dta = (FINDFILE_DTA *)GetCurrentDTA(context);
path = (const char *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
path = (const char *)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
dta->unixPath = NULL;
if (!DOSFS_GetFullName( path, FALSE, &full_name ))
{
@ -681,7 +681,7 @@ static int INT21_FindNext( CONTEXT86 *context )
static BOOL INT21_CreateTempFile( CONTEXT86 *context )
{
static int counter = 0;
char *name = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context) );
char *name = CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx );
char *p = name + strlen(name);
/* despite what Ralf Brown says, some programs seem to call without
@ -706,7 +706,7 @@ static BOOL INT21_CreateTempFile( CONTEXT86 *context )
static BOOL INT21_GetCurrentDirectory( CONTEXT86 *context )
{
int drive = DOS_GET_DRIVE( DL_reg(context) );
char *ptr = (char *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), ESI_reg(context) );
char *ptr = (char *)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Esi );
if (!DRIVE_IsValid(drive))
{
@ -723,7 +723,7 @@ static void INT21_GetDBCSLeadTable( CONTEXT86 *context )
{
if (heap || INT21_CreateHeap())
{ /* return an empty table just as DOS 4.0+ does */
DS_reg(context) = DosHeapHandle;
context->SegDs = DosHeapHandle;
SI_reg(context) = (int)&heap->DummyDBCSLeadTable - (int)heap;
}
else
@ -736,7 +736,7 @@ static void INT21_GetDBCSLeadTable( CONTEXT86 *context )
static int INT21_GetDiskSerialNumber( CONTEXT86 *context )
{
BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
int drive = DOS_GET_DRIVE( BL_reg(context) );
if (!DRIVE_IsValid(drive))
@ -755,7 +755,7 @@ static int INT21_GetDiskSerialNumber( CONTEXT86 *context )
static int INT21_SetDiskSerialNumber( CONTEXT86 *context )
{
BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
int drive = DOS_GET_DRIVE( BL_reg(context) );
if (!DRIVE_IsValid(drive))
@ -774,7 +774,7 @@ static int INT21_SetDiskSerialNumber( CONTEXT86 *context )
static int INT21_FindFirstFCB( CONTEXT86 *context )
{
BYTE *fcb = (BYTE *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
BYTE *fcb = (BYTE *)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
FINDFILE_FCB *pFCB;
LPCSTR root, cwd;
int drive;
@ -798,7 +798,7 @@ static int INT21_FindFirstFCB( CONTEXT86 *context )
static int INT21_FindNextFCB( CONTEXT86 *context )
{
BYTE *fcb = (BYTE *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
BYTE *fcb = (BYTE *)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
FINDFILE_FCB *pFCB;
DOS_DIRENTRY_LAYOUT *pResult = (DOS_DIRENTRY_LAYOUT *)GetCurrentDTA(context);
WIN32_FIND_DATAA entry;
@ -920,7 +920,7 @@ INT21_networkfunc (CONTEXT86 *context)
switch (AL_reg(context)) {
case 0x00: /* Get machine name. */
{
char *dst = CTX_SEG_OFF_TO_LIN (context,DS_reg(context),EDX_reg(context));
char *dst = CTX_SEG_OFF_TO_LIN (context,context->SegDs,context->Edx);
TRACE("getting machine name to %p\n", dst);
if (gethostname (dst, 15))
{
@ -1091,8 +1091,8 @@ void WINAPI DOS3Call( CONTEXT86 *context )
"SI=%04x DI=%04x DS=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context), DX_reg(context),
SI_reg(context), DI_reg(context),
(WORD)DS_reg(context), (WORD)ES_reg(context),
EFL_reg(context) );
(WORD)context->SegDs, (WORD)context->SegEs,
context->EFlags );
if (AH_reg(context) == 0x59) /* Get extended error info */
@ -1196,9 +1196,9 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x09: /* WRITE STRING TO STANDARD OUTPUT */
TRACE("WRITE '$'-terminated string from %04lX:%04X to stdout\n",
DS_reg(context),DX_reg(context) );
context->SegDs,DX_reg(context) );
{
LPSTR data = CTX_SEG_OFF_TO_LIN(context,DS_reg(context),EDX_reg(context));
LPSTR data = CTX_SEG_OFF_TO_LIN(context,context->SegDs,context->Edx);
LPSTR p = data;
/* do NOT use strchr() to calculate the string length,
as '\0' is valid string content, too !
@ -1211,8 +1211,8 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x0a: /* BUFFERED INPUT */
{
char *buffer = ((char *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context) ));
char *buffer = ((char *)CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx ));
int res;
TRACE("BUFFERED INPUT (size=%d)\n",buffer[0]);
@ -1264,7 +1264,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x11: /* FIND FIRST MATCHING FILE USING FCB */
TRACE("FIND FIRST MATCHING FILE USING FCB %p\n",
CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
if (!INT21_FindFirstFCB(context))
{
AL_reg(context) = 0xff;
@ -1291,7 +1291,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x1a: /* SET DISK TRANSFER AREA ADDRESS */
{
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
pTask->dta = PTR_SEG_OFF_TO_SEGPTR(DS_reg(context),DX_reg(context));
pTask->dta = PTR_SEG_OFF_TO_SEGPTR(context->SegDs,DX_reg(context));
TRACE("Set DTA: %08lx\n", pTask->dta);
}
break;
@ -1311,7 +1311,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x25: /* SET INTERRUPT VECTOR */
INT_CtxSetHandler( context, AL_reg(context),
(FARPROC16)PTR_SEG_OFF_TO_SEGPTR( DS_reg(context),
(FARPROC16)PTR_SEG_OFF_TO_SEGPTR( context->SegDs,
DX_reg(context)));
break;
@ -1344,7 +1344,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
TRACE("GET DISK TRANSFER AREA ADDRESS\n");
{
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
ES_reg(context) = SELECTOROF( pTask->dta );
context->SegEs = SELECTOROF( pTask->dta );
BX_reg(context) = OFFSETOF( pTask->dta );
}
break;
@ -1423,7 +1423,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x34: /* GET ADDRESS OF INDOS FLAG */
TRACE("GET ADDRESS OF INDOS FLAG\n");
if (!heap) INT21_CreateHeap();
ES_reg(context) = DosHeapHandle;
context->SegEs = DosHeapHandle;
BX_reg(context) = (int)&heap->InDosFlag - (int)heap;
break;
@ -1431,7 +1431,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
TRACE("GET INTERRUPT VECTOR 0x%02x\n",AL_reg(context));
{
FARPROC16 addr = INT_CtxGetHandler( context, AL_reg(context) );
ES_reg(context) = SELECTOROF(addr);
context->SegEs = SELECTOROF(addr);
BX_reg(context) = OFFSETOF(addr);
}
break;
@ -1473,9 +1473,9 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x39: /* "MKDIR" - CREATE SUBDIRECTORY */
TRACE("MKDIR %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
bSetDOSExtendedError = (!CreateDirectory16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context) ), NULL));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
bSetDOSExtendedError = (!CreateDirectory16( CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx ), NULL));
/* FIXME: CreateDirectory's LastErrors will clash with the ones
* used by dos. AH=39 only returns 3 (path not found) and 5 (access
* denied), while CreateDirectory return several ones. remap some of
@ -1495,26 +1495,26 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x3a: /* "RMDIR" - REMOVE SUBDIRECTORY */
TRACE("RMDIR %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
bSetDOSExtendedError = (!RemoveDirectory16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context) )));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
bSetDOSExtendedError = (!RemoveDirectory16( CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx )));
break;
case 0x3b: /* "CHDIR" - SET CURRENT DIRECTORY */
TRACE("CHDIR %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
bSetDOSExtendedError = !INT21_ChangeDir(context);
break;
case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */
TRACE("CREAT flag 0x%02x %s\n",CX_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
bSetDOSExtendedError = INT21_CreateFile( context );
break;
case 0x3d: /* "OPEN" - OPEN EXISTING FILE */
TRACE("OPEN mode 0x%02x %s\n",AL_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
OpenExistingFile(context);
break;
@ -1525,18 +1525,18 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x3f: /* "READ" - READ FROM FILE OR DEVICE */
TRACE("READ from %d to %04lX:%04X for %d byte\n",BX_reg(context),
DS_reg(context),DX_reg(context),CX_reg(context) );
context->SegDs,DX_reg(context),CX_reg(context) );
{
LONG result;
if (ISV86(context))
result = _hread16( BX_reg(context),
CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context) ),
CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx ),
CX_reg(context) );
else
result = WIN16_hread( BX_reg(context),
PTR_SEG_OFF_TO_SEGPTR( DS_reg(context),
EDX_reg(context) ),
PTR_SEG_OFF_TO_SEGPTR( context->SegDs,
context->Edx ),
CX_reg(context) );
if (result == -1) bSetDOSExtendedError = TRUE;
else AX_reg(context) = (WORD)result;
@ -1545,11 +1545,11 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x40: /* "WRITE" - WRITE TO FILE OR DEVICE */
TRACE("WRITE from %04lX:%04X to handle %d for %d byte\n",
DS_reg(context),DX_reg(context),BX_reg(context),CX_reg(context) );
context->SegDs,DX_reg(context),BX_reg(context),CX_reg(context) );
{
LONG result = _hwrite16( BX_reg(context),
CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context) ),
CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx ),
CX_reg(context) );
if (result == -1) bSetDOSExtendedError = TRUE;
else AX_reg(context) = (WORD)result;
@ -1558,9 +1558,9 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x41: /* "UNLINK" - DELETE FILE */
TRACE("UNLINK %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
bSetDOSExtendedError = (!DeleteFileA( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context) )));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
bSetDOSExtendedError = (!DeleteFileA( CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx )));
break;
case 0x42: /* "LSEEK" - SET CURRENT FILE POSITION */
@ -1586,25 +1586,25 @@ void WINAPI DOS3Call( CONTEXT86 *context )
{
case 0x00:
TRACE("GET FILE ATTRIBUTES for %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
AX_reg(context) = (WORD)GetFileAttributesA(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context)));
CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx));
if (AX_reg(context) == 0xffff) bSetDOSExtendedError = TRUE;
else CX_reg(context) = AX_reg(context);
break;
case 0x01:
TRACE("SET FILE ATTRIBUTES 0x%02x for %s\n", CX_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
bSetDOSExtendedError =
(!SetFileAttributesA( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context)),
(!SetFileAttributesA( CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx),
CX_reg(context) ));
break;
case 0x02:
FIXME("GET COMPRESSED FILE SIZE for %s stub\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
}
break;
@ -1627,7 +1627,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
break;
}
case 0x05:{ /* IOCTL - WRITE TO BLOCK DEVICE CONTROL CHANNEL */
/*BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context));*/
/*BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx);*/
int drive = DOS_GET_DRIVE(BL_reg(context));
FIXME("program tried to write to block device control channel of drive %d:\n",drive);
@ -1786,16 +1786,16 @@ void WINAPI DOS3Call( CONTEXT86 *context )
break;
case 0x49: /* FREE MEMORY */
TRACE("FREE MEMORY segment %04lX\n", ES_reg(context));
TRACE("FREE MEMORY segment %04lX\n", context->SegEs);
{
BOOL ret;
if (ISV86(context))
ret= DOSMEM_FreeBlock(DOSMEM_MapDosToLinear(ES_reg(context)<<4));
ret= DOSMEM_FreeBlock(DOSMEM_MapDosToLinear(context->SegEs<<4));
else
{
ret = !GlobalDOSFree16(ES_reg(context));
ret = !GlobalDOSFree16(context->SegEs);
/* If we don't reset ES_reg, we will fail in the relay code */
ES_reg(context)=ret;
context->SegEs=ret;
}
if (!ret)
{
@ -1807,11 +1807,11 @@ void WINAPI DOS3Call( CONTEXT86 *context )
break;
case 0x4a: /* RESIZE MEMORY BLOCK */
TRACE("RESIZE MEMORY segment %04lX to %d paragraphs\n", ES_reg(context), BX_reg(context));
TRACE("RESIZE MEMORY segment %04lX to %d paragraphs\n", context->SegEs, BX_reg(context));
if (!ISV86(context))
FIXME("RESIZE MEMORY probably insufficient implementation. Expect crash soon\n");
{
LPVOID *mem = DOSMEM_ResizeBlock(DOSMEM_MapDosToLinear(ES_reg(context)<<4),
LPVOID *mem = DOSMEM_ResizeBlock(DOSMEM_MapDosToLinear(context->SegEs<<4),
BX_reg(context)<<4,NULL);
if (mem)
AX_reg(context) = DOSMEM_MapLinearToDos(mem)>>4;
@ -1825,9 +1825,9 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x4b: /* "EXEC" - LOAD AND/OR EXECUTE PROGRAM */
TRACE("EXEC %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context) ));
AX_reg(context) = WinExec16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context) ),
(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);
break;
@ -1844,7 +1844,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x4e: /* "FINDFIRST" - FIND FIRST MATCHING FILE */
TRACE("FINDFIRST mask 0x%04x spec %s\n",CX_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
if (!INT21_FindFirst(context)) break;
/* fall through */
@ -1878,7 +1878,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x52: /* "SYSVARS" - GET LIST OF LISTS */
TRACE("SYSVARS - GET LIST OF LISTS\n");
{
ES_reg(context) = ISV86(context) ? HIWORD(DOS_LOLSeg) : LOWORD(DOS_LOLSeg);
context->SegEs = ISV86(context) ? HIWORD(DOS_LOLSeg) : LOWORD(DOS_LOLSeg);
BX_reg(context) = FIELD_OFFSET(DOS_LISTOFLISTS, ptr_first_DPB);
}
break;
@ -1890,11 +1890,11 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x56: /* "RENAME" - RENAME FILE */
TRACE("RENAME %s to %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, ES_reg(context),EDI_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegEs,context->Edi));
bSetDOSExtendedError =
(!MoveFileA( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)),
CTX_SEG_OFF_TO_LIN(context, ES_reg(context),EDI_reg(context))));
(!MoveFileA( CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx),
CTX_SEG_OFF_TO_LIN(context, context->SegEs,context->Edi)));
break;
case 0x57: /* FILE DATE AND TIME */
@ -1952,9 +1952,9 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x5b: /* CREATE NEW FILE */
TRACE("CREATE NEW FILE 0x%02x for %s\n", CX_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
bSetDOSExtendedError = ((AX_reg(context) =
_lcreat16_uniq( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)),
_lcreat16_uniq( CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx),
CX_reg(context) )) == (WORD)HFILE_ERROR16);
break;
@ -2001,12 +2001,12 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x60: /* "TRUENAME" - CANONICALIZE FILENAME OR PATH */
TRACE("TRUENAME %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),ESI_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Esi));
{
if (!GetFullPathNameA( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
ESI_reg(context)), 128,
CTX_SEG_OFF_TO_LIN(context, ES_reg(context),
EDI_reg(context)),NULL))
if (!GetFullPathNameA( CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Esi), 128,
CTX_SEG_OFF_TO_LIN(context, context->SegEs,
context->Edi),NULL))
bSetDOSExtendedError = TRUE;
else AX_reg(context) = 0;
}
@ -2026,7 +2026,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
break;
case 0x65:{/* GET EXTENDED COUNTRY INFORMATION */
BYTE *dataptr=CTX_SEG_OFF_TO_LIN(context, ES_reg(context),EDI_reg(context));
BYTE *dataptr=CTX_SEG_OFF_TO_LIN(context, context->SegEs,context->Edi);
TRACE("GET EXTENDED COUNTRY INFORMATION code page %d country %d\n",
BX_reg(context), DX_reg(context));
switch (AL_reg(context)) {
@ -2051,14 +2051,14 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x21:
TRACE("\tconvert string to uppercase with length\n");
{
char *ptr = (char *)CTX_SEG_OFF_TO_LIN(context,DS_reg(context),EDX_reg(context));
char *ptr = (char *)CTX_SEG_OFF_TO_LIN(context,context->SegDs,context->Edx);
WORD len = CX_reg(context);
while (len--) { *ptr = toupper(*ptr); ptr++; }
}
break;
case 0x22:
TRACE("\tConvert ASCIIZ string to uppercase\n");
_strupr( (LPSTR)CTX_SEG_OFF_TO_LIN(context,DS_reg(context),EDX_reg(context)) );
_strupr( (LPSTR)CTX_SEG_OFF_TO_LIN(context,context->SegDs,context->Edx) );
break;
default:
TRACE("\tunimplemented function %d\n",AL_reg(context));
@ -2118,7 +2118,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x6C: /* Extended Open/Create*/
TRACE("EXTENDED OPEN/CREATE %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDI_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edi));
bSetDOSExtendedError = INT21_ExtendedOpenCreateFile(context);
break;
@ -2133,10 +2133,10 @@ void WINAPI DOS3Call( CONTEXT86 *context )
{
case 0x39: /* Create directory */
TRACE("LONG FILENAME - MAKE DIRECTORY %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx));
bSetDOSExtendedError = (!CreateDirectoryA(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context) ), NULL));
CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx ), NULL));
/* FIXME: CreateDirectory's LastErrors will clash with the ones
* used by dos. AH=39 only returns 3 (path not found) and 5 (access
* denied), while CreateDirectory return several ones. remap some of
@ -2155,28 +2155,28 @@ void WINAPI DOS3Call( CONTEXT86 *context )
break;
case 0x3a: /* Remove directory */
TRACE("LONG FILENAME - REMOVE DIRECTORY %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx));
bSetDOSExtendedError = (!RemoveDirectoryA(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context) )));
CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx )));
break;
case 0x43: /* Get/Set file attributes */
TRACE("LONG FILENAME -EXTENDED GET/SET FILE ATTRIBUTES %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx));
switch (BL_reg(context))
{
case 0x00: /* Get file attributes */
TRACE("\tretrieve attributes\n");
CX_reg(context) = (WORD)GetFileAttributesA(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context)));
CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx));
if (CX_reg(context) == 0xffff) bSetDOSExtendedError = TRUE;
break;
case 0x01:
TRACE("\tset attributes 0x%04x\n",CX_reg(context));
bSetDOSExtendedError = (!SetFileAttributesA(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
EDX_reg(context)),
CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx),
CX_reg(context) ) );
break;
default:
@ -2195,12 +2195,12 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x4e: /* Find first file */
TRACE(" LONG FILENAME - FIND FIRST MATCHING FILE for %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx));
/* FIXME: use attributes in CX */
if ((AX_reg(context) = FindFirstFile16(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)),
(WIN32_FIND_DATAA *)CTX_SEG_OFF_TO_LIN(context, ES_reg(context),
EDI_reg(context))))
CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx),
(WIN32_FIND_DATAA *)CTX_SEG_OFF_TO_LIN(context, context->SegEs,
context->Edi)))
== INVALID_HANDLE_VALUE16)
bSetDOSExtendedError = TRUE;
break;
@ -2208,14 +2208,14 @@ void WINAPI DOS3Call( CONTEXT86 *context )
TRACE("LONG FILENAME - FIND NEXT MATCHING FILE for handle %d\n",
BX_reg(context));
if (!FindNextFile16( BX_reg(context),
(WIN32_FIND_DATAA *)CTX_SEG_OFF_TO_LIN(context, ES_reg(context),
EDI_reg(context))))
(WIN32_FIND_DATAA *)CTX_SEG_OFF_TO_LIN(context, context->SegEs,
context->Edi)))
bSetDOSExtendedError = TRUE;
break;
case 0xa0:
{
LPCSTR driveroot = (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context));
LPSTR buffer = (LPSTR)CTX_SEG_OFF_TO_LIN(context, ES_reg(context),EDI_reg(context));
LPCSTR driveroot = (LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx);
LPSTR buffer = (LPSTR)CTX_SEG_OFF_TO_LIN(context, context->SegEs,context->Edi);
int drive;
UINT flags;
@ -2259,19 +2259,19 @@ void WINAPI DOS3Call( CONTEXT86 *context )
{
case 0x01: /*Get short filename or path */
if (!GetShortPathNameA
( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
ESI_reg(context)),
CTX_SEG_OFF_TO_LIN(context, ES_reg(context),
EDI_reg(context)), 67))
( CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Esi),
CTX_SEG_OFF_TO_LIN(context, context->SegEs,
context->Edi), 67))
bSetDOSExtendedError = TRUE;
else AX_reg(context) = 0;
break;
case 0x02: /*Get canonical long filename or path */
if (!GetFullPathNameA
( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
ESI_reg(context)), 128,
CTX_SEG_OFF_TO_LIN(context, ES_reg(context),
EDI_reg(context)),NULL))
( CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Esi), 128,
CTX_SEG_OFF_TO_LIN(context, context->SegEs,
context->Edi),NULL))
bSetDOSExtendedError = TRUE;
else AX_reg(context) = 0;
break;
@ -2285,17 +2285,17 @@ void WINAPI DOS3Call( CONTEXT86 *context )
break;
case 0x6c: /* Create or open file */
TRACE("LONG FILENAME - CREATE OR OPEN FILE %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), ESI_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Esi));
/* translate Dos 7 action to Dos 6 action */
bSetDOSExtendedError = INT21_ExtendedOpenCreateFile(context);
break;
case 0x3b: /* Change directory */
TRACE("LONG FILENAME - CHANGE DIRECTORY %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
if (!SetCurrentDirectoryA(CTX_SEG_OFF_TO_LIN(context,
DS_reg(context),
EDX_reg(context)
context->SegDs,
context->Edx
))
) {
SET_CFLAG(context);
@ -2304,10 +2304,10 @@ void WINAPI DOS3Call( CONTEXT86 *context )
break;
case 0x41: /* Delete file */
TRACE("LONG FILENAME - DELETE FILE %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
if (!DeleteFileA(CTX_SEG_OFF_TO_LIN(context,
DS_reg(context),
EDX_reg(context))
context->SegDs,
context->Edx)
)) {
SET_CFLAG(context);
AL_reg(context) = GetLastError();
@ -2315,8 +2315,8 @@ void WINAPI DOS3Call( CONTEXT86 *context )
break;
case 0x56: /* Move (rename) file */
FIXME("LONG FILENAME - RENAME FILE %s to %s stub\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EDI_reg(context)));
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edi));
default:
FIXME("Unimplemented long file name function:\n");
INT_BARF( context, 0x21 );
@ -2349,15 +2349,15 @@ void WINAPI DOS3Call( CONTEXT86 *context )
DWORD cluster_sectors, sector_bytes, free_clusters, total_clusters;
char root[] = "A:\\";
buffer = (WORD *)CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EDI_reg(context));
buffer = (WORD *)CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Edi);
TRACE("Get Extended DPB: linear buffer address is %p\n", buffer);
/* validate passed-in buffer lengths */
if ((*buffer != 0x3d) || (ECX_reg(context) != 0x3f))
if ((*buffer != 0x3d) || (context->Ecx != 0x3f))
{
WARN("Get Extended DPB: buffer lengths incorrect\n");
WARN("CX = %lx, buffer[0] = %x\n", ECX_reg(context), *buffer);
WARN("CX = %lx, buffer[0] = %x\n", context->Ecx, *buffer);
SET_CFLAG(context);
AL_reg(context) = 0x18; /* bad buffer length */
}
@ -2431,15 +2431,15 @@ void WINAPI DOS3Call( CONTEXT86 *context )
SET_CFLAG(context);
}
if ((EFL_reg(context) & 0x0001))
if ((context->EFlags & 0x0001))
TRACE("failed, error 0x%04lx\n", GetLastError() );
TRACE("returning: AX=%04x BX=%04x CX=%04x DX=%04x "
"SI=%04x DI=%04x DS=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
(WORD)DS_reg(context), (WORD)ES_reg(context),
EFL_reg(context));
(WORD)context->SegDs, (WORD)context->SegEs,
context->EFlags);
}
/***********************************************************************

View File

@ -22,17 +22,17 @@ DEFAULT_DEBUG_CHANNEL(int)
*/
void WINAPI INT_Int25Handler( CONTEXT86 *context )
{
BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EBX_reg(context) );
BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx );
DWORD begin, length;
if (!DRIVE_IsValid(AL_reg(context)))
if (!DRIVE_IsValid(LOBYTE(context->Eax)))
{
SET_CFLAG(context);
AX_reg(context) = 0x0201; /* unknown unit */
return;
}
if (CX_reg(context) == 0xffff)
if (LOWORD(context->Ecx) == 0xffff)
{
begin = *(DWORD *)dataptr;
length = *(WORD *)(dataptr + 4);
@ -41,14 +41,14 @@ void WINAPI INT_Int25Handler( CONTEXT86 *context )
}
else
{
begin = DX_reg(context);
length = CX_reg(context);
begin = LOWORD(context->Edx);
length = LOWORD(context->Ecx);
}
TRACE("int25: abs diskread, drive %d, sector %ld, "
"count %ld, buffer %p\n",
AL_reg(context), begin, length, dataptr);
LOBYTE(context->Eax), begin, length, dataptr);
DRIVE_RawRead(AL_reg(context), begin, length, dataptr, TRUE);
DRIVE_RawRead(LOBYTE(context->Eax), begin, length, dataptr, TRUE);
RESET_CFLAG(context);
}

View File

@ -20,17 +20,17 @@ DEFAULT_DEBUG_CHANNEL(int)
*/
void WINAPI INT_Int26Handler( CONTEXT86 *context )
{
BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EBX_reg(context) );
BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Ebx );
DWORD begin, length;
if (!DRIVE_IsValid(AL_reg(context)))
if (!DRIVE_IsValid(LOBYTE(context->Eax)))
{
SET_CFLAG(context);
AX_reg(context) = 0x0201; /* unknown unit */
return;
}
if (CX_reg(context) == 0xffff)
if (LOWORD(context->Ecx) == 0xffff)
{
begin = *(DWORD *)dataptr;
length = *(WORD *)(dataptr + 4);
@ -39,14 +39,14 @@ void WINAPI INT_Int26Handler( CONTEXT86 *context )
}
else
{
begin = DX_reg(context);
length = CX_reg(context);
begin = LOWORD(context->Edx);
length = LOWORD(context->Ecx);
}
TRACE("int26: abs diskwrite, drive %d, sector %ld, "
"count %ld, buffer %p\n",
AL_reg(context), begin, length, dataptr );
DRIVE_RawWrite(AL_reg(context), begin, length, dataptr, TRUE);
DRIVE_RawWrite(LOBYTE(context->Eax), begin, length, dataptr, TRUE);
RESET_CFLAG(context);
}

View File

@ -43,7 +43,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
break;
case 0x11: /* Network Redirector / IFSFUNC */
switch (AL_reg(context))
switch (LOBYTE(context->Eax))
{
case 0x00: /* Install check */
/* not installed */
@ -58,7 +58,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
break;
case 0x12:
switch (AL_reg(context))
switch (LOBYTE(context->Eax))
{
case 0x2e: /* get or set DOS error table address */
switch (DL_reg(context))
@ -78,7 +78,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
case 0x02:
case 0x04:
case 0x06:
ES_reg(context) = 0x0001;
context->SegEs = 0x0001;
DI_reg(context) = 0x0000;
break;
case 0x08:
@ -107,7 +107,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
case 0x43:
#if 1
switch (AL_reg(context))
switch (LOBYTE(context->Eax))
{
case 0x00: /* XMS v2+ installation check */
WARN("XMS is not fully implemented\n");
@ -115,7 +115,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
break;
case 0x10: /* XMS v2+ get driver address */
{
ES_reg(context) = DOSMEM_xms_seg;
context->SegEs = DOSMEM_xms_seg;
BX_reg(context) = 0;
break;
}
@ -129,7 +129,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
break;
case 0x45:
switch (AL_reg(context))
switch (LOBYTE(context->Eax))
{
case 0x00:
case 0x01:
@ -148,7 +148,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
break;
case 0x4a:
switch(AL_reg(context))
switch(LOBYTE(context->Eax))
{
case 0x10: /* smartdrv */
break; /* not installed */
@ -163,7 +163,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
}
break;
case 0x4b:
switch(AL_reg(context))
switch(LOBYTE(context->Eax))
{
case 0x01:
case 0x02:
@ -177,7 +177,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
}
break;
case 0x56: /* INTERLNK */
switch(AL_reg(context))
switch(LOBYTE(context->Eax))
{
case 0x01: /* check if redirected drive */
AL_reg(context) = 0; /* not redirected */
@ -187,7 +187,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
}
break;
case 0x7a: /* NOVELL NetWare */
switch (AL_reg(context))
switch (LOBYTE(context->Eax))
{
case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
AL_reg(context) = 0;
@ -201,10 +201,10 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
}
break;
case 0xb7: /* append */
AL_reg(context) = 0; /* not installed */
LOBYTE(context->Eax) = 0; /* not installed */
break;
case 0xb8: /* network */
switch (AL_reg(context))
switch (LOBYTE(context->Eax))
{
case 0x00: /* Install check */
/* not installed */
@ -218,7 +218,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
AX_reg(context) = 0xa5a5; /* pretend to have Novell IPX installed */
break;
case 0xbf: /* REDIRIFS.EXE */
switch (AL_reg(context))
switch (LOBYTE(context->Eax))
{
case 0x00: /* Install check */
/* not installed */
@ -229,7 +229,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
}
break;
case 0xd2:
switch(AL_reg(context))
switch(LOBYTE(context->Eax))
{
case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
if(BX_reg(context) == 0x5145 && CX_reg(context) == 0x4D4D
@ -242,7 +242,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
}
break;
case 0xd7: /* Banyan Vines */
switch (AL_reg(context))
switch (LOBYTE(context->Eax))
{
case 0x01: /* Install check - Get Int Number */
/* not installed */
@ -253,7 +253,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
}
break;
case 0xde:
switch(AL_reg(context))
switch(LOBYTE(context->Eax))
{
case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
if(BX_reg(context) == 0x4450 && CX_reg(context) == 0x4d49
@ -281,7 +281,7 @@ static void do_int2f_16( CONTEXT86 *context )
{
DWORD addr;
switch(AL_reg(context))
switch(LOBYTE(context->Eax))
{
case 0x00: /* Windows enhanced mode installation check */
AX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ?
@ -333,7 +333,7 @@ static void do_int2f_16( CONTEXT86 *context )
ERR("Accessing unknown VxD %04x - Expect a failure now.\n",
BX_reg(context) );
}
ES_reg(context) = SELECTOROF(addr);
context->SegEs = SELECTOROF(addr);
DI_reg(context) = OFFSETOF(addr);
break;
@ -353,7 +353,7 @@ static void do_int2f_16( CONTEXT86 *context )
CL_reg(context) = si.wProcessorLevel;
DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
SI_reg(context) = 0; /* # of para. of DOS extended private data */
ES_reg(context) = DOSMEM_dpmi_seg;
context->SegEs = DOSMEM_dpmi_seg;
DI_reg(context) = 0; /* ES:DI is DPMI switch entry point */
break;
}
@ -429,7 +429,7 @@ static void MSCDEX_Handler(CONTEXT86* context)
int drive, count;
char* p;
switch(AL_reg(context)) {
switch(LOBYTE(context->Eax)) {
case 0x00: /* Installation check */
/* Count the number of contiguous CDROM drives
*/
@ -455,7 +455,7 @@ static void MSCDEX_Handler(CONTEXT86* context)
break;
case 0x0D: /* get drive letters */
p = CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EBX_reg(context));
p = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx);
memset(p, 0, MAX_DOS_DRIVES);
for (drive = 0; drive < MAX_DOS_DRIVES; drive++) {
if (DRIVE_GetType(drive) == TYPE_CDROM) *p++ = drive;
@ -477,7 +477,7 @@ static void MSCDEX_Handler(CONTEXT86* context)
/* FIXME - to be deleted ?? */
ERR("ES:BX==0 ! SEGFAULT ?\n");
ERR("-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
BX_reg(context), ES_reg(context), DS_reg(context), CX_reg(context));
BX_reg(context), context->SegEs, context->SegDs, CX_reg(context));
driver_request[4] |= 0x80;
driver_request[3] = 5; /* bad request length */
return;
@ -800,7 +800,7 @@ static void MSCDEX_Handler(CONTEXT86* context)
}
break;
default:
FIXME("Unimplemented MSCDEX function 0x%02X.\n", AL_reg(context));
FIXME("Unimplemented MSCDEX function 0x%02X.\n", LOBYTE(context->Eax));
break;
}
}

View File

@ -27,7 +27,7 @@ static struct
*/
void WINAPI INT_Int33Handler( CONTEXT86 *context )
{
switch (AX_reg(context)) {
switch (LOWORD(context->Eax)) {
case 0x00:
TRACE("Reset mouse driver and request status\n");
AX_reg(context) = 0xFFFF; /* installed */
@ -64,7 +64,7 @@ void WINAPI INT_Int33Handler( CONTEXT86 *context )
case 0x0C:
TRACE("Define mouse interrupt subroutine\n");
mouse_info.callmask = CX_reg(context);
mouse_info.callback = (FARPROC16)PTR_SEG_OFF_TO_SEGPTR(ES_reg(context), DX_reg(context));
mouse_info.callback = (FARPROC16)PTR_SEG_OFF_TO_SEGPTR(context->SegEs, LOWORD(context->Edx));
break;
case 0x10:
FIXME("Define screen region for update\n");
@ -84,14 +84,14 @@ static void MouseRelay(CONTEXT86 *context,void *mdata)
MCALLDATA *data = (MCALLDATA *)mdata;
CONTEXT86 ctx = *context;
EAX_reg(&ctx) = data->mask;
EBX_reg(&ctx) = data->but;
ECX_reg(&ctx) = data->x;
EDX_reg(&ctx) = data->y;
ESI_reg(&ctx) = data->mx;
EDI_reg(&ctx) = data->my;
CS_reg(&ctx) = SELECTOROF(data->proc);
EIP_reg(&ctx) = OFFSETOF(data->proc);
ctx.Eax = data->mask;
ctx.Ebx = data->but;
ctx.Ecx = data->x;
ctx.Edx = data->y;
ctx.Esi = data->mx;
ctx.Edi = data->my;
ctx.SegCs = SELECTOROF(data->proc);
ctx.Eip = OFFSETOF(data->proc);
free(data);
DPMI_CallRMProc(&ctx, NULL, 0, 0);
}

View File

@ -19,7 +19,7 @@ DEFAULT_DEBUG_CHANNEL(int)
void WINAPI NetBIOSCall16( CONTEXT86 *context )
{
BYTE* ptr;
ptr = (BYTE*) PTR_SEG_OFF_TO_LIN(ES_reg(context),BX_reg(context));
ptr = (BYTE*) PTR_SEG_OFF_TO_LIN(context->SegEs,BX_reg(context));
FIXME("(%p): command code %02x (ignored)\n",context, *ptr);
AL_reg(context) = *(ptr+0x01) = 0xFB; /* NetBIOS emulator not found */
}

View File

@ -32,7 +32,7 @@ DEFAULT_DEBUG_CHANNEL(vxd)
"SI %04x, DI %04x, DS %04x, ES %04x\n", \
(name), (name), AX_reg(context), BX_reg(context), \
CX_reg(context), DX_reg(context), SI_reg(context), \
DI_reg(context), (WORD)DS_reg(context), (WORD)ES_reg(context) )
DI_reg(context), (WORD)context->SegDs, (WORD)context->SegEs )
static WORD VXD_WinVersion(void)
@ -90,7 +90,7 @@ void WINAPI VXD_PageFile( CONTEXT86 *context )
case 0x01: /* get swap file info */
TRACE("VxD PageFile: returning swap file info\n");
AX_reg(context) = 0x00; /* paging disabled */
ECX_reg(context) = 0; /* maximum size of paging file */
context->Ecx = 0; /* maximum size of paging file */
/* FIXME: do I touch DS:SI or DS:DI? */
RESET_CFLAG(context);
break;
@ -197,16 +197,16 @@ void WINAPI VXD_VXDLoader( CONTEXT86 *context )
case 0x0001: /* load device */
FIXME("load device %04lx:%04x (%s)\n",
DS_reg(context), DX_reg(context),
debugstr_a(PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context))));
context->SegDs, DX_reg(context),
debugstr_a(PTR_SEG_OFF_TO_LIN(context->SegDs, DX_reg(context))));
AX_reg(context) = 0x0000;
ES_reg(context) = 0x0000;
context->SegEs = 0x0000;
DI_reg(context) = 0x0000;
RESET_CFLAG(context);
break;
case 0x0002: /* unload device */
FIXME("unload device (%08lx)\n", EBX_reg(context));
FIXME("unload device (%08lx)\n", context->Ebx);
AX_reg(context) = 0x0000;
RESET_CFLAG(context);
break;
@ -233,7 +233,7 @@ void WINAPI VXD_Shell( CONTEXT86 *context )
case 0x0000:
TRACE("returning version\n");
AX_reg(context) = VXD_WinVersion();
EBX_reg(context) = 1; /* system VM Handle */
context->Ebx = 1; /* system VM Handle */
break;
case 0x0001:
@ -300,8 +300,7 @@ void WINAPI VXD_Shell( CONTEXT86 *context )
break;
case 0x0106: /* install timeout callback */
TRACE("VxD Shell: ignoring shell callback (%ld sec.)\n",
EBX_reg( context ) );
TRACE("VxD Shell: ignoring shell callback (%ld sec.)\n", context->Ebx);
SET_CFLAG(context);
break;
@ -355,15 +354,15 @@ void WINAPI VXD_Timer( CONTEXT86 *context )
break;
case 0x0100: /* clock tick time, in 840nsecs */
EAX_reg(context) = GetTickCount();
context->Eax = GetTickCount();
EDX_reg(context) = EAX_reg(context) >> 22;
EAX_reg(context) <<= 10; /* not very precise */
context->Edx = context->Eax >> 22;
context->Eax <<= 10; /* not very precise */
break;
case 0x0101: /* current Windows time, msecs */
case 0x0102: /* current VM time, msecs */
EAX_reg(context) = GetTickCount();
context->Eax = GetTickCount();
break;
default:
@ -549,11 +548,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
TRACE("GetVersion()\n");
EAX_reg(context) = VXD_WinVersion() | (200 << 16);
EBX_reg(context) = 0;
ECX_reg(context) = 0;
EDX_reg(context) = 0;
EDI_reg(context) = 0;
context->Eax = VXD_WinVersion() | (200 << 16);
context->Ebx = 0;
context->Ecx = 0;
context->Edx = 0;
context->Edi = 0;
/*
* If this is the first time we are called for this process,
@ -660,12 +659,12 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
*/
TRACE("[0001] EBX=%lx ECX=%lx EDX=%lx ESI=%lx EDI=%lx\n",
EBX_reg(context), ECX_reg(context), EDX_reg(context),
ESI_reg(context), EDI_reg(context));
context->Ebx, context->Ecx, context->Edx,
context->Esi, context->Edi);
/* FIXME */
EAX_reg(context) = 0;
context->Eax = 0;
break;
@ -683,11 +682,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
*/
TRACE("[0002] EBX=%lx ECX=%lx EDX=%lx\n",
EBX_reg(context), ECX_reg(context), EDX_reg(context));
context->Ebx, context->Ecx, context->Edx);
/* FIXME */
EAX_reg(context) = ECX_reg(context);
context->Eax = context->Ecx;
break;
@ -700,11 +699,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Bit 1: Read-Write if set, Read-Only if clear
*/
TRACE("[0003] EDX=%lx\n", EDX_reg(context));
TRACE("[0003] EDX=%lx\n", context->Edx);
/* FIXME */
EAX_reg(context) = 6;
context->Eax = 6;
break;
@ -717,10 +716,10 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: 0 if OK
*/
if (!EDX_reg(context) || CX_reg(context) == 0xFFFF)
if (!context->Edx || CX_reg(context) == 0xFFFF)
{
TRACE("MapModule: Initialization call\n");
EAX_reg(context) = 0;
context->Eax = 0;
}
else
{
@ -747,8 +746,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
*/
struct Win32sModule *moduleTable =
(struct Win32sModule *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
struct Win32sModule *module = moduleTable + ECX_reg(context);
(struct Win32sModule *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
struct Win32sModule *module = moduleTable + context->Ecx;
IMAGE_NT_HEADERS *nt_header = PE_HEADER(module->baseAddr);
IMAGE_SECTION_HEADER *pe_seg = PE_SECTIONS(module->baseAddr);
@ -826,7 +825,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
}
}
EAX_reg(context) = 0;
context->Eax = 0;
RESET_CFLAG(context);
}
break;
@ -839,11 +838,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: 1 if OK
*/
TRACE("UnMapModule: %lx\n", (DWORD)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET));
TRACE("UnMapModule: %lx\n", (DWORD)W32S_APP2WINE(context->Edx, W32S_OFFSET));
/* As we didn't map anything, there's nothing to unmap ... */
EAX_reg(context) = 1;
context->Eax = 1;
break;
@ -862,7 +861,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
DWORD size = stack[2];
@ -889,10 +888,10 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
if (W32S_WINE2APP(result, W32S_OFFSET))
*retv = W32S_WINE2APP(result, W32S_OFFSET),
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
else
*retv = 0,
EAX_reg(context) = STATUS_NO_MEMORY; /* FIXME */
context->Eax = STATUS_NO_MEMORY; /* FIXME */
}
break;
@ -911,7 +910,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
DWORD size = stack[2];
@ -925,10 +924,10 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
if (result)
*retv = TRUE,
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
else
*retv = FALSE,
EAX_reg(context) = STATUS_NO_MEMORY; /* FIXME */
context->Eax = STATUS_NO_MEMORY; /* FIXME */
}
break;
@ -948,7 +947,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
DWORD size = stack[2];
@ -963,10 +962,10 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
if (result)
*retv = TRUE,
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
else
*retv = FALSE,
EAX_reg(context) = STATUS_NO_MEMORY; /* FIXME */
context->Eax = STATUS_NO_MEMORY; /* FIXME */
}
break;
@ -985,7 +984,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
LPMEMORY_BASIC_INFORMATION info =
@ -999,7 +998,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
result = VirtualQuery(base, info, len);
*retv = result;
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
}
break;
@ -1014,11 +1013,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
*/
TRACE("[000a] ECX=%lx EDX=%lx\n",
ECX_reg(context), EDX_reg(context));
context->Ecx, context->Edx);
/* FIXME */
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
break;
@ -1029,11 +1028,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
TRACE("[000b] ECX=%lx\n", ECX_reg(context));
TRACE("[000b] ECX=%lx\n", context->Ecx);
/* FIXME */
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
break;
@ -1044,11 +1043,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EDX: Previous Debug Flags
*/
FIXME("[000c] EDX=%lx\n", EDX_reg(context));
FIXME("[000c] EDX=%lx\n", context->Edx);
/* FIXME */
EDX_reg(context) = 0;
context->Edx = 0;
break;
@ -1068,7 +1067,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *) W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *) W32S_APP2WINE(context->Edx, W32S_OFFSET);
HANDLE *retv = (HANDLE *)W32S_APP2WINE(stack[0], W32S_OFFSET);
DWORD flags1 = stack[1];
DWORD atom = stack[2];
@ -1102,10 +1101,10 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
if (result != INVALID_HANDLE_VALUE)
*retv = result,
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
else
*retv = result,
EAX_reg(context) = STATUS_NO_MEMORY; /* FIXME */
context->Eax = STATUS_NO_MEMORY; /* FIXME */
}
break;
@ -1121,7 +1120,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
HANDLE *retv = (HANDLE *)W32S_APP2WINE(stack[0], W32S_OFFSET);
DWORD protect = stack[1];
DWORD atom = stack[2];
@ -1146,10 +1145,10 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
if (result != INVALID_HANDLE_VALUE)
*retv = result,
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
else
*retv = result,
EAX_reg(context) = STATUS_NO_MEMORY; /* FIXME */
context->Eax = STATUS_NO_MEMORY; /* FIXME */
}
break;
@ -1164,7 +1163,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
HANDLE handle = stack[0];
DWORD *id = (DWORD *)W32S_APP2WINE(stack[1], W32S_OFFSET);
@ -1173,7 +1172,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
CloseHandle(handle);
if (id) *id = 0; /* FIXME */
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
}
break;
@ -1187,7 +1186,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
HANDLE handle = stack[0];
HANDLE new_handle;
@ -1196,7 +1195,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
DuplicateHandle( GetCurrentProcess(), handle,
GetCurrentProcess(), &new_handle,
0, FALSE, DUPLICATE_SAME_ACCESS );
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
}
break;
@ -1219,7 +1218,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD * stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD * stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
HANDLE SectionHandle = stack[0];
DWORD ProcessHandle = stack[1]; /* ignored */
DWORD * BaseAddress = (DWORD *)W32S_APP2WINE(stack[2], W32S_OFFSET);
@ -1266,10 +1265,10 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
if (W32S_WINE2APP(result, W32S_OFFSET))
{
if (BaseAddress) *BaseAddress = W32S_WINE2APP(result, W32S_OFFSET);
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
}
else
EAX_reg(context) = STATUS_NO_MEMORY; /* FIXME */
context->Eax = STATUS_NO_MEMORY; /* FIXME */
}
break;
@ -1284,7 +1283,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
DWORD ProcessHandle = stack[0]; /* ignored */
LPBYTE BaseAddress = (LPBYTE)W32S_APP2WINE(stack[1], W32S_OFFSET);
@ -1293,7 +1292,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
UnmapViewOfFile(BaseAddress);
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
}
break;
@ -1310,7 +1309,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
DWORD ProcessHandle = stack[0]; /* ignored */
DWORD *BaseAddress = (DWORD *)W32S_APP2WINE(stack[1], W32S_OFFSET);
DWORD *ViewSize = (DWORD *)W32S_APP2WINE(stack[2], W32S_OFFSET);
@ -1327,7 +1326,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
FlushViewOfFile(address, size);
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
}
break;
@ -1344,7 +1343,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
*/
FIXME("[0014] ECX=%lx EDX=%lx\n",
ECX_reg(context), EDX_reg(context));
context->Ecx, context->Edx);
/* FIXME */
break;
@ -1357,7 +1356,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: None
*/
TRACE("[0015] EDX=%lx\n", EDX_reg(context));
TRACE("[0015] EDX=%lx\n", context->Edx);
/* We don't care, as we always have a coprocessor anyway */
break;
@ -1377,13 +1376,13 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: None
*/
if (EBX_reg(context) == 0)
EDX_reg(context) = 0x80;
if (context->Ebx == 0)
context->Edx = 0x80;
else
{
PDB16 *psp = PTR_SEG_OFF_TO_LIN(BX_reg(context), 0);
psp->nbFiles = 32;
psp->fileHandlesPtr = MAKELONG(HIWORD(EBX_reg(context)), 0x5c);
psp->fileHandlesPtr = MAKELONG(HIWORD(context->Ebx), 0x5c);
memset((LPBYTE)psp + 0x5c, '\xFF', 32);
}
break;
@ -1398,7 +1397,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
*/
FIXME("[0017] EBX=%lx CX=%x\n",
EBX_reg(context), CX_reg(context));
context->Ebx, CX_reg(context));
/* FIXME */
break;
@ -1417,7 +1416,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
DWORD size = stack[2];
@ -1430,10 +1429,10 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
if (result)
*retv = TRUE,
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
else
*retv = FALSE,
EAX_reg(context) = STATUS_NO_MEMORY; /* FIXME */
context->Eax = STATUS_NO_MEMORY; /* FIXME */
}
break;
@ -1451,7 +1450,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD *stack = (DWORD *)W32S_APP2WINE(EDX_reg(context), W32S_OFFSET);
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
DWORD size = stack[2];
@ -1464,10 +1463,10 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
if (result)
*retv = TRUE,
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
else
*retv = FALSE,
EAX_reg(context) = STATUS_NO_MEMORY; /* FIXME */
context->Eax = STATUS_NO_MEMORY; /* FIXME */
}
break;
@ -1491,8 +1490,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* FIXME: What about other OSes ?
*/
ECX_reg(context) = W32S_WINE2APP(0x00000000, W32S_OFFSET);
EDX_reg(context) = W32S_WINE2APP(0xbfffffff, W32S_OFFSET);
context->Ecx = W32S_WINE2APP(0x00000000, W32S_OFFSET);
context->Edx = W32S_WINE2APP(0xbfffffff, W32S_OFFSET);
break;
@ -1515,7 +1514,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
};
struct Win32sMemoryInfo *info =
(struct Win32sMemoryInfo *)W32S_APP2WINE(ESI_reg(context), W32S_OFFSET);
(struct Win32sMemoryInfo *)W32S_APP2WINE(context->Esi, W32S_OFFSET);
FIXME("KGlobalMemStat(%lx)\n", (DWORD)info);
@ -1531,7 +1530,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: None
*/
TRACE("[001c] ECX=%lx\n", ECX_reg(context));
TRACE("[001c] ECX=%lx\n", context->Ecx);
/* FIXME */
break;
@ -1550,8 +1549,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* EDX: Flat base address of allocated region
*/
{
DWORD *stack = PTR_SEG_OFF_TO_LIN(LOWORD(EDX_reg(context)),
HIWORD(EDX_reg(context)));
DWORD *stack = PTR_SEG_OFF_TO_LIN(LOWORD(context->Edx),
HIWORD(context->Edx));
LPVOID base = (LPVOID)W32S_APP2WINE(stack[0], W32S_OFFSET);
DWORD size = stack[1];
DWORD type = stack[2];
@ -1570,12 +1569,12 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
result = (DWORD)VirtualAlloc(base, size, type, prot);
if (W32S_WINE2APP(result, W32S_OFFSET))
EDX_reg(context) = W32S_WINE2APP(result, W32S_OFFSET),
EAX_reg(context) = STATUS_SUCCESS;
context->Edx = W32S_WINE2APP(result, W32S_OFFSET),
context->Eax = STATUS_SUCCESS;
else
EDX_reg(context) = 0,
EAX_reg(context) = STATUS_NO_MEMORY; /* FIXME */
TRACE("VirtualAlloc16: returning base %lx\n", EDX_reg(context));
context->Edx = 0,
context->Eax = STATUS_NO_MEMORY; /* FIXME */
TRACE("VirtualAlloc16: returning base %lx\n", context->Edx);
}
break;
@ -1592,8 +1591,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* EDX: TRUE if success, FALSE if failure
*/
{
DWORD *stack = PTR_SEG_OFF_TO_LIN(LOWORD(EDX_reg(context)),
HIWORD(EDX_reg(context)));
DWORD *stack = PTR_SEG_OFF_TO_LIN(LOWORD(context->Edx),
HIWORD(context->Edx));
LPVOID base = (LPVOID)W32S_APP2WINE(stack[0], W32S_OFFSET);
DWORD size = stack[1];
DWORD type = stack[2];
@ -1605,11 +1604,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
result = VirtualFree(base, size, type);
if (result)
EDX_reg(context) = TRUE,
EAX_reg(context) = STATUS_SUCCESS;
context->Edx = TRUE,
context->Eax = STATUS_SUCCESS;
else
EDX_reg(context) = FALSE,
EAX_reg(context) = STATUS_NO_MEMORY; /* FIXME */
context->Edx = FALSE,
context->Eax = STATUS_NO_MEMORY; /* FIXME */
}
break;
@ -1624,8 +1623,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: NtStatus
*/
{
DWORD *ptr = (DWORD *)W32S_APP2WINE(ECX_reg(context), W32S_OFFSET);
BOOL set = EDX_reg(context);
DWORD *ptr = (DWORD *)W32S_APP2WINE(context->Ecx, W32S_OFFSET);
BOOL set = context->Edx;
TRACE("FWorkingSetSize(%lx, %lx)\n", (DWORD)ptr, (DWORD)set);
@ -1634,7 +1633,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
else
*ptr = 0x100;
EAX_reg(context) = STATUS_SUCCESS;
context->Eax = STATUS_SUCCESS;
}
break;

View File

@ -76,7 +76,7 @@ void WINAPI XMS_Handler( CONTEXT86 *context )
case 0x0b: /* Move Extended Memory Block */
{
MOVESTRUCT*move=CTX_SEG_OFF_TO_LIN(context,
DS_reg(context),ESI_reg(context));
context->SegDs,context->Esi);
BYTE*src,*dst;
TRACE("move extended memory block\n");
src=XMS_Offset(&move->Source);

View File

@ -50,8 +50,8 @@ int RELAY_ShowDebugmsgRelay(const char *func) {
term += 2;
for(; *listitem; listitem++) {
itemlen = strlen(*listitem);
if((itemlen == len && !lstrncmpiA(*listitem, func, len)) ||
(itemlen == len2 && !lstrncmpiA(*listitem, func, len2)) ||
if((itemlen == len && !strncasecmp(*listitem, func, len)) ||
(itemlen == len2 && !strncasecmp(*listitem, func, len2)) ||
!strcasecmp(*listitem, term)) {
show = !show;
break;
@ -287,7 +287,7 @@ static int RELAY_CallFrom32( int ret_addr, ... )
/***********************************************************************
* RELAY_CallFrom32Regs
*
* Stack layout (esp is ESP_reg(context), not the current %esp):
* Stack layout (esp is context->Esp, not the current %esp):
*
* ...
* (esp+4) first arg
@ -306,14 +306,14 @@ void WINAPI RELAY_DoCallFrom32Regs( CONTEXT86 *context )
FARPROC func;
BYTE *entry_point;
BYTE *relay_addr = *((BYTE **)ESP_reg(context) - 1);
BYTE *relay_addr = *((BYTE **)context->Esp - 1);
DEBUG_ENTRY_POINT *relay = (DEBUG_ENTRY_POINT *)(relay_addr - 5);
WORD nb_args = (relay->args & ~0x8000) / sizeof(int);
/* remove extra stuff from the stack */
EIP_reg(context) = stack32_pop(context);
args = (int *)ESP_reg(context);
ESP_reg(context) += 4 * nb_args;
context->Eip = stack32_pop(context);
args = (int *)context->Esp;
context->Esp += 4 * nb_args;
assert(TRACE_ON(relay));
@ -325,14 +325,14 @@ void WINAPI RELAY_DoCallFrom32Regs( CONTEXT86 *context )
DPRINTF( "Call %s(", buffer );
RELAY_PrintArgs( args, nb_args, relay->argtypes );
DPRINTF( ") ret=%08lx fs=%04lx\n", EIP_reg(context), FS_reg(context) );
DPRINTF( ") ret=%08lx fs=%04lx\n", context->Eip, context->SegFs );
DPRINTF(" eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx\n",
EAX_reg(context), EBX_reg(context), ECX_reg(context),
EDX_reg(context), ESI_reg(context), EDI_reg(context) );
context->Eax, context->Ebx, context->Ecx,
context->Edx, context->Esi, context->Edi );
DPRINTF(" ebp=%08lx esp=%08lx ds=%04lx es=%04lx gs=%04lx flags=%08lx\n",
EBP_reg(context), ESP_reg(context), DS_reg(context),
ES_reg(context), GS_reg(context), EFL_reg(context) );
context->Ebp, context->Esp, context->SegDs,
context->SegEs, context->SegGs, context->EFlags );
SYSLEVEL_CheckNotLevel( 2 );
@ -370,13 +370,14 @@ void WINAPI RELAY_DoCallFrom32Regs( CONTEXT86 *context )
}
DPRINTF( "Ret %s() retval=%08lx ret=%08lx fs=%04lx\n",
buffer, EAX_reg(context), EIP_reg(context), FS_reg(context) );
buffer, context->Eax, context->Eip, context->SegFs );
DPRINTF(" eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx\n",
EAX_reg(context), EBX_reg(context), ECX_reg(context),
EDX_reg(context), ESI_reg(context), EDI_reg(context) );
context->Eax, context->Ebx, context->Ecx,
context->Edx, context->Esi, context->Edi );
DPRINTF(" ebp=%08lx esp=%08lx ds=%04lx es=%04lx gs=%04lx flags=%08lx\n",
EBP_reg(context), ESP_reg(context), DS_reg(context),
ES_reg(context), GS_reg(context), EFL_reg(context) );
context->Ebp, context->Esp, context->SegDs,
context->SegEs, context->SegGs, context->EFlags );
SYSLEVEL_CheckNotLevel( 2 );
}

View File

@ -254,13 +254,13 @@ SNOOP_PrintArg(DWORD x) {
return buf;
}
#define CALLER1REF (*(DWORD*)ESP_reg(context))
#define CALLER1REF (*(DWORD*)context->Esp)
void WINAPI SNOOP_DoEntry( CONTEXT86 *context );
DEFINE_REGS_ENTRYPOINT_0( SNOOP_Entry, SNOOP_DoEntry );
void WINAPI SNOOP_DoEntry( CONTEXT86 *context )
{
DWORD ordinal=0,entry = EIP_reg(context)-5;
DWORD ordinal=0,entry = context->Eip - 5;
SNOOP_DLL *dll = firstdll;
SNOOP_FUN *fun = NULL;
SNOOP_RETURNENTRIES **rets = &firstrets;
@ -319,30 +319,30 @@ void WINAPI SNOOP_DoEntry( CONTEXT86 *context )
ret->dll = dll;
ret->args = NULL;
ret->ordinal = ordinal;
ret->origESP = ESP_reg(context);
ret->origESP = context->Esp;
EIP_reg(context)= (DWORD)fun->origfun;
context->Eip = (DWORD)fun->origfun;
DPRINTF("CALL %s.%ld: %s(",dll->name,ordinal,fun->name);
if (fun->nrofargs>0) {
max = fun->nrofargs; if (max>16) max=16;
for (i=0;i<max;i++)
DPRINTF("%s%s",SNOOP_PrintArg(*(DWORD*)(ESP_reg(context)+4+sizeof(DWORD)*i)),(i<fun->nrofargs-1)?",":"");
DPRINTF("%s%s",SNOOP_PrintArg(*(DWORD*)(context->Esp + 4 + sizeof(DWORD)*i)),(i<fun->nrofargs-1)?",":"");
if (max!=fun->nrofargs)
DPRINTF(" ...");
} else if (fun->nrofargs<0) {
DPRINTF("<unknown, check return>");
ret->args = HeapAlloc(GetProcessHeap(),0,16*sizeof(DWORD));
memcpy(ret->args,(LPBYTE)(ESP_reg(context)+4),sizeof(DWORD)*16);
memcpy(ret->args,(LPBYTE)(context->Esp + 4),sizeof(DWORD)*16);
}
DPRINTF(") ret=%08lx fs=%04lx\n",(DWORD)ret->origreturn,FS_reg(context));
DPRINTF(") ret=%08lx fs=%04lx\n",(DWORD)ret->origreturn,context->SegFs);
}
void WINAPI SNOOP_DoReturn( CONTEXT86 *context );
DEFINE_REGS_ENTRYPOINT_0( SNOOP_Return, SNOOP_DoReturn );
void WINAPI SNOOP_DoReturn( CONTEXT86 *context )
{
SNOOP_RETURNENTRY *ret = (SNOOP_RETURNENTRY*)(EIP_reg(context)-5);
SNOOP_RETURNENTRY *ret = (SNOOP_RETURNENTRY*)(context->Eip - 5);
/* We haven't found out the nrofargs yet. If we called a cdecl
* function it is too late anyway and we can just set '0' (which
@ -350,8 +350,8 @@ void WINAPI SNOOP_DoReturn( CONTEXT86 *context )
* If stdcall -> everything ok.
*/
if (ret->dll->funs[ret->ordinal].nrofargs<0)
ret->dll->funs[ret->ordinal].nrofargs=(ESP_reg(context)-ret->origESP-4)/4;
EIP_reg(context) = (DWORD)ret->origreturn;
ret->dll->funs[ret->ordinal].nrofargs=(context->Esp - ret->origESP-4)/4;
context->Eip = (DWORD)ret->origreturn;
if (ret->args) {
int i,max;
@ -362,15 +362,13 @@ void WINAPI SNOOP_DoReturn( CONTEXT86 *context )
for (i=0;i<max;i++)
DPRINTF("%s%s",SNOOP_PrintArg(ret->args[i]),(i<max-1)?",":"");
DPRINTF(") retval = %08lx ret=%08lx fs=%04lx\n",
EAX_reg(context),(DWORD)ret->origreturn,FS_reg(context)
);
context->Eax,(DWORD)ret->origreturn,context->SegFs );
HeapFree(GetProcessHeap(),0,ret->args);
ret->args = NULL;
} else
DPRINTF("RET %s.%ld: %s() retval = %08lx ret=%08lx fs=%04lx\n",
ret->dll->name,ret->ordinal,ret->dll->funs[ret->ordinal].name,
EAX_reg(context),(DWORD)ret->origreturn,FS_reg(context)
);
context->Eax,(DWORD)ret->origreturn,context->SegFs );
ret->origreturn = NULL; /* mark as empty */
}
#else /* !__i386__ */

View File

@ -496,7 +496,7 @@ void VxDCall( DWORD service, CONTEXT86 *context )
else
ret = VxDList[i].vxdcall( service, context );
EAX_reg( context ) = ret;
context->Eax = ret;
}
@ -811,7 +811,7 @@ static DWORD VxDCall_VMM( DWORD service, CONTEXT86 *context )
(DWORD )hmem, flags );
ret = VirtualFree ( hmem, 0, MEM_RELEASE );
EAX_reg( context ) = ret;
context->Eax = ret;
FIXME("Returning: %d\n", ret );
return 0;
@ -1022,7 +1022,7 @@ static DWORD VxDCall_VWin32( DWORD service, CONTEXT86 *context )
CX_reg(context) = parm;
INT_Int31Handler(context);
return(AX_reg(context));
return LOWORD(context->Eax);
}
break;

View File

@ -77,14 +77,12 @@ static VOID WINAPI KEYBOARD_CallKeybdEventProc( FARPROC16 proc,
CONTEXT86 context;
memset( &context, 0, sizeof(context) );
CS_reg(&context) = SELECTOROF( proc );
EIP_reg(&context) = OFFSETOF( proc );
AH_reg(&context) = (dwFlags & KEYEVENTF_KEYUP)? 0x80 : 0;
AL_reg(&context) = bVk;
BH_reg(&context) = (dwFlags & KEYEVENTF_EXTENDEDKEY)? 1 : 0;
BL_reg(&context) = bScan;
SI_reg(&context) = LOWORD( dwExtraInfo );
DI_reg(&context) = HIWORD( dwExtraInfo );
context.SegCs = SELECTOROF( proc );
context.Eip = OFFSETOF( proc );
context.Eax = bVk | ((dwFlags & KEYEVENTF_KEYUP)? 0x8000 : 0);
context.Ebx = bScan | ((dwFlags & KEYEVENTF_EXTENDEDKEY) ? 0x100 : 0);
context.Esi = LOWORD( dwExtraInfo );
context.Edi = HIWORD( dwExtraInfo );
CallTo16RegisterShort( &context, 0 );
}

View File

@ -10,6 +10,7 @@
#include "wingdi.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "wine/winestring.h"
#include "stackframe.h"
#include "builtin16.h"
#include "heap.h"
@ -193,12 +194,11 @@ static LRESULT WINAPI WINPROC_CallWndProc16( WNDPROC16 proc, HWND16 hwnd,
/* Window procedures want ax = hInstance, ds = es = ss */
memset(&context, '\0', sizeof(context));
DS_reg(&context) = SELECTOROF(teb->cur_stack);
ES_reg(&context) = DS_reg(&context);
EAX_reg(&context) = wndPtr ? wndPtr->hInstance : DS_reg(&context);
CS_reg(&context) = SELECTOROF(proc);
EIP_reg(&context) = OFFSETOF(proc);
EBP_reg(&context) = OFFSETOF(teb->cur_stack)
context.SegDs = context.SegEs = SELECTOROF(teb->cur_stack);
context.Eax = wndPtr ? wndPtr->hInstance : context.SegDs;
context.SegCs = SELECTOROF(proc);
context.Eip = OFFSETOF(proc);
context.Ebp = OFFSETOF(teb->cur_stack)
+ (WORD)&((STACK16FRAME*)0)->bp;
WIN_ReleaseWndPtr(wndPtr);
@ -239,7 +239,7 @@ static LRESULT WINAPI WINPROC_CallWndProc16( WNDPROC16 proc, HWND16 hwnd,
args[4] = hwnd;
CallTo16RegisterShort( &context, 5 * sizeof(WORD) );
ret = MAKELONG( AX_reg(&context), DX_reg(&context) );
ret = MAKELONG( LOWORD(context.Eax), LOWORD(context.Edx) );
if (offset) stack16_pop( offset );
WIN_RestoreWndsLock(iWndsLocks);