diff --git a/src/lindbergh/hook.c b/src/lindbergh/hook.c index 4680549..31e8bad 100644 --- a/src/lindbergh/hook.c +++ b/src/lindbergh/hook.c @@ -108,7 +108,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"); @@ -121,7 +120,7 @@ void __attribute__((constructor)) hook_init() initConfig(); - if(initPatch() != 0) + if (initPatch() != 0) exit(1); if (initEeprom() != 0) @@ -494,3 +493,33 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) return _connect(sockfd, addr, addrlen); } + +/** + * Stop the game changing the DISPLAY environment variable + */ +int setenv(const char *name, const char *value, int overwrite) +{ + int (*_setenv)(const char *name, const char *value, int overwrite) = dlsym(RTLD_NEXT, "setenv"); + + if (strcmp(name, "DISPLAY") == 0) + { + return 0; + } + + return _setenv(name, value, overwrite); +} + +/** + * Stop the game unsetting the DISPLAY environment variable + */ +int unsetenv(const char *name) +{ + int (*_unsetenv)(const char *name) = dlsym(RTLD_NEXT, "unsetenv"); + + if (strcmp(name, "DISPLAY") == 0) + { + return 0; + } + + return _unsetenv(name); +} \ No newline at end of file