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.

204 lines
3.8 KiB

  1. //
  2. // manifests
  3. //
  4. #define OBJECT_SIGNATURE 0x41414141 // "AAAA"
  5. #define DESTROYED_OBJECT_SIGNATURE 0x5A5A5A5A // "ZZZZ"
  6. #define INET_INVALID_HANDLE_VALUE (NULL)
  7. /*++
  8. Class Description:
  9. This is generic HINTERNET class definition.
  10. Private Member functions:
  11. None.
  12. Public Member functions:
  13. IsValid : Validates handle pointer.
  14. GetStatus : Gets status of the object.
  15. --*/
  16. class HANDLE_OBJECT {
  17. private:
  18. //
  19. // _List - doubly-linked list of all handle objects
  20. //
  21. LIST_ENTRY _List;
  22. // _Parent - this member has the address of the parent object.
  23. HANDLE_OBJECT* _Parent;
  24. //
  25. // _Handle - the non-address pseudo-handle value returned at the API
  26. //
  27. HINTERNET _Handle;
  28. //
  29. // _ObjectType - type of handle object (mainly for debug purposes)
  30. //
  31. HINTERNET_HANDLE_TYPE _ObjectType;
  32. //
  33. // _ReferenceCount - number of references of this object. Used to protect
  34. // object against multi-threaded operations and can be used to delete
  35. // object when count is decremented to 0
  36. //
  37. LONG _ReferenceCount;
  38. //
  39. // _Invalid - when this is TRUE the handle has been closed although it may
  40. // still be alive. The app cannot perform any further actions on this
  41. // handle object - it will soon be destroyed
  42. //
  43. //
  44. // BUGBUG - combine into bitfield
  45. //
  46. BOOL _Invalid;
  47. //
  48. // _Error - optionally set when invalidating the handle. If set (non-zero)
  49. // then this is the preferred error to return from an invalidated request
  50. //
  51. DWORD _Error;
  52. //
  53. // _Signature - used to perform sanity test of object
  54. //
  55. DWORD _Signature;
  56. protected:
  57. //
  58. // _Context - the context value specified in the API that created this
  59. // object. This member is inherited by all derived objects
  60. //
  61. DWORD_PTR _Context;
  62. //
  63. // _Status - used to store return codes whilst creating the object. If not
  64. // ERROR_SUCCESS when new() returns, the object is deleted
  65. //
  66. DWORD _Status;
  67. public:
  68. HANDLE_OBJECT(
  69. HANDLE_OBJECT * Parent
  70. );
  71. virtual
  72. ~HANDLE_OBJECT(
  73. VOID
  74. );
  75. DWORD
  76. Reference(
  77. VOID
  78. );
  79. BOOL
  80. Dereference(
  81. VOID
  82. );
  83. VOID Invalidate(VOID) {
  84. //
  85. // just mark the object as invalidated
  86. //
  87. _Invalid = TRUE;
  88. }
  89. BOOL IsInvalidated(VOID) const {
  90. return (_Invalid || (_Parent ? _Parent->IsInvalidated() : FALSE));
  91. }
  92. VOID InvalidateWithError(DWORD dwError) {
  93. _Error = dwError;
  94. Invalidate();
  95. }
  96. DWORD GetError(VOID) const {
  97. return _Error;
  98. }
  99. DWORD ReferenceCount(VOID) const {
  100. return _ReferenceCount;
  101. }
  102. HINTERNET GetPseudoHandle(VOID) {
  103. return _Handle;
  104. }
  105. DWORD_PTR GetContext(VOID) {
  106. return _Context;
  107. }
  108. //
  109. // BUGBUG - rfirth 04/05/96 - remove virtual functions
  110. //
  111. // See similar BUGBUG in INTERNET_HANDLE_OBJECT
  112. //
  113. virtual HINTERNET_HANDLE_TYPE GetHandleType(VOID)
  114. {
  115. return TypeGenericHandle;
  116. }
  117. DWORD IsValid(HINTERNET_HANDLE_TYPE ExpectedHandleType);
  118. DWORD GetStatus(VOID) {
  119. return _Status;
  120. }
  121. HINTERNET GetParent() {
  122. return _Parent;
  123. }
  124. VOID SetObjectType(HINTERNET_HANDLE_TYPE Type) {
  125. _ObjectType = Type;
  126. }
  127. HINTERNET_HANDLE_TYPE GetObjectType(VOID) const {
  128. return _ObjectType;
  129. }
  130. //
  131. // friend functions
  132. //
  133. friend
  134. HANDLE_OBJECT *
  135. ContainingHandleObject(
  136. IN LPVOID lpAddress
  137. );
  138. };