Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. MODULEINFO GetModuleInfo(char *szModule)
  2. {
  3. MODULEINFO modinfo = { 0 };
  4. HMODULE hModule = GetModuleHandle(szModule);
  5. if (hModule == 0)
  6. return modinfo;
  7. GetModuleInformation(GetCurrentProcess(), hModule, &modinfo, sizeof(MODULEINFO));
  8. return modinfo;
  9. }
  10. void Memoria(uintptr_t addressToWrite, char* valueToWrite, int byteNum)
  11. {
  12. unsigned long OldProtection;
  13. VirtualProtect((LPVOID)(addressToWrite), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection);
  14. memcpy((LPVOID)addressToWrite, valueToWrite, byteNum);
  15. VirtualProtect((LPVOID)(addressToWrite), byteNum, OldProtection, NULL);
  16. }
  17. DWORD FindPattern(char *module, char *pattern, char *mask)
  18. {
  19. MODULEINFO mInfo = GetModuleInfo(module);
  20. DWORD base = (DWORD)mInfo.lpBaseOfDll;
  21. DWORD size = (DWORD)mInfo.SizeOfImage;
  22. DWORD patternLength = (DWORD)strlen(mask);
  23. for (DWORD i = 0; i < size - patternLength; i++)
  24. {
  25. bool found = true;
  26. for (DWORD j = 0; j < patternLength; j++)
  27. {
  28. found &= mask[j] == '?' || pattern[j] == *(char*)(base + i + j);
  29. }
  30. if (found)
  31. {
  32. return base + i;
  33. }
  34. }
  35. return NULL;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement