2.6.5: macOS and Linux fixes, fix refl/refr patches

This commit is contained in:
nastys
2021-10-07 16:31:11 +02:00
parent 162cc52c6b
commit 7df98ea648
13 changed files with 1192 additions and 17962 deletions
@@ -0,0 +1,2 @@
[InternetShortcut]
URL=https://dotnet.microsoft.com/download/dotnet-framework/net48
+2
View File
@@ -0,0 +1,2 @@
[InternetShortcut]
URL=https://www.quicksfv.org/qsfv236x64.exe
@@ -0,0 +1,2 @@
[InternetShortcut]
URL=https://aka.ms/vs/16/release/vc_redist.x64.exe
Binary file not shown.
+2 -1
View File
@@ -38,7 +38,7 @@ Cursor=1
#Use 2 channels instead of 4 (when not using DivaSound) #Use 2 channels instead of 4 (when not using DivaSound)
Stereo=1 Stereo=1
#Skip one or more menus -- 0=disabled, 1=guest, 2=guest+normal #Skip one or more menus -- 0=disabled, 1=guest, 2=guest+normal
Quick_Start=1 Quick_Start=0
#Disable the scrolling sound effect #Disable the scrolling sound effect
No_Scrolling_SFX=0 No_Scrolling_SFX=0
#Enhanced Stage Manager (sets a custom number of stages; "stage_manager" should be disabled in "components.ini") #Enhanced Stage Manager (sets a custom number of stages; "stage_manager" should be disabled in "components.ini")
@@ -153,6 +153,7 @@ r.Width=1920
r.Height=1080 r.Height=1080
[plugins] [plugins]
DivaMovie.dva=0
DivaWig.dva=0 DivaWig.dva=0
DSCRemote.dva=0 DSCRemote.dva=0
custom_freeplay_text_example.p=0 custom_freeplay_text_example.p=0
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -411,6 +411,8 @@ std::vector<PluginInfo> LoadPlugins()
do { do {
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{ {
if (ffd.cFileName[0] == '.' && ffd.cFileName[1] == '_') continue; // exclude macOS metadata
auto pos = wcslen(ffd.cFileName); auto pos = wcslen(ffd.cFileName);
if (ffd.cFileName[pos - 4] == '.' && if (ffd.cFileName[pos - 4] == '.' &&
@@ -487,11 +489,13 @@ std::vector<PluginInfo> LoadCustom()
HANDLE hFind; HANDLE hFind;
WIN32_FIND_DATAW ffd; WIN32_FIND_DATAW ffd;
hFind = FindFirstFileW((PATCHES_DIR + L"\\*.p?").c_str(), &ffd); hFind = FindFirstFileW((PATCHES_DIR + L"\\*.p*").c_str(), &ffd);
if (hFind != INVALID_HANDLE_VALUE) { if (hFind != INVALID_HANDLE_VALUE) {
do { do {
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{ {
if (ffd.cFileName[0] == '.' && ffd.cFileName[1] == '_') continue; // exclude macOS metadata
auto pos = wcslen(ffd.cFileName); auto pos = wcslen(ffd.cFileName);
if ((ffd.cFileName[pos - 2] == '.' && (ffd.cFileName[pos - 1] == 'p' || ffd.cFileName[pos - 1] == 'P')) || if ((ffd.cFileName[pos - 2] == '.' && (ffd.cFileName[pos - 1] == 'p' || ffd.cFileName[pos - 1] == 'P')) ||
+1 -1
View File
@@ -938,7 +938,7 @@ private: System::Windows::Forms::Button^ button_Wiki;
this->MaximizeBox = false; this->MaximizeBox = false;
this->Name = L"ui"; this->Name = L"ui";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen; this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"PD Launcher (2.6.4)"; this->Text = L"PD Launcher (2.6.5)";
this->TransparencyKey = System::Drawing::Color::Magenta; this->TransparencyKey = System::Drawing::Color::Magenta;
this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &ui::Ui_FormClosing); this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &ui::Ui_FormClosing);
this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &ui::Ui_FormClosed); this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &ui::Ui_FormClosed);
@@ -167,7 +167,7 @@ class PatchApplier710 : public PatchApplier {
if (nPDLoaderText && !nHideFreeplay) if (nPDLoaderText && !nHideFreeplay)
{ {
InjectCode((void*)0x00000001409F61F0, { 0x50, 0x44, 0x20, 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x72, InjectCode((void*)0x00000001409F61F0, { 0x50, 0x44, 0x20, 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x72,
0x20, 0x32, 0x2E, 0x36, 0x2E, 0x34, 0x20, 0x32, 0x2E, 0x36, 0x2E, 0x35,
0x00}); 0x00});
printf("[Patches] Show PD Loader text\n"); printf("[Patches] Show PD Loader text\n");
} }
@@ -650,12 +650,14 @@ class PatchApplier710 : public PatchApplier {
} }
// patch refract and reflect buffer sizes // patch refract and reflect buffer sizes
if (nRefractResWidth != 512 && nRefractResHeight != 256) if (nRefractResWidth != 512 || nRefractResHeight != 256)
{ {
InjectCode((void*)(0x140a24424), std::vector<uint8_t>((uint8_t*)&nRefractResWidth, (uint8_t*)((int64_t)&nRefractResWidth + 4))); InjectCode((void*)(0x140a24424), std::vector<uint8_t>((uint8_t*)&nRefractResWidth, (uint8_t*)((int64_t)&nRefractResWidth + 4)));
InjectCode((void*)(0x140a24428), std::vector<uint8_t>((uint8_t*)&nRefractResHeight, (uint8_t*)((int64_t)&nRefractResHeight + 4))); InjectCode((void*)(0x140a24428), std::vector<uint8_t>((uint8_t*)&nRefractResHeight, (uint8_t*)((int64_t)&nRefractResHeight + 4)));
printf("[Patches] Refraction resolution patched.\n");
} }
if (nReflectResWidth != 512 && nReflectResHeight != 256) if (nReflectResWidth != 512 || nReflectResHeight != 256)
{ {
InjectCode((void*)(0x140a2443c), std::vector<uint8_t>((uint8_t*)&nReflectResWidth, (uint8_t*)((int64_t)&nReflectResWidth + 4))); InjectCode((void*)(0x140a2443c), std::vector<uint8_t>((uint8_t*)&nReflectResWidth, (uint8_t*)((int64_t)&nReflectResWidth + 4)));
InjectCode((void*)(0x140a24440), std::vector<uint8_t>((uint8_t*)&nReflectResHeight, (uint8_t*)((int64_t)&nReflectResHeight + 4))); InjectCode((void*)(0x140a24440), std::vector<uint8_t>((uint8_t*)&nReflectResHeight, (uint8_t*)((int64_t)&nReflectResHeight + 4)));
@@ -697,6 +699,8 @@ class PatchApplier710 : public PatchApplier {
InjectCode((void*)(0x14050294d), { 0x89, 0x01 }); // MOV dword ptr [RCX], EAX InjectCode((void*)(0x14050294d), { 0x89, 0x01 }); // MOV dword ptr [RCX], EAX
InjectCode((void*)(0x14050294f), { 0xc3 }); // RET InjectCode((void*)(0x14050294f), { 0xc3 }); // RET
} }
printf("[Patches] Reflection resolution patched.\n");
} }
// lag compensation // lag compensation
+267 -264
View File
@@ -1,265 +1,268 @@
#include "windows.h" #include "windows.h"
#include "vector" #include "vector"
#include <tchar.h> #include <tchar.h>
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <filesystem> #include <filesystem>
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include "PluginConfigApi.h" #include "PluginConfigApi.h"
#include "PatchApplier.h" #include "PatchApplier.h"
#include "PatchApplier600.h" #include "PatchApplier600.h"
#include "PatchApplier710.h" #include "PatchApplier710.h"
#include <detours.h> #include <detours.h>
#include "framework.h" #include "framework.h"
#pragma comment(lib, "detours.lib") #pragma comment(lib, "detours.lib")
unsigned short game_version = 710; unsigned short game_version = 710;
void InjectCode(void* address, const std::vector<uint8_t> data); void InjectCode(void* address, const std::vector<uint8_t> data);
void ApplyPatches(); void ApplyPatches();
void ApplyCustomPatches(std::wstring CPATCH_FILE_STRING); void ApplyCustomPatches(std::wstring CPATCH_FILE_STRING);
HMODULE *hModulePtr; HMODULE *hModulePtr;
BOOL APIENTRY DllMain(HMODULE hModule, BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID lpReserved LPVOID lpReserved
) )
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
hModulePtr = &hModule; hModulePtr = &hModule;
if (*(char*)0x140A570F0 == '6') game_version = 600; if (*(char*)0x140A570F0 == '6') game_version = 600;
ApplyPatches(); ApplyPatches();
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH: case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
break; break;
} }
return TRUE; return TRUE;
} }
void ApplyPatches() { void ApplyPatches() {
if (game_version == 710) if (game_version == 710)
{ {
const char* exe_ver_string = (const char*)0x140A92CB8; const char* exe_ver_string = (const char*)0x140A92CB8;
if (strcmp(exe_ver_string, "7.10.00") != 0) if (strcmp(exe_ver_string, "7.10.00") != 0)
{ {
MessageBoxW(nullptr, L"Game version not 7.10. Please verify your files.", L"Patches", MB_ICONERROR); MessageBoxW(nullptr, L"Game version not 7.10. Please verify your files.", L"Patches", MB_ICONERROR);
exit(1); exit(1);
} }
} }
std::string version_string = std::to_string(game_version); std::string version_string = std::to_string(game_version);
version_string.insert(version_string.begin()+1, '.'); version_string.insert(version_string.begin()+1, '.');
std::cout << "[Patches] Game version " + version_string << std::endl; std::cout << "[Patches] Game version " + version_string << std::endl;
PatchApplier* pa; PatchApplier* pa;
switch (game_version) switch (game_version)
{ {
case 600: case 600:
pa = new PatchApplier600; pa = new PatchApplier600;
break; break;
default: default:
pa = new PatchApplier710; pa = new PatchApplier710;
} }
pa->ApplyPatches(); pa->ApplyPatches();
printf("[Patches] Patches applied\n"); printf("[Patches] Patches applied\n");
if (nCustomPatches) if (nCustomPatches)
{ {
std::cout << "[Patches] Reading custom patches...\n"; std::cout << "[Patches] Reading custom patches...\n";
try { try {
for (std::filesystem::path p : std::filesystem::directory_iterator("../patches")) for (std::filesystem::path p : std::filesystem::directory_iterator("../patches"))
{ {
std::string extension = std::filesystem::path(p).extension().string(); if (std::filesystem::path(p).filename().string()._Starts_with("._")) continue; // exclude macOS metadata
if ((extension == ".p" || extension == ".P" || extension == ".p2" || extension == ".P2") &&
GetPrivateProfileIntW(L"plugins", std::filesystem::path(p).filename().c_str(), TRUE, CONFIG_FILE)) std::string extension = std::filesystem::path(p).extension().string();
{ if ((extension == ".p" || extension == ".P" || extension == ".p2" || extension == ".P2") &&
std::cout << "[Patches] Reading custom patch file: " << std::filesystem::path(p).filename().string() << std::endl; GetPrivateProfileIntW(L"plugins", std::filesystem::path(p).filename().c_str(), TRUE, CONFIG_FILE))
ApplyCustomPatches(std::filesystem::path(p).wstring()); {
} std::cout << "[Patches] Reading custom patch file: " << std::filesystem::path(p).filename().string() << std::endl;
} ApplyCustomPatches(std::filesystem::path(p).wstring());
} }
catch (const std::filesystem::filesystem_error &e) { else std::cout << "[Patches] Skipping disabled patch file: " << std::filesystem::path(p).filename().string() << std::endl;
std::cout << "[Patches] File system error " << e.what() << " " << e.path1() << " " << e.path2() << " " << e.code() << std::endl; }
} }
catch (const std::filesystem::filesystem_error &e) {
std::cout << "[Patches] All custom patches applied\n"; std::cout << "[Patches] File system error " << e.what() << " " << e.path1() << " " << e.path2() << " " << e.code() << std::endl;
} }
}
std::cout << "[Patches] All custom patches applied\n";
}
}
void ApplyCustomPatches(std::wstring CPATCH_FILE_STRING)
{
LPCWSTR CPATCH_FILE = CPATCH_FILE_STRING.c_str();
std::ifstream fileStream(CPATCH_FILE_STRING); void ApplyCustomPatches(std::wstring CPATCH_FILE_STRING)
{
if (!fileStream.is_open()) LPCWSTR CPATCH_FILE = CPATCH_FILE_STRING.c_str();
return; std::ifstream fileStream(CPATCH_FILE_STRING);
std::string line; if (!fileStream.is_open())
return;
// check for BOM
std::getline(fileStream, line); std::string line;
if (line.size() >= 3 && line.rfind("\xEF\xBB\xBF", 0) == 0)
fileStream.seekg(3); // check for BOM
else std::getline(fileStream, line);
fileStream.seekg(0); if (line.size() >= 3 && line.rfind("\xEF\xBB\xBF", 0) == 0)
fileStream.seekg(3);
while (std::getline(fileStream, line)) else
{ fileStream.seekg(0);
if (line[0] == '#')
{ while (std::getline(fileStream, line))
std::cout << "[Patches]" << line.substr(1, line.size()-1) << std::endl; {
continue; if (line[0] == '#')
} {
if (line == "IGNORE") break; std::cout << "[Patches]" << line.substr(1, line.size()-1) << std::endl;
if (line.find(':') == std::string::npos || (line[0] == '/' && line[1] == '/')) continue; continue;
}
std::vector<std::string> commentHSplit = SplitString(line, "#"); if (line == "IGNORE") break;
std::vector<std::string> commentDSSplit = SplitString(commentHSplit[0], "//"); if (line.find(':') == std::string::npos || (line[0] == '/' && line[1] == '/')) continue;
std::vector<std::string> colonSplit = SplitString(commentDSSplit[0], ":");
if (colonSplit.size() != 2) continue; std::vector<std::string> commentHSplit = SplitString(line, "#");
bool echo = true; std::vector<std::string> commentDSSplit = SplitString(commentHSplit[0], "//");
if (colonSplit[0].at(0) == '@') std::vector<std::string> colonSplit = SplitString(commentDSSplit[0], ":");
{ if (colonSplit.size() != 2) continue;
echo = false; bool echo = true;
colonSplit[0].at(0) = ' '; if (colonSplit[0].at(0) == '@')
} {
long long int address; echo = false;
std::istringstream iss(colonSplit[0]); colonSplit[0].at(0) = ' ';
iss >> std::setbase(16) >> address; }
if (address == 0) std::cout << "[Patches] Custom patch address wrong: " << std::hex << address << std::endl; long long int address;
std::istringstream iss(colonSplit[0]);
if (colonSplit[1].at(0) == '!') iss >> std::setbase(16) >> address;
{ if (address == 0) std::cout << "[Patches] Custom patch address wrong: " << std::hex << address << std::endl;
if (echo) std::cout << "[Patches] Patching: " << std::hex << address << ":!";
std::vector<std::string> fullColonSplit = SplitString(line, ":"); if (colonSplit[1].at(0) == '!')
for (int i = 1; i < fullColonSplit[1].size(); i++) {
{ if (echo) std::cout << "[Patches] Patching: " << std::hex << address << ":!";
unsigned char byte_u = fullColonSplit[1].at(i); std::vector<std::string> fullColonSplit = SplitString(line, ":");
if(byte_u=='\\' && i<fullColonSplit[1].size()) for (int i = 1; i < fullColonSplit[1].size(); i++)
{ {
switch (fullColonSplit[1].at(i + 1)) unsigned char byte_u = fullColonSplit[1].at(i);
{ if(byte_u=='\\' && i<fullColonSplit[1].size())
case '0': {
byte_u = '\0'; switch (fullColonSplit[1].at(i + 1))
i++; {
break; case '0':
case 'n': byte_u = '\0';
byte_u = '\n'; i++;
i++; break;
break; case 'n':
case 't': byte_u = '\n';
byte_u = '\t'; i++;
i++; break;
break; case 't':
case 'r': byte_u = '\t';
byte_u = '\r'; i++;
i++; break;
break; case 'r':
case 'b': byte_u = '\r';
byte_u = '\b'; i++;
i++; break;
break; case 'b':
case 'a': byte_u = '\b';
byte_u = '\a'; i++;
i++; break;
break; case 'a':
case 'f': byte_u = '\a';
byte_u = '\f'; i++;
i++; break;
break; case 'f':
case 'v': byte_u = '\f';
byte_u = '\v'; i++;
i++; break;
break; case 'v':
case '\\': byte_u = '\v';
byte_u = '\\'; i++;
i++; break;
break; case '\\':
} byte_u = '\\';
} i++;
if (echo) std::cout << byte_u; break;
std::vector<uint8_t> patch = { byte_u }; }
InjectCode((void*)address, patch); }
address++; if (echo) std::cout << byte_u;
} std::vector<uint8_t> patch = { byte_u };
if (echo) std::cout << std::endl; InjectCode((void*)address, patch);
} address++;
else }
{ if (echo) std::cout << std::endl;
std::vector<std::string> bytes = SplitString(colonSplit[1], " "); }
if (bytes.size() < 1) continue; else
{
std::string comment_string = ""; std::vector<std::string> bytes = SplitString(colonSplit[1], " ");
int comment_counter = 0; if (bytes.size() < 1) continue;
if (commentHSplit.size() > 1)
{ std::string comment_string = "";
bool ignore = 1; int comment_counter = 0;
for (std::string comment : commentHSplit) if (commentHSplit.size() > 1)
{ {
if (ignore) bool ignore = 1;
{ for (std::string comment : commentHSplit)
ignore = 0; {
continue; if (ignore)
} {
comment_string = comment_string + comment; ignore = 0;
} continue;
} }
comment_string = comment_string + comment;
if (echo) std::cout << "[Patches] Patching: " << std::hex << address << ":"; }
for (std::string bytestring : bytes) }
{
int byte; if (echo) std::cout << "[Patches] Patching: " << std::hex << address << ":";
std::istringstream issb(bytestring); for (std::string bytestring : bytes)
issb >> std::setbase(16) >> byte; {
unsigned char byte_u = byte; int byte;
if (echo) std::istringstream issb(bytestring);
{ issb >> std::setbase(16) >> byte;
std::cout << std::hex << byte << " "; unsigned char byte_u = byte;
if (comment_counter < comment_string.length()) if (echo)
{ {
std::cout << "(" << comment_string.at(comment_counter) << ") "; std::cout << std::hex << byte << " ";
comment_counter++; if (comment_counter < comment_string.length())
} {
} std::cout << "(" << comment_string.at(comment_counter) << ") ";
std::vector<uint8_t> patch = { byte_u }; comment_counter++;
InjectCode((void*)address, patch); }
address++; }
} std::vector<uint8_t> patch = { byte_u };
if (echo) std::cout << std::endl; InjectCode((void*)address, patch);
else if (comment_string.length() > 0) address++;
{ }
std::cout << "[Patches]";; if (echo) std::cout << std::endl;
if (comment_string.at(0) != ' ') std::cout << ' '; else if (comment_string.length() > 0)
std::cout << comment_string << std::endl; {
} std::cout << "[Patches]";;
} if (comment_string.at(0) != ' ') std::cout << ' ';
} std::cout << comment_string << std::endl;
}
fileStream.close(); }
} }
fileStream.close();
using namespace PluginConfig; }
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
{ using namespace PluginConfig;
return L"Patches";
} extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
{
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void) return L"Patches";
{ }
return L"Applies patches/tweaks to the game before it starts.\nThis plugin is required.";
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void)
{
return L"Applies patches/tweaks to the game before it starts.\nThis plugin is required.";
} }
@@ -107,7 +107,7 @@ auto nMAG = GetPrivateProfileIntW(L"graphics", L"mag", 0, CONFIG_FILE);
auto nGamma = GetPrivateProfileIntW(L"graphics", L"gamma", 100, CONFIG_FILE); auto nGamma = GetPrivateProfileIntW(L"graphics", L"gamma", 100, CONFIG_FILE);
auto nStereo = GetPrivateProfileIntW(L"patches", L"stereo", TRUE, CONFIG_FILE); auto nStereo = GetPrivateProfileIntW(L"patches", L"stereo", TRUE, CONFIG_FILE);
auto nCustomPatches = GetPrivateProfileIntW(L"patches", L"custom_patches", TRUE, CONFIG_FILE); auto nCustomPatches = GetPrivateProfileIntW(L"patches", L"custom_patches", TRUE, CONFIG_FILE);
auto nQuickStart = GetPrivateProfileIntW(L"patches", L"quick_start", 1, CONFIG_FILE); auto nQuickStart = GetPrivateProfileIntW(L"patches", L"quick_start", 0, CONFIG_FILE);
auto nNoScrollingSfx = GetPrivateProfileIntW(L"patches", L"no_scrolling_sfx", FALSE, CONFIG_FILE); auto nNoScrollingSfx = GetPrivateProfileIntW(L"patches", L"no_scrolling_sfx", FALSE, CONFIG_FILE);
auto nEnablePvCustomization = GetPrivateProfileIntW(L"patches", L"enable_pv_customization", FALSE, CONFIG_FILE); auto nEnablePvCustomization = GetPrivateProfileIntW(L"patches", L"enable_pv_customization", FALSE, CONFIG_FILE);
auto nNoHandScaling = GetPrivateProfileIntW(L"patches", L"no_hand_scaling", FALSE, CONFIG_FILE); auto nNoHandScaling = GetPrivateProfileIntW(L"patches", L"no_hand_scaling", FALSE, CONFIG_FILE);