Switch stacks in CALL32_Init().
This commit is contained in:
parent
ed49003188
commit
bba76eed9c
|
@ -17,7 +17,7 @@ extern void MAIN_ParseModeOption( char *arg );
|
|||
|
||||
extern BOOL RELAY_Init(void);
|
||||
extern int RELAY_ShowDebugmsgRelay(const char *func);
|
||||
extern void* CALL32_Init(void);
|
||||
extern void CALL32_Init( void *func, void *target, void *stack );
|
||||
|
||||
extern BOOL THUNK_Init(void);
|
||||
|
||||
|
|
|
@ -158,13 +158,14 @@ int main( int argc, char *argv[] )
|
|||
if ( !(pModule = NE_GetPtr( GetModuleHandle16( "KERNEL" ) )) ) return 1;
|
||||
if ( !TASK_Create( THREAD_Current(), pModule, 0, 0, FALSE ) ) return 1;
|
||||
|
||||
/* Initialize CALL32 routines */
|
||||
/* This needs to be done just before switching stacks */
|
||||
IF1632_CallLargeStack = (int (*)(int (*func)(), void *arg))CALL32_Init();
|
||||
|
||||
/* Switch to initial task */
|
||||
CURRENT_STACK16->frame32->retaddr = (DWORD)MAIN_EmulatorRun;
|
||||
TASK_StartTask( PROCESS_Current()->task );
|
||||
MSG( "main: Should never happen: returned from TASK_StartTask()\n" );
|
||||
PostEvent16( PROCESS_Current()->task );
|
||||
TASK_Reschedule();
|
||||
|
||||
/* Switch stacks and jump to MAIN_EmulatorRun */
|
||||
CALL32_Init( &IF1632_CallLargeStack, MAIN_EmulatorRun,
|
||||
THREAD_Current()->teb.stack_top );
|
||||
|
||||
MSG( "main: Should never happen: returned from CALL32_Init()\n" );
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2488,11 +2488,20 @@ static void BuildCallTo32CBClient( FILE *outfile, BOOL isEx )
|
|||
*
|
||||
* The pointer to the function can be retrieved by calling CALL32_Init,
|
||||
* which also takes care of saving the current 32-bit stack pointer.
|
||||
* Furthermore, CALL32_Init switches to a new stack and jumps to the
|
||||
* specified target address.
|
||||
*
|
||||
* NOTE: The CALL32_LargeStack routine may be recursively entered by the
|
||||
* same thread, but not concurrently entered by several threads.
|
||||
*
|
||||
* Stack layout:
|
||||
* Stack layout of CALL32_Init:
|
||||
*
|
||||
* (esp+12) new stack address
|
||||
* (esp+8) target address
|
||||
* (esp+4) pointer to variable to receive CALL32_LargeStack address
|
||||
* (esp) ret addr
|
||||
*
|
||||
* Stack layout of CALL32_LargeStack:
|
||||
* ... ...
|
||||
* (ebp+12) arg
|
||||
* (ebp+8) func
|
||||
|
@ -2510,9 +2519,13 @@ static void BuildCallTo32LargeStack( FILE *outfile )
|
|||
fprintf( outfile, "\t.globl " PREFIX "CALL32_Init\n" );
|
||||
fprintf( outfile, "\t.type " PREFIX "CALL32_Init,@function\n" );
|
||||
fprintf( outfile, PREFIX "CALL32_Init:\n" );
|
||||
fprintf( outfile, "\tleal -256(%%esp),%%eax\n" );
|
||||
fprintf( outfile, "\tmovl %%eax,CALL32_Original32_esp\n" );
|
||||
fprintf( outfile, "\tmovl $CALL32_LargeStack,%%eax\n" );
|
||||
fprintf( outfile, "\tmovl %%esp,CALL32_Original32_esp\n" );
|
||||
fprintf( outfile, "\tpopl %%eax\n" );
|
||||
fprintf( outfile, "\tpopl %%eax\n" );
|
||||
fprintf( outfile, "\tmovl $CALL32_LargeStack,(%%eax)\n" );
|
||||
fprintf( outfile, "\tpopl %%eax\n" );
|
||||
fprintf( outfile, "\tpopl %%esp\n" );
|
||||
fprintf( outfile, "\tpushl %%eax\n" );
|
||||
fprintf( outfile, "\tret\n" );
|
||||
|
||||
/* Function header */
|
||||
|
|
Loading…
Reference in New Issue