Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
5.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef PROTECTED_THINGS_H
  8. #define PROTECTED_THINGS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. // This header tries to prevent people from using potentially dangerous functions
  13. // (like the notorious non-null-terminating strncpy) and functions that will break
  14. // VCR mode (like time, input, registry, etc).
  15. //
  16. // This header should be included by ALL of our source code.
  17. // Eventually, ALL of these should be protected, but one man can only accomplish so much in
  18. // one day AND work on features too!
  19. #if defined( PROTECTED_STRINGS_ENABLE )
  20. #if defined( printf )
  21. #undef printf
  22. #endif
  23. #define printf printf__HEY_YOU__USE_VSTDLIB
  24. #if defined( wprintf )
  25. #undef wprintf
  26. #endif
  27. #define wprintf wprintf__HEY_YOU__USE_VSTDLIB
  28. #if defined( strcmp )
  29. #undef strcmp
  30. #endif
  31. #define strcmp strcmp__HEY_YOU__USE_VSTDLIB
  32. #if defined( wcscmp )
  33. #undef wcscmp
  34. #endif
  35. #define wcscmp wcscmp__HEY_YOU__USE_VSTDLIB
  36. #if defined( strncpy )
  37. #undef strncpy
  38. #endif
  39. #define strncpy strncpy__HEY_YOU__USE_VSTDLIB
  40. #if defined( wcsncpy )
  41. #undef wcsncpy
  42. #endif
  43. #define wcsncpy wcsncpy__HEY_YOU__USE_VSTDLIB
  44. #if defined( strlen )
  45. #undef strlen
  46. #endif
  47. #define strlen strlen__HEY_YOU__USE_VSTDLIB
  48. #if defined( wcslen )
  49. #undef wcslen
  50. #endif
  51. #define wcslen wcslen__HEY_YOU__USE_VSTDLIB
  52. #if defined( Q_strlen )
  53. #undef Q_strlen
  54. #endif
  55. #define Q_strlen Q_strlen__HEY_YOU__USE_VSTDLIB
  56. #if defined( _snprintf )
  57. #undef _snprintf
  58. #endif
  59. #define _snprintf snprintf__HEY_YOU__USE_VSTDLIB
  60. #if defined( _snwprintf )
  61. #undef _snwprintf
  62. #endif
  63. #define _snwprintf snwprintf__HEY_YOU__USE_VSTDLIB
  64. #if defined( sprintf )
  65. #undef sprintf
  66. #endif
  67. #define sprintf sprintf__HEY_YOU__USE_VSTDLIB
  68. #if defined( swprintf )
  69. #undef swprintf
  70. #endif
  71. #define swprintf swprintf__HEY_YOU__USE_VSTDLIB
  72. #if defined( vsprintf )
  73. #undef vsprintf
  74. #endif
  75. #define vsprintf vsprintf__HEY_YOU__USE_VSTDLIB
  76. #if defined( vswprintf )
  77. #undef vswprintf
  78. #endif
  79. #define vswprintf vswprintf__HEY_YOU__USE_VSTDLIB
  80. #if defined( _vsnprintf )
  81. #undef _vsnprintf
  82. #endif
  83. #define _vsnprintf vsnprintf__HEY_YOU__USE_VSTDLIB
  84. #if defined( _vsnwprintf )
  85. #undef _vsnwprintf
  86. #endif
  87. #define _vsnwprintf vsnwprintf__HEY_YOU__USE_VSTDLIB
  88. #if defined( strcat )
  89. #undef strcat
  90. #endif
  91. #define strcat strcat__HEY_YOU__USE_VSTDLIB
  92. #if defined( wcscat )
  93. #undef wcscat
  94. #endif
  95. #define wcscat wcscat__HEY_YOU__USE_VSTDLIB
  96. #if defined( strncat )
  97. #undef strncat
  98. #endif
  99. #define strncat strncat__HEY_YOU__USE_VSTDLIB
  100. #if defined( wcsncat )
  101. #undef wcsncat
  102. #endif
  103. #define wcsncat wcsncat__HEY_YOU__USE_VSTDLIB
  104. #endif
  105. #if defined( PROTECTED_THINGS_ENABLE ) && !defined( _X360 )
  106. #if defined( GetTickCount )
  107. #undef GetTickCount
  108. #endif
  109. #define GetTickCount Use__Plat_MSTime__Instead_of_GetTickCount
  110. #if defined( timeGetTime )
  111. #undef timeGetTime
  112. #endif
  113. #define timeGetTime Use__Plat_MSTime__Instead_of_timeGetTime
  114. #if defined( clock )
  115. #undef clock
  116. #endif
  117. #if defined( GetCursorPos )
  118. #undef GetCursorPos
  119. #endif
  120. #define GetCursorPos GetCursorPos__USE_VCR_MODE
  121. #if defined( ScreenToClient )
  122. #undef ScreenToClient
  123. #endif
  124. #define ScreenToClient ScreenToClient__USE_VCR_MODE
  125. // JAY64: Revisit this, but squelch the warnings for now
  126. #ifndef _WIN64
  127. #if defined( GetCommandLine )
  128. #undef GetCommandLine
  129. #endif
  130. #define GetCommandLine GetCommandLine__USE_VCR_MODE
  131. #if defined( RegOpenKeyEx )
  132. #undef RegOpenKeyEx
  133. #endif
  134. #define RegOpenKeyEx RegOpenKeyEx__USE_VCR_MODE
  135. #if defined( RegOpenKey )
  136. #undef RegOpenKey
  137. #endif
  138. #define RegOpenKey RegOpenKey__USE_VCR_MODE
  139. #if defined( RegSetValueEx )
  140. #undef RegSetValueEx
  141. #endif
  142. #define RegSetValueEx RegSetValueEx__USE_VCR_MODE
  143. #if defined( RegSetValue )
  144. #undef RegSetValue
  145. #endif
  146. #define RegSetValue RegSetValue__USE_VCR_MODE
  147. #if defined( RegQueryValueEx )
  148. #undef RegQueryValueEx
  149. #endif
  150. #define RegQueryValueEx RegQueryValueEx__USE_VCR_MODE
  151. #if defined( RegQueryValue )
  152. #undef RegQueryValue
  153. #endif
  154. #define RegQueryValue RegQueryValue__USE_VCR_MODE
  155. #if defined( RegCreateKeyEx )
  156. #undef RegCreateKeyEx
  157. #endif
  158. #define RegCreateKeyEx RegCreateKeyEx__USE_VCR_MODE
  159. #if defined( RegCreateKey )
  160. #undef RegCreateKey
  161. #endif
  162. #define RegCreateKey RegCreateKey__USE_VCR_MODE
  163. #if defined( RegCloseKey )
  164. #undef RegCloseKey
  165. #endif
  166. #define RegCloseKey RegCloseKey__USE_VCR_MODE
  167. #if defined( GetNumberOfConsoleInputEvents )
  168. #undef GetNumberOfConsoleInputEvents
  169. #endif
  170. #define GetNumberOfConsoleInputEvents GetNumberOfConsoleInputEvents__USE_VCR_MODE
  171. #if defined( ReadConsoleInput )
  172. #undef ReadConsoleInput
  173. #endif
  174. #define ReadConsoleInput ReadConsoleInput__USE_VCR_MODE
  175. #if defined( GetAsyncKeyState )
  176. #undef GetAsyncKeyState
  177. #endif
  178. #define GetAsyncKeyState GetAsyncKeyState__USE_VCR_MODE
  179. #if defined( GetKeyState )
  180. #undef GetKeyState
  181. #endif
  182. #define GetKeyState GetKeyState__USE_VCR_MODE
  183. #endif
  184. #if defined( CreateThread )
  185. #undef CreateThread
  186. #endif
  187. #define CreateThread use__ThreadTools__for_thread_functions
  188. #if defined( WaitForSingleObject )
  189. #undef WaitForSingleObject
  190. #endif
  191. #define WaitForSingleObject use__ThreadTools__for_thread_functions
  192. #if defined( EnterCriticalSection )
  193. #undef EnterCriticalSection
  194. #endif
  195. #define EnterCriticalSection use__ThreadTools__for_thread_functions
  196. #endif
  197. #endif // PROTECTED_THINGS_H