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.

114 lines
2.5 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1992 - 1999
  3. Module Name:
  4. dispatch.h
  5. Abstract:
  6. Author:
  7. Michael Montague (mikemon) 11-Jun-1992
  8. Revision History:
  9. --*/
  10. #include <sysinc.h>
  11. #include <rpc.h>
  12. #include <rpcdcep.h>
  13. #include <dispatch.h>
  14. unsigned int
  15. DispatchToStubInCNoAvrf (
  16. IN RPC_DISPATCH_FUNCTION Stub,
  17. IN OUT PRPC_MESSAGE Message,
  18. OUT RPC_STATUS * ExceptionCode
  19. )
  20. /*++
  21. Routine Description:
  22. Dispatch a remote procedure call to a stub. This must be in C
  23. because cfront does not support try-except on MIPS.
  24. Arguments:
  25. Stub - Supplies the pointer to the function to dispatch to.
  26. Message - Supplies the request and returns the response.
  27. ExceptionCode - Returns the exception code if an exception
  28. occured.
  29. Return Value:
  30. A non-zero value will be returned in an exception occured.
  31. --*/
  32. {
  33. unsigned int ExceptionHappened = 0;
  34. RpcTryExcept
  35. {
  36. (*Stub)(Message);
  37. }
  38. // Return "non-fatal" errors to clients. Catching fatal errors
  39. // makes it harder to debug.
  40. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  41. {
  42. ExceptionHappened = 1;
  43. *ExceptionCode = RpcExceptionCode();
  44. ASSERT(*ExceptionCode != RPC_S_OK);
  45. }
  46. RpcEndExcept
  47. return(ExceptionHappened);
  48. }
  49. unsigned int
  50. DispatchToStubInCAvrf (
  51. IN RPC_DISPATCH_FUNCTION Stub,
  52. IN OUT PRPC_MESSAGE Message,
  53. OUT RPC_STATUS * ExceptionCode
  54. )
  55. /*++
  56. Routine Description:
  57. Dispatch a remote procedure call to a stub. This is a wrapper
  58. around DispatchToStubInCNoAvrf that is called when app verifier is enabled.
  59. It makes sure that the server routine has not orphaned a critical section.
  60. Arguments:
  61. Same as for DispatchToStubInCNoAvrf.
  62. Return Value:
  63. A non-zero value will be returned in an exception occured.
  64. --*/
  65. {
  66. unsigned int ExceptionHappened;
  67. ExceptionHappened = DispatchToStubInCNoAvrf (Stub, Message, ExceptionCode);
  68. // Make sure this is not a callback.
  69. // A thread dispatching a callback may be legitimately holding a critsec in user code
  70. // or a connection mutex in the case of DG.
  71. if (!IsCallbackMessage(Message))
  72. {
  73. RtlCheckForOrphanedCriticalSections(NtCurrentThread());
  74. }
  75. return(ExceptionHappened);
  76. }
  77. // Initialize the dispatch routine to the default one to be used in the
  78. // absence of app verifier.
  79. DISPATCH_TO_STUB DispatchToStubInC = DispatchToStubInCNoAvrf;