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.

138 lines
3.1 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. sh.c
  5. Abstract:
  6. stub helper routines.
  7. Notes:
  8. simple routines for handling pointer decisions, comm and fault
  9. status etc.
  10. History:
  11. Dec-12-1993 VibhasC Created.
  12. ----------------------------------------------------------------------------*/
  13. /****************************************************************************
  14. * include files
  15. ***************************************************************************/
  16. #include "ndrp.h"
  17. /****************************************************************************
  18. * local definitions
  19. ***************************************************************************/
  20. /****************************************************************************
  21. * local data
  22. ***************************************************************************/
  23. /****************************************************************************
  24. * externs
  25. ***************************************************************************/
  26. /****************************************************************************/
  27. RPC_STATUS RPC_ENTRY
  28. NdrMapCommAndFaultStatus(
  29. /*
  30. Note on mapping.
  31. - Some errors are defined by DCE.
  32. These appear as mapped to DCE values on wire.
  33. They are mapped back to platform specific values by the rpc runtime.
  34. - other codes are defined by RPC runtime or by an app using rpc.
  35. These are not mapped, and appear both on the wire and on the client
  36. same as their original codes at server.
  37. */
  38. PMIDL_STUB_MESSAGE pMessage,
  39. unsigned long * pComm,
  40. unsigned long * pFault,
  41. RPC_STATUS RetVal )
  42. {
  43. // For errors that are mapped through DCE values, we use constants that
  44. // resolve to platform specific error codes.
  45. // For others, we have to use absolute values as the codes on wire are NT
  46. // values set by RPC.
  47. // We don't map any app specific error codes, of course.
  48. //
  49. static long CommStatArray[] =
  50. {
  51. RPC_X_SS_CONTEXT_MISMATCH
  52. ,RPC_S_INVALID_BINDING
  53. ,RPC_S_UNKNOWN_IF
  54. ,RPC_S_SERVER_UNAVAILABLE
  55. ,RPC_S_SERVER_TOO_BUSY
  56. ,RPC_S_CALL_FAILED_DNE
  57. ,RPC_S_PROTOCOL_ERROR
  58. ,RPC_S_UNSUPPORTED_TRANS_SYN
  59. ,RPC_S_UNSUPPORTED_TYPE
  60. ,RPC_S_PROCNUM_OUT_OF_RANGE
  61. ,EPT_S_NOT_REGISTERED
  62. ,RPC_S_COMM_FAILURE
  63. ,RPC_S_ASYNC_CALL_PENDING
  64. };
  65. int Mid;
  66. int Low = 0;
  67. int High = (sizeof(CommStatArray)/sizeof( unsigned long)) - 1;
  68. BOOL fCmp;
  69. BOOL fCommStat = FALSE;
  70. // Check if there was no error.
  71. if( RetVal == 0 )
  72. return RetVal;
  73. // Find a comm error mapping.
  74. while( Low <= High )
  75. {
  76. Mid = (Low + High) / 2;
  77. fCmp = (long)RetVal - (long) CommStatArray[ Mid ];
  78. if( fCmp < 0 )
  79. {
  80. High = Mid - 1;
  81. }
  82. else if( fCmp > 0 )
  83. {
  84. Low = Mid + 1;
  85. }
  86. else
  87. {
  88. fCommStat = TRUE;
  89. break;
  90. }
  91. }
  92. // If there was a comm error, return it in the pComm, if possible;
  93. // If it was a non-comm error, return it in the pFault, if possible.
  94. if( fCommStat )
  95. {
  96. if( pComm )
  97. {
  98. *pComm = RetVal;
  99. RetVal = 0;
  100. }
  101. }
  102. else
  103. {
  104. if( pFault )
  105. {
  106. *pFault = RetVal;
  107. RetVal = 0;
  108. }
  109. }
  110. return RetVal;
  111. }
  112.