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.

157 lines
3.3 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. NO_ERROR,
  36. &fAccessAllowed );
  37. if ( contextStatus == CONTEXT_STATUS_PENDING )
  38. {
  39. return CONTEXT_STATUS_PENDING;
  40. }
  41. //
  42. // Access check must be complete if we're here
  43. //
  44. DBG_ASSERT( pW3Context->QueryAccessChecked() );
  45. if ( !fAccessAllowed )
  46. {
  47. //
  48. // CheckAccess already sent error
  49. //
  50. return CONTEXT_STATUS_CONTINUE;
  51. }
  52. //
  53. // Now we can execute the handler
  54. //
  55. return DoWork();
  56. }
  57. CONTEXT_STATUS
  58. W3_HANDLER::MainOnCompletion(
  59. DWORD cbCompletion,
  60. DWORD dwCompletionStatus
  61. )
  62. /*++
  63. Routine Description:
  64. Continue access check if needed, then then when finished, call into
  65. the handler start
  66. If handler is already started, funnel the completion to the handler
  67. Arguments:
  68. cbCompletion - Bytes of completion
  69. dwCompletionStatus - Status of completion
  70. Return Value:
  71. CONTEXT_STATUS_PENDING if async pending,
  72. else CONTEXT_STATUS_CONTINUE
  73. --*/
  74. {
  75. W3_CONTEXT * pW3Context;
  76. CONTEXT_STATUS contextStatus;
  77. BOOL fAccessAllowed = FALSE;
  78. pW3Context = QueryW3Context();
  79. DBG_ASSERT( pW3Context != NULL );
  80. if ( !pW3Context->QueryAccessChecked() )
  81. {
  82. //
  83. // If access hasn't been checked completely yet, then we should resume
  84. // it
  85. //
  86. contextStatus = pW3Context->CheckAccess( TRUE, // completion
  87. dwCompletionStatus,
  88. &fAccessAllowed );
  89. if ( contextStatus == CONTEXT_STATUS_PENDING )
  90. {
  91. return CONTEXT_STATUS_PENDING;
  92. }
  93. DBG_ASSERT( pW3Context->QueryAccessChecked() );
  94. if ( !fAccessAllowed )
  95. {
  96. //
  97. // CheckAccess already sent error
  98. //
  99. return CONTEXT_STATUS_CONTINUE;
  100. }
  101. //
  102. // Now we can execute the original handler
  103. //
  104. return DoWork();
  105. }
  106. else
  107. {
  108. //
  109. // Access checks have already been made. This must be a completion
  110. // for the handler itself
  111. //
  112. return OnCompletion( cbCompletion,
  113. dwCompletionStatus );
  114. }
  115. }