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)
Stereo=1
#Skip one or more menus -- 0=disabled, 1=guest, 2=guest+normal
Quick_Start=1
Quick_Start=0
#Disable the scrolling sound effect
No_Scrolling_SFX=0
#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
[plugins]
DivaMovie.dva=0
DivaWig.dva=0
DSCRemote.dva=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 {
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
if (ffd.cFileName[0] == '.' && ffd.cFileName[1] == '_') continue; // exclude macOS metadata
auto pos = wcslen(ffd.cFileName);
if (ffd.cFileName[pos - 4] == '.' &&
@@ -487,11 +489,13 @@ std::vector<PluginInfo> LoadCustom()
HANDLE hFind;
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) {
do {
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
if (ffd.cFileName[0] == '.' && ffd.cFileName[1] == '_') continue; // exclude macOS metadata
auto pos = wcslen(ffd.cFileName);
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->Name = L"ui";
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->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &ui::Ui_FormClosing);
this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &ui::Ui_FormClosed);
@@ -167,7 +167,7 @@ class PatchApplier710 : public PatchApplier {
if (nPDLoaderText && !nHideFreeplay)
{
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});
printf("[Patches] Show PD Loader text\n");
}
@@ -650,12 +650,14 @@ class PatchApplier710 : public PatchApplier {
}
// 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*)(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*)(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*)(0x14050294f), { 0xc3 }); // RET
}
printf("[Patches] Reflection resolution patched.\n");
}
// lag compensation
+267 -264
View File
@@ -1,265 +1,268 @@
#include "windows.h"
#include "vector"
#include <tchar.h>
#include <GL/freeglut.h>
#include <iostream>
#include <fstream>
#include <filesystem>
#include <sstream>
#include <iomanip>
#include "PluginConfigApi.h"
#include "PatchApplier.h"
#include "PatchApplier600.h"
#include "PatchApplier710.h"
#include <detours.h>
#include "framework.h"
#pragma comment(lib, "detours.lib")
unsigned short game_version = 710;
void InjectCode(void* address, const std::vector<uint8_t> data);
void ApplyPatches();
void ApplyCustomPatches(std::wstring CPATCH_FILE_STRING);
HMODULE *hModulePtr;
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
hModulePtr = &hModule;
if (*(char*)0x140A570F0 == '6') game_version = 600;
ApplyPatches();
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
void ApplyPatches() {
if (game_version == 710)
{
const char* exe_ver_string = (const char*)0x140A92CB8;
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);
exit(1);
}
}
std::string version_string = std::to_string(game_version);
version_string.insert(version_string.begin()+1, '.');
std::cout << "[Patches] Game version " + version_string << std::endl;
PatchApplier* pa;
switch (game_version)
{
case 600:
pa = new PatchApplier600;
break;
default:
pa = new PatchApplier710;
}
pa->ApplyPatches();
printf("[Patches] Patches applied\n");
if (nCustomPatches)
{
std::cout << "[Patches] Reading custom patches...\n";
try {
for (std::filesystem::path p : std::filesystem::directory_iterator("../patches"))
{
std::string extension = std::filesystem::path(p).extension().string();
if ((extension == ".p" || extension == ".P" || extension == ".p2" || extension == ".P2") &&
GetPrivateProfileIntW(L"plugins", std::filesystem::path(p).filename().c_str(), TRUE, CONFIG_FILE))
{
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) {
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);
if (!fileStream.is_open())
return;
std::string line;
// check for BOM
std::getline(fileStream, line);
if (line.size() >= 3 && line.rfind("\xEF\xBB\xBF", 0) == 0)
fileStream.seekg(3);
else
fileStream.seekg(0);
while (std::getline(fileStream, line))
{
if (line[0] == '#')
{
std::cout << "[Patches]" << line.substr(1, line.size()-1) << std::endl;
continue;
}
if (line == "IGNORE") break;
if (line.find(':') == std::string::npos || (line[0] == '/' && line[1] == '/')) continue;
std::vector<std::string> commentHSplit = SplitString(line, "#");
std::vector<std::string> commentDSSplit = SplitString(commentHSplit[0], "//");
std::vector<std::string> colonSplit = SplitString(commentDSSplit[0], ":");
if (colonSplit.size() != 2) continue;
bool echo = true;
if (colonSplit[0].at(0) == '@')
{
echo = false;
colonSplit[0].at(0) = ' ';
}
long long int address;
std::istringstream iss(colonSplit[0]);
iss >> std::setbase(16) >> address;
if (address == 0) std::cout << "[Patches] Custom patch address wrong: " << std::hex << address << std::endl;
if (colonSplit[1].at(0) == '!')
{
if (echo) std::cout << "[Patches] Patching: " << std::hex << address << ":!";
std::vector<std::string> fullColonSplit = SplitString(line, ":");
for (int i = 1; i < fullColonSplit[1].size(); i++)
{
unsigned char byte_u = fullColonSplit[1].at(i);
if(byte_u=='\\' && i<fullColonSplit[1].size())
{
switch (fullColonSplit[1].at(i + 1))
{
case '0':
byte_u = '\0';
i++;
break;
case 'n':
byte_u = '\n';
i++;
break;
case 't':
byte_u = '\t';
i++;
break;
case 'r':
byte_u = '\r';
i++;
break;
case 'b':
byte_u = '\b';
i++;
break;
case 'a':
byte_u = '\a';
i++;
break;
case 'f':
byte_u = '\f';
i++;
break;
case 'v':
byte_u = '\v';
i++;
break;
case '\\':
byte_u = '\\';
i++;
break;
}
}
if (echo) std::cout << byte_u;
std::vector<uint8_t> patch = { byte_u };
InjectCode((void*)address, patch);
address++;
}
if (echo) std::cout << std::endl;
}
else
{
std::vector<std::string> bytes = SplitString(colonSplit[1], " ");
if (bytes.size() < 1) continue;
std::string comment_string = "";
int comment_counter = 0;
if (commentHSplit.size() > 1)
{
bool ignore = 1;
for (std::string comment : commentHSplit)
{
if (ignore)
{
ignore = 0;
continue;
}
comment_string = comment_string + comment;
}
}
if (echo) std::cout << "[Patches] Patching: " << std::hex << address << ":";
for (std::string bytestring : bytes)
{
int byte;
std::istringstream issb(bytestring);
issb >> std::setbase(16) >> byte;
unsigned char byte_u = byte;
if (echo)
{
std::cout << std::hex << byte << " ";
if (comment_counter < comment_string.length())
{
std::cout << "(" << comment_string.at(comment_counter) << ") ";
comment_counter++;
}
}
std::vector<uint8_t> patch = { byte_u };
InjectCode((void*)address, patch);
address++;
}
if (echo) std::cout << std::endl;
else if (comment_string.length() > 0)
{
std::cout << "[Patches]";;
if (comment_string.at(0) != ' ') std::cout << ' ';
std::cout << comment_string << std::endl;
}
}
}
fileStream.close();
}
using namespace PluginConfig;
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
{
return L"Patches";
}
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void)
{
return L"Applies patches/tweaks to the game before it starts.\nThis plugin is required.";
#include "windows.h"
#include "vector"
#include <tchar.h>
#include <GL/freeglut.h>
#include <iostream>
#include <fstream>
#include <filesystem>
#include <sstream>
#include <iomanip>
#include "PluginConfigApi.h"
#include "PatchApplier.h"
#include "PatchApplier600.h"
#include "PatchApplier710.h"
#include <detours.h>
#include "framework.h"
#pragma comment(lib, "detours.lib")
unsigned short game_version = 710;
void InjectCode(void* address, const std::vector<uint8_t> data);
void ApplyPatches();
void ApplyCustomPatches(std::wstring CPATCH_FILE_STRING);
HMODULE *hModulePtr;
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
hModulePtr = &hModule;
if (*(char*)0x140A570F0 == '6') game_version = 600;
ApplyPatches();
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
void ApplyPatches() {
if (game_version == 710)
{
const char* exe_ver_string = (const char*)0x140A92CB8;
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);
exit(1);
}
}
std::string version_string = std::to_string(game_version);
version_string.insert(version_string.begin()+1, '.');
std::cout << "[Patches] Game version " + version_string << std::endl;
PatchApplier* pa;
switch (game_version)
{
case 600:
pa = new PatchApplier600;
break;
default:
pa = new PatchApplier710;
}
pa->ApplyPatches();
printf("[Patches] Patches applied\n");
if (nCustomPatches)
{
std::cout << "[Patches] Reading custom patches...\n";
try {
for (std::filesystem::path p : std::filesystem::directory_iterator("../patches"))
{
if (std::filesystem::path(p).filename().string()._Starts_with("._")) continue; // exclude macOS metadata
std::string extension = std::filesystem::path(p).extension().string();
if ((extension == ".p" || extension == ".P" || extension == ".p2" || extension == ".P2") &&
GetPrivateProfileIntW(L"plugins", std::filesystem::path(p).filename().c_str(), TRUE, CONFIG_FILE))
{
std::cout << "[Patches] Reading custom patch file: " << std::filesystem::path(p).filename().string() << std::endl;
ApplyCustomPatches(std::filesystem::path(p).wstring());
}
else std::cout << "[Patches] Skipping disabled patch file: " << std::filesystem::path(p).filename().string() << std::endl;
}
}
catch (const std::filesystem::filesystem_error &e) {
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);
if (!fileStream.is_open())
return;
std::string line;
// check for BOM
std::getline(fileStream, line);
if (line.size() >= 3 && line.rfind("\xEF\xBB\xBF", 0) == 0)
fileStream.seekg(3);
else
fileStream.seekg(0);
while (std::getline(fileStream, line))
{
if (line[0] == '#')
{
std::cout << "[Patches]" << line.substr(1, line.size()-1) << std::endl;
continue;
}
if (line == "IGNORE") break;
if (line.find(':') == std::string::npos || (line[0] == '/' && line[1] == '/')) continue;
std::vector<std::string> commentHSplit = SplitString(line, "#");
std::vector<std::string> commentDSSplit = SplitString(commentHSplit[0], "//");
std::vector<std::string> colonSplit = SplitString(commentDSSplit[0], ":");
if (colonSplit.size() != 2) continue;
bool echo = true;
if (colonSplit[0].at(0) == '@')
{
echo = false;
colonSplit[0].at(0) = ' ';
}
long long int address;
std::istringstream iss(colonSplit[0]);
iss >> std::setbase(16) >> address;
if (address == 0) std::cout << "[Patches] Custom patch address wrong: " << std::hex << address << std::endl;
if (colonSplit[1].at(0) == '!')
{
if (echo) std::cout << "[Patches] Patching: " << std::hex << address << ":!";
std::vector<std::string> fullColonSplit = SplitString(line, ":");
for (int i = 1; i < fullColonSplit[1].size(); i++)
{
unsigned char byte_u = fullColonSplit[1].at(i);
if(byte_u=='\\' && i<fullColonSplit[1].size())
{
switch (fullColonSplit[1].at(i + 1))
{
case '0':
byte_u = '\0';
i++;
break;
case 'n':
byte_u = '\n';
i++;
break;
case 't':
byte_u = '\t';
i++;
break;
case 'r':
byte_u = '\r';
i++;
break;
case 'b':
byte_u = '\b';
i++;
break;
case 'a':
byte_u = '\a';
i++;
break;
case 'f':
byte_u = '\f';
i++;
break;
case 'v':
byte_u = '\v';
i++;
break;
case '\\':
byte_u = '\\';
i++;
break;
}
}
if (echo) std::cout << byte_u;
std::vector<uint8_t> patch = { byte_u };
InjectCode((void*)address, patch);
address++;
}
if (echo) std::cout << std::endl;
}
else
{
std::vector<std::string> bytes = SplitString(colonSplit[1], " ");
if (bytes.size() < 1) continue;
std::string comment_string = "";
int comment_counter = 0;
if (commentHSplit.size() > 1)
{
bool ignore = 1;
for (std::string comment : commentHSplit)
{
if (ignore)
{
ignore = 0;
continue;
}
comment_string = comment_string + comment;
}
}
if (echo) std::cout << "[Patches] Patching: " << std::hex << address << ":";
for (std::string bytestring : bytes)
{
int byte;
std::istringstream issb(bytestring);
issb >> std::setbase(16) >> byte;
unsigned char byte_u = byte;
if (echo)
{
std::cout << std::hex << byte << " ";
if (comment_counter < comment_string.length())
{
std::cout << "(" << comment_string.at(comment_counter) << ") ";
comment_counter++;
}
}
std::vector<uint8_t> patch = { byte_u };
InjectCode((void*)address, patch);
address++;
}
if (echo) std::cout << std::endl;
else if (comment_string.length() > 0)
{
std::cout << "[Patches]";;
if (comment_string.at(0) != ' ') std::cout << ' ';
std::cout << comment_string << std::endl;
}
}
}
fileStream.close();
}
using namespace PluginConfig;
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
{
return L"Patches";
}
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 nStereo = GetPrivateProfileIntW(L"patches", L"stereo", 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 nEnablePvCustomization = GetPrivateProfileIntW(L"patches", L"enable_pv_customization", FALSE, CONFIG_FILE);
auto nNoHandScaling = GetPrivateProfileIntW(L"patches", L"no_hand_scaling", FALSE, CONFIG_FILE);