1
0
mirror of synced 2024-11-28 03:20:48 +01:00
This commit is contained in:
dkeruza 2023-12-06 15:15:48 -05:00
parent a460db0076
commit a4b81bdb85
2 changed files with 57 additions and 26 deletions

View File

@ -43,6 +43,7 @@
int hooks[5] = {-1, -1, -1, -1};
FILE *fileHooks[3] = {NULL, NULL, NULL};
int fileRead[3] = {0, 0, 0};
char envpath[100];
uint32_t elf_crc = 0;
cpuvendor cpu_vendor = {0};
@ -131,7 +132,6 @@ static void handleSegfault(int signal, siginfo_t *info, void *ptr)
}
}
void __attribute__((constructor)) hook_init()
{
printf("SEGA Lindbergh Loader\nRobert Dilley 2022\nNot for public consumption\n\n");
@ -615,12 +615,15 @@ uint32_t get_crc32(const char *s,size_t n)
{
uint32_t crc = 0xFFFFFFFF;
for(size_t i=0;i<n;i++) {
for (size_t i = 0; i < n; i++)
{
char ch = s[i];
for(size_t j=0;j<8;j++) {
for (size_t j = 0; j < 8; j++)
{
uint32_t b = (ch ^ crc) & 1;
crc >>= 1;
if(b) crc=crc^0xEDB88320;
if (b)
crc = crc ^ 0xEDB88320;
ch >>= 1;
}
}
@ -662,6 +665,33 @@ int setenv(const char *name, const char *value, int overwrite)
return _setenv(name, value, overwrite);
}
/**
* Fake the TEA_DIR environment variable to games that require it to run
*/
char *getenv(const char *name)
{
char *(*_getenv)(const char *name) = dlsym(RTLD_NEXT, "getenv");
if ((strcmp(name, "TEA_DIR") == 0) && getConfig()->game == VT3)
{
if (getcwd(envpath, 100) == NULL)
return "";
char *ptr = strrchr(envpath, '/');
if (ptr == NULL)
return "";
*ptr = '\0';
return envpath;
}
else if (strcmp(name, "TEA_DIR") == 0)
{
if (getcwd(envpath, 100) == NULL)
return "";
return envpath;
}
return _getenv(name);
}
/**
* Stop the game unsetting the DISPLAY environment variable
*/

View File

@ -453,6 +453,7 @@ int initPatch()
detourFunction(0x0831c99e, amDongleUpdate);
detourFunction(0x0831c5d7, amDipswGetData);
detourFunction(0x0831c64f, stub0);
setVariable(0x0827ae1b, 0x34891beb); //Disable Fullscreen
}
break;
default: