-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmemflowInterop.cs
More file actions
3767 lines (2999 loc) · 213 KB
/
memflowInterop.cs
File metadata and controls
3767 lines (2999 loc) · 213 KB
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
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace memflowNET.Interop
{
/// <summary>Defines the type of a member as it was used in the native signature.</summary>
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)]
[Conditional("DEBUG")]
internal sealed partial class NativeTypeNameAttribute : Attribute
{
private readonly string _name;
/// <summary>Initializes a new instance of the <see cref="NativeTypeNameAttribute" /> class.</summary>
/// <param name="name">The name of the type that was used in the native signature.</param>
public NativeTypeNameAttribute(string name)
{
_name = name;
}
/// <summary>Gets the name of the type that was used in the native signature.</summary>
public string Name => _name;
}
/// <summary>Defines the base type of a struct as it was in the native signature.</summary>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
[Conditional("DEBUG")]
internal sealed partial class NativeInheritanceAttribute : Attribute
{
private readonly string _name;
/// <summary>Initializes a new instance of the <see cref="NativeInheritanceAttribute" /> class.</summary>
/// <param name="name">The name of the base type that was inherited from in the native signature.</param>
public NativeInheritanceAttribute(string name)
{
_name = name;
}
/// <summary>Gets the name of the base type that was inherited from in the native signature.</summary>
public string Name => _name;
}
/// <summary>
/// Identifies the byte order of a architecture
/// This enum is used when reading/writing to/from the memory of a target system.The memory will be automatically converted to the endianess memflow is currently running on.
/// See the [wikipedia article](https://en.wikipedia.org/wiki/Endianness) for more information on the subject.
/// </summary>
[NativeTypeName("uint8_t")]
public enum Endianess : byte
{
Endianess_LittleEndian,
Endianess_BigEndian,
}
/// <summary>
/// An enum representing the available verbosity levels of the logger.
/// Typical usage includes: checking if a certain `Level` is enabled with[`log_enabled!`](macro.log_enabled.html), specifying the `Level` of[`log!`](macro.log.html), and comparing a `Level` directly to a[`LevelFilter`](enum.LevelFilter.html).
/// </summary>
[NativeTypeName("uintptr_t")]
public enum Level : uint
{
Level_Error = 1,
Level_Warn,
Level_Info,
Level_Debug,
Level_Trace,
}
/// <summary>
/// An enum representing the available verbosity level filters of the logger.
/// A `LevelFilter` may be compared directly to a [`Level`]. Use this typeto get and set the maximum log level with [`max_level()`] and [`set_max_level`].
/// [`Level`]: enum.Level.html[`max_level()`]: fn.max_level.html[`set_max_level`]: fn.set_max_level.html
/// </summary>
[NativeTypeName("uintptr_t")]
public enum LevelFilter : uint
{
LevelFilter_Off,
LevelFilter_Error,
LevelFilter_Warn,
LevelFilter_Info,
LevelFilter_Debug,
LevelFilter_Trace,
}
public partial struct ArchitectureObj
{
}
/// <summary>
/// The core of the plugin system
/// It scans system directories and collects valid memflow plugins. They can then be instantiatedeasily. The reason the libraries are collected is to allow for reuse, and save performance
/// # Examples
/// Creating a OS instance, the recommended way:
/// ```no_runuse memflow::plugins::Inventory;# use memflow::plugins::OsInstanceArcBox;# use memflow::error::Result;# fn test() -> Result<OsInstanceArcBox<'static>> {let inventory = Inventory::scan();inventory.builder().connector("qemu").os("win32").build()# }# test().ok();```
/// Nesting connectors and os plugins:```no_runuse memflow::plugins::{Inventory, Args};# use memflow::error::Result;# fn test() -> Result<()> {let inventory = Inventory::scan();let os = inventory.builder().connector("qemu").os("linux").connector("qemu").os("win32").build();# Ok(())# }# test().ok();```
/// </summary>
public partial struct Inventory
{
}
/// <summary>
/// This type represents a wrapper over a [address](address/index.html)with additional information about the containing page in the physical memory domain.
/// This type will mostly be used by the [virtual to physical address translation](todo.html).When a physical address is translated from a virtual address the additional informationabout the allocated page the virtual address points to can be obtained from this structure.
/// Most architectures have support multiple page sizes (see [huge pages](todo.html))which will be represented by the containing `page` of the `PhysicalAddress` struct.
/// </summary>
public partial struct PhysicalAddress
{
[NativeTypeName("Address")]
public ulong address;
[NativeTypeName("PageType")]
public byte page_type;
[NativeTypeName("uint8_t")]
public byte page_size_log2;
}
/// <summary>
/// FFI-safe box
/// This box has a static self reference, alongside a custom drop function.
/// The drop function can be called from anywhere, it will free on correct allocator internally.
/// </summary>
public unsafe partial struct CBox_c_void
{
public void* instance;
[NativeTypeName("void (*)(void *)")]
public delegate* unmanaged[Cdecl]<void*, void> drop_fn;
}
/// <summary>
/// FFI-Safe Arc
/// This is an FFI-Safe equivalent of Arc<T> and Option<Arc<T>>.
/// </summary>
public unsafe partial struct CArc_c_void
{
[NativeTypeName("const void *")]
public void* instance;
[NativeTypeName("const void *(*)(const void *)")]
public delegate* unmanaged[Cdecl]<void*, void*> clone_fn;
[NativeTypeName("void (*)(const void *)")]
public delegate* unmanaged[Cdecl]<void*, void> drop_fn;
}
public partial struct ConnectorInstanceContainer_CBox_c_void_____CArc_c_void
{
[NativeTypeName("struct CBox_c_void")]
public CBox_c_void instance;
[NativeTypeName("struct CArc_c_void")]
public CArc_c_void context;
}
/// <summary>
/// CGlue vtable for trait Clone.
/// This virtual function table contains ABI-safe interface for the given trait.
/// </summary>
public unsafe partial struct CloneVtbl_ConnectorInstanceContainer_CBox_c_void_____CArc_c_void
{
[NativeTypeName("struct ConnectorInstanceContainer_CBox_c_void_____CArc_c_void (*)(const struct ConnectorInstanceContainer_CBox_c_void_____CArc_c_void *)")]
public delegate* unmanaged[Cdecl]<ConnectorInstanceContainer_CBox_c_void_____CArc_c_void*, ConnectorInstanceContainer_CBox_c_void_____CArc_c_void> clone;
}
/// <summary>
/// Wrapper around mutable slices.
/// This is meant as a safe type to pass across the FFI boundary with similar semantics as regularslice. However, not all functionality is present, use the slice conversion functions.
/// </summary>
public unsafe partial struct CSliceMut_u8
{
[NativeTypeName("uint8_t *")]
public byte* data;
[NativeTypeName("uintptr_t")]
public nuint len;
}
/// <summary>
/// FFI-safe 3 element tuple.
/// </summary>
public partial struct CTup3_PhysicalAddress__Address__CSliceMut_u8
{
[NativeTypeName("struct PhysicalAddress")]
public PhysicalAddress _0;
[NativeTypeName("Address")]
public ulong _1;
[NativeTypeName("struct CSliceMut_u8")]
public CSliceMut_u8 _2;
}
/// <summary>
/// FFI compatible iterator.
/// Any mutable reference to an iterator can be converted to a `CIterator`.
/// `CIterator<T>` implements `Iterator<Item= T>`.
/// # Examples
/// Using [`AsCIterator`](AsCIterator) helper:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..10).map(|v| v * v);
/// assert_eq!(sum_all(iter.as_citer()), 285);```
/// Converting with `Into` trait:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..=10).map(|v| v * v);
/// assert_eq!(sum_all((&mutiter).into()), 385);```
/// </summary>
public unsafe partial struct CIterator_PhysicalReadData
{
public void* iter;
[NativeTypeName("int32_t (*)(void *, PhysicalReadData *)")]
public delegate* unmanaged[Cdecl]<void*, CTup3_PhysicalAddress__Address__CSliceMut_u8*, int> func;
}
/// <summary>
/// FFI-safe 2 element tuple.
/// </summary>
public partial struct CTup2_Address__CSliceMut_u8
{
[NativeTypeName("Address")]
public ulong _0;
[NativeTypeName("struct CSliceMut_u8")]
public CSliceMut_u8 _1;
}
public unsafe partial struct Callback_c_void__ReadData
{
public void* context;
[NativeTypeName("bool (*)(void *, ReadData)")]
public delegate* unmanaged[Cdecl]<void*, CTup2_Address__CSliceMut_u8, byte> func;
}
/// <summary>
/// Data needed to perform memory operations.
/// `inp` is an iterator containing
/// </summary>
public unsafe partial struct MemOps_PhysicalReadData__ReadData
{
[NativeTypeName("struct CIterator_PhysicalReadData")]
public CIterator_PhysicalReadData inp;
[NativeTypeName("OpaqueCallback_ReadData *")]
public Callback_c_void__ReadData* @out;
[NativeTypeName("OpaqueCallback_ReadData *")]
public Callback_c_void__ReadData* out_fail;
}
/// <summary>
/// Wrapper around const slices.
/// This is meant as a safe type to pass across the FFI boundary with similar semantics as regularslice. However, not all functionality is present, use the slice conversion functions.
/// # Examples
/// Simple conversion:
/// ```use cglue::slice::CSliceRef;
/// let arr = [0, 5, 3, 2];
/// let cslice = CSliceRef::from(&arr[..]);
/// let slice = cslice.as_slice();
/// assert_eq!(&arr, slice);```
/// </summary>
public unsafe partial struct CSliceRef_u8
{
[NativeTypeName("const uint8_t *")]
public byte* data;
[NativeTypeName("uintptr_t")]
public nuint len;
}
/// <summary>
/// FFI-safe 3 element tuple.
/// </summary>
public partial struct CTup3_PhysicalAddress__Address__CSliceRef_u8
{
[NativeTypeName("struct PhysicalAddress")]
public PhysicalAddress _0;
[NativeTypeName("Address")]
public ulong _1;
[NativeTypeName("struct CSliceRef_u8")]
public CSliceRef_u8 _2;
}
/// <summary>
/// FFI compatible iterator.
/// Any mutable reference to an iterator can be converted to a `CIterator`.
/// `CIterator<T>` implements `Iterator<Item= T>`.
/// # Examples
/// Using [`AsCIterator`](AsCIterator) helper:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..10).map(|v| v * v);
/// assert_eq!(sum_all(iter.as_citer()), 285);```
/// Converting with `Into` trait:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..=10).map(|v| v * v);
/// assert_eq!(sum_all((&mutiter).into()), 385);```
/// </summary>
public unsafe partial struct CIterator_PhysicalWriteData
{
public void* iter;
[NativeTypeName("int32_t (*)(void *, PhysicalWriteData *)")]
public delegate* unmanaged[Cdecl]<void*, CTup3_PhysicalAddress__Address__CSliceRef_u8*, int> func;
}
/// <summary>
/// FFI-safe 2 element tuple.
/// </summary>
public partial struct CTup2_Address__CSliceRef_u8
{
[NativeTypeName("Address")]
public ulong _0;
[NativeTypeName("struct CSliceRef_u8")]
public CSliceRef_u8 _1;
}
public unsafe partial struct Callback_c_void__WriteData
{
public void* context;
[NativeTypeName("bool (*)(void *, WriteData)")]
public delegate* unmanaged[Cdecl]<void*, CTup2_Address__CSliceRef_u8, byte> func;
}
/// <summary>
/// Data needed to perform memory operations.
/// `inp` is an iterator containing
/// </summary>
public unsafe partial struct MemOps_PhysicalWriteData__WriteData
{
[NativeTypeName("struct CIterator_PhysicalWriteData")]
public CIterator_PhysicalWriteData inp;
[NativeTypeName("OpaqueCallback_WriteData *")]
public Callback_c_void__WriteData* @out;
[NativeTypeName("OpaqueCallback_WriteData *")]
public Callback_c_void__WriteData* out_fail;
}
public partial struct PhysicalMemoryMetadata
{
[NativeTypeName("Address")]
public ulong max_address;
[NativeTypeName("umem")]
public ulong real_size;
[NativeTypeName("bool")]
public byte @readonly;
[NativeTypeName("uint32_t")]
public uint ideal_batch_size;
}
public partial struct PhysicalMemoryMapping
{
[NativeTypeName("Address")]
public ulong @base;
[NativeTypeName("umem")]
public ulong size;
[NativeTypeName("Address")]
public ulong real_base;
}
/// <summary>
/// Wrapper around const slices.
/// This is meant as a safe type to pass across the FFI boundary with similar semantics as regularslice. However, not all functionality is present, use the slice conversion functions.
/// # Examples
/// Simple conversion:
/// ```use cglue::slice::CSliceRef;
/// let arr = [0, 5, 3, 2];
/// let cslice = CSliceRef::from(&arr[..]);
/// let slice = cslice.as_slice();
/// assert_eq!(&arr, slice);```
/// </summary>
public unsafe partial struct CSliceRef_PhysicalMemoryMapping
{
[NativeTypeName("const struct PhysicalMemoryMapping *")]
public PhysicalMemoryMapping* data;
[NativeTypeName("uintptr_t")]
public nuint len;
}
/// <summary>
/// FFI-safe 3 element tuple.
/// </summary>
public partial struct CTup3_Address__Address__CSliceMut_u8
{
[NativeTypeName("Address")]
public ulong _0;
[NativeTypeName("Address")]
public ulong _1;
[NativeTypeName("struct CSliceMut_u8")]
public CSliceMut_u8 _2;
}
/// <summary>
/// FFI compatible iterator.
/// Any mutable reference to an iterator can be converted to a `CIterator`.
/// `CIterator<T>` implements `Iterator<Item= T>`.
/// # Examples
/// Using [`AsCIterator`](AsCIterator) helper:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..10).map(|v| v * v);
/// assert_eq!(sum_all(iter.as_citer()), 285);```
/// Converting with `Into` trait:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..=10).map(|v| v * v);
/// assert_eq!(sum_all((&mutiter).into()), 385);```
/// </summary>
public unsafe partial struct CIterator_ReadDataRaw
{
public void* iter;
[NativeTypeName("int32_t (*)(void *, ReadDataRaw *)")]
public delegate* unmanaged[Cdecl]<void*, CTup3_Address__Address__CSliceMut_u8*, int> func;
}
/// <summary>
/// Data needed to perform memory operations.
/// `inp` is an iterator containing
/// </summary>
public unsafe partial struct MemOps_ReadDataRaw__ReadData
{
[NativeTypeName("struct CIterator_ReadDataRaw")]
public CIterator_ReadDataRaw inp;
[NativeTypeName("OpaqueCallback_ReadData *")]
public Callback_c_void__ReadData* @out;
[NativeTypeName("OpaqueCallback_ReadData *")]
public Callback_c_void__ReadData* out_fail;
}
/// <summary>
/// FFI-safe 3 element tuple.
/// </summary>
public partial struct CTup3_Address__Address__CSliceRef_u8
{
[NativeTypeName("Address")]
public ulong _0;
[NativeTypeName("Address")]
public ulong _1;
[NativeTypeName("struct CSliceRef_u8")]
public CSliceRef_u8 _2;
}
/// <summary>
/// FFI compatible iterator.
/// Any mutable reference to an iterator can be converted to a `CIterator`.
/// `CIterator<T>` implements `Iterator<Item= T>`.
/// # Examples
/// Using [`AsCIterator`](AsCIterator) helper:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..10).map(|v| v * v);
/// assert_eq!(sum_all(iter.as_citer()), 285);```
/// Converting with `Into` trait:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..=10).map(|v| v * v);
/// assert_eq!(sum_all((&mutiter).into()), 385);```
/// </summary>
public unsafe partial struct CIterator_WriteDataRaw
{
public void* iter;
[NativeTypeName("int32_t (*)(void *, WriteDataRaw *)")]
public delegate* unmanaged[Cdecl]<void*, CTup3_Address__Address__CSliceRef_u8*, int> func;
}
/// <summary>
/// Data needed to perform memory operations.
/// `inp` is an iterator containing
/// </summary>
public unsafe partial struct MemOps_WriteDataRaw__WriteData
{
[NativeTypeName("struct CIterator_WriteDataRaw")]
public CIterator_WriteDataRaw inp;
[NativeTypeName("OpaqueCallback_WriteData *")]
public Callback_c_void__WriteData* @out;
[NativeTypeName("OpaqueCallback_WriteData *")]
public Callback_c_void__WriteData* out_fail;
}
public partial struct MemoryViewMetadata
{
[NativeTypeName("Address")]
public ulong max_address;
[NativeTypeName("umem")]
public ulong real_size;
[NativeTypeName("bool")]
public byte @readonly;
[NativeTypeName("bool")]
public byte little_endian;
[NativeTypeName("uint8_t")]
public byte arch_bits;
}
/// <summary>
/// FFI compatible iterator.
/// Any mutable reference to an iterator can be converted to a `CIterator`.
/// `CIterator<T>` implements `Iterator<Item= T>`.
/// # Examples
/// Using [`AsCIterator`](AsCIterator) helper:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..10).map(|v| v * v);
/// assert_eq!(sum_all(iter.as_citer()), 285);```
/// Converting with `Into` trait:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..=10).map(|v| v * v);
/// assert_eq!(sum_all((&mutiter).into()), 385);```
/// </summary>
public unsafe partial struct CIterator_ReadData
{
public void* iter;
[NativeTypeName("int32_t (*)(void *, ReadData *)")]
public delegate* unmanaged[Cdecl]<void*, CTup2_Address__CSliceMut_u8*, int> func;
}
/// <summary>
/// Wrapper around mutable slices.
/// This is meant as a safe type to pass across the FFI boundary with similar semantics as regularslice. However, not all functionality is present, use the slice conversion functions.
/// </summary>
public unsafe partial struct CSliceMut_ReadData
{
[NativeTypeName("ReadData *")]
public CTup2_Address__CSliceMut_u8* data;
[NativeTypeName("uintptr_t")]
public nuint len;
}
/// <summary>
/// FFI compatible iterator.
/// Any mutable reference to an iterator can be converted to a `CIterator`.
/// `CIterator<T>` implements `Iterator<Item= T>`.
/// # Examples
/// Using [`AsCIterator`](AsCIterator) helper:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..10).map(|v| v * v);
/// assert_eq!(sum_all(iter.as_citer()), 285);```
/// Converting with `Into` trait:
/// ```use cglue::iter::{CIterator, AsCIterator};
/// extern "C" fn sum_all(iter: CIterator<usize>) -> usize {iter.sum()}
/// let mut iter = (0..=10).map(|v| v * v);
/// assert_eq!(sum_all((&mutiter).into()), 385);```
/// </summary>
public unsafe partial struct CIterator_WriteData
{
public void* iter;
[NativeTypeName("int32_t (*)(void *, WriteData *)")]
public delegate* unmanaged[Cdecl]<void*, CTup2_Address__CSliceRef_u8*, int> func;
}
/// <summary>
/// Wrapper around const slices.
/// This is meant as a safe type to pass across the FFI boundary with similar semantics as regularslice. However, not all functionality is present, use the slice conversion functions.
/// # Examples
/// Simple conversion:
/// ```use cglue::slice::CSliceRef;
/// let arr = [0, 5, 3, 2];
/// let cslice = CSliceRef::from(&arr[..]);
/// let slice = cslice.as_slice();
/// assert_eq!(&arr, slice);```
/// </summary>
public unsafe partial struct CSliceRef_WriteData
{
[NativeTypeName("const WriteData *")]
public CTup2_Address__CSliceRef_u8* data;
[NativeTypeName("uintptr_t")]
public nuint len;
}
/// <summary>
/// Simple CGlue trait object container.
/// This is the simplest form of container, represented by an instance, clone context, andtemporary return context.
/// `instance` value usually is either a reference, or a mutable reference, or a `CBox`, whichcontains static reference to the instance, and a dedicated drop function for freeing resources.
/// `context` is either `PhantomData` representing nothing, or typically a `CArc` that can becloned at will, reference counting some resource, like a `Library` for automatic unloading.
/// `ret_tmp` is usually `PhantomData` representing nothing, unless the trait has functions thatreturn references to associated types, in which case space is reserved for wrapping structures.
/// </summary>
public partial struct CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void
{
[NativeTypeName("struct CBox_c_void")]
public CBox_c_void instance;
public CArc_c_void context;
}
/// <summary>
/// CGlue vtable for trait CpuState.
/// This virtual function table contains ABI-safe interface for the given trait.
/// </summary>
public unsafe partial struct CpuStateVtbl_CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void
{
[NativeTypeName("void (*)(struct CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void *)")]
public delegate* unmanaged[Cdecl]<CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void*, void> pause;
[NativeTypeName("void (*)(struct CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void *)")]
public delegate* unmanaged[Cdecl]<CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void*, void> resume;
}
/// <summary>
/// Simple CGlue trait object.
/// This is the simplest form of CGlue object, represented by a container and vtable for a singletrait.
/// Container merely is a this pointer with some optional temporary return reference context.
/// </summary>
public unsafe partial struct CGlueTraitObj_CBox_c_void_____CpuStateVtbl_CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void______________CArc_c_void_____CpuStateRetTmp_CArc_c_void
{
[NativeTypeName("const struct CpuStateVtbl_CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void *")]
public CpuStateVtbl_CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void* vtbl;
[NativeTypeName("struct CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void")]
public CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void container;
}
public partial struct IntoCpuStateContainer_CBox_c_void_____CArc_c_void
{
[NativeTypeName("struct CBox_c_void")]
public CBox_c_void instance;
public CArc_c_void context;
}
/// <summary>
/// CGlue vtable for trait Clone.
/// This virtual function table contains ABI-safe interface for the given trait.
/// </summary>
public unsafe partial struct CloneVtbl_IntoCpuStateContainer_CBox_c_void_____CArc_c_void
{
[NativeTypeName("struct IntoCpuStateContainer_CBox_c_void_____CArc_c_void (*)(const struct IntoCpuStateContainer_CBox_c_void_____CArc_c_void *)")]
public delegate* unmanaged[Cdecl]<IntoCpuStateContainer_CBox_c_void_____CArc_c_void*, IntoCpuStateContainer_CBox_c_void_____CArc_c_void> clone;
}
/// <summary>
/// CGlue vtable for trait CpuState.
/// This virtual function table contains ABI-safe interface for the given trait.
/// </summary>
public unsafe partial struct CpuStateVtbl_IntoCpuStateContainer_CBox_c_void_____CArc_c_void
{
[NativeTypeName("void (*)(struct IntoCpuStateContainer_CBox_c_void_____CArc_c_void *)")]
public delegate* unmanaged[Cdecl]<IntoCpuStateContainer_CBox_c_void_____CArc_c_void*, void> pause;
[NativeTypeName("void (*)(struct IntoCpuStateContainer_CBox_c_void_____CArc_c_void *)")]
public delegate* unmanaged[Cdecl]<IntoCpuStateContainer_CBox_c_void_____CArc_c_void*, void> resume;
}
/// <summary>
/// Trait group potentially implementing `:: cglue :: ext :: core :: clone :: Clone <> + CpuState <>` traits.
/// Optional traits are not implemented here, however. There are numerous conversionfunctions available for safely retrieving a concrete collection of traits.
/// `check_impl_` functions allow to check if the object implements the wanted traits.
/// `into_impl_` functions consume the object and produce a new final structure thatkeeps only the required information.
/// `cast_impl_` functions merely check and transform the object into a type that canbe transformed back into `IntoCpuState` without losing data.
/// `as_ref_`, and `as_mut_` functions obtain references to safe objects, but do notperform any memory transformations either. They are the safest to use, becausethere is no risk of accidentally consuming the whole object.
/// </summary>
public unsafe partial struct IntoCpuState_CBox_c_void_____CArc_c_void
{
[NativeTypeName("const struct CloneVtbl_IntoCpuStateContainer_CBox_c_void_____CArc_c_void *")]
public CloneVtbl_IntoCpuStateContainer_CBox_c_void_____CArc_c_void* vtbl_clone;
[NativeTypeName("const struct CpuStateVtbl_IntoCpuStateContainer_CBox_c_void_____CArc_c_void *")]
public CpuStateVtbl_IntoCpuStateContainer_CBox_c_void_____CArc_c_void* vtbl_cpustate;
[NativeTypeName("struct IntoCpuStateContainer_CBox_c_void_____CArc_c_void")]
public IntoCpuStateContainer_CBox_c_void_____CArc_c_void container;
}
/// <summary>
/// CGlue vtable for trait ConnectorCpuState.
/// This virtual function table contains ABI-safe interface for the given trait.
/// </summary>
public unsafe partial struct ConnectorCpuStateVtbl_ConnectorInstanceContainer_CBox_c_void_____CArc_c_void
{
[NativeTypeName("int32_t (*)(struct ConnectorInstanceContainer_CBox_c_void_____CArc_c_void *, CpuStateBase_CBox_c_void_____CArc_c_void *)")]
public delegate* unmanaged[Cdecl]<ConnectorInstanceContainer_CBox_c_void_____CArc_c_void*, CGlueTraitObj_CBox_c_void_____CpuStateVtbl_CGlueObjContainer_CBox_c_void_____CArc_c_void_____CpuStateRetTmp_CArc_c_void______________CArc_c_void_____CpuStateRetTmp_CArc_c_void*, int> cpu_state;
[NativeTypeName("int32_t (*)(struct ConnectorInstanceContainer_CBox_c_void_____CArc_c_void, struct IntoCpuState_CBox_c_void_____CArc_c_void *)")]
public delegate* unmanaged[Cdecl]<ConnectorInstanceContainer_CBox_c_void_____CArc_c_void, IntoCpuState_CBox_c_void_____CArc_c_void*, int> into_cpu_state;
}
/// <summary>
/// Trait group potentially implementing `:: cglue :: ext :: core :: clone :: Clone <> + PhysicalMemory <> + ConnectorCpuState <>` traits.
/// Optional traits are not implemented here, however. There are numerous conversionfunctions available for safely retrieving a concrete collection of traits.
/// `check_impl_` functions allow to check if the object implements the wanted traits.
/// `into_impl_` functions consume the object and produce a new final structure thatkeeps only the required information.
/// `cast_impl_` functions merely check and transform the object into a type that canbe transformed back into `ConnectorInstance` without losing data.
/// `as_ref_`, and `as_mut_` functions obtain references to safe objects, but do notperform any memory transformations either. They are the safest to use, becausethere is no risk of accidentally consuming the whole object.
/// </summary>
public unsafe partial struct ConnectorInstance_CBox_c_void_____CArc_c_void
{
[NativeTypeName("const struct CloneVtbl_ConnectorInstanceContainer_CBox_c_void_____CArc_c_void *")]
public CloneVtbl_ConnectorInstanceContainer_CBox_c_void_____CArc_c_void* vtbl_clone;
[NativeTypeName("const struct PhysicalMemoryVtbl_ConnectorInstanceContainer_CBox_c_void_____CArc_c_void *")]
public PhysicalMemoryVtbl_ConnectorInstanceContainer_CBox_c_void_____CArc_c_void* vtbl_physicalmemory;
[NativeTypeName("const struct ConnectorCpuStateVtbl_ConnectorInstanceContainer_CBox_c_void_____CArc_c_void *")]
public ConnectorCpuStateVtbl_ConnectorInstanceContainer_CBox_c_void_____CArc_c_void* vtbl_connectorcpustate;
[NativeTypeName("struct ConnectorInstanceContainer_CBox_c_void_____CArc_c_void")]
public ConnectorInstanceContainer_CBox_c_void_____CArc_c_void container;
}
public partial struct OsInstanceContainer_CBox_c_void_____CArc_c_void
{
[NativeTypeName("struct CBox_c_void")]
public CBox_c_void instance;
[NativeTypeName("struct CArc_c_void")]
public CArc_c_void context;
}
/// <summary>
/// CGlue vtable for trait Clone.
/// This virtual function table contains ABI-safe interface for the given trait.
/// </summary>
public unsafe partial struct CloneVtbl_OsInstanceContainer_CBox_c_void_____CArc_c_void
{
[NativeTypeName("struct OsInstanceContainer_CBox_c_void_____CArc_c_void (*)(const struct OsInstanceContainer_CBox_c_void_____CArc_c_void *)")]
public delegate* unmanaged[Cdecl]<OsInstanceContainer_CBox_c_void_____CArc_c_void*, OsInstanceContainer_CBox_c_void_____CArc_c_void> clone;
}
public unsafe partial struct Callback_c_void__Address
{
public void* context;
[NativeTypeName("bool (*)(void *, Address)")]
public delegate* unmanaged[Cdecl]<void*, ulong, byte> func;
}
/// <summary>
/// The state of a process
/// # Remarks
/// In case the exit code isn't known ProcessState::Unknown is set.
/// </summary>
public enum ProcessState_Tag
{
ProcessState_Unknown,
ProcessState_Alive,
ProcessState_Dead,
}
public partial struct ProcessState
{
public ProcessState_Tag tag;
[NativeTypeName("__AnonymousRecord_memflow_L1165_C5")]
public _Anonymous_e__Union Anonymous;
[UnscopedRef]
public ref int dead
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return ref Anonymous.Anonymous.dead;
}
}
[StructLayout(LayoutKind.Explicit)]
public partial struct _Anonymous_e__Union
{
[FieldOffset(0)]
[NativeTypeName("__AnonymousRecord_memflow_L1166_C9")]
public _Anonymous_e__Struct Anonymous;
public partial struct _Anonymous_e__Struct
{
[NativeTypeName("ExitCode")]
public int dead;
}
}
}
public enum ArchitectureIdent_Tag
{
ArchitectureIdent_Unknown,
ArchitectureIdent_X86,
ArchitectureIdent_AArch64,
}
public partial struct ArchitectureIdent_X86_Body
{
[NativeTypeName("uint8_t")]
public byte _0;
[NativeTypeName("bool")]
public byte _1;
}
public partial struct ArchitectureIdent
{
public ArchitectureIdent_Tag tag;
[NativeTypeName("__AnonymousRecord_memflow_L1208_C5")]
public _Anonymous_e__Union Anonymous;
[UnscopedRef]
public ref nuint unknown
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return ref Anonymous.Anonymous1.unknown;
}
}
[UnscopedRef]
public ref ArchitectureIdent_X86_Body x86
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return ref Anonymous.x86;
}
}
[UnscopedRef]
public ref nuint a_arch64
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return ref Anonymous.Anonymous2.a_arch64;
}
}
[StructLayout(LayoutKind.Explicit)]
public partial struct _Anonymous_e__Union
{
[FieldOffset(0)]
[NativeTypeName("__AnonymousRecord_memflow_L1209_C9")]
public _Anonymous1_e__Struct Anonymous1;
[FieldOffset(0)]
public ArchitectureIdent_X86_Body x86;
[FieldOffset(0)]
[NativeTypeName("__AnonymousRecord_memflow_L1213_C9")]
public _Anonymous2_e__Struct Anonymous2;
public partial struct _Anonymous1_e__Struct
{
[NativeTypeName("uintptr_t")]
public nuint unknown;
}
public partial struct _Anonymous2_e__Struct
{
[NativeTypeName("uintptr_t")]
public nuint a_arch64;
}
}
}
/// <summary>
/// Process information structure
/// This structure implements basic process information. Architectures are provided both of thesystem, and of the process.
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = 72)]
public unsafe partial struct ProcessInfo
{
[FieldOffset(0)]
[NativeTypeName("Address")]
public ulong address;
[FieldOffset(8)]
[NativeTypeName("Pid")]
public uint pid;
[FieldOffset(12)]
[NativeTypeName("struct ProcessState")]
public ProcessState state;
[FieldOffset(24)]
[NativeTypeName("ReprCString")]
public sbyte* name;
[FieldOffset(32)]
[NativeTypeName("ReprCString")]
public sbyte* path;
[FieldOffset(40)]
[NativeTypeName("ReprCString")]
public sbyte* command_line;
[FieldOffset(48)]
[NativeTypeName("struct ArchitectureIdent")]
public ArchitectureIdent sys_arch;
[FieldOffset(52)]
[NativeTypeName("struct ArchitectureIdent")]
public ArchitectureIdent proc_arch;
[FieldOffset(56)]
[NativeTypeName("Address")]
public ulong dtb1;
[FieldOffset(64)]
[NativeTypeName("Address")]
public ulong dtb2;
}
public unsafe partial struct Callback_c_void__ProcessInfo
{
public void* context;
[NativeTypeName("bool (*)(void *, struct ProcessInfo)")]
public delegate* unmanaged[Cdecl]<void*, ProcessInfo, byte> func;
}
/// <summary>
/// Pair of address and architecture used for callbacks
/// </summary>
public partial struct ModuleAddressInfo
{
[NativeTypeName("Address")]
public ulong address;
[NativeTypeName("struct ArchitectureIdent")]
public ArchitectureIdent arch;
}
public unsafe partial struct Callback_c_void__ModuleAddressInfo
{
public void* context;
[NativeTypeName("bool (*)(void *, struct ModuleAddressInfo)")]
public delegate* unmanaged[Cdecl]<void*, ModuleAddressInfo, byte> func;
}
/// <summary>
/// Module information structure
/// </summary>
public unsafe partial struct ModuleInfo
{
[NativeTypeName("Address")]
public ulong address;
[NativeTypeName("Address")]
public ulong parent_process;
[NativeTypeName("Address")]
public ulong @base;
[NativeTypeName("umem")]
public ulong size;
[NativeTypeName("ReprCString")]
public sbyte* name;
[NativeTypeName("ReprCString")]
public sbyte* path;
[NativeTypeName("struct ArchitectureIdent")]
public ArchitectureIdent arch;
}
public unsafe partial struct Callback_c_void__ModuleInfo
{
public void* context;
[NativeTypeName("bool (*)(void *, struct ModuleInfo)")]
public delegate* unmanaged[Cdecl]<void*, ModuleInfo, byte> func;
}
/// <summary>
/// Import information structure