-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
83 changed files
with
1,083 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.