This commit is contained in:
Igor Pavlov
2016-09-29 00:00:00 +00:00
committed by Kornel Lesiński
parent 1eddf527ca
commit 232ce79574
83 changed files with 1088 additions and 307 deletions

View File

@@ -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"

View File

@@ -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
@@ -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

87
C/DllSecur.c Normal file
View File

@@ -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
C/DllSecur.h Normal file
View File

@@ -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

View File

@@ -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"
@@ -21,6 +21,7 @@
#include "../../7zFile.h"
#include "../../7zVersion.h"
#include "../../CpuArch.h"
#include "../../DllSecur.h"
#include "resource.h"
@@ -876,6 +877,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
UNUSED_VAR(nCmdShow)
#ifndef UNDER_CE
LoadSecurityDlls();
CoInitialize(NULL);
#endif

View File

@@ -191,6 +191,14 @@ SOURCE=..\..\Delta.h
# End Source File
# Begin Source File
SOURCE=..\..\DllSecur.c
# End Source File
# Begin Source File
SOURCE=..\..\DllSecur.h
# End Source File
# Begin Source File
SOURCE=..\..\Lzma2Dec.c
# End Source File
# Begin Source File

View File

@@ -25,6 +25,7 @@ C_OBJS = \
$O\7zStream.obj \
$O\Bcj2.obj \
$O\CpuArch.obj \
$O\DllSecur.obj \
$O\LzmaDec.obj \
OBJS = \

View File

@@ -20,6 +20,7 @@
#include "../../7zCrc.h"
#include "../../7zFile.h"
#include "../../CpuArch.h"
#include "../../DllSecur.h"
#define k_EXE_ExtIndex 2
@@ -254,6 +255,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
Bool useShellExecute = True;
DWORD exitCode = 0;
LoadSecurityDlls();
#ifdef _CONSOLE
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
#else

View File

@@ -187,6 +187,14 @@ SOURCE=..\..\Delta.h
# End Source File
# Begin Source File
SOURCE=..\..\DllSecur.c
# End Source File
# Begin Source File
SOURCE=..\..\DllSecur.h
# End Source File
# Begin Source File
SOURCE=..\..\Lzma2Dec.c
# End Source File
# Begin Source File

View File

@@ -16,6 +16,7 @@ C_OBJS = \
$O\BraIA64.obj \
$O\CpuArch.obj \
$O\Delta.obj \
$O\DllSecur.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \

View File

@@ -17,6 +17,7 @@ C_OBJS = \
$O\BraIA64.obj \
$O\CpuArch.obj \
$O\Delta.obj \
$O\DllSecur.obj \
$O\Lzma2Dec.obj \
$O\LzmaDec.obj \