Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for biosinfo.pl

(view source code of biosinfo.pl as plain text)

  1. #! perl
  2.  
  3. # Check command line argument(s)
  4. if ( $ARGV[0] ) {
  5. 	if ( $ARGV[0] =~ m/^DEBUG$/i ) {
  6. 		$debugmode = true;
  7. 	} else {
  8. 		Syntax();
  9. 	}
  10. }
  11.  
  12. # # # # # # # # # # # # # # # # # # # # # #
  13. # Get the manufacturer info from the BIOS #
  14. # # # # # # # # # # # # # # # # # # # # # #
  15. $info = getinfo( "FF00:0000", "FF00:0080" );
  16. if ( !$info ) {
  17. 	$info = getinfo( "FFF0:0000", "FFF0:0080" );
  18. }
  19.  
  20. # Display the result
  21. print "\nBIOS manufacturer :   $info\n";
  22.  
  23. # # # # # # # # # # #
  24. # Get the BIOS date #
  25. # # # # # # # # # # #
  26.  
  27. # Create a new temporary DEBUG script to retrieve the BIOS date
  28. createdbg( "FFFF:0005 L 8" );
  29.  
  30. # Run DEBUG script and filter output;
  31. # improved DEBUG output filtering by Uri "Talentix"
  32. `debug.exe < biosinfo.dbg` =~ /(\d\d\/\d\d\/\d\d)/;
  33. print "BIOS date         :   ".$1."\n";
  34.  
  35. # Delete temporary DEBUG script
  36. `DEL biosinfo.dbg >NUL 2>&1`;
  37.  
  38.  
  39. # Create temporary DEBUG script
  40. sub createdbg {
  41. 	my $dbg = "D @_[0]\nQ\n";
  42. 	open( DBGSCR, "> biosinfo.dbg" ) || die( "Cannot open temporary DEBUG script: $!" );
  43. 	print DBGSCR $dbg;
  44. 	close DBGSCR;
  45. }
  46.  
  47.  
  48. # Try to read relevant info from BIOS at specified address
  49. sub getinfo {
  50. 	# Parse arguments
  51. 	my $adr0 = @_[0];
  52. 	my $adr1 = @_[1];
  53.  
  54. 	# Create temporary DEBUG script
  55. 	createdbg( "$adr0\nD $adr1" );
  56.  
  57. 	# Run DEBUG script and store output in array
  58. 	my @biosdbg = `debug.exe < biosinfo.dbg`;
  59.  
  60. 	# Debugging info
  61. 	if ( $debugmode ) {
  62. 		foreach ( @biosdbg ) {
  63. 			print $_."\n";
  64. 		}
  65. 	}
  66.  
  67. 	# Concatenate relevant parts of screen output into one single line
  68. 	my $line = "";
  69. 	foreach ( @biosdbg ) {
  70. 		chomp $_;
  71. 		$line = $line.substr( $_, 61 );
  72. 		if ( $debugmode ) {
  73. 			print substr( $_, 61 )."\n";
  74. 		}
  75. 	}
  76.  
  77. 	# Debugging info
  78. 	if ( $debugmode ) {
  79. 		print "$line\n";
  80. 	}
  81.  
  82. 	# Use some regular expressions to tidy up the output before display
  83. 	# Modify the minimum required length of the resulting string if necessary
  84. 	my $minlength = 7;
  85. 	if ( $line =~ m/\.([^.!?\*\+]{$minlength,})\./ ) {
  86. 		$line = $1;
  87. 		while ( $line =~ m/\.([^.]+$line[^.]*)\./ ) {
  88. 			$line = $1;
  89. 		}
  90. 	} else {
  91. 		$line = "";
  92. 	}
  93.  
  94. 	# Strip leading whitespace
  95. 	$line =~ s/^\s+//;
  96.  
  97. 	# Return the resulting string
  98. 	return $line;
  99. }
  100.  
  101.  
  102. # Display help
  103. sub Syntax {
  104. 	print "\nBIOSInfo.pl,  Version 1.10 for DOS, Windows & OS/2\n",
  105. 	      "Display BIOS manufacturer and date\n\n",
  106. 	      "Usage:  BIOSINFO.PL  [ DEBUG ]\n\n",
  107. 	      "Where:  \"DEBUG\" will display intermediate ",
  108. 	      "results for debugging purposes.\n\n",
  109. 	      "This script uses DEBUG.EXE to read the information from BIOS.\n",
  110. 	      "Tested in Windows 2000 and XP only.\n\n",
  111. 	      "Written by Rob van der Woude\n",
  112. 	      "http://www.robvanderwoude.com\n\n",
  113. 	      "Improved DEBUG output filtering by Uri \"Talentix\"\n\n",
  114. 	      "Original idea for BIOS date by ComputerHope\n",
  115. 	      "http://www.computerhope.com/rdebug.htm\n\n\n";
  116. }
  117.  

page last modified: 2024-04-16; loaded in 0.0069 seconds