3 # Script that generates a .DEF file for all objects in a directory
8 die "Usage: gendef.pl <modulepath>\n" unless ($ARGV[0] =~ /\\([^\\]+$)/);
11 if (-f
"$ARGV[0]/$defname.def")
13 print "Not re-generating $defname.DEF, file already exists.\n";
17 print "Generating $defname.DEF from directory $ARGV[0]\n";
19 while (<$ARGV[0]/*.obj
>)
22 $symfile=~ s/\.obj$/.sym/i;
24 system("dumpbin /symbols /out:symbols.out $_ >NUL") && die "Could not call dumpbin";
25 open(F
, "<symbols.out") || die "Could not open symbols.out for $_\n";
30 next unless $pieces[0] =~ /^[A-F0-9]{3,}$/;
31 next unless $pieces[6];
32 next if ($pieces[2] eq "UNDEF");
33 next unless ($pieces[4] eq "External");
34 next if $pieces[6] =~ /^@/;
35 next if $pieces[6] =~ /^\(/;
36 next if $pieces[6] =~ /^__real/;
37 next if $pieces[6] =~ /^__imp/;
38 next if $pieces[6] =~ /NULL_THUNK_DATA$/;
39 next if $pieces[6] =~ /^__IMPORT_DESCRIPTOR/;
40 next if $pieces[6] =~ /^__NULL_IMPORT/;
41 next if $pieces[6] =~ /^\?\?_C/;
43 push @def, $pieces[6];
46 rename("symbols.out",$symfile);
50 open(DEF
,">$ARGV[0]/$defname.def") || die "Could not write to $defname\n";
51 print DEF
"EXPORTS\n";
54 foreach my $f (sort @def)
56 next if ($f eq $last);
61 # print DEF " $f \@ $i\n"; # ordinaled exports?
65 print "Generated $i symbols\n";