-
-
Notifications
You must be signed in to change notification settings - Fork 2
Evaluator: implement indirect offset resolution #37
Copy link
Copy link
Labels
compatibilitylibmagic compatibility and migrationlibmagic compatibility and migrationenhancementNew feature or requestNew feature or requestevaluatorRule evaluation engine and logicRule evaluation engine and logicpriority:highImportant, significant compatibility or architecture impactImportant, significant compatibility or architecture impact
Milestone
Metadata
Metadata
Assignees
Labels
compatibilitylibmagic compatibility and migrationlibmagic compatibility and migrationenhancementNew feature or requestNew feature or requestevaluatorRule evaluation engine and logicRule evaluation engine and logicpriority:highImportant, significant compatibility or architecture impactImportant, significant compatibility or architecture impact
Type
Fields
Give feedbackNo fields configured for Feature.
Summary
Implement evaluation of indirect offsets. The AST representation (
OffsetSpec::Indirect) already exists, but the evaluator returns a "not yet implemented" error atsrc/evaluator/offset.rs:159.Context
Indirect offsets are a core feature of magic files that allow pointer-chasing through binary structures. The syntax
(offset.type)reads a value at the given offset, interprets it as a pointer of the specified type, and uses the result as the actual offset for matching.Examples:
(0x3c.l)- Read a 32-bit long at offset 0x3c, use that value as the offset (PE executable header pointer)(4.s)- Read a 16-bit short at offset 4, use as offsetCurrent state: AST variant defined, evaluation stubbed with TODO.
Acceptance Criteria
resolve_offset()handlesOffsetSpec::Indirectby reading the pointer value from the buffer(offset.type)+adjustmentImpact
HIGH - Indirect offsets are critical for complex binary format detection (PE executables, compound documents, archive formats with headers pointing to content).
Files to Modify
src/evaluator/offset.rs- Implement indirect resolution (line ~159)src/evaluator/types.rs- May need to expose read functions for indirect useReferences
(0x3c.l)extensively