-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathILFunctionNavigation.cs
More file actions
35 lines (33 loc) · 1.02 KB
/
Copy pathILFunctionNavigation.cs
File metadata and controls
35 lines (33 loc) · 1.02 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
using System;
using System.Runtime.InteropServices;
namespace BinaryNinja
{
/// <summary>
/// Shared native-list handling for IL function form navigation.
/// </summary>
internal static class ILFunctionNavigation
{
/// <summary>
/// Takes ownership of a native basic-block list, reads its graph type, and frees the list.
/// </summary>
internal static FunctionGraphType TakeFunctionGraphType(IntPtr blocks, ulong count)
{
try
{
if (IntPtr.Zero == blocks || 0 == count)
{
return FunctionGraphType.InvalidILViewType;
}
IntPtr firstBlock = Marshal.ReadIntPtr(blocks);
return NativeMethods.BNGetBasicBlockFunctionGraphType(firstBlock);
}
finally
{
if (IntPtr.Zero != blocks)
{
NativeMethods.BNFreeBasicBlockList(blocks, count);
}
}
}
}
}