Free delayed import modules on PROCESS_DETACH.

This commit is contained in:
Alexandre Julliard 2005-05-24 10:13:30 +00:00
parent c2b4bbef4f
commit 5ea0dd6d5f
3 changed files with 22 additions and 11 deletions

View File

@ -173,7 +173,7 @@ extern void add_delayed_import( const char *name );
extern void add_ignore_symbol( const char *name );
extern void read_undef_symbols( char **argv );
extern int resolve_imports( DLLSPEC *spec );
extern int output_imports( FILE *outfile, DLLSPEC *spec );
extern int output_imports( FILE *outfile, DLLSPEC *spec, int *nb_delayed );
extern int load_res32_file( const char *name, DLLSPEC *spec );
extern void output_resources( FILE *outfile, DLLSPEC *spec );
extern void load_res16_file( const char *name, DLLSPEC *spec );

View File

@ -532,6 +532,7 @@ static void add_extra_undef_symbols( const DLLSPEC *spec )
if (nb_delayed)
{
kernel_imports += add_extra_symbol( extras, &count, "LoadLibraryA", spec );
kernel_imports += add_extra_symbol( extras, &count, "FreeLibrary", spec );
kernel_imports += add_extra_symbol( extras, &count, "GetProcAddress", spec );
kernel_imports += add_extra_symbol( extras, &count, "RaiseException", spec );
}
@ -839,10 +840,10 @@ static int output_delayed_imports( FILE *outfile, const DLLSPEC *spec )
if (!nb_delayed) goto done;
fprintf( outfile, "static void *__wine_delay_imp_hmod[%d];\n", nb_delayed );
for (i = 0; i < nb_imports; i++)
{
if (!dll_imports[i]->delay) continue;
fprintf( outfile, "static void *__wine_delay_imp_%d_hmod;\n", i);
for (j = 0; j < dll_imports[i]->nb_imports; j++)
{
ORDDEF *odp = dll_imports[i]->imports[j];
@ -869,7 +870,7 @@ static int output_delayed_imports( FILE *outfile, const DLLSPEC *spec )
for (i = j = 0; i < nb_imports; i++)
{
if (!dll_imports[i]->delay) continue;
fprintf( outfile, " { 0, \"%s\", &__wine_delay_imp_%d_hmod, &delay_imports.IAT[%d], &delay_imports.INT[%d], 0, 0, 0 },\n",
fprintf( outfile, " { 0, \"%s\", &__wine_delay_imp_hmod[%d], &delay_imports.IAT[%d], &delay_imports.INT[%d], 0, 0, 0 },\n",
dll_imports[i]->spec->file_name, i, j, j );
j += dll_imports[i]->nb_imports;
}
@ -1140,8 +1141,8 @@ static int output_delayed_imports( FILE *outfile, const DLLSPEC *spec )
/* output the import and delayed import tables of a Win32 module
* returns number of DLLs exported in 'immediate' mode
*/
int output_imports( FILE *outfile, DLLSPEC *spec )
int output_imports( FILE *outfile, DLLSPEC *spec, int *nb_delayed )
{
output_delayed_imports( outfile, spec );
return output_immediate_imports( outfile );
*nb_delayed = output_delayed_imports( outfile, spec );
return output_immediate_imports( outfile );
}

View File

@ -461,7 +461,7 @@ void output_dll_init( FILE *outfile, const char *constructor, const char *destru
void BuildSpec32File( FILE *outfile, DLLSPEC *spec )
{
int exports_size = 0;
int nr_exports, nr_imports;
int nr_exports, nr_imports, nr_delayed;
DWORD page_size;
const char *init_func = spec->init_func;
@ -534,7 +534,7 @@ void BuildSpec32File( FILE *outfile, DLLSPEC *spec )
/* Output the DLL imports */
nr_imports = output_imports( outfile, spec );
nr_imports = output_imports( outfile, spec, &nr_delayed );
/* Output the resources */
@ -584,10 +584,20 @@ void BuildSpec32File( FILE *outfile, DLLSPEC *spec )
" if (reason == %d && __wine_spec_init_state == 1)\n"
" _init( __wine_main_argc, __wine_main_argv, __wine_main_environ );\n"
" ret = %s ? %s( inst, reason, reserved ) : 1;\n"
" if (reason == %d && __wine_spec_init_state == 1) _fini();\n"
" return ret;\n"
"}\n",
" if (reason == %d && __wine_spec_init_state == 1)\n",
DLL_PROCESS_ATTACH, init_func, init_func, DLL_PROCESS_DETACH );
if (!nr_delayed)
fprintf( outfile, " _fini();\n" );
else
fprintf( outfile,
" {\n"
" extern int __stdcall FreeLibrary(void *);\n"
" unsigned int i;\n"
" _fini();\n"
" for (i = 0; i < sizeof(__wine_delay_imp_hmod)/sizeof(__wine_delay_imp_hmod[0]); i++)\n"
" if (__wine_delay_imp_hmod[i]) FreeLibrary( __wine_delay_imp_hmod[i] );\n"
" }\n" );
fprintf( outfile, " return ret;\n}\n" );
init_func = "__wine_dll_main";
}
else switch(spec->subsystem)