Advertisement
djhonga2001

Untitled

Feb 2nd, 2016
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. namespace Memory
  2. {
  3. bool compare(const uint8_t* pData, const uint8_t* bMask, const char* sMask)
  4. {
  5. for (; *sMask; ++sMask, ++pData, ++bMask)
  6. if (*sMask == 'x' && *pData != *bMask)
  7. return false;
  8.  
  9. return *sMask == NULL;
  10. }
  11.  
  12. intptr_t findPattern(const char* bMask, const char* sMask)
  13. {
  14. // Game Base & Size
  15. static intptr_t pGameBase = (intptr_t)GetModuleHandle(nullptr);
  16. static uint32_t pGameSize = 0;
  17. if (!pGameSize)
  18. {
  19. MODULEINFO info;
  20. GetModuleInformation(GetCurrentProcess(), (HMODULE)pGameBase, &info, sizeof(MODULEINFO));
  21. pGameSize = info.SizeOfImage;
  22. }
  23.  
  24. // Scan
  25. for (uint32_t i = 0; i < pGameSize; i++)
  26. if (compare((uint8_t*)(pGameBase + i), (uint8_t*)bMask, sMask))
  27. return pGameBase + i;
  28.  
  29. return 0;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement