framework.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #pragma once
  2. #include "windows.h"
  3. #include <string>
  4. #include <vector>
  5. std::string TrimString(const std::string& str, const std::string& whitespace)
  6. {
  7. const size_t strBegin = str.find_first_not_of(whitespace);
  8. if (strBegin == std::string::npos)
  9. return "";
  10. const size_t strEnd = str.find_last_not_of(whitespace);
  11. const size_t strRange = strEnd - strBegin + 1;
  12. return str.substr(strBegin, strRange);
  13. }
  14. std::vector<std::string> SplitString(const std::string& str, const std::string& delim)
  15. {
  16. std::vector<std::string> tokens;
  17. size_t prev = 0, pos = 0;
  18. do
  19. {
  20. pos = str.find(delim, prev);
  21. if (pos == std::string::npos)
  22. pos = str.length();
  23. std::string token = str.substr(prev, pos - prev);
  24. if (!token.empty())
  25. tokens.push_back(token);
  26. prev = pos + delim.length();
  27. } while (pos < str.length() && prev < str.length());
  28. return tokens;
  29. }
  30. void InjectCode(void* address, const std::vector<uint8_t> data)
  31. {
  32. const size_t byteCount = data.size() * sizeof(uint8_t);
  33. DWORD oldProtect;
  34. VirtualProtect(address, byteCount, PAGE_EXECUTE_READWRITE, &oldProtect);
  35. memcpy(address, data.data(), byteCount);
  36. VirtualProtect(address, byteCount, oldProtect, nullptr);
  37. }
  38. // patchMovieExt will modify an extension to mp4 only if the file exists on disk as an mp4
  39. void patchMovieExt(std::string moviefile, void* address)
  40. {
  41. bool isinmdata = 0;
  42. try {
  43. for (std::filesystem::path p : std::filesystem::directory_iterator("../mdata"))
  44. {
  45. if (std::filesystem::path(p).filename().string().at(0) != 'M' || std::filesystem::path(p).filename().string().length() > 4) continue;
  46. if (std::filesystem::exists(p.string() + "/rom/movie/" + moviefile + ".mp4"))
  47. {
  48. isinmdata = 1;
  49. //std::cout << "[Patches] Movie " << moviefile << ".mp4 found in M" << ss.str() << std::endl;
  50. break;
  51. }
  52. }
  53. }
  54. catch (const std::filesystem::filesystem_error& e) {
  55. std::cout << "[Patches] File system error " << e.what() << " " << e.path1() << " " << e.path2() << " " << e.code() << std::endl;
  56. }
  57. if (isinmdata || std::filesystem::exists("../rom/movie/" + moviefile + ".mp4"))
  58. {
  59. InjectCode(address, { 0x6D, 0x70, 0x34 });
  60. std::cout << "[Patches] Movie " << moviefile << " patched to mp4\n";
  61. return;
  62. }
  63. //std::cout << "[Patches] Movie " << moviefile << " NOT patched to mp4\n";
  64. return;
  65. }
  66. const LPCWSTR CONFIG_FILE = L".\\config.ini";
  67. auto nCursor = GetPrivateProfileIntW(L"patches", L"cursor", TRUE, CONFIG_FILE);
  68. auto nHideFreeplay = GetPrivateProfileIntW(L"patches", L"hide_freeplay", FALSE, CONFIG_FILE);
  69. auto nFreeplay = GetPrivateProfileIntW(L"patches", L"freeplay", TRUE, CONFIG_FILE);
  70. auto nPDLoaderText = GetPrivateProfileIntW(L"patches", L"pdloadertext", TRUE, CONFIG_FILE);
  71. auto nStatusIcons = GetPrivateProfileIntW(L"patches", L"status_icons", 0, CONFIG_FILE);
  72. auto nHidePVWatermark = GetPrivateProfileIntW(L"patches", L"hide_pv_watermark", FALSE, CONFIG_FILE);
  73. auto nNoPVUi = GetPrivateProfileIntW(L"patches", L"no_pv_ui", FALSE, CONFIG_FILE);
  74. auto nHideVolCtrl = GetPrivateProfileIntW(L"patches", L"hide_volume", FALSE, CONFIG_FILE);
  75. auto nNoLyrics = GetPrivateProfileIntW(L"patches", L"no_lyrics", FALSE, CONFIG_FILE);
  76. auto nNoMovies = GetPrivateProfileIntW(L"patches", L"no_movies", FALSE, CONFIG_FILE);
  77. auto nMP4Movies = GetPrivateProfileIntW(L"patches", L"mp4_movies", FALSE, CONFIG_FILE);
  78. auto nNoError = GetPrivateProfileIntW(L"patches", L"no_error", FALSE, CONFIG_FILE);
  79. auto nNoTimer = GetPrivateProfileIntW(L"patches", L"no_timer", TRUE, CONFIG_FILE);
  80. auto nNoTimerSprite = GetPrivateProfileIntW(L"patches", L"no_timer_sprite", TRUE, CONFIG_FILE);
  81. auto nEStageManager = GetPrivateProfileIntW(L"patches", L"enhanced_stage_manager", 0, CONFIG_FILE);
  82. auto nEStageManagerEncore = GetPrivateProfileIntW(L"patches", L"enhanced_stage_manager_encore", TRUE, CONFIG_FILE);
  83. auto nUnlockPseudo = GetPrivateProfileIntW(L"patches", L"unlock_pseudo", FALSE, CONFIG_FILE);
  84. auto nCard = GetPrivateProfileIntW(L"patches", L"card", TRUE, CONFIG_FILE);
  85. auto nHardwareSlider = GetPrivateProfileIntW(L"patches", L"hardware_slider", FALSE, CONFIG_FILE);
  86. auto nOGLPatchA = GetPrivateProfileIntW(L"patches", L"opengl_patch_a", FALSE, CONFIG_FILE);
  87. auto nOGLPatchB = GetPrivateProfileIntW(L"patches", L"opengl_patch_b", FALSE, CONFIG_FILE);
  88. auto nTAA = GetPrivateProfileIntW(L"graphics", L"taa", TRUE, CONFIG_FILE);
  89. auto nMLAA = GetPrivateProfileIntW(L"graphics", L"mlaa", TRUE, CONFIG_FILE);
  90. auto nDoF = GetPrivateProfileIntW(L"graphics", L"dof", TRUE, CONFIG_FILE);
  91. auto nMAG = GetPrivateProfileIntW(L"graphics", L"mag", 0, CONFIG_FILE);
  92. auto nGamma = GetPrivateProfileIntW(L"graphics", L"gamma", 100, CONFIG_FILE);
  93. auto nStereo = GetPrivateProfileIntW(L"patches", L"stereo", TRUE, CONFIG_FILE);
  94. auto nCustomPatches = GetPrivateProfileIntW(L"patches", L"custom_patches", TRUE, CONFIG_FILE);
  95. auto nQuickStart = GetPrivateProfileIntW(L"patches", L"quick_start", 0, CONFIG_FILE);
  96. auto nNoScrollingSfx = GetPrivateProfileIntW(L"patches", L"no_scrolling_sfx", FALSE, CONFIG_FILE);
  97. auto nEnablePvCustomization = GetPrivateProfileIntW(L"patches", L"enable_pv_customization", FALSE, CONFIG_FILE);
  98. auto nNoHandScaling = GetPrivateProfileIntW(L"patches", L"no_hand_scaling", FALSE, CONFIG_FILE);
  99. auto nDefaultHandSize = GetPrivateProfileIntW(L"patches", L"default_hand_size_uint", 0, CONFIG_FILE);
  100. auto nSingMissed = GetPrivateProfileIntW(L"patches", L"sing_missed", FALSE, CONFIG_FILE);
  101. auto nForceMouth = GetPrivateProfileIntW(L"patches", L"force_mouth", 0, CONFIG_FILE);
  102. auto nForceExpressions = GetPrivateProfileIntW(L"patches", L"force_expressions", 0, CONFIG_FILE);
  103. auto nForceLook = GetPrivateProfileIntW(L"patches", L"force_look", 0, CONFIG_FILE);
  104. auto nNpr1 = GetPrivateProfileIntW(L"graphics", L"npr1", 0, CONFIG_FILE);
  105. auto nReflections = GetPrivateProfileIntW(L"graphics", L"reflections", TRUE, CONFIG_FILE);
  106. auto nShadows = GetPrivateProfileIntW(L"graphics", L"shadows", TRUE, CONFIG_FILE);
  107. auto nPunchthrough = GetPrivateProfileIntW(L"graphics", L"punchthrough", TRUE, CONFIG_FILE);
  108. auto nGlare = GetPrivateProfileIntW(L"graphics", L"glare", TRUE, CONFIG_FILE);
  109. auto nShader = GetPrivateProfileIntW(L"graphics", L"shader", TRUE, CONFIG_FILE);
  110. auto n2D = GetPrivateProfileIntW(L"graphics", L"2D", FALSE, CONFIG_FILE);
  111. auto nNoDelete = GetPrivateProfileIntW(L"patches", L"prevent_data_deletion", FALSE, CONFIG_FILE);
  112. auto nReflectResWidth = GetPrivateProfileIntW(L"graphics", L"reflect_res_width", 512, CONFIG_FILE);
  113. auto nReflectResHeight = GetPrivateProfileIntW(L"graphics", L"reflect_res_height", 256, CONFIG_FILE);
  114. auto nRefractResWidth = GetPrivateProfileIntW(L"graphics", L"refract_res_width", 512, CONFIG_FILE);
  115. auto nRefractResHeight = GetPrivateProfileIntW(L"graphics", L"refract_res_height", 256, CONFIG_FILE);
  116. auto nLagCompensation = GetPrivateProfileIntW(L"graphics", L"lag_compensation", 0, CONFIG_FILE);
  117. auto nUseDivahookBat = GetPrivateProfileIntW(L"launcher", L"use_divahook_bat", FALSE, CONFIG_FILE);