From 35818652292467c4a96e808df5d8b1d041dca0e1 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 7 Jun 2001 22:29:03 +0000 Subject: [PATCH] Support for specifying stack size of Winelib apps. --- scheduler/process.c | 31 +++++++------------------------ tools/winebuild/README | 4 ++++ tools/winebuild/build.h | 1 + tools/winebuild/main.c | 1 + tools/winebuild/parser.c | 6 ++++++ tools/winebuild/spec32.c | 5 ++++- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/scheduler/process.c b/scheduler/process.c index 3f8b12f9b5a..85be03f678d 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -319,12 +319,6 @@ static void start_process(void) LPTHREAD_START_ROUTINE entry; WINE_MODREF *wm; - /* build command line */ - if (!ENV_BuildCommandLine( main_exe_argv )) goto error; - - /* create 32-bit module for main exe */ - if (!(current_process.module = BUILTIN32_LoadExeModule( current_process.module ))) goto error; - /* use original argv[0] as name for the main module */ if (!main_exe_name[0]) { @@ -498,7 +492,6 @@ void PROCESS_InitWine( int argc, char *argv[], LPSTR win16_exe_name, HANDLE *win { if (PE_HEADER(current_process.module)->FileHeader.Characteristics & IMAGE_FILE_DLL) ExitProcess( ERROR_BAD_EXE_FORMAT ); - stack_size = PE_HEADER(current_process.module)->OptionalHeader.SizeOfStackReserve; goto found; } @@ -512,6 +505,13 @@ void PROCESS_InitWine( int argc, char *argv[], LPSTR win16_exe_name, HANDLE *win _EnterWin16Lock(); found: + /* build command line */ + if (!ENV_BuildCommandLine( main_exe_argv )) goto error; + + /* create 32-bit module for main exe */ + if (!(current_process.module = BUILTIN32_LoadExeModule( current_process.module ))) goto error; + stack_size = PE_HEADER(current_process.module)->OptionalHeader.SizeOfStackReserve; + /* allocate main thread stack */ if (!THREAD_InitStack( NtCurrentTeb(), stack_size )) goto error; @@ -523,23 +523,6 @@ void PROCESS_InitWine( int argc, char *argv[], LPSTR win16_exe_name, HANDLE *win } -/*********************************************************************** - * PROCESS_InitWinelib - * - * Initialisation of a new Winelib process. - */ -void PROCESS_InitWinelib( int argc, char *argv[] ) -{ - if (!process_init( argv )) exit(1); - - /* allocate main thread stack */ - if (!THREAD_InitStack( NtCurrentTeb(), 0 )) ExitProcess( GetLastError() ); - - /* switch to the new stack */ - SYSDEPS_SwitchToThreadStack( start_process ); -} - - /*********************************************************************** * build_argv * diff --git a/tools/winebuild/README b/tools/winebuild/README index 3942c4fef65..3b5310715de 100644 --- a/tools/winebuild/README +++ b/tools/winebuild/README @@ -6,6 +6,7 @@ type win16|win32 [file WINFILENAME] [mode dll|cuiexe|guiexe|cuiexe_unicode|guiexe_unicode] [heap SIZE] +[stack SIZE] [init FUNCTION] [import [IMP_FLAGS] DLL] [rsrc RESFILE] @@ -40,6 +41,9 @@ This is only valid for Win32 spec files. "heap" is the size of the module local heap (only valid for Win16 modules); default is no local heap. +"stack" is the stack size for Win32 exe modules, in kilobytes; default +size is 1024 (1Mb stack). + "file" gives the name of the Windows file that is replaced by the builtin. .DLL is assumed if none is given. (This is important for kernel, which lives in the Windows file KRNL386.EXE). diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 0687ec5f91c..73da0c7acec 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -161,6 +161,7 @@ extern int Limit; extern int DLLHeapSize; extern int UsePIC; extern int debugging; +extern int stack_size; extern int nb_debug_channels; extern int nb_lib_paths; diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index f129ba9a40d..b516b270477 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -27,6 +27,7 @@ int Base = MAX_ORDINALS; int Limit = 0; int DLLHeapSize = 0; int UsePIC = 0; +int stack_size = 0; int nb_entry_points = 0; int nb_names = 0; int nb_debug_channels = 0; diff --git a/tools/winebuild/parser.c b/tools/winebuild/parser.c index 3d43e329b18..a3a9ac37064 100644 --- a/tools/winebuild/parser.c +++ b/tools/winebuild/parser.c @@ -559,6 +559,12 @@ SPEC_TYPE ParseTopLevel( FILE *file ) if (!IsNumberString(token)) fatal_error( "Expected number after heap\n" ); DLLHeapSize = atoi(token); } + else if (strcmp(token, "stack") == 0) + { + token = GetToken(0); + if (!IsNumberString(token)) fatal_error( "Expected number after stack\n" ); + stack_size = atoi(token); + } else if (strcmp(token, "init") == 0) { if (SpecType == SPEC_WIN16) diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 4c81edc447e..09bb636c987 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -656,7 +656,10 @@ void BuildSpec32File( FILE *outfile ) fprintf( outfile, " %ld,\n", page_size ); /* SizeOfHeaders */ fprintf( outfile, " 0,\n" ); /* CheckSum */ fprintf( outfile, " 0x%04x,\n", subsystem ); /* Subsystem */ - fprintf( outfile, " 0, 0, 0, 0, 0, 0,\n" ); + fprintf( outfile, " 0,\n" ); /* DllCharacteristics */ + fprintf( outfile, " %d, 0,\n", stack_size*1024 ); /* SizeOfStackReserve/Commit */ + fprintf( outfile, " %d, 0,\n", DLLHeapSize*1024 );/* SizeOfHeapReserve/Commit */ + fprintf( outfile, " 0,\n" ); /* LoaderFlags */ fprintf( outfile, " %d,\n", IMAGE_NUMBEROF_DIRECTORY_ENTRIES ); /* NumberOfRvaAndSizes */ fprintf( outfile, " {\n" ); fprintf( outfile, " { %s, %d },\n", /* IMAGE_DIRECTORY_ENTRY_EXPORT */