-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBNDataVariableAndName.cs
More file actions
90 lines (76 loc) · 2.06 KB
/
Copy pathBNDataVariableAndName.cs
File metadata and controls
90 lines (76 loc) · 2.06 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
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
namespace BinaryNinja
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct BNDataVariableAndName
{
/// <summary>
/// uint64_t address
/// </summary>
internal ulong address;
/// <summary>
/// BNType* type
/// </summary>
internal IntPtr type;
/// <summary>
/// const char* name
/// </summary>
internal IntPtr name;
/// <summary>
/// bool autoDiscovered
/// </summary>
[MarshalAs(UnmanagedType.I1)] internal bool autoDiscovered;
/// <summary>
/// uint8_t typeConfidence
/// </summary>
internal byte typeConfidence;
}
public class DataVariableAndName
{
public ulong Address { get; set; } = 0;
public BinaryNinja.Type Type { get; set; }
public string Name { get; set; } = string.Empty;
public bool AutoDiscovered { get; set; } = false;
public byte TypeConfidence { get; set; } = 0;
public DataVariableAndName(
ulong address,
BinaryNinja.Type type,
string name,
bool autoDiscovered,
byte typeConfidence
)
{
this.Address = address;
this.Type = type;
this.Name = name;
this.AutoDiscovered = autoDiscovered;
this.TypeConfidence = typeConfidence;
}
public DataVariableAndName(BNDataVariableAndName native)
{
this.Address = native.address;
this.Type = BinaryNinja.Type.MustNewFromHandle(native.type);
this.Name = UnsafeUtils.ReadAnsiString(native.name);
this.AutoDiscovered = native.autoDiscovered;
this.TypeConfidence = native.typeConfidence;
}
internal static DataVariableAndName FromNative(BNDataVariableAndName native)
{
return new DataVariableAndName(native);
}
internal BNDataVariableAndName ToNative(ScopedAllocator allocator)
{
return new BNDataVariableAndName()
{
address = this.Address ,
type = this.Type.DangerousGetHandle() ,
name = allocator.AllocAnsiString(this.Name) ,
autoDiscovered = this.AutoDiscovered ,
typeConfidence = this.TypeConfidence
};
}
}
}