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.

163 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1997 - 98, Microsoft Corporation
  3. Module Name:
  4. rtmhndl.c
  5. Abstract:
  6. Contains routines for operating on handles
  7. to RTM objects like routes and dests.
  8. Author:
  9. Chaitanya Kodeboyina (chaitk) 23-Aug-1998
  10. Revision History:
  11. --*/
  12. #include "pchrtm.h"
  13. #pragma hdrstop
  14. DWORD
  15. WINAPI
  16. RtmReferenceHandles (
  17. IN RTM_ENTITY_HANDLE RtmRegHandle,
  18. IN UINT NumHandles,
  19. IN HANDLE *RtmHandles
  20. )
  21. /*++
  22. Routine Description:
  23. Increment the reference count on objects pointed to by
  24. input RTM handles.
  25. Arguments:
  26. RtmRegHandle - RTM registration handle for calling entity,
  27. NumHandles - Number of handles that are being referenced,
  28. RtmHandles - Array of handles that are being referenced.
  29. Return Value:
  30. Status of the operation
  31. --*/
  32. {
  33. PENTITY_INFO Entity;
  34. POBJECT_HEADER Object;
  35. UINT i;
  36. DBG_VALIDATE_ENTITY_HANDLE(RtmRegHandle, &Entity);
  37. //
  38. // Reference each handle in input array
  39. //
  40. for (i = 0; i < NumHandles; i++)
  41. {
  42. Object = GET_POINTER_FROM_HANDLE(RtmHandles[i]);
  43. #if DBG_HDL
  44. try
  45. {
  46. if (Object->TypeSign != OBJECT_SIGNATURE[atoi(&Object->Type)])
  47. {
  48. continue;
  49. }
  50. }
  51. except(EXCEPTION_EXECUTE_HANDLER)
  52. {
  53. continue;
  54. }
  55. #endif
  56. ReferenceObject(Object, HANDLE_REF);
  57. }
  58. return NO_ERROR;
  59. }
  60. DWORD
  61. WINAPI
  62. RtmDereferenceHandles (
  63. IN RTM_ENTITY_HANDLE RtmRegHandle,
  64. IN UINT NumHandles,
  65. IN HANDLE *RtmHandles
  66. )
  67. /*++
  68. Routine Description:
  69. Decrement the reference count on objects pointed to by
  70. input RTM handles.
  71. Arguments:
  72. RtmRegHandle - RTM registration handle for calling entity,
  73. NumHandles - Number of handles that are being dereferenced,
  74. RtmHandles - Array of handles that are being dereferenced.
  75. Return Value:
  76. Status of the operation
  77. --*/
  78. {
  79. PENTITY_INFO Entity;
  80. POBJECT_HEADER Object;
  81. UINT i;
  82. DBG_VALIDATE_ENTITY_HANDLE(RtmRegHandle, &Entity);
  83. //
  84. // Dereference each handle in input array
  85. //
  86. for (i = 0; i < NumHandles; i++)
  87. {
  88. Object = GET_POINTER_FROM_HANDLE(RtmHandles[i]);
  89. #if DBG_HDL
  90. try
  91. {
  92. if (Object->TypeSign != OBJECT_SIGNATURE[atoi(&Object->Type)])
  93. {
  94. continue;
  95. }
  96. }
  97. except(EXCEPTION_EXECUTE_HANDLER)
  98. {
  99. continue;
  100. }
  101. #endif
  102. //
  103. // This function can be used only if you know
  104. // that the reference count does not go to 0
  105. //
  106. if (DereferenceObject(Object, HANDLE_REF) == 0)
  107. {
  108. ASSERT(FALSE); // ? Destroy which object ?
  109. }
  110. }
  111. return NO_ERROR;
  112. }