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.

124 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 2000-2002 Microsoft Corporation
  3. Module Name:
  4. Counter.c
  5. Abstract:
  6. User-mode interface to HTTP.SYS: Performance Counter collection API
  7. Author:
  8. Eric Stenson (ericsten) 28-Sept-2000
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. //
  13. // Private macros.
  14. //
  15. //
  16. // Private prototypes.
  17. //
  18. //
  19. // Public functions.
  20. //
  21. /***************************************************************************++
  22. Routine Description:
  23. Gathers the perf counters for HTTP.SYS
  24. Arguments:
  25. pControlChannelHandle - A handle to the control channel of HTTP.SYS
  26. CounterGroup - which counter set to get (global or site)
  27. pSizeCounterBlock - (IN) size of buffer, (OUT) bytes written if successful,
  28. zero otherwise
  29. pCounterBlocks - Buffer to receive the returned counter data block(s)
  30. pNumInstances - number of blocks returned.
  31. Return Values:
  32. STATUS_INSUFFICIENT_RESOURCES
  33. STATUS_INVALID_DEVICE_REQUEST
  34. STATUS_INVALID_PARAMETER
  35. --***************************************************************************/
  36. ULONG
  37. WINAPI
  38. HttpGetCounters(
  39. IN HANDLE ControlChannelHandle,
  40. IN HTTP_COUNTER_GROUP CounterGroup,
  41. IN OUT PULONG pSizeCounterBlock,
  42. IN OUT PVOID pCounterBlocks,
  43. OUT PULONG pNumInstances OPTIONAL
  44. )
  45. {
  46. ULONG result;
  47. if(pSizeCounterBlock == NULL)
  48. {
  49. return ERROR_INVALID_PARAMETER;
  50. }
  51. result = HttpApiSynchronousDeviceControl(
  52. ControlChannelHandle, // FileHandle
  53. IOCTL_HTTP_GET_COUNTERS, // IoControlCode
  54. &CounterGroup, // pInputBuffer
  55. sizeof(HTTP_COUNTER_GROUP), // InputBufferLength
  56. pCounterBlocks, // pOutputBuffer
  57. *pSizeCounterBlock, // OutputBufferLength
  58. pSizeCounterBlock // pBytesTransferred
  59. );
  60. //
  61. // Calc the number of blocks returned.
  62. //
  63. if (NO_ERROR == result)
  64. {
  65. if (pNumInstances)
  66. {
  67. if (HttpCounterGroupGlobal == CounterGroup)
  68. {
  69. *pNumInstances = (*pSizeCounterBlock / sizeof(HTTP_GLOBAL_COUNTERS));
  70. }
  71. else
  72. {
  73. ASSERT(HttpCounterGroupSite == CounterGroup);
  74. *pNumInstances = (*pSizeCounterBlock / sizeof(HTTP_SITE_COUNTERS));
  75. }
  76. }
  77. }
  78. else
  79. {
  80. if (pSizeCounterBlock)
  81. *pSizeCounterBlock = 0;
  82. if (pNumInstances)
  83. *pNumInstances = 0;
  84. }
  85. return result;
  86. }