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.

98 lines
2.3 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: StandardHeader.h
  3. //
  4. // Copyright (c) 1999-2000, Microsoft Corporation
  5. //
  6. // This file defines standard includes for the consumer Windows additions
  7. // to Windows 2000 msgina.
  8. //
  9. // History: 1999-08-18 vtan created
  10. // 2000-01-31 vtan moved from Neptune to Whistler
  11. // --------------------------------------------------------------------------
  12. #ifndef _StandardHeader_
  13. #define _StandardHeader_
  14. #include <nt.h>
  15. #include <ntrtl.h>
  16. #include <nturtl.h>
  17. #include <ntlsa.h>
  18. #include <ntmsv1_0.h>
  19. #include <lmsname.h>
  20. #include <windows.h>
  21. #include <winbasep.h>
  22. #include <winuserp.h>
  23. #include <lmaccess.h>
  24. #include <lmapibuf.h>
  25. #include <lmerr.h>
  26. #include <aclapi.h>
  27. #include <limits.h>
  28. #include "StandardDebug.h"
  29. static const int kMaximumValueDataLength = 1024;
  30. #ifndef ARRAYSIZE
  31. #define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
  32. #endif
  33. #define ReleaseMemory(x) ReleaseMemoryWorker(reinterpret_cast<void**>(&x))
  34. #define ReleasePassword(x) ReleasePasswordWorker(reinterpret_cast<void**>(&x))
  35. #define ReleaseGDIObject(x) ReleaseGDIObjectWorker(reinterpret_cast<void**>(&x))
  36. static inline void ReleaseMemoryWorker (HLOCAL *memory)
  37. {
  38. if (*memory != NULL)
  39. {
  40. (HLOCAL)LocalFree(*memory);
  41. *memory = NULL;
  42. }
  43. }
  44. static inline void ReleasePasswordWorker (HLOCAL *memory)
  45. {
  46. if (*memory != NULL)
  47. {
  48. ZeroMemory(*memory, lstrlenW(reinterpret_cast<WCHAR*>(*memory)) + sizeof(L'\0'));
  49. (HLOCAL)LocalFree(*memory);
  50. *memory = NULL;
  51. }
  52. }
  53. static inline void ReleaseGDIObjectWorker (HGDIOBJ *hGDIObject)
  54. {
  55. if (*hGDIObject != NULL)
  56. {
  57. TBOOL(DeleteObject(*hGDIObject));
  58. *hGDIObject = NULL;
  59. }
  60. }
  61. static inline void ReleaseHandle (HANDLE& handle)
  62. {
  63. if (handle != NULL)
  64. {
  65. TBOOL(CloseHandle(handle));
  66. handle = NULL;
  67. }
  68. }
  69. static inline void ReleaseHWND (HWND& hwnd)
  70. {
  71. if (hwnd != NULL)
  72. {
  73. TBOOL(DestroyWindow(hwnd));
  74. hwnd = NULL;
  75. }
  76. }
  77. #endif /* _StandardHeader_ */