diff --git a/Handle/BNBinaryView.cs b/Handle/BNBinaryView.cs index 3220cce..f4700cf 100644 --- a/Handle/BNBinaryView.cs +++ b/Handle/BNBinaryView.cs @@ -208,6 +208,38 @@ public ulong Length return result; } + /// Loads a binary view from a file stored in a Binary Ninja project. + /// The project file to load. + /// Whether to update analysis before returning. + /// JSON load options accepted by the core. + /// Optional progress callback. + /// The loaded view, or null when the core cannot load the project file. + public static BinaryView? LoadFile( + ProjectFile projectFile, + bool updateAnalysis = false, + string options = "", + ProgressDelegate? progress = null + ) + { + if (null == projectFile) + { + throw new ArgumentNullException(nameof(projectFile)); + } + + ProgressCallbackContext progressContext = new ProgressCallbackContext(progress); + NativeDelegates.BNProgressFunction nativeProgress = progressContext.Invoke; + IntPtr result = NativeMethods.BNLoadProjectFile( + projectFile.DangerousGetHandle(), + updateAnalysis, + options ?? string.Empty, + Marshal.GetFunctionPointerForDelegate(nativeProgress), + IntPtr.Zero + ); + GC.KeepAlive(nativeProgress); + progressContext.ThrowIfFailed(); + return BinaryView.TakeHandle(result); + } + public static BinaryView? OpenExisting(string filename , ProgressDelegate? progress = null) { FileMetadata file = new FileMetadata(filename); diff --git a/Handle/BNType.cs b/Handle/BNType.cs index bcf1d63..46c8740 100644 --- a/Handle/BNType.cs +++ b/Handle/BNType.cs @@ -100,6 +100,16 @@ public BinaryNinja.Type Duplicate() NativeMethods.BNDuplicateType(this.handle) ); } + + /// + /// Marks whether this type is expected to remain resident so the core can omit it from + /// memory-usage accounting. The type itself is returned for fluent use. + /// + public BinaryNinja.Type SetIgnored(bool ignored) + { + NativeMethods.BNTypeSetIgnored(this.handle, ignored); + return this; + } public static string GetNameTypeString( NameType classFunctionType )