Skip to content
Snippets Groups Projects
Commit 35818652 authored by Alexandre Julliard's avatar Alexandre Julliard
Browse files

Support for specifying stack size of Winelib apps.

parent c814a6ce
No related branches found
No related tags found
No related merge requests found
......@@ -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
*
......
......@@ -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. <name>.DLL is assumed if none is given. (This is important
for kernel, which lives in the Windows file KRNL386.EXE).
......
......@@ -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;
......
......@@ -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;
......
......@@ -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)
......
......@@ -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 */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment