Team Fortress 2 Source Code as on 22/4/2020
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.

96 lines
2.1 KiB

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