This commit is contained in:
Igor Pavlov
2005-05-30 00:00:00 +00:00
committed by Kornel Lesiński
parent 8c1b5c7b7e
commit 3c510ba80b
926 changed files with 40559 additions and 23519 deletions

View File

@@ -2,8 +2,7 @@
#include "StdAfx.h"
#include <initguid.h>
#include "Common/MyInitGuid.h"
#include "Common/ComTry.h"
#include "Windows/PropVariant.h"
#include "../../ICoder.h"

View File

@@ -105,6 +105,10 @@ SOURCE=.\Rpm.def
# End Source File
# Begin Source File
SOURCE=.\Rpm.ico
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"StdAfx.h"
# End Source File
@@ -154,6 +158,14 @@ SOURCE=..\..\Compress\Copy\CopyCoder.h
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\Common\Alloc.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Alloc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\NewHandler.cpp
# End Source File
# Begin Source File
@@ -163,10 +175,6 @@ SOURCE=..\..\..\Common\NewHandler.h
# End Group
# Begin Source File
SOURCE=.\Rpm.ico
# End Source File
# Begin Source File
SOURCE=.\RpmHandler.cpp
# End Source File
# Begin Source File

View File

@@ -16,7 +16,6 @@
#include "../../Common/StreamObjects.h"
#include "../../Common/ProgressUtils.h"
#include "../../Common/LimitedStreams.h"
// #include "Interface/EnumStatProp.h"
#include "../../Compress/Copy/CopyCoder.h"
#include "../Common/ItemNameUtils.h"
@@ -29,7 +28,7 @@ namespace NRpm {
STATPROPSTG kProperties[] =
{
// { NULL, kpidPath, VT_BSTR},
{ NULL, kpidIsFolder, VT_BOOL},
// { NULL, kpidIsFolder, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
{ NULL, kpidPackedSize, VT_UI8}
};
@@ -40,13 +39,13 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
return S_OK;
}
STDMETHODIMP CHandler::GetNumberOfProperties(UINT32 *numProperties)
STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties)
{
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
return S_OK;
}
STDMETHODIMP CHandler::GetPropertyInfo(UINT32 index,
STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -58,20 +57,20 @@ STDMETHODIMP CHandler::GetPropertyInfo(UINT32 index,
return S_OK;
}
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UINT32 *numProperties)
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties)
{
*numProperties = 0;
return S_OK;
}
STDMETHODIMP CHandler::GetArchivePropertyInfo(UINT32 index,
STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
return E_INVALIDARG;
}
STDMETHODIMP CHandler::Open(IInStream *inStream,
const UINT64 *maxCheckStartPosition,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback)
{
COM_TRY_BEGIN
@@ -81,7 +80,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
return S_FALSE;
RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Pos));
m_InStream = inStream;
UINT64 endPosition;
UInt64 endPosition;
RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPosition));
m_Size = endPosition - m_Pos;
return S_OK;
@@ -99,13 +98,13 @@ STDMETHODIMP CHandler::Close()
return S_OK;
}
STDMETHODIMP CHandler::GetNumberOfItems(UINT32 *numItems)
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
*numItems = 1;
return S_OK;
}
STDMETHODIMP CHandler::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
NWindows::NCOM::CPropVariant propVariant;
@@ -130,11 +129,11 @@ STDMETHODIMP CHandler::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *val
COM_TRY_END
}
STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
INT32 _aTestMode, IArchiveExtractCallback *extractCallback)
STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
{
COM_TRY_BEGIN
bool allFilesMode = (numItems == UINT32(-1));
bool allFilesMode = (numItems == UInt32(-1));
if (allFilesMode)
numItems = 1;
if(numItems == 0)
@@ -146,14 +145,14 @@ STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
bool testMode = (_aTestMode != 0);
UINT64 currentTotalSize = 0;
UInt64 currentTotalSize = 0;
RINOK(extractCallback->SetTotal(m_Size));
RINOK(extractCallback->SetCompleted(&currentTotalSize));
CMyComPtr<ISequentialOutStream> realOutStream;
INT32 askMode;
Int32 askMode;
askMode = testMode ? NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
INT32 index = 0;
Int32 index = 0;
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));

View File

@@ -1,7 +1,5 @@
// RPM/Handler.h
// #pragma once
#ifndef __RPM_HANDLER_H
#define __RPM_HANDLER_H
@@ -19,29 +17,28 @@ public:
MY_UNKNOWN_IMP
STDMETHOD(Open)(IInStream *stream,
const UINT64 *maxCheckStartPosition,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
STDMETHOD(GetProperty)(UINT32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UINT32* indices, UINT32 numItems,
INT32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
STDMETHOD(GetPropertyInfo)(UINT32 index,
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UINT32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UINT32 index,
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
private:
CMyComPtr<IInStream> m_InStream;
UINT64 m_Pos;
UINT64 m_Size;
UInt64 m_Pos;
UInt64 m_Size;
};
}}

View File

@@ -1,7 +1,5 @@
// Archive/RpmHeader.h
// #pragma once
#ifndef __ARCHIVE_RPM_HEADER_H
#define __ARCHIVE_RPM_HEADER_H
@@ -10,9 +8,6 @@
namespace NArchive {
namespace NRpm {
#pragma pack(push, PragmaRPMHeaders)
#pragma pack(push, 1)
/* Reference: lib/signature.h of rpm package */
#define RPMSIG_NONE 0 /* Do not change! */
/* The following types are no longer generated */
@@ -22,68 +17,47 @@ namespace NRpm {
#define RPMSIG_HEADERSIG 5 /* New Header style signature */
const UInt32 kLeadSize = 96;
struct CLead
{
unsigned char Magic[4];
unsigned char Major; /* not supported ver1, only support 2,3 and lator */
unsigned char Major; // not supported ver1, only support 2,3 and lator
unsigned char Minor;
short Type;
short ArchNum;
UInt16 Type;
UInt16 ArchNum;
char Name[66];
short OSNum;
short SignatureType;
char Reserved[16]; /* pad to 96 bytes -- 8 byte aligned */
UInt16 OSNum;
UInt16 SignatureType;
char Reserved[16]; // pad to 96 bytes -- 8 byte aligned
bool MagicCheck() const
{ return Magic[0] == 0xed && Magic[1] == 0xab && Magic[2] == 0xee && Magic[3] == 0xdb; };
static short my_htons(short s)
{
const unsigned char *p = (const unsigned char*)&s;
return (short(p[0]) << 8) + (p[1]); }
;
void hton()
{
Type = my_htons(Type);
ArchNum = my_htons(ArchNum);
OSNum = my_htons(OSNum);
SignatureType = my_htons(SignatureType);
};
};
const UInt32 kEntryInfoSize = 16;
/*
struct CEntryInfo
{
int Tag;
int Type;
int Offset; /* Offset from beginning of data segment, only defined on disk */
int Offset; // Offset from beginning of data segment, only defined on disk
int Count;
};
*/
/* case: SignatureType == RPMSIG_HEADERSIG */
// case: SignatureType == RPMSIG_HEADERSIG
const UInt32 kCSigHeaderSigSize = 16;
struct CSigHeaderSig
{
unsigned char Magic[4];
int Reserved;
int IndexLen; /* count of index entries */
int DataLen; /* number of bytes */
int MagicCheck()
UInt32 Reserved;
UInt32 IndexLen; // count of index entries
UInt32 DataLen; // number of bytes
bool MagicCheck()
{ return Magic[0] == 0x8e && Magic[1] == 0xad && Magic[2] == 0xe8 && Magic[3] == 0x01; };
int GetLostHeaderLen()
{ return IndexLen * sizeof(CEntryInfo) + DataLen; };
long my_htonl(long s)
{
unsigned char *p = (unsigned char*)&s;
return (p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3];
};
void hton()
{
IndexLen = my_htonl(IndexLen);
DataLen = my_htonl(DataLen);
};
UInt32 GetLostHeaderLen()
{ return IndexLen * kEntryInfoSize + DataLen; };
};
#pragma pack(pop)
#pragma pack(pop, PragmaRPMHeaders)
}}
#endif

View File

@@ -11,18 +11,65 @@
namespace NArchive {
namespace NRpm {
static UInt16 GetUInt16(const char *data)
{
return (Byte)data[1] | (((UInt16)(Byte)data[0]) << 8);
}
static UInt32 GetUInt32(const char *data)
{
return
((UInt32)(Byte)data[3]) |
(((UInt32)(Byte)data[2]) << 8) |
(((UInt32)(Byte)data[1]) << 16) |
(((UInt32)(Byte)data[0]) << 24);
}
static HRESULT RedSigHeaderSig(IInStream *inStream, CSigHeaderSig &h)
{
char dat[kCSigHeaderSigSize];
char *cur = dat;
UInt32 processedSize;
RINOK(inStream->Read(dat, kCSigHeaderSigSize, &processedSize));
if (kCSigHeaderSigSize != processedSize)
return S_FALSE;
memmove(h.Magic, cur, 4);
cur += 4;
cur += 4;
h.IndexLen = GetUInt32(cur);
cur += 4;
h.DataLen = GetUInt32(cur);
return S_OK;
}
HRESULT OpenArchive(IInStream *inStream)
{
UINT64 pos;
UInt64 pos;
char leadData[kLeadSize];
char *cur = leadData;
CLead lead;
UINT32 processedSize;
RINOK(inStream->Read(&lead, sizeof(lead), &processedSize));
if (sizeof(lead) != processedSize)
UInt32 processedSize;
RINOK(inStream->Read(leadData, kLeadSize, &processedSize));
if (kLeadSize != processedSize)
return S_FALSE;
memmove(lead.Magic, cur, 4);
cur += 4;
lead.Major = *cur++;
lead.Minor = *cur++;
lead.Type = GetUInt16(cur);
cur += 2;
lead.ArchNum = GetUInt16(cur);
cur += 2;
memmove(lead.Name, cur, sizeof(lead.Name));
cur += sizeof(lead.Name);
lead.OSNum = GetUInt16(cur);
cur += 2;
lead.SignatureType = GetUInt16(cur);
cur += 2;
if (!lead.MagicCheck() || lead.Major < 3)
return S_FALSE;
lead.hton();
CSigHeaderSig sigHeader, header;
if(lead.SignatureType == RPMSIG_NONE)
@@ -31,18 +78,15 @@ HRESULT OpenArchive(IInStream *inStream)
}
else if(lead.SignatureType == RPMSIG_PGP262_1024)
{
UINT64 pos;
UInt64 pos;
RINOK(inStream->Seek(256, STREAM_SEEK_CUR, &pos));
}
else if(lead.SignatureType == RPMSIG_HEADERSIG)
{
RINOK(inStream->Read(&sigHeader, sizeof(sigHeader), &processedSize));
if (sizeof(sigHeader) != processedSize)
return S_FALSE;
RINOK(RedSigHeaderSig(inStream, sigHeader));
if(!sigHeader.MagicCheck())
return S_FALSE;
sigHeader.hton();
int len = sigHeader.GetLostHeaderLen();
UInt32 len = sigHeader.GetLostHeaderLen();
RINOK(inStream->Seek(len, STREAM_SEEK_CUR, &pos));
if((pos % 8) != 0)
{
@@ -53,12 +97,9 @@ HRESULT OpenArchive(IInStream *inStream)
else
return S_FALSE;
RINOK(inStream->Read(&header, sizeof(header), &processedSize));
if (sizeof(header) != processedSize)
return S_FALSE;
RINOK(RedSigHeaderSig(inStream, header));
if(!header.MagicCheck())
return S_FALSE;
header.hton();
int headerLen = header.GetLostHeaderLen();
if(headerLen == -1)
return S_FALSE;
@@ -66,5 +107,4 @@ HRESULT OpenArchive(IInStream *inStream)
return S_OK;
}
}}

View File

@@ -1,7 +1,5 @@
// Archive/RpmIn.h
// #pragma once
#ifndef __ARCHIVE_RPM_IN_H
#define __ARCHIVE_RPM_IN_H

View File

@@ -1,3 +1,3 @@
// StdAfx.cpp
#include "stdafx.h"
#include "StdAfx.h"

View File

@@ -1,8 +1,8 @@
// stdafx.h
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include <windows.h>
#include "../../../Common/MyWindows.h"
#endif
#endif

View File

@@ -75,8 +75,8 @@ IDI_ICON1 ICON DISCARDABLE "Rpm.ico"
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,9,2,0
PRODUCTVERSION 3,9,2,0
FILEVERSION 4,7,0,0
PRODUCTVERSION 4,7,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -94,14 +94,14 @@ BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "Igor Pavlov\0"
VALUE "FileDescription", "RPM Plugin for 7-Zip\0"
VALUE "FileVersion", "3, 9, 2, 0\0"
VALUE "FileVersion", "4, 7, 0, 0\0"
VALUE "InternalName", "rpm\0"
VALUE "LegalCopyright", "Copyright (C) 1999-2003 Igor Pavlov\0"
VALUE "LegalCopyright", "Copyright (C) 1999-2004 Igor Pavlov\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "rpm.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "7-Zip\0"
VALUE "ProductVersion", "3, 9, 2, 0\0"
VALUE "ProductVersion", "4, 7, 0, 0\0"
VALUE "SpecialBuild", "\0"
END
END