/// <summary> /// Creates a <see cref="ModuleDefMD"/> instance from a byte[] /// </summary> /// <param name="data">Contents of a .NET module/assembly</param> /// <param name="context">Module context or <c>null</c></param> /// <returns>A new <see cref="ModuleDefMD"/> instance</returns> public static ModuleDefMD Load(byte[] data, ModuleContext context) { DotNetFile dnFile = null; try { return Load(dnFile = DotNetFile.Load(data), context); } catch { if (dnFile != null) dnFile.Dispose(); throw; } }
/// <summary> /// Creates a <see cref="ModuleDefMD"/> instance from a memory location /// </summary> /// <param name="addr">Address of a .NET module/assembly</param> /// <param name="context">Module context or <c>null</c></param> /// <param name="imageLayout">Image layout of the file in memory</param> /// <returns>A new <see cref="ModuleDefMD"/> instance</returns> public static ModuleDefMD Load(IntPtr addr, ModuleContext context, ImageLayout imageLayout) { DotNetFile dnFile = null; try { return Load(dnFile = DotNetFile.Load(addr, imageLayout), context); } catch { if (dnFile != null) dnFile.Dispose(); throw; } }
/// <summary> /// Creates a <see cref="ModuleDefMD"/> instance from a file /// </summary> /// <param name="fileName">File name of an existing .NET module/assembly</param> /// <param name="context">Module context or <c>null</c></param> /// <returns>A new <see cref="ModuleDefMD"/> instance</returns> public static ModuleDefMD Load(string fileName, ModuleContext context) { DotNetFile dnFile = null; try { return Load(dnFile = DotNetFile.Load(fileName), context); } catch { if (dnFile != null) dnFile.Dispose(); throw; } }