@@ -202,6 +202,7 @@ typedef struct _YR_META
202202} YR_META ;
203203
204204
205+ struct _YR_RULE ;
205206struct _YR_MATCH ;
206207
207208
@@ -223,6 +224,7 @@ typedef struct _YR_STRING
223224 DECLARE_REFERENCE (char * , identifier );
224225 DECLARE_REFERENCE (uint8_t * , string );
225226 DECLARE_REFERENCE (struct _YR_STRING * , chained_to );
227+ DECLARE_REFERENCE (struct _YR_RULE * , rule );
226228
227229 int32_t chain_gap_min ;
228230 int32_t chain_gap_max ;
@@ -481,8 +483,8 @@ typedef struct _YR_AC_AUTOMATON
481483} YR_AC_AUTOMATON ;
482484
483485
484- typedef struct _YR_RULES {
485-
486+ typedef struct _YR_RULES
487+ {
486488 unsigned char tidx_mask [YR_BITARRAY_NCHARS (MAX_THREADS )];
487489 const uint8_t * code_start ;
488490
@@ -538,30 +540,60 @@ typedef int (*YR_CALLBACK_FUNC)(
538540
539541typedef struct _YR_SCAN_CONTEXT
540542{
543+ // File size of the file being scanned.
541544 uint64_t file_size ;
545+
546+ // Entry point of the file being scanned, if the file is PE or ELF.
542547 uint64_t entry_point ;
543548
549+ // Scanning flags.
544550 int flags ;
551+
552+ // Thread index for the thread using this scan context. The number of threads
553+ // that can use a YR_RULES object simultaneusly is limited by the MAX_THREADS
554+ // constant. Each thread using a YR_RULES get assigned a unique thread index
555+ // in the range [0, MAX_THREADS)
545556 int tidx ;
557+
558+ // Scan timeout in seconds.
546559 int timeout ;
547560
561+ // Pointer to user-provided data passed to the callback function.
548562 void * user_data ;
549563
564+ // Pointer to the user-provided callback function that is called when an
565+ // event occurs during the scan (a rule matching, a module being loaded, etc)
566+ YR_CALLBACK_FUNC callback ;
567+
568+ // Pointer to the YR_RULES object associated to this scan context.
550569 YR_RULES * rules ;
570+
571+ // Pointer to the YR_STRING causing the most recent scan error.
572+ YR_STRING * last_error_string ;
573+
574+ // Pointer to the iterator used for scanning
551575 YR_MEMORY_BLOCK_ITERATOR * iterator ;
576+
577+ // Pointer to a table mapping identifiers to YR_OBJECT structures. This table
578+ // contains entries for external variables and modules.
552579 YR_HASH_TABLE * objects_table ;
553- YR_CALLBACK_FUNC callback ;
554580
581+ // Arena used for storing YR_MATCH structures asociated to the matches found.
555582 YR_ARENA * matches_arena ;
583+
584+ // Arena used for storing pointers to the YR_STRING struct for each matching
585+ // string. The pointers are used by _yr_scanner_clean_matches.
556586 YR_ARENA * matching_strings_arena ;
557587
588+ // Fiber pool used by yr_re_exec.
558589 RE_FIBER_POOL re_fiber_pool ;
559590
560591} YR_SCAN_CONTEXT ;
561592
562593
563594struct _YR_OBJECT ;
564595
596+
565597typedef union _YR_VALUE
566598{
567599 int64_t i ;
0 commit comments