mirror of
https://github.com/reactos/wine.git
synced 2024-11-28 22:20:26 +00:00
Automatically detect whether the entry point is main or WinMain
instead of depending on the subsystem type.
This commit is contained in:
parent
743997fa38
commit
32e31ac7c4
@ -451,11 +451,10 @@ static void add_extra_undef_symbols( const DLLSPEC *spec )
|
||||
switch (spec->subsystem)
|
||||
{
|
||||
case IMAGE_SUBSYSTEM_WINDOWS_GUI:
|
||||
case IMAGE_SUBSYSTEM_WINDOWS_CUI:
|
||||
kernel_imports += add_extra_symbol( extras, &count, "GetCommandLineA", spec );
|
||||
kernel_imports += add_extra_symbol( extras, &count, "GetStartupInfoA", spec );
|
||||
kernel_imports += add_extra_symbol( extras, &count, "GetModuleHandleA", spec );
|
||||
/* fall through */
|
||||
case IMAGE_SUBSYSTEM_WINDOWS_CUI:
|
||||
kernel_imports += add_extra_symbol( extras, &count, "ExitProcess", spec );
|
||||
break;
|
||||
}
|
||||
|
@ -640,7 +640,15 @@ void BuildSpec32File( FILE *outfile, DLLSPEC *spec )
|
||||
init_func = "__wine_driver_entry";
|
||||
break;
|
||||
case IMAGE_SUBSYSTEM_WINDOWS_GUI:
|
||||
if (!init_func) init_func = "WinMain";
|
||||
case IMAGE_SUBSYSTEM_WINDOWS_CUI:
|
||||
if (init_func)
|
||||
fprintf( outfile, "extern int %s( int argc, char *argv[] );\n", init_func );
|
||||
else
|
||||
{
|
||||
declare_weak_function( outfile, "main", "int main( int argc, char *argv[] )" );
|
||||
declare_weak_function( outfile, "wmain", "int wmain( int argc, unsigned short *argv[] )" );
|
||||
declare_weak_function( outfile, "WinMain", "int __stdcall WinMain(void *,void *,char *,int)" );
|
||||
}
|
||||
fprintf( outfile,
|
||||
"\ntypedef struct {\n"
|
||||
" unsigned int cb;\n"
|
||||
@ -651,49 +659,12 @@ void BuildSpec32File( FILE *outfile, DLLSPEC *spec )
|
||||
" char *lpReserved2;\n"
|
||||
" void *hStdInput, *hStdOutput, *hStdError;\n"
|
||||
"} STARTUPINFOA;\n"
|
||||
"extern int __stdcall %s(void *,void *,char *,int);\n"
|
||||
"extern char * __stdcall GetCommandLineA(void);\n"
|
||||
"extern void * __stdcall GetModuleHandleA(char *);\n"
|
||||
"extern void __stdcall GetStartupInfoA(STARTUPINFOA *);\n"
|
||||
"extern void __stdcall ExitProcess(unsigned int);\n"
|
||||
"static void __wine_exe_main(void)\n"
|
||||
"{\n"
|
||||
" STARTUPINFOA info;\n"
|
||||
" char *cmdline = GetCommandLineA();\n"
|
||||
" int ret, bcount=0, in_quotes=0;\n"
|
||||
" while (*cmdline) {\n"
|
||||
" if ((*cmdline=='\\t' || *cmdline==' ') && !in_quotes) break;\n"
|
||||
" else if (*cmdline=='\\\\') bcount++;\n"
|
||||
" else if (*cmdline=='\\\"') {\n"
|
||||
" if ((bcount & 1)==0) in_quotes=!in_quotes;\n"
|
||||
" bcount=0;\n"
|
||||
" }\n"
|
||||
" else bcount=0;\n"
|
||||
" cmdline++;\n"
|
||||
" }\n"
|
||||
" while (*cmdline=='\\t' || *cmdline==' ') cmdline++;\n"
|
||||
" GetStartupInfoA( &info );\n"
|
||||
" if (!(info.dwFlags & 1)) info.wShowWindow = 1;\n"
|
||||
" if (__wine_spec_init_state == 1)\n"
|
||||
" _init( __wine_main_argc, __wine_main_argv, __wine_main_environ );\n"
|
||||
" ret = %s( GetModuleHandleA(0), 0, cmdline, info.wShowWindow );\n"
|
||||
" if (__wine_spec_init_state == 1) _fini();\n"
|
||||
" ExitProcess( ret );\n"
|
||||
"}\n\n", init_func, init_func );
|
||||
init_func = "__wine_exe_main";
|
||||
break;
|
||||
case IMAGE_SUBSYSTEM_WINDOWS_CUI:
|
||||
if (init_func)
|
||||
fprintf( outfile, "extern int %s( int argc, char *argv[] );\n", init_func );
|
||||
else
|
||||
{
|
||||
declare_weak_function( outfile, "main", "int main( int argc, char *argv[] )" );
|
||||
declare_weak_function( outfile, "wmain", "int wmain( int argc, unsigned short *argv[] )" );
|
||||
}
|
||||
fprintf( outfile,
|
||||
"\nextern void __stdcall ExitProcess(int);\n"
|
||||
"static void __wine_exe_main(void)\n"
|
||||
"{\n"
|
||||
" int ret;\n"
|
||||
" if (__wine_spec_init_state == 1)\n"
|
||||
" _init( __wine_main_argc, __wine_main_argv, __wine_main_environ );\n" );
|
||||
@ -702,7 +673,26 @@ void BuildSpec32File( FILE *outfile, DLLSPEC *spec )
|
||||
" ret = %s( __wine_main_argc, __wine_main_argv );\n", init_func );
|
||||
else
|
||||
fprintf( outfile,
|
||||
" if (wmain) ret = wmain( __wine_main_argc, __wine_main_wargv );\n"
|
||||
" if (WinMain) {\n"
|
||||
" STARTUPINFOA info;\n"
|
||||
" char *cmdline = GetCommandLineA();\n"
|
||||
" int bcount=0, in_quotes=0;\n"
|
||||
" while (*cmdline) {\n"
|
||||
" if ((*cmdline=='\\t' || *cmdline==' ') && !in_quotes) break;\n"
|
||||
" else if (*cmdline=='\\\\') bcount++;\n"
|
||||
" else if (*cmdline=='\\\"') {\n"
|
||||
" if ((bcount & 1)==0) in_quotes=!in_quotes;\n"
|
||||
" bcount=0;\n"
|
||||
" }\n"
|
||||
" else bcount=0;\n"
|
||||
" cmdline++;\n"
|
||||
" }\n"
|
||||
" while (*cmdline=='\\t' || *cmdline==' ') cmdline++;\n"
|
||||
" GetStartupInfoA( &info );\n"
|
||||
" if (!(info.dwFlags & 1)) info.wShowWindow = 1;\n"
|
||||
" ret = WinMain( GetModuleHandleA(0), 0, cmdline, info.wShowWindow );\n"
|
||||
" }\n"
|
||||
" else if (wmain) ret = wmain( __wine_main_argc, __wine_main_wargv );\n"
|
||||
" else ret = main( __wine_main_argc, __wine_main_argv );\n" );
|
||||
fprintf( outfile,
|
||||
" if (__wine_spec_init_state == 1) _fini();\n"
|
||||
|
@ -76,11 +76,12 @@ Specify the module entry point function; if not specified, the default
|
||||
is
|
||||
.B DllMain
|
||||
for dlls, and
|
||||
.B main
|
||||
or
|
||||
.B WinMain
|
||||
for CUI or GUI executables respectively. This is only valid for Win32
|
||||
modules.
|
||||
for executables (if
|
||||
.B WinMain
|
||||
is not defined, the standard C
|
||||
.B main
|
||||
is used instead). This is only valid for Win32 modules.
|
||||
.TP
|
||||
.BI \-f\ flags
|
||||
Ignored for compatibility with the C compiler.
|
||||
|
Loading…
Reference in New Issue
Block a user