Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions loader/resources/mod.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@
"name": "Expand Installed Mods List",
"description": "Make the installed mods list a single infinite scrollable list instead of having pages"
},
"hide-user-in-crashlogs": {
"type": "bool",
"default": true,
"name": "Hide Name in Crashlogs",
"description": "Replaces your username with \"<user>\" in crashlogs so you can share crashlogs without leaking your name.",
"platforms": [
"win",
"mac"
]
},
"developer-title": {
"type": "title",
"name": "Developer Settings"
Expand Down
21 changes: 19 additions & 2 deletions loader/src/internal/crashlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,23 @@ std::string crashlog::writeCrashlog(
// this could also be done by saving a loader setting or smth but eh.
(void)utils::file::writeBinary(crashlog::getCrashLogDirectory() / "last-crashed", {});

auto newInfo = std::string(info);
auto newStack = std::string(stacktrace);

#if defined(GEODE_IS_WINDOWS) || defined(GEODE_IS_MACOS)
if (Mod::get()->getSettingValue<bool>("hide-user-in-crashlogs")) {
const char* user = std::getenv("USER");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think USER is defined on windows, you might be better off using the apis provided by the os like GetUserName
(if you had objective c you could use NSUserName on mac but unfortunately you are stuck with environment variables)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mac has objc crashlog
actually why not add it as geode util
getLocalUsername

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did env variable so i could hide linux username, the winapi function just returns "steamuser"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if its not useful to expose it can be a private func

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather internal util

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do have a way to check for wine, so if you want that behavior (which makes sense to do on linux) then i'd only do it when wine is detected
also as alk said, this might be best as a proper geode util, which we definitely would want working correctly on both wine and non-wine gd

Copy link
Copy Markdown
Member

@Cvolton Cvolton Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

USER env variable is not defined on native Windows, USERNAME is (which should return the same thing as GetUserName, which means steamuser in Wine)

The current approach won't work on native Windows. Not personally sure if we should have a Geode util return the Linux username inside of Wine, I feel like getting steamuser would be more expected, though I can see that returning the Linux username would be more useful for this use case.

std::string newUser = "<user>";

// so we only replace file paths
newInfo = utils::string::replace(newInfo, fmt::format("\\{}\\", user), fmt::format("\\{}\\", newUser));
newInfo = utils::string::replace(newInfo, fmt::format("/{}/", user), fmt::format("/{}/", newUser));

newStack = utils::string::replace(newStack, fmt::format("\\{}\\", user), fmt::format("\\{}\\", newUser));
newStack = utils::string::replace(newStack, fmt::format("/{}/", user), fmt::format("/{}/", newUser));
}
#endif

Buffer file;

file.append(getDateString(false));
Expand All @@ -290,11 +307,11 @@ std::string crashlog::writeCrashlog(

// exception info
file.append("\n== Exception Information ==\n");
file.append(info);
file.append(newInfo);

// stack trace
file.append("\n== Stack Trace (the most important part) ==\n");
file.append(stacktrace);
file.append(newStack);

// registers
file.append("\n== Register States ==\n");
Expand Down
Loading