mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 22:07:07 -06:00
9.13
This commit is contained in:
committed by
Kornel Lesiński
parent
76b173af78
commit
3dacb5eb8a
@@ -41,7 +41,7 @@ namespace NMacho {
|
||||
|
||||
#define MACH_SECT_ATTR_ZEROFILL 1
|
||||
|
||||
const char *g_SectTypes[] =
|
||||
static const char *g_SectTypes[] =
|
||||
{
|
||||
"REGULAR",
|
||||
"ZEROFILL",
|
||||
@@ -60,7 +60,7 @@ const char *g_SectTypes[] =
|
||||
"16BYTE_LITERALS"
|
||||
};
|
||||
|
||||
const char *g_FileTypes[] =
|
||||
static const char *g_FileTypes[] =
|
||||
{
|
||||
"0",
|
||||
"OBJECT",
|
||||
@@ -111,11 +111,18 @@ struct CSection
|
||||
char Name[kNameSize];
|
||||
char SegName[kNameSize];
|
||||
UInt64 Va;
|
||||
UInt64 Size;
|
||||
UInt32 Pa;
|
||||
UInt64 Pa;
|
||||
UInt64 VSize;
|
||||
UInt64 PSize;
|
||||
|
||||
UInt32 Flags;
|
||||
int SegmentIndex;
|
||||
UInt64 GetPackSize() const { return Flags == MACH_SECT_ATTR_ZEROFILL ? 0 : Size; }
|
||||
|
||||
bool IsDummy;
|
||||
|
||||
CSection(): IsDummy(false) {}
|
||||
// UInt64 GetPackSize() const { return Flags == MACH_SECT_ATTR_ZEROFILL ? 0 : Size; }
|
||||
UInt64 GetPackSize() const { return PSize; }
|
||||
};
|
||||
|
||||
|
||||
@@ -195,8 +202,9 @@ bool CHandler::Parse(const Byte *buf, UInt32 size)
|
||||
if (cmdSize < offs)
|
||||
break;
|
||||
|
||||
UInt64 vmAddr, vmSize, phAddr, phSize;
|
||||
|
||||
{
|
||||
UInt64 vmAddr, vmSize, phAddr, phSize;
|
||||
if (cmd == MACH_CMD_SEGMENT_64)
|
||||
{
|
||||
vmAddr = Get64(buf + 0x18, be);
|
||||
@@ -226,7 +234,19 @@ bool CHandler::Parse(const Byte *buf, UInt32 size)
|
||||
if (numSections > (1 << 8))
|
||||
return false;
|
||||
|
||||
while (numSections-- != 0)
|
||||
if (numSections == 0)
|
||||
{
|
||||
CSection section;
|
||||
section.IsDummy = true;
|
||||
section.SegmentIndex = _segments.Size() - 1;
|
||||
section.Va = vmAddr;
|
||||
section.PSize = phSize;
|
||||
section.VSize = vmSize;
|
||||
section.Pa = phAddr;
|
||||
section.Flags = 0;
|
||||
_sections.Add(section);
|
||||
}
|
||||
else do
|
||||
{
|
||||
CSection section;
|
||||
UInt32 headerSize = (cmd == MACH_CMD_SEGMENT_64) ? 0x50 : 0x44;
|
||||
@@ -236,23 +256,29 @@ bool CHandler::Parse(const Byte *buf, UInt32 size)
|
||||
if (cmd == MACH_CMD_SEGMENT_64)
|
||||
{
|
||||
section.Va = Get64(p + 0x20, be);
|
||||
section.Size = Get64(p + 0x28, be);
|
||||
section.VSize = Get64(p + 0x28, be);
|
||||
section.Pa = Get32(p + 0x30, be);
|
||||
section.Flags = Get32(p + 0x40, be);
|
||||
}
|
||||
else
|
||||
{
|
||||
section.Va = Get32(p + 0x20, be);
|
||||
section.Size = Get32(p + 0x24, be);
|
||||
section.VSize = Get32(p + 0x24, be);
|
||||
section.Pa = Get32(p + 0x28, be);
|
||||
section.Flags = Get32(p + 0x38, be);
|
||||
}
|
||||
if (section.Flags == MACH_SECT_ATTR_ZEROFILL)
|
||||
section.PSize = 0;
|
||||
else
|
||||
section.PSize = section.VSize;
|
||||
memcpy(section.Name, p, kNameSize);
|
||||
memcpy(section.SegName, p + kNameSize, kNameSize);
|
||||
section.SegmentIndex = _segments.Size() - 1;
|
||||
_sections.Add(section);
|
||||
offs += headerSize;
|
||||
}
|
||||
while (--numSections);
|
||||
|
||||
if (offs != cmdSize)
|
||||
return false;
|
||||
}
|
||||
@@ -263,7 +289,7 @@ bool CHandler::Parse(const Byte *buf, UInt32 size)
|
||||
return reduceCommands || (size == 0);
|
||||
}
|
||||
|
||||
STATPROPSTG kArcProps[] =
|
||||
static STATPROPSTG kArcProps[] =
|
||||
{
|
||||
{ NULL, kpidCpu, VT_BSTR},
|
||||
{ NULL, kpidBit64, VT_BOOL},
|
||||
@@ -273,7 +299,7 @@ STATPROPSTG kArcProps[] =
|
||||
{ NULL, kpidHeadersSize, VT_UI4}
|
||||
};
|
||||
|
||||
STATPROPSTG kProps[] =
|
||||
static STATPROPSTG kProps[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
@@ -333,10 +359,17 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
const CSection &item = _sections[index];
|
||||
switch(propID)
|
||||
{
|
||||
case kpidPath: StringToProp(GetName(_segments[item.SegmentIndex].Name) + GetName(item.Name), prop); break;
|
||||
case kpidSize: prop = (UInt64)item.Size; break;
|
||||
case kpidPath:
|
||||
{
|
||||
AString s = GetName(_segments[item.SegmentIndex].Name);
|
||||
if (!item.IsDummy)
|
||||
s += GetName(item.Name);
|
||||
StringToProp(s, prop);
|
||||
break;
|
||||
}
|
||||
case kpidSize: /* prop = (UInt64)item.VSize; break; */
|
||||
case kpidPackSize: prop = (UInt64)item.GetPackSize(); break;
|
||||
case kpidCharacts: StringToProp(SectFlagsToString(item.Flags), prop); break;
|
||||
case kpidCharacts: if (!item.IsDummy) StringToProp(SectFlagsToString(item.Flags), prop); break;
|
||||
case kpidOffset: prop = item.Pa; break;
|
||||
case kpidVa: prop = item.Va; break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user