From a932af940fcbe18b4ec8f503dd2c8d6d31bc36d0 Mon Sep 17 00:00:00 2001 From: Sunny Date: Sun, 12 Feb 2023 13:48:30 +0800 Subject: [PATCH] =?UTF-8?q?*=20FastLZ:=20=E4=BF=AE=E6=94=B9=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Common/UFastLZ.cs | 13 ++++++++++++- SunnyUI/Win32/Win32.Kernel.cs | 12 +++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/SunnyUI/Common/UFastLZ.cs b/SunnyUI/Common/UFastLZ.cs index fb676a3a..12c4e309 100644 --- a/SunnyUI/Common/UFastLZ.cs +++ b/SunnyUI/Common/UFastLZ.cs @@ -129,6 +129,7 @@ namespace Sunny.UI /// 压缩结果 public static byte[] Compress(byte[] input, int begin, int length) { + CheckFastLZDll(); byte[] output = new byte[Math.Max(length * 2, 66)]; fixed (void* pSrc1 = &input[begin]) fixed (void* pSrc2 = output) @@ -150,6 +151,7 @@ namespace Sunny.UI /// 压缩结果 public static byte[] Compress(FastLZCompressionLevel level, byte[] input, int begin, int length) { + CheckFastLZDll(); byte[] output = new byte[Math.Max(length * 2, 66)]; fixed (void* pSrc1 = &input[begin]) fixed (void* pSrc2 = output) @@ -171,6 +173,7 @@ namespace Sunny.UI /// 解压缩结果 public static byte[] Decompress(byte[] input, int begin, int length, int maxout) { + CheckFastLZDll(); byte[] output = new byte[maxout + 66]; fixed (byte* pSrc1 = &input[begin]) fixed (byte* pSrc2 = output) @@ -198,6 +201,7 @@ namespace Sunny.UI /// 压缩结果 public static byte[] CompressEx(byte[] input, int begin, int length, DateTime dateTime, int index) { + CheckFastLZDll(); byte[] result = CompressEx(input, begin, length); if (result.Length > 0) { @@ -221,6 +225,7 @@ namespace Sunny.UI /// 压缩结果 public static byte[] CompressEx(byte[] input, int begin, int length) { + CheckFastLZDll(); byte[] result = new byte[0]; if (begin + length > input.Length) return result; byte[] output = new byte[Math.Max(length * 2, 66)]; @@ -257,6 +262,7 @@ namespace Sunny.UI /// 解压缩结果 public static byte[] DecompressEx(byte[] input, int begin, int length) { + CheckFastLZDll(); byte[] result = new byte[0]; if (input.Length <= 2 + ExHeadAllLength + ExTailAllLength) return result; if (begin + length > input.Length) return result; @@ -287,6 +293,7 @@ namespace Sunny.UI /// 解压缩结果 public static byte[] DecompressEx(byte[] input, int begin, int length, out DateTime datetime, out int index) { + CheckFastLZDll(); byte[] result = DecompressEx(input, begin, length); datetime = Jan1st1970; @@ -300,8 +307,11 @@ namespace Sunny.UI return result; } + private static bool FileExist = false; + public static bool CheckFastLZDll() { + if (FileExist) return true; if (File.Exists(DirEx.CurrentDir() + "FastLZx86.dll") && File.Exists(DirEx.CurrentDir() + "FastLZx64.dll")) return true; try @@ -314,7 +324,8 @@ namespace Sunny.UI return false; } - return File.Exists(DirEx.CurrentDir() + "FastLZx86.dll") && File.Exists(DirEx.CurrentDir() + "FastLZx64.dll"); + FileExist = File.Exists(DirEx.CurrentDir() + "FastLZx86.dll") && File.Exists(DirEx.CurrentDir() + "FastLZx64.dll"); + return FileExist; } /// diff --git a/SunnyUI/Win32/Win32.Kernel.cs b/SunnyUI/Win32/Win32.Kernel.cs index d4f8c3b6..1013b02c 100644 --- a/SunnyUI/Win32/Win32.Kernel.cs +++ b/SunnyUI/Win32/Win32.Kernel.cs @@ -1521,7 +1521,17 @@ namespace Sunny.UI.Win32 public const int DOMAIN_GROUP_RID_USERS = 0x201; public const int DOMAIN_USER_RID_ADMIN = 0x1F4; public const int DOMAIN_USER_RID_GUEST = 0x1F5; - public const int DONT_RESOLVE_DLL_REFERENCES = 0x1; + public const int DONT_RESOLVE_DLL_REFERENCES = 0x00000001; + public const int LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010; + public const int LOAD_LIBRARY_AS_DATAFILE = 0x00000002; + public const int LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040; + public const int LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020; + public const int LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x00000200; + public const int LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000; + public const int LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x00000100; + public const int LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800; + public const int LOAD_LIBRARY_SEARCH_USER_DIRS = 0x00000400; + public const int LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008; public const int DOUBLE_CLICK = 0x2; public const int DRIVE_CDROM = 5; public const int DRIVE_FIXED = 3;