Add some extra hooks
This commit is contained in:
parent
2f26408d33
commit
bc800855ee
@ -135,6 +135,7 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
|
|||||||
|
|
||||||
case BASEBOARD_INIT:
|
case BASEBOARD_INIT:
|
||||||
{
|
{
|
||||||
|
printf("baseboard init\n");
|
||||||
// selectReply = -1; Considering adding this in
|
// selectReply = -1; Considering adding this in
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -142,6 +143,8 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
|
|||||||
|
|
||||||
case BASEBOARD_READY: // Not sure this is what it should be called
|
case BASEBOARD_READY: // Not sure this is what it should be called
|
||||||
{
|
{
|
||||||
|
printf("baseboard read\n");
|
||||||
|
|
||||||
selectReply = 0;
|
selectReply = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -181,6 +184,7 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
|
|||||||
|
|
||||||
case BASEBOARD_GET_SERIAL: // bcCmdSysInfoGetReq
|
case BASEBOARD_GET_SERIAL: // bcCmdSysInfoGetReq
|
||||||
{
|
{
|
||||||
|
printf("game asked for serial\n");
|
||||||
serialCommand.destAddress = _data[1];
|
serialCommand.destAddress = _data[1];
|
||||||
serialCommand.destSize = _data[2];
|
serialCommand.destSize = _data[2];
|
||||||
}
|
}
|
||||||
@ -199,6 +203,13 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
|
|||||||
jvsCommand.destAddress = _data[3];
|
jvsCommand.destAddress = _data[3];
|
||||||
jvsCommand.destSize = _data[4];
|
jvsCommand.destSize = _data[4];
|
||||||
memcpy(inputBuffer, &sharedMemory[jvsCommand.srcAddress], jvsCommand.srcSize);
|
memcpy(inputBuffer, &sharedMemory[jvsCommand.srcAddress], jvsCommand.srcSize);
|
||||||
|
printf("TO OPENJVS\n");
|
||||||
|
for (int i = 0; i < jvsCommand.srcSize; i++)
|
||||||
|
{
|
||||||
|
printf("%X ", sharedMemory[jvsCommand.srcAddress + i] & 0xFF);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
if (getConfig()->emulateJVS)
|
if (getConfig()->emulateJVS)
|
||||||
{
|
{
|
||||||
processPacket();
|
processPacket();
|
||||||
@ -224,6 +235,9 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BASEBOARD_GET_SENSE_LINE:
|
case BASEBOARD_GET_SENSE_LINE:
|
||||||
|
{
|
||||||
|
printf("REQUEST SENSE LINE\n");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -246,6 +260,7 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
|
|||||||
|
|
||||||
case BASEBOARD_GET_SERIAL:
|
case BASEBOARD_GET_SERIAL:
|
||||||
{
|
{
|
||||||
|
printf("receive serial\n");
|
||||||
memcpy(&sharedMemory[serialCommand.destAddress + 96], SERIAL_STRING, strlen(SERIAL_STRING));
|
memcpy(&sharedMemory[serialCommand.destAddress + 96], SERIAL_STRING, strlen(SERIAL_STRING));
|
||||||
_data[1] = 1; // Set the status to success
|
_data[1] = 1; // Set the status to success
|
||||||
}
|
}
|
||||||
@ -255,6 +270,7 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
|
|||||||
{
|
{
|
||||||
_data[2] = getSenseLine();
|
_data[2] = getSenseLine();
|
||||||
_data[1] = 1; // Set the status to success
|
_data[1] = 1; // Set the status to success
|
||||||
|
printf("RECEIVE SENSE LINE\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -262,10 +278,19 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
|
|||||||
{
|
{
|
||||||
if (getConfig()->emulateJVS)
|
if (getConfig()->emulateJVS)
|
||||||
{
|
{
|
||||||
|
printf("FROM OPENJVS\n");
|
||||||
|
|
||||||
memcpy(&sharedMemory[jvsCommand.destAddress], outputBuffer, outputPacket.length + 3);
|
memcpy(&sharedMemory[jvsCommand.destAddress], outputBuffer, outputPacket.length + 3);
|
||||||
|
usleep(500);
|
||||||
_data[2] = jvsCommand.destAddress;
|
_data[2] = jvsCommand.destAddress;
|
||||||
_data[3] = outputPacket.length + 3;
|
_data[3] = outputPacket.length + 3;
|
||||||
_data[1] = 1; // Set the status to success
|
_data[1] = 1; // Set the status to success
|
||||||
|
|
||||||
|
for (int i = 0; i < _data[3]; i++)
|
||||||
|
{
|
||||||
|
printf("%X ", sharedMemory[jvsCommand.destAddress + i] & 0xFF);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
else if (jvsFileDescriptor >= 0)
|
else if (jvsFileDescriptor >= 0)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ static int detectGame()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(program_invocation_name, "Jennifer") || strstr(program_invocation_name, "JenTest"))
|
if (strstr(program_invocation_name, "Jennifer"))
|
||||||
{
|
{
|
||||||
config.game = OUTRUN;
|
config.game = OUTRUN;
|
||||||
config.emulateDriveboard = 1;
|
config.emulateDriveboard = 1;
|
||||||
@ -56,6 +56,14 @@ static int detectGame()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strstr(program_invocation_name, "JenTest"))
|
||||||
|
{
|
||||||
|
config.game = OUTRUN_TEST;
|
||||||
|
config.emulateDriveboard = 1;
|
||||||
|
config.emulateMotionboard = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (strstr(program_invocation_name, "lgj"))
|
if (strstr(program_invocation_name, "lgj"))
|
||||||
{
|
{
|
||||||
config.game = LETS_GO_JUNGLE;
|
config.game = LETS_GO_JUNGLE;
|
||||||
|
@ -10,6 +10,7 @@ typedef enum
|
|||||||
SEGABOOT_2_6,
|
SEGABOOT_2_6,
|
||||||
THE_HOUSE_OF_THE_DEAD_4,
|
THE_HOUSE_OF_THE_DEAD_4,
|
||||||
OUTRUN,
|
OUTRUN,
|
||||||
|
OUTRUN_TEST,
|
||||||
LETS_GO_JUNGLE
|
LETS_GO_JUNGLE
|
||||||
} Game;
|
} Game;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ ssize_t driveboardWrite(int fd, const void *buf, size_t count)
|
|||||||
|
|
||||||
if (count != 4)
|
if (count != 4)
|
||||||
{
|
{
|
||||||
printf("Error: Drive board count not what expected\n");
|
//printf("Error: Drive board count not what expected\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,21 +44,21 @@ ssize_t driveboardWrite(int fd, const void *buf, size_t count)
|
|||||||
{
|
{
|
||||||
case 0xFF:
|
case 0xFF:
|
||||||
{
|
{
|
||||||
printf("Driveboard: Drive board reset\n");
|
//printf("Driveboard: Drive board reset\n");
|
||||||
response = DRIVEBOARD_READY;
|
response = DRIVEBOARD_READY;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x81:
|
case 0x81:
|
||||||
{
|
{
|
||||||
printf("Driveboard: Drive board reset 2\n");
|
//printf("Driveboard: Drive board reset 2\n");
|
||||||
response = DRIVEBOARD_NOT_INIT;
|
response = DRIVEBOARD_NOT_INIT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xFC:
|
case 0xFC:
|
||||||
{
|
{
|
||||||
printf("Driveboard: Start wheel bounds testing\n");
|
//printf("Driveboard: Start wheel bounds testing\n");
|
||||||
wheelTest = 1;
|
wheelTest = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -83,7 +83,7 @@ ssize_t driveboardWrite(int fd, const void *buf, size_t count)
|
|||||||
setAnalogue(ANALOGUE_1, (int)(steerValue * 1024));
|
setAnalogue(ANALOGUE_1, (int)(steerValue * 1024));
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Driveboard move %f %f\n", steerValue, force);
|
//printf("Driveboard move %f %f\n", steerValue, force);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -98,14 +98,14 @@ ssize_t driveboardWrite(int fd, const void *buf, size_t count)
|
|||||||
if (buffer[1] == 0)
|
if (buffer[1] == 0)
|
||||||
force = ((1 - ((double)buffer[2] / 128.0)) * 2) / 100;
|
force = ((1 - ((double)buffer[2] / 128.0)) * 2) / 100;
|
||||||
|
|
||||||
printf("Driveboard set force%f %f\n", steerValue, force);
|
//printf("Driveboard set force%f %f\n", steerValue, force);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xFA:
|
case 0xFA:
|
||||||
case 0xFD:
|
case 0xFD:
|
||||||
{
|
{
|
||||||
printf("Driveboard: auto turn wheel mode\n");
|
//printf("Driveboard: auto turn wheel mode\n");
|
||||||
|
|
||||||
if (wheelTest)
|
if (wheelTest)
|
||||||
{
|
{
|
||||||
@ -123,7 +123,7 @@ ssize_t driveboardWrite(int fd, const void *buf, size_t count)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Driveboard: Unknown command received %X\n", buffer[0]);
|
//printf("Driveboard: Unknown command received %X\n", buffer[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ FGAPI int FGAPIENTRY glutEnterGameMode()
|
|||||||
glutCreateWindow(gameTitle);
|
glutCreateWindow(gameTitle);
|
||||||
|
|
||||||
// Outrun doesn't run the glutMainLoop through, so we'll do that here
|
// Outrun doesn't run the glutMainLoop through, so we'll do that here
|
||||||
if (getConfig()->game == OUTRUN)
|
if (getConfig()->game == OUTRUN || getConfig()->game == OUTRUN_TEST)
|
||||||
{
|
{
|
||||||
pthread_t glutMainLoopID;
|
pthread_t glutMainLoopID;
|
||||||
pthread_create(&glutMainLoopID, NULL, &glutMainLoopThread, NULL);
|
pthread_create(&glutMainLoopID, NULL, &glutMainLoopThread, NULL);
|
||||||
|
@ -126,6 +126,67 @@ void setVariable(uint32_t address, uint32_t value)
|
|||||||
*variable = value;
|
*variable = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
bool Detour(byte_t* src, byte_t* dst, size_t size)
|
||||||
|
{
|
||||||
|
if(size < HOOK_MIN_SIZE) return false;
|
||||||
|
//mprotect(src, size, PROT_EXEC | PROT_READ | PROT_WRITE);
|
||||||
|
int out = ProtectMemory((mem_t)src, size, PROT_EXEC | PROT_READ | PROT_WRITE);
|
||||||
|
//std::cout << out << std::endl;
|
||||||
|
mem_t jmpAddr = ((mem_t)dst - (mem_t)src) - HOOK_MIN_SIZE;
|
||||||
|
byte_t CodeCave[] = { JMP, 0x0, 0x0, 0x0, 0x0 };
|
||||||
|
*(mem_t*)((mem_t)CodeCave + sizeof(JMP)) = jmpAddr;
|
||||||
|
memcpy(src, CodeCave, sizeof(CodeCave));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void detourFunction(uint32_t address, void *function)
|
||||||
|
{
|
||||||
|
int pagesize = sysconf(_SC_PAGE_SIZE);
|
||||||
|
|
||||||
|
void *toModify = (void *)(address - (address % pagesize));
|
||||||
|
|
||||||
|
int prot = mprotect(toModify, pagesize, PROT_EXEC | PROT_WRITE | PROT_READ);
|
||||||
|
if (prot != 0)
|
||||||
|
{
|
||||||
|
printf("unprotect error %d\n", prot);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t jumpAddress = ((uint32_t)function - address) - 5;
|
||||||
|
|
||||||
|
char cave[5] = {0xE9, 0x0, 0x00, 0x00, 0x00};
|
||||||
|
memcpy(cave + 1, (void *)jumpAddress, 4);
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
printf("%X ", cave[i] & 0xFF);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
memcpy((void *)address, cave, 5);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int amDongleInit()
|
||||||
|
{
|
||||||
|
printf("amDongleInit calld\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int amDongleIsAvailable()
|
||||||
|
{
|
||||||
|
printf("amDongleIsAvailable calld\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int amDongleUpdate()
|
||||||
|
{
|
||||||
|
printf("amDongleUpdate calld\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void __attribute__((constructor)) hook_init()
|
void __attribute__((constructor)) hook_init()
|
||||||
{
|
{
|
||||||
printf("SEGA Lindbergh Loader\nRobert Dilley 2022\nNot for public consumption\n\n");
|
printf("SEGA Lindbergh Loader\nRobert Dilley 2022\nNot for public consumption\n\n");
|
||||||
@ -183,6 +244,27 @@ void __attribute__((constructor)) hook_init()
|
|||||||
setVariable(0x0a737f20, 2); // bcLibDebugLevel
|
setVariable(0x0a737f20, 2); // bcLibDebugLevel
|
||||||
setVariable(0x0a737f24, 0x0FFFFFFF); // s_logMask
|
setVariable(0x0a737f24, 0x0FFFFFFF); // s_logMask
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (getConfig()->game == OUTRUN)
|
||||||
|
{
|
||||||
|
printf("Enabling game debug features for outrun\n");
|
||||||
|
setVariable(0x0893a24c, 2); // amBackupDebugLevel
|
||||||
|
setVariable(0x0893a260, 2); // amCreditDebugLevel
|
||||||
|
setVariable(0x0893a4b8, 2); // amDipswDebugLevel
|
||||||
|
setVariable(0x0893a4bc, 2); // amDongleDebugLevel
|
||||||
|
setVariable(0x0893a4c0, 2); // amEepromDebugLevel
|
||||||
|
setVariable(0x0893a4c4, 2); // amHwmonitorDebugLevel
|
||||||
|
setVariable(0x0893a4c8, 2); // amJvsDebugLevel
|
||||||
|
setVariable(0x0893a4cc, 2); // amLibDebugLevel
|
||||||
|
setVariable(0x0893a4d0, 2); // amMiscDebugLevel
|
||||||
|
setVariable(0x0893a4d4, 2); // amOsinfoDebugLevel
|
||||||
|
setVariable(0x0893a4d8, 2); // amSysDataDebugLevel
|
||||||
|
setVariable(0x0893a4e0, 2); // bcLibDebugLevel
|
||||||
|
|
||||||
|
detourFunction(0x08190e80, amDongleInit); // amInit 08190e80
|
||||||
|
detourFunction(0x08191201, amDongleIsAvailable);
|
||||||
|
detourFunction(0x08191125, amDongleUpdate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int open(const char *pathname, int flags)
|
int open(const char *pathname, int flags)
|
||||||
|
@ -189,7 +189,7 @@ JVSStatus processPacket()
|
|||||||
size = 2;
|
size = 2;
|
||||||
io.deviceID = -1;
|
io.deviceID = -1;
|
||||||
senseLine = 3;
|
senseLine = 3;
|
||||||
// printf("CMD_RESET %d\n", senseLine);
|
printf("CMD_RESET %d\n", senseLine);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -559,9 +559,11 @@ JVSStatus readPacket(JVSPacket *packet)
|
|||||||
*/
|
*/
|
||||||
JVSStatus writePacket(JVSPacket *packet)
|
JVSStatus writePacket(JVSPacket *packet)
|
||||||
{
|
{
|
||||||
|
printf("packet\n");
|
||||||
/* Don't return anything if there isn't anything to write! */
|
/* Don't return anything if there isn't anything to write! */
|
||||||
if (packet->length < 2)
|
|
||||||
return JVS_STATUS_SUCCESS;
|
printf("sent a packet\n");
|
||||||
|
|
||||||
|
|
||||||
/* Get pointer to raw data in packet */
|
/* Get pointer to raw data in packet */
|
||||||
unsigned char *packetPointer = (unsigned char *)packet;
|
unsigned char *packetPointer = (unsigned char *)packet;
|
||||||
@ -640,5 +642,6 @@ int setAnalogue(JVSInput channel, int value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setSenseLine(int _senseLine) {
|
void setSenseLine(int _senseLine) {
|
||||||
|
printf("sense line set to %d\n", _senseLine);
|
||||||
senseLine = _senseLine;
|
senseLine = _senseLine;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user