1
0
mirror of synced 2025-02-07 22:51:29 +01:00

More patches. VF5.C working.

This commit is contained in:
dkeruza 2023-11-29 13:49:03 -05:00
parent 0ee6d12393
commit 339187d643
6 changed files with 293 additions and 190 deletions

Binary file not shown.

View File

@ -135,7 +135,7 @@ static int detectGame(uint32_t elf_crc)
if (elf_crc == 0x1bf1b627)
{
config.game = VF5_REVC;
config.gameStatus = NOT_WORKING;
config.gameStatus = WORKING;
return 0;
}

View File

@ -163,6 +163,7 @@ int XNextEvent(Display *display, XEvent *event_return)
{
case 28:
setSwitch(SYSTEM, BUTTON_TEST, event_return->type == KeyPress);
//securityBoardSetSwitch(BUTTON_TEST, 1);
break;
case 39:
setSwitch(PLAYER_1, BUTTON_SERVICE, event_return->type == KeyPress);

View File

@ -59,10 +59,12 @@ static void handleSegfault(int signal, siginfo_t *info, void *ptr)
{
ucontext_t *ctx = ptr;
//printf("Caught segfault at address %p\n", info->si_addr);
// Get the address of the instruction causing the segfault
uint8_t *code = (uint8_t *)ctx->uc_mcontext.gregs[REG_EIP];
printf("Code: 0x%08x - Port: 0x%08x\n", *code, (ctx->uc_mcontext.gregs[REG_EDX] & 0xFFFF));
printf("Code: 0x%08x - Port: 0x%08x\n", *code, (ctx->uc_mcontext.gregs[REG_EDX] & 0xFFFF) - basePortAddress);
switch (*code)
{
case 0xED:
@ -138,6 +140,11 @@ void __attribute__((constructor)) hook_init()
// Get CPU ID
getCPUID();
FILE *file = fopen("dump_unpatched.bin","w+b");
fwrite((void *)0x08048000,0x630fac,1,file);
fclose(file);
// Implement SIGSEGV handler
struct sigaction act;
act.sa_sigaction = handleSegfault;

View File

@ -1,5 +1,6 @@
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/mman.h>
#include <unistd.h>
@ -23,10 +24,28 @@ static void setVariable(uint32_t address, uint32_t value)
printf("Error: Cannot unprotect memory region to change variable (%d)\n", prot);
return;
}
// printf("Variable: %8X , Value: %8X\n",(uint32_t)variable, value);
*variable = value;
}
static void setMem(uint32_t address, uint32_t value, int size)
{
int pagesize = sysconf(_SC_PAGE_SIZE);
uint32_t *variable = (uint32_t *)address;
void *toModify = (void *)(address - (address % pagesize));
int prot = mprotect(toModify, pagesize, PROT_EXEC | PROT_WRITE);
if (prot != 0)
{
printf("Error: Cannot unprotect memory region to change variable (%d)\n", prot);
return;
}
// printf("Variable: %8X , Value: %8X\n",(uint32_t)variable, value);
memccpy((void *)variable, (void *)value, 1, size);
}
static void detourFunction(uint32_t address, void *function)
{
int pagesize = sysconf(_SC_PAGE_SIZE);
@ -52,6 +71,11 @@ static void detourFunction(uint32_t address, void *function)
memcpy((void *)address, cave, 5);
}
int stub0()
{
return 0;
}
int amDongleInit()
{
return 0;
@ -67,18 +91,55 @@ int amDongleUpdate()
return 0;
}
void _putConsole(char *param1, char *param2)
void _putConsole(const char *format, ...)
{
if(param2 >=0 )
va_list args;
va_start(args, format);
while (*format)
{
printf(param1, (int)param2);
printf("\n");
if (*format == '%')
{
format++;
if ((*format == 'd') || (*format == 'n'))
{
printf("%d", va_arg(args, int));
}
else if (*format == 's')
{
printf("%s", va_arg(args, char *));
}
else if (*format == 'u')
{
printf("%u", va_arg(args, unsigned int));
}
else if (*format == '0')
{
format ++;
if (*format == '2')
{
format++;
printf("%02X", va_arg(args, int));
}
else if (*format == '4')
{
format++;
printf("%04X", va_arg(args, unsigned int));
}
}
else
{
printf("%s\n", param1);
printf("\nFormat: %c.\n", *format);
}
return;
}
else
{
putchar(*format);
}
format++;
}
va_end(args);
printf("\n");
}
int initPatch()
@ -138,6 +199,7 @@ int initPatch()
detourFunction(0x081e3424, amDongleInit);
detourFunction(0x081e3772, amDongleIsAvailable);
detourFunction(0x081e369e, amDongleUpdate);
setVariable(0x081e7945, 0x00000001); //Test
}
break;
case OUTRUN:
@ -199,6 +261,12 @@ int initPatch()
detourFunction(0x085c6010, amDongleInit);
detourFunction(0x085c63cc, amDongleIsAvailable);
detourFunction(0x085c62f0, amDongleUpdate);
detourFunction(0x080b3426, stub0); // Stub returns 0
detourFunction(0x080cb6d4, stub0); // Stub returns 0
detourFunction(0x0840889e, stub0); // Stub returns 0
detourFunction(0x0840ab90, stub0); // Stub returns 0
setVariable(0x080e17af, 0x000000b8); // Patch IDK what
setVariable(0x080e17b3, 0x01e88300); // Patch IDK what
}
break;
case LETS_GO_JUNGLE:
@ -219,8 +287,22 @@ int initPatch()
detourFunction(0x084e50d8, amDongleInit);
detourFunction(0x084e5459, amDongleIsAvailable);
detourFunction(0x084e537d, amDongleUpdate);
//detourFunction(0x08074a8c, _putConsole);
setVariable(0x0840b06f, 0xc48306eb); // Patch to initialize????
detourFunction(0x08074a8c, _putConsole);
setVariable(0x080d1f02, 0x90909090); // Patch acpSystem::checkDongle
setVariable(0x080d1f06, 0xE8C3C990); // Patch acpSystem::checkDongle
setVariable(0x0807b76a, 0xc2839090); // Patch initializeArcadeBackup
// setVariable(0x082E006b, 0x00000280); // Set ResX
// setVariable(0x082E0078, 0x000001E0); // Set ResY
detourFunction(0x084e4efc, stub0); // Stub amDipswInit
detourFunction(0x084e500e, stub0); // Stub amDipswGetData
detourFunction(0x084e5086, stub0); // Stub amDipswSetLed
detourFunction(0x084e4f98, stub0); // Stub amDipswExit
setVariable(0x0840d858, 0x1c899090); // No more Full Screen from the Game
//From Teknoparrot
setVariable(0x083ef701, 0x00036ee9); // AMDFIX
setVariable(0x084032e0, 0x8b90c933); // fix shader compilation with AMD GPUs
setVariable(0x08523950, 0x000000c3); // Remove ADXM_SetupFramework (Not necessary)
}
break;
case LETS_GO_JUNGLE_SPECIAL:
@ -242,6 +324,14 @@ int initPatch()
detourFunction(0x085106dc, amDongleIsAvailable);
detourFunction(0x08510600, amDongleUpdate);
detourFunction(0x08075012, _putConsole);
//setVariable(0x08303C4B, 0x00000780); // Set ResX
//setVariable(0x08303C58, 0x00000438); // Set ResY
setVariable(0x080dad63, 0x90909090); // Patch acpSystem::checkDongle
setVariable(0x080dad67, 0xE8C3C990); // Patch acpSystem::checkDongle
setVariable(0x0807e609, 0x90909090); // Patch initializeArcadeBackup
setVariable(0x0807e60D, 0xC2839090); // Patch initializeArcadeBackup
setVariable(0x087d47f7, 0x62ab8500); // Seat Test??
setVariable(0x08438954, 0x1c899090); // No more Full Screen from the Game
}
break;
case ID4:
@ -263,6 +353,10 @@ int initPatch()
detourFunction(0x086e0d81, amDongleIsAvailable);
detourFunction(0x086e17e5, amDongleUpdate);
detourFunction(0x0808f9a8, _putConsole);
setVariable(0x080dad63, 0x90909090); // Patch acpSystem::checkDongle
setVariable(0x080dad67, 0xE8C3C990); // Patch acpSystem::checkDongle
setVariable(0x0807e609, 0x90909090); // Patch initializeArcadeBackup
setVariable(0x0807e60D, 0xC2839090); // Patch initializeArcadeBackup
}
default:
// Don't do any patches for random games

View File

@ -77,6 +77,7 @@ int securityBoardSetDipSwitch(int switchNumber, int value)
int securityBoardSetSwitch(JVSInput switchNumber, int value)
{
printf("Pressed\n");
switch (switchNumber)
{
case BUTTON_TEST: