Advertisement
Wolfrost

C++ Signature Scanner

Mar 25th, 2016
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool InitScanner()
  2. {
  3.     ClientBytes = new BYTE[ClientSize];
  4.     EngineBytes = new BYTE[EngineSize];
  5.     if (!ReadProcessMemory(hProcess, (LPVOID)ClientBase, ClientBytes, ClientSize, NULL))
  6.     {
  7.         ClearBytes();
  8.         return false;
  9.     }
  10.     if (!ReadProcessMemory(hProcess, (LPVOID)EngineBase, EngineBytes, EngineSize, NULL))
  11.     {
  12.         ClearBytes();
  13.         return false;
  14.     }
  15.     return true;
  16. }
  17.  
  18. void ClearBytes()
  19. {
  20.     delete [] ClientBytes;
  21.     delete [] EngineBytes;
  22. }
  23.  
  24. DWORD Client_FindPattern( BYTE Pattern[], const size_t& PatternSize) const
  25. {
  26.     for (DWORD i = 0; i < ClientSize; i++)
  27.     {
  28.         bool DoesMatch = true;
  29.  
  30.         for (DWORD j = 0; j < PatternSize; j++)
  31.         {
  32.             if (Pattern[j]==0) continue;
  33.             if (Pattern[j] == ClientBytes[i+j])
  34.             {
  35.                 DoesMatch = false;
  36.                 break;
  37.             }
  38.         }
  39.         if (DoesMatch) return i;
  40.     }
  41.     return 0;
  42. }
  43.  
  44. DWORD Engine_FindPattern( BYTE Pattern[], const size_t& PatternSize) const
  45. {
  46.     for (DWORD i = 0; i < EngineSize; i++)
  47.     {
  48.         bool DoesMatch = true;
  49.  
  50.         for (DWORD j = 0; j < PatternSize; j++)
  51.         {
  52.             if (Pattern[j]==0) continue;
  53.             if (Pattern[j] == EngineBytes[i+j])
  54.             {
  55.                 DoesMatch = false;
  56.                 break;
  57.             }
  58.         }
  59.         if (DoesMatch) return i;
  60.     }
  61.     return 0;
  62. }
  63.  
  64. DWORD Client_GetOffset( DWORD Offset ) const
  65. {
  66.     DWORD Buffer = NULL;
  67.     memcpy(&Buffer, &ClientBytes[Offset], sizeof(DWORD));
  68.     return Buffer;
  69. }
  70.  
  71. DWORD Engine_GetOffset( DWORD Offset ) const
  72. {
  73.     DWORD Buffer = NULL;
  74.     memcpy(&Buffer, &EngineBytes[Offset], sizeof(DWORD));
  75.     return Buffer;
  76. }
  77.  
  78. DWORD Client_GetOffset( BYTE Pattern[], const size_t& PatternSize, DWORD ShiftAmount )
  79. {
  80.     return Client_GetOffset( Client_FindPattern(Pattern, PatternSize) + ShiftAmount );
  81. }
  82.  
  83. DWORD Engine_GetOffset( BYTE Pattern[], const size_t& PatternSize, DWORD ShiftAmount )
  84. {
  85.     return Engine_GetOffset( Engine_FindPattern(Pattern, PatternSize) + ShiftAmount );
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement