shared_globals.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. extern int global_argc, multi_argc;
  69. extern CARGV global_argv, multi_argv;
  70. extern int_fast8_t nodaemon;
  71. extern DWORD VLActivationInterval;
  72. extern DWORD VLRenewalInterval;
  73. extern int_fast8_t DisconnectImmediately;
  74. extern KmsResponseParam_t KmsResponseParameters[MAX_KMSAPPS];
  75. extern const char *const cIPv4;
  76. extern const char *const cIPv6;
  77. extern int_fast8_t InetdMode;
  78. #ifndef USE_MSRPC
  79. extern int_fast8_t UseMultiplexedRpc;
  80. extern int_fast8_t UseRpcNDR64;
  81. extern int_fast8_t UseRpcBTFN;
  82. #endif // USE_MSRPC
  83. #ifndef NO_SOCKETS
  84. extern const char *defaultport;
  85. #endif // NO_SOCKETS
  86. #if !defined(NO_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32)
  87. extern int_fast8_t IsRestarted;
  88. #endif // !defined(NO_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32)
  89. #if !defined(NO_TIMEOUT) && !__minix__
  90. extern DWORD ServerTimeout;
  91. #endif // !defined(NO_TIMEOUT) && !__minix__
  92. #if !defined(NO_LIMIT) && !defined (NO_SOCKETS) && !__minix__
  93. extern uint32_t MaxTasks;
  94. #endif // !defined(NO_LIMIT) && !defined (NO_SOCKETS) && !__minix__
  95. #ifndef NO_LOG
  96. extern char *fn_log;
  97. extern int_fast8_t logstdout;
  98. #ifndef NO_VERBOSE_LOG
  99. extern int_fast8_t logverbose;
  100. #endif
  101. #endif
  102. #ifndef NO_RANDOM_EPID
  103. extern int_fast8_t RandomizationLevel;
  104. extern uint16_t Lcid;
  105. #endif
  106. #if !defined(NO_SOCKETS) && !defined(USE_MSRPC)
  107. extern SOCKET *SocketList;
  108. extern int numsockets;
  109. #if !defined(NO_LIMIT) && !__minix__
  110. #ifndef _WIN32
  111. extern sem_t *Semaphore;
  112. #else // _WIN32
  113. extern HANDLE Semaphore;
  114. #endif // _WIN32
  115. #endif // !defined(NO_LIMIT) && !__minix__
  116. #endif // !defined(NO_SOCKETS) && !defined(USE_MSRPC)
  117. #ifdef _NTSERVICE
  118. extern int_fast8_t IsNTService;
  119. extern int_fast8_t ServiceShutdown;
  120. #endif
  121. #ifndef NO_LOG
  122. #ifdef USE_THREADS
  123. #if !defined(_WIN32) && !defined(__CYGWIN__)
  124. extern pthread_mutex_t logmutex;
  125. #else
  126. extern CRITICAL_SECTION logmutex;
  127. #endif // _WIN32
  128. #endif // USE_THREADS
  129. #endif // NO_LOG
  130. #endif // INCLUDED_SHARED_GLOBALS_H