188 lines
5.2 KiB
C++
188 lines
5.2 KiB
C++
//+--------------------------------------------------------------------------
|
|
//
|
|
// Microsoft Windows
|
|
// Copyright (C) Microsoft Corporation, 1993
|
|
//
|
|
// File: ntdllmac.hxx
|
|
//
|
|
// Contents: various macros used in property set code
|
|
//
|
|
// History: 15-Jul-94 brianb created
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
extern "C" NTSTATUS
|
|
SynchronousNtFsControlFile(
|
|
IN HANDLE h,
|
|
OUT IO_STATUS_BLOCK *pisb,
|
|
IN ULONG FsControlCode,
|
|
IN VOID *pvIn OPTIONAL,
|
|
IN ULONG cbIn,
|
|
OUT VOID *pvOut OPTIONAL,
|
|
IN ULONG cbOut);
|
|
|
|
|
|
//+---------------------------------------------------------------------------
|
|
// Function: Add2Ptr
|
|
//
|
|
// Synopsis: Add an unscaled increment to a ptr regardless of type.
|
|
//
|
|
// Arguments: [pv] -- Initial ptr.
|
|
// [cb] -- Increment
|
|
//
|
|
// Returns: Incremented ptr.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
inline VOID *
|
|
Add2Ptr(VOID *pv, ULONG cb)
|
|
{
|
|
return((BYTE *) pv + cb);
|
|
}
|
|
|
|
|
|
//+---------------------------------------------------------------------------
|
|
// Function: Add2ConstPtr
|
|
//
|
|
// Synopsis: Add an unscaled increment to a ptr regardless of type.
|
|
//
|
|
// Arguments: [pv] -- Initial ptr.
|
|
// [cb] -- Increment
|
|
//
|
|
// Returns: Incremented ptr.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
inline
|
|
const VOID *
|
|
Add2ConstPtr(const VOID *pv, ULONG cb)
|
|
{
|
|
return((const BYTE *) pv + cb);
|
|
}
|
|
|
|
|
|
//+--------------------------------------------------------------------------
|
|
// Function: CopyFileTime, private
|
|
//
|
|
// Synopsis: Copy LARGE_INTEGER time to FILETIME structure
|
|
//
|
|
// Arguments: [pft] -- pointer to FILETIME
|
|
// [pli] -- pointer to LARGE_INTEGER
|
|
//
|
|
// Returns: Nothing
|
|
//---------------------------------------------------------------------------
|
|
|
|
__inline VOID
|
|
CopyFileTime(OUT FILETIME *pft, IN LARGE_INTEGER *pli)
|
|
{
|
|
pft->dwLowDateTime = pli->LowPart;
|
|
pft->dwHighDateTime = pli->HighPart;
|
|
}
|
|
|
|
|
|
//+--------------------------------------------------------------------------
|
|
// Function: ZeroFileTime, private
|
|
//
|
|
// Synopsis: Zero FILETIME structure
|
|
//
|
|
// Arguments: [pft] -- pointer to FILETIME
|
|
//
|
|
// Returns: Nothing
|
|
//---------------------------------------------------------------------------
|
|
|
|
__inline VOID
|
|
ZeroFileTime(OUT FILETIME *pft)
|
|
{
|
|
pft->dwLowDateTime = pft->dwHighDateTime = 0;
|
|
}
|
|
|
|
|
|
#define DwordAlign(n) (((n) + sizeof(ULONG) - 1) & ~(sizeof(ULONG) - 1))
|
|
#define QuadAlign(n) (((n) + sizeof(LONGLONG) - 1) & ~(sizeof(LONGLONG) - 1))
|
|
|
|
// stuff to make Nashville properties build
|
|
#include <propapi.h>
|
|
|
|
#if DBG
|
|
extern "C" LONG ExceptionFilter(struct _EXCEPTION_POINTERS *pep);
|
|
#else // DBG
|
|
#define ExceptionFilter(pep) EXCEPTION_EXECUTE_HANDLER
|
|
#endif // DBG
|
|
|
|
extern "C" UNICODECALLOUTS UnicodeCallouts;
|
|
|
|
|
|
// The CMemSerStream and CDeMemSerStream have different requirements for
|
|
// handling buffer overflow conditions. In the case of the driver this
|
|
// is indicative of a corrupted stream and we would like to raise an
|
|
// exception. On the other hand in Query implementation we deal with
|
|
// streams whose sizes are precomputed in the user mode. Therefore we
|
|
// do not wish to incur any additional penalty in handling such situations.
|
|
// In debug builds this condition is asserted while in retail builds it is
|
|
// ignored. The CMemSerStream and CMemDeSerStream implementation are
|
|
// implemented using a macro HANDLE_OVERFLOW(fOverflow) which take the
|
|
// appropriate action.
|
|
|
|
#define HANDLE_OVERFLOW(fOverflow) \
|
|
if (fOverflow) { \
|
|
PropRaiseException(STATUS_BUFFER_OVERFLOW); \
|
|
}
|
|
|
|
|
|
void* _CRTAPI1 operator new(size_t cb);
|
|
void _CRTAPI1 operator delete(void *pv);
|
|
|
|
#define newk(Tag, pCounter) new
|
|
|
|
#if DBG
|
|
extern "C" ULONG DebugLevel;
|
|
extern "C" ULONG DebugIndent;
|
|
|
|
#define DEBTRACE_ERROR (ULONG) 0x00000001
|
|
#define DEBTRACE_WARN (ULONG) 0x00000002
|
|
#define DEBTRACE_CREATESTREAM (ULONG) 0x00000004
|
|
#define DEBTRACE_NTPROP (ULONG) 0x00000008
|
|
#define DEBTRACE_MAPSTM (ULONG) 0x00000010
|
|
#define DEBTRACE_PROPERTY (ULONG) 0x00000020
|
|
#define DEBTRACE_SUMCAT (ULONG) 0x00000040
|
|
|
|
#ifndef WINNT
|
|
// in Nashville this is defined in ole32\stg\props\utils.cxx
|
|
extern ULONG DbgPrint(PCHAR Format, ...);
|
|
#endif
|
|
|
|
#define DebugTrace(indent, flag, args) \
|
|
if ((flag) == 0 || (DebugLevel & (flag))) \
|
|
{ \
|
|
DebugIndent += (ULONG) (indent); \
|
|
DbgPrint("NTDLL: %*s", DebugIndent, ""); \
|
|
DbgPrint args; \
|
|
} \
|
|
else
|
|
|
|
class CDebugTrace {
|
|
public:
|
|
inline CDebugTrace(CHAR *psz);
|
|
inline ~CDebugTrace();
|
|
private:
|
|
CHAR const *const _psz;
|
|
};
|
|
|
|
inline CDebugTrace::CDebugTrace(CHAR *psz): _psz(psz)
|
|
{
|
|
DebugTrace(+1, 0, ("Entering -- %s\n", _psz));
|
|
}
|
|
|
|
inline CDebugTrace::~CDebugTrace()
|
|
{
|
|
DebugTrace(-1, 0, ("Exiting -- %s\n", _psz));
|
|
}
|
|
|
|
#define DEBUG_TRACE(ProcName) CDebugTrace _trace_(#ProcName);
|
|
#else
|
|
#define DebugTrace(indent, flag, args)
|
|
#define DEBUG_TRACE(ProcName)
|
|
#endif
|
|
|