This commit is contained in:
Igor Pavlov
2023-12-22 17:17:05 +00:00
committed by Kornel
parent ec44a8a070
commit a36c48cece
954 changed files with 42199 additions and 25482 deletions

View File

@@ -14,7 +14,7 @@
#include "PropIDUtils.h"
#ifndef _SFX
#ifndef Z7_SFX
#define Get16(x) GetUi16(x)
#define Get32(x) GetUi32(x)
#endif
@@ -54,7 +54,7 @@ FILE_ATTRIBUTE_
static const char kPosixTypes[16] = { '0', 'p', 'c', '3', 'd', '5', 'b', '7', '-', '9', 'l', 'B', 's', 'D', 'E', 'F' };
#define MY_ATTR_CHAR(a, n, c) ((a) & (1 << (n))) ? c : '-';
#define MY_ATTR_CHAR(a, n, c) (((a) & (1 << (n))) ? c : '-')
static void ConvertPosixAttribToString(char *s, UInt32 a) throw()
{
@@ -88,7 +88,7 @@ void ConvertWinAttribToString(char *s, UInt32 wa) throw()
info-zip - no additional marker.
*/
bool isPosix = ((wa & 0xF0000000) != 0);
const bool isPosix = ((wa & 0xF0000000) != 0);
UInt32 posix = 0;
if (isPosix)
@@ -183,7 +183,7 @@ void ConvertPropertyToShortString2(char *dest, const PROPVARIANT &prop, PROPID p
{
if (prop.vt != VT_UI4)
break;
UInt32 a = prop.ulVal;
const UInt32 a = prop.ulVal;
/*
if ((a & 0x8000) && (a & 0x7FFF) == 0)
@@ -207,7 +207,7 @@ void ConvertPropertyToShortString2(char *dest, const PROPVARIANT &prop, PROPID p
ConvertUInt32ToString((UInt32)(prop.uhVal.QuadPart >> 48), dest);
dest += strlen(dest);
*dest++ = '-';
UInt64 low = prop.uhVal.QuadPart & (((UInt64)1 << 48) - 1);
const UInt64 low = prop.uhVal.QuadPart & (((UInt64)1 << 48) - 1);
ConvertUInt64ToString(low, dest);
return;
}
@@ -260,7 +260,7 @@ void ConvertPropertyToString2(UString &dest, const PROPVARIANT &prop, PROPID pro
dest = temp;
}
#ifndef _SFX
#ifndef Z7_SFX
static inline unsigned GetHex(unsigned v)
{
@@ -387,33 +387,33 @@ static void ParseSid(AString &s, const Byte *p, UInt32 lim, UInt32 &sidSize)
s += "ERROR";
return;
}
UInt32 rev = p[0];
const UInt32 rev = p[0];
if (rev != 1)
{
s += "UNSUPPORTED";
return;
}
UInt32 num = p[1];
const UInt32 num = p[1];
if (8 + num * 4 > lim)
{
s += "ERROR";
return;
}
sidSize = 8 + num * 4;
UInt32 authority = GetBe32(p + 4);
const UInt32 authority = GetBe32(p + 4);
if (p[2] == 0 && p[3] == 0 && authority == 5 && num >= 1)
{
UInt32 v0 = Get32(p + 8);
if (v0 < ARRAY_SIZE(sidNames))
const UInt32 v0 = Get32(p + 8);
if (v0 < Z7_ARRAY_SIZE(sidNames))
{
s += sidNames[v0];
return;
}
if (v0 == 32 && num == 2)
{
UInt32 v1 = Get32(p + 12);
int index = FindPairIndex(sid_32_Names, ARRAY_SIZE(sid_32_Names), v1);
const UInt32 v1 = Get32(p + 12);
const int index = FindPairIndex(sid_32_Names, Z7_ARRAY_SIZE(sid_32_Names), v1);
if (index >= 0)
{
s += sid_32_Names[(unsigned)index].sz;
@@ -423,7 +423,7 @@ static void ParseSid(AString &s, const Byte *p, UInt32 lim, UInt32 &sidSize)
if (v0 == 21 && num == 5)
{
UInt32 v4 = Get32(p + 8 + 4 * 4);
int index = FindPairIndex(sid_21_Names, ARRAY_SIZE(sid_21_Names), v4);
const int index = FindPairIndex(sid_21_Names, Z7_ARRAY_SIZE(sid_21_Names), v4);
if (index >= 0)
{
s += sid_21_Names[(unsigned)index].sz;
@@ -432,7 +432,7 @@ static void ParseSid(AString &s, const Byte *p, UInt32 lim, UInt32 &sidSize)
}
if (v0 == 80 && num == 6)
{
for (unsigned i = 0; i < ARRAY_SIZE(services_to_name); i++)
for (unsigned i = 0; i < Z7_ARRAY_SIZE(services_to_name); i++)
{
const CServicesToName &sn = services_to_name[i];
int j;
@@ -457,7 +457,7 @@ static void ParseSid(AString &s, const Byte *p, UInt32 lim, UInt32 &sidSize)
}
for (UInt32 i = 0; i < num; i++)
{
s += '-';
s.Add_Minus();
s.Add_UInt32(Get32(p + 8 + i * 4));
}
}
@@ -475,10 +475,10 @@ static void ParseOwner(AString &s, const Byte *p, UInt32 size, UInt32 pos)
static void ParseAcl(AString &s, const Byte *p, UInt32 size, const char *strName, UInt32 flags, UInt32 offset)
{
UInt32 control = Get16(p + 2);
const UInt32 control = Get16(p + 2);
if ((flags & control) == 0)
return;
UInt32 pos = Get32(p + offset);
const UInt32 pos = Get32(p + offset);
s.Add_Space();
s += strName;
if (pos >= size)
@@ -489,7 +489,7 @@ static void ParseAcl(AString &s, const Byte *p, UInt32 size, const char *strName
return;
if (Get16(p) != 2) // revision
return;
UInt32 num = Get32(p + 4);
const UInt32 num = Get32(p + 4);
s.Add_UInt32(num);
/*
@@ -580,26 +580,26 @@ static bool CheckSid(const Byte *data, UInt32 size, UInt32 pos) throw()
size -= pos;
if (size < 8)
return false;
UInt32 rev = data[pos];
const UInt32 rev = data[pos];
if (rev != 1)
return false;
UInt32 num = data[pos + 1];
const UInt32 num = data[pos + 1];
return (8 + num * 4 <= size);
}
static bool CheckAcl(const Byte *p, UInt32 size, UInt32 flags, UInt32 offset) throw()
{
UInt32 control = Get16(p + 2);
const UInt32 control = Get16(p + 2);
if ((flags & control) == 0)
return true;
UInt32 pos = Get32(p + offset);
const UInt32 pos = Get32(p + offset);
if (pos >= size)
return false;
p += pos;
size -= pos;
if (size < 8)
return false;
UInt32 aclSize = Get16(p + 2);
const UInt32 aclSize = Get16(p + 2);
return (aclSize <= size);
}
@@ -686,22 +686,22 @@ bool ConvertNtReparseToString(const Byte *data, UInt32 size, UString &s)
if (size < 8)
return false;
UInt32 tag = Get32(data);
UInt32 len = Get16(data + 4);
const UInt32 tag = Get32(data);
const UInt32 len = Get16(data + 4);
if (len + 8 > size)
return false;
if (Get16(data + 6) != 0) // padding
return false;
/*
#define _my_IO_REPARSE_TAG_DEDUP (0x80000013L)
if (tag == _my_IO_REPARSE_TAG_DEDUP)
#define my_IO_REPARSE_TAG_DEDUP (0x80000013L)
if (tag == my_IO_REPARSE_TAG_DEDUP)
{
}
*/
{
int index = FindPairIndex(k_ReparseTags, ARRAY_SIZE(k_ReparseTags), tag);
const int index = FindPairIndex(k_ReparseTags, Z7_ARRAY_SIZE(k_ReparseTags), tag);
if (index >= 0)
s += k_ReparseTags[(unsigned)index].sz;
else
@@ -729,7 +729,7 @@ bool ConvertNtReparseToString(const Byte *data, UInt32 size, UString &s)
s += "...";
break;
}
unsigned b = data[i];
const unsigned b = data[i];
s += (char)GetHex((b >> 4) & 0xF);
s += (char)GetHex(b & 0xF);
}