Skip to content

Commit

Permalink
16.03
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Pavlov authored and kornelski committed Dec 8, 2016
1 parent 1eddf52 commit 232ce79
Show file tree
Hide file tree
Showing 83 changed files with 1,083 additions and 302 deletions.
8 changes: 4 additions & 4 deletions C/7zVersion.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define MY_VER_MAJOR 16
#define MY_VER_MINOR 02
#define MY_VER_MINOR 03
#define MY_VER_BUILD 0
#define MY_VERSION_NUMBERS "16.02"
#define MY_VERSION "16.02"
#define MY_DATE "2016-05-21"
#define MY_VERSION_NUMBERS "16.03"
#define MY_VERSION "16.03"
#define MY_DATE "2016-09-28"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov"
Expand Down
3 changes: 2 additions & 1 deletion C/CpuArch.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* CpuArch.h -- CPU specific code
2015-12-01: Igor Pavlov : Public domain */
2016-06-09: Igor Pavlov : Public domain */

#ifndef __CPU_ARCH_H
#define __CPU_ARCH_H
Expand Down Expand Up @@ -66,6 +66,7 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
|| defined(__MIPSEL__) \
|| defined(__MIPSEL) \
|| defined(_MIPSEL) \
|| defined(__BFIN__) \
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
#define MY_CPU_LE
#endif
Expand Down
87 changes: 87 additions & 0 deletions C/DllSecur.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* DllSecur.c -- DLL loading security
2016-09-15 : Igor Pavlov : Public domain */

#include "Precomp.h"

#ifdef _WIN32

#include <windows.h>

#include "DllSecur.h"

#ifndef UNDER_CE

typedef BOOL (WINAPI *Func_SetDefaultDllDirectories)(DWORD DirectoryFlags);

#define MY_LOAD_LIBRARY_SEARCH_USER_DIRS 0x400
#define MY_LOAD_LIBRARY_SEARCH_SYSTEM32 0x800

static const char * const g_Dlls =
#ifndef _CONSOLE
"UXTHEME\0"
#endif
"USERENV\0"
"SETUPAPI\0"
"APPHELP\0"
"PROPSYS\0"
"DWMAPI\0"
"CRYPTBASE\0"
"OLEACC\0"
"CLBCATQ\0"
;

#endif

void LoadSecurityDlls()
{
#ifndef UNDER_CE

wchar_t buf[MAX_PATH + 100];

{
// at Vista (ver 6.0) : CoCreateInstance(CLSID_ShellLink, ...) doesn't work after SetDefaultDllDirectories() : Check it ???
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof(vi);
if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMajorVersion != 0)
{
Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories)
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
if (setDllDirs)
if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS))
return;
}
}

{
unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2);
if (len == 0 || len > MAX_PATH)
return;
}
{
const char *dll;
unsigned pos = (unsigned)lstrlenW(buf);

if (buf[pos - 1] != '\\')
buf[pos++] = '\\';

for (dll = g_Dlls; dll[0] != 0;)
{
unsigned k = 0;
for (;;)
{
char c = *dll++;
buf[pos + k] = c;
k++;
if (c == 0)
break;
}

lstrcatW(buf, L".dll");
LoadLibraryExW(buf, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
}
}

#endif
}

#endif
19 changes: 19 additions & 0 deletions C/DllSecur.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* DllSecur.h -- DLL loading for security
2016-06-08 : Igor Pavlov : Public domain */

#ifndef __DLL_SECUR_H
#define __DLL_SECUR_H

#include "7zTypes.h"

EXTERN_C_BEGIN

#ifdef _WIN32

void LoadSecurityDlls();

#endif

EXTERN_C_END

#endif
4 changes: 3 additions & 1 deletion C/Util/7zipInstall/7zipInstall.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 7zipInstall.c - 7-Zip Installer
2015-12-09 : Igor Pavlov : Public domain */
2016-06-08 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand All @@ -21,6 +21,7 @@
#include "../../7zFile.h"
#include "../../7zVersion.h"
#include "../../CpuArch.h"
#include "../../DllSecur.h"

#include "resource.h"

Expand Down Expand Up @@ -876,6 +877,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
UNUSED_VAR(nCmdShow)

#ifndef UNDER_CE
LoadSecurityDlls();
CoInitialize(NULL);
#endif

Expand Down
8 changes: 8 additions & 0 deletions C/Util/7zipInstall/7zipInstall.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions C/Util/7zipInstall/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ C_OBJS = \
$O\7zStream.obj \
$O\Bcj2.obj \
$O\CpuArch.obj \
$O\DllSecur.obj \
$O\LzmaDec.obj \

OBJS = \
Expand Down
3 changes: 3 additions & 0 deletions C/Util/SfxSetup/SfxSetup.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "../../7zCrc.h"
#include "../../7zFile.h"
#include "../../CpuArch.h"
#include "../../DllSecur.h"

#define k_EXE_ExtIndex 2

Expand Down Expand Up @@ -254,6 +255,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
Bool useShellExecute = True;
DWORD exitCode = 0;

LoadSecurityDlls();

#ifdef _CONSOLE
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
#else
Expand Down
8 changes: 8 additions & 0 deletions C/Util/SfxSetup/SfxSetup.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions C/Util/SfxSetup/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ C_OBJS = \
$O\BraIA64.obj \
$O\CpuArch.obj \
$O\Delta.obj \
$O\DllSecur.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \

Expand Down
1 change: 1 addition & 0 deletions C/Util/SfxSetup/makefile_con
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ C_OBJS = \
$O\BraIA64.obj \
$O\CpuArch.obj \
$O\Delta.obj \
$O\DllSecur.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \

Expand Down
5 changes: 4 additions & 1 deletion CPP/7zip/Archive/7z/7zIn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,10 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
if (CrcCalc(data, unpackSize) != folders.FolderCRCs.Vals[i])
ThrowIncorrect();
}
HeadersSize += folders.PackPositions[folders.NumPackStreams];

if (folders.PackPositions)
HeadersSize += folders.PackPositions[folders.NumPackStreams];

return S_OK;
}

Expand Down
4 changes: 2 additions & 2 deletions CPP/7zip/Archive/7z/7zUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct CFilterMode
{
if (Id == k_IA64)
Delta = 16;
else if (Id == k_ARM || Id == k_PPC || Id == k_PPC)
else if (Id == k_ARM || Id == k_PPC || Id == k_SPARC)
Delta = 4;
else if (Id == k_ARMT)
Delta = 2;
Expand Down Expand Up @@ -779,7 +779,7 @@ struct CSolidGroup
CRecordVector<CFolderRepack> folderRefs;
};

static const char *g_ExeExts[] =
static const char * const g_ExeExts[] =
{
"dll"
, "exe"
Expand Down
2 changes: 1 addition & 1 deletion CPP/7zip/Archive/Cab/CabHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)

case kpidVolumeIndex:
{
if (m_Database.Volumes.Size() == 1)
if (!m_Database.Volumes.IsEmpty())
{
const CDatabaseEx &db = m_Database.Volumes[0];
const CInArcInfo &ai = db.ArcInfo;
Expand Down
49 changes: 46 additions & 3 deletions CPP/7zip/Archive/ElfHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bool CHeader::Parse(const Byte *p)

#define PT_PHDR 6

static const char *g_SegnmentTypes[] =
static const char * const g_SegnmentTypes[] =
{
"Unused",
"Loadable segment",
Expand Down Expand Up @@ -554,13 +554,31 @@ static const CUInt32PCharPair g_OS[] =
{ 255, "Standalone" }
};

#define k_Machine_ARM 40

/*
#define EF_ARM_ABIMASK 0xFF000000
#define EF_ARM_BE8 0x00800000
#define EF_ARM_GCCMASK 0x00400FFF
#define EF_ARM_ABI_FLOAT_SOFT 0x00000200
#define EF_ARM_ABI_FLOAT_HARD 0x00000400
*/

static const CUInt32PCharPair g_ARM_Flags[] =
{
{ 9, "SF" },
{ 10, "HF" },
{ 23, "BE8" }
};


#define ET_NONE 0
#define ET_REL 1
#define ET_EXEC 2
#define ET_DYN 3
#define ET_CORE 4

static const char *g_Types[] =
static const char * const g_Types[] =
{
"None",
"Relocatable file",
Expand All @@ -569,6 +587,9 @@ static const char *g_Types[] =
"Core file"
};




class CHandler:
public IInArchive,
public IArchiveAllowTail,
Expand Down Expand Up @@ -659,7 +680,29 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
case kpidBit64: if (_header.Mode64) prop = _header.Mode64; break;
case kpidBigEndian: if (_header.Be) prop = _header.Be; break;
case kpidShortComment:
case kpidCpu: PAIR_TO_PROP(g_Machines, _header.Machine, prop); break;

case kpidCpu:
{
AString s = TypePairToString(g_Machines, ARRAY_SIZE(g_Machines), _header.Machine);
UInt32 flags = _header.Flags;
if (flags != 0)
{
char sz[16];
s.Add_Space();
if (_header.Machine == k_Machine_ARM)
{
s += FlagsToString(g_ARM_Flags, ARRAY_SIZE(g_ARM_Flags), flags & (((UInt32)1 << 24) - 1));
s += " ABI:";
ConvertUInt32ToString(flags >> 24, sz);
}
else
ConvertUInt32ToHex(flags, sz);
s += sz;
}
prop = s;
break;
}

case kpidHostOS: PAIR_TO_PROP(g_OS, _header.Os, prop); break;
case kpidCharacts: TYPE_TO_PROP(g_Types, _header.Type, prop); break;
case kpidExtension:
Expand Down
6 changes: 3 additions & 3 deletions CPP/7zip/Archive/FlvHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static const Byte kProps[] =
IMP_IInArchive_Props
IMP_IInArchive_ArcProps_NO_Table

static const char *g_AudioTypes[16] =
static const char * const g_AudioTypes[16] =
{
"pcm"
, "adpcm"
Expand All @@ -113,7 +113,7 @@ static const char *g_AudioTypes[16] =
, "audio15"
};

static const char *g_VideoTypes[16] =
static const char * const g_VideoTypes[16] =
{
"video0"
, "jpeg"
Expand All @@ -133,7 +133,7 @@ static const char *g_VideoTypes[16] =
, "video15"
};

static const char *g_Rates[4] =
static const char * const g_Rates[4] =
{
"5.5 kHz"
, "11 kHz"
Expand Down
Loading

0 comments on commit 232ce79

Please sign in to comment.