Windows NT 4.0 source code leak
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.

119 lines
2.3 KiB

4 years ago
  1. page ,132
  2. title except86 - Exception Handler for x86 machines - DOS MODE
  3. ;***
  4. ;
  5. ; Microsoft OS/2 LAN Manager
  6. ; Copyright(c) Microsoft Corp., 1990
  7. ;
  8. ;Purpose:
  9. ;
  10. ; This is OS specific part of exceptions for the x86 machines.
  11. ; This is simple because there is only 1 thread. Just get
  12. ; the current exception context through a static pointer.
  13. ; This is done in assembly so we can call the C runtime on
  14. ; unhandled exceptions.
  15. ;*******************************************************************************
  16. .model large,PASCAL
  17. option oldstructs
  18. ExceptionExitCode = 1000
  19. MSG segment byte public 'MSG'
  20. dw ExceptionExitCode
  21. db 'Unhandled Remote Procedure Call Exception',13,10,0
  22. MSG ends
  23. externdef syscall __amsg_exit:far
  24. ; NOTE - This is copied in except86.asm and sized in dos\rpc.h
  25. ExceptBuff struc
  26. savBP dw ?
  27. savDI dw ?
  28. savSI dw ?
  29. savSP dw ?
  30. savREToff dw ?
  31. savRETseg dw ?
  32. savDS dw ?
  33. pad1 dw ?
  34. pad2 dw ?
  35. nextExceptOff dw ? ; Next exception handler
  36. nextExceptSeg dw ?
  37. ExceptBuff ends
  38. .data
  39. pThreadHandlers dword 0
  40. .code
  41. ; this routine was added to make Microsoft Exchange's MONITOR mode
  42. ; able to detect when we're in an RPC call.
  43. ; returns 0 of no exception handler registerd, or non-0 otherwise
  44. RpcExceptionRegistered proc pascal
  45. push ds
  46. push si
  47. ; no guarantee that we've got a valid DS!
  48. mov ax, seg pThreadHandlers
  49. mov ds,ax
  50. mov si, offset pThreadHandlers
  51. mov ax,ds:[si+2]
  52. or ax,ds:[si]
  53. pop si
  54. pop ds
  55. ret
  56. RpcExceptionRegistered endp
  57. RpcSetExceptionHandler proc pascal pExceptionBuff:ptr ExceptBuff
  58. mov ax,word ptr pThreadHandlers
  59. mov dx,word ptr pThreadHandlers+2
  60. mov cx,word ptr pExceptionBuff
  61. mov word ptr pThreadHandlers,cx
  62. mov cx,word ptr pExceptionBuff+2
  63. mov word ptr pThreadHandlers+2,cx
  64. ret
  65. RpcSetExceptionHandler endp
  66. RpcGetExceptionHandler proc pascal
  67. mov ax,word ptr pThreadHandlers
  68. mov dx,word ptr pThreadHandlers+2
  69. or dx,dx
  70. jnz @F
  71. ; No exception handler, exit process via the runtime.
  72. mov ax, ExceptionExitCode
  73. jmp __amsg_exit
  74. @@:
  75. ret
  76. RpcGetExceptionHandler endp
  77. RpcLeaveException proc pascal
  78. les bx, pThreadHandlers
  79. mov ax, es:[bx.nextExceptOff]
  80. mov word ptr pThreadHandlers,ax
  81. mov ax, es:[bx.nextExceptSeg]
  82. mov word ptr pThreadHandlers+2,ax
  83. ret
  84. RpcLeaveException endp
  85. end
  86.