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.

110 lines
4.0 KiB

  1. .xlist
  2. include cruntime.inc
  3. include elem87.inc
  4. .list
  5. .data
  6. _exception struc ; struct _exception {
  7. typ dd ? ; int type; /* exception type - see below */
  8. nam dd ? ; char *name; /* name of function where error occured */
  9. arg1 dq ? ; double arg1; /* first argument to function */
  10. arg2 dq ? ; double arg2; /* second argument (if any) to function */
  11. retval dq ? ; double retval; /* value to be returned by function */
  12. _exception ends ; }
  13. Except_struct_size equ ((size _exception) + ISIZE - 1) and (not (ISIZE-1))
  14. Except_struct equ [ebp-Except_struct_size]
  15. CODESEG
  16. extrn _87except:proc
  17. ;***********************************************************
  18. ;
  19. ; _startTwoArgErrorHandling
  20. ;
  21. ;***********************************************************
  22. ; Purpose: call to 87except() function, and restore CW
  23. ;
  24. ; at this point we have on stack: ret_addr(4), cw(4), ret_addr(4), arg1(8bytes)
  25. ; ecx points to function name
  26. ; edx function id (for example OP_LOG)
  27. ; eax error type (for example SING)
  28. ;
  29. ; Note:
  30. ; we could use this procedure instead of _startOneArgErrorHandling,
  31. ; but not always we can assume that there is something on stack below param1
  32. ;
  33. _startTwoArgErrorHandling proc \
  34. savCW:dword, \ ; don't change it !!!
  35. ret_addr:dword, \
  36. param1:qword,
  37. param2:qword
  38. local arg_to_except87:_exception
  39. ; store second argument to _exception structure
  40. mov [arg_to_except87.typ],eax ; type of error
  41. mov eax,dword ptr [param2] ; load arg2
  42. mov dword ptr [arg_to_except87.arg2],eax
  43. mov eax,dword ptr [param2+4]
  44. mov dword ptr [arg_to_except87.arg2+4],eax
  45. jmp _ContinueErrorHandling
  46. _startTwoArgErrorHandling endp
  47. ;***********************************************************
  48. ;
  49. ; _startOneArgErrorHandling
  50. ;
  51. ;***********************************************************
  52. ; Purpose: call to 87except() function, and restore CW
  53. ;
  54. ; at this point we have on stack: ret_addr(4), cw(4), ret_addr(4), arg1(8bytes)
  55. ; ecx points to function name
  56. ; edx function id (for example OP_LOG)
  57. ; eax error type (for example SING)
  58. ;
  59. _startOneArgErrorHandling proc \
  60. savCW:dword, \ ; don't change it !!!
  61. ret_addr:dword, \
  62. param1:qword
  63. local arg_to_except87:_exception
  64. ; prepare _exception structure
  65. mov [arg_to_except87.typ],eax ; type of error
  66. _ContinueErrorHandling label proc
  67. fstp [arg_to_except87.retval] ; store return value
  68. mov [arg_to_except87.nam],ecx ; pointer to function name
  69. mov eax,dword ptr [param1] ; load arg1
  70. mov ecx,dword ptr [param1+4]
  71. mov dword ptr [arg_to_except87.arg1],eax
  72. mov dword ptr [arg_to_except87.arg1+4],ecx
  73. ; push on stack args for _87except()
  74. lea eax,[savCW] ; load control word
  75. lea ecx,arg_to_except87
  76. push eax ; &(CW)
  77. push ecx ; &(_exception structure)
  78. push edx ; function number
  79. call _87except
  80. add esp,12 ; clear arguments if _cdecl
  81. fld [arg_to_except87.retval] ; this assumes that user
  82. ; does not want to return a
  83. ; signaling NaN
  84. ; Now it's time to restore saved CW
  85. cmp word ptr[savCW],default_CW
  86. je CW_is_restored ; it's usualy taken
  87. fldcw word ptr[savCW]
  88. CW_is_restored:
  89. ret ; _cdecl return
  90. _startOneArgErrorHandling endp
  91. end