Leaked source code of windows server 2003
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.

553 lines
13 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. DataEnd
  138. INT24STACK STRUC
  139. Int24_IP dw ?
  140. Int24_CS dw ?
  141. Int24_FG dw ?
  142. Int24_AX dw ?
  143. Int24_BX dw ?
  144. Int24_CX dw ?
  145. Int24_DX dw ?
  146. Int24_SI dw ?
  147. Int24_DI dw ?
  148. Int24_BP dw ?
  149. Int24_DS dw ?
  150. Int24_ES dw ?
  151. INT24STACK ENDS
  152. sBegin code
  153. assumes cs,code
  154. assumes ds,nothing
  155. assumes es,nothing
  156. externD prevInt21Proc
  157. externNP AppendFirst
  158. externNP GetKernelDataSeg
  159. ;-----------------------------------------------------------------------;
  160. ; Int24Handler ;
  161. ; ;
  162. ; This is the default disk error handling code available to all ;
  163. ; users if they do not try to intercept interrupt 24h. ;
  164. ; The two options given the user are RETRY and FAIL. Retry goes back ;
  165. ; to DOS. If FAIL is chosen then for DOS 3.XX we return to DOS, but ;
  166. ; for DOS 2.XX we do the fail ourselves and return to the APP. ;
  167. ; ;
  168. ; Arguments: ;
  169. ; ;
  170. ; Returns: ;
  171. ; ;
  172. ; Error Returns: ;
  173. ; ;
  174. ; Registers Preserved: ;
  175. ; ;
  176. ; Registers Destroyed: ;
  177. ; ;
  178. ; Calls: ;
  179. ; ;
  180. ; History: ;
  181. ; ;
  182. ; Tue Feb 03, 1987 10:10:09p -by- David N. Weise [davidw] ;
  183. ; Removed the poking around in DOS by using Kernel_InDOS. ;
  184. ; ;
  185. ; Tue Jan 27, 1987 07:58:56p -by- David N. Weise [davidw] ;
  186. ; Added this nifty comment block. ;
  187. ;-----------------------------------------------------------------------;
  188. assumes ds, nothing
  189. assumes es, nothing
  190. cProc Int24Handler,<PUBLIC,NEAR>
  191. cBegin nogen
  192. push ds
  193. SetKernelDS
  194. mov fDialogShown, 0 ; Assume no dialog box
  195. inc InScheduler ; Prevent recursion
  196. cmp InScheduler,1 ; Well are we?
  197. jz NotInSched ; No, then handle this one
  198. jmp ReturnError ; Yes, return abort
  199. NotInSched:
  200. mov Kernel_InINT24,1
  201. FSTI
  202. cld
  203. push es
  204. push dx
  205. push cx
  206. push bx
  207. ; Save away the return capabilities mask.
  208. mov errcap,ah ; save the capabilities mask
  209. push di
  210. mov ds,bp
  211. UnSetKernelDS
  212. SetKernelDS es
  213. mov cx,[si].devAttr
  214. mov cdevat,ch
  215. mov di,dataOffset devenam1
  216. mov cx,8
  217. add si,devName ; pull up device name (even on block)
  218. push si
  219. rep movsb
  220. pop si
  221. mov di,dataOffset devenam2
  222. mov cl,8
  223. push si
  224. rep movsb
  225. pop si
  226. mov di,dataOffset devenam3
  227. mov cl,8
  228. rep movsb
  229. pop di
  230. SetKernelDS
  231. UnSetKernelDS es
  232. if 0; EarleH
  233. mov LastCriticalError, di
  234. endif
  235. add al,'A' ; compute drive letter (even on character)
  236. mov drvlet1,al
  237. mov drvlet2,al
  238. mov drvlet3,al
  239. mov drvlet4,al
  240. mov drvlet5,al
  241. ; At app exit time we will Ignore any critical errors. This is
  242. ; because errors that usually occur at app exit time are generally
  243. ; due to the network beeping death. Trying to put up the dialog
  244. ; hangs Windows because USER doesn't think the task exists any more.
  245. ; THIS IS AN INCREADABLE HACK!! We don'r really know if we can
  246. ; ignore all critical errors, but hey, nobodies complained yet.
  247. test Kernel_flags[2],KF2_WIN_EXIT ; prevent int 24h dialogs
  248. jz SetMsg
  249. xor ax,ax
  250. jmp eexit
  251. SetMsg: test ah,1
  252. jz ReadMes
  253. WriteMes:
  254. mov si,dataOffset msgCannotWriteDev
  255. test cdevat,10000000b
  256. jnz Gotmes
  257. mov si,dataOffset msgCannotWriteDrv
  258. jmps Gotmes
  259. ReadMes:
  260. mov si,dataOffset msgCannotReadDev
  261. test cdevat,10000000b
  262. jnz Gotmes
  263. mov si,dataOffset msgCannotReadDrv
  264. Gotmes:
  265. ; reach into DOS to get the extended error code
  266. ;;; les bx,InDOS
  267. ;;; mov ax,es:[bx].3
  268. push es ; DOS may trash these...
  269. push ds
  270. push si
  271. push di
  272. xor bx, bx
  273. mov ah, 59h
  274. pushf
  275. call prevInt21Proc
  276. mov LastExtendedError, ax
  277. mov LastExtendedError[2], bx
  278. mov LastExtendedError[4], cx
  279. pop di
  280. pop si
  281. pop ds
  282. pop es
  283. mov dx,dataOffset msgWriteProtect
  284. cmp ax,error_write_protect
  285. jz prmes ; Yes
  286. mov dx,dataOffset msgNoPrinter
  287. cmp al,error_out_of_paper
  288. jz prmes ; Yes
  289. mov dx,dataOffset msgShare
  290. cmp al,error_sharing_violation
  291. jz prmes ; Yes
  292. cmp al,error_lock_violation
  293. jz prmes ; Yes
  294. mov dx,dataOffset msgNetError
  295. test cdevat,10000000b
  296. jz check_net_error
  297. mov dx,dataOffset msgNetErrorDev
  298. check_net_error:
  299. cmp al,50
  300. jb not_net_error
  301. cmp al,80
  302. ja not_net_error
  303. test Kernel_Flags[2],KF2_APP_EXIT
  304. jz prmes
  305. jmps ReturnError
  306. not_net_error:
  307. mov dx,si ; Message in SI is correct
  308. prmes: call AppendFirst ; print error type
  309. mov es,curTDB ; Point to current task
  310. mov ax,es:[TDB_errMode] ; See if wants default error processing
  311. test al,1 ; Low-order bit = zero means
  312. jz ask ; ...put up dialog box
  313. mov al,2
  314. jmps eexit ; <> 0 means return error from call
  315. ask: mov es,pGlobalHeap
  316. inc es:[hi_freeze] ; freeze global heap
  317. call ShowDialogBox
  318. mov fDialogShown, dl ; will be 0 if dialog box NOT shown
  319. mov es,pGlobalHeap
  320. dec es:[hi_freeze] ; thaw global heap
  321. eexit: pop bx
  322. pop cx
  323. pop dx
  324. pop es
  325. cmp al,2 ; retry, ignore?
  326. jb aexit ; yes, return to dos
  327. cmp fNovell, 0
  328. je ReturnError ; Not NOVELL
  329. test errcap, Allowed_FAIL
  330. jnz ReturnError ; We CAN fail, so we do.
  331. push ax
  332. mov ax, di
  333. cmp al, 0Ch ; General failure
  334. pop ax
  335. jne ReturnError
  336. cmp word ptr devenam1[0], 'EN'
  337. jne ReturnError
  338. cmp word ptr devenam1[2], 'WT'
  339. jne ReturnError
  340. cmp word ptr devenam1[4], 'RO'
  341. jne ReturnError
  342. cmp word ptr devenam1[6], 'K'
  343. jne ReturnError
  344. mov al, 2 ; ABORT because NOVELL doesn't like FAIL
  345. jmps aexit
  346. ReturnError:
  347. mov al,3 ; change to return error code
  348. ; If the user canceled an error generated by the Int 21h to AUX: in kernel's
  349. ; DebugWrite routine, set a flag telling DebugWrite not to do that anymore.
  350. cmp fDialogShown, 0 ; Did end user see dialog box?
  351. jz not_krnl
  352. cmp fDW_Int21h, 0 ; fDW_Int21h will == 0 if caused by
  353. jnz not_krnl ; Int 21h/Write to AUX: in DebugWrite.
  354. mov fDW_Int21h, 2 ; Prevent DebugWrite from trying again
  355. not_krnl: ; (any value >= 2, <= 0FEh works)
  356. aexit: mov Kernel_InINT24,0
  357. dec InScheduler
  358. pop ds
  359. UnSetKernelDS ds
  360. FSTI
  361. iret
  362. cEnd nogen
  363. ;-----------------------------------------------------------------------;
  364. ; ShowDialogBox
  365. ;
  366. ;
  367. ; Entry:
  368. ;
  369. ; Returns:
  370. ;
  371. ; Registers Destroyed:
  372. ;
  373. ; History:
  374. ; Sat 02-Dec-1989 15:28:51 -by- David N. Weise [davidw]
  375. ; Removed the stack switching because of the new WinOldAp support,
  376. ; and added this nifty comment block.
  377. ;-----------------------------------------------------------------------;
  378. assumes ds,nothing
  379. assumes es,nothing
  380. cProc ShowDialogBox,<PUBLIC,NEAR>
  381. cBegin nogen
  382. CheckKernelDS
  383. ReSetKernelDS
  384. mov ax,3 ; assume no USER therefor CANCEL
  385. xor dx, dx
  386. cmp pSErrProc.sel,0 ; is there a USER yet?
  387. jz sdb_exit
  388. push bp
  389. xor bp,bp
  390. push bp
  391. mov bp,sp
  392. push ds
  393. mov ax,dataOffset OutBuf ; lpText
  394. push ax
  395. push ds
  396. mov ax,dataOffset SysErr ; lpCaption
  397. push ax
  398. ; Set up the buttons based on the capabilities mask. Cancel is always
  399. ; availible. Retry and Ignore are not always available.
  400. mov ax,SEB_CANCEL+SEB_DEFBUTTON ; cancel is always allowed
  401. push ax
  402. xor ax,ax ; assume no second button
  403. if 0 ; 05 feb 1990, ignoring is not user friendly, win 2.x did not allow it
  404. test errcap,20h ; is ignore allowed?
  405. jz button_2
  406. mov ax,SEB_IGNORE ; ignore is the second button
  407. endif
  408. button_2:
  409. push ax
  410. xor ax,ax ; assume no third button
  411. test errcap,10h ; is retry allowed?
  412. jz button_3
  413. mov ax,SEB_RETRY ; retry is the third button
  414. button_3:
  415. push ax
  416. dobox:
  417. call [pSErrProc] ; USER.SysErrorBox()
  418. mov dx, ax
  419. ; We need to map the return as follows:
  420. ; button 1 (Cancel) => 3 3
  421. ; button 2 (Retry) => 1 0
  422. ; button 3 (Ignore) => 0 1
  423. sub al,2
  424. jnb codeok
  425. mov al,3
  426. codeok:
  427. pop bp
  428. pop bp
  429. sdb_exit:
  430. ret
  431. cEnd nogen
  432. ;-----------------------------------------------------------------------;
  433. ; GetLPErrMode ;
  434. ; ;
  435. ; This routine returns a long pointer to the Kernel_InDOS and ;
  436. ; Kernel_InINT24 bytes inside the KERNEL. It is used by 386 WINOLDAP ;
  437. ; to prevent switching while inside INT 24 errors from other VMs. ;
  438. ; ;
  439. ; NOTE: Do not change this call without talking to the WIN/386 group. ;
  440. ; NOTE: USER also uses this call to determine whether PostMessage ;
  441. ; can call FatalExit. ;
  442. ; ;
  443. ; Arguments: ;
  444. ; none ;
  445. ; ;
  446. ; Returns: ;
  447. ; DX:AX = pointer to Kernel_InDOS followed by Kernel_InINT24 ;
  448. ; ;
  449. ; Error Returns: ;
  450. ; ;
  451. ; Registers Preserved: ;
  452. ; all ;
  453. ; ;
  454. ; Registers Destroyed: ;
  455. ; ;
  456. ; Calls: ;
  457. ; ;
  458. ; History: ;
  459. ; ;
  460. ; Tue Jan 27, 1987 07:13:27p -by- David N. Weise [davidw] ;
  461. ; Rewrote it and added this nifty comment block. ;
  462. ; ;
  463. ; 7/23/87 -by- Arron Reynolds [aaronr], updated comments to desired ;
  464. ; state. ;
  465. ;-----------------------------------------------------------------------;
  466. assumes ds,nothing
  467. assumes es,nothing
  468. cProc GetLPErrMode,<PUBLIC,FAR>
  469. cBegin nogen
  470. call GetKernelDataSeg
  471. mov dx, ax
  472. mov ax,dataOffset Kernel_InDOS
  473. ret
  474. cEnd nogen
  475. sEnd code
  476. end