├── src ├── lzma2201 │ └── C │ │ ├── Util │ │ ├── LzmaLib │ │ │ ├── LzmaLib.def │ │ │ ├── resource.rc │ │ │ ├── LzmaLibExports.c │ │ │ ├── LzmaLib.dsw │ │ │ ├── makefile │ │ │ └── LzmaLib.dsp │ │ ├── SfxSetup │ │ │ ├── setup.ico │ │ │ ├── Precomp.c │ │ │ ├── resource.rc │ │ │ ├── Precomp.h │ │ │ ├── SfxSetup.dsw │ │ │ ├── makefile │ │ │ ├── makefile_con │ │ │ └── SfxSetup.dsp │ │ ├── 7z │ │ │ ├── Precomp.c │ │ │ ├── Precomp.h │ │ │ ├── 7z.dsw │ │ │ ├── makefile.gcc │ │ │ └── makefile │ │ └── Lzma │ │ │ ├── makefile.gcc │ │ │ ├── makefile │ │ │ ├── LzmaUtil.dsw │ │ │ └── LzmaUtil.dsp │ │ ├── var_gcc_x64.mak │ │ ├── var_clang.mak │ │ ├── var_gcc_x86.mak │ │ ├── var_gcc.mak │ │ ├── Precomp.h │ │ ├── var_clang_x64.mak │ │ ├── var_clang_arm64.mak │ │ ├── var_clang_x86.mak │ │ ├── var_mac_x64.mak │ │ ├── var_mac_arm64.mak │ │ ├── var_gcc_arm64.mak │ │ ├── DllSecur.h │ │ ├── Sort.h │ │ ├── 7zAlloc.h │ │ ├── Delta.h │ │ ├── 7zBuf.c │ │ ├── 7zCrc.h │ │ ├── XzCrc64.h │ │ ├── RotateDefs.h │ │ ├── 7zBuf.h │ │ ├── 7zVersion.h │ │ ├── LzHash.h │ │ ├── warn_clang.mak │ │ ├── warn_clang_mac.mak │ │ ├── 7zBuf2.c │ │ ├── warn_gcc.mak │ │ ├── BraIA64.c │ │ ├── Alloc.h │ │ ├── LzmaLib.c │ │ ├── Lzma86Dec.c │ │ ├── XzEnc.h │ │ ├── Compiler.h │ │ ├── 7zVersion.rc │ │ ├── Lzma2Enc.h │ │ ├── 7zAlloc.c │ │ ├── Sha256.h │ │ ├── Bra86.c │ │ ├── 7zFile.h │ │ ├── Bra.h │ │ ├── Aes.h │ │ ├── Xz.c │ │ ├── Lzma2DecMt.h │ │ ├── XzCrc64Opt.c │ │ ├── XzCrc64.c │ │ ├── Lzma86Enc.c │ │ ├── DllSecur.c │ │ ├── LzFindMt.h │ │ ├── Sort.c │ │ ├── LzmaEnc.h │ │ ├── MtCoder.h │ │ ├── Lzma86.h │ │ ├── Delta.c │ │ ├── Bcj2.h │ │ ├── 7zCrcOpt.c │ │ ├── Lzma2Dec.h │ │ ├── LzFind.h │ │ ├── 7zStream.c │ │ ├── LzmaLib.h │ │ ├── Ppmd7.h │ │ ├── Bra.c │ │ ├── MtDec.h │ │ ├── 7z.h │ │ ├── Ppmd.h │ │ └── Bcj2.c ├── TODO.md ├── logo.hpp ├── version.hpp ├── home.hpp ├── icon.hpp ├── Picture.hpp ├── DownloadButton.hpp ├── home.cpp ├── curl_tools.hpp ├── pages.hpp ├── BuildInfo.hpp ├── page_about.cpp ├── page1.cpp ├── DownloadButton.cpp ├── page2.cpp ├── main.cpp ├── page0.cpp ├── page3.cpp ├── page4.cpp ├── Debug.hpp ├── Manager.hpp ├── page5.cpp ├── page6.cpp ├── page7.cpp ├── page8.cpp └── shortcut.cpp ├── README.md └── CMakeLists.txt /src/lzma2201/C/Util/LzmaLib/LzmaLib.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | LzmaCompress 3 | LzmaUncompress 4 | 5 | -------------------------------------------------------------------------------- /src/TODO.md: -------------------------------------------------------------------------------- 1 | -Remove freeze while deleting existing directory 2 | 3 | -shortcut.hpp 4 | 5 | -updater 6 | 7 | -installer updater 8 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/LzmaLib/resource.rc: -------------------------------------------------------------------------------- 1 | #include "../../7zVersion.rc" 2 | 3 | MY_VERSION_INFO_DLL("LZMA library", "LZMA") 4 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/SfxSetup/setup.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vuniverse0/mingwInstaller/HEAD/src/lzma2201/C/Util/SfxSetup/setup.ico -------------------------------------------------------------------------------- /src/lzma2201/C/Util/7z/Precomp.c: -------------------------------------------------------------------------------- 1 | /* Precomp.c -- StdAfx 2 | 2013-01-21 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/SfxSetup/Precomp.c: -------------------------------------------------------------------------------- 1 | /* Precomp.c -- StdAfx 2 | 2013-01-21 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/SfxSetup/resource.rc: -------------------------------------------------------------------------------- 1 | #include "../../7zVersion.rc" 2 | 3 | MY_VERSION_INFO_APP("7z Setup SFX small", "7zS2.sfx") 4 | 5 | 1 ICON "setup.ico" 6 | -------------------------------------------------------------------------------- /src/logo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MINGWINSTALLER_LOGO_HPP 2 | #define MINGWINSTALLER_LOGO_HPP 3 | 4 | #include "Picture.hpp" 5 | 6 | Picture getLogo(); 7 | 8 | #endif //MINGWINSTALLER_LOGO_HPP -------------------------------------------------------------------------------- /src/version.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MINGWINSTALLER_VERSION_HPP 2 | #define MINGWINSTALLER_VERSION_HPP 3 | 4 | #define MINGW_W64_INSTALLER_VERSION "1.2.1" 5 | 6 | #endif //MINGWINSTALLER_VERSION_HPP 7 | -------------------------------------------------------------------------------- /src/home.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MINGWINSTALLER_HOME_HPP 2 | #define MINGWINSTALLER_HOME_HPP 3 | 4 | #include 5 | 6 | 7 | std::string home(); 8 | 9 | #endif //MINGWINSTALLER_HOME_HPP 10 | -------------------------------------------------------------------------------- /src/icon.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MINGWINSTALLER_ICON_HPP 2 | #define MINGWINSTALLER_ICON_HPP 3 | 4 | #include "Picture.hpp" 5 | 6 | 7 | Picture getIcon(); 8 | 9 | #endif //MINGWINSTALLER_ICON_HPP 10 | -------------------------------------------------------------------------------- /src/lzma2201/C/var_gcc_x64.mak: -------------------------------------------------------------------------------- 1 | PLATFORM=x64 2 | O=b/g_$(PLATFORM) 3 | IS_X64=1 4 | IS_X86= 5 | IS_ARM64= 6 | CROSS_COMPILE= 7 | MY_ARCH= 8 | USE_ASM=1 9 | CC=$(CROSS_COMPILE)gcc 10 | CXX=$(CROSS_COMPILE)g++ 11 | -------------------------------------------------------------------------------- /src/lzma2201/C/var_clang.mak: -------------------------------------------------------------------------------- 1 | PLATFORM= 2 | O=b/c 3 | IS_X64= 4 | IS_X86= 5 | IS_ARM64= 6 | CROSS_COMPILE= 7 | MY_ARCH= 8 | USE_ASM= 9 | CC=$(CROSS_COMPILE)clang 10 | CXX=$(CROSS_COMPILE)clang++ 11 | USE_CLANG=1 12 | -------------------------------------------------------------------------------- /src/lzma2201/C/var_gcc_x86.mak: -------------------------------------------------------------------------------- 1 | PLATFORM=x86 2 | O=b/g_$(PLATFORM) 3 | IS_X64= 4 | IS_X86=1 5 | IS_ARM64= 6 | CROSS_COMPILE= 7 | MY_ARCH=-m32 8 | USE_ASM=1 9 | CC=$(CROSS_COMPILE)gcc 10 | CXX=$(CROSS_COMPILE)g++ 11 | -------------------------------------------------------------------------------- /src/lzma2201/C/var_gcc.mak: -------------------------------------------------------------------------------- 1 | PLATFORM= 2 | O=b/g 3 | IS_X64= 4 | IS_X86= 5 | IS_ARM64= 6 | CROSS_COMPILE= 7 | MY_ARCH= 8 | USE_ASM= 9 | CC=$(CROSS_COMPILE)gcc 10 | CXX=$(CROSS_COMPILE)g++ 11 | 12 | # -march=armv8-a+crc+crypto 13 | -------------------------------------------------------------------------------- /src/lzma2201/C/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 | -------------------------------------------------------------------------------- /src/lzma2201/C/var_clang_x64.mak: -------------------------------------------------------------------------------- 1 | PLATFORM=x64 2 | O=b/c_$(PLATFORM) 3 | IS_X64=1 4 | IS_X86= 5 | IS_ARM64= 6 | CROSS_COMPILE= 7 | MY_ARCH= 8 | USE_ASM=1 9 | CC=$(CROSS_COMPILE)clang 10 | CXX=$(CROSS_COMPILE)clang++ 11 | USE_CLANG=1 12 | -------------------------------------------------------------------------------- /src/lzma2201/C/var_clang_arm64.mak: -------------------------------------------------------------------------------- 1 | PLATFORM=arm64 2 | O=b/c_$(PLATFORM) 3 | IS_X64= 4 | IS_X86= 5 | IS_ARM64=1 6 | CROSS_COMPILE= 7 | MY_ARCH= 8 | USE_ASM=1 9 | CC=$(CROSS_COMPILE)clang 10 | CXX=$(CROSS_COMPILE)clang++ 11 | USE_CLANG=1 12 | -------------------------------------------------------------------------------- /src/lzma2201/C/var_clang_x86.mak: -------------------------------------------------------------------------------- 1 | PLATFORM=x86 2 | O=b/c_$(PLATFORM) 3 | IS_X64= 4 | IS_X86=1 5 | IS_ARM64= 6 | CROSS_COMPILE= 7 | MY_ARCH=-m32 8 | USE_ASM=1 9 | CC=$(CROSS_COMPILE)clang 10 | CXX=$(CROSS_COMPILE)clang++ 11 | USE_CLANG=1 12 | -------------------------------------------------------------------------------- /src/Picture.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MINGWINSTALLER_PICTURE_HPP 2 | #define MINGWINSTALLER_PICTURE_HPP 3 | 4 | #include 5 | 6 | struct Picture{ 7 | std::uint8_t *pointer; 8 | std::size_t size; 9 | }; 10 | 11 | #endif //MINGWINSTALLER_PICTURE_HPP 12 | -------------------------------------------------------------------------------- /src/lzma2201/C/var_mac_x64.mak: -------------------------------------------------------------------------------- 1 | PLATFORM=x64 2 | O=b/m_$(PLATFORM) 3 | IS_X64=1 4 | IS_X86= 5 | IS_ARM64= 6 | CROSS_COMPILE= 7 | MY_ARCH=-arch x86_64 8 | USE_ASM= 9 | CC=$(CROSS_COMPILE)clang 10 | CXX=$(CROSS_COMPILE)clang++ 11 | USE_CLANG=1 12 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/7z/Precomp.h: -------------------------------------------------------------------------------- 1 | /* Precomp.h -- StdAfx 2 | 2013-06-16 : 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 | -------------------------------------------------------------------------------- /src/lzma2201/C/var_mac_arm64.mak: -------------------------------------------------------------------------------- 1 | PLATFORM=arm64 2 | O=b/m_$(PLATFORM) 3 | IS_X64= 4 | IS_X86= 5 | IS_ARM64=1 6 | CROSS_COMPILE= 7 | MY_ARCH=-arch arm64 8 | USE_ASM=1 9 | CC=$(CROSS_COMPILE)clang 10 | CXX=$(CROSS_COMPILE)clang++ 11 | USE_CLANG=1 12 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/SfxSetup/Precomp.h: -------------------------------------------------------------------------------- 1 | /* Precomp.h -- StdAfx 2 | 2013-06-16 : 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 | -------------------------------------------------------------------------------- /src/lzma2201/C/var_gcc_arm64.mak: -------------------------------------------------------------------------------- 1 | PLATFORM=arm64 2 | O=b/g_$(PLATFORM) 3 | IS_X64= 4 | IS_X86= 5 | IS_ARM64=1 6 | CROSS_COMPILE= 7 | MY_ARCH=-mtune=cortex-a53 8 | USE_ASM=1 9 | CC=$(CROSS_COMPILE)gcc 10 | CXX=$(CROSS_COMPILE)g++ 11 | 12 | # -march=armv8-a+crc+crypto 13 | -------------------------------------------------------------------------------- /src/lzma2201/C/DllSecur.h: -------------------------------------------------------------------------------- 1 | /* DllSecur.h -- DLL loading for security 2 | 2018-02-19 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __DLL_SECUR_H 5 | #define __DLL_SECUR_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #ifdef _WIN32 12 | 13 | void My_SetDefaultDllDirectories(void); 14 | void LoadSecurityDlls(void); 15 | 16 | #endif 17 | 18 | EXTERN_C_END 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/DownloadButton.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MINGWINSTALLER_DOWNLOADBUTTON_HPP 2 | #define MINGWINSTALLER_DOWNLOADBUTTON_HPP 3 | 4 | #include 5 | 6 | 7 | struct DownloadButton : Fl_Button { 8 | DownloadButton(int x, int y, int w, int h, const char *label = nullptr); 9 | void extracting(); 10 | void downloading(); 11 | void download(); 12 | }; 13 | 14 | 15 | #endif //MINGWINSTALLER_DOWNLOADBUTTON_HPP 16 | -------------------------------------------------------------------------------- /src/lzma2201/C/Sort.h: -------------------------------------------------------------------------------- 1 | /* Sort.h -- Sort functions 2 | 2014-04-05 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_SORT_H 5 | #define __7Z_SORT_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | void HeapSort(UInt32 *p, size_t size); 12 | void HeapSort64(UInt64 *p, size_t size); 13 | 14 | /* void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size); */ 15 | 16 | EXTERN_C_END 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/LzmaLib/LzmaLibExports.c: -------------------------------------------------------------------------------- 1 | /* LzmaLibExports.c -- LZMA library DLL Entry point 2 | 2015-11-08 : Igor Pavlov : Public domain */ 3 | 4 | #include "../../Precomp.h" 5 | 6 | #include 7 | 8 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) 9 | { 10 | UNUSED_VAR(hInstance); 11 | UNUSED_VAR(dwReason); 12 | UNUSED_VAR(lpReserved); 13 | return TRUE; 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mingwInstaller 2 | Online installer of MinGW-W64 with GUI 3 | 4 | 5 | Libs I use: 6 | 7 | -[fltk](https://www.fltk.org/) 8 | 9 | -[curl](https://curl.se/libcurl/) 10 | 11 | I also use 7z sources(part of [lzma dev kit](https://www.7-zip.org/sdk.html)). 12 | 13 | All icons are in binary and all libs linked staticaly, so you need only one [.exe](https://github.com/Vuniverse0/mingwInstaller/releases) file to run installer. 14 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/Lzma/makefile.gcc: -------------------------------------------------------------------------------- 1 | PROG = 7lzma 2 | 3 | include ../../../CPP/7zip/LzmaDec_gcc.mak 4 | 5 | 6 | OBJS = \ 7 | $(LZMA_DEC_OPT_OBJS) \ 8 | $O/7zFile.o \ 9 | $O/7zStream.o \ 10 | $O/Alloc.o \ 11 | $O/CpuArch.o \ 12 | $O/LzFind.o \ 13 | $O/LzFindMt.o \ 14 | $O/LzFindOpt.o \ 15 | $O/LzmaDec.o \ 16 | $O/LzmaEnc.o \ 17 | $O/LzmaUtil.o \ 18 | $O/Threads.o \ 19 | 20 | 21 | include ../../7zip_gcc_c.mak 22 | -------------------------------------------------------------------------------- /src/lzma2201/C/7zAlloc.h: -------------------------------------------------------------------------------- 1 | /* 7zAlloc.h -- Allocation functions 2 | 2017-04-03 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_ALLOC_H 5 | #define __7Z_ALLOC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | void *SzAlloc(ISzAllocPtr p, size_t size); 12 | void SzFree(ISzAllocPtr p, void *address); 13 | 14 | void *SzAllocTemp(ISzAllocPtr p, size_t size); 15 | void SzFreeTemp(ISzAllocPtr p, void *address); 16 | 17 | EXTERN_C_END 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/lzma2201/C/Delta.h: -------------------------------------------------------------------------------- 1 | /* Delta.h -- Delta converter 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __DELTA_H 5 | #define __DELTA_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define DELTA_STATE_SIZE 256 12 | 13 | void Delta_Init(Byte *state); 14 | void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size); 15 | void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size); 16 | 17 | EXTERN_C_END 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/Lzma/makefile: -------------------------------------------------------------------------------- 1 | # MY_STATIC_LINK=1 2 | PROG = LZMAc.exe 3 | 4 | CFLAGS = $(CFLAGS) \ 5 | 6 | LIB_OBJS = \ 7 | $O\LzmaUtil.obj \ 8 | 9 | C_OBJS = \ 10 | $O\Alloc.obj \ 11 | $O\CpuArch.obj \ 12 | $O\LzFind.obj \ 13 | $O\LzFindMt.obj \ 14 | $O\LzFindOpt.obj \ 15 | $O\LzmaDec.obj \ 16 | $O\LzmaEnc.obj \ 17 | $O\7zFile.obj \ 18 | $O\7zStream.obj \ 19 | $O\Threads.obj \ 20 | 21 | OBJS = \ 22 | $(LIB_OBJS) \ 23 | $(C_OBJS) \ 24 | 25 | !include "../../../CPP/Build.mak" 26 | 27 | $(LIB_OBJS): $(*B).c 28 | $(COMPL_O2) 29 | $(C_OBJS): ../../$(*B).c 30 | $(COMPL_O2) 31 | -------------------------------------------------------------------------------- /src/home.cpp: -------------------------------------------------------------------------------- 1 | #include "home.hpp" 2 | 3 | #ifdef WIN32 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | std::string home() 10 | { 11 | char p[MAX_PATH]; 12 | LPSTR path = p; 13 | if(SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_PROFILE, NULL, 0, path))){ 14 | std::string res {path}; 15 | res+="/"; 16 | std::replace(res.begin(), res.end(), '\\', '/'); 17 | return res; 18 | } 19 | throw std::runtime_error("cant get home path"); 20 | } 21 | 22 | #else 23 | 24 | std::string home() 25 | { 26 | //Hardcoded for debug on Linux 27 | return "/home/vuniverse"; 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/7z/7z.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "7z"=.\7z.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/Lzma/LzmaUtil.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "LzmaUtil"=.\LzmaUtil.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/LzmaLib/LzmaLib.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "LzmaLib"=.\LzmaLib.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/SfxSetup/SfxSetup.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "SfxSetup"=.\SfxSetup.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/7z/makefile.gcc: -------------------------------------------------------------------------------- 1 | PROG = 7zdec 2 | 3 | LOCAL_FLAGS = -D_7ZIP_PPMD_SUPPPORT 4 | 5 | include ../../../CPP/7zip/LzmaDec_gcc.mak 6 | 7 | 8 | OBJS = \ 9 | $(LZMA_DEC_OPT_OBJS) \ 10 | $O/Bcj2.o \ 11 | $O/Bra.o \ 12 | $O/Bra86.o \ 13 | $O/BraIA64.o \ 14 | $O/CpuArch.o \ 15 | $O/Delta.o \ 16 | $O/Lzma2Dec.o \ 17 | $O/LzmaDec.o \ 18 | $O/Ppmd7.o \ 19 | $O/Ppmd7Dec.o \ 20 | $O/7zCrc.o \ 21 | $O/7zCrcOpt.o \ 22 | $O/Sha256.o \ 23 | $O/Sha256Opt.o \ 24 | $O/7zAlloc.o \ 25 | $O/7zArcIn.o \ 26 | $O/7zBuf.o \ 27 | $O/7zBuf2.o \ 28 | $O/7zDec.o \ 29 | $O/7zMain.o \ 30 | $O/7zFile.o \ 31 | $O/7zStream.o \ 32 | 33 | 34 | include ../../7zip_gcc_c.mak 35 | -------------------------------------------------------------------------------- /src/lzma2201/C/7zBuf.c: -------------------------------------------------------------------------------- 1 | /* 7zBuf.c -- Byte Buffer 2 | 2017-04-03 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "7zBuf.h" 7 | 8 | void Buf_Init(CBuf *p) 9 | { 10 | p->data = 0; 11 | p->size = 0; 12 | } 13 | 14 | int Buf_Create(CBuf *p, size_t size, ISzAllocPtr alloc) 15 | { 16 | p->size = 0; 17 | if (size == 0) 18 | { 19 | p->data = 0; 20 | return 1; 21 | } 22 | p->data = (Byte *)ISzAlloc_Alloc(alloc, size); 23 | if (p->data) 24 | { 25 | p->size = size; 26 | return 1; 27 | } 28 | return 0; 29 | } 30 | 31 | void Buf_Free(CBuf *p, ISzAllocPtr alloc) 32 | { 33 | ISzAlloc_Free(alloc, p->data); 34 | p->data = 0; 35 | p->size = 0; 36 | } 37 | -------------------------------------------------------------------------------- /src/lzma2201/C/7zCrc.h: -------------------------------------------------------------------------------- 1 | /* 7zCrc.h -- CRC32 calculation 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_CRC_H 5 | #define __7Z_CRC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | extern UInt32 g_CrcTable[]; 12 | 13 | /* Call CrcGenerateTable one time before other CRC functions */ 14 | void MY_FAST_CALL CrcGenerateTable(void); 15 | 16 | #define CRC_INIT_VAL 0xFFFFFFFF 17 | #define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) 18 | #define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 19 | 20 | UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size); 21 | UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size); 22 | 23 | EXTERN_C_END 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/lzma2201/C/XzCrc64.h: -------------------------------------------------------------------------------- 1 | /* XzCrc64.h -- CRC64 calculation 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __XZ_CRC64_H 5 | #define __XZ_CRC64_H 6 | 7 | #include 8 | 9 | #include "7zTypes.h" 10 | 11 | EXTERN_C_BEGIN 12 | 13 | extern UInt64 g_Crc64Table[]; 14 | 15 | void MY_FAST_CALL Crc64GenerateTable(void); 16 | 17 | #define CRC64_INIT_VAL UINT64_CONST(0xFFFFFFFFFFFFFFFF) 18 | #define CRC64_GET_DIGEST(crc) ((crc) ^ CRC64_INIT_VAL) 19 | #define CRC64_UPDATE_BYTE(crc, b) (g_Crc64Table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 20 | 21 | UInt64 MY_FAST_CALL Crc64Update(UInt64 crc, const void *data, size_t size); 22 | UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size); 23 | 24 | EXTERN_C_END 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/LzmaLib/makefile: -------------------------------------------------------------------------------- 1 | MY_STATIC_LINK=1 2 | SLIB = sLZMA.lib 3 | PROG = LZMA.dll 4 | SLIBPATH = $O\$(SLIB) 5 | 6 | DEF_FILE = LzmaLib.def 7 | CFLAGS = $(CFLAGS) \ 8 | 9 | LIB_OBJS = \ 10 | $O\LzmaLibExports.obj \ 11 | 12 | C_OBJS = \ 13 | $O\Alloc.obj \ 14 | $O\CpuArch.obj \ 15 | $O\LzFind.obj \ 16 | $O\LzFindMt.obj \ 17 | $O\LzFindOpt.obj \ 18 | $O\LzmaDec.obj \ 19 | $O\LzmaEnc.obj \ 20 | $O\LzmaLib.obj \ 21 | $O\Threads.obj \ 22 | 23 | OBJS = \ 24 | $(LIB_OBJS) \ 25 | $(C_OBJS) \ 26 | $O\resource.res 27 | 28 | !include "../../../CPP/Build.mak" 29 | 30 | $(SLIBPATH): $O $(OBJS) 31 | lib -out:$(SLIBPATH) $(OBJS) $(LIBS) 32 | 33 | $(LIB_OBJS): $(*B).c 34 | $(COMPL_O2) 35 | $(C_OBJS): ../../$(*B).c 36 | $(COMPL_O2) 37 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/SfxSetup/makefile: -------------------------------------------------------------------------------- 1 | PROG = 7zS2.sfx 2 | MY_FIXED = 1 3 | 4 | C_OBJS = \ 5 | $O\7zAlloc.obj \ 6 | $O\7zArcIn.obj \ 7 | $O\7zBuf.obj \ 8 | $O\7zBuf2.obj \ 9 | $O\7zCrc.obj \ 10 | $O\7zCrcOpt.obj \ 11 | $O\7zFile.obj \ 12 | $O\7zDec.obj \ 13 | $O\7zStream.obj \ 14 | $O\Bcj2.obj \ 15 | $O\Bra.obj \ 16 | $O\Bra86.obj \ 17 | $O\BraIA64.obj \ 18 | $O\CpuArch.obj \ 19 | $O\Delta.obj \ 20 | $O\DllSecur.obj \ 21 | $O\Lzma2Dec.obj \ 22 | $O\LzmaDec.obj \ 23 | 24 | 7Z_OBJS = \ 25 | $O\SfxSetup.obj \ 26 | 27 | OBJS = \ 28 | $(7Z_OBJS) \ 29 | $(C_OBJS) \ 30 | $O\resource.res 31 | 32 | !include "../../../CPP/Build.mak" 33 | 34 | $(7Z_OBJS): $(*B).c 35 | $(COMPL_O1) 36 | $(C_OBJS): ../../$(*B).c 37 | $(COMPL_O1) 38 | -------------------------------------------------------------------------------- /src/lzma2201/C/RotateDefs.h: -------------------------------------------------------------------------------- 1 | /* RotateDefs.h -- Rotate functions 2 | 2015-03-25 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __ROTATE_DEFS_H 5 | #define __ROTATE_DEFS_H 6 | 7 | #ifdef _MSC_VER 8 | 9 | #include 10 | 11 | /* don't use _rotl with 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 | #else 22 | 23 | /* new compilers can translate these macros to fast commands. */ 24 | 25 | #define rotlFixed(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) 26 | #define rotrFixed(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) 27 | 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/lzma2201/C/7zBuf.h: -------------------------------------------------------------------------------- 1 | /* 7zBuf.h -- Byte Buffer 2 | 2017-04-03 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_BUF_H 5 | #define __7Z_BUF_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | typedef struct 12 | { 13 | Byte *data; 14 | size_t size; 15 | } CBuf; 16 | 17 | void Buf_Init(CBuf *p); 18 | int Buf_Create(CBuf *p, size_t size, ISzAllocPtr alloc); 19 | void Buf_Free(CBuf *p, ISzAllocPtr alloc); 20 | 21 | typedef struct 22 | { 23 | Byte *data; 24 | size_t size; 25 | size_t pos; 26 | } CDynBuf; 27 | 28 | void DynBuf_Construct(CDynBuf *p); 29 | void DynBuf_SeekToBeg(CDynBuf *p); 30 | int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAllocPtr alloc); 31 | void DynBuf_Free(CDynBuf *p, ISzAllocPtr alloc); 32 | 33 | EXTERN_C_END 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/curl_tools.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MINGWINSTALLER_CURL_TOOLS_HPP 2 | #define MINGWINSTALLER_CURL_TOOLS_HPP 3 | 4 | #include 5 | 6 | static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) 7 | { 8 | size_t written = fwrite(ptr, size, nmemb, (FILE *)stream); 9 | return written; 10 | } 11 | 12 | static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) 13 | { 14 | ((std::string*)userp)->append((char*)contents, size * nmemb); 15 | return size * nmemb; 16 | } 17 | 18 | static size_t header_callback(char *, size_t size, size_t nitems, void *) 19 | { 20 | /* received header is nitems * size long in 'buffer' NOT ZERO TERMINATED */ 21 | /* 'userdata' is set with CURLOPT_HEADERDATA */ 22 | return nitems * size; 23 | } 24 | 25 | #endif //MINGWINSTALLER_CURL_TOOLS_HPP 26 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/SfxSetup/makefile_con: -------------------------------------------------------------------------------- 1 | PROG = 7zS2con.sfx 2 | MY_FIXED = 1 3 | CFLAGS = $(CFLAGS) -D_CONSOLE 4 | 5 | C_OBJS = \ 6 | $O\7zAlloc.obj \ 7 | $O\7zArcIn.obj \ 8 | $O\7zBuf.obj \ 9 | $O\7zBuf2.obj \ 10 | $O\7zCrc.obj \ 11 | $O\7zCrcOpt.obj \ 12 | $O\7zFile.obj \ 13 | $O\7zDec.obj \ 14 | $O\7zStream.obj \ 15 | $O\Bcj2.obj \ 16 | $O\Bra.obj \ 17 | $O\Bra86.obj \ 18 | $O\BraIA64.obj \ 19 | $O\CpuArch.obj \ 20 | $O\Delta.obj \ 21 | $O\DllSecur.obj \ 22 | $O\Lzma2Dec.obj \ 23 | $O\LzmaDec.obj \ 24 | 25 | 7Z_OBJS = \ 26 | $O\SfxSetup.obj \ 27 | 28 | OBJS = \ 29 | $(7Z_OBJS) \ 30 | $(C_OBJS) \ 31 | $O\resource.res 32 | 33 | !include "../../../CPP/Build.mak" 34 | 35 | $(7Z_OBJS): $(*B).c 36 | $(COMPL_O1) 37 | $(C_OBJS): ../../$(*B).c 38 | $(COMPL_O1) 39 | -------------------------------------------------------------------------------- /src/pages.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MINGWINSTALLER_PAGES_HPP 2 | #define MINGWINSTALLER_PAGES_HPP 3 | 4 | #include 5 | 6 | 7 | class Fl_Widget; 8 | 9 | constexpr std::size_t width = 650 + 300; 10 | constexpr std::size_t height = 300 + 10; 11 | constexpr std::size_t png_size = 300; 12 | constexpr std::size_t button_width = 100; 13 | constexpr std::size_t button_height = 25; 14 | constexpr std::size_t button_x = 540; 15 | constexpr std::size_t button_y = 280; 16 | 17 | void next_cb(Fl_Widget*, void*); 18 | void back_cb(Fl_Widget*, void*); 19 | void done_cb(Fl_Widget*, void*); 20 | 21 | enum class ExcRs{ sjlj, dwarf, seh, error}; 22 | enum class MgRs{ win32, posix, mcf, error}; 23 | enum class Arcs{ i686, x86_64, error}; 24 | enum class Crt{ empty, msvcrt, ucrt, error}; 25 | 26 | void showError(const char* error); 27 | 28 | #endif //MINGWINSTALLER_PAGES_HPP 29 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/7z/makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT 2 | 3 | PROG = 7zDec.exe 4 | 5 | C_OBJS = \ 6 | $O\7zAlloc.obj \ 7 | $O\7zBuf.obj \ 8 | $O\7zCrc.obj \ 9 | $O\7zCrcOpt.obj \ 10 | $O\7zFile.obj \ 11 | $O\7zDec.obj \ 12 | $O\7zArcIn.obj \ 13 | $O\7zStream.obj \ 14 | $O\Bcj2.obj \ 15 | $O\Bra.obj \ 16 | $O\Bra86.obj \ 17 | $O\BraIA64.obj \ 18 | $O\CpuArch.obj \ 19 | $O\Delta.obj \ 20 | $O\Lzma2Dec.obj \ 21 | $O\LzmaDec.obj \ 22 | $O\Ppmd7.obj \ 23 | $O\Ppmd7Dec.obj \ 24 | 25 | 7Z_OBJS = \ 26 | $O\7zMain.obj \ 27 | 28 | OBJS = \ 29 | $O\Precomp.obj \ 30 | $(7Z_OBJS) \ 31 | $(C_OBJS) \ 32 | 33 | !include "../../../CPP/Build.mak" 34 | 35 | $(7Z_OBJS): $(*B).c 36 | $(CCOMPL_USE) 37 | $(C_OBJS): ../../$(*B).c 38 | $(CCOMPL_USE) 39 | $O\Precomp.obj: Precomp.c 40 | $(CCOMPL_PCH) 41 | -------------------------------------------------------------------------------- /src/lzma2201/C/7zVersion.h: -------------------------------------------------------------------------------- 1 | #define MY_VER_MAJOR 22 2 | #define MY_VER_MINOR 01 3 | #define MY_VER_BUILD 0 4 | #define MY_VERSION_NUMBERS "22.01" 5 | #define MY_VERSION MY_VERSION_NUMBERS 6 | 7 | #ifdef MY_CPU_NAME 8 | #define MY_VERSION_CPU MY_VERSION " (" MY_CPU_NAME ")" 9 | #else 10 | #define MY_VERSION_CPU MY_VERSION 11 | #endif 12 | 13 | #define MY_DATE "2022-07-15" 14 | #undef MY_COPYRIGHT 15 | #undef MY_VERSION_COPYRIGHT_DATE 16 | #define MY_AUTHOR_NAME "Igor Pavlov" 17 | #define MY_COPYRIGHT_PD "Igor Pavlov : Public domain" 18 | #define MY_COPYRIGHT_CR "Copyright (c) 1999-2022 Igor Pavlov" 19 | 20 | #ifdef USE_COPYRIGHT_CR 21 | #define MY_COPYRIGHT MY_COPYRIGHT_CR 22 | #else 23 | #define MY_COPYRIGHT MY_COPYRIGHT_PD 24 | #endif 25 | 26 | #define MY_COPYRIGHT_DATE MY_COPYRIGHT " : " MY_DATE 27 | #define MY_VERSION_COPYRIGHT_DATE MY_VERSION_CPU " : " MY_COPYRIGHT " : " MY_DATE 28 | -------------------------------------------------------------------------------- /src/lzma2201/C/LzHash.h: -------------------------------------------------------------------------------- 1 | /* LzHash.h -- HASH functions for LZ algorithms 2 | 2019-10-30 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZ_HASH_H 5 | #define __LZ_HASH_H 6 | 7 | /* 8 | (kHash2Size >= (1 << 8)) : Required 9 | (kHash3Size >= (1 << 16)) : Required 10 | */ 11 | 12 | #define kHash2Size (1 << 10) 13 | #define kHash3Size (1 << 16) 14 | // #define kHash4Size (1 << 20) 15 | 16 | #define kFix3HashSize (kHash2Size) 17 | #define kFix4HashSize (kHash2Size + kHash3Size) 18 | // #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) 19 | 20 | /* 21 | We use up to 3 crc values for hash: 22 | crc0 23 | crc1 << Shift_1 24 | crc2 << Shift_2 25 | (Shift_1 = 5) and (Shift_2 = 10) is good tradeoff. 26 | Small values for Shift are not good for collision rate. 27 | Big value for Shift_2 increases the minimum size 28 | of hash table, that will be slow for small files. 29 | */ 30 | 31 | #define kLzHash_CrcShift_1 5 32 | #define kLzHash_CrcShift_2 10 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/lzma2201/C/warn_clang.mak: -------------------------------------------------------------------------------- 1 | CFLAGS_WARN_CLANG_3_8_UNIQ = \ 2 | -Wno-reserved-id-macro \ 3 | -Wno-old-style-cast \ 4 | -Wno-c++11-long-long \ 5 | -Wno-unused-macros \ 6 | 7 | CFLAGS_WARN_CLANG_3_8 = \ 8 | $(CFLAGS_WARN_CLANG_3_8_UNIQ) \ 9 | -Weverything \ 10 | -Wno-extra-semi \ 11 | -Wno-sign-conversion \ 12 | -Wno-language-extension-token \ 13 | -Wno-global-constructors \ 14 | -Wno-non-virtual-dtor \ 15 | -Wno-switch-enum \ 16 | -Wno-covered-switch-default \ 17 | -Wno-cast-qual \ 18 | -Wno-padded \ 19 | -Wno-exit-time-destructors \ 20 | -Wno-weak-vtables \ 21 | 22 | CFLAGS_WARN_CLANG_12= $(CFLAGS_WARN_CLANG_3_8) \ 23 | -Wno-extra-semi-stmt \ 24 | -Wno-zero-as-null-pointer-constant \ 25 | -Wno-deprecated-dynamic-exception-spec \ 26 | -Wno-c++98-compat-pedantic \ 27 | -Wno-atomic-implicit-seq-cst \ 28 | -Wconversion \ 29 | -Wno-sign-conversion \ 30 | 31 | CFLAGS_WARN_1 = \ 32 | -Wno-deprecated-copy-dtor \ 33 | 34 | 35 | 36 | 37 | CFLAGS_WARN = $(CFLAGS_WARN_CLANG_12) $(CFLAGS_WARN_1) 38 | -------------------------------------------------------------------------------- /src/BuildInfo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MINGWINSTALLER_BUILDINFO_HPP 2 | #define MINGWINSTALLER_BUILDINFO_HPP 3 | 4 | #include 5 | 6 | #include "pages.hpp" 7 | 8 | 9 | struct BuildInfo { 10 | std::string name; 11 | std::string version; 12 | std::string download; 13 | Arcs architecture; 14 | MgRs multithreading; 15 | std::size_t revision; 16 | ExcRs exception; 17 | Crt runtime; 18 | }; 19 | 20 | struct SelectInfo { 21 | std::size_t version = 0; 22 | Arcs architecture = Arcs::i686; 23 | MgRs multithreading = MgRs::win32; 24 | std::size_t revision = 0; 25 | ExcRs exception = ExcRs::error; ///TODO maybe fix it and make default sjlj 26 | Crt runtime = Crt::empty; 27 | }; 28 | 29 | inline bool operator==(SelectInfo a, SelectInfo b) 30 | { 31 | return a.version == b.version 32 | && a.revision == b.revision 33 | && a.architecture == b.architecture 34 | && a.multithreading == b.multithreading 35 | && a.runtime == b.runtime 36 | && a.exception == b.exception; 37 | } 38 | 39 | 40 | #endif //MINGWINSTALLER_BUILDINFO_HPP 41 | -------------------------------------------------------------------------------- /src/page_about.cpp: -------------------------------------------------------------------------------- 1 | #include "version.hpp" 2 | 3 | #include "pages.hpp" 4 | 5 | #include "Manager.hpp" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | ///page_about 13 | void page_about() 14 | { 15 | auto *g = new Fl_Group(0, 0, width, height); 16 | auto *text = new Fl_Help_View(50 + png_size, 1, 600, 275); 17 | text->value("

About

" 18 | "

Version: " 19 | MINGW_W64_INSTALLER_VERSION 20 | "

" 21 | "

This installer was developed by Vuniverse." 22 | "

It is open source." 23 | "

Report a bug or an error.

" 24 | ); 25 | text->textsize(20); 26 | 27 | auto *next = new Fl_Button(button_x + png_size, button_y, button_width, button_height, "Ok"); 28 | next->callback(next_cb); 29 | 30 | Manager::logo(); 31 | 32 | g->end(); 33 | } -------------------------------------------------------------------------------- /src/lzma2201/C/warn_clang_mac.mak: -------------------------------------------------------------------------------- 1 | CFLAGS_WARN_CLANG_3_8_UNIQ = \ 2 | -Wno-reserved-id-macro \ 3 | -Wno-old-style-cast \ 4 | -Wno-c++11-long-long \ 5 | -Wno-unused-macros \ 6 | 7 | CFLAGS_WARN_CLANG_3_8 = \ 8 | $(CFLAGS_WARN_CLANG_3_8_UNIQ) \ 9 | -Weverything \ 10 | -Wno-extra-semi \ 11 | -Wno-sign-conversion \ 12 | -Wno-language-extension-token \ 13 | -Wno-global-constructors \ 14 | -Wno-non-virtual-dtor \ 15 | -Wno-switch-enum \ 16 | -Wno-covered-switch-default \ 17 | -Wno-cast-qual \ 18 | -Wno-padded \ 19 | -Wno-exit-time-destructors \ 20 | -Wno-weak-vtables \ 21 | 22 | CFLAGS_WARN_CLANG_12= $(CFLAGS_WARN_CLANG_3_8) \ 23 | -Wno-extra-semi-stmt \ 24 | -Wno-zero-as-null-pointer-constant \ 25 | -Wno-deprecated-dynamic-exception-spec \ 26 | -Wno-c++98-compat-pedantic \ 27 | -Wno-atomic-implicit-seq-cst \ 28 | -Wconversion \ 29 | -Wno-sign-conversion \ 30 | 31 | CFLAGS_WARN_MAC = \ 32 | -Wno-poison-system-directories \ 33 | -Wno-c++11-long-long \ 34 | -Wno-atomic-implicit-seq-cst \ 35 | 36 | 37 | CFLAGS_WARN = $(CFLAGS_WARN_CLANG_12) $(CFLAGS_WARN_MAC) 38 | -------------------------------------------------------------------------------- /src/lzma2201/C/7zBuf2.c: -------------------------------------------------------------------------------- 1 | /* 7zBuf2.c -- Byte Buffer 2 | 2017-04-03 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include 7 | 8 | #include "7zBuf.h" 9 | 10 | void DynBuf_Construct(CDynBuf *p) 11 | { 12 | p->data = 0; 13 | p->size = 0; 14 | p->pos = 0; 15 | } 16 | 17 | void DynBuf_SeekToBeg(CDynBuf *p) 18 | { 19 | p->pos = 0; 20 | } 21 | 22 | int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAllocPtr alloc) 23 | { 24 | if (size > p->size - p->pos) 25 | { 26 | size_t newSize = p->pos + size; 27 | Byte *data; 28 | newSize += newSize / 4; 29 | data = (Byte *)ISzAlloc_Alloc(alloc, newSize); 30 | if (!data) 31 | return 0; 32 | p->size = newSize; 33 | if (p->pos != 0) 34 | memcpy(data, p->data, p->pos); 35 | ISzAlloc_Free(alloc, p->data); 36 | p->data = data; 37 | } 38 | if (size != 0) 39 | { 40 | memcpy(p->data + p->pos, buf, size); 41 | p->pos += size; 42 | } 43 | return 1; 44 | } 45 | 46 | void DynBuf_Free(CDynBuf *p, ISzAllocPtr alloc) 47 | { 48 | ISzAlloc_Free(alloc, p->data); 49 | p->data = 0; 50 | p->size = 0; 51 | p->pos = 0; 52 | } 53 | -------------------------------------------------------------------------------- /src/lzma2201/C/warn_gcc.mak: -------------------------------------------------------------------------------- 1 | CFLAGS_WARN_GCC_4_5 = \ 2 | 3 | CFLAGS_WARN_GCC_6 = \ 4 | -Waddress \ 5 | -Waggressive-loop-optimizations \ 6 | -Wattributes \ 7 | -Wbool-compare \ 8 | -Wcast-align \ 9 | -Wcomment \ 10 | -Wdiv-by-zero \ 11 | -Wduplicated-cond \ 12 | -Wformat-contains-nul \ 13 | -Winit-self \ 14 | -Wint-to-pointer-cast \ 15 | -Wunused \ 16 | -Wunused-macros \ 17 | 18 | # -Wno-strict-aliasing 19 | 20 | CFLAGS_WARN_GCC_9 = \ 21 | -Waddress \ 22 | -Waddress-of-packed-member \ 23 | -Waggressive-loop-optimizations \ 24 | -Wattributes \ 25 | -Wbool-compare \ 26 | -Wbool-operation \ 27 | -Wcast-align \ 28 | -Wcast-align=strict \ 29 | -Wcomment \ 30 | -Wdangling-else \ 31 | -Wdiv-by-zero \ 32 | -Wduplicated-branches \ 33 | -Wduplicated-cond \ 34 | -Wformat-contains-nul \ 35 | -Wimplicit-fallthrough=5 \ 36 | -Winit-self \ 37 | -Wint-in-bool-context \ 38 | -Wint-to-pointer-cast \ 39 | -Wunused \ 40 | -Wunused-macros \ 41 | -Wconversion \ 42 | 43 | # -Wno-sign-conversion \ 44 | 45 | CFLAGS_WARN_GCC_PPMD_UNALIGNED = \ 46 | -Wno-strict-aliasing \ 47 | 48 | 49 | CFLAGS_WARN = $(CFLAGS_WARN_GCC_9) \ 50 | 51 | # $(CFLAGS_WARN_GCC_PPMD_UNALIGNED) 52 | -------------------------------------------------------------------------------- /src/lzma2201/C/BraIA64.c: -------------------------------------------------------------------------------- 1 | /* BraIA64.c -- Converter for IA-64 code 2 | 2017-01-26 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "CpuArch.h" 7 | #include "Bra.h" 8 | 9 | SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) 10 | { 11 | SizeT i; 12 | if (size < 16) 13 | return 0; 14 | size -= 16; 15 | i = 0; 16 | do 17 | { 18 | unsigned m = ((UInt32)0x334B0000 >> (data[i] & 0x1E)) & 3; 19 | if (m) 20 | { 21 | m++; 22 | do 23 | { 24 | Byte *p = data + (i + (size_t)m * 5 - 8); 25 | if (((p[3] >> m) & 15) == 5 26 | && (((p[-1] | ((UInt32)p[0] << 8)) >> m) & 0x70) == 0) 27 | { 28 | unsigned raw = GetUi32(p); 29 | unsigned v = raw >> m; 30 | v = (v & 0xFFFFF) | ((v & (1 << 23)) >> 3); 31 | 32 | v <<= 4; 33 | if (encoding) 34 | v += ip + (UInt32)i; 35 | else 36 | v -= ip + (UInt32)i; 37 | v >>= 4; 38 | 39 | v &= 0x1FFFFF; 40 | v += 0x700000; 41 | v &= 0x8FFFFF; 42 | raw &= ~((UInt32)0x8FFFFF << m); 43 | raw |= (v << m); 44 | SetUi32(p, raw); 45 | } 46 | } 47 | while (++m <= 4); 48 | } 49 | i += 16; 50 | } 51 | while (i <= size); 52 | return i; 53 | } 54 | -------------------------------------------------------------------------------- /src/lzma2201/C/Alloc.h: -------------------------------------------------------------------------------- 1 | /* Alloc.h -- Memory allocation functions 2 | 2021-07-13 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __COMMON_ALLOC_H 5 | #define __COMMON_ALLOC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | void *MyAlloc(size_t size); 12 | void MyFree(void *address); 13 | 14 | #ifdef _WIN32 15 | 16 | void SetLargePageSize(void); 17 | 18 | void *MidAlloc(size_t size); 19 | void MidFree(void *address); 20 | void *BigAlloc(size_t size); 21 | void BigFree(void *address); 22 | 23 | #else 24 | 25 | #define MidAlloc(size) MyAlloc(size) 26 | #define MidFree(address) MyFree(address) 27 | #define BigAlloc(size) MyAlloc(size) 28 | #define BigFree(address) MyFree(address) 29 | 30 | #endif 31 | 32 | extern const ISzAlloc g_Alloc; 33 | 34 | #ifdef _WIN32 35 | extern const ISzAlloc g_BigAlloc; 36 | extern const ISzAlloc g_MidAlloc; 37 | #else 38 | #define g_BigAlloc g_AlignedAlloc 39 | #define g_MidAlloc g_AlignedAlloc 40 | #endif 41 | 42 | extern const ISzAlloc g_AlignedAlloc; 43 | 44 | 45 | typedef struct 46 | { 47 | ISzAlloc vt; 48 | ISzAllocPtr baseAlloc; 49 | unsigned numAlignBits; /* ((1 << numAlignBits) >= sizeof(void *)) */ 50 | size_t offset; /* (offset == (k * sizeof(void *)) && offset < (1 << numAlignBits) */ 51 | } CAlignOffsetAlloc; 52 | 53 | void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p); 54 | 55 | 56 | EXTERN_C_END 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/lzma2201/C/LzmaLib.c: -------------------------------------------------------------------------------- 1 | /* LzmaLib.c -- LZMA library wrapper 2 | 2015-06-13 : Igor Pavlov : Public domain */ 3 | 4 | #include "Alloc.h" 5 | #include "LzmaDec.h" 6 | #include "LzmaEnc.h" 7 | #include "LzmaLib.h" 8 | 9 | MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, 10 | unsigned char *outProps, size_t *outPropsSize, 11 | int level, /* 0 <= level <= 9, default = 5 */ 12 | unsigned dictSize, /* use (1 << N) or (3 << N). 4 KB < dictSize <= 128 MB */ 13 | int lc, /* 0 <= lc <= 8, default = 3 */ 14 | int lp, /* 0 <= lp <= 4, default = 0 */ 15 | int pb, /* 0 <= pb <= 4, default = 2 */ 16 | int fb, /* 5 <= fb <= 273, default = 32 */ 17 | int numThreads /* 1 or 2, default = 2 */ 18 | ) 19 | { 20 | CLzmaEncProps props; 21 | LzmaEncProps_Init(&props); 22 | props.level = level; 23 | props.dictSize = dictSize; 24 | props.lc = lc; 25 | props.lp = lp; 26 | props.pb = pb; 27 | props.fb = fb; 28 | props.numThreads = numThreads; 29 | 30 | return LzmaEncode(dest, destLen, src, srcLen, &props, outProps, outPropsSize, 0, 31 | NULL, &g_Alloc, &g_Alloc); 32 | } 33 | 34 | 35 | MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t *srcLen, 36 | const unsigned char *props, size_t propsSize) 37 | { 38 | ELzmaStatus status; 39 | return LzmaDecode(dest, destLen, src, srcLen, props, (unsigned)propsSize, LZMA_FINISH_ANY, &status, &g_Alloc); 40 | } 41 | -------------------------------------------------------------------------------- /src/lzma2201/C/Lzma86Dec.c: -------------------------------------------------------------------------------- 1 | /* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder 2 | 2016-05-16 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "Lzma86.h" 7 | 8 | #include "Alloc.h" 9 | #include "Bra.h" 10 | #include "LzmaDec.h" 11 | 12 | SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize) 13 | { 14 | unsigned i; 15 | if (srcLen < LZMA86_HEADER_SIZE) 16 | return SZ_ERROR_INPUT_EOF; 17 | *unpackSize = 0; 18 | for (i = 0; i < sizeof(UInt64); i++) 19 | *unpackSize += ((UInt64)src[LZMA86_SIZE_OFFSET + i]) << (8 * i); 20 | return SZ_OK; 21 | } 22 | 23 | SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen) 24 | { 25 | SRes res; 26 | int useFilter; 27 | SizeT inSizePure; 28 | ELzmaStatus status; 29 | 30 | if (*srcLen < LZMA86_HEADER_SIZE) 31 | return SZ_ERROR_INPUT_EOF; 32 | 33 | useFilter = src[0]; 34 | 35 | if (useFilter > 1) 36 | { 37 | *destLen = 0; 38 | return SZ_ERROR_UNSUPPORTED; 39 | } 40 | 41 | inSizePure = *srcLen - LZMA86_HEADER_SIZE; 42 | res = LzmaDecode(dest, destLen, src + LZMA86_HEADER_SIZE, &inSizePure, 43 | src + 1, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc); 44 | *srcLen = inSizePure + LZMA86_HEADER_SIZE; 45 | if (res != SZ_OK) 46 | return res; 47 | if (useFilter == 1) 48 | { 49 | UInt32 x86State; 50 | x86_Convert_Init(x86State); 51 | x86_Convert(dest, *destLen, 0, &x86State, 0); 52 | } 53 | return SZ_OK; 54 | } 55 | -------------------------------------------------------------------------------- /src/page1.cpp: -------------------------------------------------------------------------------- 1 | #include "pages.hpp" 2 | 3 | #include "Manager.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | ///revision 13 | void update_4(); 14 | 15 | ///version 16 | namespace { 17 | Fl_Choice *choice; 18 | void choice_callback(Fl_Button *, void *) 19 | { 20 | Manager::manager.downloadCandidate.version = static_cast(choice->value()); 21 | update_4(); 22 | } 23 | } 24 | 25 | 26 | void page_1() 27 | { 28 | auto *g = new Fl_Group(0, 0, width, height); 29 | 30 | auto *next = new Fl_Button(button_x + png_size, button_y, button_width, button_height, "Next @->"); 31 | next->callback(next_cb); 32 | 33 | auto *back = new Fl_Button(button_x - button_width - 20 + png_size, button_y, 34 | button_width, button_height, "@<- Back"); 35 | back->callback(back_cb); 36 | 37 | auto *out = new Fl_Box(20 + png_size, 100, 25, 25, " Select a version"); 38 | out->labelsize(50); 39 | out->align(FL_ALIGN_TOP | FL_ALIGN_LEFT); 40 | 41 | const std::vector& versions = Manager::manager.getVersions(); 42 | 43 | choice = new Fl_Choice(200 + png_size, 150, 15 * 12, 45); 44 | 45 | for(auto &version : versions) 46 | choice->add(version.c_str()); 47 | 48 | choice->value(0); 49 | choice->textsize(20); 50 | choice->callback((Fl_Callback *) choice_callback); 51 | 52 | Manager::logo(); 53 | 54 | g->end(); 55 | } 56 | -------------------------------------------------------------------------------- /src/DownloadButton.cpp: -------------------------------------------------------------------------------- 1 | #include "DownloadButton.hpp" 2 | 3 | #include "Manager.hpp" 4 | 5 | namespace DownloadCallbacks { 6 | static void download_stop_cb(Fl_Widget *button, void *); 7 | 8 | static void download_cb(Fl_Widget *button, void *) 9 | { 10 | button->label("Cancel"); 11 | button->callback(download_stop_cb); 12 | Manager::manager.download(); 13 | } 14 | 15 | static void download_stop_cb(Fl_Widget *button, void *) 16 | { 17 | button->label("Download"); 18 | button->callback(download_cb); 19 | Manager::manager.downloadEnd(); 20 | } 21 | 22 | static void extract_stop_cb(Fl_Widget *button, void *); 23 | 24 | static void extract_cb(Fl_Widget *button, void *) { 25 | button->label("Cancel"); 26 | button->callback(extract_stop_cb); 27 | Manager::manager.extract(); 28 | } 29 | 30 | static void extract_stop_cb(Fl_Widget *button, void *) 31 | { 32 | button->label("Extract"); 33 | button->callback(extract_cb); 34 | Manager::manager.extractEnd(); 35 | } 36 | } 37 | 38 | DownloadButton::DownloadButton(int x, int y, int w, int h, const char *label) 39 | : Fl_Button(x, y, w, h, label) 40 | { 41 | Fl_Button::callback(DownloadCallbacks::download_cb); 42 | } 43 | 44 | void DownloadButton::extracting() { DownloadCallbacks::extract_cb(this, nullptr); } 45 | 46 | void DownloadButton::downloading() { DownloadCallbacks::download_stop_cb(this, nullptr); } 47 | 48 | void DownloadButton::download() { DownloadCallbacks::download_cb(this, nullptr); } 49 | -------------------------------------------------------------------------------- /src/page2.cpp: -------------------------------------------------------------------------------- 1 | #include "pages.hpp" 2 | #include "Manager.hpp" 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | ///exceptions realization 13 | void update_5(); 14 | 15 | ///architecture 16 | namespace { 17 | const std::array archs{ 18 | "32 bit\0", 19 | "64 bit\0" 20 | }; 21 | 22 | Fl_Choice *choice; 23 | 24 | void choice_callback(Fl_Button *, void *) { 25 | Manager::manager.downloadCandidate.architecture = choice->value() ? Arcs::x86_64 : Arcs::i686; 26 | update_5(); 27 | } 28 | } 29 | 30 | 31 | void page_2() 32 | { 33 | auto *g = new Fl_Group(0, 0, width, height); 34 | 35 | auto *next = new Fl_Button(button_x+png_size, button_y, button_width, button_height, "Next @->"); 36 | next->callback(next_cb); 37 | 38 | auto *back = new Fl_Button(button_x-button_width-20+png_size, button_y, button_width, button_height, "@<- Back"); 39 | back->callback(back_cb); 40 | 41 | auto *out = new Fl_Box(20+png_size, 100, 25, 25, "Select an architecture"); 42 | out->labelsize(50); 43 | out->align(FL_ALIGN_TOP | FL_ALIGN_LEFT); 44 | 45 | choice = new Fl_Choice(200 + png_size, 150, static_cast(15 * archs[0].size() * 2), 45); 46 | 47 | for(auto &arch : archs) 48 | choice->add(arch.data()); 49 | 50 | choice->value(0); 51 | choice->textsize(20); 52 | choice->callback((Fl_Callback *) choice_callback); 53 | 54 | Manager::logo(); 55 | 56 | g->end(); 57 | } 58 | -------------------------------------------------------------------------------- /src/lzma2201/C/XzEnc.h: -------------------------------------------------------------------------------- 1 | /* XzEnc.h -- Xz Encode 2 | 2017-06-27 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __XZ_ENC_H 5 | #define __XZ_ENC_H 6 | 7 | #include "Lzma2Enc.h" 8 | 9 | #include "Xz.h" 10 | 11 | EXTERN_C_BEGIN 12 | 13 | 14 | #define XZ_PROPS__BLOCK_SIZE__AUTO LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO 15 | #define XZ_PROPS__BLOCK_SIZE__SOLID LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID 16 | 17 | 18 | typedef struct 19 | { 20 | UInt32 id; 21 | UInt32 delta; 22 | UInt32 ip; 23 | int ipDefined; 24 | } CXzFilterProps; 25 | 26 | void XzFilterProps_Init(CXzFilterProps *p); 27 | 28 | 29 | typedef struct 30 | { 31 | CLzma2EncProps lzma2Props; 32 | CXzFilterProps filterProps; 33 | unsigned checkId; 34 | UInt64 blockSize; 35 | int numBlockThreads_Reduced; 36 | int numBlockThreads_Max; 37 | int numTotalThreads; 38 | int forceWriteSizesInHeader; 39 | UInt64 reduceSize; 40 | } CXzProps; 41 | 42 | void XzProps_Init(CXzProps *p); 43 | 44 | 45 | typedef void * CXzEncHandle; 46 | 47 | CXzEncHandle XzEnc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig); 48 | void XzEnc_Destroy(CXzEncHandle p); 49 | SRes XzEnc_SetProps(CXzEncHandle p, const CXzProps *props); 50 | void XzEnc_SetDataSize(CXzEncHandle p, UInt64 expectedDataSiize); 51 | SRes XzEnc_Encode(CXzEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress); 52 | 53 | SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream, 54 | const CXzProps *props, ICompressProgress *progress); 55 | 56 | SRes Xz_EncodeEmpty(ISeqOutStream *outStream); 57 | 58 | EXTERN_C_END 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/lzma2201/C/Compiler.h: -------------------------------------------------------------------------------- 1 | /* Compiler.h 2 | 2021-01-05 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_COMPILER_H 5 | #define __7Z_COMPILER_H 6 | 7 | #ifdef __clang__ 8 | #pragma clang diagnostic ignored "-Wunused-private-field" 9 | #endif 10 | 11 | #ifdef _MSC_VER 12 | 13 | #ifdef UNDER_CE 14 | #define RPC_NO_WINDOWS_H 15 | /* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */ 16 | #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union 17 | #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int 18 | #endif 19 | 20 | #if _MSC_VER >= 1300 21 | #pragma warning(disable : 4996) // This function or variable may be unsafe 22 | #else 23 | #pragma warning(disable : 4511) // copy constructor could not be generated 24 | #pragma warning(disable : 4512) // assignment operator could not be generated 25 | #pragma warning(disable : 4514) // unreferenced inline function has been removed 26 | #pragma warning(disable : 4702) // unreachable code 27 | #pragma warning(disable : 4710) // not inlined 28 | #pragma warning(disable : 4714) // function marked as __forceinline not inlined 29 | #pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information 30 | #endif 31 | 32 | #ifdef __clang__ 33 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" 34 | #pragma clang diagnostic ignored "-Wmicrosoft-exception-spec" 35 | // #pragma clang diagnostic ignored "-Wreserved-id-macro" 36 | #endif 37 | 38 | #endif 39 | 40 | #define UNUSED_VAR(x) (void)x; 41 | /* #define UNUSED_VAR(x) x=x; */ 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/lzma2201/C/7zVersion.rc: -------------------------------------------------------------------------------- 1 | #define MY_VS_FFI_FILEFLAGSMASK 0x0000003FL 2 | #define MY_VOS_NT_WINDOWS32 0x00040004L 3 | #define MY_VOS_CE_WINDOWS32 0x00050004L 4 | 5 | #define MY_VFT_APP 0x00000001L 6 | #define MY_VFT_DLL 0x00000002L 7 | 8 | // #include 9 | 10 | #ifndef MY_VERSION 11 | #include "7zVersion.h" 12 | #endif 13 | 14 | #define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0 15 | 16 | #ifdef DEBUG 17 | #define DBG_FL VS_FF_DEBUG 18 | #else 19 | #define DBG_FL 0 20 | #endif 21 | 22 | #define MY_VERSION_INFO(fileType, descr, intName, origName) \ 23 | LANGUAGE 9, 1 \ 24 | 1 VERSIONINFO \ 25 | FILEVERSION MY_VER \ 26 | PRODUCTVERSION MY_VER \ 27 | FILEFLAGSMASK MY_VS_FFI_FILEFLAGSMASK \ 28 | FILEFLAGS DBG_FL \ 29 | FILEOS MY_VOS_NT_WINDOWS32 \ 30 | FILETYPE fileType \ 31 | FILESUBTYPE 0x0L \ 32 | BEGIN \ 33 | BLOCK "StringFileInfo" \ 34 | BEGIN \ 35 | BLOCK "040904b0" \ 36 | BEGIN \ 37 | VALUE "CompanyName", "Igor Pavlov" \ 38 | VALUE "FileDescription", descr \ 39 | VALUE "FileVersion", MY_VERSION \ 40 | VALUE "InternalName", intName \ 41 | VALUE "LegalCopyright", MY_COPYRIGHT \ 42 | VALUE "OriginalFilename", origName \ 43 | VALUE "ProductName", "7-Zip" \ 44 | VALUE "ProductVersion", MY_VERSION \ 45 | END \ 46 | END \ 47 | BLOCK "VarFileInfo" \ 48 | BEGIN \ 49 | VALUE "Translation", 0x409, 1200 \ 50 | END \ 51 | END 52 | 53 | #define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(MY_VFT_APP, descr, intName, intName ".exe") 54 | 55 | #define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(MY_VFT_DLL, descr, intName, intName ".dll") 56 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "version.hpp" 2 | 3 | #include "pages.hpp" 4 | 5 | #include "Manager.hpp" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | namespace { 13 | Fl_Window *G_win = nullptr; 14 | Fl_Wizard *G_wiz = nullptr; 15 | } 16 | 17 | 18 | void back_cb(Fl_Widget*,void*) { if(G_wiz) G_wiz->prev(); } 19 | void next_cb(Fl_Widget*,void*) { if(G_wiz) G_wiz->next(); } 20 | void done_cb(Fl_Widget*w,void*) { w->window()->hide(); } 21 | 22 | ///about 23 | void page_about(); 24 | 25 | ///hello 26 | void page_0(); 27 | 28 | ///version 29 | void page_1(); 30 | 31 | ///architecture 32 | void page_2(); 33 | 34 | ///multithreading realization (mrt) 35 | void page_3(); 36 | 37 | ///revision 38 | void page_4(); 39 | 40 | ///exceptions realization 41 | void page_5(); 42 | 43 | ///C runtime 44 | void page_6(); 45 | 46 | ///choose dir 47 | void page_7(); 48 | 49 | ///download 50 | void page_8(); 51 | 52 | int main(int argc, char **argv) try { 53 | if(argc > 1 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "v"))){ 54 | printf("version: %s", MINGW_W64_INSTALLER_VERSION); 55 | return 0; 56 | } 57 | 58 | Fl::scheme("gtk+"); 59 | 60 | G_win = new Fl_Window(400, 300, width, height, "MinGW-W64 Installer"); 61 | G_wiz = new Fl_Wizard(0, 0, width, height); 62 | G_win->icon(Manager::logo(false)); 63 | 64 | page_about(); 65 | page_0(); 66 | page_1(); 67 | page_2(); 68 | page_3(); 69 | page_4(); 70 | page_5(); 71 | page_6(); 72 | page_7(); 73 | page_8(); 74 | 75 | G_wiz->end(); 76 | G_win->end(); 77 | G_win->show(argc, argv); 78 | next_cb(G_wiz, nullptr); 79 | return Fl::run(); 80 | }catch(std::exception& error){ 81 | showError(error.what()); 82 | } 83 | -------------------------------------------------------------------------------- /src/page0.cpp: -------------------------------------------------------------------------------- 1 | #include "pages.hpp" 2 | 3 | #include "Manager.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | ///hello page 11 | void page_0() 12 | { 13 | auto *g = new Fl_Group(0, 0, width, height); 14 | 15 | auto *text = new Fl_Help_View(50 + png_size, 1, 600, 275); 16 | text->value("

Welcome to MinGW-W64 install wizard

" 17 | "

This installer was developed for Windows users of the MinGW-W64 compiler. " 18 | "MinGW-W64 is a native Windows compiler based " 19 | "on the GNU C Compiler.

" 20 | "Unlike MSVC or Intel C++ or any other proprietary compilers, " 21 | "MinGW-W64 is an open source compiler which " 22 | "allows any user to be sure that the compiler generates only " 23 | "the machine code that is the result of compiling the source code " 24 | "written by the user, without any covertly generated machine code.

" 25 | "This is especially important for applications that was designed " 26 | "to ensure the safety of a user in the information space.

"); 27 | text->textsize(15); 28 | 29 | auto *about = new Fl_Button(png_size + 50, 280, button_width, button_height, "About"); 30 | about->callback(back_cb); 31 | 32 | auto *next = new Fl_Button(button_x + png_size, button_y, button_width, button_height, "Next @->"); 33 | next->callback(next_cb); 34 | 35 | auto *back = new Fl_Button(button_x - button_width - 20 + png_size, 280, 36 | button_width, button_height, "Exit"); 37 | back->callback(done_cb); 38 | 39 | Manager::logo(); 40 | 41 | g->end(); 42 | } 43 | -------------------------------------------------------------------------------- /src/lzma2201/C/Lzma2Enc.h: -------------------------------------------------------------------------------- 1 | /* Lzma2Enc.h -- LZMA2 Encoder 2 | 2017-07-27 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA2_ENC_H 5 | #define __LZMA2_ENC_H 6 | 7 | #include "LzmaEnc.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO 0 12 | #define LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID ((UInt64)(Int64)-1) 13 | 14 | typedef struct 15 | { 16 | CLzmaEncProps lzmaProps; 17 | UInt64 blockSize; 18 | int numBlockThreads_Reduced; 19 | int numBlockThreads_Max; 20 | int numTotalThreads; 21 | } CLzma2EncProps; 22 | 23 | void Lzma2EncProps_Init(CLzma2EncProps *p); 24 | void Lzma2EncProps_Normalize(CLzma2EncProps *p); 25 | 26 | /* ---------- CLzmaEnc2Handle Interface ---------- */ 27 | 28 | /* Lzma2Enc_* functions can return the following exit codes: 29 | SRes: 30 | SZ_OK - OK 31 | SZ_ERROR_MEM - Memory allocation error 32 | SZ_ERROR_PARAM - Incorrect paramater in props 33 | SZ_ERROR_WRITE - ISeqOutStream write callback error 34 | SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output 35 | SZ_ERROR_PROGRESS - some break from progress callback 36 | SZ_ERROR_THREAD - error in multithreading functions (only for Mt version) 37 | */ 38 | 39 | typedef void * CLzma2EncHandle; 40 | 41 | CLzma2EncHandle Lzma2Enc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig); 42 | void Lzma2Enc_Destroy(CLzma2EncHandle p); 43 | SRes Lzma2Enc_SetProps(CLzma2EncHandle p, const CLzma2EncProps *props); 44 | void Lzma2Enc_SetDataSize(CLzma2EncHandle p, UInt64 expectedDataSiize); 45 | Byte Lzma2Enc_WriteProperties(CLzma2EncHandle p); 46 | SRes Lzma2Enc_Encode2(CLzma2EncHandle p, 47 | ISeqOutStream *outStream, 48 | Byte *outBuf, size_t *outBufSize, 49 | ISeqInStream *inStream, 50 | const Byte *inData, size_t inDataSize, 51 | ICompressProgress *progress); 52 | 53 | EXTERN_C_END 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/page3.cpp: -------------------------------------------------------------------------------- 1 | #include "pages.hpp" 2 | 3 | #include "Manager.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | void update_6(); 12 | 13 | ///multithreading realization (mrt) 14 | namespace { 15 | const std::array multithreading_realizations{ 16 | "win32\0", 17 | "posix\0", 18 | "mcf\0" 19 | }; 20 | Fl_Choice *choice; 21 | void choice_callback(Fl_Button *, void *) 22 | { 23 | Manager::manager.downloadCandidate.multithreading = 24 | choice->value() == 0 ? MgRs::posix : 25 | (choice->value() == 1 ? MgRs::win32 : 26 | (choice->value() == 2 ? MgRs::mcf : MgRs::error)); 27 | update_6(); 28 | } 29 | } 30 | 31 | 32 | void page_3() 33 | { 34 | auto *g = new Fl_Group(0, 0, width, height); 35 | 36 | auto *next = new Fl_Button(button_x + png_size, button_y, button_width, button_height, "Next @->"); 37 | next->callback(next_cb); 38 | 39 | auto *back = new Fl_Button(button_x - button_width - 20 + png_size, button_y, 40 | button_width, button_height, "@<- Back"); 41 | back->callback(back_cb); 42 | 43 | auto *out = new Fl_Box(20 + png_size, 100, 25, 25, "Select a thread model"); 44 | out->labelsize(50); 45 | out->align(FL_ALIGN_TOP | FL_ALIGN_LEFT); 46 | 47 | choice = new Fl_Choice(200 + png_size, 150, 48 | static_cast(15 * multithreading_realizations[0].size() * 2), 45); 49 | 50 | for (auto i = 0; i < (Manager::manager.areMcf()?2:3); ++i) 51 | choice->add(multithreading_realizations[i].data()); 52 | 53 | choice->value(0); 54 | choice->textsize(20); 55 | choice->callback((Fl_Callback *) choice_callback); 56 | 57 | Manager::logo(); 58 | 59 | g->end(); 60 | } 61 | -------------------------------------------------------------------------------- /src/lzma2201/C/7zAlloc.c: -------------------------------------------------------------------------------- 1 | /* 7zAlloc.c -- Allocation functions 2 | 2017-04-03 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include 7 | 8 | #include "7zAlloc.h" 9 | 10 | /* #define _SZ_ALLOC_DEBUG */ 11 | /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ 12 | 13 | #ifdef _SZ_ALLOC_DEBUG 14 | 15 | #ifdef _WIN32 16 | #include 17 | #endif 18 | 19 | #include 20 | int g_allocCount = 0; 21 | int g_allocCountTemp = 0; 22 | 23 | #endif 24 | 25 | void *SzAlloc(ISzAllocPtr p, size_t size) 26 | { 27 | UNUSED_VAR(p); 28 | if (size == 0) 29 | return 0; 30 | #ifdef _SZ_ALLOC_DEBUG 31 | fprintf(stderr, "\nAlloc %10u bytes; count = %10d", (unsigned)size, g_allocCount); 32 | g_allocCount++; 33 | #endif 34 | return malloc(size); 35 | } 36 | 37 | void SzFree(ISzAllocPtr p, void *address) 38 | { 39 | UNUSED_VAR(p); 40 | #ifdef _SZ_ALLOC_DEBUG 41 | if (address != 0) 42 | { 43 | g_allocCount--; 44 | fprintf(stderr, "\nFree; count = %10d", g_allocCount); 45 | } 46 | #endif 47 | free(address); 48 | } 49 | 50 | void *SzAllocTemp(ISzAllocPtr p, size_t size) 51 | { 52 | UNUSED_VAR(p); 53 | if (size == 0) 54 | return 0; 55 | #ifdef _SZ_ALLOC_DEBUG 56 | fprintf(stderr, "\nAlloc_temp %10u bytes; count = %10d", (unsigned)size, g_allocCountTemp); 57 | g_allocCountTemp++; 58 | #ifdef _WIN32 59 | return HeapAlloc(GetProcessHeap(), 0, size); 60 | #endif 61 | #endif 62 | return malloc(size); 63 | } 64 | 65 | void SzFreeTemp(ISzAllocPtr p, void *address) 66 | { 67 | UNUSED_VAR(p); 68 | #ifdef _SZ_ALLOC_DEBUG 69 | if (address != 0) 70 | { 71 | g_allocCountTemp--; 72 | fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp); 73 | } 74 | #ifdef _WIN32 75 | HeapFree(GetProcessHeap(), 0, address); 76 | return; 77 | #endif 78 | #endif 79 | free(address); 80 | } 81 | -------------------------------------------------------------------------------- /src/page4.cpp: -------------------------------------------------------------------------------- 1 | #include "pages.hpp" 2 | 3 | #include "Manager.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | ///revision 13 | namespace { 14 | Fl_Choice *choice; 15 | void choice_callback(Fl_Button *, void *) { 16 | Manager::manager.downloadCandidate.revision = static_cast( choice->value() ); 17 | } 18 | } 19 | 20 | 21 | void update_4() 22 | { 23 | const std::vector& revs = Manager::manager.getRevsForCandidate(); 24 | choice->clear(); 25 | 26 | for ( auto rev : revs ) 27 | choice->add( ( std::string("rev") + std::to_string(rev) ).c_str() ); 28 | 29 | Manager::manager.downloadCandidate.revision = 0; 30 | choice->value(0); 31 | } 32 | 33 | void update_5(); 34 | 35 | static void update_cb(Fl_Widget*, void*) 36 | { 37 | next_cb(nullptr, nullptr); 38 | update_5(); 39 | if(!Manager::manager.getSjlj()){ 40 | if(!Manager::manager.getCrt()) 41 | next_cb(nullptr, nullptr); 42 | next_cb(nullptr, nullptr); 43 | } 44 | } 45 | 46 | void page_4() 47 | { 48 | auto *g = new Fl_Group(0, 0, width, height); 49 | 50 | auto *next = new Fl_Button(button_x+png_size, button_y, button_width, button_height, "Next @->"); 51 | next->callback(update_cb); 52 | 53 | auto *back = new Fl_Button(button_x - button_width - 20 + png_size, button_y, 54 | button_width, button_height, "@<- Back"); 55 | back->callback(back_cb); 56 | 57 | auto *out = new Fl_Box(20 + png_size, 100, 25, 25, "Select a build revision"); 58 | out->labelsize(50); 59 | out->align(FL_ALIGN_TOP | FL_ALIGN_LEFT); 60 | 61 | choice = new Fl_Choice(200 + png_size, 150, 15 * 8, 45); 62 | 63 | update_4(); 64 | choice->textsize(20); 65 | choice->callback((Fl_Callback *) choice_callback); 66 | 67 | Manager::logo(); 68 | 69 | g->end(); 70 | } 71 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.23) 2 | 3 | project(mingwInstaller) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | 7 | add_executable(${PROJECT_NAME} 8 | src/main.cpp 9 | src/unpack.c 10 | src/DownloadButton.cpp 11 | src/Manager.cpp 12 | 13 | src/page_about.cpp 14 | src/page0.cpp 15 | src/page1.cpp 16 | src/page2.cpp 17 | src/page3.cpp 18 | src/page4.cpp 19 | src/page5.cpp 20 | src/page6.cpp 21 | src/page7.cpp 22 | src/page8.cpp 23 | 24 | src/logo.cpp 25 | src/icon.cpp 26 | src/home.cpp 27 | src/shortcut.cpp 28 | 29 | src/lzma2201/C/Bcj2.c 30 | src/lzma2201/C/Bra.c 31 | src/lzma2201/C/Bra86.c 32 | src/lzma2201/C/BraIA64.c 33 | src/lzma2201/C/BraIA64.c 34 | src/lzma2201/C/CpuArch.c 35 | src/lzma2201/C/Delta.c 36 | src/lzma2201/C/Lzma2Dec.c 37 | src/lzma2201/C/LzmaDec.c 38 | src/lzma2201/C/Ppmd7.c 39 | src/lzma2201/C/Ppmd7Dec.c 40 | src/lzma2201/C/7zCrc.c 41 | src/lzma2201/C/7zCrcOpt.c 42 | src/lzma2201/C/Sha256.c 43 | src/lzma2201/C/Sha256Opt.c 44 | src/lzma2201/C/7zAlloc.c 45 | src/lzma2201/C/7zArcIn.c 46 | src/lzma2201/C/7zBuf.c 47 | src/lzma2201/C/7zBuf2.c 48 | src/lzma2201/C/7zDec.c 49 | src/lzma2201/C/7zFile.c 50 | src/lzma2201/C/7zStream.c 51 | ) 52 | 53 | target_link_libraries(${PROJECT_NAME} PRIVATE fltk fltk_images curl ) 54 | 55 | IF (WIN32) 56 | add_definitions(-DNGHTTP2_STATICLIB -DCURL_STATICLIB -DNO_SSL_DL) 57 | add_link_options(-s) 58 | target_link_libraries(${PROJECT_NAME} PRIVATE 59 | png z nghttp2 ssl crypto psl idn2 ssh2 zstd brotlidec brotlienc brotlicommon 60 | crypt32 ws2_32 wldap32 user32 shell32 comctl32 iconv unistring -s -mwindows -static -OS) 61 | #target_link_libraries(${PROJECT_NAME} PUBLIC -shared) 62 | ENDIF() 63 | -------------------------------------------------------------------------------- /src/lzma2201/C/Sha256.h: -------------------------------------------------------------------------------- 1 | /* Sha256.h -- SHA-256 Hash 2 | 2021-01-01 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_SHA256_H 5 | #define __7Z_SHA256_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define SHA256_NUM_BLOCK_WORDS 16 12 | #define SHA256_NUM_DIGEST_WORDS 8 13 | 14 | #define SHA256_BLOCK_SIZE (SHA256_NUM_BLOCK_WORDS * 4) 15 | #define SHA256_DIGEST_SIZE (SHA256_NUM_DIGEST_WORDS * 4) 16 | 17 | typedef void (MY_FAST_CALL *SHA256_FUNC_UPDATE_BLOCKS)(UInt32 state[8], const Byte *data, size_t numBlocks); 18 | 19 | /* 20 | if (the system supports different SHA256 code implementations) 21 | { 22 | (CSha256::func_UpdateBlocks) will be used 23 | (CSha256::func_UpdateBlocks) can be set by 24 | Sha256_Init() - to default (fastest) 25 | Sha256_SetFunction() - to any algo 26 | } 27 | else 28 | { 29 | (CSha256::func_UpdateBlocks) is ignored. 30 | } 31 | */ 32 | 33 | typedef struct 34 | { 35 | SHA256_FUNC_UPDATE_BLOCKS func_UpdateBlocks; 36 | UInt64 count; 37 | UInt64 __pad_2[2]; 38 | UInt32 state[SHA256_NUM_DIGEST_WORDS]; 39 | 40 | Byte buffer[SHA256_BLOCK_SIZE]; 41 | } CSha256; 42 | 43 | 44 | #define SHA256_ALGO_DEFAULT 0 45 | #define SHA256_ALGO_SW 1 46 | #define SHA256_ALGO_HW 2 47 | 48 | /* 49 | Sha256_SetFunction() 50 | return: 51 | 0 - (algo) value is not supported, and func_UpdateBlocks was not changed 52 | 1 - func_UpdateBlocks was set according (algo) value. 53 | */ 54 | 55 | BoolInt Sha256_SetFunction(CSha256 *p, unsigned algo); 56 | 57 | void Sha256_InitState(CSha256 *p); 58 | void Sha256_Init(CSha256 *p); 59 | void Sha256_Update(CSha256 *p, const Byte *data, size_t size); 60 | void Sha256_Final(CSha256 *p, Byte *digest); 61 | 62 | 63 | 64 | 65 | // void MY_FAST_CALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks); 66 | 67 | /* 68 | call Sha256Prepare() once at program start. 69 | It prepares all supported implementations, and detects the fastest implementation. 70 | */ 71 | 72 | void Sha256Prepare(void); 73 | 74 | EXTERN_C_END 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/lzma2201/C/Bra86.c: -------------------------------------------------------------------------------- 1 | /* Bra86.c -- Converter for x86 code (BCJ) 2 | 2021-02-09 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "Bra.h" 7 | 8 | #define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0) 9 | 10 | SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding) 11 | { 12 | SizeT pos = 0; 13 | UInt32 mask = *state & 7; 14 | if (size < 5) 15 | return 0; 16 | size -= 4; 17 | ip += 5; 18 | 19 | for (;;) 20 | { 21 | Byte *p = data + pos; 22 | const Byte *limit = data + size; 23 | for (; p < limit; p++) 24 | if ((*p & 0xFE) == 0xE8) 25 | break; 26 | 27 | { 28 | SizeT d = (SizeT)(p - data) - pos; 29 | pos = (SizeT)(p - data); 30 | if (p >= limit) 31 | { 32 | *state = (d > 2 ? 0 : mask >> (unsigned)d); 33 | return pos; 34 | } 35 | if (d > 2) 36 | mask = 0; 37 | else 38 | { 39 | mask >>= (unsigned)d; 40 | if (mask != 0 && (mask > 4 || mask == 3 || Test86MSByte(p[(size_t)(mask >> 1) + 1]))) 41 | { 42 | mask = (mask >> 1) | 4; 43 | pos++; 44 | continue; 45 | } 46 | } 47 | } 48 | 49 | if (Test86MSByte(p[4])) 50 | { 51 | UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]); 52 | UInt32 cur = ip + (UInt32)pos; 53 | pos += 5; 54 | if (encoding) 55 | v += cur; 56 | else 57 | v -= cur; 58 | if (mask != 0) 59 | { 60 | unsigned sh = (mask & 6) << 2; 61 | if (Test86MSByte((Byte)(v >> sh))) 62 | { 63 | v ^= (((UInt32)0x100 << sh) - 1); 64 | if (encoding) 65 | v += cur; 66 | else 67 | v -= cur; 68 | } 69 | mask = 0; 70 | } 71 | p[1] = (Byte)v; 72 | p[2] = (Byte)(v >> 8); 73 | p[3] = (Byte)(v >> 16); 74 | p[4] = (Byte)(0 - ((v >> 24) & 1)); 75 | } 76 | else 77 | { 78 | mask = (mask >> 1) | 4; 79 | pos++; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/lzma2201/C/7zFile.h: -------------------------------------------------------------------------------- 1 | /* 7zFile.h -- File IO 2 | 2021-02-15 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_FILE_H 5 | #define __7Z_FILE_H 6 | 7 | #ifdef _WIN32 8 | #define USE_WINDOWS_FILE 9 | // #include 10 | #endif 11 | 12 | #ifdef USE_WINDOWS_FILE 13 | #include 14 | #else 15 | // note: USE_FOPEN mode is limited to 32-bit file size 16 | // #define USE_FOPEN 17 | // #include 18 | #endif 19 | 20 | #include "7zTypes.h" 21 | 22 | EXTERN_C_BEGIN 23 | 24 | /* ---------- File ---------- */ 25 | 26 | typedef struct 27 | { 28 | #ifdef USE_WINDOWS_FILE 29 | HANDLE handle; 30 | #elif defined(USE_FOPEN) 31 | FILE *file; 32 | #else 33 | int fd; 34 | #endif 35 | } CSzFile; 36 | 37 | void File_Construct(CSzFile *p); 38 | #if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) 39 | WRes InFile_Open(CSzFile *p, const char *name); 40 | WRes OutFile_Open(CSzFile *p, const char *name); 41 | #endif 42 | #ifdef USE_WINDOWS_FILE 43 | WRes InFile_OpenW(CSzFile *p, const WCHAR *name); 44 | WRes OutFile_OpenW(CSzFile *p, const WCHAR *name); 45 | #endif 46 | WRes File_Close(CSzFile *p); 47 | 48 | /* reads max(*size, remain file's size) bytes */ 49 | WRes File_Read(CSzFile *p, void *data, size_t *size); 50 | 51 | /* writes *size bytes */ 52 | WRes File_Write(CSzFile *p, const void *data, size_t *size); 53 | 54 | WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin); 55 | WRes File_GetLength(CSzFile *p, UInt64 *length); 56 | 57 | 58 | /* ---------- FileInStream ---------- */ 59 | 60 | typedef struct 61 | { 62 | ISeqInStream vt; 63 | CSzFile file; 64 | WRes wres; 65 | } CFileSeqInStream; 66 | 67 | void FileSeqInStream_CreateVTable(CFileSeqInStream *p); 68 | 69 | 70 | typedef struct 71 | { 72 | ISeekInStream vt; 73 | CSzFile file; 74 | WRes wres; 75 | } CFileInStream; 76 | 77 | void FileInStream_CreateVTable(CFileInStream *p); 78 | 79 | 80 | typedef struct 81 | { 82 | ISeqOutStream vt; 83 | CSzFile file; 84 | WRes wres; 85 | } CFileOutStream; 86 | 87 | void FileOutStream_CreateVTable(CFileOutStream *p); 88 | 89 | EXTERN_C_END 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /src/lzma2201/C/Bra.h: -------------------------------------------------------------------------------- 1 | /* Bra.h -- Branch converters for executables 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __BRA_H 5 | #define __BRA_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | /* 12 | These functions convert relative addresses to absolute addresses 13 | in CALL instructions to increase the compression ratio. 14 | 15 | In: 16 | data - data buffer 17 | size - size of data 18 | ip - current virtual Instruction Pinter (IP) value 19 | state - state variable for x86 converter 20 | encoding - 0 (for decoding), 1 (for encoding) 21 | 22 | Out: 23 | state - state variable for x86 converter 24 | 25 | Returns: 26 | The number of processed bytes. If you call these functions with multiple calls, 27 | you must start next call with first byte after block of processed bytes. 28 | 29 | Type Endian Alignment LookAhead 30 | 31 | x86 little 1 4 32 | ARMT little 2 2 33 | ARM little 4 0 34 | PPC big 4 0 35 | SPARC big 4 0 36 | IA64 little 16 0 37 | 38 | size must be >= Alignment + LookAhead, if it's not last block. 39 | If (size < Alignment + LookAhead), converter returns 0. 40 | 41 | Example: 42 | 43 | UInt32 ip = 0; 44 | for () 45 | { 46 | ; size must be >= Alignment + LookAhead, if it's not last block 47 | SizeT processed = Convert(data, size, ip, 1); 48 | data += processed; 49 | size -= processed; 50 | ip += processed; 51 | } 52 | */ 53 | 54 | #define x86_Convert_Init(state) { state = 0; } 55 | SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding); 56 | SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); 57 | SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); 58 | SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); 59 | SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); 60 | SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); 61 | 62 | EXTERN_C_END 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/lzma2201/C/Aes.h: -------------------------------------------------------------------------------- 1 | /* Aes.h -- AES encryption / decryption 2 | 2018-04-28 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __AES_H 5 | #define __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 (MY_FAST_CALL *AES_SET_KEY_FUNC)(UInt32 *aes, const Byte *key, unsigned keySize); 24 | void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *aes, const Byte *key, unsigned keySize); 25 | void MY_FAST_CALL 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 (MY_FAST_CALL *AES_CODE_FUNC)(UInt32 *ivAes, Byte *data, size_t numBlocks); 33 | 34 | extern AES_CODE_FUNC g_AesCbc_Decode; 35 | #ifndef _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 DECLARE__AES_CODE_FUNC(funcName) \ 45 | void MY_FAST_CALL funcName(UInt32 *ivAes, Byte *data, size_t numBlocks); 46 | 47 | DECLARE__AES_CODE_FUNC (AesCbc_Encode) 48 | DECLARE__AES_CODE_FUNC (AesCbc_Decode) 49 | DECLARE__AES_CODE_FUNC (AesCtr_Code) 50 | 51 | DECLARE__AES_CODE_FUNC (AesCbc_Encode_HW) 52 | DECLARE__AES_CODE_FUNC (AesCbc_Decode_HW) 53 | DECLARE__AES_CODE_FUNC (AesCtr_Code_HW) 54 | 55 | DECLARE__AES_CODE_FUNC (AesCbc_Decode_HW_256) 56 | DECLARE__AES_CODE_FUNC (AesCtr_Code_HW_256) 57 | 58 | EXTERN_C_END 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/lzma2201/C/Xz.c: -------------------------------------------------------------------------------- 1 | /* Xz.c - Xz 2 | 2021-02-09 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "7zCrc.h" 7 | #include "CpuArch.h" 8 | #include "Xz.h" 9 | #include "XzCrc64.h" 10 | 11 | const Byte XZ_SIG[XZ_SIG_SIZE] = { 0xFD, '7', 'z', 'X', 'Z', 0 }; 12 | /* const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE] = { 'Y', 'Z' }; */ 13 | 14 | unsigned Xz_WriteVarInt(Byte *buf, UInt64 v) 15 | { 16 | unsigned i = 0; 17 | do 18 | { 19 | buf[i++] = (Byte)((v & 0x7F) | 0x80); 20 | v >>= 7; 21 | } 22 | while (v != 0); 23 | buf[(size_t)i - 1] &= 0x7F; 24 | return i; 25 | } 26 | 27 | void Xz_Construct(CXzStream *p) 28 | { 29 | p->numBlocks = 0; 30 | p->blocks = NULL; 31 | p->flags = 0; 32 | } 33 | 34 | void Xz_Free(CXzStream *p, ISzAllocPtr alloc) 35 | { 36 | ISzAlloc_Free(alloc, p->blocks); 37 | p->numBlocks = 0; 38 | p->blocks = NULL; 39 | } 40 | 41 | unsigned XzFlags_GetCheckSize(CXzStreamFlags f) 42 | { 43 | unsigned t = XzFlags_GetCheckType(f); 44 | return (t == 0) ? 0 : ((unsigned)4 << ((t - 1) / 3)); 45 | } 46 | 47 | void XzCheck_Init(CXzCheck *p, unsigned mode) 48 | { 49 | p->mode = mode; 50 | switch (mode) 51 | { 52 | case XZ_CHECK_CRC32: p->crc = CRC_INIT_VAL; break; 53 | case XZ_CHECK_CRC64: p->crc64 = CRC64_INIT_VAL; break; 54 | case XZ_CHECK_SHA256: Sha256_Init(&p->sha); break; 55 | } 56 | } 57 | 58 | void XzCheck_Update(CXzCheck *p, const void *data, size_t size) 59 | { 60 | switch (p->mode) 61 | { 62 | case XZ_CHECK_CRC32: p->crc = CrcUpdate(p->crc, data, size); break; 63 | case XZ_CHECK_CRC64: p->crc64 = Crc64Update(p->crc64, data, size); break; 64 | case XZ_CHECK_SHA256: Sha256_Update(&p->sha, (const Byte *)data, size); break; 65 | } 66 | } 67 | 68 | int XzCheck_Final(CXzCheck *p, Byte *digest) 69 | { 70 | switch (p->mode) 71 | { 72 | case XZ_CHECK_CRC32: 73 | SetUi32(digest, CRC_GET_DIGEST(p->crc)); 74 | break; 75 | case XZ_CHECK_CRC64: 76 | { 77 | int i; 78 | UInt64 v = CRC64_GET_DIGEST(p->crc64); 79 | for (i = 0; i < 8; i++, v >>= 8) 80 | digest[i] = (Byte)(v & 0xFF); 81 | break; 82 | } 83 | case XZ_CHECK_SHA256: 84 | Sha256_Final(&p->sha, digest); 85 | break; 86 | default: 87 | return 0; 88 | } 89 | return 1; 90 | } 91 | -------------------------------------------------------------------------------- /src/Debug.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MINGWINSTALLER_DEBUG_HPP 2 | #define MINGWINSTALLER_DEBUG_HPP 3 | 4 | #include 5 | 6 | #include "BuildInfo.hpp" 7 | 8 | #define DEBUG_BUILD_AND_SELECT_INFO 9 | 10 | 11 | struct Manager; 12 | 13 | template 14 | std::ostream& operator<<(std::ostream& out, const SelectInfo& selectInfo) 15 | { 16 | out 17 | << "\nVersion : " << 18 | Manager_T::manager.versions[selectInfo.version] 19 | << "\narchitecture : " << 20 | (selectInfo.architecture == Arcs::i686 21 | ? "i686" : (selectInfo.architecture == Arcs::x86_64 22 | ? "x86_64" : "error")) 23 | << "\nmultithreading : " << 24 | (selectInfo.multithreading == MgRs::win32 25 | ? "win32" : (selectInfo.multithreading == MgRs::posix 26 | ? "posix" : "error")) 27 | << "\nexception : " << 28 | (selectInfo.exception == ExcRs::sjlj 29 | ? "sjlj" : (selectInfo.exception == ExcRs::dwarf 30 | ? "dwarf" : (selectInfo.exception == ExcRs::seh 31 | ? "seh" : "error"))) 32 | << "\nruntime : " << 33 | (selectInfo.runtime == Crt::empty 34 | ? "empty" : (selectInfo.runtime == Crt::msvcrt 35 | ? "msvcrt" : (selectInfo.runtime == Crt::ucrt 36 | ? "ucrt" : "error"))) 37 | << "\nrevision : " << 38 | Manager_T::manager.revs[selectInfo.revision] << '\n'; 39 | return out; 40 | } 41 | 42 | inline std::ostream& operator<<(std::ostream& out, const BuildInfo& buildInfo) 43 | { 44 | out << "\nName : " << buildInfo.name 45 | << "\nVersion : " << buildInfo.version 46 | << "\nDownload : " << buildInfo.download 47 | << "\narchitecture : " << 48 | (buildInfo.architecture == Arcs::i686 49 | ? "i686" : (buildInfo.architecture == Arcs::x86_64 ? "x86_64" : "error")) 50 | << "\nmultithreading : " << 51 | (buildInfo.multithreading == MgRs::win32 52 | ? "win32" : (buildInfo.multithreading == MgRs::posix ? "posix" : "error")) 53 | << "\nexception : " << (buildInfo.exception == ExcRs::sjlj ? "sjlj" : 54 | (buildInfo.exception == ExcRs::dwarf 55 | ? "dwarf" : (buildInfo.exception == ExcRs::seh ? "seh" : "error"))) 56 | << "\nruntime : " << 57 | (buildInfo.runtime == Crt::empty 58 | ? "empty" : (buildInfo.runtime == Crt::msvcrt 59 | ? "msvcrt" : (buildInfo.runtime == Crt::ucrt 60 | ? "ucrt" : "error"))) 61 | << "\nrevision : " << buildInfo.revision << '\n'; 62 | return out; 63 | } 64 | 65 | #endif //MINGWINSTALLER_DEBUG_HPP 66 | -------------------------------------------------------------------------------- /src/lzma2201/C/Lzma2DecMt.h: -------------------------------------------------------------------------------- 1 | /* Lzma2DecMt.h -- LZMA2 Decoder Multi-thread 2 | 2018-02-17 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA2_DEC_MT_H 5 | #define __LZMA2_DEC_MT_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | typedef struct 12 | { 13 | size_t inBufSize_ST; 14 | size_t outStep_ST; 15 | 16 | #ifndef _7ZIP_ST 17 | unsigned numThreads; 18 | size_t inBufSize_MT; 19 | size_t outBlockMax; 20 | size_t inBlockMax; 21 | #endif 22 | } CLzma2DecMtProps; 23 | 24 | /* init to single-thread mode */ 25 | void Lzma2DecMtProps_Init(CLzma2DecMtProps *p); 26 | 27 | 28 | /* ---------- CLzma2DecMtHandle Interface ---------- */ 29 | 30 | /* Lzma2DecMt_ * functions can return the following exit codes: 31 | SRes: 32 | SZ_OK - OK 33 | SZ_ERROR_MEM - Memory allocation error 34 | SZ_ERROR_PARAM - Incorrect paramater in props 35 | SZ_ERROR_WRITE - ISeqOutStream write callback error 36 | // SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output 37 | SZ_ERROR_PROGRESS - some break from progress callback 38 | SZ_ERROR_THREAD - error in multithreading functions (only for Mt version) 39 | */ 40 | 41 | typedef void * CLzma2DecMtHandle; 42 | 43 | CLzma2DecMtHandle Lzma2DecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid); 44 | void Lzma2DecMt_Destroy(CLzma2DecMtHandle p); 45 | 46 | SRes Lzma2DecMt_Decode(CLzma2DecMtHandle p, 47 | Byte prop, 48 | const CLzma2DecMtProps *props, 49 | ISeqOutStream *outStream, 50 | const UInt64 *outDataSize, // NULL means undefined 51 | int finishMode, // 0 - partial unpacking is allowed, 1 - if lzma2 stream must be finished 52 | // Byte *outBuf, size_t *outBufSize, 53 | ISeqInStream *inStream, 54 | // const Byte *inData, size_t inDataSize, 55 | 56 | // out variables: 57 | UInt64 *inProcessed, 58 | int *isMT, /* out: (*isMT == 0), if single thread decoding was used */ 59 | 60 | // UInt64 *outProcessed, 61 | ICompressProgress *progress); 62 | 63 | 64 | /* ---------- Read from CLzma2DecMtHandle Interface ---------- */ 65 | 66 | SRes Lzma2DecMt_Init(CLzma2DecMtHandle pp, 67 | Byte prop, 68 | const CLzma2DecMtProps *props, 69 | const UInt64 *outDataSize, int finishMode, 70 | ISeqInStream *inStream); 71 | 72 | SRes Lzma2DecMt_Read(CLzma2DecMtHandle pp, 73 | Byte *data, size_t *outSize, 74 | UInt64 *inStreamProcessed); 75 | 76 | 77 | EXTERN_C_END 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /src/Manager.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MINGWINSTALLER_MANAGER_HPP 2 | #define MINGWINSTALLER_MANAGER_HPP 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "BuildInfo.hpp" 10 | 11 | #ifndef NDEBUG 12 | #include "Debug.hpp" 13 | #endif 14 | 15 | 16 | class Manager final { 17 | explicit Manager() = default; 18 | 19 | public: 20 | static Manager manager; 21 | 22 | SelectInfo downloadCandidate{};///TODO set candidate? 23 | std::string installDir{};///TODO set install dir 24 | void download(); 25 | void downloadEnd(); 26 | void extract(); 27 | void extractEnd(); 28 | [[nodiscard]] int extractCancel() const; 29 | void cancel(); 30 | 31 | static Fl_RGB_Image* logo(bool box = true); 32 | 33 | const std::vector& getVersions(); 34 | const std::vector& getRevsForCandidate(); 35 | bool getSjlj(); 36 | bool getCrt(); 37 | bool getMcf(); 38 | bool areMcf(); 39 | bool desktopShortcut = false; 40 | 41 | private: 42 | #ifdef DEBUG_BUILD_AND_SELECT_INFO 43 | template 44 | friend std::ostream& operator<<(std::ostream& out, const SelectInfo& selectInfo); 45 | #endif 46 | 47 | const std::array headers_strings{ 48 | "Authorization: Bearer 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", 49 | "Accept: application/vnd.github+json" 50 | }; 51 | 52 | std::array folderNames{ 53 | "mingw32\0", 54 | "mingw64\0" 55 | }; 56 | 57 | const BuildInfo& getCandidate(); 58 | const std::vector& getInfo(); 59 | static void fillBuffer(std::vector& buff, const std::string& data); 60 | void sortVersions(); 61 | static BuildInfo parseName(const std::string& name); 62 | static void Timer_CB(void *userdata); 63 | 64 | void unpack(); 65 | void downloading(); 66 | 67 | [[nodiscard]] std::string createBat(); 68 | [[nodiscard]] std::string createIcon(); 69 | 70 | //CURL 71 | void *http_handle = nullptr; 72 | //CURLM 73 | void *multi_handle = nullptr; 74 | 75 | int still_running = 0; 76 | 77 | FILE *dataFile = nullptr; 78 | 79 | std::vector buffer; 80 | std::vector versions{}; 81 | std::vector revs{}; 82 | 83 | enum class Status{ 84 | Empty, 85 | Downloading, 86 | Downloaded, 87 | Extracting, 88 | Done, 89 | Error 90 | } status = Status::Empty; 91 | }; 92 | 93 | 94 | #endif //MINGWINSTALLER_MANAGER_HPP 95 | -------------------------------------------------------------------------------- /src/page5.cpp: -------------------------------------------------------------------------------- 1 | #include "pages.hpp" 2 | 3 | #include "Manager.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | void update_6(); 13 | 14 | ///exceptions realization 15 | namespace { 16 | const std::array exceptions{ 17 | "sjlj\0", 18 | "dwarf\0", 19 | "seh\0" 20 | }; 21 | 22 | bool isDwarf = true; 23 | Fl_Choice *choice; 24 | 25 | void choice_callback(Fl_Button*, void*) 26 | { 27 | Manager::manager.downloadCandidate.exception = 28 | (static_cast(choice->value()) != 0 29 | ? isDwarf 30 | ? ExcRs::dwarf 31 | : ExcRs::seh 32 | : ExcRs::sjlj); 33 | } 34 | } 35 | 36 | static void update_cb(Fl_Widget*, void *) 37 | { 38 | next_cb(nullptr, nullptr); 39 | if(!Manager::manager.getCrt()) 40 | next_cb(nullptr, nullptr); 41 | update_6(); 42 | } 43 | 44 | void update_5() 45 | { 46 | Manager::manager.downloadCandidate.exception = ExcRs::sjlj; 47 | 48 | auto res_page2 = static_cast(Manager::manager.downloadCandidate.architecture); 49 | isDwarf = !res_page2; 50 | 51 | if(!Manager::manager.getSjlj()){ 52 | Manager::manager.downloadCandidate.exception = isDwarf ? ExcRs::dwarf : ExcRs::seh; 53 | update_6(); 54 | return; 55 | } 56 | 57 | choice->clear(); 58 | choice->add(exceptions[0].data()); 59 | choice->add(exceptions[res_page2 + 1].data()); 60 | choice->value(0); 61 | } 62 | 63 | void page_5() 64 | { 65 | auto *g = new Fl_Group(0, 0, width, height); 66 | 67 | auto *next = new Fl_Button(button_x+png_size, button_y, button_width, button_height, "Next @->"); 68 | next->callback(update_cb); 69 | 70 | auto *back = new Fl_Button(button_x - button_width - 20 + png_size, button_y, 71 | button_width, button_height, "@<- Back"); 72 | back->callback(back_cb); 73 | 74 | auto *out = new Fl_Box(20 + png_size, 100, 25, 25, "Select an exceptions"); 75 | out->labelsize(50); 76 | out->align(FL_ALIGN_TOP | FL_ALIGN_LEFT); 77 | 78 | choice = new Fl_Choice(200 + png_size, 150, static_cast(15 * exceptions[0].size() * 2), 45); 79 | 80 | choice->add(exceptions[0].data()); 81 | choice->add(exceptions[1].data()); 82 | 83 | choice->value(0); 84 | choice->textsize(20); 85 | choice->callback((Fl_Callback *) choice_callback); 86 | 87 | Manager::logo(); 88 | 89 | g->end(); 90 | } 91 | -------------------------------------------------------------------------------- /src/lzma2201/C/XzCrc64Opt.c: -------------------------------------------------------------------------------- 1 | /* XzCrc64Opt.c -- CRC64 calculation 2 | 2021-02-09 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "CpuArch.h" 7 | 8 | #ifndef MY_CPU_BE 9 | 10 | #define CRC64_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 11 | 12 | UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table); 13 | UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table) 14 | { 15 | const Byte *p = (const Byte *)data; 16 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) 17 | v = CRC64_UPDATE_BYTE_2(v, *p); 18 | for (; size >= 4; size -= 4, p += 4) 19 | { 20 | UInt32 d = (UInt32)v ^ *(const UInt32 *)(const void *)p; 21 | v = (v >> 32) 22 | ^ (table + 0x300)[((d ) & 0xFF)] 23 | ^ (table + 0x200)[((d >> 8) & 0xFF)] 24 | ^ (table + 0x100)[((d >> 16) & 0xFF)] 25 | ^ (table + 0x000)[((d >> 24))]; 26 | } 27 | for (; size > 0; size--, p++) 28 | v = CRC64_UPDATE_BYTE_2(v, *p); 29 | return v; 30 | } 31 | 32 | #endif 33 | 34 | 35 | #ifndef MY_CPU_LE 36 | 37 | #define CRC_UINT64_SWAP(v) \ 38 | ((v >> 56) \ 39 | | ((v >> 40) & ((UInt64)0xFF << 8)) \ 40 | | ((v >> 24) & ((UInt64)0xFF << 16)) \ 41 | | ((v >> 8) & ((UInt64)0xFF << 24)) \ 42 | | ((v << 8) & ((UInt64)0xFF << 32)) \ 43 | | ((v << 24) & ((UInt64)0xFF << 40)) \ 44 | | ((v << 40) & ((UInt64)0xFF << 48)) \ 45 | | ((v << 56))) 46 | 47 | #define CRC64_UPDATE_BYTE_2_BE(crc, b) (table[(Byte)((crc) >> 56) ^ (b)] ^ ((crc) << 8)) 48 | 49 | UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table); 50 | UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table) 51 | { 52 | const Byte *p = (const Byte *)data; 53 | table += 0x100; 54 | v = CRC_UINT64_SWAP(v); 55 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) 56 | v = CRC64_UPDATE_BYTE_2_BE(v, *p); 57 | for (; size >= 4; size -= 4, p += 4) 58 | { 59 | UInt32 d = (UInt32)(v >> 32) ^ *(const UInt32 *)(const void *)p; 60 | v = (v << 32) 61 | ^ (table + 0x000)[((d ) & 0xFF)] 62 | ^ (table + 0x100)[((d >> 8) & 0xFF)] 63 | ^ (table + 0x200)[((d >> 16) & 0xFF)] 64 | ^ (table + 0x300)[((d >> 24))]; 65 | } 66 | for (; size > 0; size--, p++) 67 | v = CRC64_UPDATE_BYTE_2_BE(v, *p); 68 | return CRC_UINT64_SWAP(v); 69 | } 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/page6.cpp: -------------------------------------------------------------------------------- 1 | #include "pages.hpp" 2 | 3 | #include "Manager.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | ///exceptions realization 13 | namespace { 14 | const std::array runtimes{ 15 | "msvcrt\0", 16 | "ucrt\0", 17 | }; 18 | 19 | Fl_Choice *choice; 20 | 21 | void choice_callback(Fl_Button*, void*) 22 | { 23 | Manager::manager.downloadCandidate.runtime = 24 | (static_cast(choice->value()) == 0 25 | ? Crt::msvcrt 26 | : Crt::ucrt); 27 | } 28 | } 29 | 30 | 31 | void update_6() 32 | { 33 | if(Manager::manager.getMcf()){ 34 | Manager::manager.downloadCandidate.runtime = Crt::ucrt; 35 | choice->clear(); 36 | choice->add(runtimes[1].data()); 37 | choice->value(0); 38 | return; 39 | }else{ 40 | choice->clear(); 41 | for(auto &runtime : runtimes) 42 | choice->add(runtime.data()); 43 | choice->value(0); 44 | Manager::manager.downloadCandidate.runtime = Crt::msvcrt; 45 | } 46 | 47 | if(!Manager::manager.getCrt()){ 48 | Manager::manager.downloadCandidate.runtime = Crt::empty; 49 | return; 50 | } 51 | 52 | Manager::manager.downloadCandidate.runtime = Crt::msvcrt; 53 | choice->value(0); 54 | } 55 | 56 | static void update_cb(Fl_Widget*, void*) 57 | { 58 | back_cb(nullptr, nullptr); 59 | if(!Manager::manager.getSjlj()) 60 | back_cb(nullptr, nullptr); 61 | } 62 | 63 | void page_6() 64 | { 65 | auto *g = new Fl_Group(0, 0, width, height); 66 | 67 | auto *next = new Fl_Button(button_x+png_size, button_y, button_width, button_height, "Next @->"); 68 | next->callback(next_cb); 69 | 70 | auto *back = new Fl_Button(button_x - button_width - 20 + png_size, button_y, 71 | button_width, button_height, "@<- Back"); 72 | back->callback(update_cb); 73 | 74 | auto *out = new Fl_Box(20 + png_size, 100, 25, 25, "Select a C runtime"); 75 | out->labelsize(50); 76 | out->align(FL_ALIGN_TOP | FL_ALIGN_LEFT); 77 | 78 | choice = new Fl_Choice(200 + png_size, 150, static_cast(15 * runtimes[0].size() * 2), 45); 79 | 80 | for(auto &runtime : runtimes) 81 | choice->add(runtime.data()); 82 | 83 | choice->value(0); 84 | choice->textsize(20); 85 | choice->callback((Fl_Callback *) choice_callback); 86 | 87 | Manager::logo(); 88 | 89 | g->end(); 90 | } 91 | -------------------------------------------------------------------------------- /src/lzma2201/C/XzCrc64.c: -------------------------------------------------------------------------------- 1 | /* XzCrc64.c -- CRC64 calculation 2 | 2017-05-23 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "XzCrc64.h" 7 | #include "CpuArch.h" 8 | 9 | #define kCrc64Poly UINT64_CONST(0xC96C5795D7870F42) 10 | 11 | #ifdef MY_CPU_LE 12 | #define CRC64_NUM_TABLES 4 13 | #else 14 | #define CRC64_NUM_TABLES 5 15 | #define CRC_UINT64_SWAP(v) \ 16 | ((v >> 56) \ 17 | | ((v >> 40) & ((UInt64)0xFF << 8)) \ 18 | | ((v >> 24) & ((UInt64)0xFF << 16)) \ 19 | | ((v >> 8) & ((UInt64)0xFF << 24)) \ 20 | | ((v << 8) & ((UInt64)0xFF << 32)) \ 21 | | ((v << 24) & ((UInt64)0xFF << 40)) \ 22 | | ((v << 40) & ((UInt64)0xFF << 48)) \ 23 | | ((v << 56))) 24 | 25 | UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table); 26 | #endif 27 | 28 | #ifndef MY_CPU_BE 29 | UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table); 30 | #endif 31 | 32 | typedef UInt64 (MY_FAST_CALL *CRC64_FUNC)(UInt64 v, const void *data, size_t size, const UInt64 *table); 33 | 34 | static CRC64_FUNC g_Crc64Update; 35 | UInt64 g_Crc64Table[256 * CRC64_NUM_TABLES]; 36 | 37 | UInt64 MY_FAST_CALL Crc64Update(UInt64 v, const void *data, size_t size) 38 | { 39 | return g_Crc64Update(v, data, size, g_Crc64Table); 40 | } 41 | 42 | UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size) 43 | { 44 | return g_Crc64Update(CRC64_INIT_VAL, data, size, g_Crc64Table) ^ CRC64_INIT_VAL; 45 | } 46 | 47 | void MY_FAST_CALL Crc64GenerateTable() 48 | { 49 | UInt32 i; 50 | for (i = 0; i < 256; i++) 51 | { 52 | UInt64 r = i; 53 | unsigned j; 54 | for (j = 0; j < 8; j++) 55 | r = (r >> 1) ^ (kCrc64Poly & ((UInt64)0 - (r & 1))); 56 | g_Crc64Table[i] = r; 57 | } 58 | for (i = 256; i < 256 * CRC64_NUM_TABLES; i++) 59 | { 60 | UInt64 r = g_Crc64Table[(size_t)i - 256]; 61 | g_Crc64Table[i] = g_Crc64Table[r & 0xFF] ^ (r >> 8); 62 | } 63 | 64 | #ifdef MY_CPU_LE 65 | 66 | g_Crc64Update = XzCrc64UpdateT4; 67 | 68 | #else 69 | { 70 | #ifndef MY_CPU_BE 71 | UInt32 k = 1; 72 | if (*(const Byte *)&k == 1) 73 | g_Crc64Update = XzCrc64UpdateT4; 74 | else 75 | #endif 76 | { 77 | for (i = 256 * CRC64_NUM_TABLES - 1; i >= 256; i--) 78 | { 79 | UInt64 x = g_Crc64Table[(size_t)i - 256]; 80 | g_Crc64Table[i] = CRC_UINT64_SWAP(x); 81 | } 82 | g_Crc64Update = XzCrc64UpdateT1_BeT4; 83 | } 84 | } 85 | #endif 86 | } 87 | -------------------------------------------------------------------------------- /src/page7.cpp: -------------------------------------------------------------------------------- 1 | #include "pages.hpp" 2 | 3 | #include "Manager.hpp" 4 | 5 | #include "home.hpp" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | ///directory 19 | namespace { 20 | Fl_File_Chooser* fc; 21 | Fl_Multiline_Output *box; 22 | 23 | void choose_callback(Fl_File_Chooser *obj, void *) 24 | { 25 | if(fc->visible()) return; 26 | Manager::manager.installDir = obj->value(); 27 | box->value(Manager::manager.installDir.c_str()); 28 | if(obj != fc) 29 | throw std::runtime_error("choose_callback page0(5.5) "); 30 | delete fc; 31 | fc = nullptr; 32 | } 33 | 34 | void call_back_page_6(Fl_Widget*, void*) 35 | { 36 | if (!fc) { 37 | fc = new Fl_File_Chooser(nullptr, nullptr, 4, nullptr); 38 | fc->callback(choose_callback); 39 | fc->show(); 40 | }else if(!fc->visible()) 41 | fc->show(); 42 | } 43 | 44 | void check_button_cb(Fl_Widget *button, void*) 45 | { 46 | Manager::manager.desktopShortcut = ((Fl_Check_Button*) button)->value(); 47 | printf("\n Manager desctop: %s\n", Manager::manager.desktopShortcut ? "true" : "false"); 48 | } 49 | } 50 | 51 | void auto_download_cb(Fl_Widget*, void*); 52 | 53 | static void update_cb(Fl_Widget*, void*) 54 | { 55 | back_cb(nullptr, nullptr); 56 | if(!Manager::manager.getCrt()) 57 | { 58 | if(!Manager::manager.getSjlj()) 59 | back_cb(nullptr, nullptr); 60 | back_cb(nullptr, nullptr); 61 | } 62 | } 63 | 64 | void page_7() 65 | { 66 | auto *g = new Fl_Group(0, 0, width, height); 67 | 68 | auto *next = new Fl_Button(button_x+png_size, button_y, button_width, button_height, "Process"); 69 | next->callback(auto_download_cb); 70 | 71 | auto *back = new Fl_Button(button_x - button_width - 20 + png_size, button_y, 72 | button_width, button_height, "@<- Back"); 73 | back->callback(update_cb); 74 | 75 | auto *set_dir = new Fl_Button(500 + png_size, 180, 100, 25, "Choose"); 76 | set_dir->callback(call_back_page_6); 77 | 78 | box = new Fl_Multiline_Output(100 + png_size, 150, 500, 25,"Install in: "); 79 | Manager::manager.installDir = home(); 80 | box->value(Manager::manager.installDir.c_str()); 81 | 82 | auto *out = new Fl_Box(20 + png_size, 100, 500, 25, "Select directory for installation"); 83 | out->labelsize(45); 84 | out->align(FL_ALIGN_TOP | FL_ALIGN_LEFT); 85 | 86 | auto check_button = new Fl_Check_Button(100 + png_size, 220, 500, 25,"Create shortcut on Desktop"); 87 | check_button->callback(check_button_cb); 88 | check_button->labelsize(20); 89 | 90 | Manager::logo(); 91 | 92 | g->end(); 93 | } 94 | -------------------------------------------------------------------------------- /src/lzma2201/C/Lzma86Enc.c: -------------------------------------------------------------------------------- 1 | /* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder 2 | 2018-07-04 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include 7 | 8 | #include "Lzma86.h" 9 | 10 | #include "Alloc.h" 11 | #include "Bra.h" 12 | #include "LzmaEnc.h" 13 | 14 | int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, 15 | int level, UInt32 dictSize, int filterMode) 16 | { 17 | size_t outSize2 = *destLen; 18 | Byte *filteredStream; 19 | BoolInt useFilter; 20 | int mainResult = SZ_ERROR_OUTPUT_EOF; 21 | CLzmaEncProps props; 22 | LzmaEncProps_Init(&props); 23 | props.level = level; 24 | props.dictSize = dictSize; 25 | 26 | *destLen = 0; 27 | if (outSize2 < LZMA86_HEADER_SIZE) 28 | return SZ_ERROR_OUTPUT_EOF; 29 | 30 | { 31 | int i; 32 | UInt64 t = srcLen; 33 | for (i = 0; i < 8; i++, t >>= 8) 34 | dest[LZMA86_SIZE_OFFSET + i] = (Byte)t; 35 | } 36 | 37 | filteredStream = 0; 38 | useFilter = (filterMode != SZ_FILTER_NO); 39 | if (useFilter) 40 | { 41 | if (srcLen != 0) 42 | { 43 | filteredStream = (Byte *)MyAlloc(srcLen); 44 | if (filteredStream == 0) 45 | return SZ_ERROR_MEM; 46 | memcpy(filteredStream, src, srcLen); 47 | } 48 | { 49 | UInt32 x86State; 50 | x86_Convert_Init(x86State); 51 | x86_Convert(filteredStream, srcLen, 0, &x86State, 1); 52 | } 53 | } 54 | 55 | { 56 | size_t minSize = 0; 57 | BoolInt bestIsFiltered = False; 58 | 59 | /* passes for SZ_FILTER_AUTO: 60 | 0 - BCJ + LZMA 61 | 1 - LZMA 62 | 2 - BCJ + LZMA agaian, if pass 0 (BCJ + LZMA) is better. 63 | */ 64 | int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1; 65 | 66 | int i; 67 | for (i = 0; i < numPasses; i++) 68 | { 69 | size_t outSizeProcessed = outSize2 - LZMA86_HEADER_SIZE; 70 | size_t outPropsSize = 5; 71 | SRes curRes; 72 | BoolInt curModeIsFiltered = (numPasses > 1 && i == numPasses - 1); 73 | if (curModeIsFiltered && !bestIsFiltered) 74 | break; 75 | if (useFilter && i == 0) 76 | curModeIsFiltered = True; 77 | 78 | curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed, 79 | curModeIsFiltered ? filteredStream : src, srcLen, 80 | &props, dest + 1, &outPropsSize, 0, 81 | NULL, &g_Alloc, &g_Alloc); 82 | 83 | if (curRes != SZ_ERROR_OUTPUT_EOF) 84 | { 85 | if (curRes != SZ_OK) 86 | { 87 | mainResult = curRes; 88 | break; 89 | } 90 | if (outSizeProcessed <= minSize || mainResult != SZ_OK) 91 | { 92 | minSize = outSizeProcessed; 93 | bestIsFiltered = curModeIsFiltered; 94 | mainResult = SZ_OK; 95 | } 96 | } 97 | } 98 | dest[0] = (Byte)(bestIsFiltered ? 1 : 0); 99 | *destLen = LZMA86_HEADER_SIZE + minSize; 100 | } 101 | if (useFilter) 102 | MyFree(filteredStream); 103 | return mainResult; 104 | } 105 | -------------------------------------------------------------------------------- /src/lzma2201/C/DllSecur.c: -------------------------------------------------------------------------------- 1 | /* DllSecur.c -- DLL loading security 2 | 2022-07-15 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #ifdef _WIN32 7 | 8 | #include 9 | 10 | #include "DllSecur.h" 11 | 12 | #ifndef UNDER_CE 13 | 14 | #if defined(__GNUC__) && (__GNUC__ >= 8) 15 | #pragma GCC diagnostic ignored "-Wcast-function-type" 16 | #endif 17 | 18 | typedef BOOL (WINAPI *Func_SetDefaultDllDirectories)(DWORD DirectoryFlags); 19 | 20 | #define MY_LOAD_LIBRARY_SEARCH_USER_DIRS 0x400 21 | #define MY_LOAD_LIBRARY_SEARCH_SYSTEM32 0x800 22 | 23 | static const char * const g_Dlls = 24 | #ifndef _CONSOLE 25 | "UXTHEME\0" 26 | #endif 27 | "USERENV\0" 28 | "SETUPAPI\0" 29 | "APPHELP\0" 30 | "PROPSYS\0" 31 | "DWMAPI\0" 32 | "CRYPTBASE\0" 33 | "OLEACC\0" 34 | "CLBCATQ\0" 35 | "VERSION\0" 36 | ; 37 | 38 | #endif 39 | 40 | // #define MY_CAST_FUNC (void(*)()) 41 | #define MY_CAST_FUNC 42 | 43 | void My_SetDefaultDllDirectories() 44 | { 45 | #ifndef UNDER_CE 46 | 47 | OSVERSIONINFO vi; 48 | vi.dwOSVersionInfoSize = sizeof(vi); 49 | if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0) 50 | { 51 | Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories) 52 | MY_CAST_FUNC GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories"); 53 | if (setDllDirs) 54 | if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS)) 55 | return; 56 | } 57 | 58 | #endif 59 | } 60 | 61 | 62 | void LoadSecurityDlls() 63 | { 64 | #ifndef UNDER_CE 65 | 66 | wchar_t buf[MAX_PATH + 100]; 67 | 68 | { 69 | // at Vista (ver 6.0) : CoCreateInstance(CLSID_ShellLink, ...) doesn't work after SetDefaultDllDirectories() : Check it ??? 70 | OSVERSIONINFO vi; 71 | vi.dwOSVersionInfoSize = sizeof(vi); 72 | if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0) 73 | { 74 | Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories) 75 | MY_CAST_FUNC GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories"); 76 | if (setDllDirs) 77 | if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS)) 78 | return; 79 | } 80 | } 81 | 82 | { 83 | unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2); 84 | if (len == 0 || len > MAX_PATH) 85 | return; 86 | } 87 | { 88 | const char *dll; 89 | unsigned pos = (unsigned)lstrlenW(buf); 90 | 91 | if (buf[pos - 1] != '\\') 92 | buf[pos++] = '\\'; 93 | 94 | for (dll = g_Dlls; dll[0] != 0;) 95 | { 96 | unsigned k = 0; 97 | for (;;) 98 | { 99 | char c = *dll++; 100 | buf[pos + k] = (Byte)c; 101 | k++; 102 | if (c == 0) 103 | break; 104 | } 105 | 106 | lstrcatW(buf, L".dll"); 107 | LoadLibraryExW(buf, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); 108 | } 109 | } 110 | 111 | #endif 112 | } 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /src/lzma2201/C/LzFindMt.h: -------------------------------------------------------------------------------- 1 | /* LzFindMt.h -- multithreaded Match finder for LZ algorithms 2 | 2021-07-12 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZ_FIND_MT_H 5 | #define __LZ_FIND_MT_H 6 | 7 | #include "LzFind.h" 8 | #include "Threads.h" 9 | 10 | EXTERN_C_BEGIN 11 | 12 | typedef struct _CMtSync 13 | { 14 | UInt32 numProcessedBlocks; 15 | CThread thread; 16 | UInt64 affinity; 17 | 18 | BoolInt wasCreated; 19 | BoolInt needStart; 20 | BoolInt csWasInitialized; 21 | BoolInt csWasEntered; 22 | 23 | BoolInt exit; 24 | BoolInt stopWriting; 25 | 26 | CAutoResetEvent canStart; 27 | CAutoResetEvent wasStopped; 28 | CSemaphore freeSemaphore; 29 | CSemaphore filledSemaphore; 30 | CCriticalSection cs; 31 | // UInt32 numBlocks_Sent; 32 | } CMtSync; 33 | 34 | typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances); 35 | 36 | /* kMtCacheLineDummy must be >= size_of_CPU_cache_line */ 37 | #define kMtCacheLineDummy 128 38 | 39 | typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos, 40 | UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc); 41 | 42 | typedef struct _CMatchFinderMt 43 | { 44 | /* LZ */ 45 | const Byte *pointerToCurPos; 46 | UInt32 *btBuf; 47 | const UInt32 *btBufPos; 48 | const UInt32 *btBufPosLimit; 49 | UInt32 lzPos; 50 | UInt32 btNumAvailBytes; 51 | 52 | UInt32 *hash; 53 | UInt32 fixedHashSize; 54 | // UInt32 hash4Mask; 55 | UInt32 historySize; 56 | const UInt32 *crc; 57 | 58 | Mf_Mix_Matches MixMatchesFunc; 59 | UInt32 failure_LZ_BT; // failure in BT transfered to LZ 60 | // UInt32 failure_LZ_LZ; // failure in LZ tables 61 | UInt32 failureBuf[1]; 62 | // UInt32 crc[256]; 63 | 64 | /* LZ + BT */ 65 | CMtSync btSync; 66 | Byte btDummy[kMtCacheLineDummy]; 67 | 68 | /* BT */ 69 | UInt32 *hashBuf; 70 | UInt32 hashBufPos; 71 | UInt32 hashBufPosLimit; 72 | UInt32 hashNumAvail; 73 | UInt32 failure_BT; 74 | 75 | 76 | CLzRef *son; 77 | UInt32 matchMaxLen; 78 | UInt32 numHashBytes; 79 | UInt32 pos; 80 | const Byte *buffer; 81 | UInt32 cyclicBufferPos; 82 | UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ 83 | UInt32 cutValue; 84 | 85 | /* BT + Hash */ 86 | CMtSync hashSync; 87 | /* Byte hashDummy[kMtCacheLineDummy]; */ 88 | 89 | /* Hash */ 90 | Mf_GetHeads GetHeadsFunc; 91 | CMatchFinder *MatchFinder; 92 | // CMatchFinder MatchFinder; 93 | } CMatchFinderMt; 94 | 95 | // only for Mt part 96 | void MatchFinderMt_Construct(CMatchFinderMt *p); 97 | void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAllocPtr alloc); 98 | 99 | SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, 100 | UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAllocPtr alloc); 101 | void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder2 *vTable); 102 | 103 | /* call MatchFinderMt_InitMt() before IMatchFinder::Init() */ 104 | SRes MatchFinderMt_InitMt(CMatchFinderMt *p); 105 | void MatchFinderMt_ReleaseStream(CMatchFinderMt *p); 106 | 107 | EXTERN_C_END 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /src/lzma2201/C/Sort.c: -------------------------------------------------------------------------------- 1 | /* Sort.c -- Sort functions 2 | 2014-04-05 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "Sort.h" 7 | 8 | #define HeapSortDown(p, k, size, temp) \ 9 | { for (;;) { \ 10 | size_t s = (k << 1); \ 11 | if (s > size) break; \ 12 | if (s < size && p[s + 1] > p[s]) s++; \ 13 | if (temp >= p[s]) break; \ 14 | p[k] = p[s]; k = s; \ 15 | } p[k] = temp; } 16 | 17 | void HeapSort(UInt32 *p, size_t size) 18 | { 19 | if (size <= 1) 20 | return; 21 | p--; 22 | { 23 | size_t i = size / 2; 24 | do 25 | { 26 | UInt32 temp = p[i]; 27 | size_t k = i; 28 | HeapSortDown(p, k, size, temp) 29 | } 30 | while (--i != 0); 31 | } 32 | /* 33 | do 34 | { 35 | size_t k = 1; 36 | UInt32 temp = p[size]; 37 | p[size--] = p[1]; 38 | HeapSortDown(p, k, size, temp) 39 | } 40 | while (size > 1); 41 | */ 42 | while (size > 3) 43 | { 44 | UInt32 temp = p[size]; 45 | size_t k = (p[3] > p[2]) ? 3 : 2; 46 | p[size--] = p[1]; 47 | p[1] = p[k]; 48 | HeapSortDown(p, k, size, temp) 49 | } 50 | { 51 | UInt32 temp = p[size]; 52 | p[size] = p[1]; 53 | if (size > 2 && p[2] < temp) 54 | { 55 | p[1] = p[2]; 56 | p[2] = temp; 57 | } 58 | else 59 | p[1] = temp; 60 | } 61 | } 62 | 63 | void HeapSort64(UInt64 *p, size_t size) 64 | { 65 | if (size <= 1) 66 | return; 67 | p--; 68 | { 69 | size_t i = size / 2; 70 | do 71 | { 72 | UInt64 temp = p[i]; 73 | size_t k = i; 74 | HeapSortDown(p, k, size, temp) 75 | } 76 | while (--i != 0); 77 | } 78 | /* 79 | do 80 | { 81 | size_t k = 1; 82 | UInt64 temp = p[size]; 83 | p[size--] = p[1]; 84 | HeapSortDown(p, k, size, temp) 85 | } 86 | while (size > 1); 87 | */ 88 | while (size > 3) 89 | { 90 | UInt64 temp = p[size]; 91 | size_t k = (p[3] > p[2]) ? 3 : 2; 92 | p[size--] = p[1]; 93 | p[1] = p[k]; 94 | HeapSortDown(p, k, size, temp) 95 | } 96 | { 97 | UInt64 temp = p[size]; 98 | p[size] = p[1]; 99 | if (size > 2 && p[2] < temp) 100 | { 101 | p[1] = p[2]; 102 | p[2] = temp; 103 | } 104 | else 105 | p[1] = temp; 106 | } 107 | } 108 | 109 | /* 110 | #define HeapSortRefDown(p, vals, n, size, temp) \ 111 | { size_t k = n; UInt32 val = vals[temp]; for (;;) { \ 112 | size_t s = (k << 1); \ 113 | if (s > size) break; \ 114 | if (s < size && vals[p[s + 1]] > vals[p[s]]) s++; \ 115 | if (val >= vals[p[s]]) break; \ 116 | p[k] = p[s]; k = s; \ 117 | } p[k] = temp; } 118 | 119 | void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size) 120 | { 121 | if (size <= 1) 122 | return; 123 | p--; 124 | { 125 | size_t i = size / 2; 126 | do 127 | { 128 | UInt32 temp = p[i]; 129 | HeapSortRefDown(p, vals, i, size, temp); 130 | } 131 | while (--i != 0); 132 | } 133 | do 134 | { 135 | UInt32 temp = p[size]; 136 | p[size--] = p[1]; 137 | HeapSortRefDown(p, vals, 1, size, temp); 138 | } 139 | while (size > 1); 140 | } 141 | */ 142 | -------------------------------------------------------------------------------- /src/lzma2201/C/LzmaEnc.h: -------------------------------------------------------------------------------- 1 | /* LzmaEnc.h -- LZMA Encoder 2 | 2019-10-30 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA_ENC_H 5 | #define __LZMA_ENC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define LZMA_PROPS_SIZE 5 12 | 13 | typedef struct _CLzmaEncProps 14 | { 15 | int level; /* 0 <= level <= 9 */ 16 | UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version 17 | (1 << 12) <= dictSize <= (3 << 29) for 64-bit version 18 | default = (1 << 24) */ 19 | int lc; /* 0 <= lc <= 8, default = 3 */ 20 | int lp; /* 0 <= lp <= 4, default = 0 */ 21 | int pb; /* 0 <= pb <= 4, default = 2 */ 22 | int algo; /* 0 - fast, 1 - normal, default = 1 */ 23 | int fb; /* 5 <= fb <= 273, default = 32 */ 24 | int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ 25 | int numHashBytes; /* 2, 3 or 4, default = 4 */ 26 | UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ 27 | unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ 28 | int numThreads; /* 1 or 2, default = 2 */ 29 | 30 | UInt64 reduceSize; /* estimated size of data that will be compressed. default = (UInt64)(Int64)-1. 31 | Encoder uses this value to reduce dictionary size */ 32 | 33 | UInt64 affinity; 34 | } CLzmaEncProps; 35 | 36 | void LzmaEncProps_Init(CLzmaEncProps *p); 37 | void LzmaEncProps_Normalize(CLzmaEncProps *p); 38 | UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); 39 | 40 | 41 | /* ---------- CLzmaEncHandle Interface ---------- */ 42 | 43 | /* LzmaEnc* functions can return the following exit codes: 44 | SRes: 45 | SZ_OK - OK 46 | SZ_ERROR_MEM - Memory allocation error 47 | SZ_ERROR_PARAM - Incorrect paramater in props 48 | SZ_ERROR_WRITE - ISeqOutStream write callback error 49 | SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output 50 | SZ_ERROR_PROGRESS - some break from progress callback 51 | SZ_ERROR_THREAD - error in multithreading functions (only for Mt version) 52 | */ 53 | 54 | typedef void * CLzmaEncHandle; 55 | 56 | CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc); 57 | void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig); 58 | 59 | SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); 60 | void LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize); 61 | SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); 62 | unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p); 63 | 64 | SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, 65 | ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); 66 | SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 67 | int writeEndMark, ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); 68 | 69 | 70 | /* ---------- One Call Interface ---------- */ 71 | 72 | SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 73 | const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, 74 | ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); 75 | 76 | EXTERN_C_END 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/page8.cpp: -------------------------------------------------------------------------------- 1 | #include "DownloadButton.hpp" 2 | #include "Manager.hpp" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | ///download 10 | namespace { 11 | Fl_Progress *progress = nullptr; 12 | Fl_Box *out = nullptr; 13 | DownloadButton *download = nullptr; 14 | Fl_Button *back = nullptr; 15 | } 16 | 17 | void auto_download_cb(Fl_Widget* w, void* d) 18 | { 19 | if(download) 20 | download->download(); 21 | else 22 | throw std::runtime_error("download page 6"); 23 | next_cb(w, d); 24 | } 25 | 26 | void auto_extract() 27 | { 28 | if(download) 29 | download->extracting(); 30 | else 31 | throw std::runtime_error("download page 6"); 32 | } 33 | 34 | enum class Page7state{download, downloading, extract, extracting, done, error}; 35 | 36 | void page7_set(Page7state state) 37 | { 38 | if( !out ) throw std::runtime_error("out not defined page 6"); 39 | if(!progress) throw std::runtime_error("progress not defined page 6"); 40 | if(!download) throw std::runtime_error("download not defined page 6"); 41 | 42 | switch (state) { 43 | case Page7state::download: 44 | out->label("Download "); 45 | progress->hide(); 46 | progress->value(0.f); 47 | break; 48 | case Page7state::downloading: 49 | out->label("Downloading... "); 50 | progress->show(); 51 | break; 52 | case Page7state::extract: 53 | out->label("Extract "); 54 | progress->hide(); 55 | progress->value(0.f); 56 | break; 57 | case Page7state::extracting: 58 | out->label("Extracting... "); 59 | progress->show(); 60 | break; 61 | case Page7state::done: 62 | out->label("Done "); 63 | download->callback(done_cb); 64 | download->label("Finish"); 65 | if(back) back->hide(); 66 | else throw std::runtime_error("back not defined page 6"); 67 | break; 68 | case Page7state::error: 69 | throw std::runtime_error("state::error page6"); 70 | } 71 | } 72 | 73 | void progressSet(float rate) 74 | { 75 | if(progress) progress->value(rate); 76 | else throw std::runtime_error("progress not defined page 6"); 77 | } 78 | 79 | static void reset(Fl_Widget *button, void *data) 80 | { 81 | Manager::manager.cancel(); 82 | if(download) download->downloading(); 83 | page7_set(Page7state::download); 84 | back_cb(button, data); 85 | } 86 | 87 | void page_8() 88 | { 89 | auto *g = new Fl_Group(0, 0, width, height); 90 | 91 | download = new DownloadButton(button_x + png_size, button_y, button_width, button_height, "Download"); 92 | 93 | back = new Fl_Button(button_x - button_width - 20 + png_size, button_y, 94 | button_width, button_height, "@<- Back"); 95 | back->callback(reset); 96 | 97 | progress = new Fl_Progress(40 + png_size, 200, 500, 25); 98 | progress->maximum(1); 99 | progress->minimum(0); 100 | progress->hide(); 101 | progress->value(0.f); 102 | 103 | out = new Fl_Box(20 + png_size, 100, 25, 25, "Download"); 104 | out->labelsize(50); 105 | out->align(FL_ALIGN_TOP | FL_ALIGN_LEFT); 106 | 107 | Manager::logo(); 108 | 109 | g->end(); 110 | } 111 | -------------------------------------------------------------------------------- /src/lzma2201/C/MtCoder.h: -------------------------------------------------------------------------------- 1 | /* MtCoder.h -- Multi-thread Coder 2 | 2018-07-04 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __MT_CODER_H 5 | #define __MT_CODER_H 6 | 7 | #include "MtDec.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | /* 12 | if ( defined MTCODER__USE_WRITE_THREAD) : main thread writes all data blocks to output stream 13 | if (not defined MTCODER__USE_WRITE_THREAD) : any coder thread can write data blocks to output stream 14 | */ 15 | /* #define MTCODER__USE_WRITE_THREAD */ 16 | 17 | #ifndef _7ZIP_ST 18 | #define MTCODER__GET_NUM_BLOCKS_FROM_THREADS(numThreads) ((numThreads) + (numThreads) / 8 + 1) 19 | #define MTCODER__THREADS_MAX 64 20 | #define MTCODER__BLOCKS_MAX (MTCODER__GET_NUM_BLOCKS_FROM_THREADS(MTCODER__THREADS_MAX) + 3) 21 | #else 22 | #define MTCODER__THREADS_MAX 1 23 | #define MTCODER__BLOCKS_MAX 1 24 | #endif 25 | 26 | 27 | #ifndef _7ZIP_ST 28 | 29 | 30 | typedef struct 31 | { 32 | ICompressProgress vt; 33 | CMtProgress *mtProgress; 34 | UInt64 inSize; 35 | UInt64 outSize; 36 | } CMtProgressThunk; 37 | 38 | void MtProgressThunk_CreateVTable(CMtProgressThunk *p); 39 | 40 | #define MtProgressThunk_Init(p) { (p)->inSize = 0; (p)->outSize = 0; } 41 | 42 | 43 | struct _CMtCoder; 44 | 45 | 46 | typedef struct 47 | { 48 | struct _CMtCoder *mtCoder; 49 | unsigned index; 50 | int stop; 51 | Byte *inBuf; 52 | 53 | CAutoResetEvent startEvent; 54 | CThread thread; 55 | } CMtCoderThread; 56 | 57 | 58 | typedef struct 59 | { 60 | SRes (*Code)(void *p, unsigned coderIndex, unsigned outBufIndex, 61 | const Byte *src, size_t srcSize, int finished); 62 | SRes (*Write)(void *p, unsigned outBufIndex); 63 | } IMtCoderCallback2; 64 | 65 | 66 | typedef struct 67 | { 68 | SRes res; 69 | unsigned bufIndex; 70 | BoolInt finished; 71 | } CMtCoderBlock; 72 | 73 | 74 | typedef struct _CMtCoder 75 | { 76 | /* input variables */ 77 | 78 | size_t blockSize; /* size of input block */ 79 | unsigned numThreadsMax; 80 | UInt64 expectedDataSize; 81 | 82 | ISeqInStream *inStream; 83 | const Byte *inData; 84 | size_t inDataSize; 85 | 86 | ICompressProgress *progress; 87 | ISzAllocPtr allocBig; 88 | 89 | IMtCoderCallback2 *mtCallback; 90 | void *mtCallbackObject; 91 | 92 | 93 | /* internal variables */ 94 | 95 | size_t allocatedBufsSize; 96 | 97 | CAutoResetEvent readEvent; 98 | CSemaphore blocksSemaphore; 99 | 100 | BoolInt stopReading; 101 | SRes readRes; 102 | 103 | #ifdef MTCODER__USE_WRITE_THREAD 104 | CAutoResetEvent writeEvents[MTCODER__BLOCKS_MAX]; 105 | #else 106 | CAutoResetEvent finishedEvent; 107 | SRes writeRes; 108 | unsigned writeIndex; 109 | Byte ReadyBlocks[MTCODER__BLOCKS_MAX]; 110 | LONG numFinishedThreads; 111 | #endif 112 | 113 | unsigned numStartedThreadsLimit; 114 | unsigned numStartedThreads; 115 | 116 | unsigned numBlocksMax; 117 | unsigned blockIndex; 118 | UInt64 readProcessed; 119 | 120 | CCriticalSection cs; 121 | 122 | unsigned freeBlockHead; 123 | unsigned freeBlockList[MTCODER__BLOCKS_MAX]; 124 | 125 | CMtProgress mtProgress; 126 | CMtCoderBlock blocks[MTCODER__BLOCKS_MAX]; 127 | CMtCoderThread threads[MTCODER__THREADS_MAX]; 128 | } CMtCoder; 129 | 130 | 131 | void MtCoder_Construct(CMtCoder *p); 132 | void MtCoder_Destruct(CMtCoder *p); 133 | SRes MtCoder_Code(CMtCoder *p); 134 | 135 | 136 | #endif 137 | 138 | 139 | EXTERN_C_END 140 | 141 | #endif 142 | -------------------------------------------------------------------------------- /src/lzma2201/C/Lzma86.h: -------------------------------------------------------------------------------- 1 | /* Lzma86.h -- LZMA + x86 (BCJ) Filter 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA86_H 5 | #define __LZMA86_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define LZMA86_SIZE_OFFSET (1 + 5) 12 | #define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8) 13 | 14 | /* 15 | It's an example for LZMA + x86 Filter use. 16 | You can use .lzma86 extension, if you write that stream to file. 17 | .lzma86 header adds one additional byte to standard .lzma header. 18 | .lzma86 header (14 bytes): 19 | Offset Size Description 20 | 0 1 = 0 - no filter, pure LZMA 21 | = 1 - x86 filter + LZMA 22 | 1 1 lc, lp and pb in encoded form 23 | 2 4 dictSize (little endian) 24 | 6 8 uncompressed size (little endian) 25 | 26 | 27 | Lzma86_Encode 28 | ------------- 29 | level - compression level: 0 <= level <= 9, the default value for "level" is 5. 30 | 31 | dictSize - The dictionary size in bytes. The maximum value is 32 | 128 MB = (1 << 27) bytes for 32-bit version 33 | 1 GB = (1 << 30) bytes for 64-bit version 34 | The default value is 16 MB = (1 << 24) bytes, for level = 5. 35 | It's recommended to use the dictionary that is larger than 4 KB and 36 | that can be calculated as (1 << N) or (3 << N) sizes. 37 | For better compression ratio dictSize must be >= inSize. 38 | 39 | filterMode: 40 | SZ_FILTER_NO - no Filter 41 | SZ_FILTER_YES - x86 Filter 42 | SZ_FILTER_AUTO - it tries both alternatives to select best. 43 | Encoder will use 2 or 3 passes: 44 | 2 passes when FILTER_NO provides better compression. 45 | 3 passes when FILTER_YES provides better compression. 46 | 47 | Lzma86Encode allocates Data with MyAlloc functions. 48 | RAM Requirements for compressing: 49 | RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize 50 | filterMode FilterBlockSize 51 | SZ_FILTER_NO 0 52 | SZ_FILTER_YES inSize 53 | SZ_FILTER_AUTO inSize 54 | 55 | 56 | Return code: 57 | SZ_OK - OK 58 | SZ_ERROR_MEM - Memory allocation error 59 | SZ_ERROR_PARAM - Incorrect paramater 60 | SZ_ERROR_OUTPUT_EOF - output buffer overflow 61 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 62 | */ 63 | 64 | enum ESzFilterMode 65 | { 66 | SZ_FILTER_NO, 67 | SZ_FILTER_YES, 68 | SZ_FILTER_AUTO 69 | }; 70 | 71 | SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, 72 | int level, UInt32 dictSize, int filterMode); 73 | 74 | 75 | /* 76 | Lzma86_GetUnpackSize: 77 | In: 78 | src - input data 79 | srcLen - input data size 80 | Out: 81 | unpackSize - size of uncompressed stream 82 | Return code: 83 | SZ_OK - OK 84 | SZ_ERROR_INPUT_EOF - Error in headers 85 | */ 86 | 87 | SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize); 88 | 89 | /* 90 | Lzma86_Decode: 91 | In: 92 | dest - output data 93 | destLen - output data size 94 | src - input data 95 | srcLen - input data size 96 | Out: 97 | destLen - processed output size 98 | srcLen - processed input size 99 | Return code: 100 | SZ_OK - OK 101 | SZ_ERROR_DATA - Data error 102 | SZ_ERROR_MEM - Memory allocation error 103 | SZ_ERROR_UNSUPPORTED - unsupported file 104 | SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer 105 | */ 106 | 107 | SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen); 108 | 109 | EXTERN_C_END 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /src/lzma2201/C/Delta.c: -------------------------------------------------------------------------------- 1 | /* Delta.c -- Delta converter 2 | 2021-02-09 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "Delta.h" 7 | 8 | void Delta_Init(Byte *state) 9 | { 10 | unsigned i; 11 | for (i = 0; i < DELTA_STATE_SIZE; i++) 12 | state[i] = 0; 13 | } 14 | 15 | 16 | void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size) 17 | { 18 | Byte temp[DELTA_STATE_SIZE]; 19 | 20 | if (size == 0) 21 | return; 22 | 23 | { 24 | unsigned i = 0; 25 | do 26 | temp[i] = state[i]; 27 | while (++i != delta); 28 | } 29 | 30 | if (size <= delta) 31 | { 32 | unsigned i = 0, k; 33 | do 34 | { 35 | Byte b = *data; 36 | *data++ = (Byte)(b - temp[i]); 37 | temp[i] = b; 38 | } 39 | while (++i != size); 40 | 41 | k = 0; 42 | 43 | do 44 | { 45 | if (i == delta) 46 | i = 0; 47 | state[k] = temp[i++]; 48 | } 49 | while (++k != delta); 50 | 51 | return; 52 | } 53 | 54 | { 55 | Byte *p = data + size - delta; 56 | { 57 | unsigned i = 0; 58 | do 59 | state[i] = *p++; 60 | while (++i != delta); 61 | } 62 | { 63 | const Byte *lim = data + delta; 64 | ptrdiff_t dif = -(ptrdiff_t)delta; 65 | 66 | if (((ptrdiff_t)size + dif) & 1) 67 | { 68 | --p; *p = (Byte)(*p - p[dif]); 69 | } 70 | 71 | while (p != lim) 72 | { 73 | --p; *p = (Byte)(*p - p[dif]); 74 | --p; *p = (Byte)(*p - p[dif]); 75 | } 76 | 77 | dif = -dif; 78 | 79 | do 80 | { 81 | --p; *p = (Byte)(*p - temp[--dif]); 82 | } 83 | while (dif != 0); 84 | } 85 | } 86 | } 87 | 88 | 89 | void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size) 90 | { 91 | unsigned i; 92 | const Byte *lim; 93 | 94 | if (size == 0) 95 | return; 96 | 97 | i = 0; 98 | lim = data + size; 99 | 100 | if (size <= delta) 101 | { 102 | do 103 | *data = (Byte)(*data + state[i++]); 104 | while (++data != lim); 105 | 106 | for (; delta != i; state++, delta--) 107 | *state = state[i]; 108 | data -= i; 109 | } 110 | else 111 | { 112 | /* 113 | #define B(n) b ## n 114 | #define I(n) Byte B(n) = state[n]; 115 | #define U(n) { B(n) = (Byte)((B(n)) + *data++); data[-1] = (B(n)); } 116 | #define F(n) if (data != lim) { U(n) } 117 | 118 | if (delta == 1) 119 | { 120 | I(0) 121 | if ((lim - data) & 1) { U(0) } 122 | while (data != lim) { U(0) U(0) } 123 | data -= 1; 124 | } 125 | else if (delta == 2) 126 | { 127 | I(0) I(1) 128 | lim -= 1; while (data < lim) { U(0) U(1) } 129 | lim += 1; F(0) 130 | data -= 2; 131 | } 132 | else if (delta == 3) 133 | { 134 | I(0) I(1) I(2) 135 | lim -= 2; while (data < lim) { U(0) U(1) U(2) } 136 | lim += 2; F(0) F(1) 137 | data -= 3; 138 | } 139 | else if (delta == 4) 140 | { 141 | I(0) I(1) I(2) I(3) 142 | lim -= 3; while (data < lim) { U(0) U(1) U(2) U(3) } 143 | lim += 3; F(0) F(1) F(2) 144 | data -= 4; 145 | } 146 | else 147 | */ 148 | { 149 | do 150 | { 151 | *data = (Byte)(*data + state[i++]); 152 | data++; 153 | } 154 | while (i != delta); 155 | 156 | { 157 | ptrdiff_t dif = -(ptrdiff_t)delta; 158 | do 159 | *data = (Byte)(*data + data[dif]); 160 | while (++data != lim); 161 | data += dif; 162 | } 163 | } 164 | } 165 | 166 | do 167 | *state++ = *data; 168 | while (++data != lim); 169 | } 170 | -------------------------------------------------------------------------------- /src/lzma2201/C/Bcj2.h: -------------------------------------------------------------------------------- 1 | /* Bcj2.h -- BCJ2 Converter for x86 code 2 | 2014-11-10 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __BCJ2_H 5 | #define __BCJ2_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define BCJ2_NUM_STREAMS 4 12 | 13 | enum 14 | { 15 | BCJ2_STREAM_MAIN, 16 | BCJ2_STREAM_CALL, 17 | BCJ2_STREAM_JUMP, 18 | BCJ2_STREAM_RC 19 | }; 20 | 21 | enum 22 | { 23 | BCJ2_DEC_STATE_ORIG_0 = BCJ2_NUM_STREAMS, 24 | BCJ2_DEC_STATE_ORIG_1, 25 | BCJ2_DEC_STATE_ORIG_2, 26 | BCJ2_DEC_STATE_ORIG_3, 27 | 28 | BCJ2_DEC_STATE_ORIG, 29 | BCJ2_DEC_STATE_OK 30 | }; 31 | 32 | enum 33 | { 34 | BCJ2_ENC_STATE_ORIG = BCJ2_NUM_STREAMS, 35 | BCJ2_ENC_STATE_OK 36 | }; 37 | 38 | 39 | #define BCJ2_IS_32BIT_STREAM(s) ((s) == BCJ2_STREAM_CALL || (s) == BCJ2_STREAM_JUMP) 40 | 41 | /* 42 | CBcj2Dec / CBcj2Enc 43 | bufs sizes: 44 | BUF_SIZE(n) = lims[n] - bufs[n] 45 | bufs sizes for BCJ2_STREAM_CALL and BCJ2_STREAM_JUMP must be mutliply of 4: 46 | (BUF_SIZE(BCJ2_STREAM_CALL) & 3) == 0 47 | (BUF_SIZE(BCJ2_STREAM_JUMP) & 3) == 0 48 | */ 49 | 50 | /* 51 | CBcj2Dec: 52 | dest is allowed to overlap with bufs[BCJ2_STREAM_MAIN], with the following conditions: 53 | bufs[BCJ2_STREAM_MAIN] >= dest && 54 | bufs[BCJ2_STREAM_MAIN] - dest >= tempReserv + 55 | BUF_SIZE(BCJ2_STREAM_CALL) + 56 | BUF_SIZE(BCJ2_STREAM_JUMP) 57 | tempReserv = 0 : for first call of Bcj2Dec_Decode 58 | tempReserv = 4 : for any other calls of Bcj2Dec_Decode 59 | overlap with offset = 1 is not allowed 60 | */ 61 | 62 | typedef struct 63 | { 64 | const Byte *bufs[BCJ2_NUM_STREAMS]; 65 | const Byte *lims[BCJ2_NUM_STREAMS]; 66 | Byte *dest; 67 | const Byte *destLim; 68 | 69 | unsigned state; /* BCJ2_STREAM_MAIN has more priority than BCJ2_STATE_ORIG */ 70 | 71 | UInt32 ip; 72 | Byte temp[4]; 73 | UInt32 range; 74 | UInt32 code; 75 | UInt16 probs[2 + 256]; 76 | } CBcj2Dec; 77 | 78 | void Bcj2Dec_Init(CBcj2Dec *p); 79 | 80 | /* Returns: SZ_OK or SZ_ERROR_DATA */ 81 | SRes Bcj2Dec_Decode(CBcj2Dec *p); 82 | 83 | #define Bcj2Dec_IsFinished(_p_) ((_p_)->code == 0) 84 | 85 | 86 | 87 | typedef enum 88 | { 89 | BCJ2_ENC_FINISH_MODE_CONTINUE, 90 | BCJ2_ENC_FINISH_MODE_END_BLOCK, 91 | BCJ2_ENC_FINISH_MODE_END_STREAM 92 | } EBcj2Enc_FinishMode; 93 | 94 | typedef struct 95 | { 96 | Byte *bufs[BCJ2_NUM_STREAMS]; 97 | const Byte *lims[BCJ2_NUM_STREAMS]; 98 | const Byte *src; 99 | const Byte *srcLim; 100 | 101 | unsigned state; 102 | EBcj2Enc_FinishMode finishMode; 103 | 104 | Byte prevByte; 105 | 106 | Byte cache; 107 | UInt32 range; 108 | UInt64 low; 109 | UInt64 cacheSize; 110 | 111 | UInt32 ip; 112 | 113 | /* 32-bit ralative offset in JUMP/CALL commands is 114 | - (mod 4 GB) in 32-bit mode 115 | - signed Int32 in 64-bit mode 116 | We use (mod 4 GB) check for fileSize. 117 | Use fileSize up to 2 GB, if you want to support 32-bit and 64-bit code conversion. */ 118 | UInt32 fileIp; 119 | UInt32 fileSize; /* (fileSize <= ((UInt32)1 << 31)), 0 means no_limit */ 120 | UInt32 relatLimit; /* (relatLimit <= ((UInt32)1 << 31)), 0 means desable_conversion */ 121 | 122 | UInt32 tempTarget; 123 | unsigned tempPos; 124 | Byte temp[4 * 2]; 125 | 126 | unsigned flushPos; 127 | 128 | UInt16 probs[2 + 256]; 129 | } CBcj2Enc; 130 | 131 | void Bcj2Enc_Init(CBcj2Enc *p); 132 | void Bcj2Enc_Encode(CBcj2Enc *p); 133 | 134 | #define Bcj2Enc_Get_InputData_Size(p) ((SizeT)((p)->srcLim - (p)->src) + (p)->tempPos) 135 | #define Bcj2Enc_IsFinished(p) ((p)->flushPos == 5) 136 | 137 | 138 | #define BCJ2_RELAT_LIMIT_NUM_BITS 26 139 | #define BCJ2_RELAT_LIMIT ((UInt32)1 << BCJ2_RELAT_LIMIT_NUM_BITS) 140 | 141 | /* limit for CBcj2Enc::fileSize variable */ 142 | #define BCJ2_FileSize_MAX ((UInt32)1 << 31) 143 | 144 | EXTERN_C_END 145 | 146 | #endif 147 | -------------------------------------------------------------------------------- /src/lzma2201/C/7zCrcOpt.c: -------------------------------------------------------------------------------- 1 | /* 7zCrcOpt.c -- CRC32 calculation 2 | 2021-02-09 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "CpuArch.h" 7 | 8 | #ifndef MY_CPU_BE 9 | 10 | #define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) 11 | 12 | UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table); 13 | UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table) 14 | { 15 | const Byte *p = (const Byte *)data; 16 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) 17 | v = CRC_UPDATE_BYTE_2(v, *p); 18 | for (; size >= 4; size -= 4, p += 4) 19 | { 20 | v ^= *(const UInt32 *)(const void *)p; 21 | v = 22 | (table + 0x300)[((v ) & 0xFF)] 23 | ^ (table + 0x200)[((v >> 8) & 0xFF)] 24 | ^ (table + 0x100)[((v >> 16) & 0xFF)] 25 | ^ (table + 0x000)[((v >> 24))]; 26 | } 27 | for (; size > 0; size--, p++) 28 | v = CRC_UPDATE_BYTE_2(v, *p); 29 | return v; 30 | } 31 | 32 | UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table); 33 | UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table) 34 | { 35 | const Byte *p = (const Byte *)data; 36 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++) 37 | v = CRC_UPDATE_BYTE_2(v, *p); 38 | for (; size >= 8; size -= 8, p += 8) 39 | { 40 | UInt32 d; 41 | v ^= *(const UInt32 *)(const void *)p; 42 | v = 43 | (table + 0x700)[((v ) & 0xFF)] 44 | ^ (table + 0x600)[((v >> 8) & 0xFF)] 45 | ^ (table + 0x500)[((v >> 16) & 0xFF)] 46 | ^ (table + 0x400)[((v >> 24))]; 47 | d = *((const UInt32 *)(const void *)p + 1); 48 | v ^= 49 | (table + 0x300)[((d ) & 0xFF)] 50 | ^ (table + 0x200)[((d >> 8) & 0xFF)] 51 | ^ (table + 0x100)[((d >> 16) & 0xFF)] 52 | ^ (table + 0x000)[((d >> 24))]; 53 | } 54 | for (; size > 0; size--, p++) 55 | v = CRC_UPDATE_BYTE_2(v, *p); 56 | return v; 57 | } 58 | 59 | #endif 60 | 61 | 62 | #ifndef MY_CPU_LE 63 | 64 | #define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24)) 65 | 66 | #define CRC_UPDATE_BYTE_2_BE(crc, b) (table[(((crc) >> 24) ^ (b))] ^ ((crc) << 8)) 67 | 68 | UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table) 69 | { 70 | const Byte *p = (const Byte *)data; 71 | table += 0x100; 72 | v = CRC_UINT32_SWAP(v); 73 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) 74 | v = CRC_UPDATE_BYTE_2_BE(v, *p); 75 | for (; size >= 4; size -= 4, p += 4) 76 | { 77 | v ^= *(const UInt32 *)(const void *)p; 78 | v = 79 | (table + 0x000)[((v ) & 0xFF)] 80 | ^ (table + 0x100)[((v >> 8) & 0xFF)] 81 | ^ (table + 0x200)[((v >> 16) & 0xFF)] 82 | ^ (table + 0x300)[((v >> 24))]; 83 | } 84 | for (; size > 0; size--, p++) 85 | v = CRC_UPDATE_BYTE_2_BE(v, *p); 86 | return CRC_UINT32_SWAP(v); 87 | } 88 | 89 | UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table) 90 | { 91 | const Byte *p = (const Byte *)data; 92 | table += 0x100; 93 | v = CRC_UINT32_SWAP(v); 94 | for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++) 95 | v = CRC_UPDATE_BYTE_2_BE(v, *p); 96 | for (; size >= 8; size -= 8, p += 8) 97 | { 98 | UInt32 d; 99 | v ^= *(const UInt32 *)(const void *)p; 100 | v = 101 | (table + 0x400)[((v ) & 0xFF)] 102 | ^ (table + 0x500)[((v >> 8) & 0xFF)] 103 | ^ (table + 0x600)[((v >> 16) & 0xFF)] 104 | ^ (table + 0x700)[((v >> 24))]; 105 | d = *((const UInt32 *)(const void *)p + 1); 106 | v ^= 107 | (table + 0x000)[((d ) & 0xFF)] 108 | ^ (table + 0x100)[((d >> 8) & 0xFF)] 109 | ^ (table + 0x200)[((d >> 16) & 0xFF)] 110 | ^ (table + 0x300)[((d >> 24))]; 111 | } 112 | for (; size > 0; size--, p++) 113 | v = CRC_UPDATE_BYTE_2_BE(v, *p); 114 | return CRC_UINT32_SWAP(v); 115 | } 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /src/lzma2201/C/Lzma2Dec.h: -------------------------------------------------------------------------------- 1 | /* Lzma2Dec.h -- LZMA2 Decoder 2 | 2018-02-19 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA2_DEC_H 5 | #define __LZMA2_DEC_H 6 | 7 | #include "LzmaDec.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | /* ---------- Page6state 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_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc) 27 | #define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc) 28 | 29 | SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc); 30 | SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc); 31 | void Lzma2Dec_Init(CLzma2Dec *p); 32 | 33 | /* 34 | finishMode: 35 | It has meaning only if the decoding reaches output limit (*destLen or dicLimit). 36 | LZMA_FINISH_ANY - use smallest number of input bytes 37 | LZMA_FINISH_END - read EndOfStream marker after decoding 38 | 39 | Returns: 40 | SZ_OK 41 | status: 42 | LZMA_STATUS_FINISHED_WITH_MARK 43 | LZMA_STATUS_NOT_FINISHED 44 | LZMA_STATUS_NEEDS_MORE_INPUT 45 | SZ_ERROR_DATA - Data error 46 | */ 47 | 48 | SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, 49 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); 50 | 51 | SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, 52 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); 53 | 54 | 55 | /* ---------- LZMA2 block and chunk parsing ---------- */ 56 | 57 | /* 58 | Lzma2Dec_Parse() parses compressed data stream up to next independent block or next chunk data. 59 | It can return LZMA_STATUS_* code or LZMA2_PARSE_STATUS_* code: 60 | - LZMA2_PARSE_STATUS_NEW_BLOCK - there is new block, and 1 additional byte (control byte of next block header) was read from input. 61 | - LZMA2_PARSE_STATUS_NEW_CHUNK - there is new chunk, and only lzma2 header of new chunk was read. 62 | CLzma2Dec::unpackSize contains unpack size of that chunk 63 | */ 64 | 65 | typedef enum 66 | { 67 | /* 68 | LZMA_STATUS_NOT_SPECIFIED // data error 69 | LZMA_STATUS_FINISHED_WITH_MARK 70 | LZMA_STATUS_NOT_FINISHED // 71 | LZMA_STATUS_NEEDS_MORE_INPUT 72 | LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK // unused 73 | */ 74 | LZMA2_PARSE_STATUS_NEW_BLOCK = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK + 1, 75 | LZMA2_PARSE_STATUS_NEW_CHUNK 76 | } ELzma2ParseStatus; 77 | 78 | ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p, 79 | SizeT outSize, // output size 80 | const Byte *src, SizeT *srcLen, 81 | int checkFinishBlock // set (checkFinishBlock = 1), if it must read full input data, if decoder.dicPos reaches blockMax position. 82 | ); 83 | 84 | /* 85 | LZMA2 parser doesn't decode LZMA chunks, so we must read 86 | full input LZMA chunk to decode some part of LZMA chunk. 87 | 88 | Lzma2Dec_GetUnpackExtra() returns the value that shows 89 | max possible number of output bytes that can be output by decoder 90 | at current input positon. 91 | */ 92 | 93 | #define Lzma2Dec_GetUnpackExtra(p) ((p)->isExtraMode ? (p)->unpackSize : 0); 94 | 95 | 96 | /* ---------- One Call Interface ---------- */ 97 | 98 | /* 99 | finishMode: 100 | It has meaning only if the decoding reaches output limit (*destLen). 101 | LZMA_FINISH_ANY - use smallest number of input bytes 102 | LZMA_FINISH_END - read EndOfStream marker after decoding 103 | 104 | Returns: 105 | SZ_OK 106 | status: 107 | LZMA_STATUS_FINISHED_WITH_MARK 108 | LZMA_STATUS_NOT_FINISHED 109 | SZ_ERROR_DATA - Data error 110 | SZ_ERROR_MEM - Memory allocation error 111 | SZ_ERROR_UNSUPPORTED - Unsupported properties 112 | SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). 113 | */ 114 | 115 | SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, 116 | Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAllocPtr alloc); 117 | 118 | EXTERN_C_END 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /src/lzma2201/C/LzFind.h: -------------------------------------------------------------------------------- 1 | /* LzFind.h -- Match finder for LZ algorithms 2 | 2021-07-13 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZ_FIND_H 5 | #define __LZ_FIND_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | typedef UInt32 CLzRef; 12 | 13 | typedef struct _CMatchFinder 14 | { 15 | Byte *buffer; 16 | UInt32 pos; 17 | UInt32 posLimit; 18 | UInt32 streamPos; /* wrap over Zero is allowed (streamPos < pos). Use (UInt32)(streamPos - pos) */ 19 | UInt32 lenLimit; 20 | 21 | UInt32 cyclicBufferPos; 22 | UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ 23 | 24 | Byte streamEndWasReached; 25 | Byte btMode; 26 | Byte bigHash; 27 | Byte directInput; 28 | 29 | UInt32 matchMaxLen; 30 | CLzRef *hash; 31 | CLzRef *son; 32 | UInt32 hashMask; 33 | UInt32 cutValue; 34 | 35 | Byte *bufferBase; 36 | ISeqInStream *stream; 37 | 38 | UInt32 blockSize; 39 | UInt32 keepSizeBefore; 40 | UInt32 keepSizeAfter; 41 | 42 | UInt32 numHashBytes; 43 | size_t directInputRem; 44 | UInt32 historySize; 45 | UInt32 fixedHashSize; 46 | UInt32 hashSizeSum; 47 | SRes result; 48 | UInt32 crc[256]; 49 | size_t numRefs; 50 | 51 | UInt64 expectedDataSize; 52 | } CMatchFinder; 53 | 54 | #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((const Byte *)(p)->buffer) 55 | 56 | #define Inline_MatchFinder_GetNumAvailableBytes(p) ((UInt32)((p)->streamPos - (p)->pos)) 57 | 58 | /* 59 | #define Inline_MatchFinder_IsFinishedOK(p) \ 60 | ((p)->streamEndWasReached \ 61 | && (p)->streamPos == (p)->pos \ 62 | && (!(p)->directInput || (p)->directInputRem == 0)) 63 | */ 64 | 65 | int MatchFinder_NeedMove(CMatchFinder *p); 66 | /* Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); */ 67 | void MatchFinder_MoveBlock(CMatchFinder *p); 68 | void MatchFinder_ReadIfRequired(CMatchFinder *p); 69 | 70 | void MatchFinder_Construct(CMatchFinder *p); 71 | 72 | /* Conditions: 73 | historySize <= 3 GB 74 | keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB 75 | */ 76 | int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, 77 | UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, 78 | ISzAllocPtr alloc); 79 | void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc); 80 | void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems); 81 | // void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); 82 | 83 | /* 84 | #define Inline_MatchFinder_InitPos(p, val) \ 85 | (p)->pos = (val); \ 86 | (p)->streamPos = (val); 87 | */ 88 | 89 | #define Inline_MatchFinder_ReduceOffsets(p, subValue) \ 90 | (p)->pos -= (subValue); \ 91 | (p)->streamPos -= (subValue); 92 | 93 | 94 | UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son, 95 | size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, 96 | UInt32 *distances, UInt32 maxLen); 97 | 98 | /* 99 | Conditions: 100 | Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func. 101 | Mf_GetPointerToCurrentPos_Func's result must be used only before any other function 102 | */ 103 | 104 | typedef void (*Mf_Init_Func)(void *object); 105 | typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object); 106 | typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); 107 | typedef UInt32 * (*Mf_GetMatches_Func)(void *object, UInt32 *distances); 108 | typedef void (*Mf_Skip_Func)(void *object, UInt32); 109 | 110 | typedef struct _IMatchFinder 111 | { 112 | Mf_Init_Func Init; 113 | Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; 114 | Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos; 115 | Mf_GetMatches_Func GetMatches; 116 | Mf_Skip_Func Skip; 117 | } IMatchFinder2; 118 | 119 | void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder2 *vTable); 120 | 121 | void MatchFinder_Init_LowHash(CMatchFinder *p); 122 | void MatchFinder_Init_HighHash(CMatchFinder *p); 123 | void MatchFinder_Init_4(CMatchFinder *p); 124 | void MatchFinder_Init(CMatchFinder *p); 125 | 126 | UInt32* Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); 127 | UInt32* Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); 128 | 129 | void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); 130 | void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); 131 | 132 | void LzFindPrepare(void); 133 | 134 | EXTERN_C_END 135 | 136 | #endif 137 | -------------------------------------------------------------------------------- /src/lzma2201/C/7zStream.c: -------------------------------------------------------------------------------- 1 | /* 7zStream.c -- 7z Stream functions 2 | 2021-02-09 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include 7 | 8 | #include "7zTypes.h" 9 | 10 | SRes SeqInStream_Read2(const ISeqInStream *stream, void *buf, size_t size, SRes errorType) 11 | { 12 | while (size != 0) 13 | { 14 | size_t processed = size; 15 | RINOK(ISeqInStream_Read(stream, buf, &processed)); 16 | if (processed == 0) 17 | return errorType; 18 | buf = (void *)((Byte *)buf + processed); 19 | size -= processed; 20 | } 21 | return SZ_OK; 22 | } 23 | 24 | SRes SeqInStream_Read(const ISeqInStream *stream, void *buf, size_t size) 25 | { 26 | return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); 27 | } 28 | 29 | SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf) 30 | { 31 | size_t processed = 1; 32 | RINOK(ISeqInStream_Read(stream, buf, &processed)); 33 | return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; 34 | } 35 | 36 | 37 | 38 | SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset) 39 | { 40 | Int64 t = (Int64)offset; 41 | return ILookInStream_Seek(stream, &t, SZ_SEEK_SET); 42 | } 43 | 44 | SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size) 45 | { 46 | const void *lookBuf; 47 | if (*size == 0) 48 | return SZ_OK; 49 | RINOK(ILookInStream_Look(stream, &lookBuf, size)); 50 | memcpy(buf, lookBuf, *size); 51 | return ILookInStream_Skip(stream, *size); 52 | } 53 | 54 | SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType) 55 | { 56 | while (size != 0) 57 | { 58 | size_t processed = size; 59 | RINOK(ILookInStream_Read(stream, buf, &processed)); 60 | if (processed == 0) 61 | return errorType; 62 | buf = (void *)((Byte *)buf + processed); 63 | size -= processed; 64 | } 65 | return SZ_OK; 66 | } 67 | 68 | SRes LookInStream_Read(const ILookInStream *stream, void *buf, size_t size) 69 | { 70 | return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); 71 | } 72 | 73 | 74 | 75 | #define GET_LookToRead2 CLookToRead2 *p = CONTAINER_FROM_VTBL(pp, CLookToRead2, vt); 76 | 77 | static SRes LookToRead2_Look_Lookahead(const ILookInStream *pp, const void **buf, size_t *size) 78 | { 79 | SRes res = SZ_OK; 80 | GET_LookToRead2 81 | size_t size2 = p->size - p->pos; 82 | if (size2 == 0 && *size != 0) 83 | { 84 | p->pos = 0; 85 | p->size = 0; 86 | size2 = p->bufSize; 87 | res = ISeekInStream_Read(p->realStream, p->buf, &size2); 88 | p->size = size2; 89 | } 90 | if (*size > size2) 91 | *size = size2; 92 | *buf = p->buf + p->pos; 93 | return res; 94 | } 95 | 96 | static SRes LookToRead2_Look_Exact(const ILookInStream *pp, const void **buf, size_t *size) 97 | { 98 | SRes res = SZ_OK; 99 | GET_LookToRead2 100 | size_t size2 = p->size - p->pos; 101 | if (size2 == 0 && *size != 0) 102 | { 103 | p->pos = 0; 104 | p->size = 0; 105 | if (*size > p->bufSize) 106 | *size = p->bufSize; 107 | res = ISeekInStream_Read(p->realStream, p->buf, size); 108 | size2 = p->size = *size; 109 | } 110 | if (*size > size2) 111 | *size = size2; 112 | *buf = p->buf + p->pos; 113 | return res; 114 | } 115 | 116 | static SRes LookToRead2_Skip(const ILookInStream *pp, size_t offset) 117 | { 118 | GET_LookToRead2 119 | p->pos += offset; 120 | return SZ_OK; 121 | } 122 | 123 | static SRes LookToRead2_Read(const ILookInStream *pp, void *buf, size_t *size) 124 | { 125 | GET_LookToRead2 126 | size_t rem = p->size - p->pos; 127 | if (rem == 0) 128 | return ISeekInStream_Read(p->realStream, buf, size); 129 | if (rem > *size) 130 | rem = *size; 131 | memcpy(buf, p->buf + p->pos, rem); 132 | p->pos += rem; 133 | *size = rem; 134 | return SZ_OK; 135 | } 136 | 137 | static SRes LookToRead2_Seek(const ILookInStream *pp, Int64 *pos, ESzSeek origin) 138 | { 139 | GET_LookToRead2 140 | p->pos = p->size = 0; 141 | return ISeekInStream_Seek(p->realStream, pos, origin); 142 | } 143 | 144 | void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead) 145 | { 146 | p->vt.Look = lookahead ? 147 | LookToRead2_Look_Lookahead : 148 | LookToRead2_Look_Exact; 149 | p->vt.Skip = LookToRead2_Skip; 150 | p->vt.Read = LookToRead2_Read; 151 | p->vt.Seek = LookToRead2_Seek; 152 | } 153 | 154 | 155 | 156 | static SRes SecToLook_Read(const ISeqInStream *pp, void *buf, size_t *size) 157 | { 158 | CSecToLook *p = CONTAINER_FROM_VTBL(pp, CSecToLook, vt); 159 | return LookInStream_LookRead(p->realStream, buf, size); 160 | } 161 | 162 | void SecToLook_CreateVTable(CSecToLook *p) 163 | { 164 | p->vt.Read = SecToLook_Read; 165 | } 166 | 167 | static SRes SecToRead_Read(const ISeqInStream *pp, void *buf, size_t *size) 168 | { 169 | CSecToRead *p = CONTAINER_FROM_VTBL(pp, CSecToRead, vt); 170 | return ILookInStream_Read(p->realStream, buf, size); 171 | } 172 | 173 | void SecToRead_CreateVTable(CSecToRead *p) 174 | { 175 | p->vt.Read = SecToRead_Read; 176 | } 177 | -------------------------------------------------------------------------------- /src/lzma2201/C/LzmaLib.h: -------------------------------------------------------------------------------- 1 | /* LzmaLib.h -- LZMA library interface 2 | 2021-04-03 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA_LIB_H 5 | #define __LZMA_LIB_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define MY_STDAPI int MY_STD_CALL 12 | 13 | #define LZMA_PROPS_SIZE 5 14 | 15 | /* 16 | RAM requirements for LZMA: 17 | for compression: (dictSize * 11.5 + 6 MB) + state_size 18 | for decompression: dictSize + state_size 19 | state_size = (4 + (1.5 << (lc + lp))) KB 20 | by default (lc=3, lp=0), state_size = 16 KB. 21 | 22 | LZMA properties (5 bytes) format 23 | Offset Size Description 24 | 0 1 lc, lp and pb in encoded form. 25 | 1 4 dictSize (little endian). 26 | */ 27 | 28 | /* 29 | LzmaCompress 30 | ------------ 31 | 32 | outPropsSize - 33 | In: the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5. 34 | Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5. 35 | 36 | LZMA Encoder will use defult values for any parameter, if it is 37 | -1 for any from: level, loc, lp, pb, fb, numThreads 38 | 0 for dictSize 39 | 40 | level - compression level: 0 <= level <= 9; 41 | 42 | level dictSize algo fb 43 | 0: 64 KB 0 32 44 | 1: 256 KB 0 32 45 | 2: 1 MB 0 32 46 | 3: 4 MB 0 32 47 | 4: 16 MB 0 32 48 | 5: 16 MB 1 32 49 | 6: 32 MB 1 32 50 | 7: 32 MB 1 64 51 | 8: 64 MB 1 64 52 | 9: 64 MB 1 64 53 | 54 | The default value for "level" is 5. 55 | 56 | algo = 0 means fast method 57 | algo = 1 means normal method 58 | 59 | dictSize - The dictionary size in bytes. The maximum value is 60 | 128 MB = (1 << 27) bytes for 32-bit version 61 | 1 GB = (1 << 30) bytes for 64-bit version 62 | The default value is 16 MB = (1 << 24) bytes. 63 | It's recommended to use the dictionary that is larger than 4 KB and 64 | that can be calculated as (1 << N) or (3 << N) sizes. 65 | 66 | lc - The number of literal context bits (high bits of previous literal). 67 | It can be in the range from 0 to 8. The default value is 3. 68 | Sometimes lc=4 gives the gain for big files. 69 | 70 | lp - The number of literal pos bits (low bits of current position for literals). 71 | It can be in the range from 0 to 4. The default value is 0. 72 | The lp switch is intended for periodical data when the period is equal to 2^lp. 73 | For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's 74 | better to set lc=0, if you change lp switch. 75 | 76 | pb - The number of pos bits (low bits of current position). 77 | It can be in the range from 0 to 4. The default value is 2. 78 | The pb switch is intended for periodical data when the period is equal 2^pb. 79 | 80 | fb - Word size (the number of fast bytes). 81 | It can be in the range from 5 to 273. The default value is 32. 82 | Usually, a big number gives a little bit better compression ratio and 83 | slower compression process. 84 | 85 | numThreads - The number of thereads. 1 or 2. The default value is 2. 86 | Fast mode (algo = 0) can use only 1 thread. 87 | 88 | In: 89 | dest - output data buffer 90 | destLen - output data buffer size 91 | src - input data 92 | srcLen - input data size 93 | Out: 94 | destLen - processed output size 95 | Returns: 96 | SZ_OK - OK 97 | SZ_ERROR_MEM - Memory allocation error 98 | SZ_ERROR_PARAM - Incorrect paramater 99 | SZ_ERROR_OUTPUT_EOF - output buffer overflow 100 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 101 | */ 102 | 103 | MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, 104 | unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */ 105 | int level, /* 0 <= level <= 9, default = 5 */ 106 | unsigned dictSize, /* default = (1 << 24) */ 107 | int lc, /* 0 <= lc <= 8, default = 3 */ 108 | int lp, /* 0 <= lp <= 4, default = 0 */ 109 | int pb, /* 0 <= pb <= 4, default = 2 */ 110 | int fb, /* 5 <= fb <= 273, default = 32 */ 111 | int numThreads /* 1 or 2, default = 2 */ 112 | ); 113 | 114 | /* 115 | LzmaUncompress 116 | -------------- 117 | In: 118 | dest - output data buffer 119 | destLen - output data buffer size 120 | src - input data 121 | srcLen - input data size 122 | Out: 123 | destLen - processed output size 124 | srcLen - processed input size 125 | Returns: 126 | SZ_OK - OK 127 | SZ_ERROR_DATA - Data error 128 | SZ_ERROR_MEM - Memory allocation arror 129 | SZ_ERROR_UNSUPPORTED - Unsupported properties 130 | SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer (src) 131 | */ 132 | 133 | MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen, 134 | const unsigned char *props, size_t propsSize); 135 | 136 | EXTERN_C_END 137 | 138 | #endif 139 | -------------------------------------------------------------------------------- /src/lzma2201/C/Ppmd7.h: -------------------------------------------------------------------------------- 1 | /* Ppmd7.h -- Ppmd7 (PPMdH) compression codec 2 | 2021-04-13 : Igor Pavlov : Public domain 3 | This code is based on: 4 | PPMd var.H (2001): Dmitry Shkarin : Public domain */ 5 | 6 | 7 | #ifndef __PPMD7_H 8 | #define __PPMD7_H 9 | 10 | #include "Ppmd.h" 11 | 12 | EXTERN_C_BEGIN 13 | 14 | #define PPMD7_MIN_ORDER 2 15 | #define PPMD7_MAX_ORDER 64 16 | 17 | #define PPMD7_MIN_MEM_SIZE (1 << 11) 18 | #define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3) 19 | 20 | struct CPpmd7_Context_; 21 | 22 | typedef Ppmd_Ref_Type(struct CPpmd7_Context_) CPpmd7_Context_Ref; 23 | 24 | // MY_CPU_pragma_pack_push_1 25 | 26 | typedef struct CPpmd7_Context_ 27 | { 28 | UInt16 NumStats; 29 | 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 | CPpmd7_Context_Ref Suffix; 44 | } CPpmd7_Context; 45 | 46 | // MY_CPU_pragma_pop 47 | 48 | #define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->Union2) 49 | 50 | 51 | 52 | 53 | typedef struct 54 | { 55 | UInt32 Range; 56 | UInt32 Code; 57 | UInt32 Low; 58 | IByteIn *Stream; 59 | } CPpmd7_RangeDec; 60 | 61 | 62 | typedef struct 63 | { 64 | UInt32 Range; 65 | Byte Cache; 66 | // Byte _dummy_[3]; 67 | UInt64 Low; 68 | UInt64 CacheSize; 69 | IByteOut *Stream; 70 | } CPpmd7z_RangeEnc; 71 | 72 | 73 | typedef struct 74 | { 75 | CPpmd7_Context *MinContext, *MaxContext; 76 | CPpmd_State *FoundState; 77 | unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag; 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 | 86 | 87 | 88 | union 89 | { 90 | CPpmd7_RangeDec dec; 91 | CPpmd7z_RangeEnc enc; 92 | } rc; 93 | 94 | Byte Indx2Units[PPMD_NUM_INDEXES + 2]; // +2 for alignment 95 | Byte Units2Indx[128]; 96 | CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES]; 97 | 98 | Byte NS2BSIndx[256], NS2Indx[256]; 99 | Byte ExpEscape[16]; 100 | CPpmd_See DummySee, See[25][16]; 101 | UInt16 BinSumm[128][64]; 102 | // int LastSymbol; 103 | } CPpmd7; 104 | 105 | 106 | void Ppmd7_Construct(CPpmd7 *p); 107 | BoolInt Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAllocPtr alloc); 108 | void Ppmd7_Free(CPpmd7 *p, ISzAllocPtr alloc); 109 | void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder); 110 | #define Ppmd7_WasAllocated(p) ((p)->Base != NULL) 111 | 112 | 113 | /* ---------- Internal Functions ---------- */ 114 | 115 | #define Ppmd7_GetPtr(p, ptr) Ppmd_GetPtr(p, ptr) 116 | #define Ppmd7_GetContext(p, ptr) Ppmd_GetPtr_Type(p, ptr, CPpmd7_Context) 117 | #define Ppmd7_GetStats(p, ctx) Ppmd_GetPtr_Type(p, (ctx)->Union4.Stats, CPpmd_State) 118 | 119 | void Ppmd7_Update1(CPpmd7 *p); 120 | void Ppmd7_Update1_0(CPpmd7 *p); 121 | void Ppmd7_Update2(CPpmd7 *p); 122 | 123 | #define PPMD7_HiBitsFlag_3(sym) ((((unsigned)sym + 0xC0) >> (8 - 3)) & (1 << 3)) 124 | #define PPMD7_HiBitsFlag_4(sym) ((((unsigned)sym + 0xC0) >> (8 - 4)) & (1 << 4)) 125 | // #define PPMD7_HiBitsFlag_3(sym) ((sym) < 0x40 ? 0 : (1 << 3)) 126 | // #define PPMD7_HiBitsFlag_4(sym) ((sym) < 0x40 ? 0 : (1 << 4)) 127 | 128 | #define Ppmd7_GetBinSumm(p) \ 129 | &p->BinSumm[(size_t)(unsigned)Ppmd7Context_OneState(p->MinContext)->Freq - 1] \ 130 | [ p->PrevSuccess + ((p->RunLength >> 26) & 0x20) \ 131 | + p->NS2BSIndx[(size_t)Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] \ 132 | + PPMD7_HiBitsFlag_4(Ppmd7Context_OneState(p->MinContext)->Symbol) \ 133 | + (p->HiBitsFlag = PPMD7_HiBitsFlag_3(p->FoundState->Symbol)) ] 134 | 135 | CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale); 136 | 137 | 138 | /* 139 | We support two versions of Ppmd7 (PPMdH) methods that use same CPpmd7 structure: 140 | 1) Ppmd7a_*: original PPMdH 141 | 2) Ppmd7z_*: modified PPMdH with 7z Range Coder 142 | Ppmd7_*: the structures and functions that are common for both versions of PPMd7 (PPMdH) 143 | */ 144 | 145 | /* ---------- Decode ---------- */ 146 | 147 | #define PPMD7_SYM_END (-1) 148 | #define PPMD7_SYM_ERROR (-2) 149 | 150 | /* 151 | You must set (CPpmd7::rc.dec.Stream) before Ppmd7*_RangeDec_Init() 152 | 153 | Ppmd7*_DecodeSymbol() 154 | out: 155 | >= 0 : decoded byte 156 | -1 : PPMD7_SYM_END : End of payload marker 157 | -2 : PPMD7_SYM_ERROR : Data error 158 | */ 159 | 160 | /* Ppmd7a_* : original PPMdH */ 161 | BoolInt Ppmd7a_RangeDec_Init(CPpmd7_RangeDec *p); 162 | #define Ppmd7a_RangeDec_IsFinishedOK(p) ((p)->Code == 0) 163 | int Ppmd7a_DecodeSymbol(CPpmd7 *p); 164 | 165 | /* Ppmd7z_* : modified PPMdH with 7z Range Coder */ 166 | BoolInt Ppmd7z_RangeDec_Init(CPpmd7_RangeDec *p); 167 | #define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0) 168 | int Ppmd7z_DecodeSymbol(CPpmd7 *p); 169 | // Byte *Ppmd7z_DecodeSymbols(CPpmd7 *p, Byte *buf, const Byte *lim); 170 | 171 | 172 | /* ---------- Encode ---------- */ 173 | 174 | void Ppmd7z_Init_RangeEnc(CPpmd7 *p); 175 | void Ppmd7z_Flush_RangeEnc(CPpmd7 *p); 176 | // void Ppmd7z_EncodeSymbol(CPpmd7 *p, int symbol); 177 | void Ppmd7z_EncodeSymbols(CPpmd7 *p, const Byte *buf, const Byte *lim); 178 | 179 | EXTERN_C_END 180 | 181 | #endif 182 | -------------------------------------------------------------------------------- /src/lzma2201/C/Bra.c: -------------------------------------------------------------------------------- 1 | /* Bra.c -- Converters for RISC code 2 | 2021-02-09 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "CpuArch.h" 7 | #include "Bra.h" 8 | 9 | SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) 10 | { 11 | Byte *p; 12 | const Byte *lim; 13 | size &= ~(size_t)3; 14 | ip += 4; 15 | p = data; 16 | lim = data + size; 17 | 18 | if (encoding) 19 | 20 | for (;;) 21 | { 22 | for (;;) 23 | { 24 | if (p >= lim) 25 | return (SizeT)(p - data); 26 | p += 4; 27 | if (p[-1] == 0xEB) 28 | break; 29 | } 30 | { 31 | UInt32 v = GetUi32(p - 4); 32 | v <<= 2; 33 | v += ip + (UInt32)(p - data); 34 | v >>= 2; 35 | v &= 0x00FFFFFF; 36 | v |= 0xEB000000; 37 | SetUi32(p - 4, v); 38 | } 39 | } 40 | 41 | for (;;) 42 | { 43 | for (;;) 44 | { 45 | if (p >= lim) 46 | return (SizeT)(p - data); 47 | p += 4; 48 | if (p[-1] == 0xEB) 49 | break; 50 | } 51 | { 52 | UInt32 v = GetUi32(p - 4); 53 | v <<= 2; 54 | v -= ip + (UInt32)(p - data); 55 | v >>= 2; 56 | v &= 0x00FFFFFF; 57 | v |= 0xEB000000; 58 | SetUi32(p - 4, v); 59 | } 60 | } 61 | } 62 | 63 | 64 | SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) 65 | { 66 | Byte *p; 67 | const Byte *lim; 68 | size &= ~(size_t)1; 69 | p = data; 70 | lim = data + size - 4; 71 | 72 | if (encoding) 73 | 74 | for (;;) 75 | { 76 | UInt32 b1; 77 | for (;;) 78 | { 79 | UInt32 b3; 80 | if (p > lim) 81 | return (SizeT)(p - data); 82 | b1 = p[1]; 83 | b3 = p[3]; 84 | p += 2; 85 | b1 ^= 8; 86 | if ((b3 & b1) >= 0xF8) 87 | break; 88 | } 89 | { 90 | UInt32 v = 91 | ((UInt32)b1 << 19) 92 | + (((UInt32)p[1] & 0x7) << 8) 93 | + (((UInt32)p[-2] << 11)) 94 | + (p[0]); 95 | 96 | p += 2; 97 | { 98 | UInt32 cur = (ip + (UInt32)(p - data)) >> 1; 99 | v += cur; 100 | } 101 | 102 | p[-4] = (Byte)(v >> 11); 103 | p[-3] = (Byte)(0xF0 | ((v >> 19) & 0x7)); 104 | p[-2] = (Byte)v; 105 | p[-1] = (Byte)(0xF8 | (v >> 8)); 106 | } 107 | } 108 | 109 | for (;;) 110 | { 111 | UInt32 b1; 112 | for (;;) 113 | { 114 | UInt32 b3; 115 | if (p > lim) 116 | return (SizeT)(p - data); 117 | b1 = p[1]; 118 | b3 = p[3]; 119 | p += 2; 120 | b1 ^= 8; 121 | if ((b3 & b1) >= 0xF8) 122 | break; 123 | } 124 | { 125 | UInt32 v = 126 | ((UInt32)b1 << 19) 127 | + (((UInt32)p[1] & 0x7) << 8) 128 | + (((UInt32)p[-2] << 11)) 129 | + (p[0]); 130 | 131 | p += 2; 132 | { 133 | UInt32 cur = (ip + (UInt32)(p - data)) >> 1; 134 | v -= cur; 135 | } 136 | 137 | /* 138 | SetUi16(p - 4, (UInt16)(((v >> 11) & 0x7FF) | 0xF000)); 139 | SetUi16(p - 2, (UInt16)(v | 0xF800)); 140 | */ 141 | 142 | p[-4] = (Byte)(v >> 11); 143 | p[-3] = (Byte)(0xF0 | ((v >> 19) & 0x7)); 144 | p[-2] = (Byte)v; 145 | p[-1] = (Byte)(0xF8 | (v >> 8)); 146 | } 147 | } 148 | } 149 | 150 | 151 | SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) 152 | { 153 | Byte *p; 154 | const Byte *lim; 155 | size &= ~(size_t)3; 156 | ip -= 4; 157 | p = data; 158 | lim = data + size; 159 | 160 | for (;;) 161 | { 162 | for (;;) 163 | { 164 | if (p >= lim) 165 | return (SizeT)(p - data); 166 | p += 4; 167 | /* if ((v & 0xFC000003) == 0x48000001) */ 168 | if ((p[-4] & 0xFC) == 0x48 && (p[-1] & 3) == 1) 169 | break; 170 | } 171 | { 172 | UInt32 v = GetBe32(p - 4); 173 | if (encoding) 174 | v += ip + (UInt32)(p - data); 175 | else 176 | v -= ip + (UInt32)(p - data); 177 | v &= 0x03FFFFFF; 178 | v |= 0x48000000; 179 | SetBe32(p - 4, v); 180 | } 181 | } 182 | } 183 | 184 | 185 | SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) 186 | { 187 | Byte *p; 188 | const Byte *lim; 189 | size &= ~(size_t)3; 190 | ip -= 4; 191 | p = data; 192 | lim = data + size; 193 | 194 | for (;;) 195 | { 196 | for (;;) 197 | { 198 | if (p >= lim) 199 | return (SizeT)(p - data); 200 | /* 201 | v = GetBe32(p); 202 | p += 4; 203 | m = v + ((UInt32)5 << 29); 204 | m ^= (UInt32)7 << 29; 205 | m += (UInt32)1 << 22; 206 | if ((m & ((UInt32)0x1FF << 23)) == 0) 207 | break; 208 | */ 209 | p += 4; 210 | if ((p[-4] == 0x40 && (p[-3] & 0xC0) == 0) || 211 | (p[-4] == 0x7F && (p[-3] >= 0xC0))) 212 | break; 213 | } 214 | { 215 | UInt32 v = GetBe32(p - 4); 216 | v <<= 2; 217 | if (encoding) 218 | v += ip + (UInt32)(p - data); 219 | else 220 | v -= ip + (UInt32)(p - data); 221 | 222 | v &= 0x01FFFFFF; 223 | v -= (UInt32)1 << 24; 224 | v ^= 0xFF000000; 225 | v >>= 2; 226 | v |= 0x40000000; 227 | SetBe32(p - 4, v); 228 | } 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /src/lzma2201/C/MtDec.h: -------------------------------------------------------------------------------- 1 | /* MtDec.h -- Multi-thread Decoder 2 | 2020-03-05 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __MT_DEC_H 5 | #define __MT_DEC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | #ifndef _7ZIP_ST 10 | #include "Threads.h" 11 | #endif 12 | 13 | EXTERN_C_BEGIN 14 | 15 | #ifndef _7ZIP_ST 16 | 17 | #ifndef _7ZIP_ST 18 | #define MTDEC__THREADS_MAX 32 19 | #else 20 | #define MTDEC__THREADS_MAX 1 21 | #endif 22 | 23 | 24 | typedef struct 25 | { 26 | ICompressProgress *progress; 27 | SRes res; 28 | UInt64 totalInSize; 29 | UInt64 totalOutSize; 30 | CCriticalSection cs; 31 | } CMtProgress; 32 | 33 | void MtProgress_Init(CMtProgress *p, ICompressProgress *progress); 34 | SRes MtProgress_Progress_ST(CMtProgress *p); 35 | SRes MtProgress_ProgressAdd(CMtProgress *p, UInt64 inSize, UInt64 outSize); 36 | SRes MtProgress_GetError(CMtProgress *p); 37 | void MtProgress_SetError(CMtProgress *p, SRes res); 38 | 39 | struct _CMtDec; 40 | 41 | typedef struct 42 | { 43 | struct _CMtDec *mtDec; 44 | unsigned index; 45 | void *inBuf; 46 | 47 | size_t inDataSize_Start; // size of input data in start block 48 | UInt64 inDataSize; // total size of input data in all blocks 49 | 50 | CThread thread; 51 | CAutoResetEvent canRead; 52 | CAutoResetEvent canWrite; 53 | void *allocaPtr; 54 | } CMtDecThread; 55 | 56 | void MtDecThread_FreeInBufs(CMtDecThread *t); 57 | 58 | 59 | typedef enum 60 | { 61 | MTDEC_PARSE_CONTINUE, // continue this block with more input data 62 | MTDEC_PARSE_OVERFLOW, // MT buffers overflow, need switch to single-thread 63 | MTDEC_PARSE_NEW, // new block 64 | MTDEC_PARSE_END // end of block threading. But we still can return to threading after Write(&needContinue) 65 | } EMtDecParseState; 66 | 67 | typedef struct 68 | { 69 | // in 70 | int startCall; 71 | const Byte *src; 72 | size_t srcSize; 73 | // in : (srcSize == 0) is allowed 74 | // out : it's allowed to return less that actually was used ? 75 | int srcFinished; 76 | 77 | // out 78 | EMtDecParseState state; 79 | BoolInt canCreateNewThread; 80 | UInt64 outPos; // check it (size_t) 81 | } CMtDecCallbackInfo; 82 | 83 | 84 | typedef struct 85 | { 86 | void (*Parse)(void *p, unsigned coderIndex, CMtDecCallbackInfo *ci); 87 | 88 | // PreCode() and Code(): 89 | // (SRes_return_result != SZ_OK) means stop decoding, no need another blocks 90 | SRes (*PreCode)(void *p, unsigned coderIndex); 91 | SRes (*Code)(void *p, unsigned coderIndex, 92 | const Byte *src, size_t srcSize, int srcFinished, 93 | UInt64 *inCodePos, UInt64 *outCodePos, int *stop); 94 | // stop - means stop another Code calls 95 | 96 | 97 | /* Write() must be called, if Parse() was called 98 | set (needWrite) if 99 | { 100 | && (was not interrupted by progress) 101 | && (was not interrupted in previous block) 102 | } 103 | 104 | out: 105 | if (*needContinue), decoder still need to continue decoding with new iteration, 106 | even after MTDEC_PARSE_END 107 | if (*canRecode), we didn't flush current block data, so we still can decode current block later. 108 | */ 109 | SRes (*Write)(void *p, unsigned coderIndex, 110 | BoolInt needWriteToStream, 111 | const Byte *src, size_t srcSize, BoolInt isCross, 112 | // int srcFinished, 113 | BoolInt *needContinue, 114 | BoolInt *canRecode); 115 | 116 | } IMtDecCallback2; 117 | 118 | 119 | 120 | typedef struct _CMtDec 121 | { 122 | /* input variables */ 123 | 124 | size_t inBufSize; /* size of input block */ 125 | unsigned numThreadsMax; 126 | // size_t inBlockMax; 127 | unsigned numThreadsMax_2; 128 | 129 | ISeqInStream *inStream; 130 | // const Byte *inData; 131 | // size_t inDataSize; 132 | 133 | ICompressProgress *progress; 134 | ISzAllocPtr alloc; 135 | 136 | IMtDecCallback2 *mtCallback; 137 | void *mtCallbackObject; 138 | 139 | 140 | /* internal variables */ 141 | 142 | size_t allocatedBufsSize; 143 | 144 | BoolInt exitThread; 145 | WRes exitThreadWRes; 146 | 147 | UInt64 blockIndex; 148 | BoolInt isAllocError; 149 | BoolInt overflow; 150 | SRes threadingErrorSRes; 151 | 152 | BoolInt needContinue; 153 | 154 | // CAutoResetEvent finishedEvent; 155 | 156 | SRes readRes; 157 | SRes codeRes; 158 | 159 | BoolInt wasInterrupted; 160 | 161 | unsigned numStartedThreads_Limit; 162 | unsigned numStartedThreads; 163 | 164 | Byte *crossBlock; 165 | size_t crossStart; 166 | size_t crossEnd; 167 | UInt64 readProcessed; 168 | BoolInt readWasFinished; 169 | UInt64 inProcessed; 170 | 171 | unsigned filledThreadStart; 172 | unsigned numFilledThreads; 173 | 174 | #ifndef _7ZIP_ST 175 | BoolInt needInterrupt; 176 | UInt64 interruptIndex; 177 | CMtProgress mtProgress; 178 | CMtDecThread threads[MTDEC__THREADS_MAX]; 179 | #endif 180 | } CMtDec; 181 | 182 | 183 | void MtDec_Construct(CMtDec *p); 184 | void MtDec_Destruct(CMtDec *p); 185 | 186 | /* 187 | MtDec_Code() returns: 188 | SZ_OK - in most cases 189 | MY_SRes_HRESULT_FROM_WRes(WRes_error) - in case of unexpected error in threading function 190 | */ 191 | 192 | SRes MtDec_Code(CMtDec *p); 193 | Byte *MtDec_GetCrossBuff(CMtDec *p); 194 | 195 | int MtDec_PrepareRead(CMtDec *p); 196 | const Byte *MtDec_Read(CMtDec *p, size_t *inLim); 197 | 198 | #endif 199 | 200 | EXTERN_C_END 201 | 202 | #endif 203 | -------------------------------------------------------------------------------- /src/shortcut.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifdef WIN32 6 | 7 | #include "windows.h" 8 | #include "winnls.h" 9 | #include "shobjidl.h" 10 | #include "objbase.h" 11 | #include "objidl.h" 12 | #include "shlguid.h" 13 | #include "shobjidl.h" 14 | #include "shellapi.h" 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | /*============================================================================*/ 23 | 24 | // CreateLink - Uses the Shell's IShellLink and IPersistFile interfaces 25 | // to create and store a shortcut to the specified object. 26 | // 27 | // Returns the result of calling the member functions of the interfaces. 28 | // 29 | // Parameters: 30 | // lpszPathObj - Address of a buffer that contains the path of the object, 31 | // including the file name. 32 | // lpszPathLink - Address of a buffer that contains the path where the 33 | // Shell link is to be stored, including the file name. 34 | // lpszDesc - Address of a buffer that contains a description of the 35 | // Shell link, stored in the Comment field of the link 36 | // properties. 37 | //lpszPicture - picture of shortcut 38 | 39 | HRESULT CreateLink(LPCSTR lpszPathObj, LPCWSTR lpszPathLink, 40 | LPCSTR lpszDesc, LPCSTR lpszPicture, LPCWSTR name) 41 | { 42 | CoInitializeEx( NULL, 0 ); 43 | HRESULT hres = 0; 44 | IShellLink* psl; 45 | 46 | if (SUCCEEDED(hres)) 47 | { 48 | 49 | // Get a pointer to the IShellLink interface. It is assumed that CoInitialize 50 | // has already been called. 51 | hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_ALL, IID_IShellLink, (LPVOID*)&psl); //CLSCTX_ALL CLSCTX_INPROC_SERVER (void**)&psl (LPVOID*)&psl 52 | if (SUCCEEDED(hres)) 53 | { 54 | IPersistFile* ppf; 55 | 56 | // Set the path to the shortcut target and add the description. 57 | psl->SetPath(lpszPathObj); 58 | psl->SetDescription(lpszDesc); 59 | psl->SetIconLocation(lpszPicture, 0); 60 | 61 | // Query IShellLink for the IPersistFile interface, used for saving the 62 | // shortcut in persistent storage. 63 | hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); //(void**)&psl (LPVOID*)&ppf 64 | 65 | if (SUCCEEDED(hres)) 66 | { 67 | WCHAR wsz[MAX_PATH]; 68 | 69 | hres = _wmakepath_s( wsz, _MAX_PATH, NULL, lpszPathLink, 70 | name, L"lnk" ); 71 | 72 | using convert_type = std::codecvt_utf8; 73 | std::wstring_convert converter; 74 | std::string l = converter.to_bytes( wsz ); 75 | 76 | //printf("\n : hres : %x\n, wsz: %s\n", hres, l.c_str()); 77 | // Save the link by calling IPersistFile::Save. 78 | hres = ppf->Save(wsz, TRUE); 79 | 80 | //printf("\n : hres : %x\n, wsz: %s\n", hres, l.c_str()); 81 | ppf->Release(); 82 | } 83 | psl->Release(); 84 | } 85 | } 86 | CoUninitialize(); 87 | return hres; 88 | } 89 | 90 | //destination: 91 | // 0 - FOLDERID_Programs 92 | // 1 - FOLDERID_Desktop 93 | void shortcut(std::string filePath, std::string picturePath, const std::string& name, std::size_t destination) 94 | { 95 | wchar_t* p = nullptr; 96 | std::wstring location; 97 | if(destination == 0){ 98 | HRESULT hres = SHGetKnownFolderPath(FOLDERID_Programs, 0, NULL, &p);//FOLDERID_Programs 99 | location = p; 100 | location += L"\\MinGW-W64\\"; ///dir for shortcut 101 | std::wstring path = location; 102 | SHCreateDirectory(nullptr, path.c_str()); 103 | }else if(destination == 1){ 104 | HRESULT hres = SHGetKnownFolderPath(FOLDERID_Desktop, 0, NULL, &p); 105 | location = p; 106 | } 107 | using convert_type = std::codecvt_utf8; 108 | std::wstring_convert converter; 109 | std::string l = converter.to_bytes( location.c_str() ); 110 | 111 | std::wstring n{name.begin(), name.end()}; 112 | 113 | std::replace(picturePath.begin(), picturePath.end(), '/', '\\'); 114 | std::replace(filePath.begin(), filePath.end(), '/', '\\'); 115 | 116 | printf("\n\nWanna to create shortcut for: %s,\n to: %s,\n picture: %s,\n\n", 117 | filePath.c_str(), l.c_str(), picturePath.c_str()); 118 | 119 | CreateLink(filePath.c_str(), location.c_str(), "Compiler", picturePath.c_str(), n.c_str()); 120 | } 121 | 122 | std::size_t directory_delete(std::string pathname) 123 | { 124 | pathname += "\0\0"; 125 | SHFILEOPSTRUCTA file{ 126 | NULL, 127 | FO_DELETE, 128 | pathname.c_str(), 129 | NULL, 130 | FOF_NO_UI | FOF_NOCONFIRMATION, 131 | FALSE, 132 | NULL, 133 | NULL 134 | }; 135 | return SHFileOperationA(&file); 136 | } 137 | 138 | void showError(const char* error) 139 | { 140 | printf("%s", error); 141 | 142 | int msgboxID = MessageBox(NULL, "Check internet conection. Details?", "Problem", MB_YESNO); 143 | 144 | if(msgboxID == IDYES){ 145 | MessageBox( 146 | NULL, 147 | error, 148 | "Problem", 149 | MB_OK 150 | ); 151 | } 152 | } 153 | 154 | #else 155 | 156 | //destination: 157 | // 0 - FOLDERID_Programs 158 | // 1 - FOLDERID_Desktop 159 | void shortcut(std::string filePath, std::string picturePath, const std::string& name, std::size_t destination) 160 | { 161 | 162 | printf("\n\nWanna to create shortcut for: %s,\n to: ?,\n picture: %sn\n", 163 | filePath.c_str(), picturePath.c_str()); 164 | } 165 | 166 | std::size_t directory_delete(std::string pathname) 167 | { 168 | return std::filesystem::remove_all(pathname); 169 | } 170 | 171 | void showError(const char* error) 172 | { 173 | printf("%s", error); 174 | } 175 | #endif -------------------------------------------------------------------------------- /src/lzma2201/C/Util/LzmaLib/LzmaLib.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="LzmaLib" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 6 | 7 | CFG=LzmaLib - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "LzmaLib.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "LzmaLib.mak" CFG="LzmaLib - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "LzmaLib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") 21 | !MESSAGE "LzmaLib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "LzmaLib - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /YX /FD /c 46 | # ADD CPP /nologo /Gr /MT /W3 /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /FD /c 47 | # SUBTRACT CPP /YX 48 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 50 | # ADD BASE RSC /l 0x419 /d "NDEBUG" 51 | # ADD RSC /l 0x419 /d "NDEBUG" 52 | BSC32=bscmake.exe 53 | # ADD BASE BSC32 /nologo 54 | # ADD BSC32 /nologo 55 | LINK32=link.exe 56 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 57 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Util\LZMA.dll" /opt:NOWIN98 58 | # SUBTRACT LINK32 /pdb:none 59 | 60 | !ELSEIF "$(CFG)" == "LzmaLib - Win32 Debug" 61 | 62 | # PROP BASE Use_MFC 0 63 | # PROP BASE Use_Debug_Libraries 1 64 | # PROP BASE Output_Dir "Debug" 65 | # PROP BASE Intermediate_Dir "Debug" 66 | # PROP BASE Target_Dir "" 67 | # PROP Use_MFC 0 68 | # PROP Use_Debug_Libraries 1 69 | # PROP Output_Dir "Debug" 70 | # PROP Intermediate_Dir "Debug" 71 | # PROP Ignore_Export_Lib 0 72 | # PROP Target_Dir "" 73 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /YX /FD /GZ /c 74 | # ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /D "COMPRESS_MF_MT" /FD /GZ /c 75 | # SUBTRACT CPP /YX 76 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 77 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 78 | # ADD BASE RSC /l 0x419 /d "_DEBUG" 79 | # ADD RSC /l 0x419 /d "_DEBUG" 80 | BSC32=bscmake.exe 81 | # ADD BASE BSC32 /nologo 82 | # ADD BSC32 /nologo 83 | LINK32=link.exe 84 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept 85 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Util\LZMA.dll" /pdbtype:sept 86 | 87 | !ENDIF 88 | 89 | # Begin Target 90 | 91 | # Name "LzmaLib - Win32 Release" 92 | # Name "LzmaLib - Win32 Debug" 93 | # Begin Group "Spec" 94 | 95 | # PROP Default_Filter "" 96 | # Begin Source File 97 | 98 | SOURCE=.\LzmaLib.def 99 | # End Source File 100 | # Begin Source File 101 | 102 | SOURCE=.\LzmaLibExports.c 103 | # End Source File 104 | # End Group 105 | # Begin Source File 106 | 107 | SOURCE=..\..\7zTypes.h 108 | # End Source File 109 | # Begin Source File 110 | 111 | SOURCE=..\..\Alloc.c 112 | # End Source File 113 | # Begin Source File 114 | 115 | SOURCE=..\..\Alloc.h 116 | # End Source File 117 | # Begin Source File 118 | 119 | SOURCE=..\..\IStream.h 120 | # End Source File 121 | # Begin Source File 122 | 123 | SOURCE=..\..\LzFind.c 124 | # End Source File 125 | # Begin Source File 126 | 127 | SOURCE=..\..\LzFind.h 128 | # End Source File 129 | # Begin Source File 130 | 131 | SOURCE=..\..\LzFindMt.c 132 | # End Source File 133 | # Begin Source File 134 | 135 | SOURCE=..\..\LzFindMt.h 136 | # End Source File 137 | # Begin Source File 138 | 139 | SOURCE=..\..\LzFindOpt.c 140 | # End Source File 141 | # Begin Source File 142 | 143 | SOURCE=..\..\LzHash.h 144 | # End Source File 145 | # Begin Source File 146 | 147 | SOURCE=..\..\LzmaDec.c 148 | # End Source File 149 | # Begin Source File 150 | 151 | SOURCE=..\..\LzmaDec.h 152 | # End Source File 153 | # Begin Source File 154 | 155 | SOURCE=..\..\LzmaEnc.c 156 | # End Source File 157 | # Begin Source File 158 | 159 | SOURCE=..\..\LzmaEnc.h 160 | # End Source File 161 | # Begin Source File 162 | 163 | SOURCE=..\..\LzmaLib.c 164 | # End Source File 165 | # Begin Source File 166 | 167 | SOURCE=..\..\LzmaLib.h 168 | # End Source File 169 | # Begin Source File 170 | 171 | SOURCE=.\resource.rc 172 | # End Source File 173 | # Begin Source File 174 | 175 | SOURCE=..\..\Threads.c 176 | # End Source File 177 | # Begin Source File 178 | 179 | SOURCE=..\..\Threads.h 180 | # End Source File 181 | # End Target 182 | # End Project 183 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/Lzma/LzmaUtil.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="LzmaUtil" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=LzmaUtil - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "LzmaUtil.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "LzmaUtil.mak" CFG="LzmaUtil - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "LzmaUtil - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "LzmaUtil - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "LzmaUtil - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /MT /W4 /WX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c 46 | # SUBTRACT CPP /YX 47 | # ADD BASE RSC /l 0x419 /d "NDEBUG" 48 | # ADD RSC /l 0x419 /d "NDEBUG" 49 | BSC32=bscmake.exe 50 | # ADD BASE BSC32 /nologo 51 | # ADD BSC32 /nologo 52 | LINK32=link.exe 53 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 54 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\util\7lzma.exe" 55 | 56 | !ELSEIF "$(CFG)" == "LzmaUtil - Win32 Debug" 57 | 58 | # PROP BASE Use_MFC 0 59 | # PROP BASE Use_Debug_Libraries 1 60 | # PROP BASE Output_Dir "Debug" 61 | # PROP BASE Intermediate_Dir "Debug" 62 | # PROP BASE Target_Dir "" 63 | # PROP Use_MFC 0 64 | # PROP Use_Debug_Libraries 1 65 | # PROP Output_Dir "Debug" 66 | # PROP Intermediate_Dir "Debug" 67 | # PROP Ignore_Export_Lib 0 68 | # PROP Target_Dir "" 69 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 70 | # ADD CPP /nologo /MTd /W4 /WX /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c 71 | # SUBTRACT CPP /YX 72 | # ADD BASE RSC /l 0x419 /d "_DEBUG" 73 | # ADD RSC /l 0x419 /d "_DEBUG" 74 | BSC32=bscmake.exe 75 | # ADD BASE BSC32 /nologo 76 | # ADD BSC32 /nologo 77 | LINK32=link.exe 78 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 79 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\util\7lzma.exe" /pdbtype:sept 80 | 81 | !ENDIF 82 | 83 | # Begin Target 84 | 85 | # Name "LzmaUtil - Win32 Release" 86 | # Name "LzmaUtil - Win32 Debug" 87 | # Begin Source File 88 | 89 | SOURCE=..\..\7zFile.c 90 | # End Source File 91 | # Begin Source File 92 | 93 | SOURCE=..\..\7zFile.h 94 | # End Source File 95 | # Begin Source File 96 | 97 | SOURCE=..\..\7zStream.c 98 | # End Source File 99 | # Begin Source File 100 | 101 | SOURCE=..\..\7zTypes.h 102 | # End Source File 103 | # Begin Source File 104 | 105 | SOURCE=..\..\7zVersion.h 106 | # End Source File 107 | # Begin Source File 108 | 109 | SOURCE=..\..\Alloc.c 110 | # End Source File 111 | # Begin Source File 112 | 113 | SOURCE=..\..\Alloc.h 114 | # End Source File 115 | # Begin Source File 116 | 117 | SOURCE=..\..\CpuArch.h 118 | # End Source File 119 | # Begin Source File 120 | 121 | SOURCE=..\..\LzFind.c 122 | # End Source File 123 | # Begin Source File 124 | 125 | SOURCE=..\..\LzFind.h 126 | # End Source File 127 | # Begin Source File 128 | 129 | SOURCE=..\..\LzFindMt.c 130 | # End Source File 131 | # Begin Source File 132 | 133 | SOURCE=..\..\LzFindMt.h 134 | # End Source File 135 | # Begin Source File 136 | 137 | SOURCE=..\..\LzFindOpt.c 138 | # End Source File 139 | # Begin Source File 140 | 141 | SOURCE=..\..\LzHash.h 142 | # End Source File 143 | # Begin Source File 144 | 145 | SOURCE=..\..\LzmaDec.c 146 | # End Source File 147 | # Begin Source File 148 | 149 | SOURCE=..\..\LzmaDec.h 150 | # End Source File 151 | # Begin Source File 152 | 153 | SOURCE=..\..\LzmaEnc.c 154 | # End Source File 155 | # Begin Source File 156 | 157 | SOURCE=..\..\LzmaEnc.h 158 | # End Source File 159 | # Begin Source File 160 | 161 | SOURCE=.\LzmaUtil.c 162 | # End Source File 163 | # Begin Source File 164 | 165 | SOURCE=..\..\Threads.c 166 | # End Source File 167 | # Begin Source File 168 | 169 | SOURCE=..\..\Threads.h 170 | # End Source File 171 | # End Target 172 | # End Project 173 | -------------------------------------------------------------------------------- /src/lzma2201/C/7z.h: -------------------------------------------------------------------------------- 1 | /* 7z.h -- 7z interface 2 | 2018-07-02 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_H 5 | #define __7Z_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define k7zStartHeaderSize 0x20 12 | #define k7zSignatureSize 6 13 | 14 | extern const Byte k7zSignature[k7zSignatureSize]; 15 | 16 | typedef struct 17 | { 18 | const Byte *Data; 19 | size_t Size; 20 | } CSzData; 21 | 22 | /* CSzCoderInfo & CSzFolder support only default methods */ 23 | 24 | typedef struct 25 | { 26 | size_t PropsOffset; 27 | UInt32 MethodID; 28 | Byte NumStreams; 29 | Byte PropsSize; 30 | } CSzCoderInfo; 31 | 32 | typedef struct 33 | { 34 | UInt32 InIndex; 35 | UInt32 OutIndex; 36 | } CSzBond; 37 | 38 | #define SZ_NUM_CODERS_IN_FOLDER_MAX 4 39 | #define SZ_NUM_BONDS_IN_FOLDER_MAX 3 40 | #define SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX 4 41 | 42 | typedef struct 43 | { 44 | UInt32 NumCoders; 45 | UInt32 NumBonds; 46 | UInt32 NumPackStreams; 47 | UInt32 UnpackStream; 48 | UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX]; 49 | CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX]; 50 | CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX]; 51 | } CSzFolder; 52 | 53 | 54 | SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd); 55 | 56 | typedef struct 57 | { 58 | UInt32 Low; 59 | UInt32 High; 60 | } CNtfsFileTime; 61 | 62 | typedef struct 63 | { 64 | Byte *Defs; /* MSB 0 bit numbering */ 65 | UInt32 *Vals; 66 | } CSzBitUi32s; 67 | 68 | typedef struct 69 | { 70 | Byte *Defs; /* MSB 0 bit numbering */ 71 | // UInt64 *Vals; 72 | CNtfsFileTime *Vals; 73 | } CSzBitUi64s; 74 | 75 | #define SzBitArray_Check(p, i) (((p)[(i) >> 3] & (0x80 >> ((i) & 7))) != 0) 76 | 77 | #define SzBitWithVals_Check(p, i) ((p)->Defs && ((p)->Defs[(i) >> 3] & (0x80 >> ((i) & 7))) != 0) 78 | 79 | typedef struct 80 | { 81 | UInt32 NumPackStreams; 82 | UInt32 NumFolders; 83 | 84 | UInt64 *PackPositions; // NumPackStreams + 1 85 | CSzBitUi32s FolderCRCs; // NumFolders 86 | 87 | size_t *FoCodersOffsets; // NumFolders + 1 88 | UInt32 *FoStartPackStreamIndex; // NumFolders + 1 89 | UInt32 *FoToCoderUnpackSizes; // NumFolders + 1 90 | Byte *FoToMainUnpackSizeIndex; // NumFolders 91 | UInt64 *CoderUnpackSizes; // for all coders in all folders 92 | 93 | Byte *CodersData; 94 | 95 | UInt64 RangeLimit; 96 | } CSzAr; 97 | 98 | UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex); 99 | 100 | SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, 101 | ILookInStream *stream, UInt64 startPos, 102 | Byte *outBuffer, size_t outSize, 103 | ISzAllocPtr allocMain); 104 | 105 | typedef struct 106 | { 107 | CSzAr db; 108 | 109 | UInt64 startPosAfterHeader; 110 | UInt64 dataPos; 111 | 112 | UInt32 NumFiles; 113 | 114 | UInt64 *UnpackPositions; // NumFiles + 1 115 | // Byte *IsEmptyFiles; 116 | Byte *IsDirs; 117 | CSzBitUi32s CRCs; 118 | 119 | CSzBitUi32s Attribs; 120 | // CSzBitUi32s Parents; 121 | CSzBitUi64s MTime; 122 | CSzBitUi64s CTime; 123 | 124 | UInt32 *FolderToFile; // NumFolders + 1 125 | UInt32 *FileToFolder; // NumFiles 126 | 127 | size_t *FileNameOffsets; /* in 2-byte steps */ 128 | Byte *FileNames; /* UTF-16-LE */ 129 | } CSzArEx; 130 | 131 | #define SzArEx_IsDir(p, i) (SzBitArray_Check((p)->IsDirs, i)) 132 | 133 | #define SzArEx_GetFileSize(p, i) ((p)->UnpackPositions[(i) + 1] - (p)->UnpackPositions[i]) 134 | 135 | void SzArEx_Init(CSzArEx *p); 136 | void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc); 137 | UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder); 138 | int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize); 139 | 140 | /* 141 | if dest == NULL, the return value specifies the required size of the buffer, 142 | in 16-bit characters, including the null-terminating character. 143 | if dest != NULL, the return value specifies the number of 16-bit characters that 144 | are written to the dest, including the null-terminating character. */ 145 | 146 | size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest); 147 | 148 | /* 149 | size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex); 150 | UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest); 151 | */ 152 | 153 | 154 | 155 | /* 156 | SzArEx_Extract extracts file from archive 157 | 158 | *outBuffer must be 0 before first call for each new archive. 159 | 160 | Extracting cache: 161 | If you need to decompress more than one file, you can send 162 | these values from previous call: 163 | *blockIndex, 164 | *outBuffer, 165 | *outBufferSize 166 | You can consider "*outBuffer" as cache of solid block. If your archive is solid, 167 | it will increase decompression speed. 168 | 169 | If you use external function, you can declare these 3 cache variables 170 | (blockIndex, outBuffer, outBufferSize) as static in that external function. 171 | 172 | Free *outBuffer and set *outBuffer to 0, if you want to flush cache. 173 | */ 174 | 175 | SRes SzArEx_Extract( 176 | const CSzArEx *db, 177 | ILookInStream *inStream, 178 | UInt32 fileIndex, /* index of file */ 179 | UInt32 *blockIndex, /* index of solid block */ 180 | Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ 181 | size_t *outBufferSize, /* buffer size for output buffer */ 182 | size_t *offset, /* offset of stream for required file in *outBuffer */ 183 | size_t *outSizeProcessed, /* size of file in *outBuffer */ 184 | ISzAllocPtr allocMain, 185 | ISzAllocPtr allocTemp); 186 | 187 | 188 | /* 189 | SzArEx_Open Errors: 190 | SZ_ERROR_NO_ARCHIVE 191 | SZ_ERROR_ARCHIVE 192 | SZ_ERROR_UNSUPPORTED 193 | SZ_ERROR_MEM 194 | SZ_ERROR_CRC 195 | SZ_ERROR_INPUT_EOF 196 | SZ_ERROR_FAIL 197 | */ 198 | 199 | SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, 200 | ISzAllocPtr allocMain, ISzAllocPtr allocTemp); 201 | 202 | EXTERN_C_END 203 | 204 | #endif 205 | -------------------------------------------------------------------------------- /src/lzma2201/C/Ppmd.h: -------------------------------------------------------------------------------- 1 | /* Ppmd.h -- PPMD codec common code 2 | 2021-04-13 : 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 | #if defined(MY_CPU_SIZEOF_POINTER) && (MY_CPU_SIZEOF_POINTER == 4) 13 | /* 14 | PPMD code always uses 32-bit internal fields in PPMD structures to store internal references in main block. 15 | if (PPMD_32BIT is defined), the PPMD code stores internal pointers to 32-bit reference fields. 16 | if (PPMD_32BIT is NOT defined), the PPMD code stores internal UInt32 offsets to reference fields. 17 | if (pointer size is 64-bit), then (PPMD_32BIT) mode is not allowed, 18 | if (pointer size is 32-bit), then (PPMD_32BIT) mode is optional, 19 | and it's allowed to disable PPMD_32BIT mode even if pointer is 32-bit. 20 | PPMD code works slightly faster in (PPMD_32BIT) mode. 21 | */ 22 | #define PPMD_32BIT 23 | #endif 24 | 25 | #define PPMD_INT_BITS 7 26 | #define PPMD_PERIOD_BITS 7 27 | #define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS)) 28 | 29 | #define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift)) 30 | #define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2) 31 | #define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob)) 32 | #define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob)) 33 | 34 | #define PPMD_N1 4 35 | #define PPMD_N2 4 36 | #define PPMD_N3 4 37 | #define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4) 38 | #define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4) 39 | 40 | MY_CPU_pragma_pack_push_1 41 | /* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */ 42 | 43 | /* SEE-contexts for PPM-contexts with masked symbols */ 44 | typedef struct 45 | { 46 | UInt16 Summ; /* Freq */ 47 | Byte Shift; /* Speed of Freq change; low Shift is for fast change */ 48 | Byte Count; /* Count to next change of Shift */ 49 | } CPpmd_See; 50 | 51 | #define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \ 52 | { (p)->Summ = (UInt16)((p)->Summ << 1); (p)->Count = (Byte)(3 << (p)->Shift++); } 53 | 54 | 55 | typedef struct 56 | { 57 | Byte Symbol; 58 | Byte Freq; 59 | UInt16 Successor_0; 60 | UInt16 Successor_1; 61 | } CPpmd_State; 62 | 63 | typedef struct CPpmd_State2_ 64 | { 65 | Byte Symbol; 66 | Byte Freq; 67 | } CPpmd_State2; 68 | 69 | typedef struct CPpmd_State4_ 70 | { 71 | UInt16 Successor_0; 72 | UInt16 Successor_1; 73 | } CPpmd_State4; 74 | 75 | MY_CPU_pragma_pop 76 | 77 | /* 78 | PPMD code can write full CPpmd_State structure data to CPpmd*_Context 79 | at (byte offset = 2) instead of some fields of original CPpmd*_Context structure. 80 | 81 | If we use pointers to different types, but that point to shared 82 | memory space, we can have aliasing problem (strict aliasing). 83 | 84 | XLC compiler in -O2 mode can change the order of memory write instructions 85 | in relation to read instructions, if we have use pointers to different types. 86 | 87 | To solve that aliasing problem we use combined CPpmd*_Context structure 88 | with unions that contain the fields from both structures: 89 | the original CPpmd*_Context and CPpmd_State. 90 | So we can access the fields from both structures via one pointer, 91 | and the compiler doesn't change the order of write instructions 92 | in relation to read instructions. 93 | 94 | If we don't use memory write instructions to shared memory in 95 | some local code, and we use only reading instructions (read only), 96 | then probably it's safe to use pointers to different types for reading. 97 | */ 98 | 99 | 100 | 101 | #ifdef PPMD_32BIT 102 | 103 | #define Ppmd_Ref_Type(type) type * 104 | #define Ppmd_GetRef(p, ptr) (ptr) 105 | #define Ppmd_GetPtr(p, ptr) (ptr) 106 | #define Ppmd_GetPtr_Type(p, ptr, note_type) (ptr) 107 | 108 | #else 109 | 110 | #define Ppmd_Ref_Type(type) UInt32 111 | #define Ppmd_GetRef(p, ptr) ((UInt32)((Byte *)(ptr) - (p)->Base)) 112 | #define Ppmd_GetPtr(p, offs) ((void *)((p)->Base + (offs))) 113 | #define Ppmd_GetPtr_Type(p, offs, type) ((type *)Ppmd_GetPtr(p, offs)) 114 | 115 | #endif // PPMD_32BIT 116 | 117 | 118 | typedef Ppmd_Ref_Type(CPpmd_State) CPpmd_State_Ref; 119 | typedef Ppmd_Ref_Type(void) CPpmd_Void_Ref; 120 | typedef Ppmd_Ref_Type(Byte) CPpmd_Byte_Ref; 121 | 122 | 123 | /* 124 | #ifdef MY_CPU_LE_UNALIGN 125 | // the unaligned 32-bit access latency can be too large, if the data is not in L1 cache. 126 | #define Ppmd_GET_SUCCESSOR(p) ((CPpmd_Void_Ref)*(const UInt32 *)(const void *)&(p)->Successor_0) 127 | #define Ppmd_SET_SUCCESSOR(p, v) *(UInt32 *)(void *)(void *)&(p)->Successor_0 = (UInt32)(v) 128 | 129 | #else 130 | */ 131 | 132 | /* 133 | We can write 16-bit halves to 32-bit (Successor) field in any selected order. 134 | But the native order is more consistent way. 135 | So we use the native order, if LE/BE order can be detected here at compile time. 136 | */ 137 | 138 | #ifdef MY_CPU_BE 139 | 140 | #define Ppmd_GET_SUCCESSOR(p) \ 141 | ( (CPpmd_Void_Ref) (((UInt32)(p)->Successor_0 << 16) | (p)->Successor_1) ) 142 | 143 | #define Ppmd_SET_SUCCESSOR(p, v) { \ 144 | (p)->Successor_0 = (UInt16)(((UInt32)(v) >> 16) /* & 0xFFFF */); \ 145 | (p)->Successor_1 = (UInt16)((UInt32)(v) /* & 0xFFFF */); } 146 | 147 | #else 148 | 149 | #define Ppmd_GET_SUCCESSOR(p) \ 150 | ( (CPpmd_Void_Ref) ((p)->Successor_0 | ((UInt32)(p)->Successor_1 << 16)) ) 151 | 152 | #define Ppmd_SET_SUCCESSOR(p, v) { \ 153 | (p)->Successor_0 = (UInt16)((UInt32)(v) /* & 0xFFFF */); \ 154 | (p)->Successor_1 = (UInt16)(((UInt32)(v) >> 16) /* & 0xFFFF */); } 155 | 156 | #endif 157 | 158 | // #endif 159 | 160 | 161 | #define PPMD_SetAllBitsIn256Bytes(p) \ 162 | { size_t z; for (z = 0; z < 256 / sizeof(p[0]); z += 8) { \ 163 | 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; }} 164 | 165 | EXTERN_C_END 166 | 167 | #endif 168 | -------------------------------------------------------------------------------- /src/lzma2201/C/Util/SfxSetup/SfxSetup.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="SfxSetup" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=SfxSetup - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "SfxSetup.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "SfxSetup.mak" CFG="SfxSetup - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "SfxSetup - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "SfxSetup - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "SfxSetup - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /c 46 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 47 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD BASE RSC /l 0x419 /d "NDEBUG" 49 | # ADD RSC /l 0x419 /d "NDEBUG" 50 | BSC32=bscmake.exe 51 | # ADD BASE BSC32 /nologo 52 | # ADD BSC32 /nologo 53 | LINK32=link.exe 54 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 55 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 56 | 57 | !ELSEIF "$(CFG)" == "SfxSetup - Win32 Debug" 58 | 59 | # PROP BASE Use_MFC 0 60 | # PROP BASE Use_Debug_Libraries 1 61 | # PROP BASE Output_Dir "Debug" 62 | # PROP BASE Intermediate_Dir "Debug" 63 | # PROP BASE Target_Dir "" 64 | # PROP Use_MFC 0 65 | # PROP Use_Debug_Libraries 1 66 | # PROP Output_Dir "Debug" 67 | # PROP Intermediate_Dir "Debug" 68 | # PROP Ignore_Export_Lib 0 69 | # PROP Target_Dir "" 70 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c 71 | # ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c 72 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 73 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 74 | # ADD BASE RSC /l 0x419 /d "_DEBUG" 75 | # ADD RSC /l 0x419 /d "_DEBUG" 76 | BSC32=bscmake.exe 77 | # ADD BASE BSC32 /nologo 78 | # ADD BSC32 /nologo 79 | LINK32=link.exe 80 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 81 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 82 | 83 | !ENDIF 84 | 85 | # Begin Target 86 | 87 | # Name "SfxSetup - Win32 Release" 88 | # Name "SfxSetup - Win32 Debug" 89 | # Begin Group "Common" 90 | 91 | # PROP Default_Filter "" 92 | # Begin Source File 93 | 94 | SOURCE=..\..\7z.h 95 | # End Source File 96 | # Begin Source File 97 | 98 | SOURCE=..\..\7zAlloc.c 99 | # End Source File 100 | # Begin Source File 101 | 102 | SOURCE=..\..\7zAlloc.h 103 | # End Source File 104 | # Begin Source File 105 | 106 | SOURCE=..\..\7zArcIn.c 107 | # End Source File 108 | # Begin Source File 109 | 110 | SOURCE=..\..\7zBuf.c 111 | # End Source File 112 | # Begin Source File 113 | 114 | SOURCE=..\..\7zBuf.h 115 | # End Source File 116 | # Begin Source File 117 | 118 | SOURCE=..\..\7zCrc.c 119 | # End Source File 120 | # Begin Source File 121 | 122 | SOURCE=..\..\7zCrc.h 123 | # End Source File 124 | # Begin Source File 125 | 126 | SOURCE=..\..\7zCrcOpt.c 127 | # End Source File 128 | # Begin Source File 129 | 130 | SOURCE=..\..\7zDec.c 131 | # End Source File 132 | # Begin Source File 133 | 134 | SOURCE=..\..\7zFile.c 135 | # End Source File 136 | # Begin Source File 137 | 138 | SOURCE=..\..\7zFile.h 139 | # End Source File 140 | # Begin Source File 141 | 142 | SOURCE=..\..\7zStream.c 143 | # End Source File 144 | # Begin Source File 145 | 146 | SOURCE=..\..\7zTypes.h 147 | # End Source File 148 | # Begin Source File 149 | 150 | SOURCE=..\..\Bcj2.c 151 | # End Source File 152 | # Begin Source File 153 | 154 | SOURCE=..\..\Bcj2.h 155 | # End Source File 156 | # Begin Source File 157 | 158 | SOURCE=..\..\Bra.c 159 | # End Source File 160 | # Begin Source File 161 | 162 | SOURCE=..\..\Bra.h 163 | # End Source File 164 | # Begin Source File 165 | 166 | SOURCE=..\..\Bra86.c 167 | # End Source File 168 | # Begin Source File 169 | 170 | SOURCE=..\..\BraIA64.c 171 | # End Source File 172 | # Begin Source File 173 | 174 | SOURCE=..\..\CpuArch.c 175 | # End Source File 176 | # Begin Source File 177 | 178 | SOURCE=..\..\CpuArch.h 179 | # End Source File 180 | # Begin Source File 181 | 182 | SOURCE=..\..\Delta.c 183 | # End Source File 184 | # Begin Source File 185 | 186 | SOURCE=..\..\Delta.h 187 | # End Source File 188 | # Begin Source File 189 | 190 | SOURCE=..\..\DllSecur.c 191 | # End Source File 192 | # Begin Source File 193 | 194 | SOURCE=..\..\DllSecur.h 195 | # End Source File 196 | # Begin Source File 197 | 198 | SOURCE=..\..\Lzma2Dec.c 199 | # End Source File 200 | # Begin Source File 201 | 202 | SOURCE=..\..\Lzma2Dec.h 203 | # End Source File 204 | # Begin Source File 205 | 206 | SOURCE=..\..\LzmaDec.c 207 | # End Source File 208 | # Begin Source File 209 | 210 | SOURCE=..\..\LzmaDec.h 211 | # End Source File 212 | # End Group 213 | # Begin Group "Spec" 214 | 215 | # PROP Default_Filter "" 216 | # Begin Source File 217 | 218 | SOURCE=.\Precomp.c 219 | # ADD CPP /Yc"Precomp.h" 220 | # End Source File 221 | # Begin Source File 222 | 223 | SOURCE=.\Precomp.h 224 | # End Source File 225 | # End Group 226 | # Begin Source File 227 | 228 | SOURCE=.\SfxSetup.c 229 | # End Source File 230 | # End Target 231 | # End Project 232 | -------------------------------------------------------------------------------- /src/lzma2201/C/Bcj2.c: -------------------------------------------------------------------------------- 1 | /* Bcj2.c -- BCJ2 Decoder (Converter for x86 code) 2 | 2021-02-09 : Igor Pavlov : Public domain */ 3 | 4 | #include "Precomp.h" 5 | 6 | #include "Bcj2.h" 7 | #include "CpuArch.h" 8 | 9 | #define CProb UInt16 10 | 11 | #define kTopValue ((UInt32)1 << 24) 12 | #define kNumModelBits 11 13 | #define kBitModelTotal (1 << kNumModelBits) 14 | #define kNumMoveBits 5 15 | 16 | #define _IF_BIT_0 ttt = *prob; bound = (p->range >> kNumModelBits) * ttt; if (p->code < bound) 17 | #define _UPDATE_0 p->range = bound; *prob = (CProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); 18 | #define _UPDATE_1 p->range -= bound; p->code -= bound; *prob = (CProb)(ttt - (ttt >> kNumMoveBits)); 19 | 20 | void Bcj2Dec_Init(CBcj2Dec *p) 21 | { 22 | unsigned i; 23 | 24 | p->state = BCJ2_DEC_STATE_OK; 25 | p->ip = 0; 26 | p->temp[3] = 0; 27 | p->range = 0; 28 | p->code = 0; 29 | for (i = 0; i < sizeof(p->probs) / sizeof(p->probs[0]); i++) 30 | p->probs[i] = kBitModelTotal >> 1; 31 | } 32 | 33 | SRes Bcj2Dec_Decode(CBcj2Dec *p) 34 | { 35 | if (p->range <= 5) 36 | { 37 | p->state = BCJ2_DEC_STATE_OK; 38 | for (; p->range != 5; p->range++) 39 | { 40 | if (p->range == 1 && p->code != 0) 41 | return SZ_ERROR_DATA; 42 | 43 | if (p->bufs[BCJ2_STREAM_RC] == p->lims[BCJ2_STREAM_RC]) 44 | { 45 | p->state = BCJ2_STREAM_RC; 46 | return SZ_OK; 47 | } 48 | 49 | p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++; 50 | } 51 | 52 | if (p->code == 0xFFFFFFFF) 53 | return SZ_ERROR_DATA; 54 | 55 | p->range = 0xFFFFFFFF; 56 | } 57 | else if (p->state >= BCJ2_DEC_STATE_ORIG_0) 58 | { 59 | while (p->state <= BCJ2_DEC_STATE_ORIG_3) 60 | { 61 | Byte *dest = p->dest; 62 | if (dest == p->destLim) 63 | return SZ_OK; 64 | *dest = p->temp[(size_t)p->state - BCJ2_DEC_STATE_ORIG_0]; 65 | p->state++; 66 | p->dest = dest + 1; 67 | } 68 | } 69 | 70 | /* 71 | if (BCJ2_IS_32BIT_STREAM(p->state)) 72 | { 73 | const Byte *cur = p->bufs[p->state]; 74 | if (cur == p->lims[p->state]) 75 | return SZ_OK; 76 | p->bufs[p->state] = cur + 4; 77 | 78 | { 79 | UInt32 val; 80 | Byte *dest; 81 | SizeT rem; 82 | 83 | p->ip += 4; 84 | val = GetBe32(cur) - p->ip; 85 | dest = p->dest; 86 | rem = p->destLim - dest; 87 | if (rem < 4) 88 | { 89 | SizeT i; 90 | SetUi32(p->temp, val); 91 | for (i = 0; i < rem; i++) 92 | dest[i] = p->temp[i]; 93 | p->dest = dest + rem; 94 | p->state = BCJ2_DEC_STATE_ORIG_0 + (unsigned)rem; 95 | return SZ_OK; 96 | } 97 | SetUi32(dest, val); 98 | p->temp[3] = (Byte)(val >> 24); 99 | p->dest = dest + 4; 100 | p->state = BCJ2_DEC_STATE_OK; 101 | } 102 | } 103 | */ 104 | 105 | for (;;) 106 | { 107 | if (BCJ2_IS_32BIT_STREAM(p->state)) 108 | p->state = BCJ2_DEC_STATE_OK; 109 | else 110 | { 111 | if (p->range < kTopValue) 112 | { 113 | if (p->bufs[BCJ2_STREAM_RC] == p->lims[BCJ2_STREAM_RC]) 114 | { 115 | p->state = BCJ2_STREAM_RC; 116 | return SZ_OK; 117 | } 118 | p->range <<= 8; 119 | p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++; 120 | } 121 | 122 | { 123 | const Byte *src = p->bufs[BCJ2_STREAM_MAIN]; 124 | const Byte *srcLim; 125 | Byte *dest; 126 | SizeT num = (SizeT)(p->lims[BCJ2_STREAM_MAIN] - src); 127 | 128 | if (num == 0) 129 | { 130 | p->state = BCJ2_STREAM_MAIN; 131 | return SZ_OK; 132 | } 133 | 134 | dest = p->dest; 135 | if (num > (SizeT)(p->destLim - dest)) 136 | { 137 | num = (SizeT)(p->destLim - dest); 138 | if (num == 0) 139 | { 140 | p->state = BCJ2_DEC_STATE_ORIG; 141 | return SZ_OK; 142 | } 143 | } 144 | 145 | srcLim = src + num; 146 | 147 | if (p->temp[3] == 0x0F && (src[0] & 0xF0) == 0x80) 148 | *dest = src[0]; 149 | else for (;;) 150 | { 151 | Byte b = *src; 152 | *dest = b; 153 | if (b != 0x0F) 154 | { 155 | if ((b & 0xFE) == 0xE8) 156 | break; 157 | dest++; 158 | if (++src != srcLim) 159 | continue; 160 | break; 161 | } 162 | dest++; 163 | if (++src == srcLim) 164 | break; 165 | if ((*src & 0xF0) != 0x80) 166 | continue; 167 | *dest = *src; 168 | break; 169 | } 170 | 171 | num = (SizeT)(src - p->bufs[BCJ2_STREAM_MAIN]); 172 | 173 | if (src == srcLim) 174 | { 175 | p->temp[3] = src[-1]; 176 | p->bufs[BCJ2_STREAM_MAIN] = src; 177 | p->ip += (UInt32)num; 178 | p->dest += num; 179 | p->state = 180 | p->bufs[BCJ2_STREAM_MAIN] == 181 | p->lims[BCJ2_STREAM_MAIN] ? 182 | (unsigned)BCJ2_STREAM_MAIN : 183 | (unsigned)BCJ2_DEC_STATE_ORIG; 184 | return SZ_OK; 185 | } 186 | 187 | { 188 | UInt32 bound, ttt; 189 | CProb *prob; 190 | Byte b = src[0]; 191 | Byte prev = (Byte)(num == 0 ? p->temp[3] : src[-1]); 192 | 193 | p->temp[3] = b; 194 | p->bufs[BCJ2_STREAM_MAIN] = src + 1; 195 | num++; 196 | p->ip += (UInt32)num; 197 | p->dest += num; 198 | 199 | prob = p->probs + (unsigned)(b == 0xE8 ? 2 + (unsigned)prev : (b == 0xE9 ? 1 : 0)); 200 | 201 | _IF_BIT_0 202 | { 203 | _UPDATE_0 204 | continue; 205 | } 206 | _UPDATE_1 207 | 208 | } 209 | } 210 | } 211 | 212 | { 213 | UInt32 val; 214 | unsigned cj = (p->temp[3] == 0xE8) ? BCJ2_STREAM_CALL : BCJ2_STREAM_JUMP; 215 | const Byte *cur = p->bufs[cj]; 216 | Byte *dest; 217 | SizeT rem; 218 | 219 | if (cur == p->lims[cj]) 220 | { 221 | p->state = cj; 222 | break; 223 | } 224 | 225 | val = GetBe32(cur); 226 | p->bufs[cj] = cur + 4; 227 | 228 | p->ip += 4; 229 | val -= p->ip; 230 | dest = p->dest; 231 | rem = (SizeT)(p->destLim - dest); 232 | 233 | if (rem < 4) 234 | { 235 | p->temp[0] = (Byte)val; if (rem > 0) dest[0] = (Byte)val; val >>= 8; 236 | p->temp[1] = (Byte)val; if (rem > 1) dest[1] = (Byte)val; val >>= 8; 237 | p->temp[2] = (Byte)val; if (rem > 2) dest[2] = (Byte)val; val >>= 8; 238 | p->temp[3] = (Byte)val; 239 | p->dest = dest + rem; 240 | p->state = BCJ2_DEC_STATE_ORIG_0 + (unsigned)rem; 241 | break; 242 | } 243 | 244 | SetUi32(dest, val); 245 | p->temp[3] = (Byte)(val >> 24); 246 | p->dest = dest + 4; 247 | } 248 | } 249 | 250 | if (p->range < kTopValue && p->bufs[BCJ2_STREAM_RC] != p->lims[BCJ2_STREAM_RC]) 251 | { 252 | p->range <<= 8; 253 | p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++; 254 | } 255 | 256 | return SZ_OK; 257 | } 258 | --------------------------------------------------------------------------------