Commit d8fab2e6 authored by Alexandre Julliard's avatar Alexandre Julliard

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

CONTEXT86 structure everywhere.
parent 072dfb57
......@@ -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 */
......
......@@ -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))
......
......@@ -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;
}
/******************************************************************************
......
......@@ -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 );
}
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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 */
......@@ -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 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 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 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 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 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 */
......
......@@ -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;
}
......
......@@ -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);
}
......@@ -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 */
......
......@@ -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;
if (!pTask->pdb.cmdLine[0]) EBX_reg(context) = 0x80;
context->Eax = 1;
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 */
......
......@@ -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]);
......
......@@ -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;
}
}
......@@ -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;
......
......@@ -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 */
......
......@@ -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))
{
......
......@@ -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");
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
}
......@@ -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);
}
......@@ -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;
}
}
......@@ -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);
}
......
......@@ -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 */
}
......
......@@ -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);
......
......@@ -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 );
}
......
......@@ -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__ */
......
......@@ -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;
......
......@@ -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 );
}
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment