Exemplo n.º 1
0
 private void SaveConfig()
 {
     MelonPrefs.SetString("ScorePercentage", "leaderboardUserColor", leaderboardUserColor);
     MelonPrefs.SetString("ScorePercentage", "leaderboardHighScoreSize", leaderboardHighScoreSize);
     MelonPrefs.SetString("ScorePercentage", "leaderboardPercentSize", leaderboardPercentSize);
     MelonPrefs.SetString("ScorePercentage", "leaderboardUsernameSize", leaderboardUsernameSize);
     MelonPrefs.SetString("ScorePercentage", "songListHighScoreSize", songListHighScoreSize);
     MelonPrefs.SetString("ScorePercentage", "songListPercentSize", songListPercentSize);
     MelonPrefs.SetString("ScorePercentage", "inGameCurrentScoreSize", inGameCurrentScoreSize);
     MelonPrefs.SetString("ScorePercentage", "inGameCurrentPercentSize", inGameCurrentPercentSize);
     MelonPrefs.SetString("ScorePercentage", "inGameHighScoreLabelText", inGameHighScoreLabelText);
     MelonPrefs.SetString("ScorePercentage", "inGameHighScoreLabelSize", inGameHighScoreLabelSize);
     MelonPrefs.SetString("ScorePercentage", "inGameHighScoreSize", inGameHighScoreSize);
     MelonPrefs.SetString("ScorePercentage", "inGamePercentSize", inGamePercentSize);
     MelonPrefs.SetString("ScorePercentage", "historyTopScoreSize", historyTopScoreSize);
     MelonPrefs.SetString("ScorePercentage", "historyTopPercentSize", historyTopPercentSize);
 }
Exemplo n.º 2
0
        public override unsafe void OnApplicationStart()
        {
            try
            {
                var settingsCategory = "HWIDPatch";
                MelonPrefs.RegisterCategory(settingsCategory, "HWID Patch");
                MelonPrefs.RegisterString(settingsCategory, "HWID", "", hideFromList: true);

                var newId = MelonPrefs.GetString(settingsCategory, "HWID");
                if (newId.Length != SystemInfo.deviceUniqueIdentifier.Length)
                {
                    var random = new System.Random(Environment.TickCount);
                    var bytes  = new byte[SystemInfo.deviceUniqueIdentifier.Length / 2];
                    random.NextBytes(bytes);
                    newId = string.Join("", bytes.Select(it => it.ToString("x2")));
                    MelonPrefs.SetString(settingsCategory, "HWID", newId);
                }

                ourGeneratedHwidString = new Il2CppSystem.Object(IL2CPP.ManagedStringToIl2Cpp(newId));

                var icallName    = "UnityEngine.SystemInfo::GetDeviceUniqueIdentifier";
                var icallAddress = IL2CPP.il2cpp_resolve_icall(icallName);
                if (icallAddress == IntPtr.Zero)
                {
                    MelonLogger.LogError("Can't resolve the icall, not patching");
                    return;
                }

                CompatHook((IntPtr)(&icallAddress),
                           typeof(HWIDPatchMod).GetMethod(nameof(GetDeviceIdPatch),
                                                          BindingFlags.Static | BindingFlags.NonPublic) !.MethodHandle.GetFunctionPointer());

                MelonLogger.Log("Patched HWID; below two should match:");
                MelonLogger.Log($"Current: {SystemInfo.deviceUniqueIdentifier}");
                MelonLogger.Log($"Target:  {newId}");
            }
            catch (Exception ex)
            {
                MelonLogger.LogError(ex.ToString());
            }
        }