Merged PR 2844732: IAppx*Utf8 interfaces variants
Add UTF8 variant to public APIs that use LPWSTR or LPCWSTR. New Interfaces: • IAppxBlockMapFileUtf8 • IAppxBlockMapReaderUtf8 • IAppxBundleManifestPackageInfoUtf8 • IAppxBundleReaderUtf8 • IAppxFactoryUtf8 • IAppxFileUtf8 • IAppxManifestApplicationUtf8 • IAppxManifestPackageDependencyUtf8 • IAppxManifestPackageIdUtf8 • IAppxManifestPropertiesUtf8 • IAppxManifestQualifiedResourceUtf8 • IAppxManifestResourcesEnumeratorUtf8 • IAppxManifestTargetDeviceFamilyUtf8 • IAppxPackageReaderUtf8 This change also fixes a bug were all non-AppPackaging public interfaces (eg. IMsixElement) had their IID_I* set to 0 for Windows only. GUID definition is now defined on AppxPackaging.hpp removing the need of AppPackaging_i.cpp
This commit is contained in:
Родитель
cc3fcf0142
Коммит
7c84b3fa66
|
@ -114,12 +114,12 @@ public:
|
|||
OverrideLanguages(char** languages, int numLanguages) : m_languages(languages), m_numLanguages(numLanguages) {}
|
||||
|
||||
// IUnknown
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() override
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() noexcept override
|
||||
{
|
||||
return ++m_ref;
|
||||
}
|
||||
|
||||
virtual ULONG STDMETHODCALLTYPE Release() override
|
||||
virtual ULONG STDMETHODCALLTYPE Release() noexcept override
|
||||
{
|
||||
if (--m_ref == 0)
|
||||
{
|
||||
|
|
|
@ -187,12 +187,12 @@ public:
|
|||
|
||||
// IUnknown.
|
||||
// This is the loong way. Look at ComClass<> in src\inc\ComHelper.hpp for an example on how to avoid implementing IUnknown without pain.
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() override
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() noexcept override
|
||||
{
|
||||
return ++m_ref;
|
||||
}
|
||||
|
||||
virtual ULONG STDMETHODCALLTYPE Release() override
|
||||
virtual ULONG STDMETHODCALLTYPE Release() noexcept override
|
||||
{
|
||||
if (--m_ref == 0)
|
||||
{
|
||||
|
@ -342,12 +342,12 @@ public:
|
|||
MyStreamFactory(const std::wstring& path) : m_path(path), m_ref(1) {}
|
||||
|
||||
// IUnknown
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() override
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() noexcept override
|
||||
{
|
||||
return ++m_ref;
|
||||
}
|
||||
|
||||
virtual ULONG STDMETHODCALLTYPE Release() override
|
||||
virtual ULONG STDMETHODCALLTYPE Release() noexcept override
|
||||
{
|
||||
if (--m_ref == 0)
|
||||
{
|
||||
|
@ -382,16 +382,22 @@ public:
|
|||
|
||||
// IMsixStreamFactory
|
||||
virtual HRESULT STDMETHODCALLTYPE CreateStreamOnRelativePath(LPCWSTR relativePath, IStream** stream) noexcept override
|
||||
{
|
||||
return CreateStreamOnRelativePathUtf8(utf16_to_utf8(relativePath).c_str(), stream);
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE CreateStreamOnRelativePathUtf8(LPCSTR relativePath, IStream** stream) noexcept override
|
||||
{
|
||||
*stream = nullptr;
|
||||
ComPtr<IStream> result;
|
||||
auto path = utf16_to_utf8(m_path);
|
||||
#ifdef WIN32
|
||||
std::wstring fullFileName = m_path + std::wstring(L"\\") + relativePath;
|
||||
std::string fullFileName = path + std::string("\\") + relativePath;
|
||||
#else
|
||||
std::wstring fullFileName = m_path + std::wstring(L"/") + relativePath;
|
||||
std::string fullFileName = path + std::string("/") + relativePath;
|
||||
std::replace(fullFileName.begin(), fullFileName.end(), '\\', '/' );
|
||||
#endif
|
||||
RETURN_IF_FAILED(ComPtr<IStream>::MakeAndInitialize<MyStream>(&result, utf16_to_utf8(fullFileName), MyStream::Mode::READ));
|
||||
RETURN_IF_FAILED(ComPtr<IStream>::MakeAndInitialize<MyStream>(&result, fullFileName, MyStream::Mode::READ));
|
||||
if (result.Get() != nullptr)
|
||||
{
|
||||
*stream = result.Detach();
|
||||
|
|
|
@ -20,9 +20,8 @@
|
|||
#include "Enumerators.hpp"
|
||||
|
||||
// internal interface
|
||||
EXTERN_C const IID IID_IAppxBlockMapInternal;
|
||||
#ifndef WIN32
|
||||
// {67fed21a-70ef-4175-8f12-415b213ab6d2}
|
||||
#ifndef WIN32
|
||||
interface IAppxBlockMapInternal : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
|
@ -31,11 +30,11 @@ class IAppxBlockMapInternal : public IUnknown
|
|||
#endif
|
||||
{
|
||||
public:
|
||||
virtual std::vector<std::string> GetFileNames() = 0;
|
||||
virtual std::vector<MSIX::Block> GetBlocks(const std::string& fileName) = 0;
|
||||
virtual std::vector<std::string> GetFileNames() = 0;
|
||||
virtual std::vector<MSIX::Block> GetBlocks(const std::string& fileName) = 0;
|
||||
virtual MSIX::ComPtr<IAppxBlockMapFile> GetFile(const std::string& fileName) = 0;
|
||||
};
|
||||
SpecializeUuidOfImpl(IAppxBlockMapInternal);
|
||||
MSIX_INTERFACE(IAppxBlockMapInternal, 0x67fed21a,0x70ef,0x4175,0x8f,0x12,0x41,0x5b,0x21,0x3a,0xb6,0xd2);
|
||||
|
||||
namespace MSIX {
|
||||
|
||||
|
@ -66,7 +65,7 @@ namespace MSIX {
|
|||
Block* m_block;
|
||||
};
|
||||
|
||||
class AppxBlockMapFile final : public MSIX::ComClass<AppxBlockMapFile, IAppxBlockMapFile>
|
||||
class AppxBlockMapFile final : public MSIX::ComClass<AppxBlockMapFile, IAppxBlockMapFile, IAppxBlockMapFileUtf8 >
|
||||
{
|
||||
public:
|
||||
AppxBlockMapFile(
|
||||
|
@ -129,6 +128,13 @@ namespace MSIX {
|
|||
return static_cast<HRESULT>(Error::NotImplemented);
|
||||
}
|
||||
|
||||
// IAppxBlockMapFileUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetName(LPSTR *name) noexcept override try
|
||||
{
|
||||
ThrowHrIfFailed(m_factory->MarshalOutStringUtf8(m_name, name));
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
private:
|
||||
std::vector<ComPtr<IAppxBlockMapBlock>> m_blockMapBlocks;
|
||||
std::vector<Block>* m_blocks;
|
||||
|
@ -139,7 +145,7 @@ namespace MSIX {
|
|||
};
|
||||
|
||||
// Object backed by AppxBlockMap.xml
|
||||
class AppxBlockMapObject final : public MSIX::ComClass<AppxBlockMapObject, IAppxBlockMapReader, IVerifierObject, IAppxBlockMapInternal>
|
||||
class AppxBlockMapObject final : public MSIX::ComClass<AppxBlockMapObject, IAppxBlockMapReader, IVerifierObject, IAppxBlockMapInternal, IAppxBlockMapReaderUtf8 >
|
||||
{
|
||||
public:
|
||||
AppxBlockMapObject(IMsixFactory* factory, const ComPtr<IStream>& stream);
|
||||
|
@ -161,6 +167,9 @@ namespace MSIX {
|
|||
std::vector<Block> GetBlocks(const std::string& fileName) override;
|
||||
MSIX::ComPtr<IAppxBlockMapFile> GetFile(const std::string& fileName) override;
|
||||
|
||||
// IAppxBlockMapReaderUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetFile(LPCSTR filename, IAppxBlockMapFile **file) noexcept override;
|
||||
|
||||
protected:
|
||||
std::map<std::string, std::vector<Block>> m_blockMap;
|
||||
std::map<std::string, ComPtr<IAppxBlockMapFile>> m_blockMapFiles;
|
||||
|
|
|
@ -12,9 +12,8 @@
|
|||
#include "Applicability.hpp"
|
||||
#include "VerifierObject.hpp"
|
||||
|
||||
EXTERN_C const IID IID_IBundleInfo;
|
||||
#ifndef WIN32
|
||||
// {ff82ffcd-747a-4df9-8879-853ab9dd15a1}
|
||||
#ifndef WIN32
|
||||
interface IBundleInfo : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
|
@ -25,10 +24,10 @@ class IBundleInfo : public IUnknown
|
|||
public:
|
||||
virtual std::vector<MSIX::ComPtr<IAppxBundleManifestPackageInfo>>& GetPackages() = 0;
|
||||
};
|
||||
MSIX_INTERFACE(IBundleInfo, 0xff82ffcd,0x747a,0x4df9,0x88,0x79,0x85,0x3a,0xb9,0xdd,0x15,0xa1);
|
||||
|
||||
EXTERN_C const IID IID_IAppxBundleManifestPackageInfoInternal;
|
||||
#ifndef WIN32
|
||||
// {32e6fcf0-729b-401d-9dbc-f927b494f9af}
|
||||
#ifndef WIN32
|
||||
interface IAppxBundleManifestPackageInfoInternal : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
|
@ -42,9 +41,7 @@ public:
|
|||
virtual const std::uint64_t GetOffset() = 0;
|
||||
virtual bool HasQualifiedResources() = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IAppxBundleManifestPackageInfoInternal);
|
||||
SpecializeUuidOfImpl(IBundleInfo);
|
||||
MSIX_INTERFACE(IAppxBundleManifestPackageInfoInternal, 0x32e6fcf0,0x729b,0x401d,0x9d,0xbc,0xf9,0x27,0xb4,0x94,0xf9,0xaf);
|
||||
|
||||
namespace MSIX {
|
||||
class AppxBundleManifestObject final : public ComClass<AppxBundleManifestObject, IAppxBundleManifestReader, IVerifierObject, IBundleInfo>
|
||||
|
@ -73,7 +70,7 @@ namespace MSIX {
|
|||
std::vector<ComPtr<IAppxBundleManifestPackageInfo>> m_packages;
|
||||
};
|
||||
|
||||
class AppxBundleQualifiedResource final : public MSIX::ComClass<AppxBundleQualifiedResource, IAppxManifestQualifiedResource>
|
||||
class AppxBundleQualifiedResource final : public MSIX::ComClass<AppxBundleQualifiedResource, IAppxManifestQualifiedResource, IAppxManifestQualifiedResourceUtf8>
|
||||
{
|
||||
public:
|
||||
AppxBundleQualifiedResource(IMsixFactory* factory, const std::string& language) : m_factory(factory), m_language(language) {}
|
||||
|
@ -95,12 +92,18 @@ namespace MSIX {
|
|||
return static_cast<HRESULT>(Error::NotImplemented);
|
||||
}
|
||||
|
||||
// IAppxManifestQualifiedResourceUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetLanguage(LPSTR *language) noexcept override try
|
||||
{
|
||||
return m_factory->MarshalOutStringUtf8(m_language, language);
|
||||
} CATCH_RETURN();
|
||||
|
||||
protected:
|
||||
IMsixFactory* m_factory;
|
||||
std::string m_language;
|
||||
};
|
||||
|
||||
class AppxBundleManifestPackageInfo final : public ComClass<AppxBundleManifestPackageInfo, IAppxBundleManifestPackageInfo, IAppxBundleManifestPackageInfoInternal>
|
||||
class AppxBundleManifestPackageInfo final : public ComClass<AppxBundleManifestPackageInfo, IAppxBundleManifestPackageInfo, IAppxBundleManifestPackageInfoInternal, IAppxBundleManifestPackageInfoUtf8>
|
||||
{
|
||||
public:
|
||||
AppxBundleManifestPackageInfo(
|
||||
|
@ -130,6 +133,9 @@ namespace MSIX {
|
|||
const std::uint64_t GetOffset() override { return m_offset; }
|
||||
bool HasQualifiedResources() override { return !m_languages.empty(); }
|
||||
|
||||
// IAppxBundleManifestPackageInfoUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetFileName(LPSTR *fileName) noexcept override;
|
||||
|
||||
private:
|
||||
IMsixFactory* m_factory;
|
||||
std::string m_fileName;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <vector>
|
||||
|
||||
namespace MSIX {
|
||||
class AppxFactory final : public ComClass<AppxFactory, IMsixFactory, IAppxFactory, IXmlFactory, IAppxBundleFactory, IMsixFactoryOverrides>
|
||||
class AppxFactory final : public ComClass<AppxFactory, IMsixFactory, IAppxFactory, IXmlFactory, IAppxBundleFactory, IMsixFactoryOverrides, IAppxFactoryUtf8>
|
||||
{
|
||||
public:
|
||||
AppxFactory(MSIX_VALIDATION_OPTION validationOptions, MSIX_APPLICABILITY_OPTIONS applicability, COTASKMEMALLOC* memalloc, COTASKMEMFREE* memfree ) :
|
||||
|
@ -30,16 +30,11 @@ namespace MSIX {
|
|||
~AppxFactory() {}
|
||||
|
||||
// IAppxFactory
|
||||
HRESULT STDMETHODCALLTYPE CreatePackageWriter(IStream* outputStream, APPX_PACKAGE_SETTINGS* , IAppxPackageWriter** packageWriter) noexcept override;
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreatePackageWriter(IStream* outputStream, APPX_PACKAGE_SETTINGS* , IAppxPackageWriter** packageWriter) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE CreatePackageReader (IStream* inputStream, IAppxPackageReader** packageReader) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE CreateManifestReader(IStream* inputStream, IAppxManifestReader** manifestReader) noexcept override ;
|
||||
HRESULT STDMETHODCALLTYPE CreateBlockMapReader (IStream* inputStream, IAppxBlockMapReader** blockMapReader) noexcept override;
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateValidatedBlockMapReader (
|
||||
IStream* blockMapStream,
|
||||
LPCWSTR signatureFileName,
|
||||
IAppxBlockMapReader** blockMapReader) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE CreateManifestReader(IStream* inputStream, IAppxManifestReader** manifestReader) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE CreateBlockMapReader(IStream* inputStream, IAppxBlockMapReader** blockMapReader) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE CreateValidatedBlockMapReader(IStream* blockMapStream, LPCWSTR signatureFileName, IAppxBlockMapReader** blockMapReader) noexcept override;
|
||||
|
||||
// IAppxBundleFactory
|
||||
HRESULT STDMETHODCALLTYPE CreateBundleWriter(IStream *outputStream, UINT64 bundleVersion, IAppxBundleWriter **bundleWriter) noexcept override;
|
||||
|
@ -48,10 +43,11 @@ namespace MSIX {
|
|||
|
||||
// IMsixFactory
|
||||
HRESULT MarshalOutString(std::string& internal, LPWSTR *result) noexcept override;
|
||||
HRESULT MarshalOutWstring(std::wstring& internal, LPWSTR* result) noexcept override;
|
||||
HRESULT MarshalOutStringUtf8(std::string& internal, LPSTR* result) noexcept override;
|
||||
HRESULT MarshalOutBytes(std::vector<std::uint8_t>& data, UINT32* size, BYTE** buffer) noexcept override;
|
||||
MSIX_VALIDATION_OPTION GetValidationOptions() override { return m_validationOptions; }
|
||||
ComPtr<IStream> GetResource(const std::string& resource) override;
|
||||
HRESULT MarshalOutWstring(std::wstring& internal, LPWSTR* result) noexcept override;
|
||||
|
||||
// IXmlFactory
|
||||
MSIX::ComPtr<IXmlDom> CreateDomFromStream(XmlContentType footPrintType, const ComPtr<IStream>& stream) override
|
||||
|
@ -63,6 +59,9 @@ namespace MSIX {
|
|||
HRESULT STDMETHODCALLTYPE SpecifyExtension(MSIX_FACTORY_EXTENSION name, IUnknown* extension) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE GetCurrentSpecifiedExtension(MSIX_FACTORY_EXTENSION name, IUnknown** extension) noexcept override;
|
||||
|
||||
// IAppxFactoryUtf8
|
||||
HRESULT STDMETHODCALLTYPE CreateValidatedBlockMapReader(IStream* blockMapStream, LPCSTR signatureFileName, IAppxBlockMapReader** blockMapReader) noexcept override;
|
||||
|
||||
ComPtr<IXmlFactory> m_xmlFactory;
|
||||
COTASKMEMALLOC* m_memalloc;
|
||||
COTASKMEMFREE* m_memfree;
|
||||
|
@ -72,5 +71,9 @@ namespace MSIX {
|
|||
MSIX_APPLICABILITY_OPTIONS m_applicabilityFlags;
|
||||
ComPtr<IMsixStreamFactory> m_streamFactory;
|
||||
ComPtr<IMsixApplicabilityLanguagesEnumerator> m_applicabilityLanguagesEnumerator;
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
void MarshalOutStringHelper(std::size_t size, T* from, T** to);
|
||||
};
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
#include "StreamBase.hpp"
|
||||
|
||||
namespace MSIX {
|
||||
class AppxFile : public ComClass<AppxFile, IAppxFile>
|
||||
class AppxFile : public ComClass<AppxFile, IAppxFile, IAppxFileUtf8>
|
||||
{
|
||||
public:
|
||||
AppxFile(IMsixFactory* factory, const std::string& name, const ComPtr<IStream>& stream) : m_factory(factory), m_name(name), m_stream(stream)
|
||||
|
@ -74,6 +74,17 @@ namespace MSIX {
|
|||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IAppxFileUtf8
|
||||
virtual HRESULT STDMETHODCALLTYPE GetContentType(LPSTR* contentType) noexcept override
|
||||
{
|
||||
return static_cast<HRESULT>(Error::NotImplemented);
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetName(LPSTR* fileName) noexcept override try
|
||||
{
|
||||
return m_factory->MarshalOutStringUtf8(m_name, fileName);
|
||||
} CATCH_RETURN();
|
||||
|
||||
protected:
|
||||
std::string m_name;
|
||||
ComPtr<IStream> m_stream;
|
||||
|
|
|
@ -18,9 +18,8 @@
|
|||
#include "IXml.hpp"
|
||||
#include "UnicodeConversion.hpp"
|
||||
|
||||
EXTERN_C const IID IID_IAppxManifestObject;
|
||||
#ifndef WIN32
|
||||
// {eff6d561-a236-4058-9f1d-8f93633fba4b}
|
||||
#ifndef WIN32
|
||||
interface IAppxManifestObject : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
|
@ -31,13 +30,11 @@ class IAppxManifestObject : public IUnknown
|
|||
public:
|
||||
virtual const MSIX_PLATFORMS GetPlatform() = 0;
|
||||
};
|
||||
|
||||
|
||||
SpecializeUuidOfImpl(IAppxManifestObject);
|
||||
MSIX_INTERFACE(IAppxManifestObject, 0xeff6d561,0xa236,0x4058,0x9f,0x1d,0x8f,0x93,0x63,0x3f,0xba,0x4b);
|
||||
|
||||
namespace MSIX {
|
||||
|
||||
class AppxManifestTargetDeviceFamily final : public ComClass<AppxManifestTargetDeviceFamily, IAppxManifestTargetDeviceFamily>
|
||||
class AppxManifestTargetDeviceFamily final : public ComClass<AppxManifestTargetDeviceFamily, IAppxManifestTargetDeviceFamily, IAppxManifestTargetDeviceFamilyUtf8>
|
||||
{
|
||||
public:
|
||||
AppxManifestTargetDeviceFamily(IMsixFactory* factory, std::string& name, std::string& minVersion, std::string& maxVersion) :
|
||||
|
@ -47,6 +44,7 @@ namespace MSIX {
|
|||
m_maxVersion = DecodeVersionNumber(maxVersion);
|
||||
}
|
||||
|
||||
// IAppxManifestTargetDeviceFamily
|
||||
HRESULT STDMETHODCALLTYPE GetName(LPWSTR* name) noexcept override try
|
||||
{
|
||||
return m_factory->MarshalOutString(m_name, name);
|
||||
|
@ -66,6 +64,12 @@ namespace MSIX {
|
|||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IAppxManifestTargetDeviceFamilyUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetName(LPSTR* name) noexcept override try
|
||||
{
|
||||
return m_factory->MarshalOutStringUtf8(m_name, name);
|
||||
} CATCH_RETURN();
|
||||
|
||||
protected:
|
||||
IMsixFactory* m_factory;
|
||||
std::string m_name;
|
||||
|
@ -73,14 +77,15 @@ namespace MSIX {
|
|||
std::uint64_t m_maxVersion;
|
||||
};
|
||||
|
||||
class AppxManifestApplication final : public ComClass<AppxManifestApplication, IAppxManifestApplication>
|
||||
class AppxManifestApplication final : public ComClass<AppxManifestApplication, IAppxManifestApplication, IAppxManifestApplicationUtf8>
|
||||
{
|
||||
public:
|
||||
AppxManifestApplication(IMsixFactory* factory, std::string& aumid) :
|
||||
m_factory(factory), m_aumid(aumid)
|
||||
{}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetStringValue(LPCWSTR name, LPWSTR* value) override
|
||||
// IAppxManifestApplication
|
||||
HRESULT STDMETHODCALLTYPE GetStringValue(LPCWSTR name, LPWSTR* value) noexcept override
|
||||
{
|
||||
return static_cast<HRESULT>(Error::NotImplemented);
|
||||
}
|
||||
|
@ -90,28 +95,33 @@ namespace MSIX {
|
|||
return m_factory->MarshalOutString(m_aumid, appUserModelId);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IAppxManifestApplicationUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetStringValue(LPCSTR name, LPSTR* value) noexcept override
|
||||
{
|
||||
return static_cast<HRESULT>(Error::NotImplemented);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetAppUserModelId(LPSTR* appUserModelId) noexcept override try
|
||||
{
|
||||
return m_factory->MarshalOutStringUtf8(m_aumid, appUserModelId);
|
||||
} CATCH_RETURN();
|
||||
|
||||
protected:
|
||||
IMsixFactory* m_factory;
|
||||
std::string m_aumid;
|
||||
};
|
||||
|
||||
class AppxManifestProperties final : public ComClass<AppxManifestProperties, IAppxManifestProperties>
|
||||
class AppxManifestProperties final : public ComClass<AppxManifestProperties, IAppxManifestProperties, IAppxManifestPropertiesUtf8>
|
||||
{
|
||||
public:
|
||||
AppxManifestProperties(IMsixFactory* factory, std::map<std::string, std::string> stringValues, std::map<std::string, bool> boolValues) :
|
||||
m_factory(factory), m_stringValues(stringValues), m_boolValues(boolValues)
|
||||
{}
|
||||
|
||||
// IAppxManifestProperties
|
||||
HRESULT STDMETHODCALLTYPE GetBoolValue(LPCWSTR name, BOOL* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr), "bad pointer");
|
||||
auto result = m_boolValues.find(wstring_to_utf8(name));
|
||||
if (result != m_boolValues.end())
|
||||
{
|
||||
*value = result->second ? TRUE : FALSE;
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
}
|
||||
return static_cast<HRESULT>(Error::InvalidParameter);
|
||||
return GetBoolValue(wstring_to_utf8(name).c_str(), value);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetStringValue(LPCWSTR name, LPWSTR* value) noexcept override try
|
||||
|
@ -125,6 +135,30 @@ namespace MSIX {
|
|||
return static_cast<HRESULT>(Error::InvalidParameter);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IAppxManifestPropertiesUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetBoolValue(LPCSTR name, BOOL* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr), "bad pointer");
|
||||
auto result = m_boolValues.find(name);
|
||||
if (result != m_boolValues.end())
|
||||
{
|
||||
*value = result->second ? TRUE : FALSE;
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
}
|
||||
return static_cast<HRESULT>(Error::InvalidParameter);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetStringValue(LPCSTR name, LPSTR* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr || *value != nullptr), "bad pointer");
|
||||
auto result = m_stringValues.find(name);
|
||||
if (result != m_stringValues.end())
|
||||
{
|
||||
return m_factory->MarshalOutStringUtf8(result->second, value);
|
||||
}
|
||||
return static_cast<HRESULT>(Error::InvalidParameter);
|
||||
} CATCH_RETURN();
|
||||
|
||||
protected:
|
||||
IMsixFactory* m_factory;
|
||||
std::map<std::string, std::string> m_stringValues;
|
||||
|
@ -132,7 +166,7 @@ namespace MSIX {
|
|||
};
|
||||
|
||||
// TODO: add IAppxManifestPackageDependency2 if needed
|
||||
class AppxManifestPackageDependency final : public ComClass<AppxManifestPackageDependency, IAppxManifestPackageDependency>
|
||||
class AppxManifestPackageDependency final : public ComClass<AppxManifestPackageDependency, IAppxManifestPackageDependency, IAppxManifestPackageDependencyUtf8>
|
||||
{
|
||||
public:
|
||||
AppxManifestPackageDependency(IMsixFactory* factory, std::string& minVersion, std::string& name, std::string& publisher) :
|
||||
|
@ -141,6 +175,7 @@ namespace MSIX {
|
|||
m_minVersion = DecodeVersionNumber(minVersion);
|
||||
}
|
||||
|
||||
// IAppxManifestPackageDependency
|
||||
HRESULT STDMETHODCALLTYPE GetName(LPWSTR* name) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (name == nullptr || *name != nullptr), "bad pointer");
|
||||
|
@ -160,6 +195,19 @@ namespace MSIX {
|
|||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IAppxManifestPackageDependencyUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetName(LPSTR* name) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (name == nullptr || *name != nullptr), "bad pointer");
|
||||
return m_factory->MarshalOutStringUtf8(m_name, name);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetPublisher(LPSTR* publisher) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (publisher == nullptr || *publisher != nullptr), "bad pointer");
|
||||
return m_factory->MarshalOutStringUtf8(m_publisher, publisher);
|
||||
} CATCH_RETURN();
|
||||
|
||||
protected:
|
||||
IMsixFactory* m_factory;
|
||||
UINT64 m_minVersion;
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
EXTERN_C const IID IID_IAppxManifestPackageIdInternal;
|
||||
#ifndef WIN32
|
||||
// {76b7d3e1-768a-45cb-9626-ba6452bed2de}
|
||||
#ifndef WIN32
|
||||
interface IAppxManifestPackageIdInternal : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
|
@ -30,8 +29,7 @@ public:
|
|||
virtual const std::string& GetResourceId() = 0;
|
||||
virtual const std::string GetPackageFamilyName() = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IAppxManifestPackageIdInternal);
|
||||
MSIX_INTERFACE(IAppxManifestPackageIdInternal, 0x76b7d3e1,0x768a,0x45cb,0x96,0x26,0xba,0x64,0x52,0xbe,0xd2,0xde);
|
||||
|
||||
namespace MSIX {
|
||||
|
||||
|
@ -83,7 +81,7 @@ namespace MSIX {
|
|||
return result;
|
||||
}
|
||||
|
||||
class AppxManifestPackageId final : public ComClass<AppxManifestPackageId, IAppxManifestPackageId, IAppxManifestPackageIdInternal>
|
||||
class AppxManifestPackageId final : public ComClass<AppxManifestPackageId, IAppxManifestPackageId, IAppxManifestPackageIdInternal, IAppxManifestPackageIdUtf8>
|
||||
{
|
||||
public:
|
||||
AppxManifestPackageId(
|
||||
|
@ -119,6 +117,14 @@ namespace MSIX {
|
|||
return m_name + "_" + m_publisherId;
|
||||
}
|
||||
|
||||
// IAppxManifestPackageIdUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetName(LPSTR* name) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE GetPublisher(LPSTR* publisher) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE GetResourceId(LPSTR* resourceId) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE ComparePublisher(LPCSTR other, BOOL *isSame) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE GetPackageFullName(LPSTR* packageFullName) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE GetPackageFamilyName(LPSTR* packageFamilyName) noexcept override;
|
||||
|
||||
private:
|
||||
void ValidatePackageString(std::string& packageString);
|
||||
std::string ComputePublisherId(const std::string& publisher);
|
||||
|
|
|
@ -25,9 +25,8 @@
|
|||
#include "AppxManifestObject.hpp"
|
||||
|
||||
// internal interface
|
||||
EXTERN_C const IID IID_IPackage;
|
||||
#ifndef WIN32
|
||||
// {51b2c456-aaa9-46d6-8ec9-298220559189}
|
||||
#ifndef WIN32
|
||||
interface IPackage : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
|
@ -39,15 +38,13 @@ public:
|
|||
virtual void Unpack(MSIX_PACKUNPACK_OPTION options, const MSIX::ComPtr<IStorageObject>& to) = 0;
|
||||
virtual std::vector<std::string>& GetFootprintFiles() = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IPackage);
|
||||
|
||||
MSIX_INTERFACE(IPackage, 0x51b2c456,0xaaa9,0x46d6,0x8e,0xc9,0x29,0x82,0x20,0x55,0x91,0x89);
|
||||
|
||||
namespace MSIX {
|
||||
// Storage object representing the entire AppxPackage
|
||||
// Note: This class has is own implmentation of QueryInterface, if a new interface is implemented
|
||||
// AppxPackageObject::QueryInterface must also be modified too.
|
||||
class AppxPackageObject final : public ComClass<AppxPackageObject, IAppxPackageReader, IPackage, IStorageObject, IAppxBundleReader>
|
||||
class AppxPackageObject final : public ComClass<AppxPackageObject, IAppxPackageReader, IPackage, IStorageObject, IAppxBundleReader, IAppxPackageReaderUtf8, IAppxBundleReaderUtf8>
|
||||
{
|
||||
public:
|
||||
AppxPackageObject(IMsixFactory* factory, MSIX_VALIDATION_OPTION validation, MSIX_APPLICABILITY_OPTIONS applicabilityOptions, const ComPtr<IStorageObject>& container);
|
||||
|
@ -78,6 +75,12 @@ namespace MSIX {
|
|||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
if (riid == UuidOfImpl<IAppxPackageReaderUtf8>::iid)
|
||||
{
|
||||
*ppvObject = static_cast<void*>(static_cast<IAppxPackageReaderUtf8*>(this));
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
#ifdef BUNDLE_SUPPORT
|
||||
if (riid == UuidOfImpl<IAppxBundleReader>::iid && m_isBundle)
|
||||
{
|
||||
|
@ -85,6 +88,12 @@ namespace MSIX {
|
|||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
if (riid == UuidOfImpl<IAppxBundleReaderUtf8>::iid && m_isBundle)
|
||||
{
|
||||
*ppvObject = static_cast<void*>(static_cast<IAppxBundleReaderUtf8*>(this));
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
#endif //BUNDLE_SUPPORT
|
||||
if (riid == UuidOfImpl<IUnknown>::iid)
|
||||
{
|
||||
|
@ -112,7 +121,7 @@ namespace MSIX {
|
|||
HRESULT STDMETHODCALLTYPE GetPayloadPackages(IAppxFilesEnumerator **payloadPackages) noexcept override;
|
||||
HRESULT STDMETHODCALLTYPE GetPayloadPackage(LPCWSTR fileName, IAppxFile **payloadPackage) noexcept override;
|
||||
// Same signature as IAppxPackageReader
|
||||
// HRESULT STDMETHODCALLTYPE GetBlockMap(IAppxBlockMapReader** blockMapReader) override;
|
||||
// HRESULT STDMETHODCALLTYPE GetBlockMap(IAppxBlockMapReader** blockMapReader) noexcept override;
|
||||
|
||||
// IStorageObject methods
|
||||
const char* GetPathSeparator() override;
|
||||
|
@ -121,6 +130,12 @@ namespace MSIX {
|
|||
ComPtr<IStream> OpenFile(const std::string& fileName, MSIX::FileStream::Mode mode) override;
|
||||
std::string GetFileName() override;
|
||||
|
||||
// IAppxPackageReaderUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetPayloadFile(LPCSTR fileName, IAppxFile** file) noexcept override;
|
||||
|
||||
// IAppxBundleReaderUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetPayloadPackage(LPCSTR fileName, IAppxFile **payloadPackage) noexcept override;
|
||||
|
||||
protected:
|
||||
// Helper methods
|
||||
void VerifyFile(const ComPtr<IStream>& stream, const std::string& fileName, const ComPtr<IAppxBlockMapInternal>& blockMapInternal);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -180,8 +180,8 @@ namespace MSIX {
|
|||
public:
|
||||
virtual ~ComClass() { }
|
||||
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() override { return ++m_ref; }
|
||||
virtual ULONG STDMETHODCALLTYPE Release() override
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() noexcept override { return ++m_ref; }
|
||||
virtual ULONG STDMETHODCALLTYPE Release() noexcept override
|
||||
{
|
||||
if (--m_ref == 0)
|
||||
{ delete this;
|
||||
|
@ -190,7 +190,7 @@ namespace MSIX {
|
|||
return m_ref;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) noexcept override
|
||||
{
|
||||
if (ppvObject == nullptr || *ppvObject != nullptr)
|
||||
{
|
||||
|
|
|
@ -52,8 +52,8 @@ namespace MSIX {
|
|||
|
||||
// Helper class for implementing any IAppx*Enumerator that has an string as an out parameter
|
||||
// for their GetCurrent method.
|
||||
template<typename EnumeratorInterface>
|
||||
class EnumeratorString final : public MSIX::ComClass<EnumeratorString<EnumeratorInterface>, EnumeratorInterface>
|
||||
template<typename EnumeratorInterface, typename EnumeratorInterfaceUtf8>
|
||||
class EnumeratorString final : public MSIX::ComClass<EnumeratorString<EnumeratorInterface, EnumeratorInterfaceUtf8>, EnumeratorInterface, EnumeratorInterfaceUtf8>
|
||||
{
|
||||
public:
|
||||
EnumeratorString(IMsixFactory* factory, std::vector<std::string>& values) :
|
||||
|
@ -82,6 +82,14 @@ namespace MSIX {
|
|||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IAppx*EnumeratorUtf8
|
||||
HRESULT STDMETHODCALLTYPE GetCurrent(LPSTR* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr || *value != nullptr), "bad pointer");
|
||||
return m_factory->MarshalOutStringUtf8(m_values.at(m_cursor), value);
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
protected:
|
||||
IMsixFactory* m_factory;
|
||||
std::vector<std::string> m_values;
|
||||
|
|
|
@ -136,12 +136,8 @@ static const char* xPaths[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
EXTERN_C const IID IID_IXmlElement;
|
||||
EXTERN_C const IID IID_IXmlDom;
|
||||
EXTERN_C const IID IID_IXmlFactory;
|
||||
|
||||
#ifndef WIN32
|
||||
// {ac94449e-442d-4bed-8fca-83770c0f7ee9}
|
||||
#ifndef WIN32
|
||||
interface IXmlElement : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
|
@ -155,6 +151,7 @@ public:
|
|||
virtual std::vector<std::uint8_t> GetBase64DecodedAttributeValue(XmlAttributeName attribute) = 0;
|
||||
virtual std::string GetText() = 0;
|
||||
};
|
||||
MSIX_INTERFACE(IXmlElement, 0xac94449e,0x442d,0x4bed,0x8f,0xca,0x83,0x77,0x0c,0x0f,0x7e,0xe9);
|
||||
|
||||
struct XmlVisitor
|
||||
{
|
||||
|
@ -166,8 +163,8 @@ struct XmlVisitor
|
|||
XmlVisitor(void* c, lambda f) : context(c), Callback(f) {}
|
||||
};
|
||||
|
||||
#ifndef WIN32
|
||||
// {0e7a446e-baf7-44c1-b38a-216bfa18a1a8}
|
||||
#ifndef WIN32
|
||||
interface IXmlDom : public IUnknown
|
||||
#else
|
||||
class IXmlDom : public IUnknown
|
||||
|
@ -182,9 +179,10 @@ public:
|
|||
XmlVisitor& visitor
|
||||
) = 0;
|
||||
};
|
||||
MSIX_INTERFACE(IXmlDom, 0x0e7a446e,0xbaf7,0x44c1,0xb3,0x8a,0x21,0x6b,0xfa,0x18,0xa1,0xa8);
|
||||
|
||||
#ifndef WIN32
|
||||
// {f82a60ec-fbfc-4cb9-bc04-1a0fe2b4d5be}
|
||||
#ifndef WIN32
|
||||
interface IXmlFactory : public IUnknown
|
||||
#else
|
||||
class IXmlFactory : public IUnknown
|
||||
|
@ -194,10 +192,7 @@ class IXmlFactory : public IUnknown
|
|||
public:
|
||||
virtual MSIX::ComPtr<IXmlDom> CreateDomFromStream(XmlContentType footPrintType, const MSIX::ComPtr<IStream>& stream) = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IXmlElement);
|
||||
SpecializeUuidOfImpl(IXmlDom);
|
||||
SpecializeUuidOfImpl(IXmlFactory);
|
||||
MSIX_INTERFACE(IXmlFactory, 0xf82a60ec,0xfbfc,0x4cb9,0xbc,0x04,0x1a,0x0f,0xe2,0xb4,0xd5,0xbe);
|
||||
|
||||
namespace MSIX {
|
||||
MSIX::ComPtr<IXmlFactory> CreateXmlFactory(IMsixFactory* factory);
|
||||
|
|
|
@ -9,9 +9,8 @@
|
|||
#include <vector>
|
||||
|
||||
// internal interface
|
||||
EXTERN_C const IID IID_IMsixFactory;
|
||||
#ifndef WIN32
|
||||
// {1f850db4-32b8-4db6-8bf4-5a897eb611f1}
|
||||
#ifndef WIN32
|
||||
interface IMsixFactory : public IUnknown
|
||||
#else
|
||||
#include "UnKnwn.h"
|
||||
|
@ -25,6 +24,6 @@ public:
|
|||
virtual MSIX_VALIDATION_OPTION GetValidationOptions() = 0;
|
||||
virtual MSIX::ComPtr<IStream> GetResource(const std::string& resource) = 0;
|
||||
virtual HRESULT MarshalOutWstring(std::wstring& internal, LPWSTR* result) = 0;
|
||||
virtual HRESULT MarshalOutStringUtf8(std::string& internal, LPSTR* result) = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IMsixFactory);
|
||||
MSIX_INTERFACE(IMsixFactory, 0x1f850db4,0x32b8,0x4db6,0x8b,0xf4,0x5a,0x89,0x7e,0xb6,0x11,0xf1);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// Copyright (C) 2017 Microsoft. All rights reserved.
|
||||
// See LICENSE file in the project root for full license information.
|
||||
//
|
||||
//
|
||||
// This header defines the types used by Windows that are not defined in other platforms
|
||||
#ifndef __appxwindows_hpp__
|
||||
#define __appxwindows_hpp__
|
||||
|
@ -46,7 +46,7 @@
|
|||
|
||||
#ifndef _WINDOWS_TYPES
|
||||
#define _WINDOWS_TYPES
|
||||
|
||||
|
||||
#ifndef _HRESULT_DEFINED
|
||||
#define _HRESULT_DEFINED
|
||||
typedef signed long HRESULT;
|
||||
|
@ -271,14 +271,9 @@
|
|||
#if !defined (_SYS_GUID_OPERATORS_)
|
||||
#define _SYS_GUID_OPERATORS_
|
||||
|
||||
// Faster (but makes code fatter) inline version...use sparingly
|
||||
inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
|
||||
{
|
||||
return (
|
||||
((unsigned long *)&rguid1)[0] == ((unsigned long *)&rguid2)[0] &&
|
||||
((unsigned long *)&rguid1)[1] == ((unsigned long *)&rguid2)[1] &&
|
||||
((unsigned long *)&rguid1)[2] == ((unsigned long *)&rguid2)[2] &&
|
||||
((unsigned long *)&rguid1)[3] == ((unsigned long *)&rguid2)[3]);
|
||||
return !memcmp(&rguid1, &rguid2, sizeof(GUID));
|
||||
}
|
||||
|
||||
// Same type, different name
|
||||
|
@ -298,6 +293,6 @@
|
|||
}
|
||||
#endif // _SYS_GUID_OPERATOR_EQ_
|
||||
#endif // _SYS_GUID_OPERATORS_
|
||||
|
||||
#endif // #else of #ifdef WIN32
|
||||
|
||||
#endif //__appxwindows_hpp__
|
||||
|
|
|
@ -32,9 +32,8 @@ inline constexpr FileNameOptions operator |(FileNameOptions a, FileNameOptions b
|
|||
}
|
||||
|
||||
// internal interface
|
||||
EXTERN_C const IID IID_IStorageObject;
|
||||
#ifndef WIN32
|
||||
// {ec25b96e-0db1-4483-bdb1-cab1109cb741}
|
||||
#ifndef WIN32
|
||||
interface IStorageObject : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
|
@ -59,5 +58,4 @@ public:
|
|||
// Returns the file name of the storage object.
|
||||
virtual std::string GetFileName() = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IStorageObject);
|
||||
MSIX_INTERFACE(IStorageObject, 0xec25b96e,0x0db1,0x4483,0xbd,0xb1,0xca,0xb1,0x10,0x9c,0xb7,0x41);
|
||||
|
|
|
@ -15,9 +15,8 @@
|
|||
#include "Exceptions.hpp"
|
||||
#include "ComHelper.hpp"
|
||||
|
||||
EXTERN_C const IID IID_IStreamInternal;
|
||||
#ifndef WIN32
|
||||
// {44d2a7a8-a165-4a6e-a56f-c7c24de7505c}
|
||||
#ifndef WIN32
|
||||
interface IStreamInternal : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
|
@ -30,8 +29,7 @@ public:
|
|||
virtual bool IsCompressed() = 0;
|
||||
virtual std::string GetName() = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IStreamInternal);
|
||||
MSIX_INTERFACE(IStreamInternal, 0x44d2a7a8,0xa165,0x4a6e,0xa5,0x6f,0xc7,0xc2,0x4d,0xe7,0x50,0x5c);
|
||||
|
||||
namespace MSIX {
|
||||
class StreamBase : public MSIX::ComClass<StreamBase, IStream, IStreamInternal>
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
#include "ComHelper.hpp"
|
||||
|
||||
// internal interface
|
||||
EXTERN_C const IID IID_IVerifierObject;
|
||||
#ifndef WIN32
|
||||
// {cb0a105c-3a6c-4e48-9351-377c4dccd890}
|
||||
#ifndef WIN32
|
||||
interface IVerifierObject : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
|
@ -28,5 +27,4 @@ public:
|
|||
virtual MSIX::ComPtr<IStream> GetStream() = 0;
|
||||
virtual MSIX::ComPtr<IStream> GetValidationStream(const std::string& part, const MSIX::ComPtr<IStream>& stream) = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IVerifierObject);
|
||||
MSIX_INTERFACE(IVerifierObject, 0xcb0a105c,0x3a6c,0x4e48,0x93,0x51,0x37,0x7c,0x4d,0xcc,0xd8,0x90);
|
||||
|
|
|
@ -109,6 +109,7 @@ namespace MSIX {
|
|||
ThrowErrorIf(Error::XmlError, (0 == context.countFilesFound), "Empty AppxBlockMap.xml");
|
||||
}
|
||||
|
||||
// IVerifierObject
|
||||
ComPtr<IStream> AppxBlockMapObject::GetValidationStream(const std::string& part, const ComPtr<IStream>& stream)
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (part.empty() || !stream), "bad input");
|
||||
|
@ -119,16 +120,10 @@ namespace MSIX {
|
|||
return ComPtr<IStream>::Make<BlockMapStream>(m_factory, part, stream, item->second);
|
||||
}
|
||||
|
||||
// IAppxBlockMapReader
|
||||
HRESULT STDMETHODCALLTYPE AppxBlockMapObject::GetFile(LPCWSTR filename, IAppxBlockMapFile **file) noexcept try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (
|
||||
filename == nullptr || *filename == '\0' || file == nullptr || *file != nullptr
|
||||
), "bad pointer");
|
||||
auto blockMapFile = m_blockMapFiles.find(wstring_to_utf8(filename));
|
||||
ThrowErrorIf(Error::InvalidParameter, (blockMapFile == m_blockMapFiles.end()), "File not found!");
|
||||
MSIX::ComPtr<IAppxBlockMapFile> result = blockMapFile->second;
|
||||
*file = result.Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
return GetFile(wstring_to_utf8(filename).c_str(), file);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE AppxBlockMapObject::GetFiles(IAppxBlockMapFilesEnumerator **enumerator) noexcept try
|
||||
|
@ -186,4 +181,17 @@ namespace MSIX {
|
|||
ThrowErrorIf(Error::FileNotFound, (index == m_blockMapFiles.end()), "File not in blockmap");
|
||||
return index->second;
|
||||
}
|
||||
|
||||
// IAppxBlockMapReaderUtf8
|
||||
HRESULT STDMETHODCALLTYPE AppxBlockMapObject::GetFile(LPCSTR filename, IAppxBlockMapFile **file) noexcept try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (
|
||||
filename == nullptr || *filename == '\0' || file == nullptr || *file != nullptr
|
||||
), "bad pointer");
|
||||
auto blockMapFile = m_blockMapFiles.find(filename);
|
||||
ThrowErrorIf(Error::InvalidParameter, (blockMapFile == m_blockMapFiles.end()), "File not found!");
|
||||
MSIX::ComPtr<IAppxBlockMapFile> result = blockMapFile->second;
|
||||
*file = result.Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
}
|
|
@ -197,4 +197,11 @@ namespace MSIX {
|
|||
Make<EnumeratorCom<IAppxManifestQualifiedResourcesEnumerator, IAppxManifestQualifiedResource>>(languages).Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IAppxBundleManifestPackageInfoUtf8
|
||||
HRESULT STDMETHODCALLTYPE AppxBundleManifestPackageInfo::GetFileName(LPSTR* fileName) noexcept try
|
||||
{
|
||||
return m_factory->MarshalOutStringUtf8(m_fileName, fileName);
|
||||
} CATCH_RETURN();
|
||||
|
||||
}
|
||||
|
|
|
@ -63,22 +63,7 @@ namespace MSIX {
|
|||
LPCWSTR signatureFileName,
|
||||
IAppxBlockMapReader** blockMapReader) noexcept try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (
|
||||
inputStream == nullptr ||
|
||||
signatureFileName == nullptr ||
|
||||
*signatureFileName == '\0' ||
|
||||
blockMapReader == nullptr ||
|
||||
*blockMapReader != nullptr
|
||||
),"bad pointer.");
|
||||
|
||||
ComPtr<IMsixFactory> self;
|
||||
ThrowHrIfFailed(QueryInterface(UuidOfImpl<IMsixFactory>::iid, reinterpret_cast<void**>(&self)));
|
||||
auto stream = ComPtr<IStream>::Make<FileStream>(wstring_to_utf8(signatureFileName), FileStream::Mode::READ);
|
||||
auto signature = ComPtr<IVerifierObject>::Make<AppxSignatureObject>(self.Get(), self->GetValidationOptions(), stream);
|
||||
ComPtr<IStream> input(inputStream);
|
||||
auto validatedStream = signature->GetValidationStream("AppxBlockMap.xml", input);
|
||||
*blockMapReader = ComPtr<IAppxBlockMapReader>::Make<AppxBlockMapObject>(self.Get(), validatedStream).Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
return CreateValidatedBlockMapReader(inputStream, wstring_to_utf8(signatureFileName).c_str(), blockMapReader);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IAppxBundleFactory
|
||||
|
@ -121,13 +106,31 @@ namespace MSIX {
|
|||
if (!internal.empty())
|
||||
{
|
||||
auto intermediate = utf8_to_wstring(internal);
|
||||
ThrowHrIfFailed(MarshalOutWstring(intermediate, result));
|
||||
}
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT AppxFactory::MarshalOutWstring(std::wstring& internal, LPWSTR* result) noexcept try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (result == nullptr || *result != nullptr), "bad pointer" );
|
||||
*result = nullptr;
|
||||
if (!internal.empty())
|
||||
{
|
||||
std::size_t countBytes = sizeof(wchar_t)*(internal.size()+1);
|
||||
*result = reinterpret_cast<LPWSTR>(m_memalloc(countBytes));
|
||||
ThrowErrorIfNot(Error::OutOfMemory, (*result), "Allocation failed!");
|
||||
std::memset(reinterpret_cast<void*>(*result), 0, countBytes);
|
||||
std::memcpy(reinterpret_cast<void*>(*result),
|
||||
reinterpret_cast<void*>(const_cast<wchar_t*>(intermediate.c_str())),
|
||||
countBytes - sizeof(wchar_t));
|
||||
MarshalOutStringHelper<wchar_t>(countBytes, const_cast<wchar_t*>(internal.c_str()), result);
|
||||
}
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT AppxFactory::MarshalOutStringUtf8(std::string& internal, LPSTR* result) noexcept try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (result == nullptr || *result != nullptr), "bad pointer" );
|
||||
*result = nullptr;
|
||||
if (!internal.empty())
|
||||
{
|
||||
std::size_t countBytes = internal.size() + 1;
|
||||
MarshalOutStringHelper<char>(countBytes, const_cast<char*>(internal.c_str()), result);
|
||||
}
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
@ -160,23 +163,6 @@ namespace MSIX {
|
|||
return file;
|
||||
}
|
||||
|
||||
HRESULT AppxFactory::MarshalOutWstring(std::wstring& internal, LPWSTR *result) noexcept try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (result == nullptr || *result != nullptr), "bad pointer" );
|
||||
*result = nullptr;
|
||||
if (!internal.empty())
|
||||
{
|
||||
std::size_t countBytes = sizeof(wchar_t)*(internal.size()+1);
|
||||
*result = reinterpret_cast<LPWSTR>(m_memalloc(countBytes));
|
||||
ThrowErrorIfNot(Error::OutOfMemory, (*result), "Allocation failed!");
|
||||
std::memset(reinterpret_cast<void*>(*result), 0, countBytes);
|
||||
std::memcpy(reinterpret_cast<void*>(*result),
|
||||
reinterpret_cast<void*>(const_cast<wchar_t*>(internal.c_str())),
|
||||
countBytes - sizeof(wchar_t));
|
||||
}
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IMsixFactoryOverrides
|
||||
HRESULT STDMETHODCALLTYPE AppxFactory::SpecifyExtension(MSIX_FACTORY_EXTENSION name, IUnknown* extension) noexcept try
|
||||
{
|
||||
|
@ -224,4 +210,40 @@ namespace MSIX {
|
|||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IAppxFactoryUtf8
|
||||
HRESULT STDMETHODCALLTYPE AppxFactory::CreateValidatedBlockMapReader (
|
||||
IStream* inputStream,
|
||||
LPCSTR signatureFileName,
|
||||
IAppxBlockMapReader** blockMapReader) noexcept try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (
|
||||
inputStream == nullptr ||
|
||||
signatureFileName == nullptr ||
|
||||
*signatureFileName == '\0' ||
|
||||
blockMapReader == nullptr ||
|
||||
*blockMapReader != nullptr
|
||||
),"bad pointer.");
|
||||
|
||||
ComPtr<IMsixFactory> self;
|
||||
ThrowHrIfFailed(QueryInterface(UuidOfImpl<IMsixFactory>::iid, reinterpret_cast<void**>(&self)));
|
||||
auto stream = ComPtr<IStream>::Make<FileStream>(signatureFileName, FileStream::Mode::READ);
|
||||
auto signature = ComPtr<IVerifierObject>::Make<AppxSignatureObject>(self.Get(), self->GetValidationOptions(), stream);
|
||||
ComPtr<IStream> input(inputStream);
|
||||
auto validatedStream = signature->GetValidationStream("AppxBlockMap.xml", input);
|
||||
*blockMapReader = ComPtr<IAppxBlockMapReader>::Make<AppxBlockMapObject>(self.Get(), validatedStream).Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// Helper to marshal out strings
|
||||
template<typename T>
|
||||
void AppxFactory::MarshalOutStringHelper(std::size_t size, T* from, T** to)
|
||||
{
|
||||
*to = reinterpret_cast<T*>(m_memalloc(size));
|
||||
ThrowErrorIfNot(Error::OutOfMemory, (*to), "Allocation failed!");
|
||||
std::memset(reinterpret_cast<void*>(*to), 0, size);
|
||||
std::memcpy(reinterpret_cast<void*>(*to),
|
||||
reinterpret_cast<void*>(from),
|
||||
size - sizeof(T));
|
||||
}
|
||||
|
||||
} // namespace MSIX
|
||||
|
|
|
@ -293,7 +293,7 @@ namespace MSIX {
|
|||
return true;
|
||||
});
|
||||
m_dom->ForEachElementIn(m_dom->GetDocument(), XmlQueryName::Package_Resources_Resource, visitorResource);
|
||||
*resources = ComPtr<IAppxManifestResourcesEnumerator>::Make<EnumeratorString<IAppxManifestResourcesEnumerator>>(m_factory, appxResources).Detach();
|
||||
*resources = ComPtr<IAppxManifestResourcesEnumerator>::Make<EnumeratorString<IAppxManifestResourcesEnumerator, IAppxManifestResourcesEnumeratorUtf8>>(m_factory, appxResources).Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace MSIX {
|
|||
}
|
||||
}
|
||||
|
||||
// IAppxManifestPackageId
|
||||
HRESULT STDMETHODCALLTYPE AppxManifestPackageId::GetName(LPWSTR* name) noexcept try
|
||||
{
|
||||
return m_factory->MarshalOutString(m_name, name);
|
||||
|
@ -108,13 +109,7 @@ namespace MSIX {
|
|||
|
||||
HRESULT STDMETHODCALLTYPE AppxManifestPackageId::ComparePublisher(LPCWSTR other, BOOL *isSame) noexcept try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (isSame == nullptr), "bad pointer" );
|
||||
*isSame = FALSE;
|
||||
if (0 == m_publisher.compare(wstring_to_utf8(other)))
|
||||
{
|
||||
*isSame = TRUE;
|
||||
}
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
return ComparePublisher(wstring_to_utf8(other).c_str(), isSame);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE AppxManifestPackageId::GetPackageFullName(LPWSTR* packageFullName) noexcept try
|
||||
|
@ -172,4 +167,43 @@ namespace MSIX {
|
|||
ThrowErrorIfNot(Error::Unexpected, SHA256::ComputeHash(buffer.data(), static_cast<uint32_t>(buffer.size()), hash), "Failed computing publisherId");
|
||||
return Encoding::Base32Encoding(hash);
|
||||
}
|
||||
|
||||
// IAppxManifestPackageIdUtf8
|
||||
HRESULT STDMETHODCALLTYPE AppxManifestPackageId::GetName(LPSTR* name) noexcept try
|
||||
{
|
||||
return m_factory->MarshalOutStringUtf8(m_name, name);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE AppxManifestPackageId::GetPublisher(LPSTR* publisher) noexcept try
|
||||
{
|
||||
return m_factory->MarshalOutStringUtf8(m_publisher, publisher);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE AppxManifestPackageId::GetResourceId(LPSTR* resourceId) noexcept try
|
||||
{
|
||||
return m_factory->MarshalOutStringUtf8(m_resourceId, resourceId);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE AppxManifestPackageId::ComparePublisher(LPCSTR other, BOOL *isSame) noexcept try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (isSame == nullptr), "bad pointer" );
|
||||
*isSame = FALSE;
|
||||
if (0 == m_publisher.compare(other))
|
||||
{
|
||||
*isSame = TRUE;
|
||||
}
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE AppxManifestPackageId::GetPackageFullName(LPSTR* packageFullName) noexcept try
|
||||
{
|
||||
auto fullName = GetPackageFullName();
|
||||
return m_factory->MarshalOutStringUtf8(fullName, packageFullName);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE AppxManifestPackageId::GetPackageFamilyName(LPSTR* packageFamilyName) noexcept try
|
||||
{
|
||||
auto familyName = GetPackageFamilyName();
|
||||
return m_factory->MarshalOutStringUtf8(familyName, packageFamilyName);
|
||||
} CATCH_RETURN();
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ namespace MSIX {
|
|||
if(streamFactoryUnk.Get() != nullptr)
|
||||
{
|
||||
auto streamFactory = streamFactoryUnk.As<IMsixStreamFactory>();
|
||||
ThrowHrIfFailed(streamFactory->CreateStreamOnRelativePath(utf8_to_wstring(packageName).c_str(), &packageStream));
|
||||
ThrowHrIfFailed(streamFactory->CreateStreamOnRelativePathUtf8(packageName.c_str(), &packageStream));
|
||||
}
|
||||
else
|
||||
{ // User didn't specify a stream factory implementation. Assume packages are in the same location
|
||||
|
@ -531,16 +531,7 @@ namespace MSIX {
|
|||
|
||||
HRESULT STDMETHODCALLTYPE AppxPackageObject::GetPayloadFile(LPCWSTR fileName, IAppxFile** file) noexcept try
|
||||
{
|
||||
if (m_isBundle) { return static_cast<HRESULT>(Error::PackageIsBundle); }
|
||||
ThrowErrorIf(Error::InvalidParameter, (fileName == nullptr || file == nullptr || *file != nullptr), "bad pointer");
|
||||
auto result = GetAppxFile(Encoding::EncodeFileName(wstring_to_utf8(fileName)));
|
||||
ThrowErrorIfNot(Error::FileNotFound, result, "requested file not in package")
|
||||
// Clients expect the stream's pointer to be at the start of the file!
|
||||
ComPtr<IStream> stream;
|
||||
ThrowHrIfFailed(result->GetStream(&stream));
|
||||
ThrowHrIfFailed(stream->Seek({0}, StreamBase::Reference::START, nullptr));
|
||||
*file = result.Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
return GetPayloadFile(wstring_to_utf8(fileName).c_str(), file);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE AppxPackageObject::GetPayloadFiles(IAppxFilesEnumerator** filesEnumerator) noexcept try
|
||||
|
@ -615,21 +606,7 @@ namespace MSIX {
|
|||
|
||||
HRESULT STDMETHODCALLTYPE AppxPackageObject::GetPayloadPackage(LPCWSTR fileName, IAppxFile **payloadPackage) noexcept try
|
||||
{
|
||||
#ifdef BUNDLE_SUPPORT
|
||||
if (!m_isBundle) { return static_cast<HRESULT>(Error::NotImplemented); }
|
||||
ThrowErrorIf(Error::InvalidParameter, (fileName == nullptr || payloadPackage == nullptr || *payloadPackage != nullptr), "bad pointer");
|
||||
std::string name = wstring_to_utf8(fileName);
|
||||
auto result = GetAppxFile(name);
|
||||
ThrowErrorIfNot(Error::FileNotFound, result, "Requested package not in bundle")
|
||||
// Clients expect the stream's pointer to be at the start of the file!
|
||||
ComPtr<IStream> stream;
|
||||
ThrowHrIfFailed(result->GetStream(&stream));
|
||||
ThrowHrIfFailed(stream->Seek({0}, StreamBase::Reference::START, nullptr));
|
||||
*payloadPackage = result.Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
#else
|
||||
return static_cast<HRESULT>(MSIX::Error::NotSupported);
|
||||
#endif
|
||||
return GetPayloadPackage(wstring_to_utf8(fileName).c_str(), payloadPackage);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE AppxPackageObject::GetManifest(IAppxBundleManifestReader **manifestReader) noexcept try
|
||||
|
@ -643,4 +620,38 @@ namespace MSIX {
|
|||
return static_cast<HRESULT>(MSIX::Error::NotSupported);
|
||||
#endif
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IAppxPackageReaderUtf8
|
||||
HRESULT STDMETHODCALLTYPE AppxPackageObject::GetPayloadFile(LPCSTR fileName, IAppxFile** file) noexcept try
|
||||
{
|
||||
if (m_isBundle) { return static_cast<HRESULT>(Error::PackageIsBundle); }
|
||||
ThrowErrorIf(Error::InvalidParameter, (fileName == nullptr || file == nullptr || *file != nullptr), "bad pointer");
|
||||
auto result = GetAppxFile(Encoding::EncodeFileName(fileName));
|
||||
ThrowErrorIfNot(Error::FileNotFound, result, "requested file not in package")
|
||||
// Clients expect the stream's pointer to be at the start of the file!
|
||||
ComPtr<IStream> stream;
|
||||
ThrowHrIfFailed(result->GetStream(&stream));
|
||||
ThrowHrIfFailed(stream->Seek({0}, StreamBase::Reference::START, nullptr));
|
||||
*file = result.Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
// IAppxBundleReaderUtf8
|
||||
HRESULT STDMETHODCALLTYPE AppxPackageObject::GetPayloadPackage(LPCSTR fileName, IAppxFile **payloadPackage) noexcept try
|
||||
{
|
||||
#ifdef BUNDLE_SUPPORT
|
||||
if (!m_isBundle) { return static_cast<HRESULT>(Error::NotImplemented); }
|
||||
ThrowErrorIf(Error::InvalidParameter, (fileName == nullptr || payloadPackage == nullptr || *payloadPackage != nullptr), "bad pointer");
|
||||
auto result = GetAppxFile(fileName);
|
||||
ThrowErrorIfNot(Error::FileNotFound, result, "Requested package not in bundle")
|
||||
// Clients expect the stream's pointer to be at the start of the file!
|
||||
ComPtr<IStream> stream;
|
||||
ThrowHrIfFailed(result->GetStream(&stream));
|
||||
ThrowHrIfFailed(stream->Seek({0}, StreamBase::Reference::START, nullptr));
|
||||
*payloadPackage = result.Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
#else
|
||||
return static_cast<HRESULT>(MSIX::Error::NotSupported);
|
||||
#endif
|
||||
} CATCH_RETURN();
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
//
|
||||
// Copyright (C) 2017 Microsoft. All rights reserved.
|
||||
// See LICENSE file in the project root for full license information.
|
||||
//
|
||||
/* link this file in with the server and any clients */
|
||||
/* File based on the header created by MIDL compiler version 8.01.0622 of AppxPackaging.idl */
|
||||
/* @@MIDL_FILE_HEADING( ) */
|
||||
|
||||
// Changes made to the original AppxPackaging.h file:
|
||||
// - Add IUnknown, ISequentialStream and IStream GUIDs
|
||||
// - Remove CLSIDs and LIBID_APPXPACKAGING
|
||||
// - Add internal interfaces
|
||||
extern "C"{
|
||||
|
||||
#ifndef __IID_DEFINED__
|
||||
#define __IID_DEFINED__
|
||||
|
||||
typedef struct _IID
|
||||
{
|
||||
unsigned long x;
|
||||
unsigned short s1;
|
||||
unsigned short s2;
|
||||
unsigned char c[8];
|
||||
} IID;
|
||||
|
||||
#endif // __IID_DEFINED__
|
||||
|
||||
#ifndef WIN32
|
||||
#define MIDL_PUBLIC_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
|
||||
__attribute__((visibility("default"))) extern "C" const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
|
||||
#else
|
||||
#define MIDL_PUBLIC_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
|
||||
#endif
|
||||
|
||||
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
|
||||
extern "C" const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
|
||||
|
||||
|
||||
MIDL_PUBLIC_GUID(IID, IID_IUnknown,0x00000000,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
|
||||
MIDL_PUBLIC_GUID(IID, IID_ISequentialStream,0x0c733a30,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IStream,0x0000000c,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxFactory,0xbeb94909,0xe451,0x438b,0xb5,0xa7,0xd7,0x9e,0x76,0x7b,0x75,0xd8);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxPackageReader,0xb5c49650,0x99bc,0x481c,0x9a,0x34,0x3d,0x53,0xa4,0x10,0x67,0x08);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxPackageWriter,0x9099e33b,0x246f,0x41e4,0x88,0x1a,0x00,0x8e,0xb6,0x13,0xf8,0x58);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxFile,0x91df827b,0x94fd,0x468f,0x82,0x7b,0x57,0xf4,0x1b,0x2f,0x6f,0x2e);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxFilesEnumerator,0xf007eeaf,0x9831,0x411c,0x98,0x47,0x91,0x7c,0xdc,0x62,0xd1,0xfe);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxBlockMapReader,0x5efec991,0xbca3,0x42d1,0x9e,0xc2,0xe9,0x2d,0x60,0x9e,0xc2,0x2a);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxBlockMapFile,0x277672ac,0x4f63,0x42c1,0x8a,0xbc,0xbe,0xae,0x36,0x00,0xeb,0x59);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxBlockMapFilesEnumerator,0x02b856a2,0x4262,0x4070,0xba,0xcb,0x1a,0x8c,0xbb,0xc4,0x23,0x05);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxBlockMapBlock,0x75cf3930,0x3244,0x4fe0,0xa8,0xc8,0xe0,0xbc,0xb2,0x70,0xb8,0x89);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxBlockMapBlocksEnumerator,0x6b429b5b,0x36ef,0x479e,0xb9,0xeb,0x0c,0x14,0x82,0xb4,0x9e,0x16);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestReader,0x4e1bd148,0x55a0,0x4480,0xa3,0xd1,0x15,0x54,0x47,0x10,0x63,0x7c);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestReader2,0xd06f67bc,0xb31d,0x4eba,0xa8,0xaf,0x63,0x8e,0x73,0xe7,0x7b,0x4d);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestReader3,0xC43825AB,0x69B7,0x400A,0x97,0x09,0xCC,0x37,0xF5,0xA7,0x2D,0x24);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestPackageId,0x283ce2d7,0x7153,0x4a91,0x96,0x49,0x7a,0x0f,0x72,0x40,0x94,0x5f);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestProperties,0x03faf64d,0xf26f,0x4b2c,0xaa,0xf7,0x8f,0xe7,0x78,0x9b,0x8b,0xca);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestTargetDeviceFamiliesEnumerator,0x36537F36,0x27A4,0x4788,0x88,0xC0,0x73,0x38,0x19,0x57,0x50,0x17);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestTargetDeviceFamily,0x9091B09B,0xC8D5,0x4F31,0x86,0x87,0xA3,0x38,0x25,0x9F,0xAE,0xFB);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestPackageDependenciesEnumerator,0xb43bbcf9,0x65a6,0x42dd,0xba,0xc0,0x8c,0x67,0x41,0xe7,0xf5,0xa4);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestPackageDependency,0xe4946b59,0x733e,0x43f0,0xa7,0x24,0x3b,0xde,0x4c,0x12,0x85,0xa0);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestResourcesEnumerator,0xde4dfbbd,0x881a,0x48bb,0x85,0x8c,0xd6,0xf2,0xba,0xea,0xe6,0xed);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestDeviceCapabilitiesEnumerator,0x30204541,0x427b,0x4a1c,0xba,0xcf,0x65,0x5b,0xf4,0x63,0xa5,0x40);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestCapabilitiesEnumerator,0x11D22258,0xF470,0x42C1,0xB2,0x91,0x83,0x61,0xC5,0x43,0x7E,0x41);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestApplicationsEnumerator,0x9eb8a55a,0xf04b,0x4d0d,0x80,0x8d,0x68,0x61,0x85,0xd4,0x84,0x7a);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestApplication,0x5da89bf4,0x3773,0x46be,0xb6,0x50,0x7e,0x74,0x48,0x63,0xb7,0xe8);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestQualifiedResourcesEnumerator,0x8ef6adfe,0x3762,0x4a8f,0x93,0x73,0x2f,0xc5,0xd4,0x44,0xc8,0xd2);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxManifestQualifiedResource,0x3b53a497,0x3c5c,0x48d1,0x9e,0xa3,0xbb,0x7e,0xac,0x8c,0xd7,0xd4);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxBundleFactory,0xBBA65864,0x965F,0x4A5F,0x85,0x5F,0xF0,0x74,0xBD,0xBF,0x3A,0x7B);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxBundleWriter,0xEC446FE8,0xBFEC,0x4C64,0xAB,0x4F,0x49,0xF0,0x38,0xF0,0xC6,0xD2);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxBundleReader,0xDD75B8C0,0xBA76,0x43B0,0xAE,0x0F,0x68,0x65,0x6A,0x1D,0xC5,0xC8);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxBundleManifestReader,0xCF0EBBC1,0xCC99,0x4106,0x91,0xEB,0xE6,0x74,0x62,0xE0,0x4F,0xB0);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxBundleManifestPackageInfoEnumerator,0xF9B856EE,0x49A6,0x4E19,0xB2,0xB0,0x6A,0x24,0x06,0xD6,0x3A,0x32);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IAppxBundleManifestPackageInfo,0x54CD06C1,0x268F,0x40BB,0x8E,0xD2,0x75,0x7A,0x9E,0xBA,0xEC,0x8D);
|
||||
|
||||
// Exclusive to the MSIX SDK
|
||||
MIDL_PUBLIC_GUID(IID, IID_IMsixDocumentElement,0xE8900E0E,0x1DFD,0x4728,0x83,0x52,0xAA,0xDA,0xEB,0xBF,0x00,0x65);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IMsixElement,0x5B6786FF,0x6145,0x4F0E,0xB8,0xC9,0x8E,0x03,0xAA,0xCB,0x60,0xD0);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IMsixElementEnumerator,0x7E7EA105,0xA4F9,0x4C12,0x9E,0xFA,0x98,0xEF,0x18,0x95,0x41,0x8A);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IMsixFactoryOverrides,0x0ACEDBDB,0x57CD,0x4ACA,0X8C,0XEE,0X33,0XFA,0X52,0X39,0X43,0X16);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IMsixStreamFactory,0XC74F4821,0X3B82,0X4AD5,0X98,0XEA,0X3D,0X52,0X68,0X1A,0XFF,0X56);
|
||||
MIDL_PUBLIC_GUID(IID, IID_IMsixApplicabilityLanguagesEnumerator,0xbfc4655a,0xbe7a,0x456a,0xbc,0x4e,0x2a,0xf9,0x48,0x1e,0x84,0x32);
|
||||
|
||||
// internal interfaces.
|
||||
MIDL_DEFINE_GUID(IID, IID_IPackage, 0x51B2C456,0xAAA9,0x46D6,0x8E,0xC9,0x29,0x82,0x20,0x55,0x91,0x89);
|
||||
MIDL_DEFINE_GUID(IID, IID_IStorageObject, 0xEC25B96E,0x0DB1,0x4483,0xBD,0xB1,0xCA,0xB1,0x10,0x9C,0xB7,0x41);
|
||||
MIDL_DEFINE_GUID(IID, IID_IMsixFactory, 0x1f850db4,0x32b8,0x4db6,0x8b,0xf4,0x5a,0x89,0x7e,0xb6,0x11,0xf1);
|
||||
MIDL_DEFINE_GUID(IID, IID_IVerifierObject, 0xcb0a105c,0x3a6c,0x4e48,0x93,0x51,0x37,0x7c,0x4d,0xcc,0xd8,0x90);
|
||||
MIDL_DEFINE_GUID(IID, IID_IXmlElement, 0xac94449e,0x442d,0x4bed,0x8f,0xca,0x83,0x77,0x0c,0x0f,0x7e,0xe9);
|
||||
MIDL_DEFINE_GUID(IID, IID_IXmlDom, 0x0e7a446e,0xbaf7,0x44c1,0xb3,0x8a,0x21,0x6b,0xfa,0x18,0xa1,0xa8);
|
||||
MIDL_DEFINE_GUID(IID, IID_IXmlFactory, 0xf82a60ec,0xfbfc,0x4cb9,0xbc,0x04,0x1a,0x0f,0xe2,0xb4,0xd5,0xbe);
|
||||
MIDL_DEFINE_GUID(IID, IID_IAppxBlockMapInternal, 0x67fed21a,0x70ef,0x4175,0x8f,0x12,0x41,0x5b,0x21,0x3a,0xb6,0xd2);
|
||||
MIDL_DEFINE_GUID(IID, IID_IAppxManifestObject, 0xeff6d561,0xa236,0x4058,0x9f,0x1d,0x8f,0x93,0x63,0x3f,0xba,0x4b);
|
||||
MIDL_DEFINE_GUID(IID, IID_IAppxManifestPackageIdInternal, 0x76b7d3e1,0x768a,0x45cb,0x96,0x26,0xba,0x64,0x52,0xbe,0xd2,0xde);
|
||||
MIDL_DEFINE_GUID(IID, IID_IStreamInternal, 0x44d2a7a8,0xa165,0x4a6e,0xa5,0x6f,0xc7,0xc2,0x4d,0xe7,0x50,0x5c);
|
||||
|
||||
// Internal bundle interfaces
|
||||
#ifdef BUNDLE_SUPPORT
|
||||
MIDL_DEFINE_GUID(IID, IID_IBundleInfo, 0xff82ffcd,0x747a,0x4df9,0x88,0x79,0x85,0x3a,0xb9,0xdd,0x15,0xa1);
|
||||
MIDL_DEFINE_GUID(IID, IID_IAppxBundleManifestPackageInfoInternal, 0x32e6fcf0,0x729b,0x401d,0x9d,0xbc,0xf9,0x27,0xb4,0x94,0xf9,0xaf);
|
||||
#endif
|
||||
|
||||
// internal XML PAL interfaces
|
||||
#ifdef USING_XERCES
|
||||
MIDL_DEFINE_GUID(IID, IID_IXercesElement, 0x07d6ee0e,0x2165,0x4b90,0x80,0x24,0xe1,0x76,0x29,0x1e,0x77,0xdd);
|
||||
#endif
|
||||
|
||||
#ifdef USING_JAVAXML
|
||||
// {69AB3660-398D-4CD6-A131-E73106040E3B}
|
||||
MIDL_DEFINE_GUID(IID, IID_IJavaXmlElement, 0x69ab3660,0x398d,0x4cd6,0xa1,0x31,0xe7,0x31,0x6,0x4,0xe,0x3b);
|
||||
#endif
|
||||
|
||||
#ifdef USING_APPLE_XML
|
||||
// {8FBC0096-E87D-406A-95D9-203ADEFBF9AF}
|
||||
MIDL_DEFINE_GUID(IID, IID_IAppleXmlElement, 0x8fbc0096, 0xe87d, 0x406a, 0x95, 0xd9, 0x20, 0x3a, 0xde, 0xfb, 0xf9, 0xaf);
|
||||
#endif
|
||||
|
||||
#ifdef USING_MSXML
|
||||
MIDL_DEFINE_GUID(IID, IID_IMSXMLElement, 0x2730f595,0x0c80,0x4f3e,0x88,0x91,0x75,0x3b,0x2e,0x8c,0x30,0x5d);
|
||||
MIDL_DEFINE_GUID(IID, IID_IMSXMLDom, 0xb6bca5f0,0xc6c1,0x4409,0x85,0xbe,0xe4,0x76,0xaa,0xbe,0xc1,0x9a);
|
||||
#endif
|
||||
|
||||
#undef MIDL_DEFINE_GUID
|
||||
|
||||
}
|
|
@ -63,42 +63,6 @@ else()
|
|||
"UnpackBundleFromStream"
|
||||
"CoCreateAppxBundleFactory"
|
||||
"CoCreateAppxBundleFactoryWithHeap"
|
||||
"IID_IUnknown"
|
||||
"IID_IStream"
|
||||
"IID_IAppxFactory"
|
||||
"IID_IAppxPackageReader"
|
||||
"IID_IAppxFile"
|
||||
"IID_IAppxFilesEnumerator"
|
||||
"IID_IAppxBlockMapReader"
|
||||
"IID_IAppxBlockMapFile"
|
||||
"IID_IAppxBlockMapFilesEnumerator"
|
||||
"IID_IAppxBlockMapBlock"
|
||||
"IID_IAppxBlockMapBlocksEnumerator"
|
||||
"IID_IAppxManifestReader"
|
||||
"IID_IAppxManifestReader2"
|
||||
"IID_IAppxManifestReader3"
|
||||
"IID_IAppxManifestPackageId"
|
||||
"IID_IAppxManifestProperties"
|
||||
"IID_IAppxManifestTargetDeviceFamiliesEnumerator"
|
||||
"IID_IAppxManifestTargetDeviceFamily"
|
||||
"IID_IAppxManifestPackageDependenciesEnumerator"
|
||||
"IID_IAppxManifestPackageDependency"
|
||||
"IID_IAppxManifestResourcesEnumerator"
|
||||
"IID_IAppxManifestApplicationsEnumerator"
|
||||
"IID_IAppxManifestApplication"
|
||||
"IID_IAppxManifestQualifiedResourcesEnumerator"
|
||||
"IID_IAppxManifestQualifiedResource"
|
||||
"IID_IAppxBundleFactory"
|
||||
"IID_IAppxBundleReader"
|
||||
"IID_IAppxBundleManifestReader"
|
||||
"IID_IAppxBundleManifestPackageInfoEnumerator"
|
||||
"IID_IAppxBundleManifestPackageInfo"
|
||||
"IID_IMsixDocumentElement"
|
||||
"IID_IMsixElement"
|
||||
"IID_IMsixElementEnumerator"
|
||||
"IID_IMsixFactoryOverrides"
|
||||
"IID_IMsixStreamFactory"
|
||||
"IID_IMsixApplicabilityLanguagesEnumerator"
|
||||
)
|
||||
if((IOS) OR (MACOS))
|
||||
# on Apple platforms you can explicitly define which symbols are exported
|
||||
|
@ -210,7 +174,6 @@ add_library(${PROJECT_NAME} SHARED
|
|||
AppxManifestObject.cpp
|
||||
AppxPackageObject.cpp
|
||||
AppxPackageInfo.cpp
|
||||
AppxPackaging_i.cpp
|
||||
AppxSignature.cpp
|
||||
Encoding.cpp
|
||||
Exceptions.cpp
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// See LICENSE file in the project root for full license information.
|
||||
//
|
||||
// ONLY build on platforms other than Win32
|
||||
#ifdef WIN32
|
||||
#include "Exceptions.hpp"
|
||||
#include "DirectoryObject.hpp"
|
||||
#include "FileStream.hpp"
|
||||
|
@ -170,4 +169,3 @@ namespace MSIX {
|
|||
|
||||
// Don't pollute other compilation units with any of our #defs...
|
||||
#undef UNICODE
|
||||
#endif
|
|
@ -17,9 +17,6 @@
|
|||
#include "Enumerators.hpp"
|
||||
#include "JniHelper.hpp"
|
||||
|
||||
|
||||
EXTERN_C const IID IID_IJavaXmlElement;
|
||||
|
||||
// An internal interface for java XML document object model
|
||||
// {69AB3660-398D-4CD6-A131-E73106040E3B}
|
||||
interface IJavaXmlElement : public IUnknown
|
||||
|
@ -27,8 +24,7 @@ interface IJavaXmlElement : public IUnknown
|
|||
public:
|
||||
virtual jobject GetJavaObject() = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IJavaXmlElement);
|
||||
MSIX_INTERFACE(IJavaXmlElement, 0x69ab3660,0x398d,0x4cd6,0xa1,0x31,0xe7,0x31,0x6,0x4,0xe,0x3b);
|
||||
|
||||
namespace MSIX {
|
||||
|
||||
|
@ -84,7 +80,6 @@ public:
|
|||
auto intermediate = wstring_to_utf8(name);
|
||||
auto attributeValue = GetAttributeValue(intermediate);
|
||||
return m_factory->MarshalOutString(attributeValue, value);;
|
||||
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetText(LPWSTR* value) noexcept override try
|
||||
|
@ -96,10 +91,28 @@ public:
|
|||
|
||||
HRESULT STDMETHODCALLTYPE GetElements(LPCWSTR name, IMsixElementEnumerator** elements) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (elements == nullptr || *elements != nullptr), "bad pointer.");
|
||||
return GetElementsUtf8(wstring_to_utf8(name).c_str(), elements);
|
||||
} CATCH_RETURN();
|
||||
|
||||
auto intermediate = wstring_to_utf8(name);
|
||||
std::unique_ptr<_jstring, JObjectDeleter> jname(m_env->NewStringUTF(intermediate.c_str()));
|
||||
HRESULT STDMETHODCALLTYPE GetAttributeValueUtf8(LPCSTR name, LPSTR* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr), "bad pointer.");
|
||||
auto attribute = std::string(name);
|
||||
auto attributeValue = GetAttributeValue(attribute);
|
||||
return m_factory->MarshalOutStringUtf8(attributeValue, value);;
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetTextUtf8(LPSTR* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr), "bad pointer.");
|
||||
auto text = GetText();
|
||||
return m_factory->MarshalOutStringUtf8(text, value);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetElementsUtf8(LPCSTR name, IMsixElementEnumerator** elements) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (elements == nullptr || *elements != nullptr), "bad pointer.");
|
||||
std::unique_ptr<_jstring, JObjectDeleter> jname(m_env->NewStringUTF(name));
|
||||
std::unique_ptr<_jobjectArray, JObjectDeleter> javaElements(reinterpret_cast<jobjectArray>(m_env->CallObjectMethod(m_javaXmlElementObject.get(), getElementsFunc, jname.get())));
|
||||
std::vector<ComPtr<IMsixElement>> elementsEnum;
|
||||
// Note: if the number of elements are large, JNI might barf due to too many local refs alive. This should only be used for small lists.
|
||||
|
@ -108,10 +121,7 @@ public:
|
|||
auto item = ComPtr<IMsixElement>::Make<JavaXmlElement>(m_factory, m_env->GetObjectArrayElement(javaElements.get(), i));
|
||||
elementsEnum.push_back(std::move(item));
|
||||
}
|
||||
*elements = ComPtr<IMsixElementEnumerator>::
|
||||
Make<EnumeratorCom<IMsixElementEnumerator,IMsixElement>>(elementsEnum).Detach();
|
||||
|
||||
|
||||
*elements = ComPtr<IMsixElementEnumerator>::Make<EnumeratorCom<IMsixElementEnumerator,IMsixElement>>(elementsEnum).Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#include "Enumerators.hpp"
|
||||
#include "XmlDocumentReader.hpp"
|
||||
|
||||
EXTERN_C const IID IID_IAppleXmlElement;
|
||||
|
||||
// An internal interface for apple XML document object model
|
||||
// {8FBC0096-E87D-406A-95D9-203ADEFBF9AF}
|
||||
interface IAppleXmlElement : public IUnknown
|
||||
|
@ -26,8 +24,7 @@ interface IAppleXmlElement : public IUnknown
|
|||
public:
|
||||
virtual MSIX::XmlNode* GetXmlNode() = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IAppleXmlElement);
|
||||
MSIX_INTERFACE(IAppleXmlElement, 0x8fbc0096, 0xe87d, 0x406a, 0x95, 0xd9, 0x20, 0x3a, 0xde, 0xfb, 0xf9, 0xaf);
|
||||
|
||||
namespace MSIX {
|
||||
|
||||
|
@ -67,7 +64,6 @@ public:
|
|||
auto intermediate = wstring_to_utf8(name);
|
||||
auto attributeValue = GetAttributeValue(intermediate);
|
||||
return m_factory->MarshalOutString(attributeValue, value);;
|
||||
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetText(LPWSTR* value) noexcept override try
|
||||
|
@ -78,23 +74,37 @@ public:
|
|||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetElements(LPCWSTR name, IMsixElementEnumerator** elements) noexcept override try
|
||||
{
|
||||
return GetElementsUtf8(wstring_to_utf8(name).c_str(), elements);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetAttributeValueUtf8(LPCSTR name, LPSTR* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr), "bad pointer.");
|
||||
auto attribute = std::string(name);
|
||||
auto attributeValue = GetAttributeValue(attribute);
|
||||
return m_factory->MarshalOutStringUtf8(attributeValue, value);;
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetTextUtf8(LPSTR* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr), "bad pointer.");
|
||||
auto text = GetText();
|
||||
return m_factory->MarshalOutStringUtf8(text, value);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetElementsUtf8(LPCSTR name, IMsixElementEnumerator** elements) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (elements == nullptr || *elements != nullptr), "bad pointer.");
|
||||
|
||||
auto intermediate = wstring_to_utf8(name);
|
||||
|
||||
auto elementsFound = m_xmlNode->FindElements(intermediate);
|
||||
|
||||
auto attribute = std::string(name);
|
||||
auto elementsFound = m_xmlNode->FindElements(attribute);
|
||||
std::vector<ComPtr<IMsixElement>> elementsEnum;
|
||||
for(auto element : elementsFound)
|
||||
{
|
||||
auto item = ComPtr<IMsixElement>::Make<XmlElement>(m_factory, element);
|
||||
elementsEnum.push_back(std::move(item));
|
||||
}
|
||||
|
||||
*elements = ComPtr<IMsixElementEnumerator>::
|
||||
Make<EnumeratorCom<IMsixElementEnumerator,IMsixElement>>(elementsEnum).Detach();
|
||||
|
||||
*elements = ComPtr<IMsixElementEnumerator>::Make<EnumeratorCom<IMsixElementEnumerator,IMsixElement>>(elementsEnum).Detach();
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
|
|
|
@ -22,37 +22,25 @@
|
|||
|
||||
#include <msxml6.h>
|
||||
|
||||
EXTERN_C const IID IID_IMSXMLElement;
|
||||
EXTERN_C const IID IID_IMSXMLDom;
|
||||
|
||||
#ifndef WIN32
|
||||
// {2730f595-0c80-4f3e-8891-753b2e8c305d}
|
||||
interface IMSXMLElement : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
#include "Objidl.h"
|
||||
// {2730f595-0c80-4f3e-8891-753b2e8c305d}
|
||||
class IMSXMLElement : public IUnknown
|
||||
#endif
|
||||
// An internal interface for XML document object model
|
||||
{
|
||||
public:
|
||||
virtual MSIX::ComPtr<IXMLDOMNodeList> SelectNodes(XmlQueryName query) = 0;
|
||||
};
|
||||
MSIX_INTERFACE(IMSXMLElement, 0x2730f595,0x0c80,0x4f3e,0x88,0x91,0x75,0x3b,0x2e,0x8c,0x30,0x5d);
|
||||
|
||||
#ifndef WIN32
|
||||
// {b6bca5f0-c6c1-4409-85be-e476aabec19a}
|
||||
interface IMSXMLDom : public IUnknown
|
||||
#else
|
||||
class IMSXMLDom : public IUnknown
|
||||
#endif
|
||||
// An internal interface for XML document object model
|
||||
{
|
||||
public:
|
||||
virtual MSIX::ComPtr<IXMLDOMDocument> GetDomDocument() = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IMSXMLElement);
|
||||
SpecializeUuidOfImpl(IMSXMLDom);
|
||||
MSIX_INTERFACE(IMSXMLDom, 0xb6bca5f0,0xc6c1,0x4409,0x85,0xbe,0xe4,0x76,0xaa,0xbe,0xc1,0x9a);
|
||||
|
||||
namespace MSIX {
|
||||
|
||||
|
@ -201,13 +189,6 @@ public:
|
|||
|
||||
class MSXMLElement final : public ComClass<MSXMLElement, IXmlElement, IMSXMLElement, IMsixElement>
|
||||
{
|
||||
bool GetAttribute(const std::wstring& attribute, VARIANT* variant)
|
||||
{
|
||||
Bstr name(attribute);
|
||||
ThrowHrIfFailed(m_element->getAttribute(name, variant));
|
||||
return (variant->vt == VT_BSTR);
|
||||
}
|
||||
|
||||
public:
|
||||
MSXMLElement(IMsixFactory* factory, ComPtr<IXMLDOMElement>& element) : m_factory(factory), m_element(element) {}
|
||||
|
||||
|
@ -281,7 +262,6 @@ public:
|
|||
|
||||
HRESULT STDMETHODCALLTYPE GetElements(LPCWSTR name, IMsixElementEnumerator** elements) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (elements == nullptr || *elements != nullptr), "bad pointer.");
|
||||
ComPtr<IXMLDOMNodeList> list;
|
||||
Bstr xPath(name);
|
||||
ThrowHrIfFailed(m_element->selectNodes(xPath, &list));
|
||||
|
@ -303,7 +283,70 @@ public:
|
|||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetAttributeValueUtf8(LPCSTR name, LPSTR* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr), "bad pointer.");
|
||||
*value = nullptr;
|
||||
Variant attribute;
|
||||
auto wname = utf8_to_wstring(name);
|
||||
if (GetAttribute(wname, attribute.AddressOf()))
|
||||
{
|
||||
auto intermediate = wstring_to_utf8(std::wstring(static_cast<WCHAR*>(attribute.Get().bstrVal)));
|
||||
ThrowHrIfFailed(m_factory->MarshalOutStringUtf8(intermediate, value));
|
||||
}
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetTextUtf8(LPSTR* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr), "bad pointer.");
|
||||
ComPtr<IXMLDOMNode> node;
|
||||
ThrowHrIfFailed(m_element->QueryInterface(__uuidof(IXMLDOMNode), reinterpret_cast<void**>(&node)));
|
||||
Bstr text;
|
||||
ThrowHrIfFailed(node->get_text(text.AddressOf()));
|
||||
if (text.Get() != nullptr)
|
||||
{
|
||||
auto intermediate = wstring_to_utf8(std::wstring(static_cast<WCHAR*>(text.Get())));
|
||||
ThrowHrIfFailed(m_factory->MarshalOutStringUtf8(intermediate, value));
|
||||
}
|
||||
return static_cast<HRESULT>(Error::OK);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetElementsUtf8(LPCSTR name, IMsixElementEnumerator** elements) noexcept override try
|
||||
{
|
||||
return GetElements(utf8_to_wstring(name).c_str(), elements);
|
||||
} CATCH_RETURN();
|
||||
|
||||
protected:
|
||||
|
||||
bool GetAttribute(const std::wstring& attribute, VARIANT* variant)
|
||||
{
|
||||
Bstr name(attribute);
|
||||
ThrowHrIfFailed(m_element->getAttribute(name, variant));
|
||||
return (variant->vt == VT_BSTR);
|
||||
}
|
||||
|
||||
ComPtr<IMsixElementEnumerator> GetElementsHelper(std::wstring& name)
|
||||
{
|
||||
ComPtr<IXMLDOMNodeList> list;
|
||||
Bstr xPath(name);
|
||||
ThrowHrIfFailed(m_element->selectNodes(xPath, &list));
|
||||
|
||||
long count = 0;
|
||||
ThrowHrIfFailed(list->get_length(&count));
|
||||
std::vector<ComPtr<IMsixElement>> elementsEnum;
|
||||
for(long index=0; index < count; index++)
|
||||
{
|
||||
ComPtr<IXMLDOMNode> node;
|
||||
ThrowHrIfFailed(list->get_item(index, &node));
|
||||
ComPtr<IXMLDOMElement> elementItem;
|
||||
ThrowHrIfFailed(node->QueryInterface(__uuidof(IXMLDOMElement), reinterpret_cast<void**>(&elementItem)));
|
||||
auto item = ComPtr<IMsixElement>::Make<MSXMLElement>(m_factory, elementItem);
|
||||
elementsEnum.push_back(std::move(item));
|
||||
}
|
||||
return ComPtr<IMsixElementEnumerator>::Make<EnumeratorCom<IMsixElementEnumerator,IMsixElement>>(elementsEnum);
|
||||
}
|
||||
|
||||
IMsixFactory* m_factory;
|
||||
ComPtr<IXMLDOMElement> m_element;
|
||||
};
|
||||
|
|
|
@ -28,23 +28,20 @@
|
|||
|
||||
XERCES_CPP_NAMESPACE_USE
|
||||
|
||||
EXTERN_C const IID IID_IXercesElement;
|
||||
|
||||
#ifndef WIN32
|
||||
// An internal interface for XML document object model
|
||||
// {07d6ee0e-2165-4b90-8024-e176291e77dd}
|
||||
#ifndef WIN32
|
||||
interface IXercesElement : public IUnknown
|
||||
#else
|
||||
#include "Unknwn.h"
|
||||
#include "Objidl.h"
|
||||
class IXercesElement : public IUnknown
|
||||
#endif
|
||||
// An internal interface for XML document object model
|
||||
{
|
||||
public:
|
||||
virtual DOMElement* GetElement() = 0;
|
||||
};
|
||||
|
||||
SpecializeUuidOfImpl(IXercesElement);
|
||||
MSIX_INTERFACE(IXercesElement, 0x07d6ee0e,0x2165,0x4b90,0x80,0x24,0xe1,0x76,0x29,0x1e,0x77,0xdd);
|
||||
|
||||
namespace MSIX {
|
||||
|
||||
|
@ -270,12 +267,30 @@ public:
|
|||
|
||||
HRESULT STDMETHODCALLTYPE GetElements(LPCWSTR name, IMsixElementEnumerator** elements) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (elements == nullptr || *elements != nullptr), "bad pointer.");
|
||||
return GetElementsUtf8(wstring_to_utf8(name).c_str(), elements);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetAttributeValueUtf8(LPCSTR name, LPSTR* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr), "bad pointer.");
|
||||
auto attribute = std::string(name);
|
||||
auto attributeValue = GetAttributeValue(attribute);
|
||||
return m_factory->MarshalOutStringUtf8(attributeValue, value);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetTextUtf8(LPSTR* value) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (value == nullptr), "bad pointer.");
|
||||
auto text = GetText();
|
||||
return m_factory->MarshalOutStringUtf8(text, value);
|
||||
} CATCH_RETURN();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetElementsUtf8(LPCSTR name, IMsixElementEnumerator** elements) noexcept override try
|
||||
{
|
||||
ThrowErrorIf(Error::InvalidParameter, (elements == nullptr || *elements != nullptr), "bad pointer.");
|
||||
// Note: getElementsByTagName only returns the childs of a DOMElement and doesn't
|
||||
// support xPath. For this reason we need the XercesDomParser in this object.
|
||||
auto intermediate = wstring_to_utf8(name);
|
||||
XercesXMLChPtr xPath(XMLString::transcode(intermediate.c_str()));
|
||||
XercesXMLChPtr xPath(XMLString::transcode(name));
|
||||
XercesPtr<DOMXPathResult> result(m_parser->getDocument()->evaluate(
|
||||
xPath.Get(),
|
||||
m_element,
|
||||
|
|
|
@ -379,13 +379,25 @@ void StartTestPackage(void*)
|
|||
VERIFY_SUCCEEDED(files->GetCurrent(&file));
|
||||
Text<wchar_t> fileName;
|
||||
VERIFY_SUCCEEDED(file->GetName(&fileName));
|
||||
VERIFY_ARE_EQUAL(fileName.ToString(), expectedPayloadFiles.at(nFiles));
|
||||
VERIFY_ARE_EQUAL(expectedPayloadFiles.at(nFiles), fileName.ToString());
|
||||
|
||||
ComPtr<IAppxFileUtf8> fileUtf8;
|
||||
VERIFY_SUCCEEDED(file->QueryInterface(UuidOfImpl<IAppxFileUtf8>::iid, reinterpret_cast<void**>(&fileUtf8)));
|
||||
Text<char> fileNameUtf8;
|
||||
VERIFY_SUCCEEDED(fileUtf8->GetName(&fileNameUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedPayloadFiles.at(nFiles), fileNameUtf8.ToString());
|
||||
|
||||
// Compare that the file from GetPayloadFile is the same file
|
||||
ComPtr<IAppxFile> file2;
|
||||
VERIFY_SUCCEEDED(packageReader->GetPayloadFile(fileName.Get(), &file2));
|
||||
VERIFY_ARE_SAME(file.Get(), file2.Get());
|
||||
|
||||
ComPtr<IAppxPackageReaderUtf8> packageReaderUtf8;
|
||||
VERIFY_SUCCEEDED(packageReader->QueryInterface(UuidOfImpl<IAppxPackageReaderUtf8>::iid, reinterpret_cast<void**>(&packageReaderUtf8)));
|
||||
ComPtr<IAppxFile> file3;
|
||||
VERIFY_SUCCEEDED(packageReaderUtf8->GetPayloadFile(fileNameUtf8.Get(), &file3));
|
||||
VERIFY_ARE_SAME(file2.Get(), file3.Get());
|
||||
|
||||
VERIFY_SUCCEEDED(files->MoveNext(&hasCurrent));
|
||||
nFiles++;
|
||||
}
|
||||
|
@ -502,6 +514,12 @@ void StartTestPackageManifest(void*)
|
|||
VERIFY_SUCCEEDED(app->GetAppUserModelId(&aumid));
|
||||
VERIFY_ARE_EQUAL(expectedAumid, aumid.ToString());
|
||||
|
||||
Text<char> aumidUtf8;
|
||||
ComPtr<IAppxManifestApplicationUtf8> appUtf8;
|
||||
VERIFY_SUCCEEDED(app->QueryInterface(UuidOfImpl<IAppxManifestApplicationUtf8>::iid, reinterpret_cast<void**>(&appUtf8)));
|
||||
VERIFY_SUCCEEDED(appUtf8->GetAppUserModelId(&aumidUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedAumid, aumidUtf8.ToString());
|
||||
|
||||
// Note: this isn't implemented. But adding check so when we do, we update this test too.
|
||||
Text<wchar_t> value;
|
||||
VERIFY_HR(static_cast<HRESULT>(MSIX::Error::NotImplemented), app->GetStringValue(L"dummy", &value));
|
||||
|
@ -519,14 +537,19 @@ void StartTestPackageManifest(void*)
|
|||
ComPtr<IAppxManifestProperties> properties;
|
||||
VERIFY_SUCCEEDED(manifestReader->GetProperties(&properties));
|
||||
|
||||
ComPtr<IAppxManifestPropertiesUtf8> propertiesUtf8;
|
||||
VERIFY_SUCCEEDED(properties->QueryInterface(UuidOfImpl<IAppxManifestPropertiesUtf8>::iid, reinterpret_cast<void**>(&propertiesUtf8)));
|
||||
|
||||
for(int i = 0; i < numberOfTests; i++)
|
||||
{
|
||||
auto valueType = GetInput<std::string>();
|
||||
auto value = utf8_to_utf16(GetInput<std::string>());
|
||||
auto valueUtf8 = GetInput<std::string>();
|
||||
auto value = utf8_to_utf16(valueUtf8);
|
||||
auto expected = GetInput<std::string>();
|
||||
if (valueType == "BoolValue")
|
||||
{
|
||||
BOOL result;
|
||||
BOOL result = FALSE;
|
||||
BOOL resultUtf8 = FALSE;
|
||||
if (expected == "invalid")
|
||||
{
|
||||
VERIFY_HR(static_cast<HRESULT>(MSIX::Error::InvalidParameter), properties->GetBoolValue(value.c_str(), &result));
|
||||
|
@ -534,13 +557,16 @@ void StartTestPackageManifest(void*)
|
|||
else
|
||||
{
|
||||
VERIFY_SUCCEEDED(properties->GetBoolValue(value.c_str(), &result));
|
||||
VERIFY_SUCCEEDED(propertiesUtf8->GetBoolValue(valueUtf8.c_str(), &resultUtf8));
|
||||
if (expected == "true")
|
||||
{
|
||||
VERIFY_IS_TRUE(result);
|
||||
VERIFY_IS_TRUE(resultUtf8);
|
||||
}
|
||||
else if (expected == "false")
|
||||
{
|
||||
VERIFY_IS_FALSE(result);
|
||||
VERIFY_IS_FALSE(resultUtf8);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -551,6 +577,7 @@ void StartTestPackageManifest(void*)
|
|||
else if (valueType == "StringValue")
|
||||
{
|
||||
Text<wchar_t> result;
|
||||
Text<char> resultUtf8;
|
||||
if (expected == "invalid")
|
||||
{
|
||||
VERIFY_HR(static_cast<HRESULT>(MSIX::Error::InvalidParameter), properties->GetStringValue(value.c_str(), &result));
|
||||
|
@ -559,11 +586,17 @@ void StartTestPackageManifest(void*)
|
|||
{
|
||||
VERIFY_SUCCEEDED(properties->GetStringValue(value.c_str(), &result));
|
||||
VERIFY_IS_NULL(result.Get());
|
||||
|
||||
VERIFY_SUCCEEDED(propertiesUtf8->GetStringValue(valueUtf8.c_str(), &resultUtf8));
|
||||
VERIFY_IS_NULL(resultUtf8.Get());
|
||||
}
|
||||
else
|
||||
{
|
||||
VERIFY_SUCCEEDED(properties->GetStringValue(value.c_str(), &result));
|
||||
VERIFY_ARE_EQUAL(expected, result.ToString());
|
||||
|
||||
VERIFY_SUCCEEDED(propertiesUtf8->GetStringValue(valueUtf8.c_str(), &resultUtf8));
|
||||
VERIFY_ARE_EQUAL(expected, resultUtf8.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -589,11 +622,18 @@ void StartTestPackageManifest(void*)
|
|||
ComPtr<IAppxManifestPackageDependency> dependency;
|
||||
VERIFY_SUCCEEDED(dependencies->GetCurrent(&dependency));
|
||||
|
||||
ComPtr<IAppxManifestPackageDependencyUtf8> dependencyUtf8;
|
||||
VERIFY_SUCCEEDED(dependency->QueryInterface(UuidOfImpl<IAppxManifestPackageDependencyUtf8>::iid, reinterpret_cast<void**>(&dependencyUtf8)));
|
||||
|
||||
auto expectedName = GetInput<std::string>();
|
||||
Text<wchar_t> name;
|
||||
VERIFY_SUCCEEDED(dependency->GetName(&name));
|
||||
VERIFY_ARE_EQUAL(expectedName, name.ToString());
|
||||
|
||||
Text<char> nameUtf8;
|
||||
VERIFY_SUCCEEDED(dependencyUtf8->GetName(&nameUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedName, nameUtf8.ToString());
|
||||
|
||||
auto expectedMin = GetInput<UINT64>();
|
||||
UINT64 min = 0;
|
||||
VERIFY_SUCCEEDED(dependency->GetMinVersion(&min));
|
||||
|
@ -604,6 +644,10 @@ void StartTestPackageManifest(void*)
|
|||
VERIFY_SUCCEEDED(dependency->GetPublisher(&publisher));
|
||||
VERIFY_ARE_EQUAL(expectedPublisher, publisher.ToString());
|
||||
|
||||
Text<char> publisherUtf8;
|
||||
VERIFY_SUCCEEDED(dependencyUtf8->GetPublisher(&publisherUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedPublisher, publisherUtf8.ToString());
|
||||
|
||||
VERIFY_SUCCEEDED(dependencies->MoveNext(&hasCurrent));
|
||||
numDep++;
|
||||
}
|
||||
|
@ -625,6 +669,9 @@ void StartTestPackageManifest(void*)
|
|||
auto expNumOfResources = GetInput<int>();
|
||||
ComPtr<IAppxManifestResourcesEnumerator> resources;
|
||||
VERIFY_SUCCEEDED(manifestReader->GetResources(&resources));
|
||||
ComPtr<IAppxManifestResourcesEnumeratorUtf8> resourcesUtf8;
|
||||
VERIFY_SUCCEEDED(resources->QueryInterface(UuidOfImpl<IAppxManifestResourcesEnumeratorUtf8>::iid, reinterpret_cast<void**>(&resourcesUtf8)));
|
||||
|
||||
BOOL hasCurrent = FALSE;
|
||||
VERIFY_SUCCEEDED(resources->GetHasCurrent(&hasCurrent));
|
||||
int numOfDependencies = 0;
|
||||
|
@ -634,6 +681,11 @@ void StartTestPackageManifest(void*)
|
|||
Text<wchar_t> resource;
|
||||
VERIFY_SUCCEEDED(resources->GetCurrent(&resource));
|
||||
VERIFY_ARE_EQUAL(expectedResource, resource.ToString());
|
||||
|
||||
Text<char> resourceUtf8;
|
||||
VERIFY_SUCCEEDED(resourcesUtf8->GetCurrent(&resourceUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedResource, resourceUtf8.ToString());
|
||||
|
||||
VERIFY_SUCCEEDED(resources->MoveNext(&hasCurrent));
|
||||
numOfDependencies++;
|
||||
}
|
||||
|
@ -661,6 +713,12 @@ void StartTestPackageManifest(void*)
|
|||
VERIFY_SUCCEEDED(tdf->GetName(&name));
|
||||
VERIFY_ARE_EQUAL(expectedName, name.ToString());
|
||||
|
||||
ComPtr<IAppxManifestTargetDeviceFamilyUtf8> tdfUtf8;
|
||||
VERIFY_SUCCEEDED(tdf->QueryInterface(UuidOfImpl<IAppxManifestTargetDeviceFamilyUtf8>::iid, reinterpret_cast<void**>(&tdfUtf8)));
|
||||
Text<char> nameUtf8;
|
||||
VERIFY_SUCCEEDED(tdfUtf8->GetName(&nameUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedName, nameUtf8.ToString());
|
||||
|
||||
auto expectedMin = GetInput<UINT64>();
|
||||
UINT64 min = 0;
|
||||
VERIFY_SUCCEEDED(tdf->GetMinVersion(&min));
|
||||
|
@ -686,40 +744,75 @@ void StartTestPackageManifest(void*)
|
|||
ComPtr<IMsixElement> manifestElement;
|
||||
VERIFY_SUCCEEDED(msixDocument->GetDocumentElement(&manifestElement));
|
||||
|
||||
auto xpath = utf8_to_utf16(GetInput<std::string>());
|
||||
auto xpathUtf8 = GetInput<std::string>();
|
||||
auto xpath = utf8_to_utf16(xpathUtf8);
|
||||
ComPtr<IMsixElementEnumerator> elementEnum;
|
||||
VERIFY_SUCCEEDED(manifestElement->GetElements(xpath.c_str(), &elementEnum));
|
||||
|
||||
ComPtr<IMsixElementEnumerator> elementEnumFromUtf8;
|
||||
VERIFY_SUCCEEDED(manifestElement->GetElementsUtf8(xpathUtf8.c_str(), &elementEnumFromUtf8));
|
||||
|
||||
BOOL hasCurrent = FALSE;
|
||||
BOOL hasCurrentFromUtf8 = FALSE;
|
||||
VERIFY_SUCCEEDED(elementEnum->GetHasCurrent(&hasCurrent));
|
||||
VERIFY_SUCCEEDED(elementEnumFromUtf8->GetHasCurrent(&hasCurrentFromUtf8));
|
||||
int numOfElements = 0;
|
||||
while(hasCurrent)
|
||||
while(hasCurrent && hasCurrentFromUtf8)
|
||||
{
|
||||
// NOTE: element and elementFromUtf8 are different objects, but should output the same results.
|
||||
ComPtr<IMsixElement> element;
|
||||
VERIFY_SUCCEEDED(elementEnum->GetCurrent(&element));
|
||||
|
||||
ComPtr<IMsixElement> elementFromUtf8;
|
||||
VERIFY_SUCCEEDED(elementEnumFromUtf8->GetCurrent(&elementFromUtf8));
|
||||
|
||||
auto numOfAttributes = GetInput<int>();
|
||||
for (int i = 0; i < numOfAttributes; i++)
|
||||
{
|
||||
auto a = GetInput<std::string>();
|
||||
auto attributeUtf8 = GetInput<std::string>();
|
||||
Text<wchar_t> value;
|
||||
if (a == "Fake")
|
||||
Text<char> valueUtf8;
|
||||
Text<wchar_t> valueFromUtf8;
|
||||
Text<char> valueUtf8FromUtf8;
|
||||
if (attributeUtf8 == "Fake")
|
||||
{
|
||||
VERIFY_SUCCEEDED(element->GetAttributeValue(L"Fake", &value));
|
||||
VERIFY_IS_NULL(value.Get());
|
||||
|
||||
VERIFY_SUCCEEDED(element->GetAttributeValueUtf8("Fake", &valueUtf8));
|
||||
VERIFY_IS_NULL(valueUtf8.Get());
|
||||
|
||||
VERIFY_SUCCEEDED(elementFromUtf8->GetAttributeValue(L"Fake", &valueFromUtf8));
|
||||
VERIFY_IS_NULL(valueFromUtf8.Get());
|
||||
|
||||
VERIFY_SUCCEEDED(elementFromUtf8->GetAttributeValueUtf8("Fake", &valueUtf8FromUtf8));
|
||||
VERIFY_IS_NULL(valueUtf8FromUtf8.Get());
|
||||
}
|
||||
else
|
||||
{
|
||||
auto attribute = utf8_to_utf16(a);
|
||||
auto attribute = utf8_to_utf16(attributeUtf8);
|
||||
auto expectedValue = GetInput<std::string>();
|
||||
|
||||
VERIFY_SUCCEEDED(element->GetAttributeValue(attribute.c_str(), &value));
|
||||
VERIFY_ARE_EQUAL(expectedValue, value.ToString());
|
||||
|
||||
VERIFY_SUCCEEDED(element->GetAttributeValueUtf8(attributeUtf8.c_str(), &valueUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedValue, valueUtf8.ToString());
|
||||
|
||||
VERIFY_SUCCEEDED(elementFromUtf8->GetAttributeValue(attribute.c_str(), &valueFromUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedValue, valueFromUtf8.ToString());
|
||||
|
||||
VERIFY_SUCCEEDED(elementFromUtf8->GetAttributeValueUtf8(attributeUtf8.c_str(), &valueUtf8FromUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedValue, valueUtf8FromUtf8.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
VERIFY_SUCCEEDED(elementEnum->MoveNext(&hasCurrent));
|
||||
VERIFY_SUCCEEDED(elementEnumFromUtf8->MoveNext(&hasCurrentFromUtf8));
|
||||
numOfElements++;
|
||||
}
|
||||
VERIFY_ARE_EQUAL(expNumOfElements, numOfElements);
|
||||
VERIFY_IS_FALSE(hasCurrent || hasCurrentFromUtf8)
|
||||
}
|
||||
)},
|
||||
{ "Package.Manifest.PackageId", Test<IAppxManifestReader>("Validates manifest package id",
|
||||
|
@ -729,11 +822,17 @@ void StartTestPackageManifest(void*)
|
|||
VERIFY_SUCCEEDED(manifestReader->GetPackageId(&packageId));
|
||||
VERIFY_NOT_NULL(packageId.Get());
|
||||
|
||||
ComPtr<IAppxManifestPackageIdUtf8> packageIdUtf8;
|
||||
VERIFY_SUCCEEDED(packageId->QueryInterface(UuidOfImpl<IAppxManifestPackageIdUtf8>::iid, reinterpret_cast<void**>(&packageIdUtf8)));
|
||||
|
||||
auto expectedName = GetInput<std::string>();
|
||||
Text<wchar_t> name;
|
||||
VERIFY_SUCCEEDED(packageId->GetName(&name));
|
||||
VERIFY_ARE_EQUAL(expectedName, name.ToString())
|
||||
|
||||
Text<char> nameUtf8;
|
||||
VERIFY_SUCCEEDED(packageIdUtf8->GetName(&nameUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedName, nameUtf8.ToString())
|
||||
|
||||
auto expectedArch = GetInput<int>();
|
||||
APPX_PACKAGE_ARCHITECTURE architecture;
|
||||
|
@ -745,9 +844,16 @@ void StartTestPackageManifest(void*)
|
|||
VERIFY_SUCCEEDED(packageId->GetPublisher(&publisher));
|
||||
VERIFY_ARE_EQUAL(expectedPublisher, publisher.ToString());
|
||||
|
||||
Text<char> publisherUtf8;
|
||||
VERIFY_SUCCEEDED(packageIdUtf8->GetPublisher(&publisherUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedPublisher, publisherUtf8.ToString());
|
||||
|
||||
BOOL isSame = FALSE;
|
||||
VERIFY_SUCCEEDED(packageId->ComparePublisher(publisher.Get(), &isSame));
|
||||
VERIFY_IS_TRUE(isSame);
|
||||
isSame = FALSE;
|
||||
VERIFY_SUCCEEDED(packageIdUtf8->ComparePublisher(publisherUtf8.Get(), &isSame));
|
||||
VERIFY_IS_TRUE(isSame);
|
||||
VERIFY_SUCCEEDED(packageId->ComparePublisher(L"OtherPublisher", &isSame));
|
||||
VERIFY_IS_FALSE(isSame);
|
||||
|
||||
|
@ -766,6 +872,10 @@ void StartTestPackageManifest(void*)
|
|||
else
|
||||
{
|
||||
VERIFY_ARE_EQUAL(expectedResource, resourceId.ToString());
|
||||
|
||||
Text<char> resourceIdUtf8;
|
||||
VERIFY_SUCCEEDED(packageIdUtf8->GetResourceId(&resourceIdUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedResource, resourceIdUtf8.ToString());
|
||||
}
|
||||
|
||||
auto expectedFull = GetInput<std::string>();
|
||||
|
@ -773,10 +883,18 @@ void StartTestPackageManifest(void*)
|
|||
VERIFY_SUCCEEDED(packageId->GetPackageFullName(&packageFullName));
|
||||
VERIFY_ARE_EQUAL(expectedFull, packageFullName.ToString());
|
||||
|
||||
Text<char> packageFullNameUtf8;
|
||||
VERIFY_SUCCEEDED(packageIdUtf8->GetPackageFullName(&packageFullNameUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedFull, packageFullNameUtf8.ToString());
|
||||
|
||||
auto expectedFamily = GetInput<std::string>();
|
||||
Text<wchar_t> packageFamilyName;
|
||||
VERIFY_SUCCEEDED(packageId->GetPackageFamilyName(&packageFamilyName));
|
||||
VERIFY_ARE_EQUAL(expectedFamily, packageFamilyName.ToString());
|
||||
|
||||
Text<char> packageFamilyNameUtf8;
|
||||
VERIFY_SUCCEEDED(packageIdUtf8->GetPackageFamilyName(&packageFamilyNameUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedFamily, packageFamilyNameUtf8.ToString());
|
||||
}
|
||||
)},
|
||||
};
|
||||
|
@ -823,10 +941,22 @@ void StartTestPackageBlockMap(void*)
|
|||
VERIFY_SUCCEEDED(blockMapFile->GetName(&fileName))
|
||||
VERIFY_ARE_EQUAL(expectedName, fileName.ToString());
|
||||
|
||||
ComPtr<IAppxBlockMapFileUtf8> blockMapFileUtf8;
|
||||
VERIFY_SUCCEEDED(blockMapFile->QueryInterface(UuidOfImpl<IAppxBlockMapFileUtf8>::iid, reinterpret_cast<void**>(&blockMapFileUtf8)));
|
||||
Text<char> fileNameUtf8;
|
||||
VERIFY_SUCCEEDED(blockMapFileUtf8->GetName(&fileNameUtf8))
|
||||
VERIFY_ARE_EQUAL(expectedName, fileNameUtf8.ToString());
|
||||
|
||||
ComPtr<IAppxBlockMapFile> blockMapFile2;
|
||||
VERIFY_SUCCEEDED(blockMapReader->GetFile(fileName.Get(), &blockMapFile2));
|
||||
VERIFY_ARE_SAME(blockMapFile.Get(), blockMapFile2.Get());
|
||||
|
||||
ComPtr<IAppxBlockMapFile> blockMapFile3;
|
||||
ComPtr<IAppxBlockMapReaderUtf8> blockMapReaderUtf8;
|
||||
VERIFY_SUCCEEDED(blockMapReader->QueryInterface(UuidOfImpl<IAppxBlockMapReaderUtf8>::iid, reinterpret_cast<void**>(&blockMapReaderUtf8)));
|
||||
VERIFY_SUCCEEDED(blockMapReaderUtf8->GetFile(fileNameUtf8.Get(), &blockMapFile3));
|
||||
VERIFY_ARE_SAME(blockMapFile.Get(), blockMapFile3.Get());
|
||||
|
||||
auto expectedLfh = GetInput<UINT32>();
|
||||
UINT32 lfh;
|
||||
VERIFY_SUCCEEDED(blockMapFile->GetLocalFileHeaderSize(&lfh));
|
||||
|
@ -952,6 +1082,19 @@ void StartTestBundle(void*)
|
|||
ComPtr<IAppxFile> package2;
|
||||
VERIFY_SUCCEEDED(bundleReader->GetPayloadPackage(packageName.Get(), &package2));
|
||||
VERIFY_ARE_SAME(package.Get(), package2.Get());
|
||||
|
||||
Text<char> packageNameUtf8;
|
||||
ComPtr<IAppxFileUtf8> packageUtf8;
|
||||
VERIFY_SUCCEEDED(package->QueryInterface(UuidOfImpl<IAppxFileUtf8>::iid, reinterpret_cast<void**>(&packageUtf8)));
|
||||
VERIFY_SUCCEEDED(packageUtf8->GetName(&packageNameUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedName, packageNameUtf8.ToString());
|
||||
|
||||
ComPtr<IAppxFile> package3;
|
||||
ComPtr<IAppxBundleReaderUtf8> bundleReaderUtf8;
|
||||
VERIFY_SUCCEEDED(bundleReader->QueryInterface(UuidOfImpl<IAppxBundleReaderUtf8>::iid, reinterpret_cast<void**>(&bundleReaderUtf8)));
|
||||
VERIFY_SUCCEEDED(bundleReaderUtf8->GetPayloadPackage(packageNameUtf8.Get(), &package3));
|
||||
VERIFY_ARE_SAME(package.Get(), package3.Get());
|
||||
|
||||
VERIFY_SUCCEEDED(packages->MoveNext(&hasCurrent));
|
||||
numOfPackages++;
|
||||
}
|
||||
|
@ -1013,6 +1156,12 @@ void StartTestBundleManifest(void*)
|
|||
VERIFY_SUCCEEDED(bundleManifestPackageInfo->GetFileName(&fileName));
|
||||
VERIFY_ARE_EQUAL(expectedName, fileName.ToString());
|
||||
|
||||
Text<char> fileNameUtf8;
|
||||
ComPtr<IAppxBundleManifestPackageInfoUtf8> bundleManifestPackageInfoUtf8;
|
||||
VERIFY_SUCCEEDED(bundleManifestPackageInfo->QueryInterface(UuidOfImpl<IAppxBundleManifestPackageInfoUtf8>::iid, reinterpret_cast<void**>(&bundleManifestPackageInfoUtf8)));
|
||||
VERIFY_SUCCEEDED(bundleManifestPackageInfoUtf8->GetFileName(&fileNameUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedName, fileNameUtf8.ToString());
|
||||
|
||||
auto expectedType = GetInput<std::string>();
|
||||
APPX_BUNDLE_PAYLOAD_PACKAGE_TYPE type;
|
||||
VERIFY_SUCCEEDED(bundleManifestPackageInfo->GetPackageType(&type));
|
||||
|
@ -1056,6 +1205,12 @@ void StartTestBundleManifest(void*)
|
|||
VERIFY_SUCCEEDED(manifestQualifiedResources->GetLanguage(&language));
|
||||
VERIFY_ARE_EQUAL(expectedTag, language.ToString());
|
||||
|
||||
ComPtr<IAppxManifestQualifiedResourceUtf8> manifestQualifiedResourcesUtf8;
|
||||
VERIFY_SUCCEEDED(manifestQualifiedResources->QueryInterface(UuidOfImpl<IAppxManifestQualifiedResourceUtf8>::iid, reinterpret_cast<void**>(&manifestQualifiedResourcesUtf8)));
|
||||
Text<char> languageUtf8;
|
||||
VERIFY_SUCCEEDED(manifestQualifiedResourcesUtf8->GetLanguage(&languageUtf8));
|
||||
VERIFY_ARE_EQUAL(expectedTag, languageUtf8.ToString());
|
||||
|
||||
VERIFY_SUCCEEDED(manifestQualifiedResourcesEnumerator->MoveNext(&hasCurrentResource));
|
||||
nLangs++;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче