1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
//! dotscope prelude for convenient .NET assembly analysis.
//!
//! The dotscope prelude provides convenient access to the most commonly used types, traits,
//! and functions for .NET assembly analysis. This module serves as a one-stop import for
//! typical dotscope usage patterns, reducing the need for multiple individual imports and
//! providing immediate access to essential functionality.
//!
//! # Architecture
//!
//! The prelude is organized into logical groups covering all major aspects of .NET metadata analysis,
//! from high-level assembly loading to low-level metadata table access. This organization follows
//! the typical workflow of .NET assembly analysis applications.
//!
//! ## Core Components
//!
//! - **Entry Points**: [`crate::CilObject`], [`crate::File`], [`crate::Parser`] - Main interfaces for assembly loading
//! - **Type System**: [`crate::metadata::typesystem::CilType`], [`crate::metadata::typesystem::TypeRegistry`] - Complete type representation
//! - **Metadata Access**: Table types, stream access, and token-based navigation
//! - **Analysis Tools**: Disassembler, method body parsing, signature analysis
//! - **Error Handling**: [`crate::Error`], [`crate::Result`] - Comprehensive error management
//!
//! # Key Components
//!
//! ## Organized Import Groups
//!
//! - **Core Types**: Error handling, results, and main entry points
//! - **Type System**: Complete type representation and resolution
//! - **Metadata Tables**: High-level and raw table access
//! - **Signatures**: Type and method signature parsing
//! - **Method Analysis**: IL disassembly and method body analysis
//! - **Import/Export**: Assembly dependency analysis
//! - **Streams and Headers**: Low-level metadata structure access
//! - **Constants**: Element types, attributes, and metadata identifiers
//!
//! # Usage Examples
//!
//! ## Basic Assembly Analysis
//!
//! ```rust,no_run
//! use dotscope::prelude::*;
//!
//! // Core functionality immediately available
//! let assembly = CilObject::from_path("example.dll")?;
//! let types = assembly.types();
//!
//! // Type system components
//! for entry in types.iter() {
//! let cil_type = entry.value();
//! match cil_type.flavor() {
//! CilFlavor::Class => println!("Class: {}.{}", cil_type.namespace, cil_type.name),
//! CilFlavor::Interface => println!("Interface: {}.{}", cil_type.namespace, cil_type.name),
//! _ => {}
//! }
//! }
//! # Ok::<(), dotscope::Error>(())
//! ```
//!
//! ## Method Analysis and Disassembly
//!
//! ```rust,no_run
//! use dotscope::prelude::*;
//!
//! let assembly = CilObject::from_path("example.dll")?;
//! let methods = assembly.methods();
//!
//! for entry in methods.iter() {
//! let method = entry.value();
//! if let Some(body) = method.body.get() {
//! if body.size_code > 0 {
//! println!("Method {} has {} bytes of IL", method.name, body.size_code);
//! println!(" Max stack: {}", body.max_stack);
//!
//! // Access disassembled instructions through blocks
//! for (block_id, block) in method.blocks() {
//! println!(" Block {}: {} instructions", block_id, block.instructions.len());
//! }
//! }
//! }
//! }
//! # Ok::<(), dotscope::Error>(())
//! ```
//!
//! ## CIL Instruction Assembly
//!
//! ```rust,no_run
//! use dotscope::prelude::*;
//!
//! // High-level fluent API for common instruction patterns
//! let mut assembler = InstructionAssembler::new();
//! assembler
//! .ldarg_0()? // Load first argument
//! .ldarg_1()? // Load second argument
//! .add()? // Add them
//! .ret()?; // Return result
//! let (bytecode, max_stack, handlers) = assembler.finish()?;
//!
//! // Low-level encoder for any CIL instruction
//! let mut encoder = InstructionEncoder::new();
//! encoder.emit_instruction("ldarg.0", None)?;
//! encoder.emit_instruction("ldc.i4.s", Some(Operand::Immediate(Immediate::Int8(42))))?;
//! encoder.emit_instruction("ret", None)?;
//! let bytecode2 = encoder.finalize()?;
//!
//! // Label resolution and control flow
//! let mut asm = InstructionAssembler::new();
//! asm.ldarg_0()?
//! .brfalse_s("false_case")?
//! .ldc_i4_1()?
//! .br_s("end")?
//! .label("false_case")?
//! .ldc_i4_0()?
//! .label("end")?
//! .ret()?;
//! let (conditional_bytecode, _, _) = asm.finish()?;
//! # Ok::<(), dotscope::Error>(())
//! ```
//!
//! ## Metadata Table Access
//!
//! ```rust,no_run
//! use dotscope::prelude::*;
//!
//! let assembly = CilObject::from_path("example.dll")?;
//!
//! // High-level table access
//! if let Some(assembly_info) = assembly.assembly() {
//! println!("Assembly: {}", assembly_info.name);
//! println!("Version: {}.{}.{}.{}",
//! assembly_info.major_version, assembly_info.minor_version,
//! assembly_info.build_number, assembly_info.revision_number);
//! }
//!
//! // Token-based navigation
//! let typedef_token = Token::new(0x02000001);
//! if let Some(tables) = assembly.tables() {
//! if let Some(typedef_table) = tables.table::<TypeDefRaw>() {
//! let row_index = typedef_token.row();
//! if let Some(typedef) = typedef_table.get(row_index) {
//! println!("Type name index: {}", typedef.type_name);
//! }
//! }
//! }
//! # Ok::<(), dotscope::Error>(())
//! ```
//!
//!
//! # Import Organization
//!
//! The prelude is organized into logical sections for easy navigation:
//!
//! 1. **Core Types**: Essential error handling and configuration
//! 2. **Entry Points**: Main interfaces for assembly loading and parsing
//! 3. **Type System**: Complete .NET type representation and resolution
//! 4. **Metadata Tables**: Both high-level and raw table access
//! 5. **Signatures**: Type and method signature parsing
//! 6. **Method Analysis**: IL analysis and method body parsing
//! 7. **Disassembler**: CIL instruction decoding and control flow
//! 8. **Import/Export**: Assembly dependency analysis
//! 9. **Streams and Headers**: Metadata storage structure access
//! 10. **Constants**: Type system and marshalling constants
//!
//! # Thread Safety
//!
//! Most types in the prelude are either `Send + Sync` or use interior mutability
//! for thread-safe access. Reference-counted types ([`crate::metadata::typesystem::CilTypeRc`], [`crate::metadata::method::MethodRc`], etc.)
//! enable safe sharing across threads without performance penalties.
//!
//! # Standards Compliance
//!
//! - **ECMA-335**: Full compliance with .NET metadata specification
//! - **Type Safety**: Strong typing throughout the API surface
//! - **Memory Safety**: No unsafe code in public interfaces
//! - **Performance**: Zero-cost abstractions and efficient data structures
// ================================================================================================
// Core Types and Error Handling
// ================================================================================================
//
// This section provides the fundamental types for dotscope error handling and configuration.
// These are typically needed in any dotscope application for proper error management and
// assembly loading configuration.
/// The main error type for all dotscope operations.
///
/// Covers parsing errors, type resolution failures, IL validation issues, and I/O problems.
/// Provides detailed error context for debugging and user-friendly error messages.
pub use crateError;
/// The result type used throughout dotscope APIs.
///
/// Standard `Result<T, Error>` type alias for consistent error handling across the library.
/// Most dotscope operations return this type for uniform error propagation.
pub use crateResult;
/// Configuration for metadata validation during assembly loading.
///
/// Controls validation strictness, error handling behavior, and performance trade-offs
/// during metadata parsing and type system construction.
pub use crateValidationConfig;
/// Diagnostics collection for assembly loading anomalies.
///
/// Thread-safe container for collecting warnings and errors during assembly loading.
/// Essential for lenient loading of obfuscated or malformed assemblies where issues
/// should be reported but not prevent loading from completing.
pub use crate;
// ================================================================================================
// Main Entry Points
// ================================================================================================
//
// Primary interfaces for loading and analyzing .NET assemblies. These types provide the
// main entry points into dotscope functionality, from high-level assembly analysis to
// low-level file parsing operations.
/// Main entry point for .NET assembly analysis.
///
/// `CilObject` provides high-level access to .NET assembly metadata, type systems,
/// method bodies, and disassembly capabilities. This is typically the starting point
/// for most dotscope applications.
pub use crateCilObject;
/// Raw assembly view for editing and modification operations.
///
/// `CilAssemblyView` provides direct access to .NET assembly metadata structures
/// while maintaining a 1:1 mapping with the underlying file format. Designed as
/// the foundation for future editing and modification capabilities.
pub use crateCilAssemblyView;
/// Low-level file parsing utilities.
///
/// `File` and `Parser` provide direct access to raw PE file structure and metadata
/// parsing operations. Used for custom parsing scenarios or when fine-grained control
/// over the parsing process is required.
pub use crate::;
// ================================================================================================
// Metadata System - Core Types
// ================================================================================================
//
// Essential metadata system components for working with .NET metadata tables, tokens,
// and basic metadata structures. These types form the foundation for all metadata
// operations and table navigation.
/// Metadata token type for referencing table entries.
///
/// Tokens are 32-bit identifiers that uniquely reference rows in metadata tables.
/// They encode both the table type and row index, enabling efficient cross-table
/// references throughout the metadata system.
pub use crateToken;
/// Metadata root constants.
///
/// Magic numbers and signature constants used in .NET metadata headers for format
/// validation and version identification.
pub use crateCIL_HEADER_MAGIC;
/// Import types for external references.
///
/// Classification of different import mechanisms used by .NET assemblies for
/// referencing external types, methods, and resources.
pub use crateImportType;
// ================================================================================================
// Type System
// ================================================================================================
//
// Complete .NET type system representation including type definitions, references,
// primitives, and resolution mechanisms. This is the core of dotscope's type analysis
// capabilities, providing unified access to all .NET type constructs.
/// Composable query builders for filtering types and methods.
///
/// `TypeQuery` and `MethodQuery` provide a fluent API for searching and filtering
/// types and methods in .NET assemblies without manual iteration boilerplate.
pub use crate;
/// Core type system components.
///
/// Includes type representations (`CilType`), primitive types (`CilPrimitive`),
/// type registries (`TypeRegistry`), resolution (`TypeResolver`), and all supporting
/// types for comprehensive .NET type system analysis.
pub use crate;
// ================================================================================================
// Metadata Streams and Tables - High-Level Types
// ================================================================================================
//
// This section provides high-level, safe wrappers around metadata tables. These types
// include reference counting, validation, and convenient accessor methods. They are the
// recommended interface for most metadata operations, providing safety and ease of use
// over raw table access.
/// Assembly and module information.
///
/// Core assembly metadata including version info, culture, public keys, and module definitions.
/// These types provide the foundation for assembly identity and module organization.
pub use crate;
/// Type definitions and references.
///
/// Types for working with exported types and type resolution across assembly boundaries.
/// Essential for analyzing type dependencies and assembly composition.
pub use crate;
/// Fields and field-related types.
///
/// Complete field metadata including layout information, RVA data, and pointer tables.
/// Also includes method pointer types for efficient method table navigation.
pub use crate;
/// Parameters.
///
/// Method parameter metadata including attributes, default values, and marshalling information.
/// Essential for method signature analysis and parameter validation.
pub use crate;
/// Properties and events.
///
/// Property and event metadata including accessors, modifiers, and event handlers.
/// Core components for analyzing .NET type members and their behaviors.
pub use crate;
/// Interfaces and member references.
///
/// Interface implementation tracking and cross-assembly member references.
/// Critical for understanding type relationships and external dependencies.
pub use crate;
/// Generic types and constraints.
///
/// Generic parameter definitions, constraints, and method specializations.
/// Essential for analyzing generic types and their instantiation constraints.
pub use crate;
/// Security and custom attributes.
///
/// Security declarations and custom attribute metadata.
/// Important for analyzing assembly security policies and annotation information.
pub use crate;
/// .NET Code Access Security (CAS) implementation.
///
/// Complete support for parsing and representing .NET Code Access Security permissions,
/// permission sets, and security actions. Essential for analyzing legacy .NET Framework
/// assemblies that use declarative security attributes and CAS policies.
pub use crate;
/// Files and resources.
///
/// File references and manifest resources embedded in or referenced by the assembly.
/// Essential for analyzing resource dependencies and multi-file assemblies.
pub use crate;
/// Resource parsing with owned and zero-copy semantics.
///
/// Parse .NET resource files with both owned and zero-copy variants for flexible resource access.
/// The zero-copy variant (`parse_dotnet_resource_ref`, `ResourceEntryRef`, `ResourceTypeRef`) borrows
/// string and byte array data directly from the source buffer without allocation, enabling efficient
/// handling of large embedded resources (e.g., ZIP archives) that could be hundreds of megabytes or
/// gigabytes. The owned variant (`parse_dotnet_resource`, `ResourceEntry`, `ResourceType`) provides
/// traditional owned data for scenarios where borrowed data is inconvenient. Essential for
/// memory-mapped files and memory-critical scenarios.
pub use crate;
/// Standalone signatures.
///
/// Independent signature definitions used for indirect calls and marshalling scenarios.
pub use crate;
// ================================================================================================
// Portable PDB Debug Information Tables
// ================================================================================================
//
// This section provides access to Portable PDB format debug information tables. These tables
// enable rich debugging experiences with source line mapping, local variable information,
// scope tracking, and custom debug data. Essential for debugger integration and development
// tool support.
/// Document and source file information.
///
/// Document table entries provide information about source files referenced in debug information,
/// including file names, language identifiers, hash algorithms, and source content.
pub use crate;
/// Method debugging information.
///
/// Links methods to their sequence points for source code mapping and debugging.
/// Essential for providing line-by-line debugging and source code visualization.
pub use crate;
/// Local variable and constant scope tracking.
///
/// `LocalScope` defines the IL instruction ranges where local variables and constants are active.
/// Critical for proper variable visibility and lifetime tracking during debugging.
pub use crate;
/// Local variable debug information.
///
/// Provides names, signatures, and debugging attributes for local variables within methods.
/// Enables debuggers to display meaningful variable information during execution.
pub use crate;
/// Local constant debug information.
///
/// Contains information about local constants including names, signatures, and values.
/// Allows debuggers to display constant values and provide comprehensive local state information.
pub use crate;
/// Namespace import scope information.
///
/// Tracks namespace imports (using statements) and their active ranges for proper name resolution
/// during debugging and `IntelliSense` operations.
pub use crate;
/// State machine method mappings.
///
/// Links compiler-generated state machine methods (async/await, iterators) back to their original
/// user-written methods for seamless debugging experiences.
pub use crate;
/// Custom debugging information table types.
///
/// Extensible debug information that can be defined by compilers or tools for specialized
/// debugging scenarios beyond the standard Portable PDB format.
pub use crate;
/// Custom debug information parsing types.
///
/// Provides parsing capabilities for custom debug information blobs in Portable PDB format,
/// including Source Link, Embedded Source, and Compilation Metadata formats.
pub use crate;
// ================================================================================================
// Raw Metadata Table Types
// ================================================================================================
//
// This section provides direct access to raw metadata table structures as they appear
// in the assembly file. These types offer maximum performance and direct memory access
// but require careful handling. Use high-level types above unless you need specific
// performance characteristics or are implementing low-level tools.
/// Assembly and module raw table types.
///
/// Direct access to assembly and module table rows with minimal overhead.
/// Use for performance-critical scenarios or when implementing metadata parsers.
pub use crate;
/// Type definition raw table types.
///
/// Raw access to type definition and reference tables for direct metadata manipulation.
pub use crate;
/// Field and method raw table types.
///
/// Direct access to field and method metadata without high-level wrapper overhead.
pub use crate;
/// Core metadata raw table types.
///
/// Raw access to all fundamental metadata tables. These provide the most direct
/// interface to the underlying metadata structure with minimal processing overhead.
pub use crate;
/// File system raw table types.
///
/// Raw access to file reference metadata for multi-file assembly analysis.
pub use crateFileRaw;
// ================================================================================================
// Signatures and Type Information
// ================================================================================================
//
// This section provides comprehensive signature parsing and type information handling.
// Signatures are encoded type descriptions used throughout .NET metadata for methods,
// fields, properties, and local variables. These types handle the complex parsing and
// representation of .NET type signatures.
/// Core signature types.
///
/// Comprehensive set of signature structures for representing method signatures,
/// field types, local variables, and complex type constructs like arrays and pointers.
pub use crate;
/// Signature parsing functions.
///
/// High-level parsing functions for converting binary signature data into structured
/// type information. These functions handle the complex binary encoding used in .NET metadata.
pub use crate;
/// Additional signature support types.
///
/// Specialized signature types for member references and complex signature scenarios.
pub use crateMemberRefSignature;
// ================================================================================================
// Method Analysis
// ================================================================================================
//
// This section provides comprehensive method analysis capabilities including method body
// parsing, exception handler analysis, and instruction-level access. These types enable
// deep analysis of method implementations and control flow.
/// Method body and IL analysis.
///
/// Complete method analysis including method bodies, exception handlers, implementation
/// attributes, and instruction-level access for CIL analysis and manipulation.
pub use crate;
// ================================================================================================
// Assembly - CIL Instruction Processing
// ================================================================================================
//
// This section provides CIL (Common Intermediate Language) instruction processing capabilities.
// The assembly module can parse method bodies into individual instructions, analyze control
// flow, and provide detailed instruction-level analysis for reverse engineering and
// program analysis scenarios, as well as assemble instructions back into bytecode.
/// CIL instruction analysis, disassembly, and assembly.
///
/// Complete toolkit for CIL instruction processing, including disassembly of bytecode into
/// structured representations, control flow analysis, and assembly of instructions back to bytecode.
/// The assembly system provides both high-level fluent APIs and low-level encoding capabilities.
pub use crate;
// ================================================================================================
// Import/Export Analysis
// ================================================================================================
//
// This section provides analysis of assembly dependencies through both managed (.NET) and
// native PE import/export tables. These types enable understanding of inter-assembly
// relationships, dependency analysis, assembly composition patterns, and native DLL dependencies.
//
// The unified containers provide a single interface for both CIL and native imports/exports,
// while individual containers allow focused analysis of specific import/export types.
/// Import and export analysis.
///
/// Tools for analyzing assembly dependencies, exported types, and import relationships
/// essential for understanding assembly composition and dependency graphs. Includes both
/// managed (.NET) imports/exports and native PE import/export table support.
pub use crate;
// ================================================================================================
// Metadata Streams - Heaps and Headers
// ================================================================================================
//
// This section provides access to the fundamental storage structures of .NET metadata.
// Metadata is organized into heaps (string, blob, GUID, user string) and tables, with
// headers describing the layout and organization. These types provide both direct access
// and efficient iteration over metadata structures.
/// Metadata heap access.
///
/// Direct access to the four metadata heaps containing strings, binary data, GUIDs,
/// and user strings. These heaps store the actual data referenced by metadata tables.
pub use crate;
/// Metadata heap iterators for efficient sequential traversal.
///
/// Performance-optimized iterators for sequential access to heap contents when
/// processing large amounts of metadata or performing bulk analysis operations.
pub use crate;
/// Metadata tables and stream headers.
///
/// Header structures that describe the organization and layout of metadata streams
/// and tables, essential for understanding metadata structure and navigation.
pub use crate;
/// Main headers.
///
/// Primary assembly headers including CLR header and metadata root structures.
pub use crate;
// ================================================================================================
// Attributes and Flags
// ================================================================================================
//
// This section provides attribute flag enumerations used throughout .NET metadata.
// These flags control visibility, behavior, and characteristics of types, methods,
// fields, and other metadata elements according to ECMA-335 specifications.
/// Common attribute flags for metadata tables.
///
/// Comprehensive set of attribute enumerations for controlling type, method, field,
/// parameter, property, event, and file characteristics as defined by ECMA-335.
pub use crate;
/// Method and implementation flag constants.
///
/// Specialized flag enumerations for method definitions including access modifiers
/// used with MethodDefBuilder. Other method flags are exported in the method section.
pub use crateMethodAccessFlags;
// ================================================================================================
// Constants and Element Types
// ================================================================================================
//
// This section provides fundamental constants used throughout the .NET type system
// and marshalling infrastructure. These constants define element types, native types,
// and variant types as specified in ECMA-335 and Win32 marshalling specifications.
/// Element type constants for type system.
///
/// ECMA-335 element type constants used in signatures and type encoding throughout
/// the .NET metadata system for identifying primitive and complex types.
pub use crateELEMENT_TYPE;
/// Native type constants for marshalling.
///
/// Win32 native type and variant type constants used in P/Invoke marshalling
/// and COM interop scenarios for type conversion and memory layout.
pub use crate;
// ================================================================================================
// Table Identifiers and Utilities
// ================================================================================================
//
// This section provides metadata table identification and utility types for working
// with the underlying table structure. These types enable table enumeration, coded
// index resolution, and direct table manipulation for advanced metadata operations.
/// Metadata table identifiers.
///
/// Enumeration of all ECMA-335 metadata table types for table identification
/// and navigation throughout the metadata system.
pub use crateTableId;
/// Coded index types for metadata table relationships.
///
/// Coded index mechanisms for efficient cross-table references as defined by ECMA-335,
/// enabling compact encoding of table relationships and metadata navigation.
pub use crate;
// ================================================================================================
// Metadata Builders
// ================================================================================================
//
// This section provides metadata builder types for creating and modifying .NET assemblies.
// These builders use a fluent API pattern where CilAssembly is passed to the build()
// method, enabling ergonomic creation of multiple metadata entries in sequence.
//
// All builders follow the established pattern:
// - Builder structs do NOT hold references to CilAssembly
// - Assembly is passed as a parameter to the build() method
// - All builders implement Default trait for clippy compliance
// - Multiple builders can be used in sequence without borrow checker issues
pub use crateChangeRefRc;
/// Core builder infrastructure.
///
/// CilAssembly provides the mutable assembly interface required for metadata modification operations.
/// ChangeRefRc is a reference-counted handle for tracking heap additions and table modifications.
pub use crateCilAssembly;
/// Assembly validation pipeline components.
///
/// Conflict resolvers handle operation conflicts with different strategies (last-write-wins, etc.).
/// For validation, use the unified ValidationEngine from the metadata::validation module.
pub use crateLastWriteWinsResolver;
/// Assembly and module builders.
///
/// Create assembly metadata, module definitions, and assembly identity information.
/// AssemblyBuilder handles version numbers, culture settings, and strong naming.
pub use crateAssemblyBuilder;
/// Type system builders.
///
/// Create type definitions, type references, and type specifications. These builders
/// handle class, interface, value type, and enum creation with proper inheritance
/// relationships and generic type parameters.
pub use crate;
/// Member definition builders.
///
/// Create field definitions, method definitions, parameter definitions, property
/// definitions, event definitions, and custom attribute annotations with proper
/// signatures, attributes, and implementation details. These builders handle all
/// aspects of type member creation including accessibility, static/instance behavior,
/// method implementation, parameter information, property encapsulation, event
/// notification mechanisms, and declarative metadata annotations.
pub use crate;
/// High-level builders for .NET constructs.
///
/// Create complete class, interface, property, event, and method definitions with implementations, signatures, local variables,
/// exception handlers, and parameter tables. These builders compose the low-level metadata
/// builders to provide convenient APIs for creating complete .NET types, interfaces, properties, events, and methods with full
/// implementation details.
pub use crate;
/// Native PE import and export builders.
///
/// Create native PE import and export tables that integrate with the dotscope builder pattern.
/// These builders handle native DLL dependencies, function imports by name and ordinal,
/// export functions, and export forwarders for mixed-mode assemblies and PE files.
pub use crate;
/// Method semantic relationship constants.
///
/// Constants defining the semantic roles methods can play in relation to properties
/// and events. Used with MethodSemanticsBuilder to specify getter, setter, add, remove,
/// fire, and other semantic relationships.
pub use crateMethodSemanticsAttributes;
// ================================================================================================
// PE File Structures
// ================================================================================================
//
// Complete set of owned PE (Portable Executable) file structures for direct manipulation
// and analysis of Windows executables and .NET assemblies. These structures provide owned
// representations that don't borrow from the underlying file data, enabling flexible
// analysis and modification workflows.
/// Complete PE file representation and core structures.
///
/// Owned PE file structures including headers, sections, and import/export tables.
/// These provide direct access to PE file components without borrowing from source data.
pub use crate;
/// Generator configuration for PE file output.
///
/// Use `CilAssembly::to_file()` or `CilAssembly::to_memory()` to generate assemblies.
/// Use `GeneratorConfig` for advanced configuration.
pub use crateGeneratorConfig;
// ================================================================================================
// Analysis Infrastructure
// ================================================================================================
//
// This section provides program analysis infrastructure for .NET assemblies including
// control flow graphs, SSA (Static Single Assignment) form, data flow analysis, and
// call graph construction. These are foundational types for advanced code analysis,
// optimization, and deobfuscation.
/// Control flow graph types.
///
/// Build and analyze control flow graphs from CIL method bodies. Includes edge classification,
/// loop detection, and dominator tree computation for program analysis.
pub use crate;
/// SSA (Static Single Assignment) form types.
///
/// Convert CIL methods to SSA form for advanced analysis. Includes SSA function representation,
/// variables, operations, and phi nodes for data flow analysis.
pub use crate;
/// Data flow analysis types.
///
/// Generic data flow analysis framework including reaching definitions, live variables,
/// and constant propagation. Provides lattice-based analysis with configurable direction.
pub use crate;
/// Call graph analysis.
///
/// Build and analyze call graphs for interprocedural analysis. Essential for understanding
/// method dependencies and enabling whole-program optimization.
pub use crateCallGraph;
// ================================================================================================
// Deobfuscation Framework
// ================================================================================================
//
// This section provides the deobfuscation framework for detecting and removing code
// obfuscation from .NET assemblies. Includes the deobfuscation engine, obfuscator support,
// pass infrastructure, and built-in transformation passes.
/// Deobfuscation engine and configuration.
///
/// Main entry point for deobfuscation with configurable passes and obfuscator support.
/// Process obfuscated assemblies to recover original code structure.
pub use crate;
/// Obfuscator detection and support.
///
/// Obfuscator-based identification with confidence scoring. Create custom obfuscator
/// implementations for detecting and handling specific obfuscators.
pub use crate;
/// Pass system for SSA-based transformations.
///
/// Create custom SSA passes that operate on SSA form. The scheduler manages
/// pass execution order and fixpoint iteration.
pub use crate;
pub use crateAnalysisContext;
/// Built-in SSA optimization passes from the compiler module.
///
/// All generic SSA transformation passes: value propagation, control flow recovery,
/// dead code elimination, strength reduction, loop optimization, and more.
pub use crate;
/// Deobfuscation-specific SSA passes.
pub use crateDecryptionPass;
/// Code generation from SSA.
///
/// Convert SSA form back to CIL bytecode after transformations.
pub use crateSsaCodeGenerator;
// ================================================================================================
// Emulation Engine
// ================================================================================================
//
// This section provides the CIL emulation engine for controlled execution of .NET bytecode.
// Essential for deobfuscation when values are computed at runtime, such as string decryption
// and dynamic control flow resolution.
/// Emulation value types.
///
/// Runtime value representation for CIL emulation including primitives, references,
/// and symbolic values for partial emulation.
pub use crate;
/// Emulation memory model.
///
/// Memory model for CIL emulation including evaluation stack, local variables,
/// arguments, managed heap simulation, and Copy-on-Write memory pages.
pub use crate;
/// Emulation engine and control.
///
/// Core interpreter and execution controller with configurable limits and hook system
/// for intercepting method calls and providing custom behavior.
pub use crate;
/// Hook system for method interception.
///
/// The hook system allows intercepting method calls during emulation to provide custom
/// behavior. Use these types to implement your own hooks for methods that cannot be
/// directly emulated or require special handling.
pub use crate;