Removed some of the XXX_reg macros now that we are using the standard
CONTEXT86 structure everywhere.
diff --git a/loader/dos/dosvm.c b/loader/dos/dosvm.c
index 241f669..4f0fbcf 100644
--- a/loader/dos/dosvm.c
+++ b/loader/dos/dosvm.c
@@ -50,11 +50,11 @@
# 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 @@
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 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 @@
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 @@
}
}
-#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 @@
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 @@
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 @@
} 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;
}
diff --git a/loader/ne/module.c b/loader/ne/module.c
index 5bbceb5..96ea71e 100644
--- a/loader/ne/module.c
+++ b/loader/ne/module.c
@@ -1177,24 +1177,24 @@
* 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 @@
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 @@
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 @@
*/
void WINAPI MapHInstLS( CONTEXT86 *context )
{
- EAX_reg(context) = MapHModuleLS(EAX_reg(context));
+ context->Eax = MapHModuleLS(context->Eax);
}
/***************************************************************************
@@ -1737,7 +1737,7 @@
*/
void WINAPI MapHInstSL( CONTEXT86 *context )
{
- EAX_reg(context) = MapHModuleSL(EAX_reg(context));
+ context->Eax = MapHModuleSL(context->Eax);
}
/***************************************************************************
@@ -1745,8 +1745,7 @@
*/
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 MapHInstSL_PN( CONTEXT86 *context )
{
- if (EAX_reg(context))
- EAX_reg(context) = MapHModuleSL(EAX_reg(context));
+ if (context->Eax) context->Eax = MapHModuleSL(context->Eax);
}
diff --git a/loader/ne/segment.c b/loader/ne/segment.c
index 1c65265..d3f6aa0 100644
--- a/loader/ne/segment.c
+++ b/loader/ne/segment.c
@@ -613,20 +613,20 @@
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 @@
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 */
diff --git a/loader/task.c b/loader/task.c
index 6b29425..34ab004 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -631,7 +631,7 @@
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 @@
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 @@
*/
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 @@
/* 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 */