mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-18 01:37:05 +02:00
Players reported the game hanging for about a second while skating. A profile showed the memory line in the log walking every heap (HeapSummary) on the client thread, 0.5 to 2 s every two minutes. An audit of everything that runs on the game's update and render threads found more of the same, and Sentry's top crashes had causes of ours. Freezes: - Memory log line: no heap walk or thread snapshot; the GPU part and the write happen on a thread of their own. - Profile database: synchronous=NORMAL in WAL mode. A save is still kept when the game crashes; every play event no longer waits for the disk inside the game's hooks. - ReSkate's own preferences and values (menu clicks, session sliders, Discord) are saved by a background writer in order; reads see a value until it is saved. - Input: the foreground window and the keyboard are sampled on a thread of their own (GetAncestor and GetAsyncKeyState stalled the client tick 40-50 ms when another program held Windows' lock); flight input uses the sample; ClipCursor at most twice a second while a menu has the pointer. - Hooks installed while the game runs go in one transaction per place (HookBatch): throwdowns, remote players, the party, Hall of Meat. - Off the update thread: the host's map package lookup (one table read in the background, not the Mods folder per offer), the trainer's map file and settings save, Board Break's settings save, mod music playlists and their covers, the Spotify station covers. - Off the render thread: the Modding page's and the deck card's Mods folder reads. The overlay's three startup waits share five seconds. - Less work per frame: Steam names reused while one a frame is asked again, 2 friends a tick, steam_api64.dll checked once per process, cosmetic names read in place rather than a system call per character, an outfit load no longer copies the inventory per slot, the throwdown type scan runs at background priority over resident memory, the Board Break deck label is kept a minute. Crashes: - Render-resource pool: the metadata fields are written to the state owner only. The other renderer is 0x2daa00 bytes, and +0x11aae28 is far past its end (store_field crash; heap corruption in every release). - Other players' skateboard effects: a stale skateboard component is no longer followed, and the joint lookup is walked with a bound first (an endless loop in reused memory ended in GameStall). - Launcher: Oodle decodes into the buffer it asks for with corrupt data possible, and its assertions no longer stop the process (heap corruption in the store-copy scan; a breakpoint in oo2core). Timings (Send performance timings): - A frame of half a second or more in a level is sent as game.freeze: where the time went (ReSkate's tick, the game's frame, or outside it), whether the renderer kept presenting, and ReSkate's busiest zones. - Closing the game sends the level session it was in. Music after a connection drop: - Spotify device: an account Spotify could not be reached with is kept and tried again (3 s doubling to a minute); a session that drops is taken up again. Only an account Spotify refuses is asked for anew. - YouTube playlist pictures that could not be fetched are tried again, from 30 s to 10 minutes apart.
56 lines
2.4 KiB
C++
56 lines
2.4 KiB
C++
#pragma once
|
|
#include <Windows.h>
|
|
#include <cstddef>
|
|
|
|
namespace dingosdk {
|
|
// Win32 failures from Detours are preserved; negative values describe the
|
|
// SDK-owned lifecycle. No vendor status codes escape through feature code.
|
|
enum HookStatus : LONG {
|
|
HookOk = NO_ERROR,
|
|
HookNotInitialized = -1,
|
|
HookAlreadyInitialized = -2,
|
|
HookAlreadyPrepared = -3,
|
|
HookDisabled = -4,
|
|
HookNotFound = -5,
|
|
HookNotExecutable = -6,
|
|
HookOutOfMemory = ERROR_NOT_ENOUGH_MEMORY,
|
|
HookProtectionFailed = ERROR_ACCESS_DENIED,
|
|
HookUnsupportedFunction = ERROR_INVALID_BLOCK,
|
|
};
|
|
|
|
// A prepared original is a permanent x64 relay. Detours changes its pointer
|
|
// transactionally, so originals published into atomics or retained by native
|
|
// callbacks stay callable before attach and after detach. Only Detours performs
|
|
// instruction relocation and target patching. Preparation never patches target.
|
|
HookStatus WINAPI hook_initialize();
|
|
// original may be null when the replacement never forwards to the target.
|
|
HookStatus WINAPI hook_prepare(void* target, void* replacement, void** original = nullptr);
|
|
HookStatus WINAPI hook_enable(void* target);
|
|
HookStatus WINAPI hook_disable(void* target);
|
|
HookStatus WINAPI hook_remove(void* target);
|
|
HookStatus WINAPI hook_queue_enable(void* target);
|
|
HookStatus WINAPI hook_apply_queued();
|
|
// While one is alive on a thread, hook_enable on that thread only queues the hook (and answers
|
|
// HookOk); the outermost one, as it ends, attaches all of them in one transaction. Each
|
|
// transaction lists every thread on the system and suspends every one of the game's, a few
|
|
// milliseconds each, so installs made while the game runs are grouped: on the client thread,
|
|
// a frame paid for each of them (2026-10-15). A hook that then fails to attach stays detached,
|
|
// as a failed hook_enable leaves it.
|
|
class HookBatch {
|
|
public:
|
|
HookBatch() noexcept;
|
|
~HookBatch();
|
|
HookBatch(const HookBatch&) = delete;
|
|
HookBatch& operator=(const HookBatch&) = delete;
|
|
};
|
|
HookStatus WINAPI hook_shutdown();
|
|
const char* WINAPI hook_status_string(HookStatus status);
|
|
// Captured on the calling thread; formatting/logging happens only after Detours
|
|
// has resumed enlisted threads. Read before issuing another hook operation.
|
|
struct HookFailure { const char* operation{"none"}; LONG error{}; DWORD thread_id{}; };
|
|
HookFailure hook_last_failure() noexcept;
|
|
|
|
struct HookStatistics { std::size_t prepared{}, attached{}, retired{}; };
|
|
HookStatistics hook_statistics();
|
|
}
|