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.

99 lines
2.2 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include <windows.h>
  7. #include "shader_dll_verify.h"
  8. // NOTE: This has to be the last file included!
  9. #include "tier0/memdbgon.h"
  10. static unsigned char *g_pLastInputData = 0;
  11. static HANDLE g_hDLLInst = 0;
  12. extern "C"
  13. {
  14. void __declspec( dllexport ) _ftol3( char *pData );
  15. BOOL WINAPI DllMain (HANDLE hInst, ULONG ulInit, LPVOID lpReserved);
  16. };
  17. BOOL WINAPI DllMain (HANDLE hInst, ULONG ulInit, LPVOID lpReserved)
  18. {
  19. lpReserved = lpReserved;
  20. ulInit = ulInit;
  21. g_hDLLInst = hInst;
  22. return true;
  23. }
  24. class CShaderDLLVerification : public IShaderDLLVerification
  25. {
  26. public:
  27. virtual CRC32_t Function1( unsigned char *pData );
  28. virtual void Function2( int a, int b, int c );
  29. virtual void Function3( int a, int b, int c );
  30. virtual void Function4( int a, int b, int c );
  31. virtual CRC32_t Function5();
  32. };
  33. static CShaderDLLVerification g_Blah;
  34. // The main exported function.. return a pointer to g_Blah.
  35. void __declspec( dllexport ) _ftol3( char *pData )
  36. {
  37. pData += SHADER_DLL_VERIFY_DATA_PTR_OFFSET;
  38. char *pToFillIn = (char*)&g_Blah;
  39. memcpy( pData, &pToFillIn, 4 );
  40. }
  41. CRC32_t CShaderDLLVerification::Function1( unsigned char *pData )
  42. {
  43. pData += SHADER_DLL_VERIFY_DATA_PTR_OFFSET;
  44. g_pLastInputData = (unsigned char*)pData;
  45. void *pVerifyPtr1 = &g_Blah;
  46. CRC32_t testCRC;
  47. CRC32_Init( &testCRC );
  48. CRC32_ProcessBuffer( &testCRC, pData, SHADER_DLL_VERIFY_DATA_LEN1 );
  49. CRC32_ProcessBuffer( &testCRC, &g_hDLLInst, 4 );
  50. CRC32_ProcessBuffer( &testCRC, &pVerifyPtr1, 4 );
  51. CRC32_Final( &testCRC );
  52. return testCRC;
  53. }
  54. void CShaderDLLVerification::Function2( int a, int b, int c )
  55. {
  56. a=b=c;
  57. MD5Context_t md5Context;
  58. MD5Init( &md5Context );
  59. MD5Update( &md5Context, g_pLastInputData + SHADER_DLL_VERIFY_DATA_PTR_OFFSET, SHADER_DLL_VERIFY_DATA_LEN1 - SHADER_DLL_VERIFY_DATA_PTR_OFFSET );
  60. MD5Final( g_pLastInputData, &md5Context );
  61. }
  62. void CShaderDLLVerification::Function3( int a, int b, int c )
  63. {
  64. a=b=c;
  65. }
  66. void CShaderDLLVerification::Function4( int a, int b, int c )
  67. {
  68. a=b=c;
  69. }
  70. CRC32_t CShaderDLLVerification::Function5()
  71. {
  72. return 32423;
  73. }