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.

119 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. counter.c
  5. Abstract:
  6. User-mode interface to UL.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 UL.SYS
  24. Arguments:
  25. pControlChannelHandle - A handle to the control channel of UL.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. NTSTATUS Status;
  47. Status = HttpApiSynchronousDeviceControl(
  48. ControlChannelHandle, // FileHandle
  49. IOCTL_HTTP_GET_COUNTERS, // IoControlCode
  50. &CounterGroup, // pInputBuffer
  51. sizeof(HTTP_COUNTER_GROUP), // InputBufferLength
  52. pCounterBlocks, // pOutputBuffer
  53. *pSizeCounterBlock, // OutputBufferLength
  54. pSizeCounterBlock // pBytesTransferred
  55. );
  56. //
  57. // Calc the number of blocks returned.
  58. //
  59. if (STATUS_SUCCESS == Status)
  60. {
  61. if (pNumInstances)
  62. {
  63. if (HttpCounterGroupGlobal == CounterGroup)
  64. {
  65. *pNumInstances = (*pSizeCounterBlock / sizeof(HTTP_GLOBAL_COUNTERS));
  66. }
  67. else
  68. {
  69. ASSERT(HttpCounterGroupSite == CounterGroup);
  70. *pNumInstances = (*pSizeCounterBlock / sizeof(HTTP_SITE_COUNTERS));
  71. }
  72. }
  73. }
  74. else
  75. {
  76. if (pSizeCounterBlock)
  77. *pSizeCounterBlock = 0;
  78. if (pNumInstances)
  79. *pNumInstances = 0;
  80. }
  81. return HttpApiNtStatusToWin32Status( Status );
  82. }