mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 14:07:00 -06:00
Update to 7-Zip Version 22.01
See: https://sourceforge.net/p/sevenzip/discussion/45797/thread/c43cbc5f18/
This commit is contained in:
@@ -21,7 +21,7 @@ typedef BOOL (WINAPI * Func_LookupPrivilegeValue)(LPCTSTR lpSystemName, LPCTSTR
|
||||
typedef BOOL (WINAPI * Func_AdjustTokenPrivileges)(HANDLE TokenHandle, BOOL DisableAllPrivileges,
|
||||
PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength);
|
||||
}
|
||||
#define GET_PROC_ADDR(fff, name) Func_ ## fff my_ ## fff = (Func_ ## fff)GetProcAddress(hModule, name)
|
||||
#define GET_PROC_ADDR(fff, name) Func_ ## fff my_ ## fff = (Func_ ## fff) (void(*)()) GetProcAddress(hModule, name)
|
||||
#endif
|
||||
|
||||
bool EnablePrivilege(LPCTSTR privilegeName, bool enable)
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "SecurityUtils.h"
|
||||
|
||||
#define MY_CAST_FUNC (void(*)())
|
||||
// #define MY_CAST_FUNC
|
||||
|
||||
namespace NWindows {
|
||||
namespace NSecurity {
|
||||
|
||||
@@ -50,8 +53,10 @@ static void MyLookupSids(CPolicy &policy, PSID ps)
|
||||
}
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
|
||||
#ifndef _UNICODE
|
||||
typedef BOOL (WINAPI * LookupAccountNameWP)(
|
||||
typedef BOOL (WINAPI * Func_LookupAccountNameW)(
|
||||
LPCWSTR lpSystemName,
|
||||
LPCWSTR lpAccountName,
|
||||
PSID Sid,
|
||||
@@ -62,13 +67,17 @@ typedef BOOL (WINAPI * LookupAccountNameWP)(
|
||||
);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static PSID GetSid(LPWSTR accountName)
|
||||
{
|
||||
#ifndef _UNICODE
|
||||
HMODULE hModule = GetModuleHandle(TEXT("Advapi32.dll"));
|
||||
if (hModule == NULL)
|
||||
return NULL;
|
||||
LookupAccountNameWP lookupAccountNameW = (LookupAccountNameWP)GetProcAddress(hModule, "LookupAccountNameW");
|
||||
Func_LookupAccountNameW lookupAccountNameW = (Func_LookupAccountNameW)
|
||||
MY_CAST_FUNC
|
||||
GetProcAddress(hModule, "LookupAccountNameW");
|
||||
if (lookupAccountNameW == NULL)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
@@ -7,6 +7,31 @@
|
||||
|
||||
#include "Defs.h"
|
||||
|
||||
#ifndef _UNICODE
|
||||
|
||||
extern "C" {
|
||||
typedef NTSTATUS (NTAPI *Func_LsaOpenPolicy)(PLSA_UNICODE_STRING SystemName,
|
||||
PLSA_OBJECT_ATTRIBUTES ObjectAttributes, ACCESS_MASK DesiredAccess, PLSA_HANDLE PolicyHandle);
|
||||
typedef NTSTATUS (NTAPI *Func_LsaClose)(LSA_HANDLE ObjectHandle);
|
||||
typedef NTSTATUS (NTAPI *Func_LsaAddAccountRights)(LSA_HANDLE PolicyHandle,
|
||||
PSID AccountSid, PLSA_UNICODE_STRING UserRights, ULONG CountOfRights );
|
||||
#define MY_STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002L)
|
||||
}
|
||||
|
||||
#define POLICY_FUNC_CALL(fff, str) \
|
||||
if (hModule == NULL) return MY_STATUS_NOT_IMPLEMENTED; \
|
||||
Func_ ## fff v = (Func_ ## fff) (void(*)()) GetProcAddress(hModule, str); \
|
||||
if (!v) return MY_STATUS_NOT_IMPLEMENTED; \
|
||||
const NTSTATUS res = v
|
||||
|
||||
#else
|
||||
|
||||
#define POLICY_FUNC_CALL(fff, str) \
|
||||
const NTSTATUS res = ::fff
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
namespace NWindows {
|
||||
namespace NSecurity {
|
||||
|
||||
@@ -53,15 +78,9 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#ifndef _UNICODE
|
||||
typedef NTSTATUS (NTAPI *LsaOpenPolicyP)(PLSA_UNICODE_STRING SystemName,
|
||||
PLSA_OBJECT_ATTRIBUTES ObjectAttributes, ACCESS_MASK DesiredAccess, PLSA_HANDLE PolicyHandle);
|
||||
typedef NTSTATUS (NTAPI *LsaCloseP)(LSA_HANDLE ObjectHandle);
|
||||
typedef NTSTATUS (NTAPI *LsaAddAccountRightsP)(LSA_HANDLE PolicyHandle,
|
||||
PSID AccountSid, PLSA_UNICODE_STRING UserRights, ULONG CountOfRights );
|
||||
#define MY_STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002L)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
struct CPolicy
|
||||
{
|
||||
protected:
|
||||
@@ -82,43 +101,17 @@ public:
|
||||
NTSTATUS Open(PLSA_UNICODE_STRING systemName, PLSA_OBJECT_ATTRIBUTES objectAttributes,
|
||||
ACCESS_MASK desiredAccess)
|
||||
{
|
||||
#ifndef _UNICODE
|
||||
if (hModule == NULL)
|
||||
return MY_STATUS_NOT_IMPLEMENTED;
|
||||
LsaOpenPolicyP lsaOpenPolicy = (LsaOpenPolicyP)GetProcAddress(hModule, "LsaOpenPolicy");
|
||||
if (lsaOpenPolicy == NULL)
|
||||
return MY_STATUS_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
|
||||
Close();
|
||||
return
|
||||
#ifdef _UNICODE
|
||||
::LsaOpenPolicy
|
||||
#else
|
||||
lsaOpenPolicy
|
||||
#endif
|
||||
POLICY_FUNC_CALL (LsaOpenPolicy, "LsaOpenPolicy")
|
||||
(systemName, objectAttributes, desiredAccess, &_handle);
|
||||
return res;
|
||||
}
|
||||
|
||||
NTSTATUS Close()
|
||||
{
|
||||
if (_handle == NULL)
|
||||
return 0;
|
||||
|
||||
#ifndef _UNICODE
|
||||
if (hModule == NULL)
|
||||
return MY_STATUS_NOT_IMPLEMENTED;
|
||||
LsaCloseP lsaClose = (LsaCloseP)GetProcAddress(hModule, "LsaClose");
|
||||
if (lsaClose == NULL)
|
||||
return MY_STATUS_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
|
||||
NTSTATUS res =
|
||||
#ifdef _UNICODE
|
||||
::LsaClose
|
||||
#else
|
||||
lsaClose
|
||||
#endif
|
||||
POLICY_FUNC_CALL (LsaClose, "LsaClose")
|
||||
(_handle);
|
||||
_handle = NULL;
|
||||
return res;
|
||||
@@ -137,21 +130,9 @@ public:
|
||||
|
||||
NTSTATUS AddAccountRights(PSID accountSid, PLSA_UNICODE_STRING userRights, ULONG countOfRights)
|
||||
{
|
||||
#ifndef _UNICODE
|
||||
if (hModule == NULL)
|
||||
return MY_STATUS_NOT_IMPLEMENTED;
|
||||
LsaAddAccountRightsP lsaAddAccountRights = (LsaAddAccountRightsP)GetProcAddress(hModule, "LsaAddAccountRights");
|
||||
if (lsaAddAccountRights == NULL)
|
||||
return MY_STATUS_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
|
||||
return
|
||||
#ifdef _UNICODE
|
||||
::LsaAddAccountRights
|
||||
#else
|
||||
lsaAddAccountRights
|
||||
#endif
|
||||
POLICY_FUNC_CALL (LsaAddAccountRights, "LsaAddAccountRights")
|
||||
(_handle, accountSid, userRights, countOfRights);
|
||||
return res;
|
||||
}
|
||||
NTSTATUS AddAccountRights(PSID accountSid, PLSA_UNICODE_STRING userRights)
|
||||
{ return AddAccountRights(accountSid, userRights, 1); }
|
||||
|
||||
@@ -258,14 +258,21 @@ bool BrowseForFolder(HWND owner, LPCTSTR title,
|
||||
|
||||
#ifndef _UNICODE
|
||||
|
||||
typedef BOOL (WINAPI * SHGetPathFromIDListWP)(LPCITEMIDLIST pidl, LPWSTR pszPath);
|
||||
extern "C" {
|
||||
typedef BOOL (WINAPI * Func_SHGetPathFromIDListW)(LPCITEMIDLIST pidl, LPWSTR pszPath);
|
||||
typedef LPITEMIDLIST (WINAPI * Func_SHBrowseForFolderW)(LPBROWSEINFOW lpbi);
|
||||
}
|
||||
|
||||
#define MY_CAST_FUNC (void(*)())
|
||||
// #define MY_CAST_FUNC
|
||||
|
||||
bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path)
|
||||
{
|
||||
path.Empty();
|
||||
SHGetPathFromIDListWP shGetPathFromIDListW = (SHGetPathFromIDListWP)
|
||||
Func_SHGetPathFromIDListW shGetPathFromIDListW = (Func_SHGetPathFromIDListW)
|
||||
MY_CAST_FUNC
|
||||
::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHGetPathFromIDListW");
|
||||
if (shGetPathFromIDListW == 0)
|
||||
if (!shGetPathFromIDListW)
|
||||
return false;
|
||||
const unsigned len = MAX_PATH * 2;
|
||||
bool result = BOOLToBool(shGetPathFromIDListW(itemIDList, path.GetBuf(len)));
|
||||
@@ -273,14 +280,14 @@ bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path)
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef LPITEMIDLIST (WINAPI * SHBrowseForFolderWP)(LPBROWSEINFOW lpbi);
|
||||
|
||||
static bool BrowseForFolder(LPBROWSEINFOW browseInfo, UString &resultPath)
|
||||
{
|
||||
NWindows::NCOM::CComInitializer comInitializer;
|
||||
SHBrowseForFolderWP shBrowseForFolderW = (SHBrowseForFolderWP)
|
||||
Func_SHBrowseForFolderW shBrowseForFolderW = (Func_SHBrowseForFolderW)
|
||||
MY_CAST_FUNC
|
||||
::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHBrowseForFolderW");
|
||||
if (shBrowseForFolderW == 0)
|
||||
if (!shBrowseForFolderW)
|
||||
return false;
|
||||
LPITEMIDLIST itemIDList = shBrowseForFolderW(browseInfo);
|
||||
if (itemIDList == NULL)
|
||||
|
||||
Reference in New Issue
Block a user