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.

100 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 goto !!DO NOT USE GOTO!! - DO NOT REMOVE THIS ON PAIN OF DEATH
  34. #define ReleaseMemory(x) ReleaseMemoryWorker(reinterpret_cast<void**>(&x))
  35. #define ReleasePassword(x) ReleasePasswordWorker(reinterpret_cast<void**>(&x))
  36. #define ReleaseGDIObject(x) ReleaseGDIObjectWorker(reinterpret_cast<void**>(&x))
  37. static inline void ReleaseMemoryWorker (HLOCAL *memory)
  38. {
  39. if (*memory != NULL)
  40. {
  41. (HLOCAL)LocalFree(*memory);
  42. *memory = NULL;
  43. }
  44. }
  45. static inline void ReleasePasswordWorker (HLOCAL *memory)
  46. {
  47. if (*memory != NULL)
  48. {
  49. ZeroMemory(*memory, lstrlenW(reinterpret_cast<WCHAR*>(*memory)) + sizeof(L'\0'));
  50. (HLOCAL)LocalFree(*memory);
  51. *memory = NULL;
  52. }
  53. }
  54. static inline void ReleaseGDIObjectWorker (HGDIOBJ *hGDIObject)
  55. {
  56. if (*hGDIObject != NULL)
  57. {
  58. TBOOL(DeleteObject(*hGDIObject));
  59. *hGDIObject = NULL;
  60. }
  61. }
  62. static inline void ReleaseHandle (HANDLE& handle)
  63. {
  64. if (handle != NULL)
  65. {
  66. TBOOL(CloseHandle(handle));
  67. handle = NULL;
  68. }
  69. }
  70. static inline void ReleaseHWND (HWND& hwnd)
  71. {
  72. if (hwnd != NULL)
  73. {
  74. TBOOL(DestroyWindow(hwnd));
  75. hwnd = NULL;
  76. }
  77. }
  78. #endif /* _StandardHeader_ */