Dynamic trace for the loading-tip cycle function
The static RE pass narrowed the candidate function to a small set of
VMAs in 0x141174xxx (loading-screen construction) and a few call
targets. To confirm which one is the per-frame tip cycler, we use
hardware breakpoints to observe the running eu4.exe.
Why
Manual RE of a 38 MB binary without symbols is slow. The cycle
function is not the 0x141174F50 setup function (which runs only
once). The per-frame update is somewhere else, calling the same
findChildByName / setText virtuals, but with a Timer. Hardware
breakpoints on the candidates and a hit counter tell us which one
fires most often during the loading screen.
Tool
bin/trace_tip_cycle.exe (built with x86_64-w64-mingw32-gcc,
MinGW-w64 GCC 15.2.0). It:
- Finds the
eu4.exePID. - Opens the main thread.
- Sets
DR0–DR3hardware-execute breakpoints on the first 4 candidate VMAs. - Calls
DebugActiveProcessto attach as a debugger. - Loops on
WaitForDebugEvent, logs everyEXCEPTION_SINGLE_STEPwhoseExceptionAddressmatches a candidate, and re-arms all 4 breakpoints (Windows clears them on exception). - Exits after 10000 hits or 5 minutes, whichever comes first.
The hit log is written to trace_log.txt next to the .exe.
Candidates currently traced
| VMA | Source |
|---|---|
0x141174F50 |
load_screen_setup (static RE confirmed, runs once) |
0x141174840 |
status_updater (spinner — confirmed fires every frame) |
0x141175110 |
status_lookup (helper, may or may not be per-frame) |
0x14117AD80 |
call target — likely the GUI addChild path |
| (12 more) | See src/trace_tip_cycle.cpp for the full list |
Only the first 4 fit in the 4 HW debug registers. If the cycle function is one of the others, expand the candidate list and re-build.
How to run
- Launch EU4 through Steam. (Or directly:
"C:\Program Files (x86)\Steam\steamapps\common\Europa Universalis IV\eu4.exe".) - Trigger a loading screen — start a new campaign, or load a save. The loading screen must be on-screen for the tip cycler to run.
- In a second shell, run the tracer:
cd tools/loading_tip_patcher ./bin/trace_tip_cycle.exe - Wait 30–120 s for the loading to finish and the tracer to record enough hits.
- Open
trace_log.txt. The VMA with the highest hit count is the per-frame tip cycle function. Compare with the candidate list to identify the exact symbol we should patch.
Expected output (illustrative)
[trace] target PID 12345, main thread TID 12350
[trace] HW breakpoints set on first 4 candidates
[trace] Waiting for exceptions. Run the loading screen NOW.
[hit] #1 vma=0x141174840 count=1 prev_rip=0x141174812 +dt=12us
[hit] #1 vma=0x141174840 count=2 prev_rip=0x141174812 +dt=16543us
[hit] #1 vma=0x141174840 count=3 prev_rip=0x141174812 +dt=16601us
[hit] #0 vma=0x141174f50 count=1 prev_rip=0x141174e9f +dt=8us
[hit] #1 vma=0x141174840 count=4 prev_rip=0x141174812 +dt=16572us
...
The expected pattern: 0x141174840 (status updater / spinner)
fires 30 times per second while the loading screen is up. If a
new VMA fires every few seconds (8 s interval), that is the
tip cycle function.
After the trace
- Identify the new VMA from the log.
- Add it to the static-RE notes in
RE_notes.md. - Add a
candidates[]entry insrc/trace_tip_cycle.cppandsrc/main.cpp(with a TODO marker for the actual byte-pattern patch). - Re-run with the new candidate list if necessary.
Caveats
DebugActiveProcesswill freeze the target until the trace loop is running. If you set the breakpoint and then close the tracer, the target will be left in a frozen state. Killeu4.exewith Task Manager to recover.- x64 Windows only allows 4 HW execute breakpoints. The 5th and later candidates in the list will not fire. If the cycle function isn't in the first 4, you must narrow the list and re-run.
- The tracer is not stealthy — Paradox's anti-cheat (if it
runs in
eu4.exe) will likely detectDebugActiveProcesson the same process. Don't use this on an ironman / multiplayer session.