Files
Triforce-Source/host/hos_report_run.c
ruckus7382sfgsgdf 4fa4f9188b Triforce v0.8.0
Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
2026-11-25 10:21:32 -06:00

64 lines
2.0 KiB
C

/* SPDX-License-Identifier: GPL-3.0-or-later */
/* (Triforce) This run's id: the log's second line (host/hos_main.c, "run_id: <id>") and every crash or unclean-end record
of the run (host/hos_crash_record.c), so the window after a crash (host/hos_crash_dialog.c) finds the run's own log and
records. Nothing else: not sent anywhere. */
#include "hos_report_run.h"
#include <stddef.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ntsecapi.h>
#else
#include <errno.h>
#include <sched.h>
#include <sys/random.h>
#endif
const char *hos_report_run_id(void) {
static char id[33] = "unknown";
static int state; /* 0: new, 1: generating, 2: immutable */
int expected = 0;
if (__atomic_compare_exchange_n(&state, &expected, 1, 0, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) {
unsigned char bytes[16];
int ok;
#ifdef _WIN32
ok = RtlGenRandom(bytes, sizeof bytes) != 0;
#else
size_t used = 0;
while (used < sizeof bytes) {
const ssize_t n = getrandom(bytes + used, sizeof bytes - used, 0);
if (n < 0 && errno == EINTR) continue;
if (n <= 0) break;
used += (size_t)n;
}
ok = used == sizeof bytes;
#endif
if (ok) {
for (size_t i = 0; i < sizeof bytes; ++i) {
id[i * 2] = "0123456789abcdef"[bytes[i] >> 4];
id[i * 2 + 1] = "0123456789abcdef"[bytes[i] & 15];
}
id[32] = 0;
}
__atomic_store_n(&state, 2, __ATOMIC_RELEASE);
} else {
while (__atomic_load_n(&state, __ATOMIC_ACQUIRE) != 2) {
#ifdef _WIN32
Sleep(0);
#else
sched_yield();
#endif
}
}
return id;
}
static int dbghelp_busy;
int hos_report_dbghelp_try(void) {
int expected = 0;
return __atomic_compare_exchange_n(&dbghelp_busy, &expected, 1, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED);
}
void hos_report_dbghelp_done(void) {
__atomic_store_n(&dbghelp_busy, 0, __ATOMIC_RELEASE);
}