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.

558 lines
12 KiB

  1. ;-----------------------------------------------------------------------;
  2. ; ;
  3. ; Windows Critical Error Handler ;
  4. ; ;
  5. ;-----------------------------------------------------------------------;
  6. .xlist
  7. include kernel.inc
  8. include tdb.inc
  9. ifdef WOW
  10. include vint.inc
  11. endif
  12. .list
  13. DEVSTRC struc
  14. devLink dd ?
  15. devAttr dw ?
  16. devPtr1 dw ?
  17. devPtr2 dw ?
  18. devName db 8 dup (?)
  19. DEVSTRC ends
  20. IDABORT = 3
  21. IDRETRY = 4
  22. IDIGNORE = 5
  23. ;-----------------------------------------------------------------------;
  24. ; ;
  25. ; XENIX calls all return error codes through AX. If an error occurred ;
  26. ; then the carry bit will be set and the error code is in AX. ;
  27. ; If no error occurred then the carry bit is reset and AX contains ;
  28. ; returned info. ;
  29. ; ;
  30. ; Since the set of error codes is being extended as we extend the ;
  31. ; operating system, we have provided a means for applications to ask ;
  32. ; the system for a recommended course of action when they receive an ;
  33. ; error. ;
  34. ; ;
  35. ; The GetExtendedError system call returns a universal error, an error ;
  36. ; location and a recommended course of action. The universal error ;
  37. ; code is a symptom of the error REGARDLESS of the context in which ;
  38. ; GetExtendedError is issued. ;
  39. ; ;
  40. ; These are the universal int 24h mappings for the old INT 24 set of ;
  41. ; errors. ;
  42. ; ;
  43. ;-----------------------------------------------------------------------;
  44. error_write_protect EQU 19
  45. error_bad_unit EQU 20
  46. error_not_ready EQU 21
  47. error_bad_command EQU 22
  48. error_CRC EQU 23
  49. error_bad_length EQU 24
  50. error_Seek EQU 25
  51. error_not_DOS_disk EQU 26
  52. error_sector_not_found EQU 27
  53. error_out_of_paper EQU 28
  54. error_write_fault EQU 29
  55. error_read_fault EQU 30
  56. error_gen_failure EQU 31
  57. ; These are the new 3.0 error codes reported through INT 24h
  58. error_sharing_violation EQU 32
  59. error_lock_violation EQU 33
  60. error_wrong_disk EQU 34
  61. error_FCB_unavailable EQU 35
  62. ; New OEM network-related errors are 50-79
  63. error_not_supported EQU 50
  64. ; End of INT 24h reportable errors
  65. error_file_exists EQU 80
  66. error_DUP_FCB EQU 81 ; *****
  67. error_cannot_make EQU 82
  68. error_FAIL_I24 EQU 83
  69. ; New 3.0 network related error codes
  70. error_out_of_structures EQU 84
  71. error_Already_assigned EQU 85
  72. error_invalid_password EQU 86
  73. error_invalid_parameter EQU 87
  74. error_NET_write_fault EQU 88
  75. error_I24_write_protect EQU 0
  76. error_I24_bad_unit EQU 1
  77. error_I24_not_ready EQU 2
  78. error_I24_bad_command EQU 3
  79. error_I24_CRC EQU 4
  80. error_I24_bad_length EQU 5
  81. error_I24_Seek EQU 6
  82. error_I24_not_DOS_disk EQU 7
  83. error_I24_sector_not_found EQU 8
  84. error_I24_out_of_paper EQU 9
  85. error_I24_write_fault EQU 0Ah
  86. error_I24_read_fault EQU 0Bh
  87. error_I24_gen_failure EQU 0Ch
  88. ; NOTE: Code 0Dh is used by MT-DOS.
  89. error_I24_wrong_disk EQU 0Fh
  90. ; THE FOLLOWING ARE MASKS FOR THE AH REGISTER ON Int 24h
  91. Allowed_FAIL EQU 00001000b
  92. Allowed_RETRY EQU 00010000b
  93. Allowed_IGNORE EQU 00100000b
  94. ;NOTE: ABORT is ALWAYS allowed
  95. I24_operation EQU 00000001b ;Z if READ,NZ if Write
  96. I24_area EQU 00000110b ; 00 if DOS
  97. ; 01 if FAT
  98. ; 10 if root DIR
  99. DataBegin
  100. externB SysErr
  101. externB msgWriteProtect
  102. externB drvlet1
  103. externB msgCannotReadDrv
  104. externB drvlet2
  105. externB msgCannotWriteDrv
  106. externB drvlet3
  107. externB msgShare
  108. externB drvlet4
  109. externB msgNetError
  110. externB drvlet5
  111. externB msgCannotReadDev
  112. externB devenam1
  113. externB msgCannotWriteDev
  114. externB devenam2
  115. externB devenam3
  116. externB msgNetErrorDev
  117. externB msgNoPrinter
  118. externB OutBuf
  119. externB Kernel_Flags
  120. externB Kernel_InDOS
  121. externB Kernel_InINT24
  122. externB InScheduler
  123. externB cdevat
  124. externB errcap
  125. externB fNovell
  126. externB fDW_Int21h
  127. externW pGlobalHeap
  128. externW CurTDB
  129. ;externW MyCSDS
  130. externW LastExtendedError
  131. if 0; EarleH
  132. externW LastCriticalError
  133. endif ; 0
  134. externD pSErrProc
  135. externD InDOS
  136. fDialogShown db 0 ; NZ if end user sees dialog box
  137. if ROM
  138. externD prevInt21Proc
  139. endif
  140. DataEnd
  141. INT24STACK STRUC
  142. Int24_IP dw ?
  143. Int24_CS dw ?
  144. Int24_FG dw ?
  145. Int24_AX dw ?
  146. Int24_BX dw ?
  147. Int24_CX dw ?
  148. Int24_DX dw ?
  149. Int24_SI dw ?
  150. Int24_DI dw ?
  151. Int24_BP dw ?
  152. Int24_DS dw ?
  153. Int24_ES dw ?
  154. INT24STACK ENDS
  155. sBegin code
  156. assumes cs,code
  157. assumes ds,nothing
  158. assumes es,nothing
  159. ife ROM
  160. externD prevInt21Proc
  161. endif
  162. externNP AppendFirst
  163. externNP GetKernelDataSeg
  164. ;-----------------------------------------------------------------------;
  165. ; Int24Handler ;
  166. ; ;
  167. ; This is the default disk error handling code available to all ;
  168. ; users if they do not try to intercept interrupt 24h. ;
  169. ; The two options given the user are RETRY and FAIL. Retry goes back ;
  170. ; to DOS. If FAIL is chosen then for DOS 3.XX we return to DOS, but ;
  171. ; for DOS 2.XX we do the fail ourselves and return to the APP. ;
  172. ; ;
  173. ; Arguments: ;
  174. ; ;
  175. ; Returns: ;
  176. ; ;
  177. ; Error Returns: ;
  178. ; ;
  179. ; Registers Preserved: ;
  180. ; ;
  181. ; Registers Destroyed: ;
  182. ; ;
  183. ; Calls: ;
  184. ; ;
  185. ; History: ;
  186. ; ;
  187. ; Tue Feb 03, 1987 10:10:09p -by- David N. Weise [davidw] ;
  188. ; Removed the poking around in DOS by using Kernel_InDOS. ;
  189. ; ;
  190. ; Tue Jan 27, 1987 07:58:56p -by- David N. Weise [davidw] ;
  191. ; Added this nifty comment block. ;
  192. ;-----------------------------------------------------------------------;
  193. assumes ds, nothing
  194. assumes es, nothing
  195. cProc Int24Handler,<PUBLIC,NEAR>
  196. cBegin nogen
  197. push ds
  198. SetKernelDS
  199. mov fDialogShown, 0 ; Assume no dialog box
  200. inc InScheduler ; Prevent recursion
  201. cmp InScheduler,1 ; Well are we?
  202. jz NotInSched ; No, then handle this one
  203. jmp ReturnError ; Yes, return abort
  204. NotInSched:
  205. mov Kernel_InINT24,1
  206. FSTI
  207. cld
  208. push es
  209. push dx
  210. push cx
  211. push bx
  212. ; Save away the return capabilities mask.
  213. mov errcap,ah ; save the capabilities mask
  214. push di
  215. mov ds,bp
  216. UnSetKernelDS
  217. SetKernelDS es
  218. mov cx,[si].devAttr
  219. mov cdevat,ch
  220. mov di,dataOffset devenam1
  221. mov cx,8
  222. add si,devName ; pull up device name (even on block)
  223. push si
  224. rep movsb
  225. pop si
  226. mov di,dataOffset devenam2
  227. mov cl,8
  228. push si
  229. rep movsb
  230. pop si
  231. mov di,dataOffset devenam3
  232. mov cl,8
  233. rep movsb
  234. pop di
  235. SetKernelDS
  236. UnSetKernelDS es
  237. if 0; EarleH
  238. mov LastCriticalError, di
  239. endif
  240. add al,'A' ; compute drive letter (even on character)
  241. mov drvlet1,al
  242. mov drvlet2,al
  243. mov drvlet3,al
  244. mov drvlet4,al
  245. mov drvlet5,al
  246. ; At app exit time we will Ignore any critical errors. This is
  247. ; because errors that usually occur at app exit time are generally
  248. ; due to the network beeping death. Trying to put up the dialog
  249. ; hangs Windows because USER doesn't think the task exists any more.
  250. ; THIS IS AN INCREADABLE HACK!! We don'r really know if we can
  251. ; ignore all critical errors, but hey, nobodies complained yet.
  252. test Kernel_flags[2],KF2_WIN_EXIT ; prevent int 24h dialogs
  253. jz SetMsg
  254. xor ax,ax
  255. jmp eexit
  256. SetMsg: test ah,1
  257. jz ReadMes
  258. WriteMes:
  259. mov si,dataOffset msgCannotWriteDev
  260. test cdevat,10000000b
  261. jnz Gotmes
  262. mov si,dataOffset msgCannotWriteDrv
  263. jmps Gotmes
  264. ReadMes:
  265. mov si,dataOffset msgCannotReadDev
  266. test cdevat,10000000b
  267. jnz Gotmes
  268. mov si,dataOffset msgCannotReadDrv
  269. Gotmes:
  270. ; reach into DOS to get the extended error code
  271. ;;; les bx,InDOS
  272. ;;; mov ax,es:[bx].3
  273. push es ; DOS may trash these...
  274. push ds
  275. push si
  276. push di
  277. xor bx, bx
  278. mov ah, 59h
  279. pushf
  280. call prevInt21Proc
  281. mov LastExtendedError, ax
  282. mov LastExtendedError[2], bx
  283. mov LastExtendedError[4], cx
  284. pop di
  285. pop si
  286. pop ds
  287. pop es
  288. mov dx,dataOffset msgWriteProtect
  289. cmp ax,error_write_protect
  290. jz prmes ; Yes
  291. mov dx,dataOffset msgNoPrinter
  292. cmp al,error_out_of_paper
  293. jz prmes ; Yes
  294. mov dx,dataOffset msgShare
  295. cmp al,error_sharing_violation
  296. jz prmes ; Yes
  297. cmp al,error_lock_violation
  298. jz prmes ; Yes
  299. mov dx,dataOffset msgNetError
  300. test cdevat,10000000b
  301. jz check_net_error
  302. mov dx,dataOffset msgNetErrorDev
  303. check_net_error:
  304. cmp al,50
  305. jb not_net_error
  306. cmp al,80
  307. ja not_net_error
  308. test Kernel_Flags[2],KF2_APP_EXIT
  309. jz prmes
  310. jmps ReturnError
  311. not_net_error:
  312. mov dx,si ; Message in SI is correct
  313. prmes: call AppendFirst ; print error type
  314. mov es,curTDB ; Point to current task
  315. mov ax,es:[TDB_errMode] ; See if wants default error processing
  316. test al,1 ; Low-order bit = zero means
  317. jz ask ; ...put up dialog box
  318. mov al,2
  319. jmps eexit ; <> 0 means return error from call
  320. ask: mov es,pGlobalHeap
  321. inc es:[hi_freeze] ; freeze global heap
  322. call ShowDialogBox
  323. mov fDialogShown, dl ; will be 0 if dialog box NOT shown
  324. mov es,pGlobalHeap
  325. dec es:[hi_freeze] ; thaw global heap
  326. eexit: pop bx
  327. pop cx
  328. pop dx
  329. pop es
  330. cmp al,2 ; retry, ignore?
  331. jb aexit ; yes, return to dos
  332. cmp fNovell, 0
  333. je ReturnError ; Not NOVELL
  334. test errcap, Allowed_FAIL
  335. jnz ReturnError ; We CAN fail, so we do.
  336. push ax
  337. mov ax, di
  338. cmp al, 0Ch ; General failure
  339. pop ax
  340. jne ReturnError
  341. cmp word ptr devenam1[0], 'EN'
  342. jne ReturnError
  343. cmp word ptr devenam1[2], 'WT'
  344. jne ReturnError
  345. cmp word ptr devenam1[4], 'RO'
  346. jne ReturnError
  347. cmp word ptr devenam1[6], 'K'
  348. jne ReturnError
  349. mov al, 2 ; ABORT because NOVELL doesn't like FAIL
  350. jmps aexit
  351. ReturnError:
  352. mov al,3 ; change to return error code
  353. ; If the user canceled an error generated by the Int 21h to AUX: in kernel's
  354. ; DebugWrite routine, set a flag telling DebugWrite not to do that anymore.
  355. cmp fDialogShown, 0 ; Did end user see dialog box?
  356. jz not_krnl
  357. cmp fDW_Int21h, 0 ; fDW_Int21h will == 0 if caused by
  358. jnz not_krnl ; Int 21h/Write to AUX: in DebugWrite.
  359. mov fDW_Int21h, 2 ; Prevent DebugWrite from trying again
  360. not_krnl: ; (any value >= 2, <= 0FEh works)
  361. aexit: mov Kernel_InINT24,0
  362. dec InScheduler
  363. pop ds
  364. UnSetKernelDS ds
  365. FSTI
  366. iret
  367. cEnd nogen
  368. ;-----------------------------------------------------------------------;
  369. ; ShowDialogBox
  370. ;
  371. ;
  372. ; Entry:
  373. ;
  374. ; Returns:
  375. ;
  376. ; Registers Destroyed:
  377. ;
  378. ; History:
  379. ; Sat 02-Dec-1989 15:28:51 -by- David N. Weise [davidw]
  380. ; Removed the stack switching because of the new WinOldAp support,
  381. ; and added this nifty comment block.
  382. ;-----------------------------------------------------------------------;
  383. assumes ds,nothing
  384. assumes es,nothing
  385. cProc ShowDialogBox,<PUBLIC,NEAR>
  386. cBegin nogen
  387. CheckKernelDS
  388. ReSetKernelDS
  389. mov ax,3 ; assume no USER therefor CANCEL
  390. xor dx, dx
  391. cmp pSErrProc.sel,0 ; is there a USER yet?
  392. jz sdb_exit
  393. push bp
  394. xor bp,bp
  395. push bp
  396. mov bp,sp
  397. push ds
  398. mov ax,dataOffset OutBuf ; lpText
  399. push ax
  400. push ds
  401. mov ax,dataOffset SysErr ; lpCaption
  402. push ax
  403. ; Set up the buttons based on the capabilities mask. Cancel is always
  404. ; availible. Retry and Ignore are not always available.
  405. mov ax,SEB_CANCEL+SEB_DEFBUTTON ; cancel is always allowed
  406. push ax
  407. xor ax,ax ; assume no second button
  408. if 0 ; 05 feb 1990, ignoring is not user friendly, win 2.x did not allow it
  409. test errcap,20h ; is ignore allowed?
  410. jz button_2
  411. mov ax,SEB_IGNORE ; ignore is the second button
  412. endif
  413. button_2:
  414. push ax
  415. xor ax,ax ; assume no third button
  416. test errcap,10h ; is retry allowed?
  417. jz button_3
  418. mov ax,SEB_RETRY ; retry is the third button
  419. button_3:
  420. push ax
  421. dobox:
  422. call [pSErrProc] ; USER.SysErrorBox()
  423. mov dx, ax
  424. ; We need to map the return as follows:
  425. ; button 1 (Cancel) => 3 3
  426. ; button 2 (Retry) => 1 0
  427. ; button 3 (Ignore) => 0 1
  428. sub al,2
  429. jnb codeok
  430. mov al,3
  431. codeok:
  432. pop bp
  433. pop bp
  434. sdb_exit:
  435. ret
  436. cEnd nogen
  437. ;-----------------------------------------------------------------------;
  438. ; GetLPErrMode ;
  439. ; ;
  440. ; This routine returns a long pointer to the Kernel_InDOS and ;
  441. ; Kernel_InINT24 bytes inside the KERNEL. It is used by 386 WINOLDAP ;
  442. ; to prevent switching while inside INT 24 errors from other VMs. ;
  443. ; ;
  444. ; NOTE: Do not change this call without talking to the WIN/386 group. ;
  445. ; NOTE: USER also uses this call to determine whether PostMessage ;
  446. ; can call FatalExit. ;
  447. ; ;
  448. ; Arguments: ;
  449. ; none ;
  450. ; ;
  451. ; Returns: ;
  452. ; DX:AX = pointer to Kernel_InDOS followed by Kernel_InINT24 ;
  453. ; ;
  454. ; Error Returns: ;
  455. ; ;
  456. ; Registers Preserved: ;
  457. ; all ;
  458. ; ;
  459. ; Registers Destroyed: ;
  460. ; ;
  461. ; Calls: ;
  462. ; ;
  463. ; History: ;
  464. ; ;
  465. ; Tue Jan 27, 1987 07:13:27p -by- David N. Weise [davidw] ;
  466. ; Rewrote it and added this nifty comment block. ;
  467. ; ;
  468. ; 7/23/87 -by- Arron Reynolds [aaronr], updated comments to desired ;
  469. ; state. ;
  470. ;-----------------------------------------------------------------------;
  471. assumes ds,nothing
  472. assumes es,nothing
  473. cProc GetLPErrMode,<PUBLIC,FAR>
  474. cBegin nogen
  475. call GetKernelDataSeg
  476. mov dx, ax
  477. mov ax,dataOffset Kernel_InDOS
  478. ret
  479. cEnd nogen
  480. sEnd code
  481. end