Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for biosinfo2.rex

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

  1. /* BIOSinfo.rex                                                   */
  2. /* This version uses Patrick TJ McPhee's Rexx Regular Expressions */
  3.  
  4. /* Display empty line */
  5. Say
  6.  
  7. /* Check command line argument(s) */
  8. Parse Upper Arg dbgarg .
  9. If dbgarg = "" Then Do
  10. 	debugmode = 0
  11. End
  12. Else Do
  13. 	If dbgarg = "DEBUG" Then Do
  14. 		debugmode = 1
  15. 	End
  16. 	Else Do
  17. 		Call Syntax
  18. 	End
  19. End
  20.  
  21. /* Hide standard error */
  22. "@ECHO OFF"
  23. Trace Off
  24.  
  25. /* Initialize libraries */
  26. If RxFuncQuery( "sysloadfuncs" ) Then Do
  27. 	free_ru = 1
  28. 	Call RxFuncAdd "sysloadfuncs", "RexxUtil", "sysloadfuncs"
  29. 	If sysloadfuncs() Then Call Syntax
  30. End
  31. If RxFuncQuery( "ReLoadFuncs" ) Then Do
  32. 	free_re = 1
  33. 	Call RxFuncAdd "ReLoadFuncs", "RexxRE", "ReLoadFuncs"
  34. 	If ReLoadFuncs() Then Call Syntax
  35. End
  36.  
  37. /* Define temporary file name and location */
  38. Parse Source . . self
  39. fles   = Reverse( self )
  40. dbgscr = Reverse( SubStr( fles, Pos( ".", fles ) + 1 ) )||".dbg"
  41.  
  42. /* Get the manufacturer info from the BIOS */
  43. info = GetInfo( "FF00:0000", "FF00:0080" )
  44. If info = "" Then info = GetInfo( "FFF0:0000", "FFF0:0080" )
  45. info = Strip( info )
  46.  
  47. /* Display the result */
  48. Say "BIOS manufacturer :   "||info
  49.  
  50.  
  51. /* Get the BIOS date */
  52.  
  53. /* Create a new temporary DEBUG script to retrieve the BIOS date */
  54. Call CreateDbg "FFFF:0005 L 8"
  55.  
  56. /* Run DEBUG script and store output in array */
  57. "DEBUG.EXE < "||dbgscr||" | RXQUEUE"
  58. Do i = 1 By 1 Until Queued( ) = 0
  59. 	Parse Pull dbgout.i
  60. 	/* Debugging info */
  61. 	If debugmode = 1 Then Say dbgout.i
  62. 	biosstr = biosstr||SubStr( dbgout.i, 62 )
  63. End
  64. dbgout.0 = i
  65.  
  66. If debugmode = 1 Then Do i = 1 To dbgout.0
  67. 	Say SubStr( dbgout.i, 62 )
  68. End
  69.  
  70. /* Cut first 66 characters from each line (effectively skipping */
  71. /* all lines but one) and store the remainders in a variable    */
  72. biosdate = ""
  73. Do i = 1 To dbgout.0
  74. 	biosdate = biosdate||Strip( SubStr( dbgout.i, 66 ) )
  75. End
  76.  
  77. /* Display the result */
  78. Say "BIOS date         :   "||biosdate
  79.  
  80. /* Delete temporary DEBUG script */
  81. Call SysFileDelete dbgscr
  82.  
  83. /* Unload libraries */
  84. if free_re = 1 Then Call ReDropFuncs
  85. if free_ru = 1 Then Call SysDropFuncs
  86.  
  87. Exit 0
  88.  
  89.  
  90. /* Try to read relevant info from BIOS at specified address */
  91. GetInfo: procedure expose dbgscr debugmode
  92. 	/* Parse arguments */
  93. 	adr0 = Arg(1)
  94. 	adr1 = Arg(2)
  95.  
  96. 	/* Create temporary DEBUG script */
  97. 	Call CreateDbg "FF00:0000", "FF00:0080"
  98.  
  99. 	/* Run DEBUG script and store output in array */
  100. 	"DEBUG.EXE < "||dbgscr||" | RXQUEUE"
  101. 	Do i = 1 By 1 Until Queued( ) = 0
  102. 		Parse Pull dbgout.i
  103. 		/* Debugging info */
  104. 		If debugmode = 1 Then Say dbgout.i
  105. 		biosstr = biosstr||SubStr( dbgout.i, 62 )
  106. 	End
  107. 	dbgout.0 = i
  108.  
  109. 	If debugmode = 1 Then Do i = 1 To dbgout.0
  110. 		Say SubStr( dbgout.i, 62 )
  111. 	End
  112.  
  113. 	/* Concatenate relevant parts of screen output into one single line */
  114. 	line = "";
  115. 	Do i = 1 To dbgout.0
  116. 		line = line||SubStr( dbgout.i, 62 )
  117. 		If debugmode = 1 Then Say SubStr( dbgout.i, 62 )
  118. 	End
  119.  
  120. 	/* Debugging info */
  121. 	If debugmode = 1 Then Say line
  122.  
  123. 	/* Use some regular expressions to tidy up the output before display */
  124. 	/* Modify required minimum length of resulting string if necessary   */
  125. 	minlen = 7
  126. 	re     = "\.([^.!?\*\+]{"||minlen||",})\."
  127. 	cre    = ReComp( re, "x" )
  128. 	If Left( cre, 1 ) Then Do
  129. 		errstr = "Error compiling regular expression"
  130. 		errstr = errstr||rxCrLf||ReError( cre )
  131. 		Call Syntax errstr
  132. 	End
  133. 	If ReExec( cre, line, matches ) Then line = matches.1
  134.  
  135. 	/* Clear memory */
  136. 	Call ReFree cre
  137.  
  138. 	/* Debugging info */
  139. 	If debugmode = 1 Then Do i = 1 To matches.0
  140. 		Say matches.i
  141. 	End
  142.  
  143. 	/* Return the resulting string */
  144. Return line
  145.  
  146.  
  147. /* Create temporary DEBUG script */
  148. CreateDbg: procedure expose dbgscr debugmode
  149. 	Call SysFileDelete dbgscr
  150. 	rxCrLf = "0D0A"X
  151. 	strdbg = "D "||Arg(1)||rxCrLf
  152. 	If Arg( 2, "E" ) Then strdbg = strdbg||"D "||Arg(2)||rxCrLf
  153. 	strdbg = strdbg||"Q"||rxCrLf
  154. 	ret = LineOut( dbgscr, strdbg )
  155. 	If ret <> 0 Then Call Syntax "Cannot create temporary debug script"
  156. 	ret = LineOut( dbgscr )
  157. 	If ret <> 0 Then Call Syntax "Error closing temporary debug script"
  158. Return
  159.  
  160.  
  161. Syntax: procedure
  162. 	Say "BIOSInfo.rex,  Version 2.00 for Windows and OS/2"
  163. 	Say "Display BIOS manufacturer and date"
  164. 	Say
  165. 	Say "Usage:  BIOSINFO.REX  [ DEBUG ]"
  166. 	Say
  167. 	Say 'Where:  "DEBUG" will display intermediate results for debugging purposes.'
  168. 	Say
  169. 	Say "This script uses DEBUG.EXE to read the information from BIOS, and Patrick TJ"
  170. 	Say "McPhee's Rexx Regular Expressions library (http://www.interlog.com/~ptjm/)."
  171. 	Say "Tested in Windows 2000 and XP only."
  172. 	Say
  173. 	Say "Written by Rob van der Woude"
  174. 	Say "http://www.robvanderwoude.com"
  175. 	Say
  176. 	Say "Original idea BIOS date: ComputerHope http://www.computerhope.com/rdebug.htm"
  177. 	Exit 1
  178. Return
  179.  

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