Modify so Nascar Racing will work on any version of demul
This commit is contained in:
parent
745e7efd2b
commit
9b9742bc62
86
Common Files/SignatureScanning.h
Normal file
86
Common Files/SignatureScanning.h
Normal file
@ -0,0 +1,86 @@
|
||||
#include <Windows.h>
|
||||
|
||||
static char* aAddy;
|
||||
static char* aAddy2;
|
||||
|
||||
static char* InScan(char* pattern, char* mask, char* begin, unsigned int size)
|
||||
{
|
||||
unsigned int patternLength = strlen(mask);
|
||||
|
||||
for (unsigned int i = 0; i < size - patternLength; i++)
|
||||
{
|
||||
bool found = true;
|
||||
for (unsigned int j = 0; j < patternLength; j++)
|
||||
{
|
||||
if (mask[j] != '?' && pattern[j] != *(begin + i + j))
|
||||
{
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
return (begin + i);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char* PatternScan(char* pattern, char* mask)
|
||||
{
|
||||
SYSTEM_INFO sysInfo;
|
||||
|
||||
GetSystemInfo(&sysInfo);
|
||||
|
||||
__int64 end = (__int64)sysInfo.lpMaximumApplicationAddress;
|
||||
|
||||
char* currentChunk = 0;
|
||||
char* match = nullptr;
|
||||
SIZE_T bytesRead;
|
||||
|
||||
while (currentChunk < (char*)end)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
|
||||
HANDLE process = GetCurrentProcess();
|
||||
|
||||
if (!VirtualQueryEx(process, currentChunk, &mbi, sizeof(mbi)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* buffer = 0;
|
||||
if (mbi.State == MEM_COMMIT && mbi.Protect != PAGE_NOACCESS)
|
||||
{
|
||||
buffer = new char[mbi.RegionSize];
|
||||
DWORD oldprotect;
|
||||
if (VirtualProtectEx(process, mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &oldprotect))
|
||||
{
|
||||
ReadProcessMemory(process, mbi.BaseAddress, buffer, mbi.RegionSize, &bytesRead);
|
||||
VirtualProtectEx(process, mbi.BaseAddress, mbi.RegionSize, oldprotect, &oldprotect);
|
||||
|
||||
char* internalAddress = InScan(pattern, mask, buffer, bytesRead);
|
||||
|
||||
if (internalAddress != 0)
|
||||
{
|
||||
__int64 offsetFromBuffer = internalAddress - buffer;
|
||||
match = currentChunk + offsetFromBuffer;
|
||||
|
||||
if (match != aAddy2)
|
||||
{
|
||||
delete[] buffer;
|
||||
buffer = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentChunk = currentChunk + mbi.RegionSize;
|
||||
|
||||
if (buffer) delete[] buffer;
|
||||
buffer = 0;
|
||||
}
|
||||
return match;
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Common Files\SignatureScanning.h" />
|
||||
<ClInclude Include="Game Files\AliensExtermination.h" />
|
||||
<ClInclude Include="Game Files\Batman.h" />
|
||||
<ClInclude Include="Game Files\DirtyDrivin.h" />
|
||||
|
@ -275,6 +275,9 @@
|
||||
<ClInclude Include="Game Files\R-Tuned.h">
|
||||
<Filter>Common Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common Files\SignatureScanning.h">
|
||||
<Filter>Common Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MASM Include="DLLWrapper.asm" />
|
||||
|
@ -18,6 +18,10 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include "../Common Files/SignatureScanning.h"
|
||||
|
||||
static bool FFBGameInit = false;
|
||||
static INT_PTR FFBAddress;
|
||||
|
||||
int nascar(int ffnas) {
|
||||
switch (ffnas) {
|
||||
@ -118,13 +122,20 @@ void Demul::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers
|
||||
{
|
||||
if (!EnumWindows(FindWindowBySubstr, (LPARAM)substring))
|
||||
{
|
||||
UINT8 ffnas = helpers->ReadByte(0x30060C, /* isRelativeOffset */ true); //Nascar Arcade
|
||||
if (!FFBGameInit)
|
||||
{
|
||||
FFBGameInit = true;
|
||||
aAddy2 = PatternScan("\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x50\x72\x6F\x64\x75\x63\x65\x64\x20\x42\x79\x20", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
|
||||
FFBAddress = (int)aAddy2 - 0x2F0;
|
||||
}
|
||||
|
||||
UINT8 ffnas = helpers->ReadByte(FFBAddress, false); //Nascar Arcade
|
||||
std::string ffs = std::to_string(ffnas);
|
||||
helpers->log((char*)ffs.c_str());
|
||||
helpers->log("got value: ");
|
||||
ffnascar = nascar(ffnas);
|
||||
|
||||
if ((ffnascar > 16)& (ffnascar < 33))
|
||||
if ((ffnascar > 0x10) && (ffnascar < 0x21))
|
||||
{
|
||||
helpers->log("moving wheel left");
|
||||
double percentForce = (ffnascar - 16) / 16.0;
|
||||
@ -132,7 +143,7 @@ void Demul::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers
|
||||
triggers->Rumble(percentForce, 0, percentLength);
|
||||
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
|
||||
}
|
||||
else if ((ffnascar > 0)& (ffnascar < 17))
|
||||
else if ((ffnascar > 0x00) && (ffnascar < 0x11))
|
||||
{
|
||||
helpers->log("moving wheel right");
|
||||
double percentForce = (17 - ffnascar) / 16.0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user