Commit bf90f4db authored by Alexandre Julliard's avatar Alexandre Julliard

Adapted to use the argc/argv variables from libwine.

Automatically import libraries that contain the symbols that the .spec.c file is using.
parent 702b158e
...@@ -241,7 +241,7 @@ static int remove_symbol_holes(void) ...@@ -241,7 +241,7 @@ static int remove_symbol_holes(void)
static void add_extra_undef_symbols(void) static void add_extra_undef_symbols(void)
{ {
const char *extras[10]; const char *extras[10];
int i, count = 0; int i, count = 0, nb_stubs = 0, nb_regs = 0;
#define ADD_SYM(name) \ #define ADD_SYM(name) \
do { if (!find_symbol( extras[count] = (name), undef_symbols, \ do { if (!find_symbol( extras[count] = (name), undef_symbols, \
...@@ -249,6 +249,13 @@ static void add_extra_undef_symbols(void) ...@@ -249,6 +249,13 @@ static void add_extra_undef_symbols(void)
sort_symbols( undef_symbols, nb_undef_symbols ); sort_symbols( undef_symbols, nb_undef_symbols );
for (i = 0; i < nb_entry_points; i++)
{
ORDDEF *odp = EntryPoints[i];
if (odp->type == TYPE_STUB) nb_stubs++;
if (odp->flags & FLAG_REGISTER) nb_regs++;
}
/* add symbols that will be contained in the spec file itself */ /* add symbols that will be contained in the spec file itself */
switch (SpecMode) switch (SpecMode)
{ {
...@@ -260,7 +267,6 @@ static void add_extra_undef_symbols(void) ...@@ -260,7 +267,6 @@ static void add_extra_undef_symbols(void)
ADD_SYM( "GetModuleHandleA" ); ADD_SYM( "GetModuleHandleA" );
/* fall through */ /* fall through */
case SPEC_MODE_CUIEXE: case SPEC_MODE_CUIEXE:
ADD_SYM( "__wine_get_main_args" );
ADD_SYM( "ExitProcess" ); ADD_SYM( "ExitProcess" );
break; break;
case SPEC_MODE_GUIEXE_UNICODE: case SPEC_MODE_GUIEXE_UNICODE:
...@@ -269,26 +275,20 @@ static void add_extra_undef_symbols(void) ...@@ -269,26 +275,20 @@ static void add_extra_undef_symbols(void)
ADD_SYM( "GetModuleHandleA" ); ADD_SYM( "GetModuleHandleA" );
/* fall through */ /* fall through */
case SPEC_MODE_CUIEXE_UNICODE: case SPEC_MODE_CUIEXE_UNICODE:
ADD_SYM( "__wine_get_wmain_args" );
ADD_SYM( "ExitProcess" ); ADD_SYM( "ExitProcess" );
break; break;
} }
ADD_SYM( "RtlRaiseException" );
if (nb_delayed) if (nb_delayed)
{ {
ADD_SYM( "LoadLibraryA" ); ADD_SYM( "LoadLibraryA" );
ADD_SYM( "GetProcAddress" ); ADD_SYM( "GetProcAddress" );
} }
if (nb_regs) ADD_SYM( "__wine_call_from_32_regs" );
if (nb_delayed || nb_stubs) ADD_SYM( "RtlRaiseException" );
for (i = 0; i < nb_entry_points; i++) /* make sure we import the dlls that contain these functions */
{ if (SpecMode != SPEC_MODE_DLL || nb_delayed) add_import_dll( "kernel32", 0 );
ORDDEF *odp = EntryPoints[i]; if (nb_delayed || nb_stubs || nb_regs) add_import_dll( "ntdll", 0 );
if (odp->flags & FLAG_REGISTER)
{
ADD_SYM( "__wine_call_from_32_regs" );
break;
}
}
if (count) if (count)
{ {
......
...@@ -534,14 +534,16 @@ void BuildSpec32File( FILE *outfile ) ...@@ -534,14 +534,16 @@ void BuildSpec32File( FILE *outfile )
"extern void __stdcall ExitProcess(unsigned int);\n" "extern void __stdcall ExitProcess(unsigned int);\n"
"static void __wine_exe_main(void)\n" "static void __wine_exe_main(void)\n"
"{\n" "{\n"
" extern int __wine_get_main_args( char ***argv );\n" " extern int __wine_main_argc;\n"
" extern char **__wine_main_argv;\n"
" STARTUPINFOA info;\n" " STARTUPINFOA info;\n"
" char *cmdline = GetCommandLineA();\n" " char *cmdline = GetCommandLineA();\n"
" while (*cmdline && *cmdline != ' ') cmdline++;\n" " while (*cmdline && *cmdline != ' ') cmdline++;\n"
" if (*cmdline) cmdline++;\n" " if (*cmdline) cmdline++;\n"
" GetStartupInfoA( &info );\n" " GetStartupInfoA( &info );\n"
" if (!(info.dwFlags & 1)) info.wShowWindow = 1;\n" " if (!(info.dwFlags & 1)) info.wShowWindow = 1;\n"
" _ARGC = __wine_get_main_args( &_ARGV );\n" " _ARGC = __wine_main_argc;\n"
" _ARGV = __wine_main_argv;\n"
" ExitProcess( %s( GetModuleHandleA(0), 0, cmdline, info.wShowWindow ) );\n" " ExitProcess( %s( GetModuleHandleA(0), 0, cmdline, info.wShowWindow ) );\n"
"}\n\n", init_func, init_func ); "}\n\n", init_func, init_func );
init_func = "__wine_exe_main"; init_func = "__wine_exe_main";
...@@ -569,14 +571,16 @@ void BuildSpec32File( FILE *outfile ) ...@@ -569,14 +571,16 @@ void BuildSpec32File( FILE *outfile )
"extern void __stdcall ExitProcess(unsigned int);\n" "extern void __stdcall ExitProcess(unsigned int);\n"
"static void __wine_exe_main(void)\n" "static void __wine_exe_main(void)\n"
"{\n" "{\n"
" extern int __wine_get_wmain_args( WCHAR ***argv );\n" " extern int __wine_main_argc;\n"
" extern WCHAR **__wine_main_wargv;\n"
" STARTUPINFOA info;\n" " STARTUPINFOA info;\n"
" char *cmdline = GetCommandLineA();\n" " char *cmdline = GetCommandLineA();\n"
" while (*cmdline && *cmdline != ' ') cmdline++;\n" " while (*cmdline && *cmdline != ' ') cmdline++;\n"
" if (*cmdline) cmdline++;\n" " if (*cmdline) cmdline++;\n"
" GetStartupInfoA( &info );\n" " GetStartupInfoA( &info );\n"
" if (!(info.dwFlags & 1)) info.wShowWindow = 1;\n" " if (!(info.dwFlags & 1)) info.wShowWindow = 1;\n"
" _ARGC = __wine_get_wmain_args( &_ARGV );\n" " _ARGC = __wine_main_argc;\n"
" _ARGV = __wine_main_wargv;\n"
" ExitProcess( %s( GetModuleHandleA(0), 0, cmdline, info.wShowWindow ) );\n" " ExitProcess( %s( GetModuleHandleA(0), 0, cmdline, info.wShowWindow ) );\n"
"}\n\n", init_func, init_func ); "}\n\n", init_func, init_func );
init_func = "__wine_exe_main"; init_func = "__wine_exe_main";
...@@ -591,8 +595,10 @@ void BuildSpec32File( FILE *outfile ) ...@@ -591,8 +595,10 @@ void BuildSpec32File( FILE *outfile )
"static void __wine_exe_main(void)\n" "static void __wine_exe_main(void)\n"
"{\n" "{\n"
" extern int %s( int argc, char *argv[] );\n" " extern int %s( int argc, char *argv[] );\n"
" extern int __wine_get_main_args( char ***argv );\n" " extern int __wine_main_argc;\n"
" _ARGC = __wine_get_main_args( &_ARGV );\n" " extern char **__wine_main_argv;\n"
" _ARGC = __wine_main_argc;\n"
" _ARGV = __wine_main_argv;\n"
" ExitProcess( %s( _ARGC, _ARGV ) );\n" " ExitProcess( %s( _ARGC, _ARGV ) );\n"
"}\n\n", init_func, init_func ); "}\n\n", init_func, init_func );
init_func = "__wine_exe_main"; init_func = "__wine_exe_main";
...@@ -608,8 +614,10 @@ void BuildSpec32File( FILE *outfile ) ...@@ -608,8 +614,10 @@ void BuildSpec32File( FILE *outfile )
"static void __wine_exe_main(void)\n" "static void __wine_exe_main(void)\n"
"{\n" "{\n"
" extern int %s( int argc, WCHAR *argv[] );\n" " extern int %s( int argc, WCHAR *argv[] );\n"
" extern int __wine_get_wmain_args( WCHAR ***argv );\n" " extern int __wine_main_argc;\n"
" _ARGC = __wine_get_wmain_args( &_ARGV );\n" " extern WCHAR **__wine_main_wargv;\n"
" _ARGC = __wine_main_argc;\n"
" _ARGV = __wine_main_wargv;\n"
" ExitProcess( %s( _ARGC, _ARGV ) );\n" " ExitProcess( %s( _ARGC, _ARGV ) );\n"
"}\n\n", init_func, init_func ); "}\n\n", init_func, init_func );
init_func = "__wine_exe_main"; init_func = "__wine_exe_main";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment