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.

159 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name :
  4. w3handler.cxx
  5. Abstract:
  6. Common functionality of all handlers
  7. Author:
  8. Bilal Alam (balam) Sept-29-2000
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. ULW3.DLL
  13. --*/
  14. #include "precomp.hxx"
  15. CONTEXT_STATUS
  16. W3_HANDLER::MainDoWork(
  17. VOID
  18. )
  19. /*++
  20. Routine Description:
  21. Checks access and then calls handler routine
  22. Return Value:
  23. CONTEXT_STATUS_PENDING if async pending,
  24. else CONTEXT_STATUS_CONTINUE
  25. --*/
  26. {
  27. CONTEXT_STATUS contextStatus;
  28. BOOL fAccessAllowed = FALSE;
  29. W3_CONTEXT *pW3Context = QueryW3Context();
  30. DBG_ASSERT( pW3Context != NULL );
  31. //
  32. // Check access
  33. //
  34. contextStatus = pW3Context->CheckAccess( FALSE, // not a completion
  35. 0, // cbCompletion
  36. NO_ERROR,
  37. &fAccessAllowed );
  38. if ( contextStatus == CONTEXT_STATUS_PENDING )
  39. {
  40. return CONTEXT_STATUS_PENDING;
  41. }
  42. //
  43. // Access check must be complete if we're here
  44. //
  45. DBG_ASSERT( pW3Context->QueryAccessChecked() );
  46. if ( !fAccessAllowed )
  47. {
  48. //
  49. // CheckAccess already sent error
  50. //
  51. return CONTEXT_STATUS_CONTINUE;
  52. }
  53. //
  54. // Now we can execute the handler
  55. //
  56. return DoWork();
  57. }
  58. CONTEXT_STATUS
  59. W3_HANDLER::MainOnCompletion(
  60. DWORD cbCompletion,
  61. DWORD dwCompletionStatus
  62. )
  63. /*++
  64. Routine Description:
  65. Continue access check if needed, then then when finished, call into
  66. the handler start
  67. If handler is already started, funnel the completion to the handler
  68. Arguments:
  69. cbCompletion - Bytes of completion
  70. dwCompletionStatus - Status of completion
  71. Return Value:
  72. CONTEXT_STATUS_PENDING if async pending,
  73. else CONTEXT_STATUS_CONTINUE
  74. --*/
  75. {
  76. W3_CONTEXT * pW3Context;
  77. CONTEXT_STATUS contextStatus;
  78. BOOL fAccessAllowed = FALSE;
  79. pW3Context = QueryW3Context();
  80. DBG_ASSERT( pW3Context != NULL );
  81. if ( !pW3Context->QueryAccessChecked() )
  82. {
  83. //
  84. // If access hasn't been checked completely yet, then we should resume
  85. // it
  86. //
  87. contextStatus = pW3Context->CheckAccess( TRUE, // completion
  88. cbCompletion,
  89. dwCompletionStatus,
  90. &fAccessAllowed );
  91. if ( contextStatus == CONTEXT_STATUS_PENDING )
  92. {
  93. return CONTEXT_STATUS_PENDING;
  94. }
  95. DBG_ASSERT( pW3Context->QueryAccessChecked() );
  96. if ( !fAccessAllowed )
  97. {
  98. //
  99. // CheckAccess already sent error
  100. //
  101. return CONTEXT_STATUS_CONTINUE;
  102. }
  103. //
  104. // Now we can execute the original handler
  105. //
  106. return DoWork();
  107. }
  108. else
  109. {
  110. //
  111. // Access checks have already been made. This must be a completion
  112. // for the handler itself
  113. //
  114. return OnCompletion( cbCompletion,
  115. dwCompletionStatus );
  116. }
  117. }