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.

144 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. enumendp.c
  5. Abstract:
  6. Enumerates all AFD_ENDPOINT structures in the system.
  7. Author:
  8. Keith Moore (keithmo) 19-Apr-1995
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "afdkdp.h"
  14. #pragma hdrstop
  15. ULONG EntityCount;
  16. //
  17. // Public functions.
  18. //
  19. VOID
  20. EnumEndpoints(
  21. PENUM_ENDPOINTS_CALLBACK Callback,
  22. ULONG64 Context
  23. )
  24. /*++
  25. Routine Description:
  26. Enumerates all AFD_ENDPOINT structures in the system, invoking the
  27. specified callback for each endpoint.
  28. Arguments:
  29. Callback - Points to the callback to invoke for each AFD_ENDPOINT.
  30. Context - An uninterpreted context value passed to the callback
  31. routine.
  32. Return Value:
  33. None.
  34. --*/
  35. {
  36. LIST_ENTRY64 listEntry;
  37. ULONG64 address;
  38. ULONG64 nextEntry;
  39. ULONG64 listHead;
  40. ULONG result;
  41. EntityCount = 0;
  42. listHead = GetExpression( "afd!AfdEndpointListHead" );
  43. if( listHead == 0 ) {
  44. dprintf( "\nEnumEndpoints: Could not find afd!AfdEndpointlistHead\n" );
  45. return;
  46. }
  47. if( !ReadListEntry(
  48. listHead,
  49. &listEntry) ) {
  50. dprintf(
  51. "\nEnumEndpoints: Could not read afd!AfdEndpointlistHead @ %p\n",
  52. listHead
  53. );
  54. return;
  55. }
  56. if (Options & AFDKD_ENDPOINT_SCAN) {
  57. nextEntry = StartEndpoint+EndpointLinkOffset;
  58. }
  59. else if (Options & AFDKD_BACKWARD_SCAN) {
  60. nextEntry = listEntry.Blink;
  61. }
  62. else {
  63. nextEntry = listEntry.Flink;
  64. }
  65. while( nextEntry != listHead ) {
  66. if (nextEntry==0) {
  67. dprintf ("\nEnumEndpoints: Flink is NULL, last endpoint: %p\n", address);
  68. break;
  69. }
  70. if( CheckControlC() ) {
  71. break;
  72. }
  73. address = nextEntry - EndpointLinkOffset;
  74. result = (ULONG)InitTypeRead (address, AFD!AFD_ENDPOINT);
  75. if( result!=0) {
  76. dprintf(
  77. "\nEnumEndpoints: Could not read AFD_ENDPOINT @ %p, err: %d\n",
  78. address, result
  79. );
  80. return;
  81. }
  82. if (Options & AFDKD_BACKWARD_SCAN) {
  83. nextEntry = ReadField (GlobalEndpointListEntry.Blink);
  84. }
  85. else {
  86. nextEntry = ReadField (GlobalEndpointListEntry.Flink);
  87. }
  88. if( !(Callback)( address, Context ) ) {
  89. break;
  90. }
  91. }
  92. } // EnumEndpoints