From 5d719d3e908d87009befdff48016882d3cb2740c Mon Sep 17 00:00:00 2001 From: iliana etaoin Date: Tue, 21 Feb 2023 12:09:43 -0800 Subject: [PATCH] Add magic string to the start of the `game` global The `-addresses` command-line option added in 64be99d4 helps autosplitters on platforms where VVVVVV is not built as a position-independent executable. macOS has made it increasingly difficult, or impossible, to build binaries without PIE. Adding an obvious string to search for will help tools that need to deal with versions of VVVVVV built with PIE. The bytestring to search for is `[vVvVvV]game`, followed by four null bytes (to avoid finding it in the program code section). This identifies the beginning of the game object; addresses to other objects can be figured out by relative offsets printed by `-addresses`, since ASLR can only change where the globals begin. Partially fixes #928; it may still be advisable to figure out how to explicitly disable PIE on Windows/Linux. --- desktop_version/src/Game.cpp | 2 ++ desktop_version/src/Game.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 847044da..03087fad 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -158,6 +158,8 @@ end: void Game::init(void) { + SDL_strlcpy(magic, "[vVvVvV]game", sizeof(magic)); + roomx = 0; roomy = 0; prevroomx = 0; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 6dc2517f..67cfac8e 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -132,6 +132,8 @@ struct CustomLevelStat class Game { + char magic[16]; + public: void init(void);