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.

152 lines
4.2 KiB

  1. page ,132
  2. if 0
  3. /*++
  4. Copyright (c) 1991 Microsoft Corporation
  5. Module Name:
  6. neterror.asm
  7. Abstract:
  8. This module contains error handling code, specifically in order to get
  9. 16-bit errors back to apps - DOS summarily truncates error codes to 8
  10. bits. The following routines are contained herein:
  11. SetNetErrorCodeAx
  12. ReturnNetErrorCodeAx
  13. Author:
  14. Richard L Firth (rfirth) 05-Sep-1991
  15. Environment:
  16. Dos mode only
  17. Revision History:
  18. 05-Sep-1991 rfirth
  19. Created
  20. --*/
  21. endif
  22. .xlist ; don't list these include files
  23. .xcref ; turn off cross-reference listing
  24. include dosmac.inc ; Break macro etc (for following include files only)
  25. include dossym.inc ; User_<Reg> defines
  26. include mult.inc ; MultNET
  27. include error.inc ; DOS errors - ERROR_INVALID_FUNCTION
  28. include syscall.inc ; DOS system call numbers
  29. include rdrint2f.inc ; redirector Int 2f numbers
  30. include segorder.inc ; segments
  31. include enumapis.inc ; dispatch codes
  32. include debugmac.inc ; DbgPrint macro
  33. include localmac.inc ; DbgPrint macro
  34. include asmmacro.inc ; language extensions
  35. include rdrsvc.inc ; BOP and SVC macros/dispatch codes
  36. include sf.inc ; SFT definitions/structure
  37. .cref ; switch cross-reference back on
  38. .list ; switch listing back on
  39. subttl ; kill subtitling started in include file
  40. .286 ; all code in this module 286 compatible
  41. ResidentCodeStart
  42. assume cs:ResidentCode
  43. assume ds:nothing
  44. assume es:nothing
  45. assume ss:nothing
  46. ;
  47. ; once again, store the data in the code segment
  48. ;
  49. CallerAx dw ? ; where the error code goes
  50. CallerCs dw ? ; far return address to caller
  51. CallerIp dw ?
  52. ; *** SetNetErrorCodeAx
  53. ; *
  54. ; * Causes a 16-bit error code to be returned in ax to a calling app. This
  55. ; * routine is only called in the case of an error being returned
  56. ; *
  57. ; * DOS routinely truncates any error we hand it to 8 bits, since
  58. ; * historically DOS error codes were all <255. We do here the same
  59. ; * execrable fix that the real redir must do - capture the return address
  60. ; * from DOS's stack, set the DOS return address to this routine, store
  61. ; * away the 16-bit error code and return an 8-bit error code to DOS. When
  62. ; * DOS does an iret, we get control, set ax to the real 16-bit error, set
  63. ; * the carry flag and return to the caller for real
  64. ; *
  65. ; * ENTRY AX = error code
  66. ; *
  67. ; * EXIT nothing affected
  68. ; *
  69. ; * USES ds
  70. ; *
  71. ; * ASSUMES Not re-entrant
  72. ; *
  73. ; ***
  74. public SetNetErrorCodeAx
  75. SetNetErrorCodeAx proc
  76. pushf ; don't lose error indication
  77. push ax ; or error code
  78. DosCallBack GET_USER_STACK
  79. mov ax,[si].User_Cs
  80. mov CallerCs,ax
  81. mov ax,[si].User_Ip
  82. mov CallerIp,ax
  83. mov [si].User_Cs,cs
  84. mov [si].User_Ip,offset ReturnNetErrorCodeAx
  85. pop ax
  86. popf
  87. mov CallerAx,ax
  88. ret
  89. SetNetErrorCodeAx endp
  90. ; *** ReturnNetErrorCodeAx
  91. ; *
  92. ; * This routine is called as a result of SetNetErrorCodeAx being called.
  93. ; * This is on the exit path from DOS to an app which called a redir
  94. ; * entry point which returned an error.
  95. ; * We set the real 16-bit error code that we remembered before, set the
  96. ; * carry flag to indicate an error then iret to the real caller's return
  97. ; * address
  98. ; *
  99. ; * ENTRY user's registers
  100. ; *
  101. ; * EXIT CF = 1
  102. ; * AX = Error code
  103. ; *
  104. ; * USES ax, carry flag
  105. ; *
  106. ; * ASSUMES nothing
  107. ; *
  108. ; ***
  109. public ReturnNetErrorCodeAx
  110. ReturnNetErrorCodeAx proc
  111. push CallerCs
  112. push CallerIp
  113. mov ax,CallerAx
  114. stc ; remember - only called if error
  115. retf ; far return
  116. ReturnNetErrorCodeAx endp
  117. ResidentCodeEnd
  118. end