116 int image_index = -1;
127 image_index = _image_index;
199 return !(*
this == r);
305#define DLRF_UNDO_ON_FAILURE 0x1
306#define DLRF_CREATE_UNDO_POINT (0x2 | DLRF_UNDO_ON_FAILURE)
307#define DLRF_SILENT 0x4
308#define DLRF_ASK_CONFIRMATION 0x8
309#define DLRF_DEFAULT (DLRF_CREATE_UNDO_POINT)
349 TB_INTERR_OR_RETURN(0);
355 for (
const auto &ri : ris )
367 flags = DLRF_DEFAULT;
425class shared_cache_toplevel_file_t;
461 virtual std::shared_ptr<shared_cache_toplevel_file_t>
get_toplevel()
const = 0;
540 size_t *out_region_index=
nullptr,
541 bool full=
true)
const = 0;
551 bool full=
true)
const = 0;
771 const range_t &range)
const = 0;
789#define FSF_LOADED_IMAGES_ONLY 0x1
790#define FSF_CASE_INSENSITIVE 0x2
809 size_t max_count=
size_t(-1))
const = 0;
814#define FSSF_SCOPE_IMAGES 0x00
815#define FSSF_SCOPE_FILES 0x01
816#define FSSF_SCOPE_MASK 0x01
818#define FSSF_IMAGES_SCOPE_DATA_SECTIONS 0x00
819#define FSSF_IMAGES_SCOPE_ALL 0x02
820#define FSSF_IMAGES_SCOPE_MASK 0x02
822#define FSSF_FILES_INCLUDE_SYMBOLS 0x04
823#define FSSF_FILES_INCLUDE_BRANCH_MAPPINGS 0x08
824#define FSSF_FILES_INCLUDE_OTHER 0x10
826#define FSSF_CASE_INSENSITIVE 0x20
841 size_t max_count=
size_t(-1))
const = 0;
858#define MDF_ALLOW_CPU_MISMATCH 0x1
859#define MDF_ALLOW_PLATFORM_MISMATCH 0x2
872 uint32 flags=0)
const = 0;
877#define DLF_VALIDATE (1 << 0)
878#define DLF_VALIDATE_HARD (DLF_VALIDATE | (1 << 1))
879#define DLF_TOPLEVEL_INPUT_PATH (1 << 2)
880#define DLF_TOPLEVEL_DETAILS (1 << 3)
881#define DLF_TOPLEVEL (DLF_TOPLEVEL_INPUT_PATH | DLF_TOPLEVEL_DETAILS)
882#define DLF_FILES (1 << 4)
883#define DLF_MAPPINGS (1 << 5)
884#define DLF_IMAGES (1 << 6)
885#define DLF_IMAGES_DEPENDENCIES (DLF_IMAGES | (1 << 7))
886#define DLF_IMAGES_REGIONS (DLF_IMAGES | (1 << 8))
887#define DLF_ISLANDS (1 << 9)
888#define DLF_ISLANDS_REGIONS (DLF_ISLANDS | (1 << 10))
889#define DLF_GOTS (1 << 11)
890#define DLF_UNKNOWN_REGIONS (1 << 12)
891#define DLF_CACHE_DATA (1 << 13)
893#define DLF_ALL 0xFFFFFFFF
void swap(_qstring< qchar > &r)
Swap contents of two qstrings. see qvector::swap()
Definition pro.h:3198
size_t rfind(qchar c, size_t pos=0) const
Search backwards for a character in the qstring.
Definition pro.h:3459
static constexpr size_t npos
Definition pro.h:3769
size_t length(void) const
Get number of chars in this qstring (not including terminating zero)
Definition pro.h:3199
const qchar * c_str(void) const
Convert the qstring to a char *.
Definition pro.h:3246
Vector of bytes (use for dynamic memory)
Definition pro.h:3850
dscu_create_layout_req_t(const bytevec_t &_uuid, const qstring &_path, int _image_index)
Definition dscu.h:119
bool perform()
Definition dscu.h:130
dscu_req_t(code_t _code)
Definition dscu.h:100
code_t
Definition dscu.h:86
@ drc_create_layout
Definition dscu.h:88
@ drc_load_cancellation_req
Definition dscu.h:92
@ drc_unknown
Definition dscu.h:87
@ drc_get_dscu_svc
Definition dscu.h:89
bool _perform()
Definition dscu.h:103
dscu_svc_req_t()
Definition dscu.h:144
dscu_svc_t * perform()
Definition dscu.h:147
Reimplementation of vector class from STL.
Definition pro.h:2262
CASSERT(sizeof(mapping_coords_t)==sizeof(int))
qvector< symbol_match_t > symbol_match_vec_t
Definition dscu.h:396
qvector< string_match_t > string_match_vec_t
Definition dscu.h:422
qvector< region_info_t > region_info_vec_t
Definition dscu.h:273
dscu_svc_t * get_dscu_svc()
Retrieve the "shared cache services".
Definition dscu.h:166
region_type_t
Available region types. See the region_info_t documentation for more info.
Definition dscu.h:174
@ rt_unknown
A covered cache region whose content we don't (yet) identify.
Definition dscu.h:180
@ rt_invalid
Invalid.
Definition dscu.h:175
@ rt_mapping
A subcache branch mapping.
Definition dscu.h:179
@ rt_cache_data
Cache-wide named data (e.g. a linkedit subcache mapping)
Definition dscu.h:182
@ rt_header
The dyld header.
Definition dscu.h:178
@ rt_got
A Global Offset Table.
Definition dscu.h:181
@ rt_image_entity
A subset of an image (segment, section, ...)
Definition dscu.h:176
@ rt_island
A branch island.
Definition dscu.h:177
DECLARE_TYPE_AS_MOVABLE(mapping_coords_t)
qvector< mapping_coords_t > mapping_coords_vec_t
Definition dscu.h:214
std::set< int > dyldlib_set_t
Definition dscu.h:290
qvector< dependency_match_entry_t > dependency_match_entry_vec_t
Definition dscu.h:444
virtual region_type_t get_region_type(size_t region_index) const =0
Return the type of the region at region_index.
virtual bool find_symbol(symbol_match_vec_t *out, const char *needle, uint32 flags=0, size_t max_count=size_t(-1)) const =0
Find all symbols whose name contains needle, searching the cache's local symbol table and each image'...
virtual void dump_layout(uint32 flags=DLF_ALL) const =0
Dump the full cache layout to the output window.
virtual bool find_string(string_match_vec_t *out, const char *needle, uint32 flags=0, size_t max_count=size_t(-1)) const =0
Find all occurrences of needle in the cache's byte content.
virtual bool query_symbols(symbol_match_vec_t *out, const range_t &range) const =0
Find symbols from the cache's local symbol table that fall within range.
virtual depmatch_code_t match_dependencies(dependency_match_result_t *out, const char *path, uint32 flags=0) const =0
Parse the Mach-O file's load commands, and match the image dependencies to this DSC.
depmatch_code_t
Definition dscu.h:847
virtual std::string_view query_symbol(ea_t ea) const =0
Look up a single address in the local symbol table.
virtual std::string_view query_exported_symbol(ea_t ea) const =0
Look up an address in the per-image export tables.
virtual bool has_local_symbols() const =0
Whether this cache has a .symbols sidecar file.
@ dmc_cpu_mismatch
CPU architecture doesn't match the shared cache's (see MDF_ALLOW_CPU_MISMATCH)
Definition dscu.h:850
@ dmc_platform_mismatch
Platform doesn't match the shared cache's (see MDF_ALLOW_PLATFORM_MISMATCH)
Definition dscu.h:851
@ dmc_failed
Failed to satisfy the request, for misc. reasons.
Definition dscu.h:852
@ dmc_ok
Match succeeded.
Definition dscu.h:848
@ dmc_bad_file
File either not present or not a Mach-O file.
Definition dscu.h:849
int code
Definition fpro.h:88
bool ok
Definition kernwin.hpp:7410
idaman int64 pos
Definition kernwin.hpp:1398
unsigned __int64 uint64
Definition llong.hpp:13
Definitions of IDP, LDR, PLUGIN module interfaces.
bool idaapi load_and_run_plugin(const char *name, size_t arg)
Load & run a plugin.
Definition loader.hpp:805
qvector< qstring > qstrvec_t
Definition lumina.hpp:831
This is the first header included in the IDA project.
unsigned int uint32
unsigned 32 bit value
Definition pro.h:352
qvector< int > intvec_t
vector of integers
Definition pro.h:2839
uint64 asize_t
Definition pro.h:427
qvector< size_t > sizevec_t
vector of sizes
Definition pro.h:2841
short int16
signed 16 bit value
Definition pro.h:349
int64 adiff_t
Definition pro.h:428
uint64 ea_t
Definition pro.h:425
THREAD_SAFE void qswap(T &a, T &b)
Swap 2 objects of the same type using memory copies.
Definition pro.h:1728
qvector< ea_t > eavec_t
vector of addresses
Definition pro.h:2838
_qstring< char > qstring
regular string
Definition pro.h:3771
Contains the definition of range_t.
Resolution of a single address into the cache layout: the region it lives in, the mapping that backs ...
Definition dscu.h:280
uint64 file_offset
Offset within the on-disk file backing mapping.
Definition dscu.h:283
region_info_t region
Region containing the address (type=rt_invalid if not found)
Definition dscu.h:281
mapping_coords_t mapping
Mapping that backs the address.
Definition dscu.h:282
bool valid() const
Definition dscu.h:285
Report on one "load command" entry found in an external file.
Definition dscu.h:430
bool operator!=(const dependency_match_entry_t &r) const
Definition dscu.h:441
bool operator==(const dependency_match_entry_t &r) const
Definition dscu.h:435
int image_index
The image index in this DSC (-1 if not found)
Definition dscu.h:432
qstring image_name
The image name.
Definition dscu.h:431
uint32 load_command_type
Load command type. One of ACH_LC_*.
Definition dscu.h:433
The result of a dscu_svc_t::match_dependencies operation.
Definition dscu.h:449
A load request, offering the ability to be populated from previously-retrieved region_info_t,...
Definition dscu.h:297
eavec_t gots
global offset table ranges
Definition dscu.h:301
dscu_load_request_t(uint32 _flags=DLRF_DEFAULT)
Definition dscu.h:313
void add_regions(const region_info_vec_t &ris)
Definition dscu.h:353
eavec_t mappings
branch mappings
Definition dscu.h:300
uint32 flags
Definition dscu.h:311
eavec_t unknown_regions
unknown-region ranges (covered, but unidentified)
Definition dscu.h:302
bool empty() const
Definition dscu.h:370
intvec_t islands
branch island numbers
Definition dscu.h:299
void add_region(const region_info_t &ri)
Definition dscu.h:315
eavec_t cache_data
cache-wide data ranges (e.g. linkedit subcache mappings)
Definition dscu.h:303
void clear()
Definition dscu.h:359
intvec_t images
image indexes
Definition dscu.h:298
IDA's DSC API interface.
Definition dscu.h:457
virtual bool is_island_loaded(int island_index) const =0
Check whether a branch island has been loaded into the database.
virtual bool is_got_loaded(ea_t got_addr) const =0
Check whether a GOT region has been loaded.
virtual void get_files_names(qstrvec_t *out) const =0
Retrieve the names of all cache files (toplevel + subcaches).
virtual bool get_image_name(qstring *out, int image_index) const =0
Retrieve the full path of an image.
virtual bool load_cache_data(ea_t ea, uint32 flags=DLRF_DEFAULT)=0
Load a cache-wide data region (e.g.
bool is_image_loaded(const char *image_name) const
Definition dscu.h:611
mapping_coords_t get_image_mapping(const char *image_name) const
Definition dscu.h:606
virtual int get_image_index(const char *image_name) const =0
Look up an image index by full path.
virtual bool get_file_name(qstring *out, size_t file_index) const =0
Get the on-disk file name for the given file index.
virtual void get_images_names(qstrvec_t *out) const =0
Retrieve the full paths of all images in the cache.
virtual bool get_region_by_ea(region_info_t *ri, ea_t ea, size_t *out_region_index=nullptr, bool full=true) const =0
Find the region containing ea, optionally returning its index.
virtual bool load_image(int image_index, uint32 flags=DLRF_DEFAULT)=0
Load a Mach-O image from the shared cache into the database.
virtual bool get_image_regions(region_info_vec_t *out, int image_index, bool full=true) const =0
Retrieve all regions belonging to an image.
virtual ea_t get_image_address(int image_index) const =0
Return the start address of the image's Mach-O header in the cache.
virtual uint64 get_image_total_size(int image_index) const =0
Return the total size of all regions that compose this image.
virtual void get_regions(region_info_vec_t *vout, const sizevec_t *region_indexes=nullptr, bool full=true) const =0
Retrieve a batch of regions.
virtual int get_images_count() const =0
Return the number of images in the cache.
virtual std::shared_ptr< shared_cache_toplevel_file_t > get_toplevel() const =0
Return the parsed toplevel shared cache file.
virtual bool load_branch_mapping(ea_t ea, uint32 flags=DLRF_DEFAULT)=0
Load a branch mapping (__stubs) region into the database.
virtual bool is_cache_data_loaded(ea_t cache_data_addr) const =0
Check whether a cache-wide data region has been loaded.
virtual size_t get_file_index(const char *file_name) const =0
Look up a file index by name.
virtual size_t get_image_file_index(int image_index) const =0
Return the file index of the cache file that contains the image.
virtual address_info_t locate_address(ea_t ea) const =0
Resolve ea into the cache layout: the region it lives in, the mapping that backs it,...
virtual mapping_coords_t get_image_mapping(int image_index) const =0
Return the mapping coordinates for an image.
virtual bool load_got(ea_t ea, uint32 flags=DLRF_DEFAULT)=0
Load a GOT region into the database.
bool get_image_file_name(qstring *out, const char *image_name) const
Definition dscu.h:618
bool get_image_filename(qstring *out, int image_index) const
Like get_image_name(), but returns only the filename component (everything after the last '/').
Definition dscu.h:586
virtual void update_dyld_slide(adiff_t delta)=0
Apply an additional slide delta and reload the cache.
size_t get_image_file_index(const char *image_name) const
Definition dscu.h:659
uint64 get_image_total_size(const char *image_name) const
Definition dscu.h:653
virtual bool load_regions(const dscu_load_request_t ®ions)=0
Load all regions described by the request (images, islands, mappings, GOTs, unknown_regions,...
virtual bool is_mapping_loaded(ea_t mapping_addr) const =0
Check whether a branch mapping has been loaded.
virtual bool is_image_loaded(int image_index) const =0
Check whether an image has been loaded into the database.
virtual bool get_input_file_path(qstring *out) const =0
Retrieve the path to the dyld_shared_cache file on disk.
bool get_image_dependencies(intvec_t *out, const char *image_name, int depth=1) const
Definition dscu.h:642
virtual bool get_image_dependencies(intvec_t *out, int image_index, int depth=1) const =0
Collect transitive dependencies of an image.
virtual bool get_region(region_info_t *ri, size_t region_index, bool full=true) const =0
Retrieve region info by index.
virtual bool get_file_mappings(mapping_coords_vec_t *out, const char *file_name) const =0
Return all mapping coordinates for the given cache file.
bool get_image_regions(region_info_vec_t *out, const char *image_name, bool full=true) const
Definition dscu.h:626
virtual ~dscu_svc_t()
Definition dscu.h:458
virtual bool get_image_file_name(qstring *out, int image_index) const =0
Return the on-disk cache file name that contains the image.
virtual bool is_unknown_region_loaded(ea_t ea) const =0
Check whether an unknown region has been loaded.
virtual bool get_images_dependencies(intvec_t *out, const intvec_t &images_indexes, int depth=1) const =0
Like get_image_dependencies(), but for multiple images at once.
virtual bool get_image_regions_indexes(sizevec_t *out, int image_index) const =0
Retrieve the region indexes (into the global region list) for an image.
virtual bool load_unknown_region(ea_t ea, uint32 flags=DLRF_DEFAULT)=0
Load an unknown region (a covered-but-unidentified range of a mapping) into the database.
bool get_image_regions_indexes(sizevec_t *out, const char *image_name) const
Definition dscu.h:633
virtual bool get_mapping_range(range_t *out, mapping_coords_t mapping) const =0
Return the address range covered by a mapping.
virtual adiff_t get_dyld_slide() const =0
Return the cumulative ASLR slide applied to the cache.
virtual bool load_island(int island_index, uint32 flags=DLRF_DEFAULT)=0
Load a branch island from the shared cache into the database.
virtual int get_load_regions_requests_count() const =0
Return the number of times load_regions() has been invoked successfully.
An "intermediate" partioning of file(s) participating in the DSC.
Definition dscu.h:188
int16 mapping_index
the toplevel/subcache to which mapping_index applies. 0 means toplevel file
Definition dscu.h:190
int16 file_index
Definition dscu.h:189
bool valid() const
Definition dscu.h:202
bool operator!=(const mapping_coords_t &r) const
Definition dscu.h:197
bool operator==(const mapping_coords_t &r) const
the mapping # inside that file
Definition dscu.h:192
static mapping_coords_t make_invalid()
Definition dscu.h:204
Base class for an range.
Definition range.hpp:35
Address ranges that can be loaded into the database.
Definition dscu.h:234
region_type_t type
Size in bytes.
Definition dscu.h:238
int image_index
Definition dscu.h:243
bool operator==(const region_info_t &r) const
Definition dscu.h:261
void swap(region_info_t &r)
region name (e.g., __text). Not unique
Definition dscu.h:250
int branch_island_number
for rt_image
Definition dscu.h:244
range_t get_range() const
Definition dscu.h:259
ea_t start
Definition dscu.h:235
asize_t size
Coordinates in address space.
Definition dscu.h:236
char name[40]
Definition dscu.h:247
bool operator!=(const region_info_t &r) const
Definition dscu.h:269
A string-literal match produced by dscu_svc_t::find_string().
Definition dscu.h:401
ea_t ea
Mapped address; BADADDR for non-image hits.
Definition dscu.h:402
bool operator!=(const string_match_t &r) const
Definition dscu.h:419
uint64 file_offset
Offset within that file (when image_index == -1)
Definition dscu.h:408
bool operator==(const string_match_t &r) const
Definition dscu.h:411
int image_index
Owning image index, or -1 if the hit came from a non-image blob (.symbols, branch mappings,...
Definition dscu.h:403
qstring context
Bytes around the match, for display.
Definition dscu.h:409
size_t file_index
When image_index == -1: the file the hit lives in (see get_file_name()).
Definition dscu.h:406
A symbol match produced by dscu_svc_t::find_symbol() / query_symbols().
Definition dscu.h:384
bool operator==(const symbol_match_t &r) const
Definition dscu.h:389
bool operator!=(const symbol_match_t &r) const
Definition dscu.h:393
int image_index
Owning image index, or -1 if the symbol came from the cache's local symbol table (....
Definition dscu.h:387
std::string_view symbol
Matching symbol name; the view is valid for the lifetime of the dscu_svc_t.
Definition dscu.h:385
ea_t ea
Address of the symbol.
Definition dscu.h:386