shared_globals.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. #ifdef IS_LIBRARY
  69. #define MESSAGE_BUFFER_SIZE 256
  70. EXTERNC __declspec(EXTERNAL) 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_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32)
  93. extern int_fast8_t IsRestarted;
  94. #endif // !defined(NO_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32)
  95. #if !defined(NO_TIMEOUT) && !__minix__
  96. extern DWORD ServerTimeout;
  97. #endif // !defined(NO_TIMEOUT) && !__minix__
  98. #if !defined(NO_LIMIT) && !defined (NO_SOCKETS) && !__minix__
  99. extern uint32_t MaxTasks;
  100. #endif // !defined(NO_LIMIT) && !defined (NO_SOCKETS) && !__minix__
  101. #ifndef NO_LOG
  102. extern char *fn_log;
  103. extern int_fast8_t logstdout;
  104. #ifndef NO_VERBOSE_LOG
  105. extern int_fast8_t logverbose;
  106. #endif
  107. #endif
  108. #ifndef NO_RANDOM_EPID
  109. extern int_fast8_t RandomizationLevel;
  110. extern uint16_t Lcid;
  111. #endif
  112. #if !defined(NO_SOCKETS) && !defined(USE_MSRPC)
  113. #if defined(SIMPLE_SOCKETS)
  114. extern SOCKET s_server;
  115. #else // !defined(SIMPLE_SOCKETS)
  116. extern SOCKET *SocketList;
  117. extern int numsockets;
  118. #endif // !defined(SIMPLE_SOCKETS)
  119. #if !defined(NO_LIMIT) && !__minix__
  120. #ifndef _WIN32
  121. extern sem_t *Semaphore;
  122. #else // _WIN32
  123. extern HANDLE Semaphore;
  124. #endif // _WIN32
  125. #endif // !defined(NO_LIMIT) && !__minix__
  126. #endif // !defined(NO_SOCKETS) && !defined(USE_MSRPC)
  127. #ifdef _NTSERVICE
  128. extern int_fast8_t IsNTService;
  129. extern int_fast8_t ServiceShutdown;
  130. #endif
  131. #ifndef NO_LOG
  132. #ifdef USE_THREADS
  133. #if !defined(_WIN32) && !defined(__CYGWIN__)
  134. extern pthread_mutex_t logmutex;
  135. #else
  136. extern CRITICAL_SECTION logmutex;
  137. #endif // _WIN32
  138. #endif // USE_THREADS
  139. #endif // NO_LOG
  140. #if HAVE_FREEBIND
  141. extern int_fast8_t freebind;
  142. #endif // HAVE_FREEBIND
  143. #endif // INCLUDED_SHARED_GLOBALS_H