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.

175 lines
5.0 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993
  5. //
  6. // File: ntdllmac.hxx
  7. //
  8. // Contents: various macros used in property set code
  9. //
  10. // History: 15-Jul-94 brianb created
  11. // 06-May-98 MikeHill Removed the defunct UnicodeCallouts.
  12. //
  13. //---------------------------------------------------------------------------
  14. extern "C" NTSTATUS
  15. SynchronousNtFsControlFile(
  16. IN HANDLE h,
  17. OUT IO_STATUS_BLOCK *pisb,
  18. IN ULONG FsControlCode,
  19. IN VOID *pvIn OPTIONAL,
  20. IN ULONG cbIn,
  21. OUT VOID *pvOut OPTIONAL,
  22. IN ULONG cbOut);
  23. //+---------------------------------------------------------------------------
  24. // Function: Add2Ptr
  25. //
  26. // Synopsis: Add an unscaled increment to a ptr regardless of type.
  27. //
  28. // Arguments: [pv] -- Initial ptr.
  29. // [cb] -- Increment
  30. //
  31. // Returns: Incremented ptr.
  32. //
  33. //----------------------------------------------------------------------------
  34. inline VOID *
  35. Add2Ptr(VOID *pv, LONG cb)
  36. {
  37. return((BYTE *) pv + cb);
  38. }
  39. //+---------------------------------------------------------------------------
  40. // Function: Add2ConstPtr
  41. //
  42. // Synopsis: Add an unscaled increment to a ptr regardless of type.
  43. //
  44. // Arguments: [pv] -- Initial ptr.
  45. // [cb] -- Increment
  46. //
  47. // Returns: Incremented ptr.
  48. //
  49. //----------------------------------------------------------------------------
  50. inline
  51. const VOID *
  52. Add2ConstPtr(const VOID *pv, LONG cb)
  53. {
  54. return((const BYTE *) pv + cb);
  55. }
  56. //+--------------------------------------------------------------------------
  57. // Function: CopyFileTime, private
  58. //
  59. // Synopsis: Copy LARGE_INTEGER time to FILETIME structure
  60. //
  61. // Arguments: [pft] -- pointer to FILETIME
  62. // [pli] -- pointer to LARGE_INTEGER
  63. //
  64. // Returns: Nothing
  65. //---------------------------------------------------------------------------
  66. __inline VOID
  67. CopyFileTime(OUT FILETIME *pft, IN LARGE_INTEGER *pli)
  68. {
  69. pft->dwLowDateTime = pli->LowPart;
  70. pft->dwHighDateTime = pli->HighPart;
  71. }
  72. //+--------------------------------------------------------------------------
  73. // Function: ZeroFileTime, private
  74. //
  75. // Synopsis: Zero FILETIME structure
  76. //
  77. // Arguments: [pft] -- pointer to FILETIME
  78. //
  79. // Returns: Nothing
  80. //---------------------------------------------------------------------------
  81. __inline VOID
  82. ZeroFileTime(OUT FILETIME *pft)
  83. {
  84. pft->dwLowDateTime = pft->dwHighDateTime = 0;
  85. }
  86. #define DwordAlign(n) (((n) + sizeof(ULONG) - 1) & ~(sizeof(ULONG) - 1))
  87. #define QuadAlign(n) (((n) + sizeof(LONGLONG) - 1) & ~(sizeof(LONGLONG) - 1))
  88. // stuff to make Nashville properties build
  89. #include <propapi.h>
  90. #if DBG
  91. extern "C" LONG ExceptionFilter(struct _EXCEPTION_POINTERS *pep);
  92. #else // DBG
  93. #define ExceptionFilter(pep) EXCEPTION_EXECUTE_HANDLER
  94. #endif // DBG
  95. // The CMemSerStream and CDeMemSerStream have different requirements for
  96. // handling buffer overflow conditions. In the case of the driver this
  97. // is indicative of a corrupted stream and we would like to raise an
  98. // exception. On the other hand in Query implementation we deal with
  99. // streams whose sizes are precomputed in the user mode. Therefore we
  100. // do not wish to incur any additional penalty in handling such situations.
  101. // In debug builds this condition is asserted while in retail builds it is
  102. // ignored. The CMemSerStream and CMemDeSerStream implementation are
  103. // implemented using a macro HANDLE_OVERFLOW(fOverflow) which take the
  104. // appropriate action.
  105. #define HANDLE_OVERFLOW(fOverflow) \
  106. if (fOverflow) { \
  107. PropRaiseException(STATUS_BUFFER_OVERFLOW); \
  108. }
  109. #define newk(Tag, pCounter) new
  110. #if DBG
  111. extern "C" ULONG DebugLevel;
  112. extern "C" ULONG DebugIndent;
  113. #ifndef WINNT
  114. // in Nashville this is defined in ole32\stg\props\utils.cxx
  115. extern ULONG DbgPrint(PCHAR Format, ...);
  116. #endif
  117. #define DebugTrace(indent, flag, args) \
  118. if ((flag) == 0 || (DebugLevel & (flag))) \
  119. { \
  120. DebugIndent += (ULONG) (indent); \
  121. DbgPrint("Prop: %*s", DebugIndent, ""); \
  122. DbgPrint args; \
  123. } \
  124. else
  125. class CDebugTrace {
  126. public:
  127. inline CDebugTrace(CHAR *psz);
  128. inline ~CDebugTrace();
  129. private:
  130. CHAR const *const _psz;
  131. };
  132. inline CDebugTrace::CDebugTrace(CHAR *psz): _psz(psz)
  133. {
  134. DebugTrace(+1, 0, ("Entering -- %s\n", _psz));
  135. }
  136. inline CDebugTrace::~CDebugTrace()
  137. {
  138. DebugTrace(-1, 0, ("Exiting -- %s\n", _psz));
  139. }
  140. #define DEBUG_TRACE(ProcName) CDebugTrace _trace_(#ProcName);
  141. #else
  142. #define DebugTrace(indent, flag, args) {}
  143. #define DEBUG_TRACE(ProcName)
  144. #endif