OSDN Git Service

use boost_1_56_0 and build by VS2013
[yamy/yamy.git] / misc.h
1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
2 // misc.h\r
3 \r
4 \r
5 #ifndef _MISC_H\r
6 #  define _MISC_H\r
7 \r
8 #  include "compiler_specific.h"\r
9 #  include <windows.h>\r
10 #  include <cassert>\r
11 \r
12 #define YAMY_SUCCESS                                            0\r
13 #define YAMY_ERROR_ON_GET_USERNAME                      1001\r
14 #define YAMY_ERROR_INSUFFICIENT_BUFFER          1002\r
15 #define YAMY_ERROR_NO_MEMORY                            1003\r
16 #define YAMY_ERROR_ON_GET_LOGONUSERNAME         1004\r
17 #define YAMY_ERROR_ON_GET_SECURITYINFO          1005\r
18 #define YAMY_ERROR_ON_GET_DACL                          1006\r
19 #define YAMY_ERROR_ON_INITIALIZE_ACL            1007\r
20 #define YAMY_ERROR_ON_GET_ACE                           1008\r
21 #define YAMY_ERROR_ON_ADD_ACE                           1009\r
22 #define YAMY_ERROR_ON_ADD_ALLOWED_ACE           1010\r
23 #define YAMY_ERROR_ON_SET_SECURITYINFO          1011\r
24 #define YAMY_ERROR_ON_OPEN_YAMY_PROCESS         1012\r
25 #define YAMY_ERROR_ON_OPEN_YAMY_TOKEN           1013\r
26 #define YAMY_ERROR_ON_IMPERSONATE                       1014\r
27 #define YAMY_ERROR_ON_REVERT_TO_SELF            1015\r
28 #define YAMY_ERROR_ON_OPEN_CURRENT_PROCESS      1016\r
29 #define YAMY_ERROR_ON_LOOKUP_PRIVILEGE          1017\r
30 #define YAMY_ERROR_ON_ADJUST_PRIVILEGE          1018\r
31 #define YAMY_ERROR_ON_OPEN_WINLOGON_PROCESS     1019\r
32 #define YAMY_ERROR_ON_VIRTUALALLOCEX            1020\r
33 #define YAMY_ERROR_ON_WRITEPROCESSMEMORY        1021\r
34 #define YAMY_ERROR_ON_CREATEREMOTETHREAD        1022\r
35 #define YAMY_ERROR_TIMEOUT_INJECTION            1023\r
36 #define YAMY_ERROR_RETRY_INJECTION_SUCCESS      1024\r
37 #define YAMY_ERROR_ON_READ_SCANCODE_MAP         1025\r
38 #define YAMY_ERROR_ON_WRITE_SCANCODE_MAP        1026\r
39 #define YAMY_ERROR_ON_GET_WINLOGON_PID          1027\r
40 \r
41 typedef unsigned char u_char;                   /// unsigned char\r
42 typedef unsigned short u_short;                 /// unsigned short\r
43 typedef unsigned long u_long;                   /// unsigned long\r
44 \r
45 typedef char int8;                              /// signed 8bit\r
46 typedef short int16;                            /// signed 16bit\r
47 typedef long int32;                             /// signed 32bit\r
48 typedef unsigned char u_int8;                   /// unsigned 8bit\r
49 typedef unsigned short u_int16;                 /// unsigned 16bit\r
50 typedef unsigned long u_int32;                  /// unsigned 32bit\r
51 #if defined(__BORLANDC__)\r
52 typedef unsigned __int64 u_int64;                       /// unsigned 64bit\r
53 #elif _MSC_VER <= 1300\r
54 typedef unsigned _int64 u_int64;                        /// unsigned 64bit\r
55 #else\r
56 typedef unsigned long long u_int64;                     /// unsigned 64bit\r
57 #endif\r
58 \r
59 \r
60 #  ifdef NDEBUG\r
61 #    define ASSERT(i_exp)\r
62 #    define CHECK(i_cond, i_exp)        i_exp\r
63 #    define CHECK_TRUE(i_exp)           i_exp\r
64 #    define CHECK_FALSE(i_exp)          i_exp\r
65 #  else // NDEBUG\r
66 /// assertion. i_exp is evaluated only in debug build\r
67 #    define ASSERT(i_exp)               assert(i_exp)\r
68 /// assertion, but i_exp is always evaluated\r
69 #    define CHECK(i_cond, i_exp)        assert(i_cond (i_exp))\r
70 /// identical to CHECK(!!, i_exp)\r
71 #    define CHECK_TRUE(i_exp)           assert(!!(i_exp))\r
72 /// identical to CHECK(!, i_exp)\r
73 #    define CHECK_FALSE(i_exp)          assert(!(i_exp))\r
74 #  endif // NDEBUG\r
75 \r
76 \r
77 /// get number of array elements\r
78 #  define NUMBER_OF(i_array) (sizeof(i_array) / sizeof((i_array)[0]))\r
79 \r
80 /// max path length\r
81 #  define GANA_MAX_PATH         (MAX_PATH * 4)\r
82 \r
83 /// max length of global atom\r
84 #  define GANA_MAX_ATOM_LENGTH  256\r
85 \r
86 #  undef MAX\r
87 /// redefine MAX macro\r
88 #  define MAX(a, b)     (((b) < (a)) ? (a) : (b))\r
89 \r
90 #  undef MIN\r
91 /// redefine MIN macro\r
92 #  define MIN(a, b)     (((a) < (b)) ? (a) : (b))\r
93 \r
94 \r
95 #endif // !_MISC_H\r