Update to 7-Zip Version 22.01

See: https://sourceforge.net/p/sevenzip/discussion/45797/thread/c43cbc5f18/
This commit is contained in:
Tino Reichardt
2022-08-07 10:03:34 +02:00
parent 57558682a8
commit f9e0730191
47 changed files with 2485 additions and 812 deletions

View File

@@ -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); }