Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for biosinfo.rex

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

  1. /* Initialize variables */
  2. rxCrLf = "0D0A"X
  3.  
  4. /* Check command line argument(s) */
  5. Parse Upper Arg mode
  6. If mode <> "" Then Do
  7. 	If mode = "DEBUG" Then debugmode = 1; Else Call Syntax
  8. End
  9.  
  10. /* Hide standard error */
  11. "@ECHO OFF"
  12. Trace Off
  13.  
  14. /* Get the manufacturer info from the BIOS */
  15. info = GetInfo( "FF00:0000", "FF00:0080" )
  16. If info = "" Then info = GetInfo( "FFF0:0000", "FFF0:0080" )
  17.  
  18. /* Display the result */
  19. Say
  20. Say "BIOS manufacturer :   "||info
  21.  
  22. /* Delete temporary DEBUG script */
  23. "DEL biosinfo.dbg >NUL 2>&1"
  24.  
  25. /* Create a new temporary DEBUG script to retrieve the BIOS date */
  26. Call CreateDbg "FFFF:0005 L 8"
  27.  
  28. /* Run DEBUG script and store output in variable */
  29. biosdate = ""
  30. address SYSTEM "DEBUG.EXE < biosinfo.dbg | RXQUEUE"
  31. Do i = 1 By 1 Until Queued( ) = 0
  32. 	Parse Pull dbgout
  33. 	/* Debugging info */
  34. 	If debugmode = 1 Then Say dbgout
  35. 	biosdate = biosdate||SubStr( dbgout, 67 )
  36. End
  37.  
  38. /* Display the result */
  39. Say "BIOS date         :   "||biosdate
  40.  
  41. /* Delete temporary DEBUG script */
  42. "DEL biosinfo.dbg >NUL 2>&1"
  43.  
  44. /* Normal program termination */
  45. Exit 0
  46.  
  47.  
  48.  
  49. /* Create temporary DEBUG script */
  50. CreateDbg:
  51. 	strDbg = "D "||Arg( 1 )||rxCrLf||"Q"||rxCrLf
  52. 	ret = LineOut( "biosinfo.dbg", strDbg )
  53. 	If ret <> 0 Then Call Error "Cannot create temporary debug script"
  54. 	ret = LineOut( "biosinfo.dbg" )
  55. Return
  56.  
  57.  
  58. /* Try to read relevant info from BIOS at specified address */
  59. GetInfo:
  60. 	/* Parse arguments */
  61. 	adr0 = Arg(1)
  62. 	adr1 = Arg(2)
  63.  
  64. 	/* Create temporary DEBUG script */
  65. 	Call CreateDbg adr0||rxCrLf||"D "||adr1
  66.  
  67. 	/* Run DEBUG script and concatenate output into a variable */
  68. 	address SYSTEM "DEBUG.EXE < biosinfo.dbg | RXQUEUE"
  69. 	line = ""
  70. 	Do Until Queued( ) = 0
  71. 		Parse Pull dbgout
  72. 		/* Debugging info */
  73. 		If debugmode = 1 Then Say dbgout
  74. 		line = line||SubStr( dbgout, 62 )
  75. 	End
  76.  
  77. 	/* Debugging info */
  78. 	If debugmode = 1 Then Say line
  79.  
  80. 	/* Remove irrelevant parts of resulting string */
  81. 	/* Modify minumum required length if necessary */
  82. 	minlength = 7
  83. 	newlength = 0
  84. 	newline   = line
  85. 	Do until newlength >= minlength
  86. 		Parse Value newline With string"."newline
  87. 		newlength = Length( string )
  88. 	End
  89. 	If newlength >= minlength Then line = string; Else line = ""
  90.  
  91. 	/* Strip whitespace */
  92. 	line = Strip( line )
  93.  
  94. 	/* Return the resulting string */
  95. Return line
  96.  
  97.  
  98.  
  99. Syntax: procedure
  100. 	Say
  101. 	Say "BIOSInfo.rex,  Version 1.00 for Windows & OS/2"
  102. 	Say "Display BIOS manufacturer and date"
  103. 	Say
  104. 	Say "Usage:  BIOSINFO.REX  [ DEBUG ]"
  105. 	Say
  106. 	Say 'Where:  "DEBUG" will display intermediate results for debugging purposes.'
  107. 	Say
  108. 	Say "This script uses DEBUG.EXE to read the information from BIOS."
  109. 	Say "Tested in Windows 2000 only."
  110. 	Say
  111. 	Say "Written by Rob van der Woude"
  112. 	Say "http://www.robvanderwoude.com"
  113. 	Say
  114. 	Say "Original idea for BIOS date by ComputerHope"
  115. 	Say "http://www.computerhope.com/rdebug.htm"
  116. 	Exit 1
  117. Return
  118.  

page last uploaded: 2017-04-06, 13:33