diff --git a/SevenZip/LibraryManager.BinaryResource.cs b/SevenZip/LibraryManager.BinaryResource.cs
index d7a0f65..3a2aa9d 100644
--- a/SevenZip/LibraryManager.BinaryResource.cs
+++ b/SevenZip/LibraryManager.BinaryResource.cs
@@ -196,6 +196,6 @@
_ => [],
};
""")]
-partial class LibraryManager
+partial class SevenZipLibraryManager
{
}
\ No newline at end of file
diff --git a/SevenZip/LibraryManager.cs b/SevenZip/LibraryManager.cs
index 317954e..d579f4c 100644
--- a/SevenZip/LibraryManager.cs
+++ b/SevenZip/LibraryManager.cs
@@ -289,7 +289,7 @@ public static bool ModifyCapable
private static unsafe bool ExtractionBenchmark(string archiveFileName, Stream outStream, ref LibraryFeature? features, LibraryFeature testedFeature)
{
- var bytes = LibraryManager.GetManifestResource(archiveFileName, "arch");
+ var bytes = SevenZipLibraryManager.GetManifestResource(archiveFileName, "arch");
var bytes_span = bytes.AsSpan();
bytes_span.Reverse();
fixed (byte* ptr = bytes)
diff --git a/SevenZip/SevenZipSfx.cs b/SevenZip/SevenZipSfx.cs
index d52c223..469166e 100644
--- a/SevenZip/SevenZipSfx.cs
+++ b/SevenZip/SevenZipSfx.cs
@@ -179,7 +179,7 @@ private static SfxModule GetModuleByName(string name)
/// The resource name for xsd definitions
private unsafe void LoadCommandsFromResource(string xmlDefinitions_xml, string xmlDefinitions_xsd)
{
- var bytes_cfg = LibraryManager.GetManifestResource(xmlDefinitions_xml, "sfx");
+ var bytes_cfg = SevenZipLibraryManager.GetManifestResource(xmlDefinitions_xml, "sfx");
var bytes_cfg_span = bytes_cfg.AsSpan();
bytes_cfg_span.Reverse();
fixed (byte* ptr_cfg = bytes_cfg)
@@ -194,7 +194,7 @@ private unsafe void LoadCommandsFromResource(string xmlDefinitions_xml, string x
using UnmanagedMemoryStream cfg = new(ptr_cfg, bytes_cfg.Length);
- var bytes_schm = LibraryManager.GetManifestResource(xmlDefinitions_xsd, "sfx");
+ var bytes_schm = SevenZipLibraryManager.GetManifestResource(xmlDefinitions_xsd, "sfx");
var bytes_schm_span = bytes_schm.AsSpan();
bytes_schm_span.Reverse();
fixed (byte* ptr_schm = bytes_schm)
@@ -435,7 +435,7 @@ public void MakeSfx(Stream archive, SfxSettings settings, string sfxFileName)
/// The archive stream.
/// The sfx settings.
/// The stream to write the self-extracting executable to.
- public void MakeSfx(Stream archive, SfxSettings settings, Stream sfxStream)
+ public unsafe void MakeSfx(Stream archive, SfxSettings settings, Stream sfxStream)
{
if (!sfxStream.CanWrite)
{
@@ -444,9 +444,20 @@ public void MakeSfx(Stream archive, SfxSettings settings, Stream sfxStream)
ValidateSettings(settings);
- using (var sfx = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetResourceString(SfxSupportedModuleNames[SfxModule][0])))
+ var bytes_sfx = SevenZipLibraryManager.GetManifestResource(SfxSupportedModuleNames[SfxModule][0], "sfx");
+ var bytes_sfx_span = bytes_sfx.AsSpan();
+ bytes_sfx_span.Reverse();
+ fixed (byte* ptr_sfx = bytes_sfx)
{
- WriteStream(sfx, sfxStream);
+ try
+ {
+ using UnmanagedMemoryStream sfx = new(ptr_sfx, bytes_sfx.Length);
+ WriteStream(sfx, sfxStream);
+ }
+ finally
+ {
+ bytes_sfx_span.Clear();
+ }
}
if (SfxModule == SfxModule.Custom || _sfxCommands[SfxModule] != null)