HARDERR.ASM 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. ;
  2. ; Command & Conquer Red Alert(tm)
  3. ; Copyright 2025 Electronic Arts Inc.
  4. ;
  5. ; This program is free software: you can redistribute it and/or modify
  6. ; it under the terms of the GNU General Public License as published by
  7. ; the Free Software Foundation, either version 3 of the License, or
  8. ; (at your option) any later version.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ;
  18. ;***************************************************************************
  19. ;** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
  20. ;***************************************************************************
  21. ;* *
  22. ;* Project Name : Hard/Critical Error Handler *
  23. ;* *
  24. ;* File Name : harderr.asm *
  25. ;* *
  26. ;* Programmer : Scott K. Bowen. *
  27. ;* *
  28. ;* Start Date : July 18, 1994 *
  29. ;* *
  30. ;* Last Update : July 26, 1994 [SKB] *
  31. ;* *
  32. ;*-------------------------------------------------------------------------*
  33. ;* Functions: *
  34. ;* Install_Hard_Error_Handler -- Setup for handling critical errors *
  35. ;* Remove_Hard_Erroror_Handler -- Remove the critical error handler stuff*
  36. ;* Critical_Error_Handler -- Catch critical error interrupt. *
  37. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  38. IDEAL
  39. P386
  40. MODEL USE32 FLAT
  41. LOCALS ??
  42. ;INCLUDE "tntdos.inc"
  43. ;//////////////////////////////////////////////////////////////////////////////////////
  44. ;///////////////////////////////////// Equates ////////////////////////////////////////
  45. DOS_SYS_CALL EQU 21h ; to do TNT DOS-XNDR system calls.
  46. LOCK_PAGES EQU 5 ; Lock pages subfunction using DX_MEM_MGT
  47. UNLOCK_PAGES EQU 6 ; Unlock pages subfunction using DX_MEM_MGT
  48. CRITERR_INT_NUM EQU 24h
  49. DISK_ERROR_BIT EQU 01000000000000000b ; bit 7 of dh.
  50. DISK_ERROR EQU 1 ; Value of Hard_Error_Occured if disk/floppy error.
  51. OTHER_ERROR EQU 2 ; Value of Hard_Error_Occured if other type of error.
  52. ;
  53. ; Interrupt handler stack frame
  54. ;
  55. _FLGS equ [DWORD PTR ebp+52] ; 386|DOS-Extender flags
  56. _GS equ [WORD PTR ebp+48] ; original GS
  57. _FS equ [WORD PTR ebp+44] ; original FS
  58. _DS equ [WORD PTR ebp+40] ; original DS
  59. _ES equ [WORD PTR ebp+36] ; original ES
  60. _SS equ [WORD PTR ebp+32] ; original SS
  61. _ESP equ [DWORD PTR ebp+28] ; original ESP
  62. _EFLAGS equ [DWORD PTR ebp+24] ; original EFLAGS
  63. _CS equ [DWORD PTR ebp+20] ; original CS
  64. _EIP equ [DWORD PTR ebp+16] ; original EIP
  65. _EBP equ [DWORD PTR ebp] ; original EBP
  66. ;
  67. ; DOS critical error stack frame
  68. ;
  69. _DOS_FLAGS equ [WORD PTR es:ebx+22] ; interrupt stack frame from real
  70. _DOS_CS equ [WORD PTR es:ebx+20] ; mode INT 21h
  71. _DOS_IP equ [WORD PTR es:ebx+18] ;
  72. _DOS_ES equ [WORD PTR es:ebx+16] ; regs at time INT 21h was issued
  73. _DOS_DS equ [WORD PTR es:ebx+14] ; in real mode
  74. _DOS_BP equ [WORD PTR es:ebx+12] ;
  75. _DOS_DI equ [WORD PTR es:ebx+10] ;
  76. _DOS_SI equ [WORD PTR es:ebx+8] ;
  77. _DOS_DX equ [WORD PTR es:ebx+6] ;
  78. _DOS_CX equ [WORD PTR es:ebx+4] ;
  79. _DOS_BX equ [WORD PTR es:ebx+2] ;
  80. _DOS_AX equ [WORD PTR es:ebx] ;
  81. ;
  82. ; Error codes put into Hard_Error_Code
  83. ;
  84. DISK_WRITE_PROTECTED equ 00h
  85. UNKOWN_DEVICE equ 01h
  86. DRIVE_NOT_READY equ 02h
  87. UNKOWN_COMMAND equ 03h
  88. CRC_ERROR equ 04h
  89. WRONG_DATA_LENGTH equ 05h
  90. SEEK_ERROR equ 06h
  91. UNKOWN_DEVICE_TYPE equ 07h
  92. SECTOR_NOT_FOUND equ 08h
  93. OUT_OF_PAPER equ 09h
  94. WRITE_ERROR equ 0Ah
  95. READ_ERROR equ 0Bh
  96. GENERAL_ERROR equ 0Ch
  97. ;//////////////////////////////////////////////////////////////////////////////////////
  98. ;/////////////////////////////////// Prototypes ///////////////////////////////////////
  99. GLOBAL Install_Hard_Error_Handler :NEAR
  100. GLOBAL Remove_Hard_Error_Handler :NEAR
  101. ;//////////////////////////////////////////////////////////////////////////////////////
  102. ;///////////////////////////////// Global/Local Data //////////////////////////////////
  103. DATASEG
  104. LABEL LockedDataStart BYTE
  105. Hard_Error_Occured DB 0 ; Hard disk error or other error.
  106. Hard_Error_Code DB 0 ; Error Code.
  107. LABEL LockedDataEnd BYTE
  108. OldRMI DD ? ; original real mode critical err vector
  109. OldPMIOffset DD ? ; original protected mode critical err vector
  110. OldPMISelector DD ? ; original PM crit error selector.
  111. InitFlags DD 0 ; Flags to indicate what has been initialized.
  112. ; InitFlags that are set to have a fully functional interrupt.
  113. IF_SET_VECTORS equ 1 ; Vectors have been set.
  114. IF_LOCKED_PM_CODE equ 2 ; Locked PM code for DPMI.
  115. IF_LOCKED_PM_DATA equ 4 ; Locked PM data for DPMI.
  116. IF_FUNCTIONAL equ 8 ; crit error is in and functional.
  117. ;//////////////////////////////////////////////////////////////////////////////////////
  118. ;///////////////////////////////////// Code //////////////////////////////////////////
  119. CODESEG
  120. ;***************************************************************************
  121. ;* INSTALL_HARD_ERROR_HANDLER -- Setup for handling critical errors. *
  122. ;* *
  123. ;* *
  124. ;* *
  125. ;* INPUT: *
  126. ;* *
  127. ;* OUTPUT: *
  128. ;* *
  129. ;* WARNINGS: *
  130. ;* *
  131. ;* HISTORY: *
  132. ;* 07/26/1994 SKB : Created. *
  133. ;*=========================================================================*
  134. PROC Install_Hard_Error_Handler C near
  135. USES eax,ebx,ecx,ds,es
  136. ret
  137. ENDP Install_Hard_Error_Handler
  138. ;***************************************************************************
  139. ;* REMOVE_HARD_ERROROR_HANDLER -- Remove the critical error handler stuff *
  140. ;* *
  141. ;* *
  142. ;* *
  143. ;* INPUT: *
  144. ;* *
  145. ;* OUTPUT: *
  146. ;* *
  147. ;* WARNINGS: *
  148. ;* *
  149. ;* HISTORY: *
  150. ;* 07/26/1994 SKB : Created. *
  151. ;*=========================================================================*
  152. PROC Remove_Hard_Error_Handler C near
  153. USES ebx,ecx,edx,ds,es
  154. ;
  155. ; Restore the original interrupt vectors and exit
  156. ;
  157. ret
  158. ENDP Remove_Hard_Error_Handler
  159. ;***************************************************************************
  160. ;* Critical_Error_Handler -- Catch critical error interrupt. *
  161. ;* *
  162. ;* *
  163. ;* *
  164. ;* INPUT: *
  165. ;* *
  166. ;* OUTPUT: *
  167. ;* *
  168. ;* WARNINGS: *
  169. ;* *
  170. ;* HISTORY: *
  171. ;* 07/26/1994 SKB : Created. *
  172. ;*=========================================================================*
  173. LABEL LockedCodeStart BYTE
  174. PROC Critical_Error_Handler NEAR
  175. ENDP Critical_Error_Handler
  176. LABEL LockedCodeEnd BYTE
  177. END
  178.