mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 07:14:56 -06:00
23.01
This commit is contained in:
@@ -42,7 +42,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FAcs /Yu"Precomp.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /D "Z7_PPMD_SUPPORT" /FAcs /Yu"Precomp.h" /FD /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -67,7 +67,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /D "Z7_PPMD_SUPPORT" /Yu"Precomp.h" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -145,6 +145,10 @@ SOURCE=..\..\7zTypes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\7zWindows.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Bcj2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* 7zMain.c - Test application for 7z Decoder
|
||||
2021-04-29 : Igor Pavlov : Public domain */
|
||||
2023-04-04 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define kInputBufSize ((size_t)1 << 18)
|
||||
|
||||
static const ISzAlloc g_Alloc = { SzAlloc, SzFree };
|
||||
// static const ISzAlloc g_Alloc_temp = { SzAllocTemp, SzFreeTemp };
|
||||
|
||||
|
||||
static void Print(const char *s)
|
||||
@@ -53,19 +53,19 @@ static int Buf_EnsureSize(CBuf *dest, size_t size)
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
#define _USE_UTF8
|
||||
#define MY_USE_UTF8
|
||||
#endif
|
||||
|
||||
/* #define _USE_UTF8 */
|
||||
/* #define MY_USE_UTF8 */
|
||||
|
||||
#ifdef _USE_UTF8
|
||||
#ifdef MY_USE_UTF8
|
||||
|
||||
#define _UTF8_START(n) (0x100 - (1 << (7 - (n))))
|
||||
#define MY_UTF8_START(n) (0x100 - (1 << (7 - (n))))
|
||||
|
||||
#define _UTF8_RANGE(n) (((UInt32)1) << ((n) * 5 + 6))
|
||||
#define MY_UTF8_RANGE(n) (((UInt32)1) << ((n) * 5 + 6))
|
||||
|
||||
#define _UTF8_HEAD(n, val) ((Byte)(_UTF8_START(n) + (val >> (6 * (n)))))
|
||||
#define _UTF8_CHAR(n, val) ((Byte)(0x80 + (((val) >> (6 * (n))) & 0x3F)))
|
||||
#define MY_UTF8_HEAD(n, val) ((Byte)(MY_UTF8_START(n) + (val >> (6 * (n)))))
|
||||
#define MY_UTF8_CHAR(n, val) ((Byte)(0x80 + (((val) >> (6 * (n))) & 0x3F)))
|
||||
|
||||
static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim)
|
||||
{
|
||||
@@ -82,7 +82,7 @@ static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim)
|
||||
if (val < 0x80)
|
||||
continue;
|
||||
|
||||
if (val < _UTF8_RANGE(1))
|
||||
if (val < MY_UTF8_RANGE(1))
|
||||
{
|
||||
size++;
|
||||
continue;
|
||||
@@ -90,7 +90,7 @@ static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim)
|
||||
|
||||
if (val >= 0xD800 && val < 0xDC00 && src != srcLim)
|
||||
{
|
||||
UInt32 c2 = *src;
|
||||
const UInt32 c2 = *src;
|
||||
if (c2 >= 0xDC00 && c2 < 0xE000)
|
||||
{
|
||||
src++;
|
||||
@@ -119,33 +119,33 @@ static Byte *Utf16_To_Utf8(Byte *dest, const UInt16 *src, const UInt16 *srcLim)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (val < _UTF8_RANGE(1))
|
||||
if (val < MY_UTF8_RANGE(1))
|
||||
{
|
||||
dest[0] = _UTF8_HEAD(1, val);
|
||||
dest[1] = _UTF8_CHAR(0, val);
|
||||
dest[0] = MY_UTF8_HEAD(1, val);
|
||||
dest[1] = MY_UTF8_CHAR(0, val);
|
||||
dest += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (val >= 0xD800 && val < 0xDC00 && src != srcLim)
|
||||
{
|
||||
UInt32 c2 = *src;
|
||||
const UInt32 c2 = *src;
|
||||
if (c2 >= 0xDC00 && c2 < 0xE000)
|
||||
{
|
||||
src++;
|
||||
val = (((val - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000;
|
||||
dest[0] = _UTF8_HEAD(3, val);
|
||||
dest[1] = _UTF8_CHAR(2, val);
|
||||
dest[2] = _UTF8_CHAR(1, val);
|
||||
dest[3] = _UTF8_CHAR(0, val);
|
||||
dest[0] = MY_UTF8_HEAD(3, val);
|
||||
dest[1] = MY_UTF8_CHAR(2, val);
|
||||
dest[2] = MY_UTF8_CHAR(1, val);
|
||||
dest[3] = MY_UTF8_CHAR(0, val);
|
||||
dest += 4;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
dest[0] = _UTF8_HEAD(2, val);
|
||||
dest[1] = _UTF8_CHAR(1, val);
|
||||
dest[2] = _UTF8_CHAR(0, val);
|
||||
dest[0] = MY_UTF8_HEAD(2, val);
|
||||
dest[1] = MY_UTF8_CHAR(1, val);
|
||||
dest[2] = MY_UTF8_CHAR(0, val);
|
||||
dest += 3;
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ static SRes Utf16_To_Utf8Buf(CBuf *dest, const UInt16 *src, size_t srcLen)
|
||||
#endif
|
||||
|
||||
static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s
|
||||
#ifndef _USE_UTF8
|
||||
#ifndef MY_USE_UTF8
|
||||
, UINT codePage
|
||||
#endif
|
||||
)
|
||||
@@ -171,7 +171,7 @@ static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s
|
||||
unsigned len = 0;
|
||||
for (len = 0; s[len] != 0; len++) {}
|
||||
|
||||
#ifndef _USE_UTF8
|
||||
#ifndef MY_USE_UTF8
|
||||
{
|
||||
const unsigned size = len * 3 + 100;
|
||||
if (!Buf_EnsureSize(buf, size))
|
||||
@@ -216,7 +216,7 @@ static WRes MyCreateDir(const UInt16 *name)
|
||||
CBuf buf;
|
||||
WRes res;
|
||||
Buf_Init(&buf);
|
||||
RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM));
|
||||
RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM))
|
||||
|
||||
res =
|
||||
#ifdef _WIN32
|
||||
@@ -239,7 +239,7 @@ static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name)
|
||||
CBuf buf;
|
||||
WRes res;
|
||||
Buf_Init(&buf);
|
||||
RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM));
|
||||
RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM))
|
||||
res = OutFile_Open(p, (const char *)buf.data);
|
||||
Buf_Free(&buf, &g_Alloc);
|
||||
return res;
|
||||
@@ -253,7 +253,7 @@ static SRes PrintString(const UInt16 *s)
|
||||
SRes res;
|
||||
Buf_Init(&buf);
|
||||
res = Utf16_To_Char(&buf, s
|
||||
#ifndef _USE_UTF8
|
||||
#ifndef MY_USE_UTF8
|
||||
, CP_OEMCP
|
||||
#endif
|
||||
);
|
||||
@@ -328,12 +328,12 @@ typedef struct _FILETIME
|
||||
|
||||
static LONG TIME_GetBias()
|
||||
{
|
||||
time_t utc = time(NULL);
|
||||
const time_t utc = time(NULL);
|
||||
struct tm *ptm = localtime(&utc);
|
||||
int localdaylight = ptm->tm_isdst; /* daylight for local timezone */
|
||||
const int localdaylight = ptm->tm_isdst; /* daylight for local timezone */
|
||||
ptm = gmtime(&utc);
|
||||
ptm->tm_isdst = localdaylight; /* use local daylight, not that of Greenwich */
|
||||
LONG bias = (int)(mktime(ptm)-utc);
|
||||
const LONG bias = (int)(mktime(ptm) - utc);
|
||||
return bias;
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ static BOOL WINAPI FileTimeToLocalFileTime(const FILETIME *fileTime, FILETIME *l
|
||||
{
|
||||
UInt64 v = GET_TIME_64(fileTime);
|
||||
v = (UInt64)((Int64)v - (Int64)TIME_GetBias() * TICKS_PER_SEC);
|
||||
SET_FILETIME(localFileTime, v);
|
||||
SET_FILETIME(localFileTime, v)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ static const UInt64 kUnixTimeOffset =
|
||||
|
||||
static Int64 Time_FileTimeToUnixTime64(const FILETIME *ft)
|
||||
{
|
||||
UInt64 winTime = GET_TIME_64(ft);
|
||||
const UInt64 winTime = GET_TIME_64(ft);
|
||||
return (Int64)(winTime / kNumTimeQuantumsInSecond) - (Int64)kUnixTimeOffset;
|
||||
}
|
||||
|
||||
@@ -384,8 +384,8 @@ static void FILETIME_To_timespec(const FILETIME *ft, struct MY_ST_TIMESPEC *ts)
|
||||
if (sec2 == sec)
|
||||
{
|
||||
ts->tv_sec = sec2;
|
||||
UInt64 winTime = GET_TIME_64(ft);
|
||||
ts->tv_nsec = (long)((winTime % 10000000) * 100);;
|
||||
const UInt64 winTime = GET_TIME_64(ft);
|
||||
ts->tv_nsec = (long)((winTime % 10000000) * 100);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -407,7 +407,7 @@ static WRes Set_File_FILETIME(const UInt16 *name, const FILETIME *mTime)
|
||||
CBuf buf;
|
||||
int res;
|
||||
Buf_Init(&buf);
|
||||
RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM));
|
||||
RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM))
|
||||
FILETIME_To_timespec(NULL, ×[0]);
|
||||
FILETIME_To_timespec(mTime, ×[1]);
|
||||
res = utimensat(AT_FDCWD, (const char *)buf.data, times, flags);
|
||||
@@ -461,7 +461,7 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nTime, char *s)
|
||||
ms[1] = 29;
|
||||
for (mon = 0;; mon++)
|
||||
{
|
||||
unsigned d = ms[mon];
|
||||
const unsigned d = ms[mon];
|
||||
if (v < d)
|
||||
break;
|
||||
v -= d;
|
||||
@@ -474,7 +474,7 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nTime, char *s)
|
||||
UIntToStr_2(s, sec); s[2] = 0;
|
||||
}
|
||||
|
||||
static void PrintLF()
|
||||
static void PrintLF(void)
|
||||
{
|
||||
Print("\n");
|
||||
}
|
||||
@@ -541,7 +541,7 @@ static void GetAttribString(UInt32 wa, BoolInt isDir, char *s)
|
||||
|
||||
// #define NUM_PARENTS_MAX 128
|
||||
|
||||
int MY_CDECL main(int numargs, char *args[])
|
||||
int Z7_CDECL main(int numargs, char *args[])
|
||||
{
|
||||
ISzAlloc allocImp;
|
||||
ISzAlloc allocTempImp;
|
||||
@@ -581,6 +581,7 @@ int MY_CDECL main(int numargs, char *args[])
|
||||
|
||||
allocImp = g_Alloc;
|
||||
allocTempImp = g_Alloc;
|
||||
// allocTempImp = g_Alloc_temp;
|
||||
|
||||
{
|
||||
WRes wres =
|
||||
@@ -611,7 +612,7 @@ int MY_CDECL main(int numargs, char *args[])
|
||||
{
|
||||
lookStream.bufSize = kInputBufSize;
|
||||
lookStream.realStream = &archiveStream.vt;
|
||||
LookToRead2_Init(&lookStream);
|
||||
LookToRead2_INIT(&lookStream)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,7 +768,7 @@ int MY_CDECL main(int numargs, char *args[])
|
||||
}
|
||||
else
|
||||
{
|
||||
WRes wres = OutFile_OpenUtf16(&outFile, destPath);
|
||||
const WRes wres = OutFile_OpenUtf16(&outFile, destPath);
|
||||
if (wres != 0)
|
||||
{
|
||||
PrintError_WRes("cannot open output file", wres);
|
||||
@@ -779,7 +780,7 @@ int MY_CDECL main(int numargs, char *args[])
|
||||
processedSize = outSizeProcessed;
|
||||
|
||||
{
|
||||
WRes wres = File_Write(&outFile, outBuffer + offset, &processedSize);
|
||||
const WRes wres = File_Write(&outFile, outBuffer + offset, &processedSize);
|
||||
if (wres != 0 || processedSize != outSizeProcessed)
|
||||
{
|
||||
PrintError_WRes("cannot write output file", wres);
|
||||
@@ -819,7 +820,7 @@ int MY_CDECL main(int numargs, char *args[])
|
||||
#endif
|
||||
|
||||
{
|
||||
WRes wres = File_Close(&outFile);
|
||||
const WRes wres = File_Close(&outFile);
|
||||
if (wres != 0)
|
||||
{
|
||||
PrintError_WRes("cannot close output file", wres);
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
/* Precomp.h -- StdAfx
|
||||
2013-06-16 : Igor Pavlov : Public domain */
|
||||
2023-03-04 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __7Z_PRECOMP_H
|
||||
#define __7Z_PRECOMP_H
|
||||
#ifndef ZIP7_INC_PRECOMP_H
|
||||
#define ZIP7_INC_PRECOMP_H
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||
#pragma warning(disable : 4464) // relative include path contains '..'
|
||||
#endif
|
||||
|
||||
#include "../../Compiler.h"
|
||||
#include "../../7zTypes.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CFLAGS = $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT
|
||||
CFLAGS = $(CFLAGS) -DZ7_PPMD_SUPPORT -DZ7_EXTRACT_ONLY
|
||||
|
||||
PROG = 7zDec.exe
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
PROG = 7zdec
|
||||
|
||||
LOCAL_FLAGS = -D_7ZIP_PPMD_SUPPPORT
|
||||
LOCAL_FLAGS = -DZ7_PPMD_SUPPORT -DZ7_EXTRACT_ONLY
|
||||
|
||||
include ../../../CPP/7zip/LzmaDec_gcc.mak
|
||||
|
||||
@@ -19,8 +19,6 @@ OBJS = \
|
||||
$O/Ppmd7Dec.o \
|
||||
$O/7zCrc.o \
|
||||
$O/7zCrcOpt.o \
|
||||
$O/Sha256.o \
|
||||
$O/Sha256Opt.o \
|
||||
$O/7zAlloc.o \
|
||||
$O/7zArcIn.o \
|
||||
$O/7zBuf.o \
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
/* 7zipInstall.c - 7-Zip Installer
|
||||
2021-09-02 : Igor Pavlov : Public domain */
|
||||
2023-04-04 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#define SZ_ERROR_ABORT 100
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "../../7zWindows.h"
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1600
|
||||
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#ifdef Z7_OLD_WIN_SDK
|
||||
struct IShellView;
|
||||
#define SHFOLDERAPI EXTERN_C DECLSPEC_IMPORT HRESULT STDAPICALLTYPE
|
||||
SHFOLDERAPI SHGetFolderPathW(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
|
||||
#define BIF_NEWDIALOGSTYLE 0x0040 // Use the new dialog layout with the ability to resize
|
||||
typedef enum {
|
||||
SHGFP_TYPE_CURRENT = 0, // current value for user, verify it exists
|
||||
SHGFP_TYPE_DEFAULT = 1, // default value, may not exist
|
||||
} SHGFP_TYPE;
|
||||
#endif
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#include <shlobj.h>
|
||||
#else
|
||||
#include <ShlObj.h>
|
||||
#endif
|
||||
|
||||
#include "../../7z.h"
|
||||
#include "../../7zAlloc.h"
|
||||
@@ -22,36 +37,46 @@
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#if (defined(__GNUC__) && (__GNUC__ >= 8)) || defined(__clang__)
|
||||
// #pragma GCC diagnostic ignored "-Wcast-function-type"
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
typedef void (*Z7_voidFunction)(void);
|
||||
#define MY_CAST_FUNC (Z7_voidFunction)
|
||||
#elif defined(_MSC_VER) && _MSC_VER > 1920
|
||||
#define MY_CAST_FUNC (void *)
|
||||
// #pragma warning(disable : 4191) // 'type cast': unsafe conversion from 'FARPROC' to 'void (__cdecl *)()'
|
||||
#else
|
||||
#define MY_CAST_FUNC
|
||||
#endif
|
||||
|
||||
#define LLL_(quote) L##quote
|
||||
#define LLL(quote) LLL_(quote)
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
#define wcscat lstrcatW
|
||||
#define wcslen lstrlenW
|
||||
#define wcslen (size_t)lstrlenW
|
||||
#define wcscpy lstrcpyW
|
||||
// wcsncpy() and lstrcpynW() work differently. We don't use them.
|
||||
|
||||
|
||||
#define kInputBufSize ((size_t)1 << 18)
|
||||
|
||||
|
||||
#define _7ZIP_CUR_VER ((MY_VER_MAJOR << 16) | MY_VER_MINOR)
|
||||
#define _7ZIP_DLL_VER_COMPAT ((16 << 16) | 3)
|
||||
#define Z7_7ZIP_CUR_VER ((MY_VER_MAJOR << 16) | MY_VER_MINOR)
|
||||
#define Z7_7ZIP_DLL_VER_COMPAT ((16 << 16) | 3)
|
||||
|
||||
static LPCSTR const k_7zip = "7-Zip";
|
||||
|
||||
static LPCWSTR const k_Reg_Software_7zip = L"Software\\7-Zip";
|
||||
|
||||
// #define _64BIT_INSTALLER 1
|
||||
// #define Z7_64BIT_INSTALLER 1
|
||||
|
||||
#ifdef _WIN64
|
||||
#define _64BIT_INSTALLER 1
|
||||
#define Z7_64BIT_INSTALLER 1
|
||||
#endif
|
||||
|
||||
#define k_7zip_with_Ver_base L"7-Zip " LLL(MY_VERSION)
|
||||
|
||||
#ifdef _64BIT_INSTALLER
|
||||
#ifdef Z7_64BIT_INSTALLER
|
||||
|
||||
// #define USE_7ZIP_32_DLL
|
||||
|
||||
@@ -70,7 +95,7 @@ static LPCWSTR const k_Reg_Software_7zip = L"Software\\7-Zip";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define k_7zip_with_Ver k_7zip_with_Ver_base k_Postfix
|
||||
#define k_7zip_with_Ver k_7zip_with_Ver_base k_Postfix
|
||||
|
||||
|
||||
static LPCWSTR const k_7zip_with_Ver_str = k_7zip_with_Ver;
|
||||
@@ -80,14 +105,14 @@ static LPCWSTR const k_7zip_Setup = k_7zip_with_Ver L" Setup";
|
||||
static LPCWSTR const k_Reg_Path = L"Path";
|
||||
|
||||
static LPCWSTR const k_Reg_Path32 = L"Path"
|
||||
#ifdef _64BIT_INSTALLER
|
||||
#ifdef Z7_64BIT_INSTALLER
|
||||
L"64"
|
||||
#else
|
||||
L"32"
|
||||
#endif
|
||||
;
|
||||
|
||||
#if defined(_64BIT_INSTALLER) && !defined(_WIN64)
|
||||
#if defined(Z7_64BIT_INSTALLER) && !defined(_WIN64)
|
||||
#define k_Reg_WOW_Flag KEY_WOW64_64KEY
|
||||
#else
|
||||
#define k_Reg_WOW_Flag 0
|
||||
@@ -122,8 +147,6 @@ static WCHAR cmdError[MAX_PATH + 4];
|
||||
static WCHAR path[MAX_PATH * 2 + 40];
|
||||
|
||||
|
||||
// #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c)))
|
||||
|
||||
|
||||
static void CpyAscii(wchar_t *dest, const char *s)
|
||||
{
|
||||
@@ -196,9 +219,12 @@ static DWORD GetFileVersion(LPCWSTR s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
my_GetFileVersionInfoSizeW = (Func_GetFileVersionInfoSizeW)GetProcAddress(g_version_dll_hModule, "GetFileVersionInfoSizeW");
|
||||
my_GetFileVersionInfoW = (Func_GetFileVersionInfoW)GetProcAddress(g_version_dll_hModule, "GetFileVersionInfoW");
|
||||
my_VerQueryValueW = (Func_VerQueryValueW)GetProcAddress(g_version_dll_hModule, "VerQueryValueW");
|
||||
my_GetFileVersionInfoSizeW = (Func_GetFileVersionInfoSizeW) MY_CAST_FUNC GetProcAddress(g_version_dll_hModule,
|
||||
"GetFileVersionInfoSizeW");
|
||||
my_GetFileVersionInfoW = (Func_GetFileVersionInfoW) MY_CAST_FUNC GetProcAddress(g_version_dll_hModule,
|
||||
"GetFileVersionInfoW");
|
||||
my_VerQueryValueW = (Func_VerQueryValueW) MY_CAST_FUNC GetProcAddress(g_version_dll_hModule,
|
||||
"VerQueryValueW");
|
||||
|
||||
if (!my_GetFileVersionInfoSizeW
|
||||
|| !my_GetFileVersionInfoW
|
||||
@@ -249,7 +275,7 @@ static int ReverseFind_PathSepar(const wchar_t *s)
|
||||
}
|
||||
}
|
||||
|
||||
static WRes CreateComplexDir()
|
||||
static WRes CreateComplexDir(void)
|
||||
{
|
||||
WCHAR s[MAX_PATH + 10];
|
||||
|
||||
@@ -283,7 +309,7 @@ static WRes CreateComplexDir()
|
||||
{
|
||||
size_t len = wcslen(s);
|
||||
{
|
||||
int pos = ReverseFind_PathSepar(s);
|
||||
const int pos = ReverseFind_PathSepar(s);
|
||||
if (pos < 0)
|
||||
return wres;
|
||||
if ((unsigned)pos < prefixSize)
|
||||
@@ -293,7 +319,7 @@ static WRes CreateComplexDir()
|
||||
if (len == 1)
|
||||
return 0;
|
||||
s[pos] = 0;
|
||||
len = pos;
|
||||
len = (unsigned)pos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +331,7 @@ static WRes CreateComplexDir()
|
||||
break;
|
||||
if (wres == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
DWORD attrib = GetFileAttributesW(s);
|
||||
const DWORD attrib = GetFileAttributesW(s);
|
||||
if (attrib != INVALID_FILE_ATTRIBUTES)
|
||||
if ((attrib & FILE_ATTRIBUTE_DIRECTORY) == 0)
|
||||
return ERROR_ALREADY_EXISTS;
|
||||
@@ -319,7 +345,7 @@ static WRes CreateComplexDir()
|
||||
|
||||
for (;;)
|
||||
{
|
||||
size_t pos = wcslen(s);
|
||||
const size_t pos = wcslen(s);
|
||||
if (pos >= len)
|
||||
return 0;
|
||||
s[pos] = CHAR_PATH_SEPARATOR;
|
||||
@@ -335,7 +361,7 @@ static int MyRegistry_QueryString(HKEY hKey, LPCWSTR name, LPWSTR dest)
|
||||
{
|
||||
DWORD cnt = MAX_PATH * sizeof(name[0]);
|
||||
DWORD type = 0;
|
||||
LONG res = RegQueryValueExW(hKey, name, NULL, &type, (LPBYTE)dest, (DWORD *)&cnt);
|
||||
const LONG res = RegQueryValueExW(hKey, name, NULL, &type, (LPBYTE)dest, &cnt);
|
||||
if (type != REG_SZ)
|
||||
return False;
|
||||
return res == ERROR_SUCCESS;
|
||||
@@ -344,11 +370,11 @@ static int MyRegistry_QueryString(HKEY hKey, LPCWSTR name, LPWSTR dest)
|
||||
static int MyRegistry_QueryString2(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest)
|
||||
{
|
||||
HKEY key = 0;
|
||||
LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag, &key);
|
||||
const LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag, &key);
|
||||
if (res != ERROR_SUCCESS)
|
||||
return False;
|
||||
{
|
||||
BoolInt res2 = MyRegistry_QueryString(key, valName, dest);
|
||||
const BoolInt res2 = MyRegistry_QueryString(key, valName, dest);
|
||||
RegCloseKey(key);
|
||||
return res2;
|
||||
}
|
||||
@@ -546,7 +572,7 @@ static void NormalizePrefix(WCHAR *s)
|
||||
|
||||
for (;; i++)
|
||||
{
|
||||
wchar_t c = s[i];
|
||||
const wchar_t c = s[i];
|
||||
if (c == 0)
|
||||
break;
|
||||
if (c == '/')
|
||||
@@ -583,7 +609,7 @@ static LPCWSTR FindSubString(LPCWSTR s1, const char *s2)
|
||||
return NULL;
|
||||
for (i = 0;; i++)
|
||||
{
|
||||
Byte b = s2[i];
|
||||
const char b = s2[i];
|
||||
if (b == 0)
|
||||
return s1;
|
||||
if (MyWCharLower_Ascii(s1[i]) != (Byte)MyCharLower_Ascii(b))
|
||||
@@ -606,7 +632,7 @@ static void Set7zipPostfix(WCHAR *s)
|
||||
|
||||
static int Install(void);
|
||||
|
||||
static void OnClose()
|
||||
static void OnClose(void)
|
||||
{
|
||||
if (g_Install_was_Pressed && !g_Finished)
|
||||
{
|
||||
@@ -620,7 +646,13 @@ static void OnClose()
|
||||
g_HWND = NULL;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK MyDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
static
|
||||
#ifdef Z7_OLD_WIN_SDK
|
||||
BOOL
|
||||
#else
|
||||
INT_PTR
|
||||
#endif
|
||||
CALLBACK MyDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// UNUSED_VAR(hwnd)
|
||||
UNUSED_VAR(lParam)
|
||||
@@ -726,7 +758,7 @@ static LONG SetRegKey_Path2(HKEY parentKey)
|
||||
return res;
|
||||
}
|
||||
|
||||
static void SetRegKey_Path()
|
||||
static void SetRegKey_Path(void)
|
||||
{
|
||||
SetRegKey_Path2(HKEY_CURRENT_USER);
|
||||
SetRegKey_Path2(HKEY_LOCAL_MACHINE);
|
||||
@@ -824,7 +856,7 @@ static void SetShellProgramsGroup(HWND hwndOwner)
|
||||
static LPCWSTR const k_Shell_Approved = L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved";
|
||||
static LPCWSTR const k_7zip_ShellExtension = L"7-Zip Shell Extension";
|
||||
|
||||
static void WriteCLSID()
|
||||
static void WriteCLSID(void)
|
||||
{
|
||||
HKEY destKey;
|
||||
LONG res;
|
||||
@@ -875,12 +907,12 @@ static LPCSTR const k_ShellEx_Items[] =
|
||||
, "Drive\\shellex\\DragDropHandlers"
|
||||
};
|
||||
|
||||
static void WriteShellEx()
|
||||
static void WriteShellEx(void)
|
||||
{
|
||||
unsigned i;
|
||||
WCHAR destPath[MAX_PATH + 40];
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(k_ShellEx_Items); i++)
|
||||
for (i = 0; i < Z7_ARRAY_SIZE(k_ShellEx_Items); i++)
|
||||
{
|
||||
CpyAscii(destPath, k_ShellEx_Items[i]);
|
||||
CatAscii(destPath, "\\7-Zip");
|
||||
@@ -964,7 +996,7 @@ static const wchar_t *GetCmdParam(const wchar_t *s)
|
||||
quoteMode = !quoteMode;
|
||||
continue;
|
||||
}
|
||||
if (pos >= ARRAY_SIZE(cmd) - 1)
|
||||
if (pos >= Z7_ARRAY_SIZE(cmd) - 1)
|
||||
exit(1);
|
||||
cmd[pos++] = c;
|
||||
}
|
||||
@@ -1022,7 +1054,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
for (;;)
|
||||
{
|
||||
{
|
||||
wchar_t c = *s;
|
||||
const wchar_t c = *s;
|
||||
if (c == 0)
|
||||
break;
|
||||
if (c == ' ')
|
||||
@@ -1066,11 +1098,12 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_64BIT_INSTALLER) && !defined(_WIN64)
|
||||
#if defined(Z7_64BIT_INSTALLER) && !defined(_WIN64)
|
||||
{
|
||||
BOOL isWow64 = FALSE;
|
||||
Func_IsWow64Process func_IsWow64Process = (Func_IsWow64Process)
|
||||
GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "IsWow64Process");
|
||||
const Func_IsWow64Process func_IsWow64Process = (Func_IsWow64Process)
|
||||
MY_CAST_FUNC GetProcAddress(GetModuleHandleW(L"kernel32.dll"),
|
||||
"IsWow64Process");
|
||||
|
||||
if (func_IsWow64Process)
|
||||
func_IsWow64Process(GetCurrentProcess(), &isWow64);
|
||||
@@ -1089,7 +1122,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
{
|
||||
HKEY key = 0;
|
||||
BoolInt ok = False;
|
||||
LONG res = RegOpenKeyExW(HKEY_CURRENT_USER, k_Reg_Software_7zip, 0, KEY_READ | k_Reg_WOW_Flag, &key);
|
||||
const LONG res = RegOpenKeyExW(HKEY_CURRENT_USER, k_Reg_Software_7zip, 0, KEY_READ | k_Reg_WOW_Flag, &key);
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
ok = MyRegistry_QueryString(key, k_Reg_Path32, path);
|
||||
@@ -1105,7 +1138,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
CpyAscii(path, "\\Program Files\\");
|
||||
#else
|
||||
|
||||
#ifdef _64BIT_INSTALLER
|
||||
#ifdef Z7_64BIT_INSTALLER
|
||||
{
|
||||
DWORD ttt = GetEnvironmentVariableW(L"ProgramW6432", path, MAX_PATH);
|
||||
if (ttt == 0 || ttt > MAX_PATH)
|
||||
@@ -1146,7 +1179,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
return 1;
|
||||
|
||||
{
|
||||
HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));
|
||||
const HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));
|
||||
// SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon);
|
||||
SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon);
|
||||
}
|
||||
@@ -1240,7 +1273,7 @@ static int Install(void)
|
||||
allocTempImp.Free = SzFreeTemp;
|
||||
|
||||
{
|
||||
DWORD len = GetModuleFileNameW(NULL, sfxPath, MAX_PATH);
|
||||
const DWORD len = GetModuleFileNameW(NULL, sfxPath, MAX_PATH);
|
||||
if (len == 0 || len > MAX_PATH)
|
||||
return 1;
|
||||
}
|
||||
@@ -1282,7 +1315,7 @@ if (res == SZ_OK)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
wchar_t c = path[i++];
|
||||
const wchar_t c = path[i++];
|
||||
if (c == 0)
|
||||
break;
|
||||
if (c != ' ')
|
||||
@@ -1314,7 +1347,7 @@ if (res == SZ_OK)
|
||||
{
|
||||
lookStream.bufSize = kInputBufSize;
|
||||
lookStream.realStream = &archiveStream.vt;
|
||||
LookToRead2_Init(&lookStream);
|
||||
LookToRead2_INIT(&lookStream)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1368,7 +1401,7 @@ if (res == SZ_OK)
|
||||
}
|
||||
|
||||
{
|
||||
size_t len = SzArEx_GetFileNameUtf16(&db, i, NULL);
|
||||
const size_t len = SzArEx_GetFileNameUtf16(&db, i, NULL);
|
||||
if (len >= MAX_PATH)
|
||||
{
|
||||
res = SZ_ERROR_FAIL;
|
||||
@@ -1464,8 +1497,8 @@ if (res == SZ_OK)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
DWORD ver = GetFileVersion(path);
|
||||
fileLevel = ((ver < _7ZIP_DLL_VER_COMPAT || ver > _7ZIP_CUR_VER) ? 2 : 1);
|
||||
const DWORD ver = GetFileVersion(path);
|
||||
fileLevel = ((ver < Z7_7ZIP_DLL_VER_COMPAT || ver > Z7_7ZIP_CUR_VER) ? 2 : 1);
|
||||
tempIndex++;
|
||||
continue;
|
||||
}
|
||||
@@ -1533,7 +1566,7 @@ if (res == SZ_OK)
|
||||
#endif
|
||||
|
||||
{
|
||||
SRes winRes2 = File_Close(&outFile);
|
||||
const WRes winRes2 = File_Close(&outFile);
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
if (winRes2 != 0)
|
||||
|
||||
@@ -152,6 +152,10 @@ SOURCE=..\..\7zVersion.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\7zWindows.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Bcj2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -220,6 +224,10 @@ SOURCE=..\..\LzmaDec.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compiler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Precomp.c
|
||||
# ADD CPP /Yc"Precomp.h"
|
||||
# End Source File
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
/* Precomp.h -- StdAfx
|
||||
2015-05-24 : Igor Pavlov : Public domain */
|
||||
2023-03-04 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __7Z_PRECOMP_H
|
||||
#define __7Z_PRECOMP_H
|
||||
#ifndef ZIP7_INC_PRECOMP_H
|
||||
#define ZIP7_INC_PRECOMP_H
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||
#pragma warning(disable : 4464) // relative include path contains '..'
|
||||
#endif
|
||||
|
||||
#include "../../Compiler.h"
|
||||
|
||||
#include "../../7zTypes.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
PROG = 7zipInstall.exe
|
||||
MY_FIXED = 1
|
||||
|
||||
!IFDEF _64BIT_INSTALLER
|
||||
CFLAGS = $(CFLAGS) -D_64BIT_INSTALLER
|
||||
!IFDEF Z7_64BIT_INSTALLER
|
||||
CFLAGS = $(CFLAGS) -DZ7_64BIT_INSTALLER
|
||||
!ENDIF
|
||||
|
||||
CFLAGS = $(CFLAGS) -D_LZMA_SIZE_OPT
|
||||
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-D_7Z_NO_METHOD_LZMA2 \
|
||||
-D_7Z_NO_METHODS_FILTERS
|
||||
-DZ7_LZMA_SIZE_OPT \
|
||||
-DZ7_NO_METHOD_LZMA2 \
|
||||
-DZ7_NO_METHODS_FILTERS \
|
||||
-DZ7_USE_NATIVE_BRANCH_FILTER \
|
||||
-DZ7_EXTRACT_ONLY \
|
||||
|
||||
MAIN_OBJS = \
|
||||
$O\7zipInstall.obj \
|
||||
@@ -25,6 +26,7 @@ C_OBJS = \
|
||||
$O\7zDec.obj \
|
||||
$O\7zStream.obj \
|
||||
$O\Bcj2.obj \
|
||||
$O\Bra.obj \
|
||||
$O\CpuArch.obj \
|
||||
$O\DllSecur.obj \
|
||||
$O\LzmaDec.obj \
|
||||
|
||||
@@ -1,38 +1,66 @@
|
||||
/* 7zipUninstall.c - 7-Zip Uninstaller
|
||||
2021-11-24 : Igor Pavlov : Public domain */
|
||||
2022-07-15 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
|
||||
#pragma warning(disable : 4011) // vs2010: identifier truncated to _CRT_SECURE_CPP_OVERLOAD_SECURE
|
||||
#endif
|
||||
|
||||
// #define SZ_ERROR_ABORT 100
|
||||
|
||||
#include <windows.h>
|
||||
#include "../../7zWindows.h"
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1600
|
||||
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
|
||||
#endif
|
||||
|
||||
#ifdef Z7_OLD_WIN_SDK
|
||||
struct IShellView;
|
||||
#define SHFOLDERAPI EXTERN_C DECLSPEC_IMPORT HRESULT STDAPICALLTYPE
|
||||
SHFOLDERAPI SHGetFolderPathW(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
|
||||
#define BIF_NEWDIALOGSTYLE 0x0040 // Use the new dialog layout with the ability to resize
|
||||
typedef enum {
|
||||
SHGFP_TYPE_CURRENT = 0, // current value for user, verify it exists
|
||||
SHGFP_TYPE_DEFAULT = 1, // default value, may not exist
|
||||
} SHGFP_TYPE;
|
||||
#endif
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#include <shlobj.h>
|
||||
#else
|
||||
#include <ShlObj.h>
|
||||
#endif
|
||||
|
||||
#include "../../7zVersion.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#if (defined(__GNUC__) && (__GNUC__ >= 8)) || defined(__clang__)
|
||||
// #pragma GCC diagnostic ignored "-Wcast-function-type"
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER > 1920
|
||||
#define MY_CAST_FUNC (void *)
|
||||
// #pragma warning(disable : 4191) // 'type cast': unsafe conversion from 'FARPROC' to 'void (__cdecl *)()'
|
||||
#else
|
||||
#define MY_CAST_FUNC
|
||||
#endif
|
||||
|
||||
|
||||
#define LLL_(quote) L##quote
|
||||
#define LLL(quote) LLL_(quote)
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#define wcscat lstrcatW
|
||||
#define wcslen (size_t)lstrlenW
|
||||
#define wcscpy lstrcpyW
|
||||
|
||||
// static LPCWSTR const k_7zip = L"7-Zip";
|
||||
|
||||
// #define _64BIT_INSTALLER 1
|
||||
// #define Z7_64BIT_INSTALLER 1
|
||||
|
||||
#ifdef _WIN64
|
||||
#define _64BIT_INSTALLER 1
|
||||
#define Z7_64BIT_INSTALLER 1
|
||||
#endif
|
||||
|
||||
#define k_7zip_with_Ver_base L"7-Zip " LLL(MY_VERSION)
|
||||
|
||||
#ifdef _64BIT_INSTALLER
|
||||
#ifdef Z7_64BIT_INSTALLER
|
||||
|
||||
// #define USE_7ZIP_32_DLL
|
||||
|
||||
@@ -60,14 +88,14 @@ static LPCWSTR const k_Reg_Software_7zip = L"Software\\7-Zip";
|
||||
static LPCWSTR const k_Reg_Path = L"Path";
|
||||
|
||||
static LPCWSTR const k_Reg_Path32 = L"Path"
|
||||
#ifdef _64BIT_INSTALLER
|
||||
#ifdef Z7_64BIT_INSTALLER
|
||||
L"64"
|
||||
#else
|
||||
L"32"
|
||||
#endif
|
||||
;
|
||||
|
||||
#if defined(_64BIT_INSTALLER) && !defined(_WIN64)
|
||||
#if defined(Z7_64BIT_INSTALLER) && !defined(_WIN64)
|
||||
#define k_Reg_WOW_Flag KEY_WOW64_64KEY
|
||||
#else
|
||||
#define k_Reg_WOW_Flag 0
|
||||
@@ -112,14 +140,14 @@ static WCHAR copyPath[MAX_PATH * 2 + 40];
|
||||
|
||||
static LPCWSTR const kUninstallExe = L"Uninstall.exe";
|
||||
|
||||
#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c)))
|
||||
#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c)))
|
||||
|
||||
|
||||
static void CpyAscii(wchar_t *dest, const char *s)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
Byte b = (Byte)*s++;
|
||||
const Byte b = (Byte)*s++;
|
||||
*dest++ = b;
|
||||
if (b == 0)
|
||||
return;
|
||||
@@ -169,7 +197,7 @@ static BoolInt IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_
|
||||
for (;;)
|
||||
{
|
||||
wchar_t c1;
|
||||
wchar_t c2 = *s2++;
|
||||
const wchar_t c2 = *s2++;
|
||||
if (c2 == 0)
|
||||
return True;
|
||||
c1 = *s1++;
|
||||
@@ -180,7 +208,7 @@ static BoolInt IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_
|
||||
|
||||
static void NormalizePrefix(WCHAR *s)
|
||||
{
|
||||
size_t len = wcslen(s);
|
||||
const size_t len = wcslen(s);
|
||||
if (len != 0)
|
||||
if (s[len - 1] != WCHAR_PATH_SEPARATOR)
|
||||
{
|
||||
@@ -193,7 +221,7 @@ static int MyRegistry_QueryString(HKEY hKey, LPCWSTR name, LPWSTR dest)
|
||||
{
|
||||
DWORD cnt = MAX_PATH * sizeof(name[0]);
|
||||
DWORD type = 0;
|
||||
LONG res = RegQueryValueExW(hKey, name, NULL, &type, (LPBYTE)dest, (DWORD *)&cnt);
|
||||
const LONG res = RegQueryValueExW(hKey, name, NULL, &type, (LPBYTE)dest, &cnt);
|
||||
if (type != REG_SZ)
|
||||
return False;
|
||||
return res == ERROR_SUCCESS;
|
||||
@@ -202,11 +230,11 @@ static int MyRegistry_QueryString(HKEY hKey, LPCWSTR name, LPWSTR dest)
|
||||
static int MyRegistry_QueryString2(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest)
|
||||
{
|
||||
HKEY key = 0;
|
||||
LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag, &key);
|
||||
const LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag, &key);
|
||||
if (res != ERROR_SUCCESS)
|
||||
return False;
|
||||
{
|
||||
BoolInt res2 = MyRegistry_QueryString(key, valName, dest);
|
||||
const BoolInt res2 = MyRegistry_QueryString(key, valName, dest);
|
||||
RegCloseKey(key);
|
||||
return res2;
|
||||
}
|
||||
@@ -233,11 +261,11 @@ static LONG MyRegistry_DeleteKey(HKEY parentKey, LPCWSTR name)
|
||||
static int MyRegistry_QueryString2_32(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest)
|
||||
{
|
||||
HKEY key = 0;
|
||||
LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag_32, &key);
|
||||
const LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag_32, &key);
|
||||
if (res != ERROR_SUCCESS)
|
||||
return False;
|
||||
{
|
||||
BoolInt res2 = MyRegistry_QueryString(key, valName, dest);
|
||||
const BoolInt res2 = MyRegistry_QueryString(key, valName, dest);
|
||||
RegCloseKey(key);
|
||||
return res2;
|
||||
}
|
||||
@@ -278,7 +306,7 @@ static void MyReg_DeleteVal_Path_if_Equal(HKEY hKey, LPCWSTR name)
|
||||
static void SetRegKey_Path2(HKEY parentKey)
|
||||
{
|
||||
HKEY key = 0;
|
||||
LONG res = MyRegistry_OpenKey_ReadWrite(parentKey, k_Reg_Software_7zip, &key);
|
||||
const LONG res = MyRegistry_OpenKey_ReadWrite(parentKey, k_Reg_Software_7zip, &key);
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
MyReg_DeleteVal_Path_if_Equal(key, k_Reg_Path32);
|
||||
@@ -289,7 +317,7 @@ static void SetRegKey_Path2(HKEY parentKey)
|
||||
}
|
||||
}
|
||||
|
||||
static void SetRegKey_Path()
|
||||
static void SetRegKey_Path(void)
|
||||
{
|
||||
SetRegKey_Path2(HKEY_CURRENT_USER);
|
||||
SetRegKey_Path2(HKEY_LOCAL_MACHINE);
|
||||
@@ -422,7 +450,7 @@ static BoolInt AreEqual_Path_PrefixName(const wchar_t *s, const wchar_t *prefix,
|
||||
return AreStringsEqual_NoCase(s + wcslen(prefix), name);
|
||||
}
|
||||
|
||||
static void WriteCLSID()
|
||||
static void WriteCLSID(void)
|
||||
{
|
||||
WCHAR s[MAX_PATH + 30];
|
||||
|
||||
@@ -431,14 +459,14 @@ static void WriteCLSID()
|
||||
if (AreEqual_Path_PrefixName(s, path, L"7-zip.dll"))
|
||||
{
|
||||
{
|
||||
LONG res = MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc);
|
||||
const LONG res = MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc);
|
||||
if (res == ERROR_SUCCESS)
|
||||
MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip);
|
||||
}
|
||||
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < ARRAY_SIZE(k_ShellEx_Items); i++)
|
||||
for (i = 0; i < Z7_ARRAY_SIZE(k_ShellEx_Items); i++)
|
||||
{
|
||||
WCHAR destPath[MAX_PATH];
|
||||
CpyAscii(destPath, k_ShellEx_Items[i]);
|
||||
@@ -450,7 +478,7 @@ static void WriteCLSID()
|
||||
|
||||
{
|
||||
HKEY destKey = 0;
|
||||
LONG res = MyRegistry_OpenKey_ReadWrite(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey);
|
||||
const LONG res = MyRegistry_OpenKey_ReadWrite(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey);
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
RegDeleteValueW(destKey, k_7zip_CLSID);
|
||||
@@ -468,14 +496,14 @@ static void WriteCLSID()
|
||||
if (AreEqual_Path_PrefixName(s, path, L"7-zip32.dll"))
|
||||
{
|
||||
{
|
||||
LONG res = MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc);
|
||||
const LONG res = MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc);
|
||||
if (res == ERROR_SUCCESS)
|
||||
MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip);
|
||||
}
|
||||
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < ARRAY_SIZE(k_ShellEx_Items); i++)
|
||||
for (i = 0; i < Z7_ARRAY_SIZE(k_ShellEx_Items); i++)
|
||||
{
|
||||
WCHAR destPath[MAX_PATH];
|
||||
CpyAscii(destPath, k_ShellEx_Items[i]);
|
||||
@@ -487,7 +515,7 @@ static void WriteCLSID()
|
||||
|
||||
{
|
||||
HKEY destKey = 0;
|
||||
LONG res = MyRegistry_OpenKey_ReadWrite_32(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey);
|
||||
const LONG res = MyRegistry_OpenKey_ReadWrite_32(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey);
|
||||
if (res == ERROR_SUCCESS)
|
||||
{
|
||||
RegDeleteValueW(destKey, k_7zip_CLSID);
|
||||
@@ -522,7 +550,7 @@ static const wchar_t *GetCmdParam(const wchar_t *s)
|
||||
BoolInt quoteMode = False;
|
||||
for (;; s++)
|
||||
{
|
||||
wchar_t c = *s;
|
||||
const wchar_t c = *s;
|
||||
if (c == 0 || (c == L' ' && !quoteMode))
|
||||
break;
|
||||
if (c == L'\"')
|
||||
@@ -530,7 +558,7 @@ static const wchar_t *GetCmdParam(const wchar_t *s)
|
||||
quoteMode = !quoteMode;
|
||||
continue;
|
||||
}
|
||||
if (pos >= ARRAY_SIZE(cmd) - 1)
|
||||
if (pos >= Z7_ARRAY_SIZE(cmd) - 1)
|
||||
exit(1);
|
||||
cmd[pos++] = c;
|
||||
}
|
||||
@@ -554,7 +582,7 @@ static void RemoveQuotes(wchar_t *s)
|
||||
}
|
||||
*/
|
||||
|
||||
static BoolInt DoesFileOrDirExist()
|
||||
static BoolInt DoesFileOrDirExist(void)
|
||||
{
|
||||
return (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES);
|
||||
}
|
||||
@@ -569,7 +597,7 @@ static BOOL RemoveFileAfterReboot2(const WCHAR *s)
|
||||
#endif
|
||||
}
|
||||
|
||||
static BOOL RemoveFileAfterReboot()
|
||||
static BOOL RemoveFileAfterReboot(void)
|
||||
{
|
||||
return RemoveFileAfterReboot2(path);
|
||||
}
|
||||
@@ -580,7 +608,7 @@ static BoolInt IsThereSpace(const wchar_t *s)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
wchar_t c = *s++;
|
||||
const wchar_t c = *s++;
|
||||
if (c == 0)
|
||||
return False;
|
||||
if (c == ' ')
|
||||
@@ -590,7 +618,7 @@ static BoolInt IsThereSpace(const wchar_t *s)
|
||||
|
||||
static void AddPathParam(wchar_t *dest, const wchar_t *src)
|
||||
{
|
||||
BoolInt needQuote = IsThereSpace(src);
|
||||
const BoolInt needQuote = IsThereSpace(src);
|
||||
if (needQuote)
|
||||
CatAscii(dest, "\"");
|
||||
wcscat(dest, src);
|
||||
@@ -614,9 +642,9 @@ static BoolInt GetErrorMessage(DWORD errorCode, WCHAR *message)
|
||||
return True;
|
||||
}
|
||||
|
||||
static BOOL RemoveDir()
|
||||
static BOOL RemoveDir(void)
|
||||
{
|
||||
DWORD attrib = GetFileAttributesW(path);
|
||||
const DWORD attrib = GetFileAttributesW(path);
|
||||
if (attrib == INVALID_FILE_ATTRIBUTES)
|
||||
return TRUE;
|
||||
if (RemoveDirectoryW(path))
|
||||
@@ -666,7 +694,7 @@ static const char * const k_Names =
|
||||
|
||||
|
||||
|
||||
static int Install()
|
||||
static int Install(void)
|
||||
{
|
||||
SRes res = SZ_OK;
|
||||
WRes winRes = 0;
|
||||
@@ -720,7 +748,7 @@ static int Install()
|
||||
|
||||
for (;;)
|
||||
{
|
||||
char c = *curName;
|
||||
const char c = *curName;
|
||||
if (c == 0)
|
||||
break;
|
||||
curName++;
|
||||
@@ -739,7 +767,7 @@ static int Install()
|
||||
SetWindowTextW(g_InfoLine_HWND, temp);
|
||||
|
||||
{
|
||||
DWORD attrib = GetFileAttributesW(path);
|
||||
const DWORD attrib = GetFileAttributesW(path);
|
||||
if (attrib == INVALID_FILE_ATTRIBUTES)
|
||||
continue;
|
||||
if (attrib & FILE_ATTRIBUTE_READONLY)
|
||||
@@ -799,7 +827,7 @@ static int Install()
|
||||
}
|
||||
|
||||
|
||||
static void OnClose()
|
||||
static void OnClose(void)
|
||||
{
|
||||
if (g_Install_was_Pressed && !g_Finished)
|
||||
{
|
||||
@@ -813,7 +841,13 @@ static void OnClose()
|
||||
g_HWND = NULL;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK MyDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
static
|
||||
#ifdef Z7_OLD_WIN_SDK
|
||||
BOOL
|
||||
#else
|
||||
INT_PTR
|
||||
#endif
|
||||
CALLBACK MyDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
UNUSED_VAR(lParam)
|
||||
|
||||
@@ -901,7 +935,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
#endif
|
||||
|
||||
#ifndef UNDER_CE
|
||||
func_RegDeleteKeyExW = (Func_RegDeleteKeyExW)
|
||||
func_RegDeleteKeyExW = (Func_RegDeleteKeyExW) MY_CAST_FUNC
|
||||
GetProcAddress(GetModuleHandleW(L"advapi32.dll"), "RegDeleteKeyExW");
|
||||
#endif
|
||||
|
||||
@@ -972,7 +1006,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
|
||||
{
|
||||
wchar_t *name;
|
||||
DWORD len = GetModuleFileNameW(NULL, modulePath, MAX_PATH);
|
||||
const DWORD len = GetModuleFileNameW(NULL, modulePath, MAX_PATH);
|
||||
if (len == 0 || len > MAX_PATH)
|
||||
return 1;
|
||||
|
||||
@@ -983,7 +1017,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
wchar_t *s = modulePrefix;
|
||||
for (;;)
|
||||
{
|
||||
wchar_t c = *s++;
|
||||
const wchar_t c = *s++;
|
||||
if (c == 0)
|
||||
break;
|
||||
if (c == WCHAR_PATH_SEPARATOR)
|
||||
@@ -1033,7 +1067,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
unsigned k;
|
||||
for (k = 0; k < 8; k++)
|
||||
{
|
||||
unsigned t = value & 0xF;
|
||||
const unsigned t = value & 0xF;
|
||||
value >>= 4;
|
||||
s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
|
||||
}
|
||||
@@ -1130,7 +1164,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
return 1;
|
||||
|
||||
{
|
||||
HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));
|
||||
const HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));
|
||||
// SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon);
|
||||
SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon);
|
||||
}
|
||||
|
||||
@@ -104,6 +104,14 @@ SOURCE=..\..\7zVersion.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\7zWindows.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compiler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Precomp.c
|
||||
# ADD CPP /Yc"Precomp.h"
|
||||
# End Source File
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
/* Precomp.h -- StdAfx
|
||||
2015-05-24 : Igor Pavlov : Public domain */
|
||||
2023-03-04 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __7Z_PRECOMP_H
|
||||
#define __7Z_PRECOMP_H
|
||||
#ifndef ZIP7_INC_PRECOMP_H
|
||||
#define ZIP7_INC_PRECOMP_H
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||
#pragma warning(disable : 4464) // relative include path contains '..'
|
||||
#endif
|
||||
|
||||
#include "../../Compiler.h"
|
||||
|
||||
#include "../../7zTypes.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
PROG = 7zipUninstall.exe
|
||||
MY_FIXED = 1
|
||||
|
||||
!IFDEF _64BIT_INSTALLER
|
||||
CFLAGS = $(CFLAGS) -D_64BIT_INSTALLER
|
||||
!IFDEF Z7_64BIT_INSTALLER
|
||||
CFLAGS = $(CFLAGS) -DZ7_64BIT_INSTALLER
|
||||
!ENDIF
|
||||
|
||||
MAIN_OBJS = \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* LzmaUtil.c -- Test application for LZMA compression
|
||||
2021-11-01 : Igor Pavlov : Public domain */
|
||||
2023-03-07 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "../../Precomp.h"
|
||||
#include "Precomp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -21,48 +21,80 @@ static const char * const kCantWriteMessage = "Cannot write output file";
|
||||
static const char * const kCantAllocateMessage = "Cannot allocate memory";
|
||||
static const char * const kDataErrorMessage = "Data error";
|
||||
|
||||
static void PrintHelp(char *buffer)
|
||||
static void Print(const char *s)
|
||||
{
|
||||
strcat(buffer,
|
||||
"\nLZMA-C " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE "\n\n"
|
||||
"Usage: lzma <e|d> inputFile outputFile\n"
|
||||
" e: encode file\n"
|
||||
" d: decode file\n");
|
||||
fputs(s, stdout);
|
||||
}
|
||||
|
||||
static int PrintError(char *buffer, const char *message)
|
||||
static void PrintHelp(void)
|
||||
{
|
||||
strcat(buffer, "\nError: ");
|
||||
strcat(buffer, message);
|
||||
strcat(buffer, "\n");
|
||||
Print(
|
||||
"\n" "LZMA-C " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE
|
||||
"\n"
|
||||
"\n" "Usage: lzma <e|d> inputFile outputFile"
|
||||
"\n" " e: encode file"
|
||||
"\n" " d: decode file"
|
||||
"\n");
|
||||
}
|
||||
|
||||
static int PrintError(const char *message)
|
||||
{
|
||||
Print("\nError: ");
|
||||
Print(message);
|
||||
Print("\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int PrintError_WRes(char *buffer, const char *message, WRes wres)
|
||||
#define CONVERT_INT_TO_STR(charType, tempSize) \
|
||||
unsigned char temp[tempSize]; unsigned i = 0; \
|
||||
while (val >= 10) { temp[i++] = (unsigned char)('0' + (unsigned)(val % 10)); val /= 10; } \
|
||||
*s++ = (charType)('0' + (unsigned)val); \
|
||||
while (i != 0) { i--; *s++ = (charType)temp[i]; } \
|
||||
*s = 0; \
|
||||
return s;
|
||||
|
||||
static char * Convert_unsigned_To_str(unsigned val, char *s)
|
||||
{
|
||||
strcat(buffer, "\nError: ");
|
||||
strcat(buffer, message);
|
||||
sprintf(buffer + strlen(buffer), "\nSystem error code: %d", (unsigned)wres);
|
||||
CONVERT_INT_TO_STR(char, 32)
|
||||
}
|
||||
|
||||
static void Print_unsigned(unsigned code)
|
||||
{
|
||||
char str[32];
|
||||
Convert_unsigned_To_str(code, str);
|
||||
Print(str);
|
||||
}
|
||||
|
||||
static int PrintError_WRes(const char *message, WRes wres)
|
||||
{
|
||||
PrintError(message);
|
||||
Print("\nSystem error code: ");
|
||||
Print_unsigned((unsigned)wres);
|
||||
#ifndef _WIN32
|
||||
{
|
||||
const char *s = strerror(wres);
|
||||
if (s)
|
||||
sprintf(buffer + strlen(buffer), " : %s", s);
|
||||
{
|
||||
Print(" : ");
|
||||
Print(s);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
strcat(buffer, "\n");
|
||||
Print("\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int PrintErrorNumber(char *buffer, SRes val)
|
||||
static int PrintErrorNumber(SRes val)
|
||||
{
|
||||
sprintf(buffer + strlen(buffer), "\n7-Zip error code: %d\n", (unsigned)val);
|
||||
Print("\n7-Zip error code: ");
|
||||
Print_unsigned((unsigned)val);
|
||||
Print("\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int PrintUserError(char *buffer)
|
||||
static int PrintUserError(void)
|
||||
{
|
||||
return PrintError(buffer, "Incorrect command");
|
||||
return PrintError("Incorrect command");
|
||||
}
|
||||
|
||||
|
||||
@@ -70,10 +102,10 @@ static int PrintUserError(char *buffer)
|
||||
#define OUT_BUF_SIZE (1 << 16)
|
||||
|
||||
|
||||
static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inStream,
|
||||
static SRes Decode2(CLzmaDec *state, ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream,
|
||||
UInt64 unpackSize)
|
||||
{
|
||||
int thereIsSize = (unpackSize != (UInt64)(Int64)-1);
|
||||
const int thereIsSize = (unpackSize != (UInt64)(Int64)-1);
|
||||
Byte inBuf[IN_BUF_SIZE];
|
||||
Byte outBuf[OUT_BUF_SIZE];
|
||||
size_t inPos = 0, inSize = 0, outPos = 0;
|
||||
@@ -83,7 +115,7 @@ static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inS
|
||||
if (inPos == inSize)
|
||||
{
|
||||
inSize = IN_BUF_SIZE;
|
||||
RINOK(inStream->Read(inStream, inBuf, &inSize));
|
||||
RINOK(inStream->Read(inStream, inBuf, &inSize))
|
||||
inPos = 0;
|
||||
}
|
||||
{
|
||||
@@ -124,7 +156,7 @@ static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inS
|
||||
}
|
||||
|
||||
|
||||
static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream)
|
||||
static SRes Decode(ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream)
|
||||
{
|
||||
UInt64 unpackSize;
|
||||
int i;
|
||||
@@ -137,27 +169,29 @@ static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream)
|
||||
|
||||
/* Read and parse header */
|
||||
|
||||
RINOK(SeqInStream_Read(inStream, header, sizeof(header)));
|
||||
|
||||
{
|
||||
size_t size = sizeof(header);
|
||||
RINOK(SeqInStream_ReadMax(inStream, header, &size))
|
||||
if (size != sizeof(header))
|
||||
return SZ_ERROR_INPUT_EOF;
|
||||
}
|
||||
unpackSize = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
unpackSize += (UInt64)header[LZMA_PROPS_SIZE + i] << (i * 8);
|
||||
|
||||
LzmaDec_Construct(&state);
|
||||
RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc));
|
||||
LzmaDec_CONSTRUCT(&state)
|
||||
RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc))
|
||||
res = Decode2(&state, outStream, inStream, unpackSize);
|
||||
LzmaDec_Free(&state, &g_Alloc);
|
||||
return res;
|
||||
}
|
||||
|
||||
static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize, char *rs)
|
||||
static SRes Encode(ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream, UInt64 fileSize)
|
||||
{
|
||||
CLzmaEncHandle enc;
|
||||
SRes res;
|
||||
CLzmaEncProps props;
|
||||
|
||||
UNUSED_VAR(rs);
|
||||
|
||||
enc = LzmaEnc_Create(&g_Alloc);
|
||||
if (enc == 0)
|
||||
return SZ_ERROR_MEM;
|
||||
@@ -187,7 +221,7 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file
|
||||
}
|
||||
|
||||
|
||||
static int main2(int numArgs, const char *args[], char *rs)
|
||||
int Z7_CDECL main(int numArgs, const char *args[])
|
||||
{
|
||||
CFileSeqInStream inStream;
|
||||
CFileOutStream outStream;
|
||||
@@ -208,29 +242,31 @@ static int main2(int numArgs, const char *args[], char *rs)
|
||||
|
||||
if (numArgs == 1)
|
||||
{
|
||||
PrintHelp(rs);
|
||||
PrintHelp();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (numArgs < 3 || numArgs > 4 || strlen(args[1]) != 1)
|
||||
return PrintUserError(rs);
|
||||
return PrintUserError();
|
||||
|
||||
c = args[1][0];
|
||||
encodeMode = (c == 'e' || c == 'E');
|
||||
if (!encodeMode && c != 'd' && c != 'D')
|
||||
return PrintUserError(rs);
|
||||
return PrintUserError();
|
||||
|
||||
/*
|
||||
{
|
||||
size_t t4 = sizeof(UInt32);
|
||||
size_t t8 = sizeof(UInt64);
|
||||
if (t4 != 4 || t8 != 8)
|
||||
return PrintError(rs, "Incorrect UInt32 or UInt64");
|
||||
return PrintError("Incorrect UInt32 or UInt64");
|
||||
}
|
||||
*/
|
||||
|
||||
{
|
||||
WRes wres = InFile_Open(&inStream.file, args[2]);
|
||||
const WRes wres = InFile_Open(&inStream.file, args[2]);
|
||||
if (wres != 0)
|
||||
return PrintError_WRes(rs, "Cannot open input file", wres);
|
||||
return PrintError_WRes("Cannot open input file", wres);
|
||||
}
|
||||
|
||||
if (numArgs > 3)
|
||||
@@ -239,18 +275,18 @@ static int main2(int numArgs, const char *args[], char *rs)
|
||||
useOutFile = True;
|
||||
wres = OutFile_Open(&outStream.file, args[3]);
|
||||
if (wres != 0)
|
||||
return PrintError_WRes(rs, "Cannot open output file", wres);
|
||||
return PrintError_WRes("Cannot open output file", wres);
|
||||
}
|
||||
else if (encodeMode)
|
||||
PrintUserError(rs);
|
||||
PrintUserError();
|
||||
|
||||
if (encodeMode)
|
||||
{
|
||||
UInt64 fileSize;
|
||||
WRes wres = File_GetLength(&inStream.file, &fileSize);
|
||||
const WRes wres = File_GetLength(&inStream.file, &fileSize);
|
||||
if (wres != 0)
|
||||
return PrintError_WRes(rs, "Cannot get file length", wres);
|
||||
res = Encode(&outStream.vt, &inStream.vt, fileSize, rs);
|
||||
return PrintError_WRes("Cannot get file length", wres);
|
||||
res = Encode(&outStream.vt, &inStream.vt, fileSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -264,23 +300,14 @@ static int main2(int numArgs, const char *args[], char *rs)
|
||||
if (res != SZ_OK)
|
||||
{
|
||||
if (res == SZ_ERROR_MEM)
|
||||
return PrintError(rs, kCantAllocateMessage);
|
||||
return PrintError(kCantAllocateMessage);
|
||||
else if (res == SZ_ERROR_DATA)
|
||||
return PrintError(rs, kDataErrorMessage);
|
||||
return PrintError(kDataErrorMessage);
|
||||
else if (res == SZ_ERROR_WRITE)
|
||||
return PrintError_WRes(rs, kCantWriteMessage, outStream.wres);
|
||||
return PrintError_WRes(kCantWriteMessage, outStream.wres);
|
||||
else if (res == SZ_ERROR_READ)
|
||||
return PrintError_WRes(rs, kCantReadMessage, inStream.wres);
|
||||
return PrintErrorNumber(rs, res);
|
||||
return PrintError_WRes(kCantReadMessage, inStream.wres);
|
||||
return PrintErrorNumber(res);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int MY_CDECL main(int numArgs, const char *args[])
|
||||
{
|
||||
char rs[1000] = { 0 };
|
||||
int res = main2(numArgs, args, rs);
|
||||
fputs(rs, stdout);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -106,6 +106,10 @@ SOURCE=..\..\7zVersion.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\7zWindows.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Alloc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -114,6 +118,10 @@ SOURCE=..\..\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compiler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\CpuArch.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -162,6 +170,14 @@ SOURCE=.\LzmaUtil.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Precomp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Precomp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Threads.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
14
C/Util/Lzma/Precomp.h
Executable file
14
C/Util/Lzma/Precomp.h
Executable file
@@ -0,0 +1,14 @@
|
||||
/* Precomp.h -- StdAfx
|
||||
2023-03-04 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef ZIP7_INC_PRECOMP_H
|
||||
#define ZIP7_INC_PRECOMP_H
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||
#pragma warning(disable : 4464) // relative include path contains '..'
|
||||
#endif
|
||||
|
||||
#include "../../Compiler.h"
|
||||
#include "../../7zTypes.h"
|
||||
|
||||
#endif
|
||||
@@ -101,6 +101,10 @@ SOURCE=.\LzmaLib.def
|
||||
|
||||
SOURCE=.\LzmaLibExports.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Precomp.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
@@ -108,6 +112,10 @@ SOURCE=..\..\7zTypes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\7zWindows.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Alloc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -116,6 +124,14 @@ SOURCE=..\..\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compiler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\CpuArch.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\IStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -168,6 +184,10 @@ SOURCE=..\..\LzmaLib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Precomp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
/* LzmaLibExports.c -- LZMA library DLL Entry point
|
||||
2015-11-08 : Igor Pavlov : Public domain */
|
||||
2023-03-05 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "../../Precomp.h"
|
||||
#include "Precomp.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include "../../7zWindows.h"
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved);
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
UNUSED_VAR(hInstance);
|
||||
UNUSED_VAR(dwReason);
|
||||
UNUSED_VAR(lpReserved);
|
||||
UNUSED_VAR(hInstance)
|
||||
UNUSED_VAR(dwReason)
|
||||
UNUSED_VAR(lpReserved)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
4
C/Util/LzmaLib/Precomp.c
Executable file
4
C/Util/LzmaLib/Precomp.c
Executable file
@@ -0,0 +1,4 @@
|
||||
/* Precomp.c -- StdAfx
|
||||
2013-01-21 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
14
C/Util/LzmaLib/Precomp.h
Executable file
14
C/Util/LzmaLib/Precomp.h
Executable file
@@ -0,0 +1,14 @@
|
||||
/* Precomp.h -- StdAfx
|
||||
2023-03-04 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef ZIP7_INC_PRECOMP_H
|
||||
#define ZIP7_INC_PRECOMP_H
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||
#pragma warning(disable : 4464) // relative include path contains '..'
|
||||
#endif
|
||||
|
||||
#include "../../Compiler.h"
|
||||
#include "../../7zTypes.h"
|
||||
|
||||
#endif
|
||||
@@ -21,6 +21,7 @@ C_OBJS = \
|
||||
$O\Threads.obj \
|
||||
|
||||
OBJS = \
|
||||
$O\Precomp.obj \
|
||||
$(LIB_OBJS) \
|
||||
$(C_OBJS) \
|
||||
$O\resource.res
|
||||
@@ -30,7 +31,24 @@ OBJS = \
|
||||
$(SLIBPATH): $O $(OBJS)
|
||||
lib -out:$(SLIBPATH) $(OBJS) $(LIBS)
|
||||
|
||||
|
||||
MAK_SINGLE_FILE = 1
|
||||
|
||||
$O\Precomp.obj: Precomp.c
|
||||
$(CCOMPL_PCH)
|
||||
|
||||
!IFDEF MAK_SINGLE_FILE
|
||||
|
||||
$(LIB_OBJS): $(*B).c
|
||||
$(COMPL_O2)
|
||||
$(CCOMPL_USE)
|
||||
$(C_OBJS): ../../$(*B).c
|
||||
$(COMPL_O2)
|
||||
$(CCOMPL_USE)
|
||||
|
||||
!ELSE
|
||||
|
||||
{.}.c{$O}.obj::
|
||||
$(CCOMPLB_USE)
|
||||
{../../../C}.c{$O}.obj::
|
||||
$(CCOMPLB_USE)
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
/* Precomp.h -- StdAfx
|
||||
2013-06-16 : Igor Pavlov : Public domain */
|
||||
2023-03-04 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __7Z_PRECOMP_H
|
||||
#define __7Z_PRECOMP_H
|
||||
#ifndef ZIP7_INC_PRECOMP_H
|
||||
#define ZIP7_INC_PRECOMP_H
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||
#pragma warning(disable : 4464) // relative include path contains '..'
|
||||
#endif
|
||||
|
||||
#include "../../Compiler.h"
|
||||
#include "../../7zTypes.h"
|
||||
|
||||
@@ -26,6 +26,12 @@
|
||||
|
||||
#define kInputBufSize ((size_t)1 << 18)
|
||||
|
||||
|
||||
#define wcscat lstrcatW
|
||||
#define wcslen (size_t)lstrlenW
|
||||
#define wcscpy lstrcpyW
|
||||
// wcsncpy() and lstrcpynW() work differently. We don't use them.
|
||||
|
||||
static const char * const kExts[] =
|
||||
{
|
||||
"bat"
|
||||
@@ -64,7 +70,7 @@ static unsigned FindExt(const wchar_t *s, unsigned *extLen)
|
||||
return len;
|
||||
}
|
||||
|
||||
#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c)))
|
||||
#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c)))
|
||||
|
||||
static unsigned FindItem(const char * const *items, unsigned num, const wchar_t *s, unsigned len)
|
||||
{
|
||||
@@ -72,13 +78,13 @@ static unsigned FindItem(const char * const *items, unsigned num, const wchar_t
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
const char *item = items[i];
|
||||
unsigned itemLen = (unsigned)strlen(item);
|
||||
const unsigned itemLen = (unsigned)strlen(item);
|
||||
unsigned j;
|
||||
if (len != itemLen)
|
||||
continue;
|
||||
for (j = 0; j < len; j++)
|
||||
{
|
||||
unsigned c = (Byte)item[j];
|
||||
const unsigned c = (Byte)item[j];
|
||||
if (c != s[j] && MAKE_CHAR_UPPER(c) != s[j])
|
||||
break;
|
||||
}
|
||||
@@ -96,10 +102,20 @@ static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _CONSOLE
|
||||
static void PrintStr(const char *s)
|
||||
{
|
||||
fputs(s, stdout);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void PrintErrorMessage(const char *message)
|
||||
{
|
||||
#ifdef _CONSOLE
|
||||
printf("\n7-Zip Error: %s\n", message);
|
||||
PrintStr("\n7-Zip Error: ");
|
||||
PrintStr(message);
|
||||
PrintStr("\n");
|
||||
#else
|
||||
#ifdef UNDER_CE
|
||||
WCHAR messageW[256 + 4];
|
||||
@@ -179,7 +195,7 @@ static WRes RemoveDirWithSubItems(WCHAR *path)
|
||||
WIN32_FIND_DATAW fd;
|
||||
HANDLE handle;
|
||||
WRes res = 0;
|
||||
size_t len = wcslen(path);
|
||||
const size_t len = wcslen(path);
|
||||
wcscpy(path + len, L"*");
|
||||
handle = FindFirstFileW(path, &fd);
|
||||
path[len] = L'\0';
|
||||
@@ -228,7 +244,7 @@ static WRes RemoveDirWithSubItems(WCHAR *path)
|
||||
}
|
||||
|
||||
#ifdef _CONSOLE
|
||||
int MY_CDECL main()
|
||||
int Z7_CDECL main(void)
|
||||
#else
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
#ifdef UNDER_CE
|
||||
@@ -290,7 +306,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
BoolInt quoteMode = False;
|
||||
for (;; cmdLineParams++)
|
||||
{
|
||||
wchar_t c = *cmdLineParams;
|
||||
const wchar_t c = *cmdLineParams;
|
||||
if (c == L'\"')
|
||||
quoteMode = !quoteMode;
|
||||
else if (c == 0 || (c == L' ' && !quoteMode))
|
||||
@@ -324,7 +340,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
unsigned k;
|
||||
for (k = 0; k < 8; k++)
|
||||
{
|
||||
unsigned t = value & 0xF;
|
||||
const unsigned t = value & 0xF;
|
||||
value >>= 4;
|
||||
s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
|
||||
}
|
||||
@@ -386,7 +402,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
{
|
||||
lookStream.bufSize = kInputBufSize;
|
||||
lookStream.realStream = &archiveStream.vt;
|
||||
LookToRead2_Init(&lookStream);
|
||||
LookToRead2_INIT(&lookStream)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,11 +471,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
unsigned extLen;
|
||||
const WCHAR *name = temp + nameStartPos;
|
||||
unsigned len = (unsigned)wcslen(name);
|
||||
unsigned nameLen = FindExt(temp + nameStartPos, &extLen);
|
||||
unsigned extPrice = FindItem(kExts, sizeof(kExts) / sizeof(kExts[0]), name + len - extLen, extLen);
|
||||
unsigned namePrice = FindItem(kNames, sizeof(kNames) / sizeof(kNames[0]), name, nameLen);
|
||||
const unsigned nameLen = FindExt(temp + nameStartPos, &extLen);
|
||||
const unsigned extPrice = FindItem(kExts, sizeof(kExts) / sizeof(kExts[0]), name + len - extLen, extLen);
|
||||
const unsigned namePrice = FindItem(kNames, sizeof(kNames) / sizeof(kNames[0]), name, nameLen);
|
||||
|
||||
unsigned price = namePrice + extPrice * 64 + (nameStartPos == 0 ? 0 : (1 << 12));
|
||||
const unsigned price = namePrice + extPrice * 64 + (nameStartPos == 0 ? 0 : (1 << 12));
|
||||
if (minPrice > price)
|
||||
{
|
||||
minPrice = price;
|
||||
@@ -500,7 +516,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
#endif
|
||||
|
||||
{
|
||||
SRes res2 = File_Close(&outFile);
|
||||
const SRes res2 = File_Close(&outFile);
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
if (res2 != SZ_OK)
|
||||
@@ -550,7 +566,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
WCHAR oldCurDir[MAX_PATH + 2];
|
||||
oldCurDir[0] = 0;
|
||||
{
|
||||
DWORD needLen = GetCurrentDirectory(MAX_PATH + 1, oldCurDir);
|
||||
const DWORD needLen = GetCurrentDirectory(MAX_PATH + 1, oldCurDir);
|
||||
if (needLen == 0 || needLen > MAX_PATH)
|
||||
oldCurDir[0] = 0;
|
||||
SetCurrentDirectory(workCurDir);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
PROG = 7zS2.sfx
|
||||
MY_FIXED = 1
|
||||
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-DZ7_EXTRACT_ONLY \
|
||||
|
||||
C_OBJS = \
|
||||
$O\7zAlloc.obj \
|
||||
$O\7zArcIn.obj \
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
PROG = 7zS2con.sfx
|
||||
MY_FIXED = 1
|
||||
CFLAGS = $(CFLAGS) -D_CONSOLE
|
||||
|
||||
CFLAGS = $(CFLAGS) -D_CONSOLE \
|
||||
-DZ7_EXTRACT_ONLY \
|
||||
|
||||
C_OBJS = \
|
||||
$O\7zAlloc.obj \
|
||||
|
||||
Reference in New Issue
Block a user