Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. DWORD Utilities::Memory::FindPatternV2(std::string moduleName, std::string pattern)
  2. {
  3. const char* pat = pattern.c_str();
  4. DWORD firstMatch = 0;
  5. DWORD rangeStart = (DWORD)GetModuleHandleA(moduleName.c_str());
  6. MODULEINFO miModInfo; GetModuleInformation(GetCurrentProcess(), (HMODULE)rangeStart, &miModInfo, sizeof(MODULEINFO));
  7. DWORD rangeEnd = rangeStart + miModInfo.SizeOfImage;
  8. for (DWORD pCur = rangeStart; pCur < rangeEnd; pCur++)
  9. {
  10. if (!pat)
  11. return firstMatch;
  12.  
  13. if ((PBYTE)pat == '\?' || (BYTE)pCur == getByte(pat))
  14. {
  15. if (!firstMatch)
  16. firstMatch = pCur;
  17.  
  18. if (!pat[2])
  19. return firstMatch;
  20.  
  21. if (*(PWORD)pat == '\?\?' || *(PBYTE)pat != '?')
  22. pat += 3;
  23.  
  24. else
  25. pat += 2;
  26. }
  27. else
  28. {
  29. pat = pattern.c_str();
  30. firstMatch = 0;
  31. }
  32. }
  33. return NULL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement