Fix possible crash when exit after disabling messagebox

This commit is contained in:
rebtd7 2021-03-16 12:00:04 -03:00
parent 6723a31b6a
commit 308d4a9464
2 changed files with 29 additions and 4 deletions

View file

@ -198,6 +198,7 @@ void MainContext::FF13_InitializeGameAddresses()
ff13_party_screen_scissor_scaling_factor_3 = baseAddr + 0x668E56;
ff13_party_screen_scissor_scaling_factor_4 = baseAddr + 0x668E91;
ff13_message_box_call_address = baseAddr + 0xA8A98F;
ff13_message_box_stack_push_address = baseAddr + 0xA8A982;
}
void MainContext::ForceWindowActivate(const HWND hWnd) {
@ -208,7 +209,7 @@ void MainContext::ForceWindowActivate(const HWND hWnd) {
void MainContext::FF13_OneTimeFixes() {
if (IsDXVK()) {
PatchMessageBox(ff13_message_box_call_address);
FF13_PatchMessageBox();
}
ForceWindowActivate(hWndFF13);
@ -223,6 +224,17 @@ void MainContext::FF13_OneTimeFixes() {
PrintLog("Finished FF13 One Time Fixes");
}
void MainContext::FF13_PatchMessageBox()
{
PrintLog("Removing 'Quit game' textbox");
MemPatch::Nop(ff13_message_box_stack_push_address, 1);
MemPatch::Nop(ff13_message_box_stack_push_address + 1 * 4, 1);
MemPatch::Nop(ff13_message_box_stack_push_address + 2 * 4, 1);
MemPatch::Nop(ff13_message_box_stack_push_address + 3 * 4, 1);
PatchMessageBoxCall(ff13_message_box_call_address);
}
void MainContext::FF13_EnableControllerVibration()
{
if (!config.GetFFXIIIEnableControllerVibration()) {
@ -320,7 +332,7 @@ void MainContext::FF13_2_OneTimeFixes()
{
ForceWindowActivate(hWndFF13);
if (IsDXVK()) {
PatchMessageBox(ff13_2_message_box_call_address);
FF13_2_PatchMessageBox();
}
if (*ff13_2_frame_pacer_ptr_address) {
@ -338,9 +350,17 @@ void MainContext::FF13_2_OneTimeFixes()
}
}
void MainContext::PatchMessageBox(uint8_t* callInstructionAddress)
void MainContext::FF13_2_PatchMessageBox()
{
PrintLog("Removing 'Quit game' textbox");
// NOP push of registers to call MessageBox
MemPatch::Nop(ff13_2_message_box_stack_push_address, 5);
PatchMessageBoxCall(ff13_2_message_box_call_address);
}
void MainContext::PatchMessageBoxCall(uint8_t* callInstructionAddress)
{
const int patchSize = 6;
uint8_t patch[patchSize];
@ -394,6 +414,7 @@ void MainContext::FF13_2_InitializeGameAddresses()
ff13_2_internal_res_w = (uint32_t*)(baseAddr + 0x1FA864C);
ff13_2_internal_res_h = ff13_2_internal_res_w + 1;
ff13_2_message_box_call_address = baseAddr + 0x8047C0;
ff13_2_message_box_stack_push_address = baseAddr + 0x8047B4;
}
void MainContext::FF13_2_RemoveContinuousControllerScan()

View file

@ -93,6 +93,7 @@ private:
uint8_t* ff13_party_screen_scissor_scaling_factor_2 = NULL;
uint8_t* ff13_party_screen_scissor_scaling_factor_3 = NULL;
uint8_t* ff13_party_screen_scissor_scaling_factor_4 = NULL;
uint8_t* ff13_message_box_stack_push_address = NULL;
uint8_t* ff13_message_box_call_address = NULL;
uint32_t* ff13_internal_res_w;
uint32_t* ff13_internal_res_h;
@ -105,6 +106,7 @@ private:
uint8_t** ff13_2_base_controller_input_address_ptr = NULL;
uint8_t* ff13_2_vibration_high_set_zero_address = NULL;
uint8_t* ff13_2_vibration_low_set_zero_address = NULL;
uint8_t* ff13_2_message_box_stack_push_address = NULL;
uint8_t* ff13_2_message_box_call_address = NULL;
uint32_t* ff13_2_internal_res_w;
uint32_t* ff13_2_internal_res_h;
@ -143,6 +145,7 @@ private:
void FF13_InitializeGameAddresses();
void FF13_OneTimeFixes();
void FF13_PatchMessageBox();
void FF13_EnableControllerVibration();
void FF13_NOPIngameFrameRateLimitSetter();
void FF13_SetFrameRateVariables();
@ -154,12 +157,13 @@ private:
void FF13_2_RemoveContinuousControllerScan();
void FF13_2_AddHookIngameFrameRateLimitSetter();
void FF13_2_OneTimeFixes();
void FF13_2_PatchMessageBox();
void FF13_2_EnableControllerVibration();
void AdjustVertexData(const uint32_t width, const uint32_t height);
bool MatchesExpectedVertexStream(const float* pVertexStreamZeroData);
void ForceWindowActivate(const HWND hWnd);
void PatchMessageBox(uint8_t* callInstructionAddress);
void PatchMessageBoxCall(uint8_t* callInstructionAddress);
bool OneTimeFixInit(std::unique_ptr<wchar_t[]>& className, HWND hWnd);
std::atomic_bool otf_init = false;