FileHackGlobalGameManagers.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using System.IO;
  3. using UnityEngine;
  4. public class FileHackGlobalGameManagers
  5. {
  6. public static string Path
  7. {
  8. get
  9. {
  10. return Application.dataPath + "/globalgamemanagers";
  11. }
  12. }
  13. public static byte[] ReadAllBytes(string path = "")
  14. {
  15. if (string.IsNullOrEmpty(path))
  16. {
  17. path = FileHackGlobalGameManagers.Path;
  18. }
  19. byte[] result = null;
  20. try
  21. {
  22. result = File.ReadAllBytes(path);
  23. }
  24. catch (Exception ex)
  25. {
  26. Debug.LogError(ex.Message);
  27. }
  28. return result;
  29. }
  30. public static bool WriteAllBytes(byte[] src, string path = "")
  31. {
  32. if (string.IsNullOrEmpty(path))
  33. {
  34. path = FileHackGlobalGameManagers.Path;
  35. }
  36. bool result = false;
  37. try
  38. {
  39. File.WriteAllBytes(path, src);
  40. result = true;
  41. }
  42. catch (Exception ex)
  43. {
  44. Debug.LogError(ex.Message);
  45. }
  46. return result;
  47. }
  48. public static int IndexOfVRFlag(byte[] src)
  49. {
  50. if (src == null || src.Length <= 0)
  51. {
  52. return -1;
  53. }
  54. string text = "com.";
  55. string text2 = "1.0";
  56. int num = FileHackGlobalGameManagers.IndexOf(src, 0, text);
  57. if (num <= 0)
  58. {
  59. return -1;
  60. }
  61. int num2 = FileHackGlobalGameManagers.IndexOf(src, num, text2);
  62. if (num2 <= 0)
  63. {
  64. return -1;
  65. }
  66. int num3 = num2 + text2.Length + 9;
  67. return (num3 >= src.Length) ? -1 : num3;
  68. }
  69. public static int IndexOf(byte[] src, int offset, string text)
  70. {
  71. byte[] array = new byte[text.Length];
  72. for (int i = 0; i < text.Length; i++)
  73. {
  74. array[i] = (byte)text[i];
  75. }
  76. int num = 0;
  77. while (num + offset < src.Length)
  78. {
  79. if (src[num + offset] == array[0])
  80. {
  81. int num2 = num + offset;
  82. int num3 = 0;
  83. while (num2 < src.Length && num3 < array.Length)
  84. {
  85. if ((char)src[num2] != text[num3])
  86. {
  87. num3 = -1;
  88. break;
  89. }
  90. num2++;
  91. num3++;
  92. }
  93. if (0 < num3)
  94. {
  95. return num + offset;
  96. }
  97. }
  98. num++;
  99. }
  100. return -1;
  101. }
  102. }