Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.9 KiB

  1. $VCBINDIR = "D:\\DevStudio\\VC\\Bin";
  2. $NONREDIST = "KERNEL32.DLL,GDI32.DLL,ADVAPI32.DLL,RPCRT4.DLL,MPR.DLL,OLE32.DLL,COMCTL32.DLL,USER32.DLL,NETAPI32.DLL,VERSION.DLL,COMDLG32.DLL";
  3. $numfiles = 0;
  4. $usage = 0;
  5. while ($_ = $ARGV[0], /.+/) {
  6. shift;
  7. last if /^--$/;
  8. /^[-|\/][\?|H]/i && ($usage = 1) ||
  9. /^[-|\/]F(.+)/i && ($outputfile = $1) ||
  10. /(.+)/ && ($imagefile[$numfiles++] = $1);
  11. }
  12. ($imagefile[0] && !$usage) || die "Usage: GetDeps.pl [-F<Output FileName>] <EXE or DLL image files>\n";
  13. if ( $outputfile ) {
  14. open (OUTFILE, ">$outputfile") || die "Error opening $outputfile: $!\n";
  15. }
  16. for ($index = 0; $index < $numfiles; $index++) {
  17. $nonredist_list = "";
  18. $redist_list = "";
  19. if ( $outputfile ) {
  20. print "$imagefile[$index]\n";
  21. }
  22. open (INPIPE, "$VCBINDIR\\DumpBin.exe /imports $imagefile[$index] |") ||
  23. print "Error running DumpBin.exe on $imagefile[$index]: $!\n" && next;
  24. while (<INPIPE>) {
  25. if ( /^\s+(\w+\.\w+)$/ ) {
  26. $depfile = $1;
  27. if ( $NONREDIST =~ /$depfile/i ) {
  28. if ( $nonredist_list ) {
  29. $nonredist_list = "$nonredist_list, $depfile";
  30. }
  31. else {
  32. $nonredist_list = "$depfile";
  33. }
  34. }
  35. else {
  36. if ( $redist_list ) {
  37. $redist_list = "$redist_list, $depfile";
  38. }
  39. else {
  40. $redist_list = "$depfile";
  41. }
  42. }
  43. }
  44. }
  45. close INPIPE;
  46. if ( $outputfile ) {
  47. print OUTFILE "\nDependencies for $imagefile[$index]:\n";
  48. ($nonredist_list) && print OUTFILE "Non-Redistributable: $nonredist_list\n";
  49. ($redist_list) && print OUTFILE "Redistributable: $redist_list\n";
  50. }
  51. else {
  52. print "\nDependencies for $imagefile[$index]:\n";
  53. ($nonredist_list) && print "Non-Redistributable: $nonredist_list\n";
  54. ($redist_list) && print "Redistributable: $redist_list\n";
  55. }
  56. }
  57. exit 0;