Fix SevenZipLibraryManager.LoadLibrary

This commit is contained in:
YoshiRulz 2019-10-14 00:51:44 +10:00
parent 7df71f2c86
commit 462bd891af
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 44 additions and 44 deletions

View File

@ -147,18 +147,20 @@ namespace SevenZip
#if !WINCE && !MONO
if (_modulePtr == IntPtr.Zero)
{
//zero 29-oct-2012 - this check isnt useful since LoadLibrary can pretty much check for the same thing. and it wrecks our dll relocation scheme
//zero 29-oct-2012 - this check isnt useful since LoadOrNull can pretty much check for the same thing. and it wrecks our dll relocation scheme
//if (!File.Exists(_libraryFileName))
//{
// throw new SevenZipLibraryException("DLL file does not exist.");
//}
if ((_modulePtr = libLoader.LoadOrNull(_libraryFileName).Value) == IntPtr.Zero)
var newPtr = libLoader.LoadOrNull(_libraryFileName);
if (!newPtr.HasValue)
{
//try a different directory
string alternateFilename = Path.Combine(Path.Combine(Path.GetDirectoryName(_libraryFileName),"dll"),"7z.dll");
if ((_modulePtr = libLoader.LoadOrNull(_libraryFileName).Value) == IntPtr.Zero)
throw new SevenZipLibraryException("failed to load library.");
newPtr = libLoader.LoadOrNull(Path.Combine(Path.Combine(Path.GetDirectoryName(_libraryFileName), "dll"), "7z.dll"));
if (!newPtr.HasValue) throw new SevenZipLibraryException("failed to load library.");
}
_modulePtr = newPtr.Value;
if (libLoader.GetProcAddr(_modulePtr, "GetHandlerProperty") == IntPtr.Zero)
{
libLoader.FreeByPtr(_modulePtr);
@ -178,10 +180,8 @@ namespace SevenZip
return;
}
#endif
throw new ArgumentException(
"Enum " + format + " is not a valid archive format attribute!");
throw new ArgumentException("Enum " + format + " is not a valid archive format attribute!");
}
}
/*/// <summary>