├── README.md ├── .gitignore ├── XArchive.pro ├── 3rdparty ├── lzma │ ├── src │ │ ├── Precomp.h │ │ ├── Aes.h │ │ └── Lzma2Dec.h │ ├── lzma.pri │ ├── lzma.pro │ ├── CMakeLists.txt │ └── include │ │ ├── Ppmd.h │ │ └── Ppmd7.h ├── ppmd │ ├── ppmd.pri │ ├── ppmd.pro │ ├── CMakeLists.txt │ └── src │ │ ├── RotateDefs.h │ │ ├── Precomp.h │ │ └── Ppmd8.h ├── zlib │ ├── zlib.pri │ ├── src │ │ ├── inffast.h │ │ └── inftrees.h │ ├── zlib.pro │ └── CMakeLists.txt ├── bzip2 │ ├── bzip2.pri │ ├── bzip2.pro │ ├── CMakeLists.txt │ └── src │ │ ├── LICENSE │ │ └── randtable.c └── lzfse │ ├── lzfse.pri │ ├── lzfse.pro │ └── src │ ├── LICENSE │ ├── lzvn_decode_base.h │ ├── lzfse_decode.c │ └── lzfse_tunables.h ├── CMakeLists.txt ├── xarchives.pri ├── xarchives.cmake ├── LICENSE ├── Algos ├── xlzwdecoder.h ├── xstoredecoder.h ├── xascii85decoder.h ├── xbzip2decoder.h ├── ximplodedecoder.h ├── xlzssdecoder.h ├── xshrinkdecoder.h ├── xreducedecoder.h ├── xppmddecoder.h ├── xit214decoder.h ├── xlzmadecoder.h ├── xsha256decoder.h ├── xaesdecoder.h ├── xdeflatedecoder.h ├── xzipcryptodecoder.h ├── xppmdrangedecoder.h ├── xppmd7model.h ├── xppmdmodel.h ├── xstoredecoder.cpp ├── xzipaesdecoder.h ├── xppmdrangedecoder.cpp ├── xbzip2decoder.cpp ├── xppmdmodel.cpp └── xppmd7model.cpp ├── xipa.h ├── xapks.h ├── xipa.cpp ├── xdeb.h ├── xnpm.h ├── xcompresseddevice.h ├── xtgz.h ├── xjar.h ├── xdecompress.h ├── xtgz.cpp ├── xdos16.h ├── xapk.h ├── xapks.cpp ├── xlha.h ├── xnpm.cpp ├── xzlib.h ├── xdeb.cpp ├── xbzip2.h ├── xmachofat.h ├── xszdd.h ├── xsquashfs.h ├── xgzip.h ├── xlzip.h ├── xcompresseddevice.cpp ├── x_ar.h ├── xarchive.pri ├── xxz.h ├── xarchives.h └── xjar.cpp /README.md: -------------------------------------------------------------------------------- 1 | # XArchive 2 | Archives formats 3 | 4 | * ZIP 5 | * MACHOFAT 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 3rdparty/zlib/libs 2 | 3rdparty/lzfse/libs 3 | 3rdparty/lzma/libs 4 | 3rdparty/zlib/libs 5 | -------------------------------------------------------------------------------- /XArchive.pro: -------------------------------------------------------------------------------- 1 | # build libs 2 | TEMPLATE = subdirs 3 | SUBDIRS += 3rdparty/bzip2 4 | SUBDIRS += 3rdparty/lzma 5 | SUBDIRS += 3rdparty/ppmd 6 | SUBDIRS += 3rdparty/zlib 7 | #SUBDIRS += 3rdparty/lzfse -------------------------------------------------------------------------------- /3rdparty/lzma/src/Precomp.h: -------------------------------------------------------------------------------- 1 | /* Precomp.h -- StdAfx 2 | 2013-11-12 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_PRECOMP_H 5 | #define __7Z_PRECOMP_H 6 | 7 | #include "Compiler.h" 8 | /* #include "7zTypes.h" */ 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(XArchive) 4 | 5 | add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/bzip2) 6 | add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/lzma) 7 | add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/ppmd) 8 | add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/zlib) 9 | -------------------------------------------------------------------------------- /3rdparty/ppmd/ppmd.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD/src 2 | DEPENDPATH += $$PWD/src 3 | 4 | win32-g++ { 5 | LIBS += $$PWD/libs/libppmd-win-$${QT_ARCH}.a 6 | } 7 | win32-msvc* { 8 | LIBS += $$PWD/libs/ppmd-win-$${QT_ARCH}.lib 9 | } 10 | unix:!macx { 11 | LIBS += $$PWD/libs/libppmd-unix-$${QT_ARCH}.a 12 | } 13 | unix:macx { 14 | LIBS += $$PWD/libs/libppmd-macos-$${QT_ARCH}.a 15 | } 16 | -------------------------------------------------------------------------------- /xarchives.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | HEADERS += \ 5 | $$PWD/xarchives.h 6 | 7 | SOURCES += \ 8 | $$PWD/xarchives.cpp 9 | 10 | !contains(XCONFIG, xarchive) { 11 | XCONFIG += xarchive 12 | include(xarchive.pri) 13 | } 14 | 15 | DISTFILES += \ 16 | $$PWD/LICENSE \ 17 | $$PWD/README.md \ 18 | $$PWD/xarchives.cmake 19 | -------------------------------------------------------------------------------- /3rdparty/lzma/lzma.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD/src 2 | DEPENDPATH += $$PWD/src 3 | 4 | win32-g++ { 5 | LIBS += $$PWD/libs/liblzma-win-$${QT_ARCH}.a 6 | } 7 | win32-msvc* { 8 | LIBS += $$PWD/libs/lzma-win-$${QT_ARCH}.lib 9 | } 10 | unix:!macx { 11 | LIBS += $$PWD/libs/liblzma-unix-$${QT_ARCH}.a 12 | } 13 | unix:macx { 14 | LIBS += $$PWD/libs/liblzma-macos-$${QT_ARCH}.a 15 | } 16 | -------------------------------------------------------------------------------- /3rdparty/zlib/zlib.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD/src 2 | DEPENDPATH += $$PWD/src 3 | 4 | win32-g++ { 5 | LIBS += $$PWD/libs/libzlib-win-$${QT_ARCH}.a 6 | } 7 | win32-msvc* { 8 | LIBS += $$PWD/libs/zlib-win-$${QT_ARCH}.lib 9 | } 10 | unix:!macx { 11 | LIBS += $$PWD/libs/libzlib-unix-$${QT_ARCH}.a 12 | } 13 | unix:macx { 14 | LIBS += $$PWD/libs/libzlib-macos-$${QT_ARCH}.a 15 | } 16 | -------------------------------------------------------------------------------- /3rdparty/bzip2/bzip2.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD/src 2 | DEPENDPATH += $$PWD/src 3 | 4 | win32-g++ { 5 | LIBS += $$PWD/libs/libbzip2-win-$${QT_ARCH}.a 6 | } 7 | win32-msvc* { 8 | LIBS += $$PWD/libs/bzip2-win-$${QT_ARCH}.lib 9 | } 10 | unix:!macx { 11 | LIBS += $$PWD/libs/libbzip2-unix-$${QT_ARCH}.a 12 | } 13 | unix:macx { 14 | LIBS += $$PWD/libs/libbzip2-macos-$${QT_ARCH}.a 15 | } 16 | -------------------------------------------------------------------------------- /xarchives.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | if (NOT DEFINED XARCHIVE_SOURCES) 4 | include(${CMAKE_CURRENT_LIST_DIR}/xarchive.cmake) 5 | set(XARCHIVES_SOURCES ${XARCHIVES_SOURCES} ${XARCHIVE_SOURCES}) 6 | endif() 7 | 8 | set(XARCHIVES_SOURCES 9 | ${XARCHIVES_SOURCES} 10 | ${CMAKE_CURRENT_LIST_DIR}/xarchives.cpp 11 | ${CMAKE_CURRENT_LIST_DIR}/xarchives.h 12 | ) 13 | -------------------------------------------------------------------------------- /3rdparty/zlib/src/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /3rdparty/lzma/lzma.pro: -------------------------------------------------------------------------------- 1 | QT -= core gui 2 | 3 | TARGET = lzma 4 | TEMPLATE = lib 5 | CONFIG += staticlib 6 | 7 | INCLUDEPATH += $$PWD/lzma 8 | DEPENDPATH += $$PWD/lzma 9 | 10 | include(../../build.pri) 11 | 12 | win32{ 13 | TARGET = lzma-win-$${QT_ARCH} 14 | } 15 | unix:!macx { 16 | TARGET = lzma-unix-$${QT_ARCH} 17 | } 18 | unix:macx { 19 | TARGET = lzma-macos-$${QT_ARCH} 20 | } 21 | 22 | SOURCES += \ 23 | $$PWD/src/LzmaDec.c \ 24 | $$PWD/src/Lzma2Dec.c 25 | 26 | TARGETLIB_PATH = $$PWD 27 | 28 | DESTDIR=$${TARGETLIB_PATH}/libs 29 | -------------------------------------------------------------------------------- /3rdparty/ppmd/ppmd.pro: -------------------------------------------------------------------------------- 1 | QT -= core gui 2 | 3 | TARGET = ppmd 4 | TEMPLATE = lib 5 | CONFIG += staticlib 6 | 7 | INCLUDEPATH += $$PWD/src 8 | DEPENDPATH += $$PWD/src 9 | 10 | include(../../build.pri) 11 | 12 | win32{ 13 | TARGET = ppmd-win-$${QT_ARCH} 14 | } 15 | unix:!macx { 16 | TARGET = ppmd-unix-$${QT_ARCH} 17 | } 18 | unix:macx { 19 | TARGET = ppmd-macos-$${QT_ARCH} 20 | } 21 | 22 | SOURCES += \ 23 | $$PWD/src/Ppmd7.c \ 24 | $$PWD/src/Ppmd7Dec.c \ 25 | $$PWD/src/Ppmd8.c \ 26 | $$PWD/src/Ppmd8Dec.c 27 | 28 | HEADERS += \ 29 | $$PWD/src/Ppmd8.h 30 | 31 | TARGETLIB_PATH = $$PWD 32 | 33 | DESTDIR=$${TARGETLIB_PATH}/libs 34 | -------------------------------------------------------------------------------- /3rdparty/lzma/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(lzma LANGUAGES C) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_CXX_STANDARD 11) 7 | set(CMAKE_C_STANDARD 11) 8 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 9 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 10 | 11 | include_directories(${PROJECT_SOURCE_DIR}/src/) 12 | 13 | add_library(lzma STATIC 14 | ${PROJECT_SOURCE_DIR}/src/LzmaDec.c 15 | ${PROJECT_SOURCE_DIR}/src/Lzma2Dec.c 16 | ) 17 | 18 | set_target_properties(lzma PROPERTIES LINKER_LANGUAGE C) 19 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 20 | 21 | if(MSVC) 22 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 23 | endif() 24 | -------------------------------------------------------------------------------- /3rdparty/ppmd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(ppmd LANGUAGES C) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_CXX_STANDARD 11) 7 | set(CMAKE_C_STANDARD 11) 8 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 9 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 10 | 11 | include_directories(${PROJECT_SOURCE_DIR}/src/) 12 | 13 | add_library(ppmd STATIC 14 | ${PROJECT_SOURCE_DIR}/src/Ppmd7.c 15 | ${PROJECT_SOURCE_DIR}/src/Ppmd7Dec.c 16 | ${PROJECT_SOURCE_DIR}/src/Ppmd8.c 17 | ${PROJECT_SOURCE_DIR}/src/Ppmd8Dec.c 18 | ) 19 | 20 | set_target_properties(ppmd PROPERTIES LINKER_LANGUAGE C) 21 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 22 | 23 | if(MSVC) 24 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 25 | endif() 26 | -------------------------------------------------------------------------------- /3rdparty/zlib/zlib.pro: -------------------------------------------------------------------------------- 1 | QT -= core gui 2 | 3 | TARGET = zlib 4 | TEMPLATE = lib 5 | CONFIG += staticlib 6 | 7 | INCLUDEPATH += $$PWD/zlib 8 | DEPENDPATH += $$PWD/zlib 9 | 10 | include(../../build.pri) 11 | 12 | win32{ 13 | TARGET = zlib-win-$${QT_ARCH} 14 | } 15 | unix:!macx { 16 | TARGET = zlib-unix-$${QT_ARCH} 17 | } 18 | unix:macx { 19 | TARGET = zlib-macos-$${QT_ARCH} 20 | } 21 | 22 | SOURCES += \ 23 | $$PWD/src/deflate.c \ 24 | $$PWD/src/inflate.c \ 25 | $$PWD/src/adler32.c \ 26 | $$PWD/src/crc32.c \ 27 | $$PWD/src/inffast.c \ 28 | $$PWD/src/inftrees.c \ 29 | $$PWD/src/trees.c \ 30 | $$PWD/src/zutil.c 31 | 32 | TARGETLIB_PATH = $$PWD 33 | 34 | DESTDIR=$${TARGETLIB_PATH}/libs -------------------------------------------------------------------------------- /3rdparty/bzip2/bzip2.pro: -------------------------------------------------------------------------------- 1 | QT -= core gui 2 | 3 | TARGET = bzip2 4 | TEMPLATE = lib 5 | CONFIG += staticlib 6 | 7 | INCLUDEPATH += $$PWD/bzip2 8 | DEPENDPATH += $$PWD/bzip2 9 | 10 | include(../../build.pri) 11 | 12 | win32{ 13 | TARGET = bzip2-win-$${QT_ARCH} 14 | } 15 | unix:!macx { 16 | TARGET = bzip2-unix-$${QT_ARCH} 17 | } 18 | unix:macx { 19 | TARGET = bzip2-macos-$${QT_ARCH} 20 | } 21 | 22 | SOURCES += \ 23 | $$PWD/src/bzip2.c \ 24 | $$PWD/src/crctable.c \ 25 | $$PWD/src/bzlib.c \ 26 | $$PWD/src/compress.c \ 27 | $$PWD/src/decompress.c \ 28 | $$PWD/src/blocksort.c \ 29 | $$PWD/src/randtable.c \ 30 | $$PWD/src/huffman.c 31 | 32 | TARGETLIB_PATH = $$PWD 33 | 34 | DESTDIR=$${TARGETLIB_PATH}/libs 35 | -------------------------------------------------------------------------------- /3rdparty/lzfse/lzfse.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD/src 2 | DEPENDPATH += $$PWD/src 3 | 4 | win32-g++ { 5 | contains(QT_ARCH, i386) { 6 | LIBS += $$PWD/libs/win32-g++/liblzfse.a 7 | } else { 8 | LIBS += $$PWD/libs/win64-g++/liblzfse.a 9 | } 10 | } 11 | win32-msvc* { 12 | contains(QMAKE_TARGET.arch, x86_64) { 13 | LIBS += $$PWD/libs/win64-msvc/lzfse.lib 14 | } else { 15 | LIBS += $$PWD/libs/win32-msvc/lzfse.lib 16 | } 17 | } 18 | unix:!macx { 19 | BITSIZE = $$system(getconf LONG_BIT) 20 | if (contains(BITSIZE, 64)) { 21 | LIBS += $$PWD/libs/lin64/liblzfse.a 22 | } 23 | if (contains(BITSIZE, 32)) { 24 | LIBS += $$PWD/libs/lin32/liblzfse.a 25 | } 26 | } 27 | unix:macx { 28 | LIBS += $$PWD/libs/mac/liblzfse.a 29 | } 30 | -------------------------------------------------------------------------------- /3rdparty/bzip2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(bzip2 LANGUAGES C) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_CXX_STANDARD 11) 7 | set(CMAKE_C_STANDARD 11) 8 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 9 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 10 | 11 | include_directories(${PROJECT_SOURCE_DIR}/src/) 12 | 13 | add_library(bzip2 STATIC 14 | ${PROJECT_SOURCE_DIR}/src/bzip2.c 15 | ${PROJECT_SOURCE_DIR}/src/crctable.c 16 | ${PROJECT_SOURCE_DIR}/src/bzlib.c 17 | ${PROJECT_SOURCE_DIR}/src/compress.c 18 | ${PROJECT_SOURCE_DIR}/src/decompress.c 19 | ${PROJECT_SOURCE_DIR}/src/blocksort.c 20 | ${PROJECT_SOURCE_DIR}/src/randtable.c 21 | ${PROJECT_SOURCE_DIR}/src/huffman.c 22 | ) 23 | 24 | set_target_properties(bzip2 PROPERTIES LINKER_LANGUAGE C) 25 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 26 | 27 | if(MSVC) 28 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 29 | endif() 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-2025 hors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /3rdparty/zlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(zlib LANGUAGES C) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_CXX_STANDARD 11) 7 | set(CMAKE_C_STANDARD 11) 8 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 9 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 10 | 11 | include_directories(${PROJECT_SOURCE_DIR}/src/) 12 | 13 | add_library(zlib STATIC 14 | ${PROJECT_SOURCE_DIR}/src/deflate.c 15 | ${PROJECT_SOURCE_DIR}/src/deflate.h 16 | ${PROJECT_SOURCE_DIR}/src/inflate.c 17 | ${PROJECT_SOURCE_DIR}/src/inflate.h 18 | ${PROJECT_SOURCE_DIR}/src/adler32.c 19 | ${PROJECT_SOURCE_DIR}/src/crc32.c 20 | ${PROJECT_SOURCE_DIR}/src/crc32.h 21 | ${PROJECT_SOURCE_DIR}/src/inffast.c 22 | ${PROJECT_SOURCE_DIR}/src/inffast.h 23 | ${PROJECT_SOURCE_DIR}/src/inftrees.c 24 | ${PROJECT_SOURCE_DIR}/src/inftrees.h 25 | ${PROJECT_SOURCE_DIR}/src/trees.c 26 | ${PROJECT_SOURCE_DIR}/src/trees.h 27 | ${PROJECT_SOURCE_DIR}/src/zutil.c 28 | ${PROJECT_SOURCE_DIR}/src/zutil.h 29 | ) 30 | 31 | set_target_properties(zlib PROPERTIES LINKER_LANGUAGE C) 32 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 33 | 34 | if(MSVC) 35 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 36 | endif() 37 | -------------------------------------------------------------------------------- /3rdparty/lzfse/lzfse.pro: -------------------------------------------------------------------------------- 1 | QT -= core gui 2 | 3 | TARGET = lzfse 4 | TEMPLATE = lib 5 | CONFIG += staticlib 6 | 7 | INCLUDEPATH += $$PWD/lzfse 8 | DEPENDPATH += $$PWD/lzfse 9 | 10 | include(../../build.pri) 11 | 12 | CONFIG(debug, debug|release) { 13 | TARGET = lzfsed 14 | } else { 15 | TARGET = lzfse 16 | } 17 | 18 | TARGETLIB_PATH = $$PWD 19 | 20 | win32-g++ { 21 | contains(QT_ARCH, i386) { 22 | DESTDIR=$${TARGETLIB_PATH}/libs/win32-g++ 23 | } else { 24 | DESTDIR=$${TARGETLIB_PATH}/libs/win64-g++ 25 | } 26 | } 27 | win32-msvc* { 28 | contains(QMAKE_TARGET.arch, x86_64) { 29 | DESTDIR=$${TARGETLIB_PATH}/libs/win64-msvc 30 | } else { 31 | DESTDIR=$${TARGETLIB_PATH}/libs/win32-msvc 32 | } 33 | } 34 | unix:!macx { 35 | BITSIZE = $$system(getconf LONG_BIT) 36 | if (contains(BITSIZE, 64)) { 37 | DESTDIR=$${TARGETLIB_PATH}/libs/lin64 38 | } 39 | if (contains(BITSIZE, 32)) { 40 | DESTDIR=$${TARGETLIB_PATH}/libs/lin32 41 | } 42 | } 43 | unix:macx { 44 | DESTDIR=$${TARGETLIB_PATH}/libs/mac 45 | } 46 | 47 | SOURCES += \ 48 | $$PWD/src/lzfse_decode.c \ 49 | $$PWD/src/lzfse_decode_base.c \ 50 | $$PWD/src/lzfse_encode.c \ 51 | $$PWD/src/lzfse_encode_base.c \ 52 | $$PWD/src/lzfse_fse.c \ 53 | $$PWD/src/lzvn_decode_base.c \ 54 | $$PWD/src/lzvn_encode_base.c -------------------------------------------------------------------------------- /3rdparty/lzfse/src/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2016, Apple Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, 4 | are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder(s) nor the names of any contributors 14 | may be used to endorse or promote products derived from this software without 15 | specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 25 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 26 | OF SUCH DAMAGE. 27 | 28 | -------------------------------------------------------------------------------- /Algos/xlzwdecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XLZWDECODER_H 22 | #define XLZWDECODER_H 23 | 24 | #include "xbinary.h" 25 | 26 | class XLZWDecoder : public QObject { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit XLZWDecoder(QObject *parent = nullptr); 31 | static bool decompress_pdf(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 32 | }; 33 | 34 | #endif // XLZWDECODER_H 35 | -------------------------------------------------------------------------------- /Algos/xstoredecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XSTOREDECODER_H 22 | #define XSTOREDECODER_H 23 | 24 | #include "xbinary.h" 25 | 26 | class XStoreDecoder : public QObject { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit XStoreDecoder(QObject *parent = nullptr); 31 | static bool decompress(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 32 | }; 33 | 34 | #endif // XSTOREDECODER_H 35 | -------------------------------------------------------------------------------- /Algos/xascii85decoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XASCII85DECODER_H 22 | #define XASCII85DECODER_H 23 | 24 | #include "xbinary.h" 25 | 26 | class XASCII85Decoder : public QObject { 27 | Q_OBJECT 28 | public: 29 | explicit XASCII85Decoder(QObject *parent = nullptr); 30 | static bool decompress_pdf(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 31 | }; 32 | 33 | #endif // XASCII85DECODER_H 34 | -------------------------------------------------------------------------------- /Algos/xbzip2decoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XBZIP2DECODER_H 22 | #define XBZIP2DECODER_H 23 | 24 | #include "bzlib.h" 25 | #include "../xbinary.h" 26 | 27 | class XBZIP2Decoder : public QObject { 28 | Q_OBJECT 29 | 30 | public: 31 | explicit XBZIP2Decoder(QObject *parent = nullptr); 32 | 33 | static bool decompress(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 34 | }; 35 | 36 | #endif // XBZIP2DECODER_H 37 | -------------------------------------------------------------------------------- /Algos/ximplodedecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XIMPLODEDECODER_H 22 | #define XIMPLODEDECODER_H 23 | 24 | #include "xbinary.h" 25 | 26 | class XImplodeDecoder : public QObject { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit XImplodeDecoder(QObject *parent = nullptr); 31 | static bool decompress(XBinary::DATAPROCESS_STATE *pDecompressState, bool b8kdict, bool b3trees, XBinary::PDSTRUCT *pPdStruct = nullptr); 32 | }; 33 | 34 | #endif // XIMPLODEDECODER_H 35 | -------------------------------------------------------------------------------- /Algos/xlzssdecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XLZSSDECODER_H 22 | #define XLZSSDECODER_H 23 | 24 | #include 25 | #include 26 | #include "../xbinary.h" 27 | 28 | class XLZSSDecoder : public QObject { 29 | Q_OBJECT 30 | 31 | public: 32 | explicit XLZSSDecoder(QObject *parent = nullptr); 33 | 34 | static bool decompress(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 35 | }; 36 | 37 | #endif // XLZSSDECODER_H 38 | -------------------------------------------------------------------------------- /Algos/xshrinkdecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XSHRINKDECODER_H 22 | #define XSHRINKDECODER_H 23 | 24 | #include 25 | #include 26 | #include "../xbinary.h" 27 | 28 | class XShrinkDecoder : public QObject { 29 | Q_OBJECT 30 | 31 | public: 32 | explicit XShrinkDecoder(QObject *parent = nullptr); 33 | 34 | static bool decompress(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 35 | }; 36 | 37 | #endif // XSHRINKDECODER_H 38 | -------------------------------------------------------------------------------- /xipa.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XIPA_H 22 | #define XIPA_H 23 | 24 | #include "xjar.h" 25 | 26 | class XIPA : public XJAR { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit XIPA(QIODevice *pDevice = nullptr); 31 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 32 | static bool isValid(QIODevice *pDevice); 33 | static bool isValid(QList *pListRecords, PDSTRUCT *pPdStruct); 34 | 35 | // virtual QString getMIMEString(); 36 | }; 37 | 38 | #endif // XIPA_H 39 | -------------------------------------------------------------------------------- /Algos/xreducedecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XREDUCEDECODER_H 22 | #define XREDUCEDECODER_H 23 | 24 | #include 25 | #include 26 | #include "../xbinary.h" 27 | 28 | class XReduceDecoder : public QObject { 29 | Q_OBJECT 30 | 31 | public: 32 | explicit XReduceDecoder(QObject *parent = nullptr); 33 | 34 | static bool decompress(XBinary::DATAPROCESS_STATE *pDecompressState, qint32 nFactor, XBinary::PDSTRUCT *pPdStruct = nullptr); 35 | }; 36 | 37 | #endif // XREDUCEDECODER_H 38 | -------------------------------------------------------------------------------- /3rdparty/ppmd/src/RotateDefs.h: -------------------------------------------------------------------------------- 1 | /* RotateDefs.h -- Rotate functions 2 | 2023-06-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef ZIP7_INC_ROTATE_DEFS_H 5 | #define ZIP7_INC_ROTATE_DEFS_H 6 | 7 | #ifdef _MSC_VER 8 | 9 | #include 10 | 11 | /* don't use _rotl with old MINGW. It can insert slow call to function. */ 12 | 13 | /* #if (_MSC_VER >= 1200) */ 14 | #pragma intrinsic(_rotl) 15 | #pragma intrinsic(_rotr) 16 | /* #endif */ 17 | 18 | #define rotlFixed(x, n) _rotl((x), (n)) 19 | #define rotrFixed(x, n) _rotr((x), (n)) 20 | 21 | #if (_MSC_VER >= 1300) 22 | #define Z7_ROTL64(x, n) _rotl64((x), (n)) 23 | #define Z7_ROTR64(x, n) _rotr64((x), (n)) 24 | #else 25 | #define Z7_ROTL64(x, n) (((x) << (n)) | ((x) >> (64 - (n)))) 26 | #define Z7_ROTR64(x, n) (((x) >> (n)) | ((x) << (64 - (n)))) 27 | #endif 28 | 29 | #else 30 | 31 | /* new compilers can translate these macros to fast commands. */ 32 | 33 | #if defined(__clang__) && (__clang_major__ >= 4) \ 34 | || defined(__GNUC__) && (__GNUC__ >= 5) 35 | /* GCC 4.9.0 and clang 3.5 can recognize more correct version: */ 36 | #define rotlFixed(x, n) (((x) << (n)) | ((x) >> (-(n) & 31))) 37 | #define rotrFixed(x, n) (((x) >> (n)) | ((x) << (-(n) & 31))) 38 | #define Z7_ROTL64(x, n) (((x) << (n)) | ((x) >> (-(n) & 63))) 39 | #define Z7_ROTR64(x, n) (((x) >> (n)) | ((x) << (-(n) & 63))) 40 | #else 41 | /* for old GCC / clang: */ 42 | #define rotlFixed(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) 43 | #define rotrFixed(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) 44 | #define Z7_ROTL64(x, n) (((x) << (n)) | ((x) >> (64 - (n)))) 45 | #define Z7_ROTR64(x, n) (((x) >> (n)) | ((x) << (64 - (n)))) 46 | #endif 47 | 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /Algos/xppmddecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XPPMDDECODER_H 22 | #define XPPMDDECODER_H 23 | 24 | #include "xbinary.h" 25 | 26 | class XPPMdDecoder : public QObject { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit XPPMdDecoder(QObject *pParent = nullptr); 31 | static bool decompress(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 32 | static bool decompressPPMdH(XBinary::DATAPROCESS_STATE *pDecompressState, const QByteArray &baProperty, XBinary::PDSTRUCT *pPdStruct = nullptr); 33 | }; 34 | 35 | #endif // XPPMDDECODER_H 36 | -------------------------------------------------------------------------------- /xapks.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XAPKS_H 22 | #define XAPKS_H 23 | 24 | #include "xapk.h" 25 | 26 | class XAPKS : public XAPK { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit XAPKS(QIODevice *pDevice = nullptr); 31 | ~XAPKS(); 32 | 33 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 34 | static bool isValid(QIODevice *pDevice); 35 | static bool isValid(QList *pListRecords, PDSTRUCT *pPdStruct); 36 | 37 | virtual FT getFileType() override; 38 | virtual QString getFileFormatExt() override; 39 | virtual QString getMIMEString() override; 40 | }; 41 | 42 | #endif // XAPKS_H 43 | -------------------------------------------------------------------------------- /xipa.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xipa.h" 22 | 23 | XIPA::XIPA(QIODevice *pDevice) : XJAR(pDevice) 24 | { 25 | } 26 | 27 | bool XIPA::isValid(PDSTRUCT *pPdStruct) 28 | { 29 | // TODO 30 | // Check "Payload/" 31 | return XJAR::isValid(pPdStruct); 32 | } 33 | 34 | bool XIPA::isValid(QList *pListRecords, PDSTRUCT *pPdStruct) 35 | { 36 | Q_UNUSED(pListRecords) 37 | Q_UNUSED(pPdStruct) 38 | 39 | return false; 40 | } 41 | 42 | // QString XIPA::getMIMEString() 43 | // { 44 | 45 | // } 46 | 47 | bool XIPA::isValid(QIODevice *pDevice) 48 | { 49 | XIPA xipa(pDevice); 50 | 51 | return xipa.isValid(); 52 | } 53 | -------------------------------------------------------------------------------- /Algos/xit214decoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XIT214DECODER_H 22 | #define XIT214DECODER_H 23 | 24 | #include "xbinary.h" 25 | 26 | class XIT214Decoder : public QObject { 27 | Q_OBJECT 28 | 29 | struct STATE { 30 | char *ibuf; 31 | quint32 bitlen; 32 | quint8 bitnum; 33 | qint32 nInputBufferSize; 34 | char *pBufferIn; 35 | }; 36 | 37 | public: 38 | explicit XIT214Decoder(QObject *parent = nullptr); 39 | static bool decompress(XBinary::DATAPROCESS_STATE *pDecompressState, quint8 nBits, bool bIs215, XBinary::PDSTRUCT *pPdStruct = nullptr); 40 | 41 | private: 42 | static quint32 readbits(STATE *pState, quint8 n); 43 | static bool readBlock(STATE *pState, XBinary::DATAPROCESS_STATE *pDecompressState); 44 | }; 45 | 46 | #endif // XIT214DECODER_H 47 | -------------------------------------------------------------------------------- /xdeb.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XDEB_H 22 | #define XDEB_H 23 | 24 | #include "x_ar.h" 25 | 26 | class XDEB : public X_Ar { 27 | Q_OBJECT 28 | 29 | public: 30 | enum STRUCTID { 31 | STRUCTID_UNKNOWN = 0, 32 | }; 33 | 34 | explicit XDEB(QIODevice *pDevice = nullptr); 35 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 36 | static bool isValid(QIODevice *pDevice); 37 | static bool isValid(QList *pListRecords, PDSTRUCT *pPdStruct); 38 | virtual QString getVersion() override; 39 | virtual FT getFileType() override; 40 | QString structIDToString(quint32 nID) override; 41 | virtual QString getFileFormatExt() override; 42 | virtual FILEFORMATINFO getFileFormatInfo(PDSTRUCT *pPdStruct) override; 43 | virtual QString getMIMEString() override; 44 | }; 45 | 46 | #endif // XDEB_H 47 | -------------------------------------------------------------------------------- /3rdparty/bzip2/src/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------- 3 | 4 | This program, "bzip2", the associated library "libbzip2", and all 5 | documentation, are copyright (C) 1996-2010 Julian R Seward. All 6 | rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | 1. Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | 2. The origin of this software must not be misrepresented; you must 16 | not claim that you wrote the original software. If you use this 17 | software in a product, an acknowledgment in the product 18 | documentation would be appreciated but is not required. 19 | 20 | 3. Altered source versions must be plainly marked as such, and must 21 | not be misrepresented as being the original software. 22 | 23 | 4. The name of the author may not be used to endorse or promote 24 | products derived from this software without specific prior written 25 | permission. 26 | 27 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 28 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 29 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 31 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 35 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | 39 | Julian Seward, jseward@bzip.org 40 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 41 | 42 | -------------------------------------------------------------------------- 43 | -------------------------------------------------------------------------------- /Algos/xlzmadecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XLZMADECODER_H 22 | #define XLZMADECODER_H 23 | 24 | #include "xbinary.h" 25 | #include "LzmaDec.h" 26 | #include "Lzma2Dec.h" 27 | 28 | class XLZMADecoder : public QObject { 29 | Q_OBJECT 30 | 31 | public: 32 | explicit XLZMADecoder(QObject *parent = nullptr); 33 | static bool decompress(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 34 | static bool decompress(XBinary::DATAPROCESS_STATE *pDecompressState, const QByteArray &baProperty, XBinary::PDSTRUCT *pPdStruct = nullptr); 35 | static bool decompressLZMA2(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 36 | static bool decompressLZMA2(XBinary::DATAPROCESS_STATE *pDecompressState, const QByteArray &baProperty, XBinary::PDSTRUCT *pPdStruct = nullptr); 37 | }; 38 | 39 | #endif // XLZMADECODER_H 40 | -------------------------------------------------------------------------------- /Algos/xsha256decoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XSHA256DECODER_H 22 | #define XSHA256DECODER_H 23 | 24 | #include 25 | 26 | class XSha256Decoder : public QObject { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit XSha256Decoder(QObject *parent = nullptr); 31 | 32 | struct Context { 33 | quint32 state[8]; 34 | quint64 count; 35 | quint8 buffer[64]; 36 | }; 37 | 38 | static void init(Context *pContext); 39 | static void update(Context *pContext, const quint8 *pData, qint32 nSize); 40 | static void final(Context *pContext, quint8 *pDigest); 41 | 42 | private: 43 | static void transform(quint32 state[8], const quint8 data[64]); 44 | static quint32 rotr(quint32 x, quint32 n); 45 | static quint32 getBe32(const quint8 *p); 46 | static void setBe32(quint8 *p, quint32 v); 47 | }; 48 | 49 | #endif // XSHA256DECODER_H 50 | -------------------------------------------------------------------------------- /Algos/xaesdecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XAESDECODER_H 22 | #define XAESDECODER_H 23 | 24 | #include "xbinary.h" 25 | #include "xsha256decoder.h" 26 | 27 | // AES constants 28 | #define AES_BLOCK_SIZE 16 29 | 30 | class XAESDecoder : public QObject { 31 | Q_OBJECT 32 | 33 | public: 34 | explicit XAESDecoder(QObject *parent = nullptr); 35 | 36 | // Decrypt AES-encrypted data from 7z archives 37 | // Properties format: NumCyclesPower (1 byte) + SaltSize (1 byte) + Salt (0-16 bytes) + IV (16 bytes) 38 | static bool decrypt(XBinary::DATAPROCESS_STATE *pDecryptState, const QByteArray &baProperties, const QString &sPassword, XBinary::PDSTRUCT *pPdStruct = nullptr); 39 | 40 | private: 41 | // Derive key from password using SHA-256 with salt and cycle power 42 | static void deriveKey(const QString &sPassword, const QByteArray &baSalt, quint8 nNumCyclesPower, quint8 *pKey); 43 | }; 44 | 45 | #endif // XAESDECODER_H 46 | -------------------------------------------------------------------------------- /Algos/xdeflatedecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XDEFLATEDECODER_H 22 | #define XDEFLATEDECODER_H 23 | 24 | #include "xbinary.h" 25 | #include 26 | 27 | class XDeflateDecoder : public QObject { 28 | Q_OBJECT 29 | public: 30 | explicit XDeflateDecoder(QObject *parent = nullptr); 31 | static bool decompress(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 32 | static bool decompress64(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 33 | static bool decompress_zlib(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct = nullptr); 34 | static bool compress(XBinary::DATAPROCESS_STATE *pCompressState, XBinary::PDSTRUCT *pPdStruct = nullptr, int nCompressionLevel = Z_DEFAULT_COMPRESSION); 35 | static bool compress_zlib(XBinary::DATAPROCESS_STATE *pCompressState, XBinary::PDSTRUCT *pPdStruct = nullptr, int nCompressionLevel = Z_DEFAULT_COMPRESSION); 36 | 37 | signals: 38 | }; 39 | 40 | #endif // XDEFLATEDECODER_H 41 | -------------------------------------------------------------------------------- /xnpm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XNPM_H 22 | #define XNPM_H 23 | 24 | #include "xtgz.h" 25 | 26 | class XNPM : public XTGZ { 27 | Q_OBJECT 28 | 29 | public: 30 | enum STRUCTID { 31 | STRUCTID_UNKNOWN = 0, 32 | }; 33 | 34 | enum TYPE { 35 | TYPE_UNKNOWN = 0, 36 | TYPE_PACKAGE, 37 | // TODO more 38 | }; 39 | 40 | explicit XNPM(QIODevice *pDevice = nullptr); 41 | 42 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr); 43 | static bool isValid(QIODevice *pDevice); 44 | static bool isValid(QList *pListRecords, PDSTRUCT *pPdStruct); 45 | 46 | virtual QString getFileFormatExt(); 47 | virtual FT getFileType(); 48 | 49 | virtual FILEFORMATINFO getFileFormatInfo(PDSTRUCT *pPdStruct); 50 | virtual MODE getMode(); 51 | virtual QString getArch(); 52 | virtual qint32 getType(); 53 | virtual QString typeIdToString(qint32 nType); 54 | virtual QString getMIMEString(); 55 | virtual QString structIDToString(quint32 nID); 56 | }; 57 | 58 | #endif // XNPM_H 59 | -------------------------------------------------------------------------------- /3rdparty/lzma/src/Aes.h: -------------------------------------------------------------------------------- 1 | /* Aes.h -- AES encryption / decryption 2 | 2023-04-02 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef ZIP7_INC_AES_H 5 | #define ZIP7_INC_AES_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define AES_BLOCK_SIZE 16 12 | 13 | /* Call AesGenTables one time before other AES functions */ 14 | void AesGenTables(void); 15 | 16 | /* UInt32 pointers must be 16-byte aligned */ 17 | 18 | /* 16-byte (4 * 32-bit words) blocks: 1 (IV) + 1 (keyMode) + 15 (AES-256 roundKeys) */ 19 | #define AES_NUM_IVMRK_WORDS ((1 + 1 + 15) * 4) 20 | 21 | /* aes - 16-byte aligned pointer to keyMode+roundKeys sequence */ 22 | /* keySize = 16 or 24 or 32 (bytes) */ 23 | typedef void (Z7_FASTCALL *AES_SET_KEY_FUNC)(UInt32 *aes, const Byte *key, unsigned keySize); 24 | void Z7_FASTCALL Aes_SetKey_Enc(UInt32 *aes, const Byte *key, unsigned keySize); 25 | void Z7_FASTCALL Aes_SetKey_Dec(UInt32 *aes, const Byte *key, unsigned keySize); 26 | 27 | /* ivAes - 16-byte aligned pointer to iv+keyMode+roundKeys sequence: UInt32[AES_NUM_IVMRK_WORDS] */ 28 | void AesCbc_Init(UInt32 *ivAes, const Byte *iv); /* iv size is AES_BLOCK_SIZE */ 29 | 30 | /* data - 16-byte aligned pointer to data */ 31 | /* numBlocks - the number of 16-byte blocks in data array */ 32 | typedef void (Z7_FASTCALL *AES_CODE_FUNC)(UInt32 *ivAes, Byte *data, size_t numBlocks); 33 | 34 | extern AES_CODE_FUNC g_AesCbc_Decode; 35 | #ifndef Z7_SFX 36 | extern AES_CODE_FUNC g_AesCbc_Encode; 37 | extern AES_CODE_FUNC g_AesCtr_Code; 38 | #define k_Aes_SupportedFunctions_HW (1 << 2) 39 | #define k_Aes_SupportedFunctions_HW_256 (1 << 3) 40 | extern UInt32 g_Aes_SupportedFunctions_Flags; 41 | #endif 42 | 43 | 44 | #define Z7_DECLARE_AES_CODE_FUNC(funcName) \ 45 | void Z7_FASTCALL funcName(UInt32 *ivAes, Byte *data, size_t numBlocks); 46 | 47 | Z7_DECLARE_AES_CODE_FUNC (AesCbc_Encode) 48 | Z7_DECLARE_AES_CODE_FUNC (AesCbc_Decode) 49 | Z7_DECLARE_AES_CODE_FUNC (AesCtr_Code) 50 | 51 | Z7_DECLARE_AES_CODE_FUNC (AesCbc_Encode_HW) 52 | Z7_DECLARE_AES_CODE_FUNC (AesCbc_Decode_HW) 53 | Z7_DECLARE_AES_CODE_FUNC (AesCtr_Code_HW) 54 | 55 | Z7_DECLARE_AES_CODE_FUNC (AesCbc_Decode_HW_256) 56 | Z7_DECLARE_AES_CODE_FUNC (AesCtr_Code_HW_256) 57 | 58 | EXTERN_C_END 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /xcompresseddevice.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2024-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XCOMPRESSEDDEVICE_H 22 | #define XCOMPRESSEDDEVICE_H 23 | 24 | #include "xiodevice.h" 25 | #include "subdevice.h" 26 | #include "xgzip.h" 27 | #include "xdecompress.h" 28 | 29 | class XCompressedDevice : public XIODevice { 30 | Q_OBJECT 31 | 32 | public: 33 | explicit XCompressedDevice(QObject *pParent = nullptr); 34 | ~XCompressedDevice(); 35 | 36 | bool setData(QIODevice *pDevice, const XBinary::FPART &fPart, XBinary::PDSTRUCT *pPdStruct); 37 | virtual bool open(OpenMode mode); 38 | 39 | QIODevice *getOrigDevice(); 40 | 41 | virtual qint64 size() const; 42 | virtual bool seek(qint64 nPos); 43 | virtual qint64 pos() const; 44 | 45 | protected: 46 | virtual qint64 readData(char *pData, qint64 nMaxSize); 47 | virtual qint64 writeData(const char *pData, qint64 nMaxSize); 48 | 49 | private: 50 | QIODevice *m_pOrigDevice; 51 | SubDevice *m_pSubDevice; 52 | bool m_bIsValid; 53 | QIODevice *m_pCurrentDevice; 54 | QIODevice *m_pBufferDevice; 55 | }; 56 | 57 | #endif // XCOMPRESSEDDEVICE_H 58 | -------------------------------------------------------------------------------- /xtgz.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XTGZ_H 22 | #define XTGZ_H 23 | 24 | #include "xgzip.h" 25 | #include "xtar.h" 26 | 27 | class XTGZ : public XGzip { 28 | Q_OBJECT 29 | 30 | public: 31 | explicit XTGZ(QIODevice *pDevice = nullptr); 32 | virtual ~XTGZ(); 33 | 34 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 35 | static bool isValid(QIODevice *pDevice); 36 | 37 | virtual QString getFileFormatExt() override; 38 | virtual FT getFileType() override; 39 | 40 | virtual bool initUnpack(UNPACK_STATE *pUnpackState, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 41 | virtual ARCHIVERECORD infoCurrent(UNPACK_STATE *pUnpackState, PDSTRUCT *pPdStruct = nullptr) override; 42 | virtual bool unpackCurrent(UNPACK_STATE *pUnpackState, QIODevice *pDevice, PDSTRUCT *pPdStruct = nullptr) override; 43 | virtual bool moveToNext(UNPACK_STATE *pUnpackState, PDSTRUCT *pPdStruct = nullptr) override; 44 | virtual bool finishUnpack(UNPACK_STATE *pUnpackState, PDSTRUCT *pPdStruct = nullptr) override; 45 | }; 46 | #endif // XTGZ_H 47 | -------------------------------------------------------------------------------- /Algos/xzipcryptodecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XZIPCRYPTODECODER_H 22 | #define XZIPCRYPTODECODER_H 23 | 24 | #include "xbinary.h" 25 | 26 | class XZipCryptoDecoder : public QObject { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit XZipCryptoDecoder(QObject *pParent = nullptr); 31 | 32 | static bool decrypt(XBinary::DATAPROCESS_STATE *pDecompressState, const QString &sPassword, XBinary::PDSTRUCT *pPdStruct = nullptr); 33 | static bool decrypt(XBinary::DATAPROCESS_STATE *pDecompressState, const QByteArray &baPassword, XBinary::PDSTRUCT *pPdStruct = nullptr); 34 | 35 | static bool encrypt(XBinary::DATAPROCESS_STATE *pCompressState, const QString &sPassword, quint32 nCRC32, XBinary::PDSTRUCT *pPdStruct = nullptr); 36 | static bool encrypt(XBinary::DATAPROCESS_STATE *pCompressState, const QByteArray &baPassword, quint32 nCRC32, XBinary::PDSTRUCT *pPdStruct = nullptr); 37 | 38 | private: 39 | static void initKeys(quint32 *pnKeys, const QByteArray &baPassword); 40 | static void updateKeys(quint32 *pnKeys, quint8 nByte); 41 | static quint8 decryptByte(const quint32 *pnKeys); 42 | }; 43 | 44 | #endif // XZIPCRYPTODECODER_H 45 | -------------------------------------------------------------------------------- /xjar.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XJAR_H 22 | #define XJAR_H 23 | 24 | #include "xzip.h" 25 | #include "xjavaclass.h" 26 | 27 | class XJAR : public XZip { 28 | Q_OBJECT 29 | 30 | public: 31 | enum STRUCTID { 32 | STRUCTID_UNKNOWN = 0, 33 | }; 34 | 35 | enum TYPE { 36 | TYPE_UNKNOWN = 0, 37 | TYPE_PACKAGE, 38 | // TODO more 39 | }; 40 | 41 | explicit XJAR(QIODevice *pDevice = nullptr); 42 | 43 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 44 | static bool isValid(QIODevice *pDevice); 45 | static bool isValid(QList *pListRecords, PDSTRUCT *pPdStruct); 46 | 47 | virtual FT getFileType() override; 48 | virtual FILEFORMATINFO getFileFormatInfo(PDSTRUCT *pPdStruct) override; 49 | virtual QString getFileFormatExt() override; 50 | virtual ENDIAN getEndian() override; 51 | virtual MODE getMode() override; 52 | virtual QString getArch() override; 53 | virtual qint32 getType() override; 54 | virtual QString typeIdToString(qint32 nType) override; 55 | virtual QString structIDToString(quint32 nID) override; 56 | }; 57 | 58 | #endif // XJAR_H 59 | -------------------------------------------------------------------------------- /Algos/xppmdrangedecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XPPMDRANGEDECODER_H 22 | #define XPPMDRANGEDECODER_H 23 | 24 | #include 25 | #include "xbinary.h" 26 | 27 | // Range decoder for PPMd - wraps arithmetic coding 28 | class XPPMdRangeDecoder { 29 | public: 30 | XPPMdRangeDecoder(); 31 | ~XPPMdRangeDecoder(); 32 | 33 | // Initialize range decoder with input stream 34 | bool init(QIODevice *pDevice); 35 | 36 | // Get current bit from range 37 | quint32 getThreshold(quint32 nTotal); 38 | 39 | // Decode using range 40 | void decode(quint32 nStart, quint32 nSize, quint32 nTotal); 41 | 42 | // Normalize range 43 | void normalize(); 44 | 45 | // Check if stream is finished correctly 46 | bool isFinishedOK() const; 47 | 48 | // Get range and code values (for debugging) 49 | quint32 getRange() const 50 | { 51 | return m_nRange; 52 | } 53 | quint32 getCode() const 54 | { 55 | return m_nCode; 56 | } 57 | 58 | private: 59 | QIODevice *m_pDevice; 60 | quint32 m_nRange; 61 | quint32 m_nCode; 62 | bool m_bError; 63 | 64 | quint8 readByte(); 65 | }; 66 | 67 | #endif // XPPMDRANGEDECODER_H 68 | -------------------------------------------------------------------------------- /3rdparty/lzma/include/Ppmd.h: -------------------------------------------------------------------------------- 1 | /* Ppmd.h -- PPMD codec common code 2 | 2017-04-03 : Igor Pavlov : Public domain 3 | This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ 4 | 5 | #ifndef __PPMD_H 6 | #define __PPMD_H 7 | 8 | #include "CpuArch.h" 9 | 10 | EXTERN_C_BEGIN 11 | 12 | #ifdef MY_CPU_32BIT 13 | #define PPMD_32BIT 14 | #endif 15 | 16 | #define PPMD_INT_BITS 7 17 | #define PPMD_PERIOD_BITS 7 18 | #define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS)) 19 | 20 | #define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift)) 21 | #define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2) 22 | #define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob)) 23 | #define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob)) 24 | 25 | #define PPMD_N1 4 26 | #define PPMD_N2 4 27 | #define PPMD_N3 4 28 | #define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4) 29 | #define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4) 30 | 31 | #pragma pack(push, 1) 32 | /* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */ 33 | 34 | /* SEE-contexts for PPM-contexts with masked symbols */ 35 | typedef struct 36 | { 37 | UInt16 Summ; /* Freq */ 38 | Byte Shift; /* Speed of Freq change; low Shift is for fast change */ 39 | Byte Count; /* Count to next change of Shift */ 40 | } CPpmd_See; 41 | 42 | #define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \ 43 | { (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); } 44 | 45 | typedef struct 46 | { 47 | Byte Symbol; 48 | Byte Freq; 49 | UInt16 SuccessorLow; 50 | UInt16 SuccessorHigh; 51 | } CPpmd_State; 52 | 53 | #pragma pack(pop) 54 | 55 | typedef 56 | #ifdef PPMD_32BIT 57 | CPpmd_State * 58 | #else 59 | UInt32 60 | #endif 61 | CPpmd_State_Ref; 62 | 63 | typedef 64 | #ifdef PPMD_32BIT 65 | void * 66 | #else 67 | UInt32 68 | #endif 69 | CPpmd_Void_Ref; 70 | 71 | typedef 72 | #ifdef PPMD_32BIT 73 | Byte * 74 | #else 75 | UInt32 76 | #endif 77 | CPpmd_Byte_Ref; 78 | 79 | #define PPMD_SetAllBitsIn256Bytes(p) \ 80 | { size_t z; for (z = 0; z < 256 / sizeof(p[0]); z += 8) { \ 81 | p[z+7] = p[z+6] = p[z+5] = p[z+4] = p[z+3] = p[z+2] = p[z+1] = p[z+0] = ~(size_t)0; }} 82 | 83 | EXTERN_C_END 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Algos/xppmd7model.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /* This code is based on: 23 | Ppmd7.h -- Ppmd7 (PPMdH) compression codec 24 | 2023-04-02 : Igor Pavlov : Public domain 25 | PPMd var.H (2001): Dmitry Shkarin : Public domain 26 | */ 27 | 28 | #ifndef XPPMD7MODEL_H 29 | #define XPPMD7MODEL_H 30 | 31 | #include 32 | #include "xbinary.h" 33 | 34 | #include "Ppmd.h" 35 | #include "Ppmd7.h" 36 | 37 | // Forward declaration for internal implementation 38 | struct XPPMd7ModelPrivate; 39 | 40 | // PPMd7 Model wrapper class for 7z PPMd support 41 | class XPPMd7Model { 42 | public: 43 | static const quint8 MIN_ORDER = PPMD7_MIN_ORDER; 44 | static const quint8 MAX_ORDER = PPMD7_MAX_ORDER; 45 | 46 | XPPMd7Model(); 47 | ~XPPMd7Model(); 48 | 49 | // Allocate memory for the model 50 | bool allocate(quint32 nMemorySize); 51 | 52 | // Initialize the model with parameters 53 | void init(quint8 nOrder); 54 | 55 | // Set input device for stream reading 56 | void setInputStream(QIODevice *pDevice); 57 | 58 | // Decode a single symbol 59 | // Returns: >= 0 for decoded byte, -1 for end of stream, -2 for error 60 | qint32 decodeSymbol(); 61 | 62 | // Free allocated resources 63 | void free(); 64 | 65 | // Check if memory was allocated 66 | bool wasAllocated() const; 67 | 68 | private: 69 | XPPMd7ModelPrivate *m_pPrivate; 70 | }; 71 | 72 | #endif // XPPMD7MODEL_H 73 | -------------------------------------------------------------------------------- /xdecompress.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2023-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XDECOMPRESS_H 22 | #define XDECOMPRESS_H 23 | 24 | #include "xlzhdecoder.h" 25 | #include "xrardecoder.h" 26 | #include "xit214decoder.h" 27 | #include "xdeflatedecoder.h" 28 | #include "ximplodedecoder.h" 29 | #include "xlzmadecoder.h" 30 | #include "xlzwdecoder.h" 31 | #include "xascii85decoder.h" 32 | #include "xbzip2decoder.h" 33 | #include "xshrinkdecoder.h" 34 | #include "xreducedecoder.h" 35 | #include "xthreadobject.h" 36 | #include "xstoredecoder.h" 37 | #include "Algos/xppmddecoder.h" 38 | 39 | class XDecompress : public XThreadObject { 40 | Q_OBJECT 41 | 42 | public: 43 | explicit XDecompress(QObject *parent = nullptr); 44 | bool decompressFPART(const XBinary::FPART &fPart, QIODevice *pDeviceInput, QIODevice *pDeviceOutput, XBinary::PDSTRUCT *pPdStruct); 45 | bool decompressArchiveRecord(const XBinary::ARCHIVERECORD &archiveRecord, QIODevice *pDeviceInput, QIODevice *pDeviceOutput, XBinary::PDSTRUCT *pPdStruct); 46 | bool checkCRC(const QMap &mapProperties, QIODevice *pDevice, XBinary::PDSTRUCT *pPdStruct); 47 | bool decompress(XBinary::DATAPROCESS_STATE *pState, XBinary::PDSTRUCT *pPdStruct); 48 | QByteArray decomressToByteArray(QIODevice *pDevice, qint64 nOffset, qint64 nSize, XBinary::COMPRESS_METHOD compressMethod, XBinary::PDSTRUCT *pPdStruct); 49 | qint64 getCompressedDataSize(QIODevice *pDevice, qint64 nOffset, qint64 nSize, XBinary::COMPRESS_METHOD compressMethod, XBinary::PDSTRUCT *pPdStruct); 50 | 51 | virtual void process(); 52 | }; 53 | 54 | #endif // XDECOMPRESS_H 55 | -------------------------------------------------------------------------------- /xtgz.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xtgz.h" 22 | 23 | XTGZ::XTGZ(QIODevice *pDevice) : XGzip(pDevice) 24 | { 25 | } 26 | 27 | XTGZ::~XTGZ() 28 | { 29 | } 30 | 31 | bool XTGZ::isValid(PDSTRUCT *pPdStruct) 32 | { 33 | bool bResult = false; 34 | 35 | if (XGzip::isValid(pPdStruct)) { 36 | bResult = true; 37 | } 38 | 39 | return bResult; 40 | } 41 | 42 | bool XTGZ::isValid(QIODevice *pDevice) 43 | { 44 | XTGZ xtgz(pDevice); 45 | 46 | return xtgz.isValid(); 47 | } 48 | 49 | bool XTGZ::initUnpack(UNPACK_STATE *pUnpackState, const QMap &mapProperties, PDSTRUCT *pPdStruct) 50 | { 51 | return XTAR::sub_initUnpack(FT_TARGZ, getDevice(), pUnpackState, mapProperties, pPdStruct); 52 | } 53 | 54 | XBinary::ARCHIVERECORD XTGZ::infoCurrent(UNPACK_STATE *pUnpackState, PDSTRUCT *pPdStruct) 55 | { 56 | return XTAR::sub_infoCurrent(FT_TARGZ, pUnpackState, pPdStruct); 57 | } 58 | 59 | bool XTGZ::unpackCurrent(UNPACK_STATE *pUnpackState, QIODevice *pDevice, PDSTRUCT *pPdStruct) 60 | { 61 | return XTAR::sub_unpackCurrent(FT_TARGZ, pUnpackState, pDevice, pPdStruct); 62 | } 63 | 64 | bool XTGZ::moveToNext(UNPACK_STATE *pUnpackState, PDSTRUCT *pPdStruct) 65 | { 66 | return XTAR::sub_moveToNext(FT_TARGZ, pUnpackState, pPdStruct); 67 | } 68 | 69 | bool XTGZ::finishUnpack(UNPACK_STATE *pUnpackState, PDSTRUCT *pPdStruct) 70 | { 71 | return XTAR::sub_finishUnpack(FT_TARGZ, pUnpackState, pPdStruct); 72 | } 73 | 74 | QString XTGZ::getFileFormatExt() 75 | { 76 | return "tar.gz"; 77 | } 78 | 79 | XBinary::FT XTGZ::getFileType() 80 | { 81 | return FT_TARGZ; 82 | } 83 | -------------------------------------------------------------------------------- /xdos16.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XDOS16_H 22 | #define XDOS16_H 23 | 24 | #include "xarchive.h" 25 | #include "xmsdos_def.h" 26 | 27 | class XDOS16 : public XArchive { 28 | Q_OBJECT 29 | 30 | public: 31 | enum STRUCTID { 32 | STRUCTID_UNKNOWN = 0, 33 | STRUCTID_LOADER, 34 | STRUCTID_SEGMENT, 35 | STRUCTID_PAYLOAD 36 | }; 37 | 38 | explicit XDOS16(QIODevice *pDevice = nullptr); 39 | virtual ~XDOS16(); 40 | 41 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 42 | static bool isValid(QIODevice *pDevice); 43 | virtual quint64 getNumberOfRecords(PDSTRUCT *pPdStruct) override; 44 | virtual QList getRecords(qint32 nLimit, PDSTRUCT *pPdStruct) override; 45 | virtual QList getFileParts(quint32 nFileParts, qint32 nLimit = -1, PDSTRUCT *pPdStruct = nullptr) override; 46 | virtual FT getFileType() override; 47 | virtual QString getMIMEString() override; 48 | virtual QString getFileFormatExt() override; 49 | virtual QString getFileFormatExtsString() override; 50 | virtual qint64 getFileFormatSize(PDSTRUCT *pPdStruct = nullptr) override; 51 | virtual QList getMapModesList() override; 52 | virtual _MEMORY_MAP getMemoryMap(XBinary::MAPMODE mapMode = XBinary::MAPMODE_UNKNOWN, PDSTRUCT *pPdStruct = nullptr) override; 53 | virtual OSNAME getOsName() override; 54 | virtual QString getOsVersion() override; 55 | virtual MODE getMode() override; 56 | virtual QString getArch() override; 57 | virtual ENDIAN getEndian() override; 58 | virtual qint32 getType() override; 59 | virtual QString structIDToString(quint32 nID) override; 60 | }; 61 | 62 | #endif // XDOS16_H 63 | -------------------------------------------------------------------------------- /xapk.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XAPK_H 22 | #define XAPK_H 23 | 24 | #include "xjar.h" 25 | #ifdef USE_DEX 26 | #include "xandroidbinary.h" 27 | #endif 28 | 29 | class XAPK : public XJAR { 30 | Q_OBJECT 31 | 32 | public: 33 | enum TYPE { 34 | TYPE_UNKNOWN = 0, 35 | TYPE_PACKAGE, 36 | // TODO more 37 | }; 38 | 39 | explicit XAPK(QIODevice *pDevice = nullptr); 40 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 41 | static bool isValid(QIODevice *pDevice); 42 | static bool isValid(QList *pListRecords, PDSTRUCT *pPdStruct); 43 | 44 | virtual FT getFileType() override; 45 | virtual FILEFORMATINFO getFileFormatInfo(PDSTRUCT *pPdStruct) override; 46 | virtual QString getFileFormatExt() override; 47 | virtual MODE getMode() override; 48 | virtual QString getArch() override; 49 | virtual qint32 getType() override; 50 | virtual QString typeIdToString(qint32 nType) override; 51 | virtual bool isSigned() override; 52 | virtual OFFSETSIZE getSignOffsetSize() override; 53 | 54 | bool isAPKSignBlockPresent(); // For APK Check jar 55 | 56 | struct APK_SIG_BLOCK_RECORD { 57 | quint32 nID; 58 | quint64 nDataOffset; 59 | quint64 nDataSize; 60 | }; 61 | 62 | QList getAPKSignaturesBlockRecordsList(); 63 | static bool isAPKSignatureBlockRecordPresent(QList *pList, quint32 nID); 64 | static APK_SIG_BLOCK_RECORD getAPKSignatureBlockRecord(QList *pList, quint32 nID); 65 | 66 | private: 67 | qint64 findAPKSignBlockOffset(PDSTRUCT *pPdStruct = nullptr); 68 | }; 69 | 70 | #endif // XAPK_H 71 | -------------------------------------------------------------------------------- /3rdparty/lzfse/src/lzvn_decode_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015-2016, Apple Inc. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 9 | in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived 12 | from this software without specific prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 15 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 16 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 18 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 19 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20 | */ 21 | 22 | // LZVN low-level decoder (v2) 23 | // Functions in the low-level API should switch to these at some point. 24 | // Apr 2014 25 | 26 | #ifndef LZVN_DECODE_BASE_H 27 | #define LZVN_DECODE_BASE_H 28 | 29 | #include "lzfse_internal.h" 30 | 31 | /*! @abstract Base decoder state. */ 32 | typedef struct { 33 | 34 | // Decoder I/O 35 | 36 | // Next byte to read in source buffer 37 | const unsigned char *src; 38 | // Next byte after source buffer 39 | const unsigned char *src_end; 40 | 41 | // Next byte to write in destination buffer (by decoder) 42 | unsigned char *dst; 43 | // Valid range for destination buffer is [dst_begin, dst_end - 1] 44 | unsigned char *dst_begin; 45 | unsigned char *dst_end; 46 | // Next byte to read in destination buffer (modified by caller) 47 | unsigned char *dst_current; 48 | 49 | // Decoder state 50 | 51 | // Partially expanded match, or 0,0,0. 52 | // In that case, src points to the next literal to copy, or the next op-code 53 | // if L==0. 54 | size_t L, M, D; 55 | 56 | // Distance for last emitted match, or 0 57 | lzvn_offset d_prev; 58 | 59 | // Did we decode end-of-stream? 60 | int end_of_stream; 61 | 62 | } lzvn_decoder_state; 63 | 64 | /*! @abstract Decode source to destination. 65 | * Updates \p state (src,dst,d_prev). */ 66 | void lzvn_decode(lzvn_decoder_state *state); 67 | 68 | #endif // LZVN_DECODE_BASE_H 69 | -------------------------------------------------------------------------------- /Algos/xppmdmodel.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /* This code is based on: 23 | Ppmd8.h -- Ppmd8 (PPMdI) compression codec 24 | 2023-04-02 : Igor Pavlov : Public domain 25 | PPMd var.I (2002): Dmitry Shkarin : Public domain 26 | Carryless rangecoder (1999): Dmitry Subbotin : Public domain 27 | */ 28 | 29 | #ifndef XPPMDMODEL_H 30 | #define XPPMDMODEL_H 31 | 32 | #include 33 | #include "xbinary.h" 34 | 35 | #include "../3rdparty/ppmd/src/Ppmd.h" 36 | #include "../3rdparty/ppmd/src/Ppmd8.h" 37 | 38 | // Forward declaration for internal implementation 39 | struct XPPMdModelPrivate; 40 | 41 | // PPMd Model wrapper class 42 | class XPPMdModel { 43 | public: 44 | static const quint8 MIN_ORDER = PPMD8_MIN_ORDER; 45 | static const quint8 MAX_ORDER = PPMD8_MAX_ORDER; 46 | 47 | enum RESTORE_METHOD { 48 | RESTORE_METHOD_RESTART = PPMD8_RESTORE_METHOD_RESTART, 49 | RESTORE_METHOD_CUT_OFF = PPMD8_RESTORE_METHOD_CUT_OFF, 50 | RESTORE_METHOD_UNSUPPORTED = PPMD8_RESTORE_METHOD_UNSUPPPORTED 51 | }; 52 | 53 | XPPMdModel(); 54 | ~XPPMdModel(); 55 | 56 | // Allocate memory for the model 57 | bool allocate(quint32 nMemorySize); 58 | 59 | // Initialize the model with parameters 60 | void init(quint8 nOrder, quint8 nRestoreMethod); 61 | 62 | // Set input device for stream reading 63 | void setInputStream(QIODevice *pDevice); 64 | 65 | // Decode a single symbol 66 | // Returns: >= 0 for decoded byte, -1 for end of stream, -2 for error 67 | qint32 decodeSymbol(); 68 | 69 | // Free allocated resources 70 | void free(); 71 | 72 | // Check if memory was allocated 73 | bool wasAllocated() const; 74 | 75 | private: 76 | XPPMdModelPrivate *m_pPrivate; 77 | }; 78 | 79 | #endif // XPPMDMODEL_H 80 | -------------------------------------------------------------------------------- /xapks.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xapks.h" 22 | 23 | XAPKS::XAPKS(QIODevice *pDevice) : XAPK(pDevice) 24 | { 25 | } 26 | 27 | XAPKS::~XAPKS() 28 | { 29 | } 30 | 31 | bool XAPKS::isValid(PDSTRUCT *pPdStruct) 32 | { 33 | bool bResult = false; 34 | 35 | XAPKS xapks(getDevice()); 36 | 37 | if (xapks.XAPK::isValid(pPdStruct)) { 38 | QList listArchiveRecords = xapks.getRecords(10, pPdStruct); 39 | bResult = isValid(&listArchiveRecords, pPdStruct); 40 | } 41 | 42 | return bResult; 43 | } 44 | 45 | bool XAPKS::isValid(QIODevice *pDevice) 46 | { 47 | XAPKS xapks(pDevice); 48 | 49 | return xapks.isValid(); 50 | } 51 | 52 | bool XAPKS::isValid(QList *pListRecords, PDSTRUCT *pPdStruct) 53 | { 54 | Q_UNUSED(pPdStruct) 55 | 56 | // // APKS is an APK with additional metadata, check for BundleConfig.pb file 57 | // bool bHasBundleConfig = false; 58 | // bool bHasSignatures = false; 59 | 60 | // if (pListRecords) { 61 | // for (qint32 i = 0; i < pListRecords->count(); i++) { 62 | // QString sFileName = pListRecords->at(i).spInfo.sRecordName; 63 | 64 | // if (sFileName == "BundleConfig.pb") { 65 | // bHasBundleConfig = true; 66 | // } 67 | 68 | // if (sFileName == "META-INF/MANIFEST.MF" || sFileName.startsWith("META-INF/") && sFileName.endsWith(".SF")) { 69 | // bHasSignatures = true; 70 | // } 71 | // } 72 | // } 73 | 74 | // // APKS format requires bundle configuration and signatures 75 | // return (bHasBundleConfig && bHasSignatures); 76 | 77 | return false; // TODO 78 | } 79 | 80 | QString XAPKS::getFileFormatExt() 81 | { 82 | return "apks"; 83 | } 84 | 85 | QString XAPKS::getMIMEString() 86 | { 87 | return "application/vnd.android.package-archive"; 88 | } 89 | 90 | XBinary::FT XAPKS::getFileType() 91 | { 92 | return FT_APKS; 93 | } 94 | -------------------------------------------------------------------------------- /xlha.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2023-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XLHA_H 22 | #define XLHA_H 23 | 24 | #include "xarchive.h" 25 | 26 | class XLHA : public XArchive { 27 | Q_OBJECT 28 | public: 29 | enum STRUCTID { 30 | STRUCTID_UNKNOWN = 0, 31 | STRUCTID_HEADER, 32 | STRUCTID_RECORD, 33 | }; 34 | 35 | explicit XLHA(QIODevice *pDevice = nullptr); 36 | 37 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 38 | static bool isValid(QIODevice *pDevice); 39 | virtual qint64 getFileFormatSize(PDSTRUCT *pPdStruct) override; 40 | virtual QList getMapModesList() override; 41 | virtual _MEMORY_MAP getMemoryMap(MAPMODE mapMode = MAPMODE_UNKNOWN, PDSTRUCT *pPdStruct = nullptr) override; 42 | virtual FT getFileType() override; 43 | virtual QString getFileFormatExt() override; 44 | virtual QString getFileFormatExtsString() override; 45 | virtual QString getMIMEString() override; 46 | virtual QString getVersion() override; 47 | virtual QString getArch() override; 48 | virtual MODE getMode() override; 49 | virtual ENDIAN getEndian() override; 50 | 51 | // Streaming unpacking API 52 | virtual bool initUnpack(UNPACK_STATE *pState, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 53 | virtual ARCHIVERECORD infoCurrent(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 54 | virtual bool unpackCurrent(UNPACK_STATE *pState, QIODevice *pDevice, PDSTRUCT *pPdStruct = nullptr) override; 55 | virtual bool moveToNext(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 56 | virtual bool finishUnpack(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 57 | virtual QString structIDToString(quint32 nID) override; 58 | virtual QList getDataHeaders(const DATA_HEADERS_OPTIONS &dataHeadersOptions, PDSTRUCT *pPdStruct = nullptr) override; 59 | virtual QList getFileParts(quint32 nFileParts, qint32 nLimit = -1, PDSTRUCT *pPdStruct = nullptr) override; 60 | }; 61 | 62 | #endif // XLHA_H 63 | -------------------------------------------------------------------------------- /3rdparty/zlib/src/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /Algos/xstoredecoder.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xstoredecoder.h" 22 | #include 23 | 24 | const qint32 N_BUFFER_SIZE = 65536; 25 | 26 | XStoreDecoder::XStoreDecoder(QObject *parent) : QObject(parent) 27 | { 28 | } 29 | 30 | bool XStoreDecoder::decompress(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct) 31 | { 32 | bool bResult = false; 33 | 34 | if (pDecompressState && pDecompressState->pDeviceInput && pDecompressState->pDeviceOutput) { 35 | // Initialize error states 36 | pDecompressState->bReadError = false; 37 | pDecompressState->bWriteError = false; 38 | pDecompressState->nCountInput = 0; 39 | pDecompressState->nCountOutput = 0; 40 | 41 | // Set input device position 42 | if (pDecompressState->pDeviceInput) { 43 | pDecompressState->pDeviceInput->seek(pDecompressState->nInputOffset); 44 | } 45 | 46 | // Set output device position 47 | if (pDecompressState->pDeviceOutput) { 48 | pDecompressState->pDeviceOutput->seek(0); 49 | } 50 | 51 | // Allocate buffer for copying data 52 | char bufferIn[N_BUFFER_SIZE]; 53 | 54 | // Copy data from input to output 55 | for (qint64 nOffset = 0; (nOffset < pDecompressState->nInputLimit) && XBinary::isPdStructNotCanceled(pPdStruct);) { 56 | qint32 nBufferSize = qMin((qint32)(pDecompressState->nInputLimit - nOffset), N_BUFFER_SIZE); 57 | 58 | qint32 nRead = XBinary::_readDevice(bufferIn, nBufferSize, pDecompressState); 59 | 60 | if (nRead > 0) { 61 | XBinary::_writeDevice(bufferIn, nRead, pDecompressState); 62 | } else { 63 | break; 64 | } 65 | 66 | if (pDecompressState->bReadError || pDecompressState->bWriteError) { 67 | break; 68 | } 69 | 70 | nOffset += nRead; 71 | } 72 | 73 | // Success if no errors occurred 74 | bResult = !pDecompressState->bReadError && !pDecompressState->bWriteError; 75 | } 76 | 77 | return bResult; 78 | } 79 | -------------------------------------------------------------------------------- /3rdparty/lzfse/src/lzfse_decode.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015-2016, Apple Inc. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 9 | in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived 12 | from this software without specific prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 15 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 16 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 18 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 19 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20 | */ 21 | 22 | // LZFSE decode API 23 | 24 | #include "lzfse.h" 25 | #include "lzfse_internal.h" 26 | 27 | size_t lzfse_decode_scratch_size() { return sizeof(lzfse_decoder_state); } 28 | 29 | size_t lzfse_decode_buffer_with_scratch(uint8_t *__restrict dst_buffer, 30 | size_t dst_size, const uint8_t *__restrict src_buffer, 31 | size_t src_size, void *__restrict scratch_buffer) { 32 | lzfse_decoder_state *s = (lzfse_decoder_state *)scratch_buffer; 33 | memset(s, 0x00, sizeof(*s)); 34 | 35 | // Initialize state 36 | s->src = src_buffer; 37 | s->src_begin = src_buffer; 38 | s->src_end = s->src + src_size; 39 | s->dst = dst_buffer; 40 | s->dst_begin = dst_buffer; 41 | s->dst_end = dst_buffer + dst_size; 42 | 43 | // Decode 44 | int status = lzfse_decode(s); 45 | if (status == LZFSE_STATUS_DST_FULL) 46 | return dst_size; 47 | if (status != LZFSE_STATUS_OK) 48 | return 0; // failed 49 | return (size_t)(s->dst - dst_buffer); // bytes written 50 | } 51 | 52 | size_t lzfse_decode_buffer(uint8_t *__restrict dst_buffer, size_t dst_size, 53 | const uint8_t *__restrict src_buffer, 54 | size_t src_size, void *__restrict scratch_buffer) { 55 | int has_malloc = 0; 56 | size_t ret = 0; 57 | 58 | // Deal with the possible NULL pointer 59 | if (scratch_buffer == NULL) { 60 | // +1 in case scratch size could be zero 61 | scratch_buffer = malloc(lzfse_decode_scratch_size() + 1); 62 | has_malloc = 1; 63 | } 64 | if (scratch_buffer == NULL) 65 | return 0; 66 | ret = lzfse_decode_buffer_with_scratch(dst_buffer, 67 | dst_size, src_buffer, 68 | src_size, scratch_buffer); 69 | if (has_malloc) 70 | free(scratch_buffer); 71 | return ret; 72 | } 73 | -------------------------------------------------------------------------------- /Algos/xzipaesdecoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XZIPAESDECODER_H 22 | #define XZIPAESDECODER_H 23 | 24 | #include "xbinary.h" 25 | #include 26 | #include 27 | 28 | // Custom AES key structure (compatible with OpenSSL AES_KEY) 29 | struct CUSTOM_AES_KEY { 30 | quint32 rd_key[60]; // Round keys (max 14 rounds * 4 = 56, plus padding) 31 | qint32 rounds; // Number of rounds 32 | }; 33 | 34 | class XZipAESDecoder : public QObject { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit XZipAESDecoder(QObject *pParent = nullptr); 39 | 40 | static bool decrypt(XBinary::DATAPROCESS_STATE *pDecompressState, const QString &sPassword, XBinary::CRYPTO_METHOD cryptoMethod, 41 | XBinary::PDSTRUCT *pPdStruct = nullptr); 42 | static bool decrypt(XBinary::DATAPROCESS_STATE *pDecompressState, const QByteArray &baPassword, XBinary::CRYPTO_METHOD cryptoMethod, 43 | XBinary::PDSTRUCT *pPdStruct = nullptr); 44 | 45 | static bool encrypt(XBinary::DATAPROCESS_STATE *pCompressState, const QString &sPassword, XBinary::CRYPTO_METHOD cryptoMethod, 46 | XBinary::PDSTRUCT *pPdStruct = nullptr); 47 | static bool encrypt(XBinary::DATAPROCESS_STATE *pCompressState, const QByteArray &baPassword, XBinary::CRYPTO_METHOD cryptoMethod, 48 | XBinary::PDSTRUCT *pPdStruct = nullptr); 49 | 50 | private: 51 | static void pbkdf2(const QByteArray &baPassword, const QByteArray &baSalt, qint32 nIterations, qint32 nKeyLength, QByteArray &baResult); 52 | static bool deriveKeys(const QByteArray &baPassword, const QByteArray &baSalt, qint32 nKeySize, QByteArray &baAESKey, QByteArray &baPasswordVerify, 53 | QByteArray &baHMACKey, XBinary::PDSTRUCT *pPdStruct); 54 | static bool decryptAESCTR(const QByteArray &baKey, const QByteArray &baNonce, const char *pInputData, char *pOutputData, qint64 nSize, XBinary::PDSTRUCT *pPdStruct); 55 | static bool encryptAESCTR(const QByteArray &baKey, const QByteArray &baNonce, const char *pInputData, char *pOutputData, qint64 nSize, XBinary::PDSTRUCT *pPdStruct); 56 | 57 | // Custom AES implementation 58 | static qint32 custom_aes_set_encrypt_key(const quint8 *pUserKey, qint32 nBits, CUSTOM_AES_KEY *pKey); 59 | static void custom_aes_encrypt(const quint8 *pInput, quint8 *pOutput, const CUSTOM_AES_KEY *pKey); 60 | }; 61 | 62 | #endif // XZIPAESDECODER_H 63 | -------------------------------------------------------------------------------- /xnpm.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xnpm.h" 22 | 23 | XBinary::XCONVERT _TABLE_XNPM_STRUCTID[] = { 24 | {XNPM::STRUCTID_UNKNOWN, "Unknown", QObject::tr("Unknown")}, 25 | }; 26 | 27 | XNPM::XNPM(QIODevice *pDevice) : XTGZ(pDevice) 28 | { 29 | } 30 | 31 | bool XNPM::isValid(PDSTRUCT *pPdStruct) 32 | { 33 | bool bResult = false; 34 | 35 | XTGZ xtgz(getDevice()); 36 | 37 | if (xtgz.isValid()) { 38 | QList listArchiveRecords = xtgz.getRecords(20000, pPdStruct); 39 | 40 | bResult = isValid(&listArchiveRecords, pPdStruct); 41 | } 42 | 43 | return bResult; 44 | } 45 | 46 | bool XNPM::isValid(QIODevice *pDevice) 47 | { 48 | XNPM xtar(pDevice); 49 | 50 | return xtar.isValid(); 51 | } 52 | 53 | bool XNPM::isValid(QList *pListRecords, PDSTRUCT *pPdStruct) 54 | { 55 | bool bResult = false; 56 | 57 | bResult = XArchive::isArchiveRecordPresent("package/package.json", pListRecords, pPdStruct); 58 | 59 | return bResult; 60 | } 61 | 62 | QString XNPM::getFileFormatExt() 63 | { 64 | return "tgz"; 65 | } 66 | 67 | XBinary::FT XNPM::getFileType() 68 | { 69 | return FT_NPM; 70 | } 71 | 72 | XBinary::FILEFORMATINFO XNPM::getFileFormatInfo(PDSTRUCT *pPdStruct) 73 | { 74 | XBinary::FILEFORMATINFO result = {}; 75 | 76 | if (isValid(pPdStruct)) { 77 | result.bIsValid = true; 78 | result.nSize = getSize(); 79 | result.sExt = "tgz"; 80 | result.fileType = FT_NPM; 81 | } 82 | 83 | return result; 84 | } 85 | 86 | XBinary::MODE XNPM::getMode() 87 | { 88 | return MODE_32; 89 | } 90 | 91 | QString XNPM::getArch() 92 | { 93 | return tr("Universal"); 94 | } 95 | 96 | qint32 XNPM::getType() 97 | { 98 | return TYPE_PACKAGE; 99 | } 100 | 101 | QString XNPM::typeIdToString(qint32 nType) 102 | { 103 | QString sResult = tr("Unknown"); 104 | 105 | switch (nType) { 106 | case TYPE_PACKAGE: sResult = tr("Package"); 107 | } 108 | 109 | return sResult; 110 | } 111 | 112 | QString XNPM::getMIMEString() 113 | { 114 | return "application/x-npm"; 115 | } 116 | 117 | QString XNPM::structIDToString(quint32 nID) 118 | { 119 | return XBinary::XCONVERT_idToTransString(nID, _TABLE_XNPM_STRUCTID, sizeof(_TABLE_XNPM_STRUCTID) / sizeof(XBinary::XCONVERT)); 120 | } 121 | -------------------------------------------------------------------------------- /3rdparty/lzfse/src/lzfse_tunables.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015-2016, Apple Inc. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 9 | in the documentation and/or other materials provided with the distribution. 10 | 11 | 3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived 12 | from this software without specific prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 15 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 16 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 18 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 19 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20 | */ 21 | 22 | #ifndef LZFSE_TUNABLES_H 23 | #define LZFSE_TUNABLES_H 24 | 25 | // Parameters controlling details of the LZ-style match search. These values 26 | // may be modified to fine tune compression ratio vs. encoding speed, while 27 | // keeping the compressed format compatible with LZFSE. Note that 28 | // modifying them will also change the amount of work space required by 29 | // the encoder. The values here are those used in the compression library 30 | // on iOS and OS X. 31 | 32 | // Number of bits for hash function to produce. Should be in the range 33 | // [10, 16]. Larger values reduce the number of false-positive found during 34 | // the match search, and expand the history table, which may allow additional 35 | // matches to be found, generally improving the achieved compression ratio. 36 | // Larger values also increase the workspace size, and make it less likely 37 | // that the history table will be present in cache, which reduces performance. 38 | #define LZFSE_ENCODE_HASH_BITS 14 39 | 40 | // Number of positions to store for each line in the history table. May 41 | // be either 4 or 8. Using 8 doubles the size of the history table, which 42 | // increases the chance of finding matches (thus improving compression ratio), 43 | // but also increases the workspace size. 44 | #define LZFSE_ENCODE_HASH_WIDTH 4 45 | 46 | // Match length in bytes to cause immediate emission. Generally speaking, 47 | // LZFSE maintains multiple candidate matches and waits to decide which match 48 | // to emit until more information is available. When a match exceeds this 49 | // threshold, it is emitted immediately. Thus, smaller values may give 50 | // somewhat better performance, and larger values may give somewhat better 51 | // compression ratios. 52 | #define LZFSE_ENCODE_GOOD_MATCH 40 53 | 54 | // When the source buffer is very small, LZFSE doesn't compress as well as 55 | // some simpler algorithms. To maintain reasonable compression for these 56 | // cases, we transition to use LZVN instead if the size of the source buffer 57 | // is below this threshold. 58 | #define LZFSE_ENCODE_LZVN_THRESHOLD 4096 59 | 60 | #endif // LZFSE_TUNABLES_H 61 | -------------------------------------------------------------------------------- /xzlib.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2023-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XZLIB_H 22 | #define XZLIB_H 23 | 24 | #include "xarchive.h" 25 | 26 | class XZlib : public XArchive { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit XZlib(QIODevice *pDevice = nullptr); 31 | 32 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr); 33 | static bool isValid(QIODevice *pDevice); 34 | 35 | virtual qint64 getFileFormatSize(PDSTRUCT *pPdStruct); 36 | 37 | virtual QList getMapModesList(); 38 | virtual _MEMORY_MAP getMemoryMap(MAPMODE mapMode = MAPMODE_UNKNOWN, PDSTRUCT *pPdStruct = nullptr); 39 | virtual FT getFileType(); 40 | virtual QString getVersion(); 41 | virtual QString getFileFormatExt(); 42 | virtual QString getFileFormatExtsString(); 43 | virtual QString getMIMEString(); 44 | virtual QList getFileParts(quint32 nFileParts, qint32 nLimit = -1, PDSTRUCT *pPdStruct = nullptr) override; 45 | 46 | // Streaming unpacking API 47 | virtual bool initUnpack(UNPACK_STATE *pState, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 48 | virtual ARCHIVERECORD infoCurrent(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 49 | virtual bool unpackCurrent(UNPACK_STATE *pState, QIODevice *pDevice, PDSTRUCT *pPdStruct = nullptr) override; 50 | virtual bool moveToNext(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 51 | virtual bool finishUnpack(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 52 | 53 | // Streaming packing API 54 | virtual bool initPack(PACK_STATE *pState, QIODevice *pDevice, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 55 | virtual bool addDevice(PACK_STATE *pState, QIODevice *pDevice, PDSTRUCT *pPdStruct = nullptr) override; 56 | virtual bool addFile(PACK_STATE *pState, const QString &sFileName, PDSTRUCT *pPdStruct = nullptr) override; 57 | virtual bool addFolder(PACK_STATE *pState, const QString &sDirectoryPath, PDSTRUCT *pPdStruct = nullptr) override; 58 | virtual bool finishPack(PACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 59 | 60 | private: 61 | struct ZLIB_UNPACK_CONTEXT { 62 | QString sFileName; 63 | qint64 nHeaderSize; 64 | qint64 nCompressedSize; 65 | qint64 nUncompressedSize; 66 | quint32 nAdler32; 67 | }; 68 | 69 | struct ZLIB_PACK_CONTEXT { 70 | bool bDataAdded; // Track if data has been added (only one stream allowed) 71 | }; 72 | }; 73 | 74 | #endif // XZLIB_H 75 | -------------------------------------------------------------------------------- /xdeb.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xdeb.h" 22 | 23 | XBinary::XCONVERT _TABLE_XDEB_STRUCTID[] = { 24 | {XDEB::STRUCTID_UNKNOWN, "Unknown", QObject::tr("Unknown")}, 25 | }; 26 | 27 | XDEB::XDEB(QIODevice *pDevice) : X_Ar(pDevice) 28 | { 29 | } 30 | 31 | bool XDEB::isValid(PDSTRUCT *pPdStruct) 32 | { 33 | bool bResult = false; 34 | 35 | X_Ar xar(getDevice()); 36 | 37 | if (xar.isValid()) { 38 | QList listArchiveRecords = xar.getRecords(10, pPdStruct); // TODO remove 39 | 40 | bResult = isValid(&listArchiveRecords, pPdStruct); 41 | } 42 | 43 | return bResult; 44 | } 45 | 46 | bool XDEB::isValid(QIODevice *pDevice) 47 | { 48 | XDEB xdeb(pDevice); 49 | 50 | return xdeb.isValid(); 51 | } 52 | 53 | bool XDEB::isValid(QList *pListRecords, PDSTRUCT *pPdStruct) 54 | { 55 | return isArchiveRecordPresent("debian-binary", pListRecords, pPdStruct); 56 | } 57 | 58 | QString XDEB::getVersion() 59 | { 60 | return getFileFormatInfo(nullptr).sVersion; 61 | } 62 | 63 | QString XDEB::getFileFormatExt() 64 | { 65 | return "deb"; 66 | } 67 | 68 | QString XDEB::getMIMEString() 69 | { 70 | return "application/vnd.debian.binary-package"; 71 | } 72 | 73 | XBinary::FILEFORMATINFO XDEB::getFileFormatInfo(PDSTRUCT *pPdStruct) 74 | { 75 | XBinary::FILEFORMATINFO result = {}; 76 | 77 | QList listArchiveRecords = getRecords(3, nullptr); 78 | 79 | if (isValid(&listArchiveRecords, pPdStruct)) { 80 | result.bIsValid = true; 81 | result.nSize = getSize(); 82 | result.sExt = "deb"; 83 | result.fileType = FT_DEB; 84 | 85 | RECORD record = getArchiveRecord("debian-binary", &listArchiveRecords); 86 | 87 | if (record.spInfo.nUncompressedSize < 10) { 88 | QByteArray baVersion = decompress(&record); 89 | result.sVersion.append(baVersion); 90 | result.sVersion = result.sVersion.trimmed(); 91 | } 92 | 93 | result.osName = OSNAME_DEBIANLINUX; 94 | 95 | result.sArch = getArch(); 96 | result.mode = getMode(); 97 | result.sType = typeIdToString(getType()); 98 | result.endian = getEndian(); 99 | } 100 | 101 | return result; 102 | } 103 | 104 | XBinary::FT XDEB::getFileType() 105 | { 106 | return FT_DEB; 107 | } 108 | 109 | QString XDEB::structIDToString(quint32 nID) 110 | { 111 | return XBinary::XCONVERT_idToTransString(nID, _TABLE_XDEB_STRUCTID, sizeof(_TABLE_XDEB_STRUCTID) / sizeof(XBinary::XCONVERT)); 112 | } 113 | -------------------------------------------------------------------------------- /Algos/xppmdrangedecoder.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xppmdrangedecoder.h" 22 | 23 | XPPMdRangeDecoder::XPPMdRangeDecoder() 24 | { 25 | m_pDevice = nullptr; 26 | m_nRange = 0; 27 | m_nCode = 0; 28 | m_bError = false; 29 | } 30 | 31 | XPPMdRangeDecoder::~XPPMdRangeDecoder() 32 | { 33 | } 34 | 35 | bool XPPMdRangeDecoder::init(QIODevice *pDevice) 36 | { 37 | m_pDevice = pDevice; 38 | m_bError = false; 39 | 40 | if (!m_pDevice) { 41 | m_bError = true; 42 | return false; 43 | } 44 | 45 | // Initialize range decoder 46 | m_nRange = 0xFFFFFFFF; 47 | m_nCode = 0; 48 | 49 | // Read initial 4 bytes for Code value (matching 7-Zip's Ppmd8_Init_RangeDec) 50 | for (qint32 i = 0; i < 4; i++) { 51 | m_nCode = (m_nCode << 8) | readByte(); 52 | } 53 | 54 | if (m_bError) { 55 | return false; 56 | } 57 | 58 | return true; 59 | } 60 | 61 | quint32 XPPMdRangeDecoder::getThreshold(quint32 nTotal) 62 | { 63 | // Calculate threshold = (Code - Low) * Total / Range 64 | // In 7-Zip's implementation: (Code / (Range / Total)) 65 | return m_nCode / (m_nRange / nTotal); 66 | } 67 | 68 | void XPPMdRangeDecoder::decode(quint32 nStart, quint32 nSize, quint32 nTotal) 69 | { 70 | // Update range decoder state after decoding a symbol 71 | // Range = Range / Total 72 | quint32 nNewRange = m_nRange / nTotal; 73 | 74 | // Low = Low + Start * NewRange 75 | // Code = Code - Start * NewRange 76 | m_nCode -= nStart * nNewRange; 77 | 78 | // Range = Size * NewRange 79 | m_nRange = nSize * nNewRange; 80 | 81 | // Normalize if needed 82 | normalize(); 83 | } 84 | 85 | void XPPMdRangeDecoder::normalize() 86 | { 87 | // Normalize range when it becomes too small 88 | // This matches 7-Zip's range decoder normalization 89 | while (m_nRange < 0x01000000) { 90 | m_nRange <<= 8; 91 | m_nCode = (m_nCode << 8) | readByte(); 92 | } 93 | } 94 | 95 | bool XPPMdRangeDecoder::isFinishedOK() const 96 | { 97 | // Stream is finished correctly if Code equals 0 98 | return (m_nCode == 0) && !m_bError; 99 | } 100 | 101 | quint8 XPPMdRangeDecoder::readByte() 102 | { 103 | if (m_bError || !m_pDevice) { 104 | m_bError = true; 105 | return 0; 106 | } 107 | 108 | char cByte = 0; 109 | qint64 nRead = m_pDevice->read(&cByte, 1); 110 | 111 | if (nRead != 1) { 112 | m_bError = true; 113 | return 0; 114 | } 115 | 116 | return (quint8)cByte; 117 | } 118 | -------------------------------------------------------------------------------- /xbzip2.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XBZIP2_H 22 | #define XBZIP2_H 23 | 24 | #include "xarchive.h" 25 | 26 | class XBZIP2 : public XArchive { 27 | Q_OBJECT 28 | 29 | public: 30 | enum BZIP2_TYPE { 31 | TYPE_UNKNOWN = 0, 32 | TYPE_BZ2 33 | }; 34 | 35 | struct BZIP2_HEADER { 36 | char magic[3]; // BZh 37 | quint8 blockSize; // '1' - '9' (file-level compression) 38 | }; 39 | 40 | enum STRUCTID { 41 | STRUCTID_UNKNOWN = 0, 42 | STRUCTID_BZIP2_HEADER, 43 | STRUCTID_BLOCK_HEADER 44 | }; 45 | 46 | explicit XBZIP2(QIODevice *pDevice = nullptr); 47 | ~XBZIP2(); 48 | 49 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 50 | virtual MODE getMode() override; 51 | virtual qint32 getType() override; 52 | virtual QString typeIdToString(qint32 nType) override; 53 | virtual QString getFileFormatExt() override; 54 | virtual FT getFileType() override; 55 | virtual QString getFileFormatExtsString() override; 56 | virtual qint64 getFileFormatSize(PDSTRUCT *pPdStruct) override; 57 | virtual QString getMIMEString() override; 58 | virtual ENDIAN getEndian() override; 59 | virtual OSNAME getOsName() override; 60 | virtual QList getMapModesList() override; 61 | virtual _MEMORY_MAP getMemoryMap(MAPMODE mapMode = MAPMODE_UNKNOWN, PDSTRUCT *pPdStruct = nullptr) override; 62 | virtual QString structIDToString(quint32 nID) override; 63 | virtual QList getDataHeaders(const DATA_HEADERS_OPTIONS &dataHeadersOptions, PDSTRUCT *pPdStruct) override; 64 | virtual QList getFileParts(quint32 nFileParts, qint32 nLimit = -1, PDSTRUCT *pPdStruct = nullptr) override; 65 | 66 | // Streaming unpacking API 67 | virtual bool initUnpack(UNPACK_STATE *pState, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 68 | virtual ARCHIVERECORD infoCurrent(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 69 | virtual bool unpackCurrent(UNPACK_STATE *pState, QIODevice *pDevice, PDSTRUCT *pPdStruct = nullptr) override; 70 | virtual bool moveToNext(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 71 | virtual bool finishUnpack(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 72 | 73 | BZIP2_HEADER _read_BZIP2_HEADER(qint64 nOffset); 74 | 75 | private: 76 | // Format-specific unpacking context 77 | struct BZIP2_UNPACK_CONTEXT { 78 | qint64 nHeaderSize; // Size of BZIP2 header (4 bytes) 79 | qint64 nCompressedSize; // Size of compressed data 80 | qint64 nUncompressedSize; // Size of uncompressed data 81 | QString sFileName; // Original file name (if available) 82 | }; 83 | }; 84 | 85 | #endif // XBZIP2_H 86 | -------------------------------------------------------------------------------- /3rdparty/ppmd/src/Precomp.h: -------------------------------------------------------------------------------- 1 | /* Precomp.h -- precompilation file 2 | 2024-01-25 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef ZIP7_INC_PRECOMP_H 5 | #define ZIP7_INC_PRECOMP_H 6 | 7 | /* 8 | this file must be included before another *.h files and before . 9 | this file is included from the following files: 10 | C\*.c 11 | C\Util\*\Precomp.h <- C\Util\*\*.c 12 | CPP\Common\Common.h <- *\StdAfx.h <- *\*.cpp 13 | 14 | this file can set the following macros: 15 | Z7_LARGE_PAGES 1 16 | Z7_LONG_PATH 1 17 | Z7_WIN32_WINNT_MIN 0x0500 (or higher) : we require at least win2000+ for 7-Zip 18 | _WIN32_WINNT 0x0500 (or higher) 19 | WINVER _WIN32_WINNT 20 | UNICODE 1 21 | _UNICODE 1 22 | */ 23 | 24 | #include "Compiler.h" 25 | 26 | #ifdef _MSC_VER 27 | // #pragma warning(disable : 4206) // nonstandard extension used : translation unit is empty 28 | #if _MSC_VER >= 1912 29 | // #pragma warning(disable : 5039) // pointer or reference to potentially throwing function passed to 'extern "C"' function under - EHc.Undefined behavior may occur if this function throws an exception. 30 | #endif 31 | #endif 32 | 33 | /* 34 | // for debug: 35 | #define UNICODE 1 36 | #define _UNICODE 1 37 | #define _WIN32_WINNT 0x0500 // win2000 38 | #ifndef WINVER 39 | #define WINVER _WIN32_WINNT 40 | #endif 41 | */ 42 | 43 | #ifdef _WIN32 44 | /* 45 | this "Precomp.h" file must be included before , 46 | if we want to define _WIN32_WINNT before . 47 | */ 48 | 49 | #ifndef Z7_LARGE_PAGES 50 | #ifndef Z7_NO_LARGE_PAGES 51 | #define Z7_LARGE_PAGES 1 52 | #endif 53 | #endif 54 | 55 | #ifndef Z7_LONG_PATH 56 | #ifndef Z7_NO_LONG_PATH 57 | #define Z7_LONG_PATH 1 58 | #endif 59 | #endif 60 | 61 | #ifndef Z7_DEVICE_FILE 62 | #ifndef Z7_NO_DEVICE_FILE 63 | // #define Z7_DEVICE_FILE 1 64 | #endif 65 | #endif 66 | 67 | // we don't change macros if included after 68 | #ifndef _WINDOWS_ 69 | 70 | #ifndef Z7_WIN32_WINNT_MIN 71 | #if defined(_M_ARM64) || defined(__aarch64__) 72 | // #define Z7_WIN32_WINNT_MIN 0x0a00 // win10 73 | #define Z7_WIN32_WINNT_MIN 0x0600 // vista 74 | #elif defined(_M_ARM) && defined(_M_ARMT) && defined(_M_ARM_NT) 75 | // #define Z7_WIN32_WINNT_MIN 0x0602 // win8 76 | #define Z7_WIN32_WINNT_MIN 0x0600 // vista 77 | #elif defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) || defined(_M_IA64) 78 | #define Z7_WIN32_WINNT_MIN 0x0503 // win2003 79 | // #elif defined(_M_IX86) || defined(__i386__) 80 | // #define Z7_WIN32_WINNT_MIN 0x0500 // win2000 81 | #else // x86 and another(old) systems 82 | #define Z7_WIN32_WINNT_MIN 0x0500 // win2000 83 | // #define Z7_WIN32_WINNT_MIN 0x0502 // win2003 // for debug 84 | #endif 85 | #endif // Z7_WIN32_WINNT_MIN 86 | 87 | 88 | #ifndef Z7_DO_NOT_DEFINE_WIN32_WINNT 89 | #ifdef _WIN32_WINNT 90 | // #error Stop_Compiling_Bad_WIN32_WINNT 91 | #else 92 | #ifndef Z7_NO_DEFINE_WIN32_WINNT 93 | Z7_DIAGNOSTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER 94 | #define _WIN32_WINNT Z7_WIN32_WINNT_MIN 95 | Z7_DIAGNOSTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER 96 | #endif 97 | #endif // _WIN32_WINNT 98 | 99 | #ifndef WINVER 100 | #define WINVER _WIN32_WINNT 101 | #endif 102 | #endif // Z7_DO_NOT_DEFINE_WIN32_WINNT 103 | 104 | 105 | #ifndef _MBCS 106 | #ifndef Z7_NO_UNICODE 107 | // UNICODE and _UNICODE are used by and by 7-zip code. 108 | 109 | #ifndef UNICODE 110 | #define UNICODE 1 111 | #endif 112 | 113 | #ifndef _UNICODE 114 | Z7_DIAGNOSTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER 115 | #define _UNICODE 1 116 | Z7_DIAGNOSTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER 117 | #endif 118 | 119 | #endif // Z7_NO_UNICODE 120 | #endif // _MBCS 121 | #endif // _WINDOWS_ 122 | 123 | // #include "7zWindows.h" 124 | 125 | #endif // _WIN32 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /xmachofat.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XMACHOFAT_H 22 | #define XMACHOFAT_H 23 | 24 | #include "xarchive.h" 25 | #include "xmach.h" 26 | 27 | class XMACHOFat : public XArchive { 28 | Q_OBJECT 29 | 30 | public: 31 | /*! 32 | \brief XMACHOFat class for handling Universal Mach-O (fat) binary files 33 | Universal Mach-O files contain multiple architecture-specific Mach-O binaries 34 | in a single file, allowing for multi-architecture support on macOS. 35 | */ 36 | enum STRUCTID { 37 | STRUCTID_UNKNOWN = 0, 38 | STRUCTID_HEADER, 39 | STRUCTID_ARCHITECTURE 40 | }; 41 | 42 | enum TYPE { 43 | TYPE_UNKNOWN = 0, 44 | TYPE_BUNDLE, 45 | }; 46 | 47 | explicit XMACHOFat(QIODevice *pDevice = nullptr); 48 | 49 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr); 50 | static bool isValid(QIODevice *pDevice); 51 | virtual ENDIAN getEndian(); 52 | virtual quint64 getNumberOfRecords(PDSTRUCT *pPdStruct); 53 | virtual QList getRecords(qint32 nLimit, PDSTRUCT *pPdStruct); 54 | 55 | virtual OSNAME getOsName(); 56 | virtual QString getFileFormatExt(); 57 | virtual QString getFileFormatExtsString(); 58 | virtual qint64 getFileFormatSize(PDSTRUCT *pPdStruct); 59 | virtual QList getMapModesList(); 60 | virtual _MEMORY_MAP getMemoryMap(MAPMODE mapMode = MAPMODE_UNKNOWN, PDSTRUCT *pPdStruct = nullptr); 61 | virtual QString getArch(); 62 | virtual qint32 getType(); 63 | virtual QString typeIdToString(qint32 nType); 64 | virtual FT getFileType(); 65 | virtual QString getMIMEString(); 66 | virtual bool isArchive(); 67 | virtual QString structIDToString(quint32 nID); 68 | 69 | virtual bool initUnpack(UNPACK_STATE *pState, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 70 | virtual ARCHIVERECORD infoCurrent(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 71 | virtual bool unpackCurrent(UNPACK_STATE *pState, QIODevice *pDevice, PDSTRUCT *pPdStruct = nullptr) override; 72 | virtual bool moveToNext(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 73 | virtual bool finishUnpack(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 74 | 75 | XMACH_DEF::fat_header read_fat_header(); 76 | XMACH_DEF::fat_arch read_fat_arch(qint32 nIndex); 77 | QList read_fat_arch_list(PDSTRUCT *pPdStruct); 78 | 79 | static QMap getHeaderMagics(); 80 | static QMap getHeaderMagicsS(); 81 | 82 | QString getArchitectureString(qint32 nIndex); 83 | qint64 getArchitectureOffset(qint32 nIndex); 84 | qint64 getArchitectureSize(qint32 nIndex); 85 | bool isArchitectureValid(qint32 nIndex); 86 | }; 87 | 88 | #endif // XMACHOFAT_H 89 | -------------------------------------------------------------------------------- /3rdparty/bzip2/src/randtable.c: -------------------------------------------------------------------------------- 1 | 2 | /*-------------------------------------------------------------*/ 3 | /*--- Table for randomising repetitive blocks ---*/ 4 | /*--- randtable.c ---*/ 5 | /*-------------------------------------------------------------*/ 6 | 7 | /* ------------------------------------------------------------------ 8 | This file is part of bzip2/libbzip2, a program and library for 9 | lossless, block-sorting data compression. 10 | 11 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 12 | Copyright (C) 1996-2010 Julian Seward 13 | 14 | Please read the WARNING, DISCLAIMER and PATENTS sections in the 15 | README file. 16 | 17 | This program is released under the terms of the license contained 18 | in the file LICENSE. 19 | ------------------------------------------------------------------ */ 20 | 21 | 22 | #include "bzlib_private.h" 23 | 24 | 25 | /*---------------------------------------------*/ 26 | Int32 BZ2_rNums[512] = { 27 | 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, 28 | 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, 29 | 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, 30 | 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, 31 | 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, 32 | 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, 33 | 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, 34 | 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, 35 | 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, 36 | 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, 37 | 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, 38 | 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, 39 | 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, 40 | 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, 41 | 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, 42 | 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, 43 | 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, 44 | 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, 45 | 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, 46 | 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, 47 | 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, 48 | 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, 49 | 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, 50 | 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, 51 | 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, 52 | 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, 53 | 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, 54 | 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, 55 | 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, 56 | 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, 57 | 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, 58 | 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, 59 | 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, 60 | 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, 61 | 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, 62 | 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, 63 | 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, 64 | 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, 65 | 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, 66 | 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, 67 | 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, 68 | 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, 69 | 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, 70 | 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, 71 | 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, 72 | 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, 73 | 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, 74 | 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, 75 | 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, 76 | 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, 77 | 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, 78 | 936, 638 79 | }; 80 | 81 | 82 | /*-------------------------------------------------------------*/ 83 | /*--- end randtable.c ---*/ 84 | /*-------------------------------------------------------------*/ 85 | -------------------------------------------------------------------------------- /xszdd.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XSZDD_H 22 | #define XSZDD_H 23 | 24 | #include "xarchive.h" 25 | 26 | class XSZDD : public XArchive { 27 | Q_OBJECT 28 | public: 29 | enum STRUCTID { 30 | STRUCTID_UNKNOWN = 0, 31 | STRUCTID_SZDD_HEADER 32 | }; 33 | 34 | #pragma pack(push) 35 | #pragma pack(1) 36 | struct SZDD_HEADER { 37 | char signature[8]; // "SZDD" magic 38 | quint8 compression_mode; // Always 0x41 ("A") 39 | quint8 missing_char; // Character missing from end of filename (0=unknown) 40 | quint32 uncompressed_size; // Uncompressed file size 41 | }; 42 | #pragma pack(pop) 43 | explicit XSZDD(QIODevice *pDevice = nullptr); 44 | ~XSZDD() override; 45 | 46 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 47 | static bool isValid(QIODevice *pDevice); 48 | virtual FT getFileType() override; 49 | virtual MODE getMode() override; 50 | virtual QString getMIMEString() override; 51 | virtual qint32 getType() override; 52 | virtual ENDIAN getEndian() override; 53 | virtual QString getArch() override; 54 | virtual QString getFileFormatExt() override; 55 | virtual QString getFileFormatExtsString() override; 56 | virtual qint64 getFileFormatSize(PDSTRUCT *pPdStruct) override; 57 | virtual bool isSigned() override; 58 | virtual OSNAME getOsName() override; 59 | virtual QString getOsVersion() override; 60 | virtual QString getVersion() override; 61 | virtual bool isEncrypted() override; 62 | virtual QList getMapModesList() override; 63 | virtual _MEMORY_MAP getMemoryMap(MAPMODE mapMode = MAPMODE_UNKNOWN, PDSTRUCT *pPdStruct = nullptr) override; 64 | 65 | virtual QString structIDToString(quint32 nID) override; 66 | virtual QList getDataHeaders(const DATA_HEADERS_OPTIONS &dataHeadersOptions, PDSTRUCT *pPdStruct) override; 67 | virtual QList getFileParts(quint32 nFileParts, qint32 nLimit = -1, PDSTRUCT *pPdStruct = nullptr) override; 68 | 69 | SZDD_HEADER _read_SZDD_HEADER(qint64 nOffset); 70 | 71 | // Streaming unpacking API 72 | virtual bool initUnpack(UNPACK_STATE *pState, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 73 | virtual ARCHIVERECORD infoCurrent(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 74 | virtual bool unpackCurrent(UNPACK_STATE *pState, QIODevice *pDevice, PDSTRUCT *pPdStruct = nullptr) override; 75 | virtual bool moveToNext(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 76 | virtual bool finishUnpack(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 77 | 78 | private: 79 | // Format-specific unpacking context 80 | struct SZDD_UNPACK_CONTEXT { 81 | qint64 nHeaderSize; // Size of SZDD header 82 | qint64 nCompressedSize; // Size of compressed data 83 | qint64 nUncompressedSize; // Size of uncompressed data 84 | QString sFileName; // Original file name 85 | }; 86 | }; 87 | 88 | #endif // XSZDD_H 89 | -------------------------------------------------------------------------------- /xsquashfs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XSQUASHFS_H 22 | #define XSQUASHFS_H 23 | 24 | #include "xarchive.h" 25 | 26 | class XSquashfs : public XArchive { 27 | Q_OBJECT 28 | 29 | #pragma pack(push) 30 | #pragma pack(1) 31 | struct SQUASHFS_HEADER { 32 | quint32 nMagic; // Magic number: 0x73717368 ("sqsh") 33 | quint32 nInodesCount; // Number of inodes 34 | quint32 nCreationTime; // Creation time (seconds since epoch) 35 | quint32 nBlockSize; // Block size (power of 2) 36 | quint32 nFragmentsCount; // Number of fragments 37 | quint16 nCompressionType; // Compression method 38 | quint16 nBlockLog; // Log2 of block size 39 | quint16 nFlags; // Flags 40 | quint16 nNoIds; // Number of unique IDs 41 | quint32 nVersionMajor; // Version major 42 | quint32 nVersionMinor; // Version minor 43 | quint64 nRootInodeRef; // Root inode reference 44 | quint64 nBytesUsed; // Bytes used 45 | quint64 nIdTableStart; // ID table start block 46 | quint64 nXattrTableStart; // Xattr table start block 47 | quint64 nInodeTableStart; // Inode table start block 48 | quint64 nDirectoryTableStart; // Directory table start block 49 | quint64 nFragmentTableStart; // Fragment table start block 50 | quint64 nExportTableStart; // Export table start block 51 | }; 52 | #pragma pack(pop) 53 | 54 | enum SQUASHFS_COMPRESSION { 55 | COMP_UNKNOWN = 0, 56 | COMP_GZIP = 1, 57 | COMP_LZMA = 2, 58 | COMP_LZO = 3, 59 | COMP_XZ = 4, 60 | COMP_LZ4 = 5, 61 | COMP_ZSTD = 6 62 | }; 63 | 64 | public: 65 | enum STRUCTID { 66 | STRUCTID_UNKNOWN = 0, 67 | STRUCTID_HEADER, 68 | STRUCTID_SUPERBLOCK 69 | }; 70 | 71 | explicit XSquashfs(QIODevice *pDevice = nullptr); 72 | ~XSquashfs(); 73 | 74 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 75 | static bool isValid(QIODevice *pDevice); 76 | virtual QString getFileFormatExt() override; 77 | virtual QString getFileFormatExtsString() override; 78 | virtual QString getMIMEString() override; 79 | virtual FT getFileType() override; 80 | virtual QList getMapModesList() override; 81 | virtual _MEMORY_MAP getMemoryMap(MAPMODE mapMode = MAPMODE_UNKNOWN, PDSTRUCT *pPdStruct = nullptr) override; 82 | virtual QString structIDToString(quint32 nID) override; 83 | virtual QList getDataHeaders(const DATA_HEADERS_OPTIONS &dataHeadersOptions, PDSTRUCT *pPdStruct) override; 84 | virtual QList getFileParts(quint32 nFileParts, qint32 nLimit = -1, PDSTRUCT *pPdStruct = nullptr) override; 85 | 86 | SQUASHFS_HEADER _readHeader(qint64 nOffset); 87 | 88 | private: 89 | SQUASHFS_COMPRESSION _getCompressionMethod(quint16 nType); 90 | QString _getCompressionMethodString(SQUASHFS_COMPRESSION comp); 91 | }; 92 | 93 | #endif // XSQUASHFS_H 94 | -------------------------------------------------------------------------------- /3rdparty/lzma/src/Lzma2Dec.h: -------------------------------------------------------------------------------- 1 | /* Lzma2Dec.h -- LZMA2 Decoder 2 | 2023-03-03 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef ZIP7_INC_LZMA2_DEC_H 5 | #define ZIP7_INC_LZMA2_DEC_H 6 | 7 | #include "LzmaDec.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | /* ---------- State Interface ---------- */ 12 | 13 | typedef struct 14 | { 15 | unsigned state; 16 | Byte control; 17 | Byte needInitLevel; 18 | Byte isExtraMode; 19 | Byte _pad_; 20 | UInt32 packSize; 21 | UInt32 unpackSize; 22 | CLzmaDec decoder; 23 | } CLzma2Dec; 24 | 25 | #define Lzma2Dec_CONSTRUCT(p) LzmaDec_CONSTRUCT(&(p)->decoder) 26 | #define Lzma2Dec_Construct(p) Lzma2Dec_CONSTRUCT(p) 27 | #define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc) 28 | #define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc) 29 | 30 | SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc); 31 | SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc); 32 | void Lzma2Dec_Init(CLzma2Dec *p); 33 | 34 | /* 35 | finishMode: 36 | It has meaning only if the decoding reaches output limit (*destLen or dicLimit). 37 | LZMA_FINISH_ANY - use smallest number of input bytes 38 | LZMA_FINISH_END - read EndOfStream marker after decoding 39 | 40 | Returns: 41 | SZ_OK 42 | status: 43 | LZMA_STATUS_FINISHED_WITH_MARK 44 | LZMA_STATUS_NOT_FINISHED 45 | LZMA_STATUS_NEEDS_MORE_INPUT 46 | SZ_ERROR_DATA - Data error 47 | */ 48 | 49 | SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, 50 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); 51 | 52 | SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, 53 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); 54 | 55 | 56 | /* ---------- LZMA2 block and chunk parsing ---------- */ 57 | 58 | /* 59 | Lzma2Dec_Parse() parses compressed data stream up to next independent block or next chunk data. 60 | It can return LZMA_STATUS_* code or LZMA2_PARSE_STATUS_* code: 61 | - LZMA2_PARSE_STATUS_NEW_BLOCK - there is new block, and 1 additional byte (control byte of next block header) was read from input. 62 | - LZMA2_PARSE_STATUS_NEW_CHUNK - there is new chunk, and only lzma2 header of new chunk was read. 63 | CLzma2Dec::unpackSize contains unpack size of that chunk 64 | */ 65 | 66 | typedef enum 67 | { 68 | /* 69 | LZMA_STATUS_NOT_SPECIFIED // data error 70 | LZMA_STATUS_FINISHED_WITH_MARK 71 | LZMA_STATUS_NOT_FINISHED // 72 | LZMA_STATUS_NEEDS_MORE_INPUT 73 | LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK // unused 74 | */ 75 | LZMA2_PARSE_STATUS_NEW_BLOCK = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK + 1, 76 | LZMA2_PARSE_STATUS_NEW_CHUNK 77 | } ELzma2ParseStatus; 78 | 79 | ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p, 80 | SizeT outSize, // output size 81 | const Byte *src, SizeT *srcLen, 82 | int checkFinishBlock // set (checkFinishBlock = 1), if it must read full input data, if decoder.dicPos reaches blockMax position. 83 | ); 84 | 85 | /* 86 | LZMA2 parser doesn't decode LZMA chunks, so we must read 87 | full input LZMA chunk to decode some part of LZMA chunk. 88 | 89 | Lzma2Dec_GetUnpackExtra() returns the value that shows 90 | max possible number of output bytes that can be output by decoder 91 | at current input positon. 92 | */ 93 | 94 | #define Lzma2Dec_GetUnpackExtra(p) ((p)->isExtraMode ? (p)->unpackSize : 0) 95 | 96 | 97 | /* ---------- One Call Interface ---------- */ 98 | 99 | /* 100 | finishMode: 101 | It has meaning only if the decoding reaches output limit (*destLen). 102 | LZMA_FINISH_ANY - use smallest number of input bytes 103 | LZMA_FINISH_END - read EndOfStream marker after decoding 104 | 105 | Returns: 106 | SZ_OK 107 | status: 108 | LZMA_STATUS_FINISHED_WITH_MARK 109 | LZMA_STATUS_NOT_FINISHED 110 | SZ_ERROR_DATA - Data error 111 | SZ_ERROR_MEM - Memory allocation error 112 | SZ_ERROR_UNSUPPORTED - Unsupported properties 113 | SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). 114 | */ 115 | 116 | SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, 117 | Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAllocPtr alloc); 118 | 119 | EXTERN_C_END 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /xgzip.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XGZIP_H 22 | #define XGZIP_H 23 | 24 | #include "xarchive.h" 25 | 26 | class XGzip : public XArchive { 27 | Q_OBJECT 28 | public: 29 | enum GZIP_TYPE { 30 | TYPE_UNKNOWN = 0, 31 | TYPE_GZ 32 | }; 33 | 34 | #pragma pack(push) 35 | #pragma pack(1) 36 | struct GZIP_HEADER { 37 | quint16 nMagic; // 0x1f 0x8b Magic number identifying file type 38 | quint8 nCompressionMethod; // Compression Method * 0-7 (Reserved) * 8 (Deflate) 39 | quint8 nFileFlags; // File Flags 40 | quint32 nTimeStamp; // 32-bit timestamp 41 | quint8 nCompressionFlags; // Compression flags 42 | quint8 nOS; // Operating system ID 43 | }; 44 | #pragma pack(pop) 45 | 46 | enum STRUCTID { 47 | STRUCTID_UNKNOWN = 0, 48 | STRUCTID_GZIP_HEADER, 49 | STRUCTID_STREAM 50 | }; 51 | 52 | explicit XGzip(QIODevice *pDevice = nullptr); 53 | ~XGzip(); 54 | 55 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 56 | static bool isValid(QIODevice *pDevice); 57 | virtual MODE getMode() override; 58 | virtual qint32 getType() override; 59 | virtual QString typeIdToString(qint32 nType) override; 60 | virtual QString getFileFormatExt() override; 61 | virtual FT getFileType() override; 62 | virtual QString getFileFormatExtsString() override; 63 | virtual qint64 getFileFormatSize(PDSTRUCT *pPdStruct) override; 64 | virtual QString getMIMEString() override; 65 | virtual ENDIAN getEndian() override; 66 | virtual OSNAME getOsName() override; 67 | virtual QList getMapModesList() override; 68 | virtual _MEMORY_MAP getMemoryMap(MAPMODE mapMode = MAPMODE_UNKNOWN, PDSTRUCT *pPdStruct = nullptr) override; 69 | virtual QString structIDToString(quint32 nID) override; 70 | virtual QList getDataHeaders(const DATA_HEADERS_OPTIONS &dataHeadersOptions, PDSTRUCT *pPdStruct) override; 71 | virtual QList getFileParts(quint32 nFileParts, qint32 nLimit = -1, PDSTRUCT *pPdStruct = nullptr) override; 72 | 73 | // Streaming unpacking API 74 | virtual bool initUnpack(UNPACK_STATE *pState, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 75 | virtual ARCHIVERECORD infoCurrent(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 76 | virtual bool unpackCurrent(UNPACK_STATE *pState, QIODevice *pDevice, PDSTRUCT *pPdStruct = nullptr) override; 77 | virtual bool moveToNext(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 78 | virtual bool finishUnpack(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 79 | 80 | GZIP_HEADER _read_GZIP_HEADER(qint64 nOffset); 81 | qint64 getHeaderSize(); 82 | 83 | private: 84 | // Format-specific unpacking context 85 | struct GZIP_UNPACK_CONTEXT { 86 | qint64 nHeaderSize; // Size of GZIP header (variable) 87 | qint64 nCompressedSize; // Size of compressed data 88 | qint64 nUncompressedSize; // Size of uncompressed data 89 | QString sFileName; // Original file name (if available) 90 | }; 91 | }; 92 | 93 | #endif // XGZIP_H 94 | -------------------------------------------------------------------------------- /3rdparty/lzma/include/Ppmd7.h: -------------------------------------------------------------------------------- 1 | /* Ppmd7.h -- PPMdH compression codec 2 | 2018-07-04 : Igor Pavlov : Public domain 3 | This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ 4 | 5 | /* This code supports virtual RangeDecoder and includes the implementation 6 | of RangeCoder from 7z, instead of RangeCoder from original PPMd var.H. 7 | If you need the compatibility with original PPMd var.H, you can use external RangeDecoder */ 8 | 9 | #ifndef __PPMD7_H 10 | #define __PPMD7_H 11 | 12 | #include "Ppmd.h" 13 | 14 | EXTERN_C_BEGIN 15 | 16 | #define PPMD7_MIN_ORDER 2 17 | #define PPMD7_MAX_ORDER 64 18 | 19 | #define PPMD7_MIN_MEM_SIZE (1 << 11) 20 | #define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3) 21 | 22 | struct CPpmd7_Context_; 23 | 24 | typedef 25 | #ifdef PPMD_32BIT 26 | struct CPpmd7_Context_ * 27 | #else 28 | UInt32 29 | #endif 30 | CPpmd7_Context_Ref; 31 | 32 | typedef struct CPpmd7_Context_ 33 | { 34 | UInt16 NumStats; 35 | UInt16 SummFreq; 36 | CPpmd_State_Ref Stats; 37 | CPpmd7_Context_Ref Suffix; 38 | } CPpmd7_Context; 39 | 40 | #define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq) 41 | 42 | typedef struct 43 | { 44 | CPpmd7_Context *MinContext, *MaxContext; 45 | CPpmd_State *FoundState; 46 | unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag; 47 | Int32 RunLength, InitRL; /* must be 32-bit at least */ 48 | 49 | UInt32 Size; 50 | UInt32 GlueCount; 51 | Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart; 52 | UInt32 AlignOffset; 53 | 54 | Byte Indx2Units[PPMD_NUM_INDEXES]; 55 | Byte Units2Indx[128]; 56 | CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES]; 57 | Byte NS2Indx[256], NS2BSIndx[256], HB2Flag[256]; 58 | CPpmd_See DummySee, See[25][16]; 59 | UInt16 BinSumm[128][64]; 60 | } CPpmd7; 61 | 62 | void Ppmd7_Construct(CPpmd7 *p); 63 | BoolInt Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAllocPtr alloc); 64 | void Ppmd7_Free(CPpmd7 *p, ISzAllocPtr alloc); 65 | void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder); 66 | #define Ppmd7_WasAllocated(p) ((p)->Base != NULL) 67 | 68 | 69 | /* ---------- Internal Functions ---------- */ 70 | 71 | extern const Byte PPMD7_kExpEscape[16]; 72 | 73 | #ifdef PPMD_32BIT 74 | #define Ppmd7_GetPtr(p, ptr) (ptr) 75 | #define Ppmd7_GetContext(p, ptr) (ptr) 76 | #define Ppmd7_GetStats(p, ctx) ((ctx)->Stats) 77 | #else 78 | #define Ppmd7_GetPtr(p, offs) ((void *)((p)->Base + (offs))) 79 | #define Ppmd7_GetContext(p, offs) ((CPpmd7_Context *)Ppmd7_GetPtr((p), (offs))) 80 | #define Ppmd7_GetStats(p, ctx) ((CPpmd_State *)Ppmd7_GetPtr((p), ((ctx)->Stats))) 81 | #endif 82 | 83 | void Ppmd7_Update1(CPpmd7 *p); 84 | void Ppmd7_Update1_0(CPpmd7 *p); 85 | void Ppmd7_Update2(CPpmd7 *p); 86 | void Ppmd7_UpdateBin(CPpmd7 *p); 87 | 88 | #define Ppmd7_GetBinSumm(p) \ 89 | &p->BinSumm[(size_t)(unsigned)Ppmd7Context_OneState(p->MinContext)->Freq - 1][p->PrevSuccess + \ 90 | p->NS2BSIndx[(size_t)Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] + \ 91 | (p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]) + \ 92 | 2 * p->HB2Flag[(unsigned)Ppmd7Context_OneState(p->MinContext)->Symbol] + \ 93 | ((p->RunLength >> 26) & 0x20)] 94 | 95 | CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale); 96 | 97 | 98 | /* ---------- Decode ---------- */ 99 | 100 | typedef struct IPpmd7_RangeDec IPpmd7_RangeDec; 101 | 102 | struct IPpmd7_RangeDec 103 | { 104 | UInt32 (*GetThreshold)(const IPpmd7_RangeDec *p, UInt32 total); 105 | void (*Decode)(const IPpmd7_RangeDec *p, UInt32 start, UInt32 size); 106 | UInt32 (*DecodeBit)(const IPpmd7_RangeDec *p, UInt32 size0); 107 | }; 108 | 109 | typedef struct 110 | { 111 | IPpmd7_RangeDec vt; 112 | UInt32 Range; 113 | UInt32 Code; 114 | IByteIn *Stream; 115 | } CPpmd7z_RangeDec; 116 | 117 | void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p); 118 | BoolInt Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p); 119 | #define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0) 120 | 121 | int Ppmd7_DecodeSymbol(CPpmd7 *p, const IPpmd7_RangeDec *rc); 122 | 123 | 124 | /* ---------- Encode ---------- */ 125 | 126 | typedef struct 127 | { 128 | UInt64 Low; 129 | UInt32 Range; 130 | Byte Cache; 131 | UInt64 CacheSize; 132 | IByteOut *Stream; 133 | } CPpmd7z_RangeEnc; 134 | 135 | void Ppmd7z_RangeEnc_Init(CPpmd7z_RangeEnc *p); 136 | void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p); 137 | 138 | void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol); 139 | 140 | EXTERN_C_END 141 | 142 | #endif 143 | -------------------------------------------------------------------------------- /xlzip.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XLZIP_H 22 | #define XLZIP_H 23 | 24 | #include "xarchive.h" 25 | 26 | class XLzip : public XArchive { 27 | Q_OBJECT 28 | 29 | public: 30 | enum LZIP_TYPE { 31 | TYPE_UNKNOWN = 0, 32 | TYPE_LZ 33 | }; 34 | 35 | // Lzip file format (RFC 1952 inspired): 36 | // Magic: "LZIP" (4 bytes: 0x4C, 0x5A, 0x49, 0x50) 37 | // Version: 1 byte 38 | // Dict size code: 1 byte (encodes dictionary size as 2^(n+16) - 35) 39 | // Compressed data 40 | // CRC32: 4 bytes 41 | // Size: 8 bytes (uncompressed size mod 2^32) 42 | 43 | #pragma pack(push) 44 | #pragma pack(1) 45 | struct LZIP_HEADER { 46 | char magic[4]; // "LZIP" (0x4C, 0x5A, 0x49, 0x50) 47 | quint8 nVersion; // Format version 48 | quint8 nDictSizeCode; // Dictionary size code 49 | }; 50 | #pragma pack(pop) 51 | 52 | enum STRUCTID { 53 | STRUCTID_UNKNOWN = 0, 54 | STRUCTID_LZIP_HEADER, 55 | STRUCTID_MEMBER_HEADER, 56 | STRUCTID_COMPRESSED_DATA, 57 | STRUCTID_FOOTER 58 | }; 59 | 60 | explicit XLzip(QIODevice *pDevice = nullptr); 61 | ~XLzip(); 62 | 63 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 64 | static bool isValid(QIODevice *pDevice); 65 | virtual MODE getMode() override; 66 | virtual qint32 getType() override; 67 | virtual QString typeIdToString(qint32 nType) override; 68 | virtual QString getFileFormatExt() override; 69 | virtual FT getFileType() override; 70 | virtual QString getFileFormatExtsString() override; 71 | virtual qint64 getFileFormatSize(PDSTRUCT *pPdStruct) override; 72 | virtual QString getMIMEString() override; 73 | virtual ENDIAN getEndian() override; 74 | virtual OSNAME getOsName() override; 75 | virtual QList getMapModesList() override; 76 | virtual _MEMORY_MAP getMemoryMap(MAPMODE mapMode = MAPMODE_UNKNOWN, PDSTRUCT *pPdStruct = nullptr) override; 77 | virtual QString structIDToString(quint32 nID) override; 78 | virtual QList getDataHeaders(const DATA_HEADERS_OPTIONS &dataHeadersOptions, PDSTRUCT *pPdStruct) override; 79 | virtual QList getFileParts(quint32 nFileParts, qint32 nLimit = -1, PDSTRUCT *pPdStruct = nullptr) override; 80 | 81 | // Streaming unpacking API 82 | virtual bool initUnpack(UNPACK_STATE *pState, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 83 | virtual ARCHIVERECORD infoCurrent(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 84 | virtual bool unpackCurrent(UNPACK_STATE *pState, QIODevice *pDevice, PDSTRUCT *pPdStruct = nullptr) override; 85 | virtual bool moveToNext(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 86 | virtual bool finishUnpack(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 87 | 88 | LZIP_HEADER _read_LZIP_HEADER(qint64 nOffset); 89 | quint32 _getDictionarySize(quint8 nDictSizeCode); 90 | 91 | private: 92 | // Format-specific unpacking context 93 | struct LZIP_UNPACK_CONTEXT { 94 | qint64 nHeaderSize; // Size of LZIP header (6 bytes min) 95 | qint64 nCompressedSize; // Size of compressed data 96 | qint64 nUncompressedSize; // Size of uncompressed data 97 | quint32 nCRC32; // CRC32 of uncompressed data 98 | }; 99 | }; 100 | 101 | #endif // XLZIP_H 102 | -------------------------------------------------------------------------------- /xcompresseddevice.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2024-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xcompresseddevice.h" 22 | 23 | XCompressedDevice::XCompressedDevice(QObject *pParent) : XIODevice(pParent) 24 | { 25 | m_pOrigDevice = nullptr; 26 | m_pSubDevice = nullptr; 27 | m_bIsValid = false; 28 | m_pCurrentDevice = nullptr; 29 | m_pBufferDevice = nullptr; 30 | } 31 | 32 | XCompressedDevice::~XCompressedDevice() 33 | { 34 | if (m_pSubDevice) { 35 | m_pSubDevice->close(); 36 | delete m_pSubDevice; 37 | } 38 | 39 | XBinary::freeFileBuffer(&m_pBufferDevice); 40 | } 41 | 42 | bool XCompressedDevice::setData(QIODevice *pDevice, const XBinary::FPART &fPart, XBinary::PDSTRUCT *pPdStruct) 43 | { 44 | bool bResult = false; 45 | 46 | m_pOrigDevice = pDevice; 47 | 48 | if (fPart.mapProperties.value(XBinary::FPART_PROP_COMPRESSMETHOD, XBinary::COMPRESS_METHOD_STORE) != XBinary::COMPRESS_METHOD_STORE) { 49 | qint64 nUncompressedSize = fPart.mapProperties.value(XBinary::FPART_PROP_UNCOMPRESSEDSIZE, 0).toLongLong(); 50 | 51 | m_pBufferDevice = XBinary::createFileBuffer(nUncompressedSize, pPdStruct); 52 | 53 | bResult = XDecompress().decompressFPART(fPart, pDevice, m_pBufferDevice, pPdStruct); 54 | m_pCurrentDevice = m_pBufferDevice; 55 | } else { 56 | if ((fPart.nFileOffset == 0) && (pDevice->size() == fPart.nFileSize)) { 57 | m_pCurrentDevice = m_pOrigDevice; 58 | bResult = true; 59 | } else { 60 | m_pSubDevice = new SubDevice(m_pOrigDevice, fPart.nFileOffset, fPart.nFileSize); 61 | if (m_pSubDevice->open(QIODevice::ReadOnly)) { 62 | m_pCurrentDevice = m_pSubDevice; 63 | bResult = true; 64 | } 65 | } 66 | } 67 | 68 | m_bIsValid = bResult; 69 | 70 | return bResult; 71 | } 72 | 73 | bool XCompressedDevice::open(OpenMode mode) 74 | { 75 | bool bResult = false; 76 | 77 | if ((m_bIsValid) && (mode == QIODevice::ReadOnly)) { 78 | bResult = XIODevice::open(mode); 79 | } 80 | 81 | return bResult; 82 | } 83 | 84 | QIODevice *XCompressedDevice::getOrigDevice() 85 | { 86 | return m_pOrigDevice; 87 | } 88 | 89 | qint64 XCompressedDevice::size() const 90 | { 91 | qint64 nResult = 0; 92 | 93 | if (m_pCurrentDevice) { 94 | nResult = m_pCurrentDevice->size(); 95 | } 96 | 97 | return nResult; 98 | } 99 | 100 | bool XCompressedDevice::seek(qint64 nPos) 101 | { 102 | bool bResult = false; 103 | 104 | if (m_pCurrentDevice) { 105 | bResult = m_pCurrentDevice->seek(nPos) && XIODevice::seek(nPos); 106 | } 107 | 108 | return bResult; 109 | } 110 | 111 | qint64 XCompressedDevice::pos() const 112 | { 113 | qint64 nResult = 0; 114 | 115 | if (m_pCurrentDevice) { 116 | nResult = m_pCurrentDevice->pos(); 117 | } 118 | 119 | return nResult; 120 | } 121 | 122 | qint64 XCompressedDevice::readData(char *pData, qint64 nMaxSize) 123 | { 124 | qint64 nResult = 0; 125 | 126 | if (m_pCurrentDevice->seek(pos())) { 127 | nResult = m_pCurrentDevice->read(pData, nMaxSize); 128 | } 129 | 130 | return nResult; 131 | } 132 | 133 | qint64 XCompressedDevice::writeData(const char *pData, qint64 nMaxSize) 134 | { 135 | Q_UNUSED(pData) 136 | Q_UNUSED(nMaxSize) 137 | #ifdef QT_DEBUG 138 | qDebug("XCompressedDevice::writeData: seekpos %lld", pos()); 139 | #endif 140 | return 0; 141 | } 142 | -------------------------------------------------------------------------------- /x_ar.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef X_AR_H 22 | #define X_AR_H 23 | 24 | #include "xarchive.h" 25 | 26 | class X_Ar : public XArchive { 27 | Q_OBJECT 28 | 29 | #pragma pack(push) 30 | #pragma pack(1) 31 | struct FRECORD { 32 | char fileId[16]; // File identifier ASCII 33 | char fileMod[12]; // File modification timestamp (in seconds) Decimal 34 | char ownerId[6]; // Owner ID Decimal 35 | char groupId[6]; // Group ID Decimal 36 | char fileMode[8]; // File mode (type and permission) Octal 37 | char fileSize[10]; // File size in bytes Decimal 38 | char endChar[2]; // Ending characters 0x60 0x0A 39 | }; 40 | #pragma pack(pop) 41 | 42 | enum TYPE { 43 | TYPE_UNKNOWN = 0, 44 | TYPE_PACKAGE, 45 | // TODO more 46 | }; 47 | 48 | public: 49 | enum STRUCTID { 50 | STRUCTID_UNKNOWN = 0, 51 | STRUCTID_FRECORD, 52 | STRUCTID_SIGNATURE 53 | }; 54 | 55 | explicit X_Ar(QIODevice *pDevice = nullptr); 56 | 57 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 58 | static bool isValid(QIODevice *pDevice); 59 | virtual QString getFileFormatExt() override; 60 | virtual QList getMapModesList() override; 61 | virtual FT getFileType() override; 62 | virtual qint32 getType() override; 63 | virtual _MEMORY_MAP getMemoryMap(MAPMODE mapMode = MAPMODE_UNKNOWN, PDSTRUCT *pPdStruct = nullptr) override; 64 | virtual QString getMIMEString() override; 65 | virtual QList getFileParts(quint32 nFileParts, qint32 nLimit = -1, PDSTRUCT *pPdStruct = nullptr) override; 66 | virtual QString structIDToString(quint32 nID) override; 67 | virtual QList getDataHeaders(const DATA_HEADERS_OPTIONS &dataHeadersOptions, PDSTRUCT *pPdStruct); 68 | virtual bool readTableInit(const DATA_RECORDS_OPTIONS &dataRecordsOptions, void **ppUserData, PDSTRUCT *pPdStruct); 69 | virtual qint32 readTableRow(qint32 nRow, LT locType, XADDR nLocation, const DATA_RECORDS_OPTIONS &dataRecordsOptions, QList *pListDataRecords, 70 | void *pUserData, PDSTRUCT *pPdStruct); 71 | virtual void readTableFinalize(const DATA_RECORDS_OPTIONS &dataRecordsOptions, void *pUserData, PDSTRUCT *pPdStruct); 72 | quint64 _getNumberOfStreams(qint64 nOffset, PDSTRUCT *pPdStruct); 73 | 74 | virtual bool initPack(PACK_STATE *pState, QIODevice *pDevice, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 75 | virtual bool addFile(PACK_STATE *pState, const QString &sFilePath, PDSTRUCT *pPdStruct = nullptr) override; 76 | virtual bool addFolder(PACK_STATE *pState, const QString &sDirectoryPath, PDSTRUCT *pPdStruct = nullptr) override; 77 | virtual bool finishPack(PACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 78 | 79 | virtual bool initUnpack(UNPACK_STATE *pState, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 80 | virtual ARCHIVERECORD infoCurrent(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 81 | virtual bool unpackCurrent(UNPACK_STATE *pState, QIODevice *pDevice, PDSTRUCT *pPdStruct = nullptr) override; 82 | virtual bool moveToNext(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 83 | 84 | private: 85 | FRECORD readFRECORD(qint64 nOffset); 86 | static FRECORD createHeader(const QString &sFileName, qint64 nFileSize, quint32 nMode, qint64 nMTime); 87 | }; 88 | 89 | #endif // X_AR_H 90 | -------------------------------------------------------------------------------- /xarchive.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | INCLUDEPATH += $$PWD/Algos 4 | DEPENDPATH += $$PWD/Algos 5 | INCLUDEPATH += $$PWD/3rdparty/ppmd/src 6 | DEPENDPATH += $$PWD/3rdparty/ppmd/src 7 | 8 | HEADERS += \ 9 | $$PWD/Algos/xlzhdecoder.h \ 10 | $$PWD/Algos/xrardecoder.h \ 11 | $$PWD/Algos/xit214decoder.h \ 12 | $$PWD/Algos/xdeflatedecoder.h \ 13 | $$PWD/Algos/ximplodedecoder.h \ 14 | $$PWD/Algos/xlzmadecoder.h \ 15 | $$PWD/Algos/xlzwdecoder.h \ 16 | $$PWD/Algos/xascii85decoder.h \ 17 | $$PWD/Algos/xstoredecoder.h \ 18 | $$PWD/Algos/xbzip2decoder.h \ 19 | $$PWD/Algos/xlzssdecoder.h \ 20 | $$PWD/Algos/xshrinkdecoder.h \ 21 | $$PWD/Algos/xreducedecoder.h \ 22 | $$PWD/Algos/xzipcryptodecoder.h \ 23 | $$PWD/Algos/xzipaesdecoder.h \ 24 | $$PWD/Algos/xppmddecoder.h \ 25 | $$PWD/Algos/xppmdrangedecoder.h \ 26 | $$PWD/Algos/xppmdmodel.h \ 27 | $$PWD/Algos/xppmd7model.h \ 28 | $$PWD/Algos/xaesdecoder.h \ 29 | $$PWD/Algos/xsha256decoder.h \ 30 | $$PWD/x_ar.h \ 31 | $$PWD/xapk.h \ 32 | $$PWD/xapks.h \ 33 | $$PWD/xarchive.h \ 34 | $$PWD/xcab.h \ 35 | $$PWD/xcfbf.h \ 36 | $$PWD/xcpio.h \ 37 | $$PWD/xcompress.h \ 38 | $$PWD/xdecompress.h \ 39 | $$PWD/xcompresseddevice.h \ 40 | $$PWD/xdeb.h \ 41 | $$PWD/xdos16.h \ 42 | $$PWD/xgzip.h \ 43 | $$PWD/xipa.h \ 44 | $$PWD/xiso9660.h \ 45 | $$PWD/xjar.h \ 46 | $$PWD/xlha.h \ 47 | $$PWD/xmachofat.h \ 48 | $$PWD/xrar.h \ 49 | $$PWD/xsevenzip.h \ 50 | $$PWD/xsquashfs.h \ 51 | $$PWD/xtar.h \ 52 | $$PWD/xtgz.h \ 53 | $$PWD/xzip.h \ 54 | $$PWD/xnpm.h \ 55 | $$PWD/xszdd.h \ 56 | $$PWD/xbzip2.h \ 57 | $$PWD/xlzip.h \ 58 | $$PWD/xxz.h \ 59 | $$PWD/xzlib.h \ 60 | $$PWD/xminidump.h \ 61 | $$PWD/xdmg.h 62 | 63 | SOURCES += \ 64 | $$PWD/Algos/xlzhdecoder.cpp \ 65 | $$PWD/Algos/xrardecoder.cpp \ 66 | $$PWD/Algos/xit214decoder.cpp \ 67 | $$PWD/Algos/xdeflatedecoder.cpp \ 68 | $$PWD/Algos/ximplodedecoder.cpp \ 69 | $$PWD/Algos/xlzmadecoder.cpp \ 70 | $$PWD/Algos/xlzwdecoder.cpp \ 71 | $$PWD/Algos/xascii85decoder.cpp \ 72 | $$PWD/Algos/xstoredecoder.cpp \ 73 | $$PWD/Algos/xbzip2decoder.cpp \ 74 | $$PWD/Algos/xlzssdecoder.cpp \ 75 | $$PWD/Algos/xshrinkdecoder.cpp \ 76 | $$PWD/Algos/xreducedecoder.cpp \ 77 | $$PWD/Algos/xzipcryptodecoder.cpp \ 78 | $$PWD/Algos/xzipaesdecoder.cpp \ 79 | $$PWD/Algos/xppmddecoder.cpp \ 80 | $$PWD/Algos/xppmdrangedecoder.cpp \ 81 | $$PWD/Algos/xppmdmodel.cpp \ 82 | $$PWD/Algos/xppmd7model.cpp \ 83 | $$PWD/Algos/xaesdecoder.cpp \ 84 | $$PWD/Algos/xsha256decoder.cpp \ 85 | $$PWD/x_ar.cpp \ 86 | $$PWD/xapk.cpp \ 87 | $$PWD/xapks.cpp \ 88 | $$PWD/xarchive.cpp \ 89 | $$PWD/xcab.cpp \ 90 | $$PWD/xcfbf.cpp \ 91 | $$PWD/xcpio.cpp \ 92 | $$PWD/xcompress.cpp \ 93 | $$PWD/xdecompress.cpp \ 94 | $$PWD/xcompresseddevice.cpp \ 95 | $$PWD/xdeb.cpp \ 96 | $$PWD/xdos16.cpp \ 97 | $$PWD/xgzip.cpp \ 98 | $$PWD/xipa.cpp \ 99 | $$PWD/xiso9660.cpp \ 100 | $$PWD/xjar.cpp \ 101 | $$PWD/xlha.cpp \ 102 | $$PWD/xmachofat.cpp \ 103 | $$PWD/xrar.cpp \ 104 | $$PWD/xsevenzip.cpp \ 105 | $$PWD/xsquashfs.cpp \ 106 | $$PWD/xtar.cpp \ 107 | $$PWD/xtgz.cpp \ 108 | $$PWD/xzip.cpp \ 109 | $$PWD/xnpm.cpp \ 110 | $$PWD/xszdd.cpp \ 111 | $$PWD/xbzip2.cpp \ 112 | $$PWD/xlzip.cpp \ 113 | $$PWD/xxz.cpp \ 114 | $$PWD/xzlib.cpp \ 115 | $$PWD/xminidump.cpp \ 116 | $$PWD/xdmg.cpp 117 | 118 | !contains(XCONFIG, xbinary) { 119 | XCONFIG += xbinary 120 | include($$PWD/../Formats/xbinary.pri) 121 | } 122 | 123 | !contains(XCONFIG, xmach) { 124 | XCONFIG += xmach 125 | include($$PWD/../Formats/exec/xmach.pri) # MACHFAT archive contains Mach-O 126 | } 127 | 128 | !contains(XCONFIG, xjavaclass) { 129 | XCONFIG += xjavaclass 130 | include($$PWD/../Formats/formats/xjavaclass.pri) 131 | } 132 | 133 | !contains(XCONFIG, xpyc) { 134 | XCONFIG += xpyc 135 | include($$PWD/../Formats/formats/xpyc.pri) 136 | } 137 | 138 | !contains(XCONFIG, zlib) { 139 | XCONFIG += zlib 140 | include($$PWD/3rdparty/zlib/zlib.pri) 141 | } 142 | 143 | !contains(XCONFIG, bzip2) { 144 | XCONFIG += bzip2 145 | include($$PWD/3rdparty/bzip2/bzip2.pri) 146 | } 147 | 148 | !contains(XCONFIG, lzma) { 149 | XCONFIG += lzma 150 | include($$PWD/3rdparty/lzma/lzma.pri) 151 | } 152 | 153 | !contains(XCONFIG, ppmd) { 154 | XCONFIG += ppmd 155 | include($$PWD/3rdparty/ppmd/ppmd.pri) 156 | } 157 | 158 | DISTFILES += \ 159 | $$PWD/LICENSE \ 160 | $$PWD/README.md \ 161 | $$PWD/xarchive.cmake 162 | -------------------------------------------------------------------------------- /Algos/xbzip2decoder.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xbzip2decoder.h" 22 | 23 | XBZIP2Decoder::XBZIP2Decoder(QObject *parent) : QObject(parent) 24 | { 25 | } 26 | 27 | bool XBZIP2Decoder::decompress(XBinary::DATAPROCESS_STATE *pDecompressState, XBinary::PDSTRUCT *pPdStruct) 28 | { 29 | bool bResult = false; 30 | 31 | const qint32 N_BUFFER_SIZE = 0x4000; 32 | 33 | char bufferIn[N_BUFFER_SIZE]; 34 | char bufferOut[N_BUFFER_SIZE]; 35 | 36 | if (pDecompressState && pDecompressState->pDeviceInput && pDecompressState->pDeviceOutput) { 37 | if (pDecompressState->pDeviceInput) { 38 | pDecompressState->pDeviceInput->seek(pDecompressState->nInputOffset); 39 | } 40 | 41 | if (pDecompressState->pDeviceOutput) { 42 | pDecompressState->pDeviceOutput->seek(0); 43 | } 44 | 45 | bz_stream strm = {}; 46 | qint32 ret = BZ_MEM_ERROR; 47 | bool bReadMore = true; 48 | 49 | qint32 rc = BZ2_bzDecompressInit(&strm, 0, 0); 50 | 51 | if (rc == BZ_OK) { 52 | do { 53 | // Read more data only if we consumed all input 54 | if (bReadMore && strm.avail_in == 0) { 55 | qint32 nBufferSize = qMin((qint32)(pDecompressState->nInputLimit - pDecompressState->nCountInput), N_BUFFER_SIZE); 56 | 57 | if (nBufferSize > 0) { 58 | strm.avail_in = XBinary::_readDevice(bufferIn, nBufferSize, pDecompressState); 59 | 60 | if (strm.avail_in > 0) { 61 | strm.next_in = bufferIn; 62 | } else { 63 | // No more data available from device - signal to stop reading 64 | bReadMore = false; 65 | } 66 | } else { 67 | // nBufferSize is 0 - we've reached input limit 68 | bReadMore = false; 69 | } 70 | } 71 | 72 | // Only decompress if we have input data available 73 | if (strm.avail_in > 0) { 74 | strm.total_in_hi32 = 0; 75 | strm.total_in_lo32 = 0; 76 | strm.total_out_hi32 = 0; 77 | strm.total_out_lo32 = 0; 78 | strm.avail_out = N_BUFFER_SIZE; 79 | strm.next_out = bufferOut; 80 | ret = BZ2_bzDecompress(&strm); 81 | 82 | if ((ret != BZ_STREAM_END) && (ret != BZ_OK)) { 83 | break; 84 | } 85 | 86 | qint32 nTemp = N_BUFFER_SIZE - strm.avail_out; 87 | 88 | if (nTemp > 0) { 89 | if (!XBinary::_writeDevice((char *)bufferOut, nTemp, pDecompressState)) { 90 | ret = BZ_MEM_ERROR; 91 | break; 92 | } 93 | } 94 | } else if (!bReadMore) { 95 | // No more data to read and buffer is empty - exit loop 96 | // The stream should have ended by now if data was valid 97 | break; 98 | } 99 | 100 | if (XBinary::isPdStructStopped(pPdStruct)) { 101 | break; 102 | } 103 | } while (ret != BZ_STREAM_END); 104 | 105 | BZ2_bzDecompressEnd(&strm); 106 | 107 | if (ret == BZ_STREAM_END) { 108 | bResult = true; 109 | } 110 | } 111 | } 112 | 113 | return bResult; 114 | } 115 | -------------------------------------------------------------------------------- /xxz.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XXZ_H 22 | #define XXZ_H 23 | 24 | #include "xarchive.h" 25 | #include "xlzmadecoder.h" 26 | 27 | class XXZ : public XArchive { 28 | Q_OBJECT 29 | public: 30 | enum STRUCTID { 31 | STRUCTID_UNKNOWN = 0, 32 | STRUCTID_STREAM_HEADER, 33 | STRUCTID_BLOCK_HEADER, 34 | STRUCTID_INDEX, 35 | STRUCTID_STREAM_FOOTER, 36 | STRUCTID_RECORD, 37 | }; 38 | 39 | struct STREAM_HEADER { 40 | quint8 header_magic[6]; 41 | quint8 stream_flags[2]; 42 | quint32 crc32; 43 | }; 44 | 45 | struct STREAM_FOOTER { 46 | quint32 crc32; 47 | quint32 backward_size; 48 | quint8 stream_flags[2]; 49 | quint8 footer_magic[2]; 50 | }; 51 | 52 | struct BLOCK_HEADER { 53 | quint8 header_size; 54 | quint8 flags; 55 | // Compressed and Uncompressed sizes are variable-size, not fixed! 56 | // Filter info, etc., not parsed here for brevity 57 | }; 58 | 59 | struct INDEX { 60 | quint8 indicator; 61 | quint64 num_records; 62 | // Records array, variable size, not included here 63 | }; 64 | 65 | // Add more format data structs as needed 66 | 67 | explicit XXZ(QIODevice *pDevice = nullptr); 68 | ~XXZ(); 69 | 70 | virtual bool isValid(PDSTRUCT *pPdStruct = nullptr) override; 71 | static bool isValid(QIODevice *pDevice); 72 | virtual FT getFileType() override; 73 | virtual MODE getMode() override; 74 | virtual QString getMIMEString() override; 75 | virtual qint32 getType() override; 76 | virtual QString typeIdToString(qint32 nType) override; 77 | virtual ENDIAN getEndian() override; 78 | virtual QString getArch() override; 79 | virtual QString getFileFormatExt() override; 80 | virtual QString getFileFormatExtsString() override; 81 | virtual qint64 getFileFormatSize(PDSTRUCT *pPdStruct) override; 82 | virtual bool isSigned() override; 83 | virtual OSNAME getOsName() override; 84 | virtual QString getOsVersion() override; 85 | virtual QString getVersion() override; 86 | virtual bool isEncrypted() override; 87 | virtual QList getMapModesList() override; 88 | virtual _MEMORY_MAP getMemoryMap(MAPMODE mapMode = MAPMODE_UNKNOWN, PDSTRUCT *pPdStruct = nullptr) override; 89 | 90 | virtual QString structIDToString(quint32 nID) override; 91 | virtual QList getDataHeaders(const DATA_HEADERS_OPTIONS &dataHeadersOptions, PDSTRUCT *pPdStruct) override; 92 | 93 | STREAM_HEADER _read_STREAM_HEADER(qint64 nOffset); 94 | STREAM_FOOTER _read_STREAM_FOOTER(qint64 nOffset); 95 | BLOCK_HEADER _read_BLOCK_HEADER(qint64 nOffset); 96 | INDEX _read_INDEX(qint64 nOffset); 97 | 98 | // XArchive interface 99 | virtual quint64 getNumberOfRecords(PDSTRUCT *pPdStruct) override; 100 | virtual QList getRecords(qint32 nLimit, PDSTRUCT *pPdStruct) override; 101 | 102 | // Streaming unpacking API 103 | virtual bool initUnpack(UNPACK_STATE *pState, const QMap &mapProperties, PDSTRUCT *pPdStruct = nullptr) override; 104 | virtual ARCHIVERECORD infoCurrent(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 105 | virtual bool unpackCurrent(UNPACK_STATE *pState, QIODevice *pDevice, PDSTRUCT *pPdStruct = nullptr) override; 106 | virtual bool moveToNext(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 107 | virtual bool finishUnpack(UNPACK_STATE *pState, PDSTRUCT *pPdStruct = nullptr) override; 108 | 109 | private: 110 | struct XXZ_UNPACK_CONTEXT { 111 | QString sFileName; 112 | qint64 nHeaderSize; 113 | qint64 nCompressedSize; 114 | qint64 nUncompressedSize; 115 | quint32 nCRC32; 116 | }; 117 | }; 118 | 119 | #endif // XXZ_H 120 | -------------------------------------------------------------------------------- /Algos/xppmdmodel.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include "xppmdmodel.h" 23 | 24 | #include 25 | #include 26 | 27 | static void *XPPMdAlloc(ISzAllocPtr, size_t nSize) 28 | { 29 | return malloc(nSize); 30 | } 31 | 32 | static void XPPMdFree(ISzAllocPtr, void *pAddress) 33 | { 34 | free(pAddress); 35 | } 36 | 37 | static ISzAlloc g_XPPMdAlloc = {XPPMdAlloc, XPPMdFree}; 38 | 39 | // Input stream adapter to connect 7-Zip's IByteIn with QIODevice 40 | typedef struct { 41 | IByteIn vt; 42 | QIODevice *pDevice; 43 | bool bError; 44 | } XPPMdInputStream; 45 | 46 | static Byte XPPMdInputStream_Read(const IByteIn *p) 47 | { 48 | XPPMdInputStream *pStream = Z7_CONTAINER_FROM_VTBL(p, XPPMdInputStream, vt); 49 | 50 | if (pStream->bError || !pStream->pDevice) { 51 | pStream->bError = true; 52 | return 0; 53 | } 54 | 55 | char cByte = 0; 56 | qint64 nRead = pStream->pDevice->read(&cByte, 1); 57 | 58 | if (nRead != 1) { 59 | pStream->bError = true; 60 | return 0; 61 | } 62 | 63 | return (Byte)cByte; 64 | } 65 | 66 | // Private implementation using 7-Zip PPMd model 67 | struct XPPMdModelPrivate { 68 | CPpmd8 sPpmd; 69 | XPPMdInputStream sInputStream; 70 | bool bAllocated; 71 | 72 | XPPMdModelPrivate() : bAllocated(false) 73 | { 74 | memset(&sPpmd, 0, sizeof(sPpmd)); 75 | memset(&sInputStream, 0, sizeof(sInputStream)); 76 | } 77 | }; 78 | 79 | // ============================================================================ 80 | // XPPMdModel public methods 81 | // ============================================================================ 82 | 83 | XPPMdModel::XPPMdModel() 84 | { 85 | m_pPrivate = new XPPMdModelPrivate(); 86 | Ppmd8_Construct(&m_pPrivate->sPpmd); 87 | } 88 | 89 | XPPMdModel::~XPPMdModel() 90 | { 91 | free(); 92 | delete m_pPrivate; 93 | } 94 | 95 | bool XPPMdModel::allocate(quint32 nMemorySize) 96 | { 97 | if (m_pPrivate->bAllocated) { 98 | free(); 99 | } 100 | 101 | m_pPrivate->bAllocated = (Ppmd8_Alloc(&m_pPrivate->sPpmd, nMemorySize, &g_XPPMdAlloc) != 0); 102 | return m_pPrivate->bAllocated; 103 | } 104 | 105 | void XPPMdModel::init(quint8 nOrder, quint8 nRestoreMethod) 106 | { 107 | // Initialize the PPMd model with the specified parameters 108 | Ppmd8_Init(&m_pPrivate->sPpmd, nOrder, nRestoreMethod); 109 | } 110 | 111 | void XPPMdModel::setInputStream(QIODevice *pDevice) 112 | { 113 | // Set up input stream for 7-Zip's internal range decoder 114 | m_pPrivate->sInputStream.vt.Read = XPPMdInputStream_Read; 115 | m_pPrivate->sInputStream.pDevice = pDevice; 116 | m_pPrivate->sInputStream.bError = false; 117 | 118 | // Connect the stream to the PPMd decoder 119 | m_pPrivate->sPpmd.Stream.In = &m_pPrivate->sInputStream.vt; 120 | 121 | // Initialize 7-Zip's internal range decoder 122 | if (!Ppmd8_Init_RangeDec(&m_pPrivate->sPpmd)) { 123 | // Range decoder initialization failed 124 | m_pPrivate->sInputStream.bError = true; 125 | } 126 | } 127 | 128 | qint32 XPPMdModel::decodeSymbol() 129 | { 130 | if (!m_pPrivate->bAllocated) { 131 | return -2; // Error: model not allocated 132 | } 133 | 134 | // Use 7-Zip's proven decoder 135 | int nSymbol = Ppmd8_DecodeSymbol(&m_pPrivate->sPpmd); 136 | 137 | return nSymbol; 138 | } 139 | 140 | void XPPMdModel::free() 141 | { 142 | if (m_pPrivate->bAllocated) { 143 | Ppmd8_Free(&m_pPrivate->sPpmd, &g_XPPMdAlloc); 144 | m_pPrivate->bAllocated = false; 145 | } 146 | } 147 | 148 | bool XPPMdModel::wasAllocated() const 149 | { 150 | return m_pPrivate->bAllocated; 151 | } 152 | -------------------------------------------------------------------------------- /Algos/xppmd7model.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include "xppmd7model.h" 23 | 24 | #include 25 | #include 26 | 27 | static void *XPPMd7Alloc(ISzAllocPtr, size_t nSize) 28 | { 29 | return malloc(nSize); 30 | } 31 | 32 | static void XPPMd7Free(ISzAllocPtr, void *pAddress) 33 | { 34 | free(pAddress); 35 | } 36 | 37 | static ISzAlloc g_XPPMd7Alloc = {XPPMd7Alloc, XPPMd7Free}; 38 | 39 | // Input stream adapter to connect 7-Zip's IByteIn with QIODevice 40 | typedef struct { 41 | IByteIn vt; 42 | QIODevice *pDevice; 43 | bool bError; 44 | } XPPMd7InputStream; 45 | 46 | static Byte XPPMd7InputStream_Read(const IByteIn *p) 47 | { 48 | XPPMd7InputStream *pStream = Z7_CONTAINER_FROM_VTBL(p, XPPMd7InputStream, vt); 49 | 50 | if (pStream->bError || !pStream->pDevice) { 51 | pStream->bError = true; 52 | return 0; 53 | } 54 | 55 | char cByte = 0; 56 | qint64 nRead = pStream->pDevice->read(&cByte, 1); 57 | 58 | if (nRead != 1) { 59 | pStream->bError = true; 60 | return 0; 61 | } 62 | 63 | return (Byte)cByte; 64 | } 65 | 66 | // Private implementation using 7-Zip Ppmd7 model 67 | struct XPPMd7ModelPrivate { 68 | CPpmd7 sPpmd; 69 | XPPMd7InputStream sInputStream; 70 | bool bAllocated; 71 | 72 | XPPMd7ModelPrivate() : bAllocated(false) 73 | { 74 | memset(&sPpmd, 0, sizeof(sPpmd)); 75 | memset(&sInputStream, 0, sizeof(sInputStream)); 76 | } 77 | }; 78 | 79 | // ============================================================================ 80 | // XPPMd7Model public methods 81 | // ============================================================================ 82 | 83 | XPPMd7Model::XPPMd7Model() 84 | { 85 | m_pPrivate = new XPPMd7ModelPrivate(); 86 | Ppmd7_Construct(&m_pPrivate->sPpmd); 87 | } 88 | 89 | XPPMd7Model::~XPPMd7Model() 90 | { 91 | free(); 92 | delete m_pPrivate; 93 | } 94 | 95 | bool XPPMd7Model::allocate(quint32 nMemorySize) 96 | { 97 | if (m_pPrivate->bAllocated) { 98 | free(); 99 | } 100 | 101 | m_pPrivate->bAllocated = (Ppmd7_Alloc(&m_pPrivate->sPpmd, nMemorySize, &g_XPPMd7Alloc) != 0); 102 | return m_pPrivate->bAllocated; 103 | } 104 | 105 | void XPPMd7Model::init(quint8 nOrder) 106 | { 107 | // Initialize the Ppmd7 model with the specified order 108 | Ppmd7_Init(&m_pPrivate->sPpmd, nOrder); 109 | } 110 | 111 | void XPPMd7Model::setInputStream(QIODevice *pDevice) 112 | { 113 | // Set up input stream for 7-Zip's internal range decoder 114 | m_pPrivate->sInputStream.vt.Read = XPPMd7InputStream_Read; 115 | m_pPrivate->sInputStream.pDevice = pDevice; 116 | m_pPrivate->sInputStream.bError = false; 117 | 118 | // Connect the stream to the Ppmd7 decoder 119 | m_pPrivate->sPpmd.rc.dec.Stream = &m_pPrivate->sInputStream.vt; 120 | 121 | // Initialize 7-Zip's internal range decoder for 7z format 122 | if (!Ppmd7z_RangeDec_Init(&m_pPrivate->sPpmd.rc.dec)) { 123 | // Range decoder initialization failed 124 | m_pPrivate->sInputStream.bError = true; 125 | } 126 | } 127 | 128 | qint32 XPPMd7Model::decodeSymbol() 129 | { 130 | if (!m_pPrivate->bAllocated) { 131 | return -2; // Error: model not allocated 132 | } 133 | 134 | // Use 7-Zip's Ppmd7z decoder (for 7z format) 135 | int nSymbol = Ppmd7z_DecodeSymbol(&m_pPrivate->sPpmd); 136 | 137 | return nSymbol; 138 | } 139 | 140 | void XPPMd7Model::free() 141 | { 142 | if (m_pPrivate->bAllocated) { 143 | Ppmd7_Free(&m_pPrivate->sPpmd, &g_XPPMd7Alloc); 144 | m_pPrivate->bAllocated = false; 145 | } 146 | } 147 | 148 | bool XPPMd7Model::wasAllocated() const 149 | { 150 | return m_pPrivate->bAllocated; 151 | } 152 | -------------------------------------------------------------------------------- /xarchives.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XARCHIVES_H 22 | #define XARCHIVES_H 23 | 24 | // TODO more 25 | #include "x_ar.h" 26 | #include "xcab.h" 27 | #include "xcpio.h" 28 | #include "xgzip.h" 29 | #include "xiso9660.h" 30 | #include "xmachofat.h" 31 | #include "xrar.h" 32 | #include "xsevenzip.h" 33 | #include "xsquashfs.h" 34 | #include "xzip.h" 35 | #include "xzlib.h" 36 | #include "xlha.h" 37 | #include "xjar.h" 38 | #include "xapk.h" 39 | #include "xipa.h" 40 | #include "xapks.h" 41 | #include "xtar.h" 42 | #include "xtgz.h" 43 | #include "xnpm.h" 44 | #include "xdeb.h" 45 | #include "xdos16.h" 46 | #include "xcfbf.h" 47 | #include "xcab.h" 48 | #include "xszdd.h" 49 | #include "xbzip2.h" 50 | #include "xxz.h" 51 | #include "xminidump.h" 52 | #include "xdmg.h" 53 | 54 | class XArchives : public QObject { 55 | Q_OBJECT 56 | 57 | public: 58 | explicit XArchives(QObject *pParent = nullptr); 59 | 60 | static XArchive *getClass(XBinary::FT fileType, QIODevice *pDevice); 61 | static QList getRecords(QIODevice *pDevice, XBinary::FT fileType = XBinary::FT_UNKNOWN, qint32 nLimit = -1, XBinary::PDSTRUCT *pPdStruct = nullptr); 62 | static QList getRecords(const QString &sFileName, XBinary::FT fileType = XBinary::FT_UNKNOWN, qint32 nLimit = -1, 63 | XBinary::PDSTRUCT *pPdStruct = nullptr); 64 | static QList getRecordsFromDirectory(const QString &sDirectoryName, qint32 nLimit = -1, XBinary::PDSTRUCT *pPdStruct = nullptr); 65 | static QByteArray decompress(QIODevice *pDevice, const XArchive::RECORD *pRecord, XBinary::PDSTRUCT *pPdStruct = nullptr, qint64 nDecompressedOffset = 0, 66 | qint64 nDecompressedSize = -1); 67 | static QByteArray decompress(const QString &sFileName, XArchive::RECORD *pRecord, XBinary::PDSTRUCT *pPdStruct = nullptr, qint64 nDecompressedOffset = 0, 68 | qint64 nDecompressedSize = -1); 69 | static QByteArray decompress(QIODevice *pDevice, const QString &sRecordFileName, XBinary::PDSTRUCT *pPdStruct = nullptr); 70 | static QByteArray decompress(const QString &sFileName, const QString &sRecordFileName, XBinary::PDSTRUCT *pPdStruct = nullptr); 71 | static bool decompressToFile(QIODevice *pDevice, XArchive::RECORD *pRecord, const QString &sResultFileName, XBinary::PDSTRUCT *pPdStruct = nullptr); 72 | static bool decompressToDevice(QIODevice *pDevice, XArchive::RECORD *pRecord, QIODevice *pDestDevice, XBinary::PDSTRUCT *pPdStruct = nullptr); 73 | static bool decompressToFile(const QString &sFileName, XArchive::RECORD *pRecord, const QString &sResultFileName, XBinary::PDSTRUCT *pPdStruct = nullptr); 74 | static bool decompressToFile(const QString &sFileName, const QString &sRecordFileName, const QString &sResultFileName, XBinary::PDSTRUCT *pPdStruct = nullptr); 75 | static bool decompressToFolder(QIODevice *pDevice, const QString &sResultFileFolder, XBinary::PDSTRUCT *pPdStruct = nullptr); 76 | static bool decompressToFolder(const QString &sFileName, const QString &sResultFileFolder, XBinary::PDSTRUCT *pPdStruct = nullptr); 77 | static bool isArchiveRecordPresent(QIODevice *pDevice, const QString &sRecordFileName, XBinary::PDSTRUCT *pPdStruct = nullptr); 78 | static bool isArchiveRecordPresent(const QString &sFileName, const QString &sRecordFileName, XBinary::PDSTRUCT *pPdStruct = nullptr); 79 | static bool isArchiveOpenValid(QIODevice *pDevice, const QSet &stAvailable); 80 | static bool isArchiveOpenValid(const QString &sFileName, const QSet &stAvailable); 81 | static QSet getArchiveOpenValidFileTypes(); 82 | 83 | private: 84 | static void _findFiles(const QString &sDirectoryName, QList *pListRecords, qint32 nLimit, 85 | XBinary::PDSTRUCT *pPdStruct); // TODO mb nLimit pointer to qint32 86 | }; 87 | 88 | #endif // XARCHIVES_H 89 | -------------------------------------------------------------------------------- /3rdparty/ppmd/src/Ppmd8.h: -------------------------------------------------------------------------------- 1 | /* Ppmd8.h -- Ppmd8 (PPMdI) compression codec 2 | 2023-04-02 : Igor Pavlov : Public domain 3 | This code is based on: 4 | PPMd var.I (2002): Dmitry Shkarin : Public domain 5 | Carryless rangecoder (1999): Dmitry Subbotin : Public domain */ 6 | 7 | #ifndef ZIP7_INC_PPMD8_H 8 | #define ZIP7_INC_PPMD8_H 9 | 10 | #include "Ppmd.h" 11 | 12 | EXTERN_C_BEGIN 13 | 14 | #define PPMD8_MIN_ORDER 2 15 | #define PPMD8_MAX_ORDER 16 16 | 17 | 18 | 19 | 20 | struct CPpmd8_Context_; 21 | 22 | typedef Ppmd_Ref_Type(struct CPpmd8_Context_) CPpmd8_Context_Ref; 23 | 24 | // MY_CPU_pragma_pack_push_1 25 | 26 | typedef struct CPpmd8_Context_ 27 | { 28 | Byte NumStats; 29 | Byte Flags; 30 | 31 | union 32 | { 33 | UInt16 SummFreq; 34 | CPpmd_State2 State2; 35 | } Union2; 36 | 37 | union 38 | { 39 | CPpmd_State_Ref Stats; 40 | CPpmd_State4 State4; 41 | } Union4; 42 | 43 | CPpmd8_Context_Ref Suffix; 44 | } CPpmd8_Context; 45 | 46 | // MY_CPU_pragma_pop 47 | 48 | #define Ppmd8Context_OneState(p) ((CPpmd_State *)&(p)->Union2) 49 | 50 | /* PPMdI code rev.2 contains the fix over PPMdI code rev.1. 51 | But the code PPMdI.2 is not compatible with PPMdI.1 for some files compressed 52 | in FREEZE mode. So we disable FREEZE mode support. */ 53 | 54 | // #define PPMD8_FREEZE_SUPPORT 55 | 56 | enum 57 | { 58 | PPMD8_RESTORE_METHOD_RESTART, 59 | PPMD8_RESTORE_METHOD_CUT_OFF 60 | #ifdef PPMD8_FREEZE_SUPPORT 61 | , PPMD8_RESTORE_METHOD_FREEZE 62 | #endif 63 | , PPMD8_RESTORE_METHOD_UNSUPPPORTED 64 | }; 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | typedef struct 74 | { 75 | CPpmd8_Context *MinContext, *MaxContext; 76 | CPpmd_State *FoundState; 77 | unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, RestoreMethod; 78 | Int32 RunLength, InitRL; /* must be 32-bit at least */ 79 | 80 | UInt32 Size; 81 | UInt32 GlueCount; 82 | UInt32 AlignOffset; 83 | Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart; 84 | 85 | UInt32 Range; 86 | UInt32 Code; 87 | UInt32 Low; 88 | union 89 | { 90 | IByteInPtr In; 91 | IByteOutPtr Out; 92 | } Stream; 93 | 94 | Byte Indx2Units[PPMD_NUM_INDEXES + 2]; // +2 for alignment 95 | Byte Units2Indx[128]; 96 | CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES]; 97 | UInt32 Stamps[PPMD_NUM_INDEXES]; 98 | Byte NS2BSIndx[256], NS2Indx[260]; 99 | Byte ExpEscape[16]; 100 | CPpmd_See DummySee, See[24][32]; 101 | UInt16 BinSumm[25][64]; 102 | 103 | } CPpmd8; 104 | 105 | 106 | void Ppmd8_Construct(CPpmd8 *p); 107 | BoolInt Ppmd8_Alloc(CPpmd8 *p, UInt32 size, ISzAllocPtr alloc); 108 | void Ppmd8_Free(CPpmd8 *p, ISzAllocPtr alloc); 109 | void Ppmd8_Init(CPpmd8 *p, unsigned maxOrder, unsigned restoreMethod); 110 | #define Ppmd8_WasAllocated(p) ((p)->Base != NULL) 111 | 112 | 113 | /* ---------- Internal Functions ---------- */ 114 | 115 | #define Ppmd8_GetPtr(p, ptr) Ppmd_GetPtr(p, ptr) 116 | #define Ppmd8_GetContext(p, ptr) Ppmd_GetPtr_Type(p, ptr, CPpmd8_Context) 117 | #define Ppmd8_GetStats(p, ctx) Ppmd_GetPtr_Type(p, (ctx)->Union4.Stats, CPpmd_State) 118 | 119 | void Ppmd8_Update1(CPpmd8 *p); 120 | void Ppmd8_Update1_0(CPpmd8 *p); 121 | void Ppmd8_Update2(CPpmd8 *p); 122 | 123 | 124 | 125 | 126 | 127 | 128 | #define Ppmd8_GetBinSumm(p) \ 129 | &p->BinSumm[p->NS2Indx[(size_t)Ppmd8Context_OneState(p->MinContext)->Freq - 1]] \ 130 | [ p->PrevSuccess + ((p->RunLength >> 26) & 0x20) \ 131 | + p->NS2BSIndx[Ppmd8_GetContext(p, p->MinContext->Suffix)->NumStats] + \ 132 | + p->MinContext->Flags ] 133 | 134 | 135 | CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked, UInt32 *scale); 136 | 137 | 138 | /* 20.01: the original PPMdI encoder and decoder probably could work incorrectly in some rare cases, 139 | where the original PPMdI code can give "Divide by Zero" operation. 140 | We use the following fix to allow correct working of encoder and decoder in any cases. 141 | We correct (Escape_Freq) and (_sum_), if (_sum_) is larger than p->Range) */ 142 | #define PPMD8_CORRECT_SUM_RANGE(p, _sum_) if (_sum_ > p->Range /* /1 */) _sum_ = p->Range; 143 | 144 | 145 | /* ---------- Decode ---------- */ 146 | 147 | #define PPMD8_SYM_END (-1) 148 | #define PPMD8_SYM_ERROR (-2) 149 | 150 | /* 151 | You must set (CPpmd8::Stream.In) before Ppmd8_RangeDec_Init() 152 | 153 | Ppmd8_DecodeSymbol() 154 | out: 155 | >= 0 : decoded byte 156 | -1 : PPMD8_SYM_END : End of payload marker 157 | -2 : PPMD8_SYM_ERROR : Data error 158 | */ 159 | 160 | 161 | BoolInt Ppmd8_Init_RangeDec(CPpmd8 *p); 162 | #define Ppmd8_RangeDec_IsFinishedOK(p) ((p)->Code == 0) 163 | int Ppmd8_DecodeSymbol(CPpmd8 *p); 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | /* ---------- Encode ---------- */ 173 | 174 | #define Ppmd8_Init_RangeEnc(p) { (p)->Low = 0; (p)->Range = 0xFFFFFFFF; } 175 | void Ppmd8_Flush_RangeEnc(CPpmd8 *p); 176 | void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol); 177 | 178 | 179 | EXTERN_C_END 180 | 181 | #endif 182 | -------------------------------------------------------------------------------- /xjar.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xjar.h" 22 | 23 | XBinary::XCONVERT _TABLE_XJAR_STRUCTID[] = { 24 | {XJAR::STRUCTID_UNKNOWN, "Unknown", QObject::tr("Unknown")}, 25 | }; 26 | 27 | XJAR::XJAR(QIODevice *pDevice) : XZip(pDevice) 28 | { 29 | } 30 | 31 | bool XJAR::isValid(PDSTRUCT *pPdStruct) 32 | { 33 | bool bResult = false; 34 | 35 | XZip xzip(getDevice()); 36 | 37 | if (xzip.isValid()) { 38 | qint64 nECDOffset = xzip.findECDOffset(pPdStruct); 39 | bResult = xzip.isJAR(nECDOffset, pPdStruct); 40 | } 41 | 42 | return bResult; 43 | } 44 | 45 | bool XJAR::isValid(QIODevice *pDevice) 46 | { 47 | XJAR xjar(pDevice); 48 | 49 | return xjar.isValid(); 50 | } 51 | 52 | bool XJAR::isValid(QList *pListRecords, PDSTRUCT *pPdStruct) 53 | { 54 | bool bResult = false; 55 | 56 | bResult = XArchive::isArchiveRecordPresent("META-INF/MANIFEST.MF", pListRecords, pPdStruct); 57 | 58 | return bResult; 59 | } 60 | 61 | XBinary::FT XJAR::getFileType() 62 | { 63 | return FT_JAR; 64 | } 65 | 66 | XBinary::FILEFORMATINFO XJAR::getFileFormatInfo(PDSTRUCT *pPdStruct) 67 | { 68 | XBinary::FILEFORMATINFO result = {}; 69 | 70 | QList listArchiveRecords = getRecords(20000, pPdStruct); 71 | 72 | if (isValid(&listArchiveRecords, pPdStruct)) { 73 | result.bIsValid = true; 74 | result.nSize = getSize(); 75 | result.sExt = "jar"; 76 | result.fileType = FT_JAR; 77 | 78 | result.osName = OSNAME_JVM; 79 | result.bIsVM = true; 80 | 81 | result.sArch = getArch(); 82 | result.mode = getMode(); 83 | result.sType = typeIdToString(getType()); 84 | result.endian = getEndian(); 85 | 86 | qint32 nNumberOfRecords = listArchiveRecords.count(); 87 | 88 | for (qint32 i = 0; i < nNumberOfRecords; i++) { 89 | if (listArchiveRecords.at(i).spInfo.sRecordName.section(".", -1, -1) == "class") { 90 | RECORD record = listArchiveRecords.at(i); 91 | QByteArray baData = XArchive::decompress(&record, pPdStruct, 0, 0x100); 92 | 93 | if (baData.size() > 10) { 94 | char *pData = baData.data(); 95 | if (XBinary::_read_uint32(pData, true) == 0xCAFEBABE) { 96 | quint16 nMinor = XBinary::_read_uint16(pData + 4, true); 97 | quint16 nMajor = XBinary::_read_uint16(pData + 6, true); 98 | 99 | result.sOsVersion = XJavaClass::_getJDKVersion(nMajor, nMinor); 100 | 101 | break; 102 | } 103 | } 104 | } 105 | } 106 | 107 | // if (nNumberOfRecords < 20000) { 108 | // result.nNumberOfRecords = nNumberOfRecords; 109 | // } else { 110 | // result.nNumberOfRecords = getNumberOfRecords(pPdStruct); 111 | // } 112 | } 113 | 114 | return result; 115 | } 116 | 117 | QString XJAR::getFileFormatExt() 118 | { 119 | return "jar"; 120 | } 121 | 122 | XBinary::ENDIAN XJAR::getEndian() 123 | { 124 | return ENDIAN_UNKNOWN; 125 | } 126 | 127 | XBinary::MODE XJAR::getMode() 128 | { 129 | return MODE_DATA; 130 | } 131 | 132 | QString XJAR::getArch() 133 | { 134 | return tr("Universal"); 135 | } 136 | 137 | qint32 XJAR::getType() 138 | { 139 | return TYPE_PACKAGE; 140 | } 141 | 142 | QString XJAR::typeIdToString(qint32 nType) 143 | { 144 | QString sResult = tr("Unknown"); 145 | 146 | switch (nType) { 147 | case TYPE_PACKAGE: sResult = tr("Package"); 148 | } 149 | 150 | return sResult; 151 | } 152 | 153 | QString XJAR::structIDToString(quint32 nID) 154 | { 155 | return XBinary::XCONVERT_idToTransString(nID, _TABLE_XJAR_STRUCTID, sizeof(_TABLE_XJAR_STRUCTID) / sizeof(XBinary::XCONVERT)); 156 | } 157 | --------------------------------------------------------------------------------