mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-07 08:25:41 +00:00
rdi namespace baking; cv parsing rec iterator, deduplicate oob-safe cv record iterating
This commit is contained in:
@@ -1606,3 +1606,31 @@ cv_c13_parsed_from_data(Arena *arena, String8 c13_data, String8 strtbl, COFF_Sec
|
||||
return result;
|
||||
}
|
||||
|
||||
//- rjf: record iterator
|
||||
|
||||
internal B32
|
||||
cv_rec_next(String8 data, CV_RecRangeArray *recs, B32 is_leaf, CV_RecIter *iter)
|
||||
{
|
||||
B32 result = 0;
|
||||
{
|
||||
U64 next_num = iter->num+1;
|
||||
for(;1 <= next_num && next_num <= recs->count; next_num += 1)
|
||||
{
|
||||
CV_RecRange *rec_range = &recs->ranges[next_num-1];
|
||||
U64 rec_off_first = rec_range->off + 2; // (skip 2 header bytes)
|
||||
U64 rec_off_opl = rec_range->off + rec_range->hdr.size;
|
||||
U16 kind = rec_range->hdr.kind;
|
||||
U64 header_struct_size = (is_leaf ? cv_header_struct_size_from_leaf_kind(kind) : cv_header_struct_size_from_sym_kind(kind));
|
||||
if(rec_off_opl <= data.size && rec_off_first + header_struct_size <= data.size)
|
||||
{
|
||||
result = 1;
|
||||
iter->num = next_num;
|
||||
iter->kind = kind;
|
||||
iter->struct_base = data.str + rec_off_first;
|
||||
iter->opl = data.str + rec_off_opl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -236,6 +236,18 @@ struct CV_TypeIdArray
|
||||
U64 count;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ Record Iterator
|
||||
|
||||
typedef struct CV_RecIter CV_RecIter;
|
||||
struct CV_RecIter
|
||||
{
|
||||
U64 num;
|
||||
U16 kind;
|
||||
void *struct_base;
|
||||
void *opl;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
//- Hasher
|
||||
@@ -301,5 +313,8 @@ internal CV_SymParsed * cv_sym_from_data(Arena *arena, String8 sym_data, U64 sym
|
||||
internal CV_LeafParsed * cv_leaf_from_data(Arena *arena, String8 leaf_data, CV_TypeId first);
|
||||
internal CV_C13Parsed * cv_c13_parsed_from_data(Arena *arena, String8 c13_data, String8 strtbl, COFF_SectionHeaderArray sections);
|
||||
|
||||
//- rjf: record iterator
|
||||
internal B32 cv_rec_next(String8 data, CV_RecRangeArray *recs, B32 is_leaf, CV_RecIter *iter);
|
||||
|
||||
#endif // CODEVIEW_PARSE_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user