shared_globals.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #ifndef INCLUDED_SHARED_GLOBALS_H
  2. #define INCLUDED_SHARED_GLOBALS_H
  3. #ifndef CONFIG
  4. #define CONFIG "config.h"
  5. #endif // CONFIG
  6. #include CONFIG
  7. #include <sys/types.h>
  8. #ifndef _WIN32
  9. #include <sys/socket.h>
  10. #include <netinet/in.h>
  11. #include <arpa/inet.h>
  12. #include <netdb.h>
  13. #include <pwd.h>
  14. #include <grp.h>
  15. #include <syslog.h>
  16. #if (!defined(NO_LIMIT) || defined(USE_THREADS)) && !__minix__
  17. #include <pthread.h>
  18. #endif // (!defined(NO_LIMIT) || defined(USE_THREADS)) && !__minix__
  19. #include <fcntl.h>
  20. #include <sys/stat.h>
  21. #if !defined(NO_LIMIT) && !__minix__
  22. #include <semaphore.h>
  23. #endif // !defined(NO_LIMIT) && !__minix__
  24. #else
  25. #ifndef USE_MSRPC
  26. #include <winsock2.h>
  27. #include <ws2tcpip.h>
  28. #endif // USE_MSRPC
  29. #include <windows.h>
  30. #endif
  31. #include <signal.h>
  32. #include <unistd.h>
  33. #include <time.h>
  34. #include <stdio.h>
  35. #include <stdlib.h>
  36. #include <string.h>
  37. #include <stdint.h>
  38. #include <limits.h>
  39. #include <ctype.h>
  40. #include <stdarg.h>
  41. //#include <semaphore.h>
  42. #include "types.h"
  43. #define MAX_KMSAPPS 3
  44. typedef struct
  45. {
  46. const char* Epid;
  47. const BYTE* HwId;
  48. #ifndef NO_LOG
  49. const char* EpidSource;
  50. #endif // NO_LOG
  51. } KmsResponseParam_t, *PKmsResponseParam_t;
  52. #if !defined(NO_LIMIT) && !__minix__
  53. #ifndef SEM_VALUE_MAX // Android does not define this
  54. #ifdef __ANDROID__
  55. #define SEM_VALUE_MAX 0x3fffffff
  56. #elif !defined(_WIN32)
  57. #define SEM_VALUE_MAX 0x7fffffff
  58. #else
  59. #define SEM_VALUE_MAX 0x7fff // Be cautious if unknown
  60. #endif // __ANDROID__
  61. #endif // !defined(SEM_VALUE_MAX)
  62. #endif // !defined(NO_LIMIT) && !__minix__
  63. extern const char *const Version;
  64. //Fix for stupid eclipse parser
  65. #ifndef UINT_MAX
  66. #define UINT_MAX 4294967295
  67. #endif
  68. #define MESSAGE_BUFFER_SIZE 4096
  69. #ifdef IS_LIBRARY
  70. extern char ErrorMessage[MESSAGE_BUFFER_SIZE];
  71. #endif // IS_LIBRARY
  72. extern int global_argc, multi_argc;
  73. extern CARGV global_argv, multi_argv;
  74. #ifndef _WIN32
  75. extern int_fast8_t nodaemon;
  76. #endif // _WIN32
  77. extern DWORD VLActivationInterval;
  78. extern DWORD VLRenewalInterval;
  79. extern int_fast8_t DisconnectImmediately;
  80. extern KmsResponseParam_t KmsResponseParameters[MAX_KMSAPPS];
  81. extern const char *const cIPv4;
  82. extern const char *const cIPv6;
  83. extern int_fast8_t InetdMode;
  84. #ifndef USE_MSRPC
  85. extern int_fast8_t UseMultiplexedRpc;
  86. extern int_fast8_t UseRpcNDR64;
  87. extern int_fast8_t UseRpcBTFN;
  88. #endif // USE_MSRPC
  89. #ifndef NO_SOCKETS
  90. extern const char *defaultport;
  91. #endif // NO_SOCKETS
  92. #if !defined(NO_PRIVATE_IP_DETECT)
  93. extern uint32_t PublicIPProtectionLevel;
  94. #endif
  95. #if !defined(NO_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32)
  96. extern int_fast8_t IsRestarted;
  97. #endif // !defined(NO_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32)
  98. #if !defined(NO_TIMEOUT) && !__minix__
  99. extern DWORD ServerTimeout;
  100. #endif // !defined(NO_TIMEOUT) && !__minix__
  101. #if !defined(NO_LIMIT) && !defined (NO_SOCKETS) && !__minix__
  102. extern uint32_t MaxTasks;
  103. #endif // !defined(NO_LIMIT) && !defined (NO_SOCKETS) && !__minix__
  104. #ifndef NO_LOG
  105. extern int_fast8_t LogDateAndTime;
  106. extern char *fn_log;
  107. extern int_fast8_t logstdout;
  108. #ifndef NO_VERBOSE_LOG
  109. extern int_fast8_t logverbose;
  110. #endif
  111. #endif
  112. #ifndef NO_RANDOM_EPID
  113. extern int_fast8_t RandomizationLevel;
  114. extern uint16_t Lcid;
  115. #endif
  116. #if !defined(NO_SOCKETS) && !defined(USE_MSRPC)
  117. #if defined(SIMPLE_SOCKETS)
  118. extern SOCKET s_server;
  119. #else // !defined(SIMPLE_SOCKETS)
  120. extern SOCKET *SocketList;
  121. extern int numsockets;
  122. #endif // !defined(SIMPLE_SOCKETS)
  123. #if !defined(NO_LIMIT) && !__minix__
  124. #ifndef _WIN32
  125. extern sem_t *Semaphore;
  126. #else // _WIN32
  127. extern HANDLE Semaphore;
  128. #endif // _WIN32
  129. #endif // !defined(NO_LIMIT) && !__minix__
  130. #endif // !defined(NO_SOCKETS) && !defined(USE_MSRPC)
  131. #ifdef _NTSERVICE
  132. extern int_fast8_t IsNTService;
  133. extern int_fast8_t ServiceShutdown;
  134. #endif
  135. #ifndef NO_LOG
  136. #ifdef USE_THREADS
  137. #if !defined(_WIN32) && !defined(__CYGWIN__)
  138. extern pthread_mutex_t logmutex;
  139. #else
  140. extern CRITICAL_SECTION logmutex;
  141. #endif // _WIN32
  142. #endif // USE_THREADS
  143. #endif // NO_LOG
  144. #if HAVE_FREEBIND
  145. extern int_fast8_t freebind;
  146. #endif // HAVE_FREEBIND
  147. #endif // INCLUDED_SHARED_GLOBALS_H