-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBNLinearViewObjectIdentifier.cs
More file actions
89 lines (71 loc) · 2.07 KB
/
Copy pathBNLinearViewObjectIdentifier.cs
File metadata and controls
89 lines (71 loc) · 2.07 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
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
namespace BinaryNinja
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct BNLinearViewObjectIdentifier
{
/// <summary>
/// const char* name
/// </summary>
internal IntPtr name;
/// <summary>
/// BNLinearViewObjectIdentifierType type
/// </summary>
internal LinearViewObjectIdentifierType type;
/// <summary>
/// uint64_t start
/// </summary>
internal ulong start;
/// <summary>
/// uint64_t end
/// </summary>
internal ulong end;
}
public sealed class LinearViewObjectIdentifier : INativeWrapperEx<BNLinearViewObjectIdentifier>
{
public string Name { get; set; } = string.Empty;
public LinearViewObjectIdentifierType Type { get; set; } = LinearViewObjectIdentifierType.SingleLinearViewObject;
public ulong Start { get; set; } = 0;
public ulong End { get; set; } = 0;
public LinearViewObjectIdentifier()
{
}
internal static LinearViewObjectIdentifier FromNativeStructPtr(IntPtr rawPtr)
{
if (IntPtr.Zero == rawPtr)
{
throw new ArgumentNullException(nameof(rawPtr));
}
return LinearViewObjectIdentifier.FromNative(Marshal.PtrToStructure<BNLinearViewObjectIdentifier>(rawPtr));
}
internal static LinearViewObjectIdentifier FromNative(BNLinearViewObjectIdentifier raw)
{
return new LinearViewObjectIdentifier()
{
Name = UnsafeUtils.ReadAnsiString(raw.name),
Type = raw.type,
Start = raw.start,
End = raw.end
};
}
internal static LinearViewObjectIdentifier TakeNativeStruct(BNLinearViewObjectIdentifier raw)
{
LinearViewObjectIdentifier target = LinearViewObjectIdentifier.FromNative(raw);
NativeMethods.BNFreeLinearViewObjectIdentifier(raw);
return target;
}
public BNLinearViewObjectIdentifier ToNativeEx(ScopedAllocator allocator)
{
return new BNLinearViewObjectIdentifier()
{
name = allocator.AllocAnsiString(this.Name) ,
type = this.Type ,
start = this.Start ,
end = this.End
};
}
}
}