|
|
@ -19,7 +19,12 @@ |
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MAIN_H |
|
|
|
|
|
|
|
#define MAIN_H |
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
|
#include <stdio.h> |
|
|
|
|
|
|
|
#include <stdarg.h> |
|
|
|
|
|
|
|
#include <tchar.h> |
|
|
|
|
|
|
|
|
|
|
|
/* Define this to enable DEBUG build */ |
|
|
|
/* Define this to enable DEBUG build */ |
|
|
|
//#define DEBUG
|
|
|
|
//#define DEBUG
|
|
|
@ -58,31 +63,43 @@ struct security_attributes |
|
|
|
SECURITY_DESCRIPTOR sd; |
|
|
|
SECURITY_DESCRIPTOR sd; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/* Return the number of elements in an array */ |
|
|
|
/* Return the number of elements in an TCHAR array */ |
|
|
|
#define ELEMENTS(x) sizeof(x)/sizeof(*(x)) |
|
|
|
static inline size_t |
|
|
|
|
|
|
|
_tsizeof(TCHAR x[]) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return (sizeof(x) / sizeof(*x)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* clear an object */ |
|
|
|
/* clear an object */ |
|
|
|
#define CLEAR(x) memset(&(x), 0, sizeof(x)) |
|
|
|
#define CLEAR(x) memset(&(x), 0, sizeof(x)) |
|
|
|
|
|
|
|
|
|
|
|
/* snprintf with guaranteed null termination */ |
|
|
|
/* _sntprintf with guaranteed \0 termination */ |
|
|
|
#define mysnprintf(out, ...) \ |
|
|
|
static inline int |
|
|
|
{ \
|
|
|
|
_sntprintf_0(TCHAR *buf, TCHAR *format, ...) |
|
|
|
snprintf (out, sizeof(out), __VA_ARGS__); \
|
|
|
|
{ |
|
|
|
out [sizeof (out) - 1] = '\0'; \
|
|
|
|
int i; |
|
|
|
} |
|
|
|
va_list args; |
|
|
|
|
|
|
|
va_start(args, format); |
|
|
|
|
|
|
|
i = _vsntprintf(buf, _tsizeof(buf), format, args); |
|
|
|
|
|
|
|
buf[_tsizeof(buf) - 1] = _T('\0'); |
|
|
|
|
|
|
|
va_end(args); |
|
|
|
|
|
|
|
return i; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
/* Print Debug Message */ |
|
|
|
/* Print Debug Message */ |
|
|
|
#define PrintDebug(args...) \ |
|
|
|
#define PrintDebug(...) \ |
|
|
|
{ \
|
|
|
|
{ \
|
|
|
|
char x_msg[256]; \
|
|
|
|
TCHAR x_msg[256]; \
|
|
|
|
mysnprintf (x_msg, args); \
|
|
|
|
_sntprintf_0(x_msg, __VA_ARGS__); \
|
|
|
|
PrintDebugMsg(x_msg); \
|
|
|
|
PrintDebugMsg(x_msg); \
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PrintDebugMsg(char *msg); |
|
|
|
void PrintDebugMsg(TCHAR *msg); |
|
|
|
void PrintErrorDebug(char *msg); |
|
|
|
void PrintErrorDebug(TCHAR *msg); |
|
|
|
bool init_security_attributes_allow_all (struct security_attributes *obj); |
|
|
|
bool init_security_attributes_allow_all (struct security_attributes *obj); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
DWORD GetDllVersion(LPCTSTR lpszDllName); |
|
|
|
DWORD GetDllVersion(LPCTSTR lpszDllName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|