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.

127 lines
2.1 KiB

  1. /*++ BUILD Version: 0000 // Increment this if a change has global effects
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. handle.h
  5. Abstract:
  6. Public definitions for handle table library
  7. Author:
  8. Dan Knudson (DanKn) 15-Sep-1998
  9. Revision History:
  10. --*/
  11. typedef VOID (CALLBACK * FREECONTEXTCALLBACK)(LPVOID, LPVOID);
  12. typedef struct _MYCONTEXT
  13. {
  14. LPVOID C;
  15. LPVOID C2;
  16. } MYCONTEXT, *PMYCONTEXT;
  17. typedef struct _HANDLETABLEENTRY
  18. {
  19. // NOTE: ListEntry must be 1st field in structure so that we don't
  20. // have to use CONTAINING_RECORD macro
  21. union
  22. {
  23. LIST_ENTRY ListEntry;
  24. MYCONTEXT Context;
  25. };
  26. DWORD Handle;
  27. union
  28. {
  29. DWORD ReferenceCount;
  30. DWORD Instance;
  31. };
  32. } HANDLETABLEENTRY, *PHANDLETABLEENTRY;
  33. typedef struct _HANDLETABLEHEADER
  34. {
  35. HANDLE Heap;
  36. PHANDLETABLEENTRY Table;
  37. DWORD NumEntries;
  38. DWORD HandleBase;
  39. LIST_ENTRY FreeList;
  40. FREECONTEXTCALLBACK FreeContextCallback;
  41. CRITICAL_SECTION Lock;
  42. } HANDLETABLEHEADER, *PHANDLETABLEHEADER;
  43. HANDLE
  44. CreateHandleTable(
  45. HANDLE Heap,
  46. FREECONTEXTCALLBACK FreeContextCallback,
  47. DWORD MinHandleValue,
  48. DWORD MaxHandleValue
  49. );
  50. VOID
  51. DeleteHandleTable(
  52. HANDLE HandleTable
  53. );
  54. DWORD
  55. NewObject(
  56. HANDLE HandleTable,
  57. LPVOID Context,
  58. LPVOID Context2
  59. );
  60. DWORD
  61. NewObjectEx(
  62. HANDLE HandleTable,
  63. LPVOID Context,
  64. LPVOID Context2,
  65. DWORD ModBase,
  66. DWORD Remainder
  67. );
  68. LPVOID
  69. ReferenceObject(
  70. HANDLE HandleTable,
  71. DWORD Handle,
  72. DWORD Key
  73. );
  74. LPVOID
  75. ReferenceObjectEx(
  76. HANDLE HandleTable,
  77. DWORD Handle,
  78. DWORD Key,
  79. LPVOID *Context2
  80. );
  81. VOID
  82. DereferenceObject(
  83. HANDLE HandleTable,
  84. DWORD Handle,
  85. DWORD DereferenceCount
  86. );
  87. void
  88. ReleaseAllHandles(
  89. HANDLE HandleTable,
  90. PVOID Context2
  91. );