|
102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
|
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <dttr_core.h>#include <dttr_pcdogs.h>Go to the source code of this file.
Data Structures | |
| struct | DTTR_Util_PkgVisit |
| Pointers last only for the visit unless PCDOGS documents a longer lifetime. More... | |
| struct | DTTR_Util_PkgWalkOptions |
| Walk options. Start from DTTR_Util_PkgWalk_DefaultOptions() for defaults. More... | |
| struct | DTTR_Util_PkgWalkResult |
| Non-fatal per-entry failures keep traversal moving. More... | |
Macros | |
| #define | DTTR_UTIL_API extern |
| #define | DTTR_UTIL_PKG_DEFAULT_TOC_COUNT 138u |
| Default TOC entry count when options provide neither entries nor a count. | |
| #define | DTTR_UTIL_PKG_VISIT_AS(FnSuffix, Kind, Type) |
| Define a typed accessor that returns visit->ptr only for the matching kind. | |
Typedefs | |
| typedef enum DTTR_Util_PkgWalkDomain | DTTR_Util_PkgWalkDomain |
| Bit flags for DTTR_Util_PkgWalkOptions.domains. | |
| typedef enum DTTR_Util_PkgVisitKind | DTTR_Util_PkgVisitKind |
| Values stored in DTTR_Util_PkgVisit.kind. | |
| typedef enum DTTR_Util_PkgVisitStatus | DTTR_Util_PkgVisitStatus |
| Status values reported by visits and the final walk result. | |
| typedef enum DTTR_Util_PkgVisitAction | DTTR_Util_PkgVisitAction |
| Visitor actions that steer the next walk step. | |
| typedef struct DTTR_Util_PkgVisit | DTTR_Util_PkgVisit |
| typedef DTTR_Util_PkgVisitAction(* | DTTR_Util_PkgVisitor) (const DTTR_Util_PkgVisit *visit, void *userdata) |
| Visitor called once per visit. Its return value steers traversal. | |
| typedef bool(* | DTTR_Util_PkgLoadEntryFn) (const DTTR_Core_Context *ctx, int32_t toc_index, const DTTR_PCDOGS_T_PKG_TOCEntry *entry, void *userdata, void **out_entry, size_t *out_size, DTTR_Util_PkgVisitStatus *out_status) |
| Load data for a TOC entry, reporting failures through out_status. | |
| typedef void(* | DTTR_Util_PkgFreeEntryFn) (const DTTR_Core_Context *ctx, int32_t toc_index, const DTTR_PCDOGS_T_PKG_TOCEntry *entry, void *entry_data, void *userdata) |
| Release entry data produced by the matching load callback. | |
| typedef struct DTTR_Util_PkgWalkOptions | DTTR_Util_PkgWalkOptions |
| Walk options. Start from DTTR_Util_PkgWalk_DefaultOptions() for defaults. | |
| typedef struct DTTR_Util_PkgWalkResult | DTTR_Util_PkgWalkResult |
| Non-fatal per-entry failures keep traversal moving. | |
Functions | |
| DTTR_UTIL_API DTTR_Util_PkgWalkOptions | DTTR_Util_PkgWalk_DefaultOptions () |
| Return default options covering all known domains, entry loading included. | |
| DTTR_UTIL_API DTTR_Util_PkgWalkResult | DTTR_Util_PkgWalk (const DTTR_Core_Context *ctx, const DTTR_Util_PkgWalkOptions *options, DTTR_Util_PkgVisitor visitor, void *userdata) |
| Walk live package structures and call the visitor for each visit. | |
| DTTR_UTIL_API const char * | DTTR_Util_PkgVisitStatusName (DTTR_Util_PkgVisitStatus status) |
| Return a static log-friendly name such as ok or load failed. | |
| DTTR_UTIL_PKG_VISIT_AS (LevelRuntimeData, DTTR_UTIL_PKG_VISIT_LEVEL_RUNTIME_DATA, DTTR_PCDOGS_T_Level_RuntimeData) DTTR_UTIL_PKG_VISIT_AS(MaterialEntry | |
| DTTR_PCDOGS_T_Material_Entry | DTTR_UTIL_PKG_VISIT_AS (SpriteContext, DTTR_UTIL_PKG_VISIT_SPRITE_ENTRY, DTTR_PCDOGS_T_Graphics_SpriteContext) DTTR_UTIL_PKG_VISIT_AS(CollisionShape |
Variables | |
| DTTR_UTIL_PKG_VISIT_MATERIAL_ENTRY | |
| DTTR_PCDOGS_T_Material_Entry | DTTR_UTIL_PKG_VISIT_COLLISION_SHAPE |
| #define DTTR_UTIL_API extern |
Experimental helpers for walking live package structures during reverse-engineering work.
This header is exposed through dttr_sdk.h only when DTTR_SDK_ENABLE_UNSTABLE is set. It depends on PCDOGS layouts that are still being mapped, so source and ABI details may change without notice.
Definition at line 22 of file dttr_util_pkg.h.
| #define DTTR_UTIL_PKG_DEFAULT_TOC_COUNT 138u |
Default TOC entry count when options provide neither entries nor a count.
Definition at line 30 of file dttr_util_pkg.h.
Referenced by DTTR_Util_PkgWalk_DefaultOptions(), and resolve_toc().
| #define DTTR_UTIL_PKG_VISIT_AS | ( | FnSuffix, | |
| Kind, | |||
| Type ) |
Define a typed accessor that returns visit->ptr only for the matching kind.
Definition at line 167 of file dttr_util_pkg.h.
Referenced by DTTR_UTIL_PKG_VISIT_AS(), and DTTR_UTIL_PKG_VISIT_AS().
| typedef void(* DTTR_Util_PkgFreeEntryFn) (const DTTR_Core_Context *ctx, int32_t toc_index, const DTTR_PCDOGS_T_PKG_TOCEntry *entry, void *entry_data, void *userdata) |
Release entry data produced by the matching load callback.
Definition at line 105 of file dttr_util_pkg.h.
| typedef bool(* DTTR_Util_PkgLoadEntryFn) (const DTTR_Core_Context *ctx, int32_t toc_index, const DTTR_PCDOGS_T_PKG_TOCEntry *entry, void *userdata, void **out_entry, size_t *out_size, DTTR_Util_PkgVisitStatus *out_status) |
Load data for a TOC entry, reporting failures through out_status.
Definition at line 94 of file dttr_util_pkg.h.
| typedef struct DTTR_Util_PkgVisit DTTR_Util_PkgVisit |
Definition at line 85 of file dttr_util_pkg.h.
| typedef enum DTTR_Util_PkgVisitAction DTTR_Util_PkgVisitAction |
Visitor actions that steer the next walk step.
| typedef enum DTTR_Util_PkgVisitKind DTTR_Util_PkgVisitKind |
Values stored in DTTR_Util_PkgVisit.kind.
| typedef DTTR_Util_PkgVisitAction(* DTTR_Util_PkgVisitor) (const DTTR_Util_PkgVisit *visit, void *userdata) |
Visitor called once per visit. Its return value steers traversal.
Definition at line 88 of file dttr_util_pkg.h.
| typedef enum DTTR_Util_PkgVisitStatus DTTR_Util_PkgVisitStatus |
Status values reported by visits and the final walk result.
| typedef enum DTTR_Util_PkgWalkDomain DTTR_Util_PkgWalkDomain |
Bit flags for DTTR_Util_PkgWalkOptions.domains.
| typedef struct DTTR_Util_PkgWalkOptions DTTR_Util_PkgWalkOptions |
Walk options. Start from DTTR_Util_PkgWalk_DefaultOptions() for defaults.
| typedef struct DTTR_Util_PkgWalkResult DTTR_Util_PkgWalkResult |
Non-fatal per-entry failures keep traversal moving.
Visitor actions that steer the next walk step.
| Enumerator | |
|---|---|
| DTTR_UTIL_PKG_VISIT_CONTINUE | |
| DTTR_UTIL_PKG_VISIT_RECURSE | |
| DTTR_UTIL_PKG_VISIT_LOAD_AND_RECURSE | |
| DTTR_UTIL_PKG_VISIT_SKIP_SUBTREE | |
| DTTR_UTIL_PKG_VISIT_STOP | |
Definition at line 77 of file dttr_util_pkg.h.
Values stored in DTTR_Util_PkgVisit.kind.
Definition at line 53 of file dttr_util_pkg.h.
Status values reported by visits and the final walk result.
Definition at line 66 of file dttr_util_pkg.h.
Bit flags for DTTR_Util_PkgWalkOptions.domains.
Definition at line 33 of file dttr_util_pkg.h.
| DTTR_UTIL_PKG_VISIT_AS | ( | LevelRuntimeData | , |
| DTTR_UTIL_PKG_VISIT_LEVEL_RUNTIME_DATA | , | ||
| DTTR_PCDOGS_T_Level_RuntimeData | ) |
| DTTR_PCDOGS_T_Material_Entry DTTR_UTIL_PKG_VISIT_AS | ( | SpriteContext | , |
| DTTR_UTIL_PKG_VISIT_SPRITE_ENTRY | , | ||
| DTTR_PCDOGS_T_Graphics_SpriteContext | ) |
References DTTR_UTIL_PKG_VISIT_AS, and DTTR_UTIL_PKG_VISIT_SPRITE_ENTRY.
| DTTR_UTIL_API const char * DTTR_Util_PkgVisitStatusName | ( | DTTR_Util_PkgVisitStatus | status | ) |
Return a static log-friendly name such as ok or load failed.
Definition at line 28 of file util_pkg_walk.c.
References DTTR_UTIL_PKG_STATUS_BOUNDS_INVALID, DTTR_UTIL_PKG_STATUS_DECODE_UNSUPPORTED, DTTR_UTIL_PKG_STATUS_INVALID_ARGUMENT, DTTR_UTIL_PKG_STATUS_LOAD_FAILED, DTTR_UTIL_PKG_STATUS_OK, DTTR_UTIL_PKG_STATUS_UNKNOWN_ENTRY_KIND, and DTTR_UTIL_PKG_STATUS_UNRESOLVED_SYMBOL.
| DTTR_UTIL_API DTTR_Util_PkgWalkResult DTTR_Util_PkgWalk | ( | const DTTR_Core_Context * | ctx, |
| const DTTR_Util_PkgWalkOptions * | options, | ||
| DTTR_Util_PkgVisitor | visitor, | ||
| void * | userdata ) |
Walk live package structures and call the visitor for each visit.
Definition at line 258 of file util_pkg_walk.c.
References ctx, default_free_entry(), default_load_entry(), DTTR_Util_PkgWalkOptions::domains, DTTR_UTIL_PKG_DOMAIN_TOC, DTTR_UTIL_PKG_STATUS_INVALID_ARGUMENT, DTTR_UTIL_PKG_STATUS_LOAD_FAILED, DTTR_UTIL_PKG_STATUS_OK, DTTR_UTIL_PKG_STATUS_UNRESOLVED_SYMBOL, DTTR_UTIL_PKG_VISIT_LOADED_ENTRY, DTTR_UTIL_PKG_VISIT_SKIP_SUBTREE, DTTR_UTIL_PKG_VISIT_STOP, DTTR_UTIL_PKG_VISIT_TOC_ENTRY, DTTR_UTIL_PKG_VISIT_UNSUPPORTED, DTTR_Util_PkgWalk_DefaultOptions(), emit_decode_boundary(), emit_visit(), DTTR_Util_PkgWalkOptions::free_entry, DTTR_Util_PkgWalkOptions::io_userdata, DTTR_Util_PkgWalkOptions::load_entry, DTTR_Util_PkgWalkResult::loaded_count, make_result(), make_visit(), DTTR_Util_PkgWalkOptions::max_depth, NULL, resolve_toc(), should_load(), should_recurse(), and DTTR_Util_PkgWalkResult::stopped.
| DTTR_UTIL_API DTTR_Util_PkgWalkOptions DTTR_Util_PkgWalk_DefaultOptions | ( | ) |
Return default options covering all known domains, entry loading included.
Definition at line 18 of file util_pkg_walk.c.
References DTTR_UTIL_PKG_DEFAULT_TOC_COUNT, and DTTR_UTIL_PKG_DOMAIN_ALL_KNOWN.
Referenced by DTTR_Util_PkgWalk().
| DTTR_UTIL_PKG_VISIT_COLLISION_SHAPE |
Definition at line 195 of file dttr_util_pkg.h.
| DTTR_UTIL_PKG_VISIT_MATERIAL_ENTRY |
Definition at line 184 of file dttr_util_pkg.h.