A PDB for forza_durango_release_final.exe, the Forza Horizon 2 build that Azimuth runs (24 Nov 2015,
TimeDateStamp 0x565501ED, SizeOfImage 0x3A18000). It carries the exe's own GUID and age, so tools accept it as
the game's real PDB, with no mismatch override.
It holds names, addresses and function sizes. It has no types, local variables or source lines.
Instead of forza_durango_release_final+0x12CC7A0 you see CollisionWorld::GetPolys+0x70.
Use it
Azimuth maps the game into azimuth.exe by hand, so the game is not a module and no tool finds this PDB on its
own: give the game a module entry first. Addresses below are as mapped at 0x140000000 (the base on Windows).
-
Crash reports and
game+0x...addresses, no debugger (tried):python lookup.py C:\path\to\pdb-folder "C:\path\to\forza_durango_release_final.exe" 0x1412CC7A0That prints
CollisionWorld::GetPolys+0x70 (size 0x4e0). -
lldb, on a platform minidump (tried), with the exe and the PDB in the current folder:
lldb -c crash-....dmp (lldb) target modules add forza_durango_release_final.exe (lldb) target modules load --file forza_durango_release_final.exe --slide 0 (lldb) image lookup -a 0x1412CC7A0 Summary: forza_durango_release_final.exe`CollisionWorld::GetPolys + 112Under Wine or Proton the game sits elsewhere: the slide is its base minus 0x140000000.
-
WinDbg (untested):
.sympath+ C:\path\to\pdb-folder,.exepath+the game'sMountfolder, then.reload /f forza_durango_release_final.exe=0x140000000,0x3A18000. -
Ghidra (tried with 12.2, headless, through the same PDB analyser the menus use): import the exe, then put the PDB beside it before auto-analysis, or use File > Load PDB File. It creates all 170,286 functions with their names in about 20 seconds. Names show spaces as
_, and a few dozen C++/CX vtable warnings are harmless. -
x64dbg (tried), attached to
azimuth.exewith the game running: in the command box,virtualmod forza_durango_release_final.exe, 140000000, 3A18000, thensymload forza_durango_release_final.exe, <path to the pdb>(add, 1if it reports a mismatch). Leave with Debug > Detach; stopping the debugger ends the game. -
IDA and other disassemblers (untested): load the PDB onto the exe file; its GUID matches.
Where the names come from
At each address the first of these wins:
names.txt: names people have worked out by hand. Add yours here (see below).- The exe's exports and imports: mostly FMOD's API, plus
__imp_...for every imported function's slot. - RTTI vtables and records: every class's vtable, as
Class::vftable', and RTTI's own records under the names the compiler gives them: ``ClassRTTI Type Descriptor',Class::RTTI Complete Object Locator'`` (what the pointer just before a vtable points at), ``Class::RTTI Class Hierarchy Descriptor'andClass::`RTTI Base Class Array'``. names-reflect.txt: the game has its own reflection system (theRTTInamespace), and about 1,000 classes register their methods and properties with it by name, each with a pointer to its code.derive.pyreads those registrations, so these are the developers' own names:Class::Method, andClass::get_PropertyandClass::set_Propertyfor a property's two accessors, with the property's type in the list as a note. An accessor is often a three-instruction function that reads or writes one field, so it also tells you where that field sits in the object._xNmeans N members share one piece of code.Class::`reflection registration'is the function that does the registering.names-found.txt: names gathered from FH2 mods' source code and research notes byharvest.py. A name only counts at a function's first byte or in a data section, never at a call site inside a function.names-lib.txtandnames-libref.txt: standard library and C runtime functions found by matching their bytes, and what those functions call (see below). Element types in these names are the test code's:std::vector<Elem16>is a vector of some 16-byte type.names-code.txt: namesderive.pyworks out from what the code does.- Constructors,
Class::Class: a function that stores vtables into its own object, base classes first, and returns the object. The last vtable it stores at the object's start is its class. A class with several constructors has several functions of that name. Of the 768 constructors the reflection code calls (so their class is known for certain), this finds 767, all with the right class. - Deleting destructors,
Class::`scalar deleting destructor': the virtual functiondeletegoes through. It calls the destructor, then frees the object if asked to. It's usually slot 0, but not in every class. - Destructors,
Class::~Class: the function a deleting destructor calls first is that class's destructor. Where only the vtable it stores is known, it's named after that, and only when no other function fits the same class, because a destructor may leave out the store of its own vtable and then looks like its base class's. - Thunks:
`vcall'{N}jumps to the virtual function at offset N in the vtable; a function named after an import (memcpy) is the jump to that import. - Deferred calls: calls into the render and audio threads are queued. The class that carries the
arguments is named after the interface and method it will call
(
CTrackPresentationDeferred::CParams1ITrackPresentationResetObjectPose), and the small function queued with it calls that method through the real object's vtable. That function isCTrackPresentationDeferred::ResetObjectPose`deferred call', and the vtable offset it uses gives the interface's slot for the method (slots-code.txt, used in step 10). The slot is only taken where the queueing class's own method sits in the same slot. - The UI library's types: AVUI keeps an
AVUI::Typeobject for each UI class, built at start-up from the class's name. The object isClass::`AVUI type', the function that builds itClass::`AVUI type initializer', and the stub that destroys it at exitClass::`AVUI type atexit destructor'. - FMOD Studio's command table: the two functions listed beside each recordable API call's name:
FMOD::Studio::System::getBank`command parser'and...`command function 2'.
- Constructors,
- "Class::Method" strings the game logs: a function gets the name when it is the only one that uses that
string. A few of these (
PartyManager::State,...::RouteType) name an enum the function prints, not the function itself. - Destructors
gen.pyfinds itself: the same shapes as above, for slot 0 only, whennames-code.txtis missing. - Shared one-line functions: the linker keeps one copy of identical functions, so every
return 0;in the game is a single function that sits in thousands of unrelated vtables. A name taken from one of its uses would be wrong for all the others, so a one-line function found in different slots of different vtables is named after what it does, whatever an earlier source called it:stub_do_nothing(in about 49,000 vtable slots),stub_return_0,stub_return_true,stub_return_arg1,stub_get_qword_at_18(returns the 8 bytes at +0x18 of its first argument),stub_call_virtual_at_98(calls the virtual function at offset 0x98 of its first argument's vtable),stub_return_float_0.5. About 215 of them. A second function that does the same thing has its address on the end. - Virtual functions named through their hierarchy: a derived class's vtable starts with its base's
slots in the same order, so when slot N has a name in one class, the function in slot N of every related
class is its version of the same method. The names come from four places:
slots.txt, hand-kept vtable layouts taken from headers (std::function's holder,shared_ptr's control block, C++/CX objects);slots-reflect.txt, the virtual methods the reflection code registers;slots-code.txt, the interface methods the deferred calls go to; and any name above that belongs to a function sitting in a vtable. So one knownUpdatenames theUpdateof every class derived from the same base.A (or B)is one body the linker merged for two slots.Name`adjustor{N}'is the small thunk a second base class's vtable holds, which moves the object pointer back by N and jumps toName. Where none of those knows a slot, a guess fromslots-guess.txtis used and marked (see "Guessed names" below). - Guessed names:
names-guess.txt, best guesses for single functions (see "Guessed names" below). - RTTI virtual functions:
Class::vfN, named after the most basic class that has the function in slot N._xNmeans N vtables share it.vfshared_...means it sits in different slots and is not one of the one-line shapes above, so it has no owner. - Catch blocks and unwind actions: a function with a
tryblock, or with objects to destroy when an exception passes through, has small pieces of code for that ("funclets") which the linker puts far away from it. The C++ exception data lists them for each function, so they are named after it:Function$catch$0,Function$dtor$0,$dtor$1and so on, numbered by address. About 89,000 of them, and 72,000 had no symbol at all. One the linker merged for several functions has no single owner and readsdtor$<address>_xNorcatch$<address>_xN, N being how many functions use it. A "Class::Method" string that only a catch block uses names the function the catch block belongs to. - Everything else:
sub_<address>, for each function in.pdataand for each function without unwind data thatderive.pysaw called, jumped to or pointed at (functions-found.txt, about 10,400 small leaf functions). Without these, an address in an unnamed function would show as the nearest name plus a big, misleading offset.
Of about 417,000 names, some 108,000 are RTTI records, 89,000 are catch blocks and unwind actions, some
79,000 are real names of code and vtables, and about 16,000 are guesses, marked ? (12,000 functions and the
catch blocks and chunks named after them); the rest are vfN and sub_ placeholders.
Guessed names
Every name above this point is one the game gives, or one that follows from what the code does. A name that
ends in ? is different: it is somebody's best guess from reading the code.
RTTI::Private::CConstructor0<class EntityModel::AICarUpgradeComponent>::Construct?
States::AdvanceIE::Enter?
AVUI::Object::operator new?
A guess is used only where no other source has a name, so a real name always wins. There are two files, and each line says why:
slots-guess.txt: what a virtual function slot of a base class is. One line names that slot in every derived class, so about 50 guesses name about 11,700 functions that wereClass::vfN. The class in such a name is certain; only the method is the guess. Most are the reflection system's helpers (Construct?,Destroy?,GetValue?,SetValue?,Invoke?,ToString?), the UI library'sGetType?andIsType?, and the state machine'sEnter?. The UI library follows WPF closely, so WPF's names are used where a slot behaves like WPF's method (MeasureOverride?,CreateInstanceCore?).names-guess.txt: single functions, starting with the ones the rest of the game calls most. Here the class can be a guess too, and two are made up because the exe has no name for them (RTTI::Value,RTTI::TypeHandle); the file says so.gen.pyadds one kind itself: a function that only returns a class'sAVUI::Typeobject isClass::GetStaticType?(about 280).
To add one, read the function (and for a slot, two or three classes' versions of it), then add a line with the
reason after a ;. To promote a guess you have confirmed, move its line to names.txt or slots.txt. To
build a PDB without guesses, rename the two files away. To drop the mark, set GUESS = "" in gen.py.
Pieces split off a function (about 22,500) are named after it: Parent$chunk1, $chunk2 and so on, by
address. Most continue the same function's code, split where its unwind state changes.
Every function in .pdata (about 170,000) has its size, so debuggers know where it ends. Small leaf functions
without a .pdata entry have a name but no size. An address in the padding after a function still shows as
that function, with an offset at or past its size: that's how debuggers pick the nearest symbol.
Add names
Add a line to names.txt: the address minus 0x140000000, then the name.
0x12CC730 CollisionWorld::GetPolys
Then rebuild. Names in names.txt beat every other source, so they also fix a wrong guess.
Rebuild it
python gen.py "C:\path\to\forza_durango_release_final.exe"
It writes out\forza_durango_release_final.pdb in about 40 seconds. It needs Python 3, Windows (for
dbghelp.dll) and llvm-pdbutil from LLVM or llvm-mingw, on PATH or named by the LLVM_PDBUTIL environment
variable.
To read the names out of the game's code again (after changing derive.py or slots.txt):
python derive.py "C:\path\to\forza_durango_release_final.exe"
That rewrites names-reflect.txt, slots-reflect.txt, slots-code.txt, names-code.txt and
functions-found.txt in about half a minute. It needs the capstone disassembler (pip install capstone). To
add a vtable layout you know, add lines to slots.txt: the slot number, then Class::Method. A layout you
have only worked out by reading the code goes in slots-guess.txt, in the same form.
To gather names from source code and notes on your own disk:
python harvest.py "C:\path\to\forza_durango_release_final.exe" report.txt C:\path\to\your\mods
That rewrites names-found.txt and writes report.txt, listing where each name came from and every address
with more than one name. The report holds your file paths, so keep it to yourself.
To keep things out of the shared list, write a harvest-private.txt beside the script (git ignores it): a line
dir <folder name> skips every folder of that name, and name <regex> drops any name that matches, such as the
name of a mod you haven't released.
Name library code
The game was built with Visual C++ 2012, compiler build 65501, with /O2 /arch:AVX (the guide's chapter 15.6 has
the evidence). Code compiled with a compiler of that same build and those flags comes out byte for byte as in the
game, apart from the addresses the linker fills in, so library functions can be found by their bytes:
cl /nologo /c /O2 /Gy /GR /EHsc /bigobj /arch:AVX /DNDEBUG stl-corpus.cpp
python libmatch.py "C:\path\to\forza_durango_release_final.exe" stl.txt stl-corpus.obj
python libmatch.py "C:\path\to\forza_durango_release_final.exe" crt.txt msvcrt.lib msvcprt.lib vccorlib.lib
python libnames.py crt.txt stl.txt
libmatch.py takes objects or libraries, masks every relocated field, and names a game function only where a
pattern matches whole, at a function's start, in no more than three places. Where a function reads its own
object's data (a string, a table), the game's bytes there must match too, which tells apart functions with the
same code. A short function with nothing to check (under 40 bytes) counts only between two surer matches from
the same object, close together. stl-corpus.cpp instantiates the containers and algorithms the game is likely
to use, for element types of common sizes. libnames.py merges the results into names-lib.txt with shorter
names. A compiler of any other build gives few or no matches.
Third-party C libraries the game links were built with their own flags. These match:
| Library | Version | Flags |
|---|---|---|
| zlib | 1.2.7 | /O1 (one function more with /GS-) |
| SQLite | 3.6.19 | /Od, SQLITE_THREADSAFE=0, built for the console (/D_DURANGO /DWINAPI_FAMILY=WINAPI_FAMILY_TV_TITLE /DWIN32_LEAN_AND_MEAN) |
Much of a library still doesn't match by its bytes, but the calls give it away. libref.py starts from the
matched functions of a C library. A matched function has its relocations in the same places in the game, so
what each one points at in the game is the symbol the object names there. From those it follows the calls
down: when a named function makes the same number of calls as the object's version, call N in the game is
call N in the object. A name found that way is kept only if the two functions are the same size (within a
tenth) with the same number of calls, and no other address got the same name.
python libref.py "C:\path\to\forza_durango_release_final.exe" sqlite3.obj deflate.obj trees.obj ...
That writes names-libref.txt: about 560 more SQLite and zlib names. Give it several builds of a library to
cover more. It's for C libraries only, where every symbol in the object is the library's own.
How the PDB is made
llvm-pdbutil yaml2pdb writes the names (as public symbols) and the sized functions (as procedures in one
module). It leaves out three things debuggers need, which gen.py adds while rewriting the PDB's MSF container:
- the exe's section headers and a section map, so section:offset pairs become addresses;
- section contributions that give each code section to that module, or dbghelp ignores the procedures;
- (in the YAML) an object-name and compiler record at the module's start, and one
void()type for every procedure, or lldb ignores the procedures; - free-block maps that read 0xFF past the last block, or dbghelp refuses the file.
