Fiixed issue where M2 Emulator wouldnt close correctly on certain pcs
This commit is contained in:
parent
44d31dcdb3
commit
42555cf9d6
@ -4,6 +4,36 @@
|
||||
#include "math.h"
|
||||
#include "SDL.h"
|
||||
|
||||
static bool init = false;
|
||||
|
||||
static bool __stdcall ExitHook(UINT uExitCode)
|
||||
{
|
||||
TerminateProcess(GetCurrentProcess(), 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool Hook(void * toHook, void * ourFunct, int len) {
|
||||
if (len < 5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD curProtection;
|
||||
VirtualProtect(toHook, len, PAGE_EXECUTE_READWRITE, &curProtection);
|
||||
|
||||
memset(toHook, 0x90, len);
|
||||
|
||||
DWORD relativeAddress = ((DWORD)ourFunct - (DWORD)toHook) - 5;
|
||||
|
||||
*(BYTE*)toHook = 0xE9;
|
||||
*(DWORD*)((DWORD)toHook + 1) = relativeAddress;
|
||||
|
||||
DWORD temp;
|
||||
VirtualProtect(toHook, len, curProtection, &temp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static DWORD jmpBackAddy;
|
||||
|
||||
void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) {
|
||||
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
|
||||
@ -32,6 +62,23 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT
|
||||
HWND hWnd19 = FindWindowA(0, ("Sega Touring Car Championship (Rev B)"));
|
||||
HWND hWnd20 = FindWindowA(0, ("Over Rev (Model 2B)"));
|
||||
|
||||
|
||||
HMODULE hMod = GetModuleHandleA("KERNEL32.dll");
|
||||
if (hMod)
|
||||
{
|
||||
if (!init)
|
||||
{
|
||||
int hookLength = 6;
|
||||
DWORD hookAddress = (DWORD)GetProcAddress(GetModuleHandle(L"KERNEL32.dll"), "ExitProcess");
|
||||
if (hookAddress)
|
||||
{
|
||||
jmpBackAddy = hookAddress + hookLength;
|
||||
Hook((void*)hookAddress, ExitHook, hookLength);
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hWnd1 > NULL)
|
||||
{
|
||||
UINT8 ff = helpers->ReadByte(0x174CF4, /* isRelativeOffset*/ true); //SegaRallyChampionship
|
||||
|
@ -1,6 +1,6 @@
|
||||
***FFB Arcade Plugin***
|
||||
|
||||
Version 0.9a
|
||||
Version 1.0
|
||||
|
||||
Created by Boomslangnz, Ducon2016 & Spazzy.
|
||||
|
||||
@ -10,6 +10,10 @@ While best efforts were made to try to resemble the real arcade force feedback,
|
||||
in some cases eg Mario Kart GP DX, Pokken Tournament and Battle Gear 4,effects were created entirely from scratch
|
||||
so are not using real force feedback values. Most games use correct ffb values however :)
|
||||
|
||||
***1.0 Changes***
|
||||
|
||||
- Fixed issue where M2 Emulator wouldn't close correctly while using FFB Plugin
|
||||
|
||||
***0.9a Changes***
|
||||
|
||||
- Fixed issue where MAME plugins would not load
|
||||
|
Loading…
x
Reference in New Issue
Block a user