forked from 9ee1/Capstone.NET
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNativeIndependentInstructionDetail.cs
106 lines (94 loc) · 4.48 KB
/
NativeIndependentInstructionDetail.cs
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
using System;
using System.Runtime.InteropServices;
namespace Gee.External.Capstone {
/// <summary>
/// Native Architecture Independent Instruction Detail.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe struct NativeIndependentInstructionDetail {
/// <summary>
/// Implicit Registers Read by an Instruction.
/// </summary>
public fixed byte ReadRegisters [12];
/// <summary>
/// Number of Implicit Registers Read by an Instruction.
/// </summary>
public byte ReadRegisterCount;
/// <summary>
/// Implicit Registers Written by an Instruction.
/// </summary>
public fixed byte WrittenRegisters [20];
/// <summary>
/// Number of Implicit Registers Written by an Instruction.
/// </summary>
public byte WrittenRegisterCount;
/// <summary>
/// Groups an Instruction Belongs to.
/// </summary>
public fixed byte Groups [8];
/// <summary>
/// Number of Groups an Instruction Belongs to.
/// </summary>
public byte GroupCount;
/// <summary>
/// Get Managed Groups an Instruction Belongs to.
/// </summary>
/// <value>
/// Convenient property to retrieve the implicit groups an instruction belongs to as a managed collection.
/// The size of the managed collection will always be equal to the value represented by
/// <c>NativeInstructionIndependentDetail.GroupCount</c>. This property allocates managed memory for a new
/// managed collection and uses direct memory copying to copy the collection from unmanaged memory to
/// managed memory every time it is invoked.
/// </value>
public byte[] ManagedGroups {
get {
fixed (byte* pGroups = this.Groups) {
var pPGroups = new IntPtr(pGroups);
var managedGroups = new byte[this.GroupCount];
Marshal.Copy(pPGroups, managedGroups, 0, this.GroupCount);
return managedGroups;
}
}
}
/// <summary>
/// Get Managed Implicit Registers Read by an Instruction.
/// </summary>
/// <value>
/// Convenient property to retrieve the implicit registers read by an instruction as a managed collection.
/// The size of the managed collection will always be equal to the value represented by
/// <c>NativeInstructionIndependentDetail.ReadRegisterCount</c>. This property allocates managed memory
/// for a new managed collection and uses direct memory copying to copy the collection from unmanaged
/// memory to managed memory every time it is invoked.
/// </value>
public byte[] ManagedReadRegisters {
get {
fixed (byte* pReadRegisters = this.ReadRegisters) {
var pPReadRegisters = new IntPtr(pReadRegisters);
var managedReadRegisters = new byte[this.ReadRegisterCount];
Marshal.Copy(pPReadRegisters, managedReadRegisters, 0, this.ReadRegisterCount);
return managedReadRegisters;
}
}
}
/// <summary>
/// Get Managed Implicit Registers Written by an Instruction.
/// </summary>
/// <value>
/// Convenient property to retrieve the implicit registers written by an instruction as a managed
/// collection. The size of the managed collection will always be equal to the value represented by
/// <c>NativeInstructionIndependentDetail.WrittenRegisterCount</c>. This property allocates managed memory
/// for a new managed collection and uses direct memory copying to copy the collection from unmanaged
/// memory to managed memory every time it is invoked.
/// </value>
public byte[] ManagedWrittenRegisters {
get {
fixed (byte* pWrittenRegisters = this.WrittenRegisters) {
var pPWrittenRegisters = new IntPtr(pWrittenRegisters);
var managedWrittenRegisters = new byte[this.WrittenRegisterCount];
Marshal.Copy(pPWrittenRegisters, managedWrittenRegisters, 0, this.WrittenRegisterCount);
return managedWrittenRegisters;
}
}
}
}
}