Advertisement
Guest User

find info

a guest
May 6th, 2019
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. //ProdMods
  2. PlayerSquared - 2019
  3.  
  4. uint findInfo(uint startOfs, int lenForIp, int lenForVerify, byte[] findIp, byte[] verifyIp)
  5. {
  6. byte[] search = PS3.Extension.ReadBytes(startOfs, lenForIp);
  7. int findIpPos = 0;
  8.  
  9. while (true)
  10. {
  11. findIpPos = findBytes(search, findIp, findIpPos);
  12. if (findIpPos != -1)
  13. {
  14. byte[] searchVerify = PS3.Extension.ReadBytes(startOfs + (uint)findIpPos, lenForVerify);
  15. int findVerifyIpPos = findBytes(searchVerify, verifyIp, 0);
  16. if (findVerifyIpPos != -1)
  17. {
  18. return startOfs + (uint)findIpPos;
  19. }
  20. else
  21. {
  22. findIpPos += findIp.Length;
  23. }
  24. }
  25. else
  26. {
  27. return 0x00;
  28. }
  29. }
  30. }
  31. int findBytes(byte[] haystack, byte[] needle, int start_index)
  32. {
  33. int len = needle.Length;
  34. int limit = haystack.Length - len;
  35. for (int i = start_index; i <= limit; i++)
  36. {
  37. int k = 0;
  38. for (; k < len; k++)
  39. {
  40. if (needle[k] != haystack[i + k]) break;
  41. }
  42. if (k == len) return i;
  43. }
  44. return -1;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement