libwz 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/binding.gyp +149 -0
- package/deps/tiny-aes/.github/workflows/c-cpp.yml +27 -0
- package/deps/tiny-aes/CMakeLists.txt +17 -0
- package/deps/tiny-aes/Makefile +61 -0
- package/deps/tiny-aes/README.md +83 -0
- package/deps/tiny-aes/aes.c +572 -0
- package/deps/tiny-aes/aes.h +91 -0
- package/deps/tiny-aes/aes.hpp +12 -0
- package/deps/tiny-aes/conanfile.py +73 -0
- package/deps/tiny-aes/library.json +19 -0
- package/deps/tiny-aes/library.properties +11 -0
- package/deps/tiny-aes/test.c +316 -0
- package/deps/tiny-aes/test.cpp +2 -0
- package/deps/tiny-aes/test_package/CMakeLists.txt +11 -0
- package/deps/tiny-aes/test_package/conanfile.py +17 -0
- package/deps/tiny-aes/unlicense.txt +24 -0
- package/deps/zlib/.cmake-format.yaml +245 -0
- package/deps/zlib/.github/workflows/c-std.yml +268 -0
- package/deps/zlib/.github/workflows/cmake.yml +147 -0
- package/deps/zlib/.github/workflows/configure.yml +146 -0
- package/deps/zlib/.github/workflows/contribs.yml +64 -0
- package/deps/zlib/.github/workflows/fuzz.yml +25 -0
- package/deps/zlib/.github/workflows/msys-cygwin.yml +92 -0
- package/deps/zlib/.github/workflows/others.yml +153 -0
- package/deps/zlib/BUILD.bazel +134 -0
- package/deps/zlib/CMakeLists.txt +310 -0
- package/deps/zlib/ChangeLog +1669 -0
- package/deps/zlib/FAQ +371 -0
- package/deps/zlib/INDEX +67 -0
- package/deps/zlib/LICENSE +22 -0
- package/deps/zlib/MODULE.bazel +9 -0
- package/deps/zlib/Makefile.in +426 -0
- package/deps/zlib/README +115 -0
- package/deps/zlib/README-cmake.md +79 -0
- package/deps/zlib/adler32.c +164 -0
- package/deps/zlib/amiga/Makefile.pup +69 -0
- package/deps/zlib/amiga/Makefile.sas +68 -0
- package/deps/zlib/compress.c +99 -0
- package/deps/zlib/configure +1078 -0
- package/deps/zlib/contrib/CMakeLists.txt +61 -0
- package/deps/zlib/contrib/README.contrib +57 -0
- package/deps/zlib/contrib/ada/CMakeLists.txt +217 -0
- package/deps/zlib/contrib/ada/buffer_demo.adb +106 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADACompiler.cmake.in +23 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADAInformation.cmake +133 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeDetermineADACompiler.cmake +33 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeTestADACompiler.cmake +46 -0
- package/deps/zlib/contrib/ada/cmake/binder_helper.cmake +47 -0
- package/deps/zlib/contrib/ada/cmake/compile_helper.cmake +32 -0
- package/deps/zlib/contrib/ada/cmake/exe_link_helper.cmake +53 -0
- package/deps/zlib/contrib/ada/cmake/shared_link_helper.cmake +52 -0
- package/deps/zlib/contrib/ada/cmake/static_link_helper.cmake +25 -0
- package/deps/zlib/contrib/ada/mtest.adb +156 -0
- package/deps/zlib/contrib/ada/read.adb +156 -0
- package/deps/zlib/contrib/ada/readme.txt +65 -0
- package/deps/zlib/contrib/ada/test.adb +463 -0
- package/deps/zlib/contrib/ada/zlib-streams.adb +225 -0
- package/deps/zlib/contrib/ada/zlib-streams.ads +114 -0
- package/deps/zlib/contrib/ada/zlib-thin.adb +142 -0
- package/deps/zlib/contrib/ada/zlib-thin.ads +450 -0
- package/deps/zlib/contrib/ada/zlib.adb +701 -0
- package/deps/zlib/contrib/ada/zlib.ads +328 -0
- package/deps/zlib/contrib/ada/zlib.gpr +20 -0
- package/deps/zlib/contrib/blast/CMakeLists.txt +166 -0
- package/deps/zlib/contrib/blast/Makefile +14 -0
- package/deps/zlib/contrib/blast/README +4 -0
- package/deps/zlib/contrib/blast/blast-test.c +42 -0
- package/deps/zlib/contrib/blast/blast.c +422 -0
- package/deps/zlib/contrib/blast/blast.h +84 -0
- package/deps/zlib/contrib/blast/blastConfig.cmake.in +18 -0
- package/deps/zlib/contrib/blast/test/CMakeLists.txt +193 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/blast/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test.pk +0 -0
- package/deps/zlib/contrib/blast/test.txt +1 -0
- package/deps/zlib/contrib/blast/tester.cmake +28 -0
- package/deps/zlib/contrib/crc32vx/CMakeLists.txt +67 -0
- package/deps/zlib/contrib/crc32vx/README +9 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx.c +254 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx_hooks.h +9 -0
- package/deps/zlib/contrib/delphi/ZLib.pas +557 -0
- package/deps/zlib/contrib/delphi/ZLibConst.pas +11 -0
- package/deps/zlib/contrib/delphi/readme.txt +76 -0
- package/deps/zlib/contrib/delphi/zlibd32.mak +99 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs +202 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs +83 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CodecBase.cs +198 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Deflater.cs +106 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.cs +288 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj +141 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/GZipStream.cs +301 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Inflater.cs +105 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/UnitTests.cs +274 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.build +33 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.chm +0 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.sln +21 -0
- package/deps/zlib/contrib/dotzlib/LICENSE_1_0.txt +23 -0
- package/deps/zlib/contrib/dotzlib/readme.txt +58 -0
- package/deps/zlib/contrib/gcc_gvmat64/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/gcc_gvmat64/gvmat64.S +570 -0
- package/deps/zlib/contrib/infback9/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/infback9/README +1 -0
- package/deps/zlib/contrib/infback9/infback9.c +603 -0
- package/deps/zlib/contrib/infback9/infback9.h +37 -0
- package/deps/zlib/contrib/infback9/inffix9.h +107 -0
- package/deps/zlib/contrib/infback9/inflate9.h +47 -0
- package/deps/zlib/contrib/infback9/inftree9.c +319 -0
- package/deps/zlib/contrib/infback9/inftree9.h +61 -0
- package/deps/zlib/contrib/iostream/test.cpp +24 -0
- package/deps/zlib/contrib/iostream/zfstream.cpp +329 -0
- package/deps/zlib/contrib/iostream/zfstream.h +128 -0
- package/deps/zlib/contrib/iostream2/zstream.h +306 -0
- package/deps/zlib/contrib/iostream2/zstream_test.cpp +25 -0
- package/deps/zlib/contrib/iostream3/CMakeLists.txt +200 -0
- package/deps/zlib/contrib/iostream3/README +35 -0
- package/deps/zlib/contrib/iostream3/TODO +17 -0
- package/deps/zlib/contrib/iostream3/iostream3Config.cmake.in +23 -0
- package/deps/zlib/contrib/iostream3/test/CMakeLists.txt +191 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/iostream3/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test.cc +50 -0
- package/deps/zlib/contrib/iostream3/zfstream.cc +479 -0
- package/deps/zlib/contrib/iostream3/zfstream.h +466 -0
- package/deps/zlib/contrib/minizip/CMakeLists.txt +387 -0
- package/deps/zlib/contrib/minizip/LICENSE.Info-Zip +58 -0
- package/deps/zlib/contrib/minizip/Makefile +33 -0
- package/deps/zlib/contrib/minizip/Makefile.am +45 -0
- package/deps/zlib/contrib/minizip/MiniZip64_Changes.txt +6 -0
- package/deps/zlib/contrib/minizip/MiniZip64_info.txt +69 -0
- package/deps/zlib/contrib/minizip/configure.ac +32 -0
- package/deps/zlib/contrib/minizip/crypt.h +125 -0
- package/deps/zlib/contrib/minizip/ints.h +57 -0
- package/deps/zlib/contrib/minizip/ioapi.c +231 -0
- package/deps/zlib/contrib/minizip/ioapi.h +183 -0
- package/deps/zlib/contrib/minizip/iowin32.c +447 -0
- package/deps/zlib/contrib/minizip/iowin32.h +27 -0
- package/deps/zlib/contrib/minizip/make_vms.com +25 -0
- package/deps/zlib/contrib/minizip/miniunz.c +647 -0
- package/deps/zlib/contrib/minizip/miniunzip.1 +63 -0
- package/deps/zlib/contrib/minizip/minizip.1 +46 -0
- package/deps/zlib/contrib/minizip/minizip.c +511 -0
- package/deps/zlib/contrib/minizip/minizip.pc.in +13 -0
- package/deps/zlib/contrib/minizip/minizip.pc.txt +13 -0
- package/deps/zlib/contrib/minizip/minizipConfig.cmake.in +27 -0
- package/deps/zlib/contrib/minizip/mztools.c +294 -0
- package/deps/zlib/contrib/minizip/mztools.h +37 -0
- package/deps/zlib/contrib/minizip/skipset.h +366 -0
- package/deps/zlib/contrib/minizip/test/CMakeLists.txt +176 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/contrib/minizip/test/find_package_no_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_wrong_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/test_helper.cm +32 -0
- package/deps/zlib/contrib/minizip/unzip.c +1984 -0
- package/deps/zlib/contrib/minizip/unzip.h +442 -0
- package/deps/zlib/contrib/minizip/zip.c +2246 -0
- package/deps/zlib/contrib/minizip/zip.h +371 -0
- package/deps/zlib/contrib/nuget/nuget.csproj +45 -0
- package/deps/zlib/contrib/nuget/nuget.sln +22 -0
- package/deps/zlib/contrib/pascal/example.pas +599 -0
- package/deps/zlib/contrib/pascal/readme.txt +76 -0
- package/deps/zlib/contrib/pascal/zlibd32.mak +99 -0
- package/deps/zlib/contrib/pascal/zlibpas.pas +276 -0
- package/deps/zlib/contrib/puff/CMakeLists.txt +154 -0
- package/deps/zlib/contrib/puff/Makefile +42 -0
- package/deps/zlib/contrib/puff/README +63 -0
- package/deps/zlib/contrib/puff/bin-writer.c +26 -0
- package/deps/zlib/contrib/puff/puff.c +840 -0
- package/deps/zlib/contrib/puff/puff.h +35 -0
- package/deps/zlib/contrib/puff/puffConfig.cmake.in +18 -0
- package/deps/zlib/contrib/puff/pufftest.c +168 -0
- package/deps/zlib/contrib/puff/test/CMakeLists.txt +262 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_exclude_test.cmake.in +26 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/puff/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/tester-cov.cmake +58 -0
- package/deps/zlib/contrib/puff/test/tester.cmake +16 -0
- package/deps/zlib/contrib/puff/zeros.raw +0 -0
- package/deps/zlib/contrib/testzlib/CMakeLists.txt +44 -0
- package/deps/zlib/contrib/testzlib/testzlib.c +275 -0
- package/deps/zlib/contrib/testzlib/testzlib.txt +10 -0
- package/deps/zlib/contrib/vstudio/readme.txt +22 -0
- package/deps/zlib/contrib/zlib1-dll/CMakeLists.txt +196 -0
- package/deps/zlib/contrib/zlib1-dll/readme.txt +21 -0
- package/deps/zlib/crc32.c +983 -0
- package/deps/zlib/crc32.h +9446 -0
- package/deps/zlib/deflate.c +2185 -0
- package/deps/zlib/deflate.h +383 -0
- package/deps/zlib/doc/algorithm.txt +209 -0
- package/deps/zlib/doc/crc-doc.1.0.pdf +0 -0
- package/deps/zlib/doc/rfc1950.txt +619 -0
- package/deps/zlib/doc/rfc1951.txt +955 -0
- package/deps/zlib/doc/rfc1952.txt +675 -0
- package/deps/zlib/doc/txtvsbin.txt +107 -0
- package/deps/zlib/examples/README.examples +54 -0
- package/deps/zlib/examples/enough.c +597 -0
- package/deps/zlib/examples/fitblk.c +233 -0
- package/deps/zlib/examples/gun.c +702 -0
- package/deps/zlib/examples/gzappend.c +504 -0
- package/deps/zlib/examples/gzjoin.c +449 -0
- package/deps/zlib/examples/gzlog.c +1061 -0
- package/deps/zlib/examples/gzlog.h +91 -0
- package/deps/zlib/examples/gznorm.c +474 -0
- package/deps/zlib/examples/zlib_how.html +550 -0
- package/deps/zlib/examples/zpipe.c +206 -0
- package/deps/zlib/examples/zran.c +546 -0
- package/deps/zlib/examples/zran.h +53 -0
- package/deps/zlib/gzclose.c +23 -0
- package/deps/zlib/gzguts.h +216 -0
- package/deps/zlib/gzlib.c +609 -0
- package/deps/zlib/gzread.c +668 -0
- package/deps/zlib/gzwrite.c +700 -0
- package/deps/zlib/infback.c +581 -0
- package/deps/zlib/inffast.c +321 -0
- package/deps/zlib/inffast.h +11 -0
- package/deps/zlib/inffixed.h +94 -0
- package/deps/zlib/inflate.c +1413 -0
- package/deps/zlib/inflate.h +126 -0
- package/deps/zlib/inftrees.c +424 -0
- package/deps/zlib/inftrees.h +64 -0
- package/deps/zlib/make_vms.com +867 -0
- package/deps/zlib/msdos/Makefile.bor +115 -0
- package/deps/zlib/msdos/Makefile.dj2 +104 -0
- package/deps/zlib/msdos/Makefile.emx +69 -0
- package/deps/zlib/msdos/Makefile.msc +112 -0
- package/deps/zlib/msdos/Makefile.tc +100 -0
- package/deps/zlib/os400/README400 +48 -0
- package/deps/zlib/os400/bndsrc +144 -0
- package/deps/zlib/os400/make.sh +383 -0
- package/deps/zlib/os400/zlibfixed.rpgle +578 -0
- package/deps/zlib/os400/zlibfree.rpgle +634 -0
- package/deps/zlib/qnx/package.qpg +141 -0
- package/deps/zlib/test/CMakeLists.txt +318 -0
- package/deps/zlib/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/test/example.c +552 -0
- package/deps/zlib/test/find_package_no_components_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_wrong_components_test.cmake.in +27 -0
- package/deps/zlib/test/infcover.c +672 -0
- package/deps/zlib/test/minigzip.c +592 -0
- package/deps/zlib/treebuild.xml +116 -0
- package/deps/zlib/trees.c +1119 -0
- package/deps/zlib/trees.h +128 -0
- package/deps/zlib/uncompr.c +101 -0
- package/deps/zlib/watcom/watcom_f.mak +43 -0
- package/deps/zlib/watcom/watcom_l.mak +43 -0
- package/deps/zlib/win32/DLL_FAQ.txt +381 -0
- package/deps/zlib/win32/Makefile.bor +109 -0
- package/deps/zlib/win32/Makefile.gcc +177 -0
- package/deps/zlib/win32/Makefile.msc +159 -0
- package/deps/zlib/win32/README-WIN32.txt +103 -0
- package/deps/zlib/win32/VisualC.txt +3 -0
- package/deps/zlib/win32/zlib.def +104 -0
- package/deps/zlib/win32/zlib1.rc +37 -0
- package/deps/zlib/zconf.h.in +551 -0
- package/deps/zlib/zlib.3 +149 -0
- package/deps/zlib/zlib.3.pdf +0 -0
- package/deps/zlib/zlib.h +2057 -0
- package/deps/zlib/zlib.map +116 -0
- package/deps/zlib/zlib.pc.cmakein +14 -0
- package/deps/zlib/zlib.pc.in +14 -0
- package/deps/zlib/zlibConfig.cmake.in +18 -0
- package/deps/zlib/zutil.c +313 -0
- package/deps/zlib/zutil.h +331 -0
- package/dist/index.d.ts +266 -0
- package/dist/index.js +1146 -0
- package/dist/libwz.js +5632 -0
- package/dist/libwz.wasm +0 -0
- package/include/wz/CRC32.h +182 -0
- package/include/wz/PngUtility.h +72 -0
- package/include/wz/PortalType.h +124 -0
- package/include/wz/Properties/WzBinaryProperty.h +70 -0
- package/include/wz/Properties/WzCanvasProperty.h +55 -0
- package/include/wz/Properties/WzConvexProperty.h +34 -0
- package/include/wz/Properties/WzDoubleProperty.h +32 -0
- package/include/wz/Properties/WzFloatProperty.h +30 -0
- package/include/wz/Properties/WzIntProperty.h +30 -0
- package/include/wz/Properties/WzLongProperty.h +30 -0
- package/include/wz/Properties/WzLuaProperty.h +31 -0
- package/include/wz/Properties/WzNullProperty.h +15 -0
- package/include/wz/Properties/WzPngProperty.h +53 -0
- package/include/wz/Properties/WzRawDataProperty.h +46 -0
- package/include/wz/Properties/WzShortProperty.h +31 -0
- package/include/wz/Properties/WzStringProperty.h +32 -0
- package/include/wz/Properties/WzSubProperty.h +35 -0
- package/include/wz/Properties/WzUOLProperty.h +44 -0
- package/include/wz/Properties/WzVectorProperty.h +40 -0
- package/include/wz/Properties/WzVideoProperty.h +43 -0
- package/include/wz/Result.h +58 -0
- package/include/wz/Util/Defines.h +16 -0
- package/include/wz/Util/ListFileParser.h +20 -0
- package/include/wz/Util/WzBinaryReader.h +95 -0
- package/include/wz/Util/WzBinaryWriter.h +72 -0
- package/include/wz/Util/WzBlobDataSource.h +30 -0
- package/include/wz/Util/WzDataSource.h +49 -0
- package/include/wz/Util/WzKeyGenerator.h +28 -0
- package/include/wz/Util/WzMutableKey.h +39 -0
- package/include/wz/Util/WzPath.h +37 -0
- package/include/wz/Util/WzStream.h +86 -0
- package/include/wz/Util/WzTool.h +42 -0
- package/include/wz/WzAESConstant.h +17 -0
- package/include/wz/WzDirectory.h +97 -0
- package/include/wz/WzEnums.h +76 -0
- package/include/wz/WzFile.h +99 -0
- package/include/wz/WzHeader.h +47 -0
- package/include/wz/WzImage.h +97 -0
- package/include/wz/WzImageProperty.h +92 -0
- package/include/wz/WzObject.h +55 -0
- package/include/wz/WzPropertyCollection.h +115 -0
- package/include/wz/wz.h +41 -0
- package/include/wz/wz_api.h +432 -0
- package/package.json +93 -0
- package/src/PngUtility.cpp +328 -0
- package/src/Properties/WzBinaryProperty.cpp +183 -0
- package/src/Properties/WzCanvasProperty.cpp +262 -0
- package/src/Properties/WzConvexProperty.cpp +159 -0
- package/src/Properties/WzDoubleProperty.cpp +12 -0
- package/src/Properties/WzFloatProperty.cpp +17 -0
- package/src/Properties/WzIntProperty.cpp +12 -0
- package/src/Properties/WzLongProperty.cpp +12 -0
- package/src/Properties/WzLuaProperty.cpp +37 -0
- package/src/Properties/WzNullProperty.cpp +11 -0
- package/src/Properties/WzPngProperty.cpp +637 -0
- package/src/Properties/WzRawDataProperty.cpp +116 -0
- package/src/Properties/WzShortProperty.cpp +12 -0
- package/src/Properties/WzStringProperty.cpp +44 -0
- package/src/Properties/WzSubProperty.cpp +129 -0
- package/src/Properties/WzUOLProperty.cpp +136 -0
- package/src/Properties/WzVectorProperty.cpp +22 -0
- package/src/Properties/WzVideoProperty.cpp +115 -0
- package/src/Util/ListFileParser.cpp +48 -0
- package/src/Util/WzBinaryReader.cpp +368 -0
- package/src/Util/WzBinaryWriter.cpp +305 -0
- package/src/Util/WzBlobDataSource.cpp +47 -0
- package/src/Util/WzDataSource.cpp +61 -0
- package/src/Util/WzKeyGenerator.cpp +43 -0
- package/src/Util/WzMutableKey.cpp +59 -0
- package/src/Util/WzStream.cpp +196 -0
- package/src/Util/WzTool.cpp +266 -0
- package/src/WzAESConstant.cpp +12 -0
- package/src/WzDirectory.cpp +669 -0
- package/src/WzEnums.cpp +20 -0
- package/src/WzFile.cpp +450 -0
- package/src/WzImage.cpp +350 -0
- package/src/WzImageProperty.cpp +469 -0
- package/src/WzObject.cpp +174 -0
- package/src/WzPropertyCollection.cpp +84 -0
- package/src/capi/wz_api.cpp +1996 -0
- package/src/node/binding.cpp +1776 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#include "wz/Util/WzDataSource.h"
|
|
2
|
+
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
#include <cstring>
|
|
5
|
+
#include <utility>
|
|
6
|
+
|
|
7
|
+
namespace wz {
|
|
8
|
+
|
|
9
|
+
WzFileDataSource::WzFileDataSource(WzFileStream* input)
|
|
10
|
+
: input_(input),
|
|
11
|
+
size_(input_ && input_->Size() > 0 ? static_cast<uint64_t>(input_->Size())
|
|
12
|
+
: 0) {}
|
|
13
|
+
|
|
14
|
+
Result<size_t> WzFileDataSource::ReadAt(uint64_t offset,
|
|
15
|
+
std::span<uint8_t> destination) {
|
|
16
|
+
if (!input_ || !input_->IsOpen()) {
|
|
17
|
+
return std::unexpected(Error::IoError("Source file is not open"));
|
|
18
|
+
}
|
|
19
|
+
if (offset > size_) {
|
|
20
|
+
return std::unexpected(Error::IoError("Read offset is beyond source size"));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const uint64_t available = size_ - offset;
|
|
24
|
+
const size_t count = static_cast<size_t>(
|
|
25
|
+
std::min<uint64_t>(available, static_cast<uint64_t>(destination.size())));
|
|
26
|
+
if (count == 0) return 0;
|
|
27
|
+
|
|
28
|
+
if (!input_->Seek(static_cast<int64_t>(offset), WzSeekOrigin::Begin)) {
|
|
29
|
+
return std::unexpected(Error::IoError("Failed to seek source file"));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (input_->Read(destination.data(), count) != count) {
|
|
33
|
+
return std::unexpected(Error::IoError("Failed to read source file"));
|
|
34
|
+
}
|
|
35
|
+
return count;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
uint64_t WzFileDataSource::Size() const {
|
|
39
|
+
return size_;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
WzMemoryDataSource::WzMemoryDataSource(std::vector<uint8_t> data)
|
|
43
|
+
: data_(std::move(data)) {}
|
|
44
|
+
|
|
45
|
+
Result<size_t> WzMemoryDataSource::ReadAt(uint64_t offset,
|
|
46
|
+
std::span<uint8_t> destination) {
|
|
47
|
+
if (offset > data_.size()) {
|
|
48
|
+
return std::unexpected(Error::IoError("Read offset is beyond source size"));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const size_t index = static_cast<size_t>(offset);
|
|
52
|
+
const size_t count = std::min(destination.size(), data_.size() - index);
|
|
53
|
+
if (count > 0) std::memcpy(destination.data(), data_.data() + index, count);
|
|
54
|
+
return count;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
uint64_t WzMemoryDataSource::Size() const {
|
|
58
|
+
return data_.size();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
} // namespace wz
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#include "wz/Util/WzKeyGenerator.h"
|
|
2
|
+
#include "wz/WzAESConstant.h"
|
|
3
|
+
|
|
4
|
+
namespace wz {
|
|
5
|
+
|
|
6
|
+
const std::array<uint8_t, 128> MAPLESTORY_USERKEY_DEFAULT = {
|
|
7
|
+
0x13, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00,
|
|
8
|
+
0x5B, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
|
9
|
+
0x10, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
|
10
|
+
0x02, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00,
|
|
11
|
+
0xB4, 0x00, 0x00, 0x00, 0x4B, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00,
|
|
12
|
+
0x05, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00,
|
|
13
|
+
0x5F, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00,
|
|
14
|
+
0x50, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00,
|
|
15
|
+
0x33, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
16
|
+
0x09, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0xDE, 0x00, 0x00, 0x00,
|
|
17
|
+
0xC7, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00};
|
|
18
|
+
|
|
19
|
+
std::array<uint8_t, 32> GetTrimmedUserKey(
|
|
20
|
+
const std::array<uint8_t, 128>& userKey) {
|
|
21
|
+
std::array<uint8_t, 32> key{};
|
|
22
|
+
for (int i = 0; i < 128; i += 16) {
|
|
23
|
+
key[i / 4] = userKey[i];
|
|
24
|
+
}
|
|
25
|
+
return key;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
WzMutableKey WzKeyGenerator::GenerateWzKey(const std::array<uint8_t, 4>& WzIv) {
|
|
29
|
+
return WzMutableKey(WzIv, GetTrimmedUserKey(MAPLESTORY_USERKEY_DEFAULT));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
WzMutableKey WzKeyGenerator::GenerateLuaWzKey() {
|
|
33
|
+
return WzMutableKey(WzAESConstant::WZ_MSEAIV,
|
|
34
|
+
GetTrimmedUserKey(MAPLESTORY_USERKEY_DEFAULT));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
WzMutableKey WzKeyGenerator::GenerateWzKey(
|
|
38
|
+
const std::array<uint8_t, 4>& WzIv,
|
|
39
|
+
const std::array<uint8_t, 128>& AesUserKey) {
|
|
40
|
+
return WzMutableKey(WzIv, GetTrimmedUserKey(AesUserKey));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
} // namespace wz
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#include "wz/Util/WzMutableKey.h"
|
|
2
|
+
#include <cstring>
|
|
3
|
+
#include <aes.hpp>
|
|
4
|
+
|
|
5
|
+
namespace wz {
|
|
6
|
+
|
|
7
|
+
WzMutableKey::WzMutableKey(const std::array<uint8_t, 4>& iv,
|
|
8
|
+
const std::array<uint8_t, 32>& aesKey)
|
|
9
|
+
: iv_(iv), aesKey_(aesKey) {}
|
|
10
|
+
|
|
11
|
+
uint8_t WzMutableKey::operator[](size_t index) const {
|
|
12
|
+
const_cast<WzMutableKey*>(this)->EnsureKeySize(index + 1);
|
|
13
|
+
return keys_[index];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
std::vector<uint8_t> WzMutableKey::GetKeys() const {
|
|
17
|
+
if (keys_.empty()) return {};
|
|
18
|
+
return {keys_.begin(), keys_.begin() + std::min(size_t(4), keys_.size())};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
void WzMutableKey::EnsureKeySize(size_t size) {
|
|
22
|
+
if (!keys_.empty() && keys_.size() >= size) return;
|
|
23
|
+
|
|
24
|
+
size = ((size + BatchSize - 1) / BatchSize) * BatchSize;
|
|
25
|
+
std::vector<uint8_t> newKeys(size, 0);
|
|
26
|
+
|
|
27
|
+
if (iv_[0] == 0 && iv_[1] == 0 && iv_[2] == 0 && iv_[3] == 0) {
|
|
28
|
+
keys_ = std::move(newKeys);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
size_t startIndex = 0;
|
|
33
|
+
if (!keys_.empty()) {
|
|
34
|
+
std::copy(keys_.begin(), keys_.end(), newKeys.begin());
|
|
35
|
+
startIndex = keys_.size();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
struct AES_ctx ctx;
|
|
39
|
+
AES_init_ctx(&ctx, aesKey_.data());
|
|
40
|
+
|
|
41
|
+
uint8_t block[16];
|
|
42
|
+
for (size_t i = startIndex; i < size; i += 16) {
|
|
43
|
+
if (i == 0) {
|
|
44
|
+
for (int j = 0; j < 16; j++) block[j] = iv_[j % 4];
|
|
45
|
+
} else {
|
|
46
|
+
std::memcpy(block, newKeys.data() + i - 16, 16);
|
|
47
|
+
}
|
|
48
|
+
AES_ECB_encrypt(&ctx, block);
|
|
49
|
+
std::memcpy(newKeys.data() + i, block, 16);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
keys_ = std::move(newKeys);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
bool WzMutableKey::operator==(const WzMutableKey& other) const {
|
|
56
|
+
return iv_ == other.iv_ && aesKey_ == other.aesKey_;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
} // namespace wz
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
#include "wz/Util/WzStream.h"
|
|
2
|
+
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
#include <cstring>
|
|
5
|
+
#include <limits>
|
|
6
|
+
#include <utility>
|
|
7
|
+
|
|
8
|
+
namespace wz {
|
|
9
|
+
|
|
10
|
+
namespace {
|
|
11
|
+
|
|
12
|
+
FILE* OpenFilePath(const std::filesystem::path& path, const char* mode) {
|
|
13
|
+
#ifdef _WIN32
|
|
14
|
+
std::wstring wideMode;
|
|
15
|
+
for (const char* p = mode; *p != '\0'; ++p) {
|
|
16
|
+
wideMode.push_back(static_cast<wchar_t>(*p));
|
|
17
|
+
}
|
|
18
|
+
return _wfopen(path.wstring().c_str(), wideMode.c_str());
|
|
19
|
+
#else
|
|
20
|
+
return std::fopen(path.string().c_str(), mode);
|
|
21
|
+
#endif
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
int SeekOriginToC(WzSeekOrigin origin) {
|
|
25
|
+
switch (origin) {
|
|
26
|
+
case WzSeekOrigin::Begin:
|
|
27
|
+
return SEEK_SET;
|
|
28
|
+
case WzSeekOrigin::Current:
|
|
29
|
+
return SEEK_CUR;
|
|
30
|
+
case WzSeekOrigin::End:
|
|
31
|
+
return SEEK_END;
|
|
32
|
+
}
|
|
33
|
+
return SEEK_SET;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
bool FileSeek(FILE* file, int64_t offset, WzSeekOrigin origin) {
|
|
37
|
+
#ifdef _WIN32
|
|
38
|
+
return _fseeki64(file, offset, SeekOriginToC(origin)) == 0;
|
|
39
|
+
#else
|
|
40
|
+
return fseeko(file, static_cast<off_t>(offset), SeekOriginToC(origin)) == 0;
|
|
41
|
+
#endif
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
int64_t FileTell(FILE* file) {
|
|
45
|
+
#ifdef _WIN32
|
|
46
|
+
return static_cast<int64_t>(_ftelli64(file));
|
|
47
|
+
#else
|
|
48
|
+
return static_cast<int64_t>(ftello(file));
|
|
49
|
+
#endif
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
} // namespace
|
|
53
|
+
|
|
54
|
+
bool WzStream::WriteByte(uint8_t value) {
|
|
55
|
+
return Write(&value, sizeof(value));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
WzFileStream::WzFileStream(const std::filesystem::path& path,
|
|
59
|
+
const char* mode) {
|
|
60
|
+
Open(path, mode);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
WzFileStream::~WzFileStream() {
|
|
64
|
+
Close();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
WzFileStream::WzFileStream(WzFileStream&& other) noexcept
|
|
68
|
+
: file_(other.file_), size_(other.size_) {
|
|
69
|
+
other.file_ = nullptr;
|
|
70
|
+
other.size_ = 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
WzFileStream& WzFileStream::operator=(WzFileStream&& other) noexcept {
|
|
74
|
+
if (this != &other) {
|
|
75
|
+
Close();
|
|
76
|
+
file_ = other.file_;
|
|
77
|
+
size_ = other.size_;
|
|
78
|
+
other.file_ = nullptr;
|
|
79
|
+
other.size_ = 0;
|
|
80
|
+
}
|
|
81
|
+
return *this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
bool WzFileStream::Open(const std::filesystem::path& path, const char* mode) {
|
|
85
|
+
Close();
|
|
86
|
+
file_ = OpenFilePath(path, mode);
|
|
87
|
+
if (!file_) {
|
|
88
|
+
size_ = 0;
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
return RefreshSize();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
void WzFileStream::Close() {
|
|
95
|
+
if (file_) {
|
|
96
|
+
std::fclose(file_);
|
|
97
|
+
file_ = nullptr;
|
|
98
|
+
}
|
|
99
|
+
size_ = 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
size_t WzFileStream::Read(void* destination, size_t count) {
|
|
103
|
+
if (!file_ || count == 0) return 0;
|
|
104
|
+
return std::fread(destination, 1, count, file_);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
bool WzFileStream::Write(const void* data, size_t count) {
|
|
108
|
+
if (!file_) return false;
|
|
109
|
+
if (count == 0) return true;
|
|
110
|
+
if (std::fwrite(data, 1, count, file_) != count) return false;
|
|
111
|
+
const int64_t position = Position();
|
|
112
|
+
if (position > size_) size_ = position;
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
bool WzFileStream::Seek(int64_t offset, WzSeekOrigin origin) {
|
|
117
|
+
return file_ && FileSeek(file_, offset, origin);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
int64_t WzFileStream::Position() const {
|
|
121
|
+
if (!file_) return -1;
|
|
122
|
+
return FileTell(file_);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
bool WzFileStream::Flush() {
|
|
126
|
+
return file_ && std::fflush(file_) == 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
bool WzFileStream::RefreshSize() {
|
|
130
|
+
if (!file_) return false;
|
|
131
|
+
const int64_t original = Position();
|
|
132
|
+
if (original < 0) return false;
|
|
133
|
+
if (!Seek(0, WzSeekOrigin::End)) return false;
|
|
134
|
+
size_ = Position();
|
|
135
|
+
return Seek(original, WzSeekOrigin::Begin);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
WzMemoryStream::WzMemoryStream(std::vector<uint8_t> data)
|
|
139
|
+
: buffer_(std::move(data)) {}
|
|
140
|
+
|
|
141
|
+
size_t WzMemoryStream::Read(void* destination, size_t count) {
|
|
142
|
+
if (count == 0 || position_ < 0) return 0;
|
|
143
|
+
const int64_t size = Size();
|
|
144
|
+
if (position_ >= size) return 0;
|
|
145
|
+
const size_t available = static_cast<size_t>(size - position_);
|
|
146
|
+
const size_t toRead = std::min(count, available);
|
|
147
|
+
std::memcpy(destination, buffer_.data() + position_, toRead);
|
|
148
|
+
position_ += static_cast<int64_t>(toRead);
|
|
149
|
+
return toRead;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
bool WzMemoryStream::Write(const void* data, size_t count) {
|
|
153
|
+
if (position_ < 0) return false;
|
|
154
|
+
if (count == 0) return true;
|
|
155
|
+
if (count >
|
|
156
|
+
static_cast<size_t>(std::numeric_limits<int64_t>::max() - position_)) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
const int64_t end = position_ + static_cast<int64_t>(count);
|
|
160
|
+
if (end > Size()) {
|
|
161
|
+
buffer_.resize(static_cast<size_t>(end));
|
|
162
|
+
}
|
|
163
|
+
std::memcpy(buffer_.data() + position_, data, count);
|
|
164
|
+
position_ = end;
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
bool WzMemoryStream::Seek(int64_t offset, WzSeekOrigin origin) {
|
|
169
|
+
int64_t base = 0;
|
|
170
|
+
switch (origin) {
|
|
171
|
+
case WzSeekOrigin::Begin:
|
|
172
|
+
base = 0;
|
|
173
|
+
break;
|
|
174
|
+
case WzSeekOrigin::Current:
|
|
175
|
+
base = position_;
|
|
176
|
+
break;
|
|
177
|
+
case WzSeekOrigin::End:
|
|
178
|
+
base = Size();
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
if ((offset > 0 && base > std::numeric_limits<int64_t>::max() - offset) ||
|
|
182
|
+
(offset < 0 && base < std::numeric_limits<int64_t>::min() - offset)) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
const int64_t next = base + offset;
|
|
186
|
+
if (next < 0) return false;
|
|
187
|
+
position_ = next;
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
void WzMemoryStream::Close() {
|
|
192
|
+
buffer_.clear();
|
|
193
|
+
position_ = 0;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
} // namespace wz
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
#include "wz/Util/WzTool.h"
|
|
2
|
+
#include <memory>
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <unordered_set>
|
|
5
|
+
#include "wz/Util/WzPath.h"
|
|
6
|
+
#include "wz/Util/WzStream.h"
|
|
7
|
+
#include "wz/WzAESConstant.h"
|
|
8
|
+
#include "wz/WzDirectory.h"
|
|
9
|
+
#include "wz/WzFile.h"
|
|
10
|
+
#include "wz/WzImage.h"
|
|
11
|
+
|
|
12
|
+
#ifdef _WIN32
|
|
13
|
+
#ifndef WIN32_LEAN_AND_MEAN
|
|
14
|
+
#define WIN32_LEAN_AND_MEAN
|
|
15
|
+
#endif
|
|
16
|
+
#include <windows.h>
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
namespace wz {
|
|
20
|
+
|
|
21
|
+
namespace {
|
|
22
|
+
|
|
23
|
+
std::unordered_set<std::string> objectValueLengthCache;
|
|
24
|
+
|
|
25
|
+
struct EncodedStringInfo {
|
|
26
|
+
bool needsUnicode = false;
|
|
27
|
+
int utf16CodeUnits = 0;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
EncodedStringInfo GetEncodedStringInfo(const std::string& value) {
|
|
31
|
+
EncodedStringInfo result;
|
|
32
|
+
for (size_t i = 0; i < value.size();) {
|
|
33
|
+
uint8_t ch = static_cast<uint8_t>(value[i]);
|
|
34
|
+
uint32_t codePoint = 0;
|
|
35
|
+
size_t extraBytes = 0;
|
|
36
|
+
|
|
37
|
+
if ((ch & 0x80) == 0) {
|
|
38
|
+
codePoint = ch;
|
|
39
|
+
} else if ((ch & 0xE0) == 0xC0) {
|
|
40
|
+
codePoint = ch & 0x1F;
|
|
41
|
+
extraBytes = 1;
|
|
42
|
+
} else if ((ch & 0xF0) == 0xE0) {
|
|
43
|
+
codePoint = ch & 0x0F;
|
|
44
|
+
extraBytes = 2;
|
|
45
|
+
} else if ((ch & 0xF8) == 0xF0) {
|
|
46
|
+
codePoint = ch & 0x07;
|
|
47
|
+
extraBytes = 3;
|
|
48
|
+
} else {
|
|
49
|
+
result.needsUnicode = result.needsUnicode || ch > INT8_MAX;
|
|
50
|
+
++result.utf16CodeUnits;
|
|
51
|
+
++i;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (i + extraBytes >= value.size()) {
|
|
56
|
+
result.needsUnicode = result.needsUnicode || ch > INT8_MAX;
|
|
57
|
+
++result.utf16CodeUnits;
|
|
58
|
+
++i;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
bool valid = true;
|
|
63
|
+
for (size_t j = 1; j <= extraBytes; ++j) {
|
|
64
|
+
uint8_t next = static_cast<uint8_t>(value[i + j]);
|
|
65
|
+
if ((next & 0xC0) != 0x80) {
|
|
66
|
+
valid = false;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
codePoint = (codePoint << 6) | (next & 0x3F);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!valid) {
|
|
73
|
+
result.needsUnicode = result.needsUnicode || ch > INT8_MAX;
|
|
74
|
+
++result.utf16CodeUnits;
|
|
75
|
+
++i;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
result.needsUnicode = result.needsUnicode || codePoint > INT8_MAX;
|
|
80
|
+
result.utf16CodeUnits += codePoint <= 0xFFFF ? 1 : 2;
|
|
81
|
+
i += extraBytes + 1;
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
} // namespace
|
|
87
|
+
|
|
88
|
+
#ifdef _WIN32
|
|
89
|
+
std::filesystem::path WzTool::ToPath(const std::string& utf8_path) {
|
|
90
|
+
if (utf8_path.empty()) return {};
|
|
91
|
+
// MB_ERR_INVALID_CHARS: fails if the input is not valid UTF-8.
|
|
92
|
+
// This lets us detect and fall back to ANSI (GBK etc.) gracefully.
|
|
93
|
+
int n = MultiByteToWideChar(CP_UTF8,
|
|
94
|
+
MB_ERR_INVALID_CHARS,
|
|
95
|
+
utf8_path.c_str(),
|
|
96
|
+
static_cast<int>(utf8_path.size()),
|
|
97
|
+
nullptr,
|
|
98
|
+
0);
|
|
99
|
+
if (n <= 0) {
|
|
100
|
+
// Not valid UTF-8 — treat as system ANSI code page
|
|
101
|
+
return std::filesystem::path(utf8_path);
|
|
102
|
+
}
|
|
103
|
+
std::wstring w(static_cast<size_t>(n), L'\0');
|
|
104
|
+
MultiByteToWideChar(CP_UTF8,
|
|
105
|
+
0,
|
|
106
|
+
utf8_path.c_str(),
|
|
107
|
+
static_cast<int>(utf8_path.size()),
|
|
108
|
+
&w[0],
|
|
109
|
+
n);
|
|
110
|
+
return std::filesystem::path(w);
|
|
111
|
+
}
|
|
112
|
+
#endif
|
|
113
|
+
|
|
114
|
+
uint32_t WzTool::RotateLeft(uint32_t x, uint8_t n) {
|
|
115
|
+
n &= 0x1F;
|
|
116
|
+
if (n == 0) return x;
|
|
117
|
+
return static_cast<uint32_t>((x << n) | (x >> (32 - n)));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
uint32_t WzTool::RotateRight(uint32_t x, uint8_t n) {
|
|
121
|
+
n &= 0x1F;
|
|
122
|
+
if (n == 0) return x;
|
|
123
|
+
return static_cast<uint32_t>((x >> n) | (x << (32 - n)));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
int WzTool::GetCompressedIntLength(int i) {
|
|
127
|
+
if (i > 127 || i < -127) return 5;
|
|
128
|
+
return 1;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
int WzTool::GetEncodedStringLength(const std::string& s) {
|
|
132
|
+
if (s.empty()) return 1;
|
|
133
|
+
|
|
134
|
+
EncodedStringInfo info = GetEncodedStringInfo(s);
|
|
135
|
+
int length =
|
|
136
|
+
info.needsUnicode ? info.utf16CodeUnits : static_cast<int>(s.length());
|
|
137
|
+
int prefixLength = length > (info.needsUnicode ? 126 : 127) ? 5 : 1;
|
|
138
|
+
int encodedLength = info.needsUnicode ? info.utf16CodeUnits * 2
|
|
139
|
+
: static_cast<int>(s.length());
|
|
140
|
+
return prefixLength + encodedLength;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
int WzTool::GetWzObjectValueLength(const std::string& s, uint8_t type) {
|
|
144
|
+
std::string storeName = std::to_string(type) + "_" + s;
|
|
145
|
+
if (s.length() > 4 && objectValueLengthCache.contains(storeName)) {
|
|
146
|
+
return 5;
|
|
147
|
+
}
|
|
148
|
+
objectValueLengthCache.insert(std::move(storeName));
|
|
149
|
+
return 1 + GetEncodedStringLength(s);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
void WzTool::ClearWzObjectValueLengthCache() {
|
|
153
|
+
objectValueLengthCache.clear();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
std::array<uint8_t, 4> WzTool::GetIvByMapleVersion(WzMapleVersion ver) {
|
|
157
|
+
switch (ver) {
|
|
158
|
+
case WzMapleVersion::EMS:
|
|
159
|
+
return WzAESConstant::WZ_MSEAIV;
|
|
160
|
+
case WzMapleVersion::GMS:
|
|
161
|
+
return WzAESConstant::WZ_GMSIV;
|
|
162
|
+
case WzMapleVersion::GENERATE:
|
|
163
|
+
return {0, 0, 0, 0};
|
|
164
|
+
case WzMapleVersion::BMS:
|
|
165
|
+
case WzMapleVersion::CLASSIC:
|
|
166
|
+
case WzMapleVersion::CUSTOM:
|
|
167
|
+
default:
|
|
168
|
+
return WzAESConstant::WZ_BMSCLASSIC;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
int WzTool::GetRecognizedCharacters(const std::string& source) {
|
|
173
|
+
int count = 0;
|
|
174
|
+
for (char c : source) {
|
|
175
|
+
if (c >= 0x20 && c <= 0x7E) count++;
|
|
176
|
+
}
|
|
177
|
+
return count;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
double WzTool::GetDecryptionSuccessRate(const std::string& wzPath,
|
|
181
|
+
WzMapleVersion encVersion,
|
|
182
|
+
int16_t* version) {
|
|
183
|
+
std::unique_ptr<WzFile> wzf;
|
|
184
|
+
if (version == nullptr || *version == 0) {
|
|
185
|
+
wzf = std::make_unique<WzFile>(wzPath, encVersion);
|
|
186
|
+
} else {
|
|
187
|
+
wzf = std::make_unique<WzFile>(wzPath, *version, encVersion);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
WzFileParseStatus parseStatus = wzf->ParseWzFile();
|
|
191
|
+
if (parseStatus != WzFileParseStatus::Success) {
|
|
192
|
+
return 0.0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (version) *version = wzf->Version();
|
|
196
|
+
int recognizedChars = 0;
|
|
197
|
+
int totalChars = 0;
|
|
198
|
+
WzDirectory* wzDir = wzf->GetWzDirectory();
|
|
199
|
+
if (wzDir) {
|
|
200
|
+
for (WzDirectory* d : wzDir->WzDirectories()) {
|
|
201
|
+
recognizedChars += GetRecognizedCharacters(d->Name());
|
|
202
|
+
totalChars += static_cast<int>(d->Name().length());
|
|
203
|
+
}
|
|
204
|
+
for (WzImage* img : wzDir->WzImages()) {
|
|
205
|
+
recognizedChars += GetRecognizedCharacters(img->Name());
|
|
206
|
+
totalChars += static_cast<int>(img->Name().length());
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (totalChars == 0) return 0.0;
|
|
210
|
+
return static_cast<double>(recognizedChars) / static_cast<double>(totalChars);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
WzMapleVersion WzTool::DetectMapleVersion(const std::string& wzFilePath,
|
|
214
|
+
int16_t* fileVersion) {
|
|
215
|
+
int16_t version = 0;
|
|
216
|
+
double gmsRate =
|
|
217
|
+
GetDecryptionSuccessRate(wzFilePath, WzMapleVersion::GMS, &version);
|
|
218
|
+
double emsRate =
|
|
219
|
+
GetDecryptionSuccessRate(wzFilePath, WzMapleVersion::EMS, &version);
|
|
220
|
+
double bmsRate =
|
|
221
|
+
GetDecryptionSuccessRate(wzFilePath, WzMapleVersion::BMS, &version);
|
|
222
|
+
|
|
223
|
+
if (fileVersion) *fileVersion = version;
|
|
224
|
+
|
|
225
|
+
WzMapleVersion bestVersion = WzMapleVersion::GMS;
|
|
226
|
+
double maxRate = 0;
|
|
227
|
+
if (gmsRate > maxRate) {
|
|
228
|
+
maxRate = gmsRate;
|
|
229
|
+
bestVersion = WzMapleVersion::GMS;
|
|
230
|
+
}
|
|
231
|
+
if (emsRate > maxRate) {
|
|
232
|
+
maxRate = emsRate;
|
|
233
|
+
bestVersion = WzMapleVersion::EMS;
|
|
234
|
+
}
|
|
235
|
+
if (bmsRate > maxRate) {
|
|
236
|
+
maxRate = bmsRate;
|
|
237
|
+
bestVersion = WzMapleVersion::BMS;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (maxRate < 0.7) {
|
|
241
|
+
std::string zlzPath =
|
|
242
|
+
(wz::to_path(wzFilePath).parent_path() / "ZLZ.dll").string();
|
|
243
|
+
if (std::filesystem::exists(wz::to_path(zlzPath)))
|
|
244
|
+
return WzMapleVersion::GETFROMZLZ;
|
|
245
|
+
}
|
|
246
|
+
return bestVersion;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
bool WzTool::IsListFile(const std::string& path) {
|
|
250
|
+
WzFileStream reader;
|
|
251
|
+
if (!reader.Open(wz::to_path(path), "rb")) return false;
|
|
252
|
+
int32_t header = 0;
|
|
253
|
+
if (reader.Read(&header, sizeof(header)) != sizeof(header)) return false;
|
|
254
|
+
return header != WZ_HEADER;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
bool WzTool::IsDataWzHotfixFile(const std::string& path) {
|
|
258
|
+
WzFileStream reader;
|
|
259
|
+
if (!reader.Open(wz::to_path(path), "rb")) return false;
|
|
260
|
+
uint8_t firstByte = 0;
|
|
261
|
+
if (reader.Read(&firstByte, sizeof(firstByte)) != sizeof(firstByte))
|
|
262
|
+
return false;
|
|
263
|
+
return firstByte == WzImage::WzImageHeaderByte_WithoutOffset;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
} // namespace wz
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#include "wz/WzAESConstant.h"
|
|
2
|
+
|
|
3
|
+
namespace wz {
|
|
4
|
+
|
|
5
|
+
const std::array<uint8_t, 4> WzAESConstant::WZ_GMSIV = {0x4D, 0x23, 0xC7, 0x2B};
|
|
6
|
+
const std::array<uint8_t, 4> WzAESConstant::WZ_MSEAIV = {
|
|
7
|
+
0xB9, 0x7D, 0x63, 0xE9};
|
|
8
|
+
const std::array<uint8_t, 4> WzAESConstant::WZ_BMSCLASSIC = {
|
|
9
|
+
0x00, 0x00, 0x00, 0x00};
|
|
10
|
+
const uint32_t WzAESConstant::WZ_OffsetConstant = 0x581C3F6D;
|
|
11
|
+
|
|
12
|
+
} // namespace wz
|