Adapted to use the argc/argv variables from libwine.
Automatically import libraries that contain the symbols that the .spec.c file is using.
This commit is contained in:
parent
702b158e70
commit
bf90f4db87
|
@ -241,7 +241,7 @@ static int remove_symbol_holes(void)
|
|||
static void add_extra_undef_symbols(void)
|
||||
{
|
||||
const char *extras[10];
|
||||
int i, count = 0;
|
||||
int i, count = 0, nb_stubs = 0, nb_regs = 0;
|
||||
|
||||
#define ADD_SYM(name) \
|
||||
do { if (!find_symbol( extras[count] = (name), undef_symbols, \
|
||||
|
@ -249,6 +249,13 @@ static void add_extra_undef_symbols(void)
|
|||
|
||||
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 */
|
||||
switch (SpecMode)
|
||||
{
|
||||
|
@ -260,7 +267,6 @@ static void add_extra_undef_symbols(void)
|
|||
ADD_SYM( "GetModuleHandleA" );
|
||||
/* fall through */
|
||||
case SPEC_MODE_CUIEXE:
|
||||
ADD_SYM( "__wine_get_main_args" );
|
||||
ADD_SYM( "ExitProcess" );
|
||||
break;
|
||||
case SPEC_MODE_GUIEXE_UNICODE:
|
||||
|
@ -269,26 +275,20 @@ static void add_extra_undef_symbols(void)
|
|||
ADD_SYM( "GetModuleHandleA" );
|
||||
/* fall through */
|
||||
case SPEC_MODE_CUIEXE_UNICODE:
|
||||
ADD_SYM( "__wine_get_wmain_args" );
|
||||
ADD_SYM( "ExitProcess" );
|
||||
break;
|
||||
}
|
||||
ADD_SYM( "RtlRaiseException" );
|
||||
if (nb_delayed)
|
||||
{
|
||||
ADD_SYM( "LoadLibraryA" );
|
||||
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++)
|
||||
{
|
||||
ORDDEF *odp = EntryPoints[i];
|
||||
if (odp->flags & FLAG_REGISTER)
|
||||
{
|
||||
ADD_SYM( "__wine_call_from_32_regs" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* make sure we import the dlls that contain these functions */
|
||||
if (SpecMode != SPEC_MODE_DLL || nb_delayed) add_import_dll( "kernel32", 0 );
|
||||
if (nb_delayed || nb_stubs || nb_regs) add_import_dll( "ntdll", 0 );
|
||||
|
||||
if (count)
|
||||
{
|
||||
|
|
|
@ -534,14 +534,16 @@ void BuildSpec32File( FILE *outfile )
|
|||
"extern void __stdcall ExitProcess(unsigned int);\n"
|
||||
"static void __wine_exe_main(void)\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"
|
||||
" char *cmdline = GetCommandLineA();\n"
|
||||
" while (*cmdline && *cmdline != ' ') cmdline++;\n"
|
||||
" if (*cmdline) cmdline++;\n"
|
||||
" GetStartupInfoA( &info );\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"
|
||||
"}\n\n", init_func, init_func );
|
||||
init_func = "__wine_exe_main";
|
||||
|
@ -569,14 +571,16 @@ void BuildSpec32File( FILE *outfile )
|
|||
"extern void __stdcall ExitProcess(unsigned int);\n"
|
||||
"static void __wine_exe_main(void)\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"
|
||||
" char *cmdline = GetCommandLineA();\n"
|
||||
" while (*cmdline && *cmdline != ' ') cmdline++;\n"
|
||||
" if (*cmdline) cmdline++;\n"
|
||||
" GetStartupInfoA( &info );\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"
|
||||
"}\n\n", init_func, init_func );
|
||||
init_func = "__wine_exe_main";
|
||||
|
@ -591,8 +595,10 @@ void BuildSpec32File( FILE *outfile )
|
|||
"static void __wine_exe_main(void)\n"
|
||||
"{\n"
|
||||
" extern int %s( int argc, char *argv[] );\n"
|
||||
" extern int __wine_get_main_args( char ***argv );\n"
|
||||
" _ARGC = __wine_get_main_args( &_ARGV );\n"
|
||||
" extern int __wine_main_argc;\n"
|
||||
" extern char **__wine_main_argv;\n"
|
||||
" _ARGC = __wine_main_argc;\n"
|
||||
" _ARGV = __wine_main_argv;\n"
|
||||
" ExitProcess( %s( _ARGC, _ARGV ) );\n"
|
||||
"}\n\n", init_func, init_func );
|
||||
init_func = "__wine_exe_main";
|
||||
|
@ -608,8 +614,10 @@ void BuildSpec32File( FILE *outfile )
|
|||
"static void __wine_exe_main(void)\n"
|
||||
"{\n"
|
||||
" extern int %s( int argc, WCHAR *argv[] );\n"
|
||||
" extern int __wine_get_wmain_args( WCHAR ***argv );\n"
|
||||
" _ARGC = __wine_get_wmain_args( &_ARGV );\n"
|
||||
" extern int __wine_main_argc;\n"
|
||||
" extern WCHAR **__wine_main_wargv;\n"
|
||||
" _ARGC = __wine_main_argc;\n"
|
||||
" _ARGV = __wine_main_wargv;\n"
|
||||
" ExitProcess( %s( _ARGC, _ARGV ) );\n"
|
||||
"}\n\n", init_func, init_func );
|
||||
init_func = "__wine_exe_main";
|
||||
|
|
Loading…
Reference in New Issue