Files
mirror-processhacker/2.x/trunk/ProcessHacker/include/base.h
T
wj32 30981015f7 * ported KPH interfacing code from NPH
* added most missing KPH functions

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@2532 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2009-12-29 11:08:23 +00:00

61 lines
1.5 KiB
C

#ifndef BASE_H
#define BASE_H
#ifndef UNICODE
#define UNICODE
#endif
#include <ntwin.h>
#include <intrin.h>
// nonstandard extension used : nameless struct/union
#pragma warning(disable: 4201)
// nonstandard extension used : bit field types other than int
#pragma warning(disable: 4214)
// 'function': was declared deprecated
#pragma warning(disable: 4996)
#define PH_INT_STR_LEN 10
#define PH_INT_STR_LEN_1 (PH_INT_STR_LEN + 1)
#define PTR_ADD_OFFSET(Pointer, Offset) ((PVOID)((ULONG_PTR)(Pointer) + (ULONG_PTR)(Offset)))
#define REBASE_ADDRESS(Pointer, OldBase, NewBase) \
((PVOID)((ULONG_PTR)(Pointer) - (ULONG_PTR)(OldBase) + (ULONG_PTR)(NewBase)))
#define WCHAR_LONG_TO_SHORT(Long) (((Long) & 0xff) | (((Long) & 0xff0000) >> 16))
#define PH_TIMEOUT_TO_MS ((LONGLONG)1 * 10 * 1000)
#define PH_TIMEOUT_TO_SEC (PH_TIMEOUT_TO_MS * 1000)
#define PhRaiseStatus(Status) RaiseException(Status, 0, 0, NULL)
#ifdef _M_IX86
PVOID FORCEINLINE _InterlockedCompareExchangePointer(
__inout PVOID volatile *Destination,
__in PVOID Exchange,
__in PVOID Comparand
)
{
return (PVOID)_InterlockedCompareExchange(
(PLONG_PTR)Destination,
(LONG_PTR)Exchange,
(LONG_PTR)Comparand
);
}
PVOID FORCEINLINE _InterlockedExchangePointer(
__inout PVOID volatile *Destination,
__in PVOID Exchange
)
{
return (PVOID)_InterlockedExchange(
(PLONG_PTR)Destination,
(LONG_PTR)Exchange
);
}
#endif
#endif