Commit 09cb9cd1 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

cryptowinrt: Add a stub module.

parent 307eae20
......@@ -980,6 +980,7 @@ enable_cryptdlg
enable_cryptdll
enable_cryptext
enable_cryptnet
enable_cryptowinrt
enable_cryptsp
enable_cryptui
enable_ctapi32
......@@ -21347,6 +21348,7 @@ wine_fn_config_makefile dlls/cryptdll enable_cryptdll
wine_fn_config_makefile dlls/cryptext enable_cryptext
wine_fn_config_makefile dlls/cryptnet enable_cryptnet
wine_fn_config_makefile dlls/cryptnet/tests enable_tests
wine_fn_config_makefile dlls/cryptowinrt enable_cryptowinrt
wine_fn_config_makefile dlls/cryptsp enable_cryptsp
wine_fn_config_makefile dlls/cryptui enable_cryptui
wine_fn_config_makefile dlls/cryptui/tests enable_tests
......
......@@ -2452,6 +2452,7 @@ WINE_CONFIG_MAKEFILE(dlls/cryptdll)
WINE_CONFIG_MAKEFILE(dlls/cryptext)
WINE_CONFIG_MAKEFILE(dlls/cryptnet)
WINE_CONFIG_MAKEFILE(dlls/cryptnet/tests)
WINE_CONFIG_MAKEFILE(dlls/cryptowinrt)
WINE_CONFIG_MAKEFILE(dlls/cryptsp)
WINE_CONFIG_MAKEFILE(dlls/cryptui)
WINE_CONFIG_MAKEFILE(dlls/cryptui/tests)
......
MODULE = cryptowinrt.dll
IMPORTS = combase uuid
C_SRCS = \
main.c
IDL_SRCS = classes.idl
/*
* Copyright 2022 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma makedep register
#include "windows.security.cryptography.idl"
@ stdcall -private DllCanUnloadNow()
@ stdcall -private DllGetActivationFactory(ptr ptr)
@ stdcall -private DllGetClassObject(ptr ptr ptr)
/*
* Copyright 2022 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <assert.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winstring.h"
#include "wine/debug.h"
#include "objbase.h"
#include "initguid.h"
#include "activation.h"
#define WIDL_using_Windows_Foundation
#define WIDL_using_Windows_Foundation_Collections
#include "windows.foundation.h"
#define WIDL_using_Windows_Storage_Streams
#include "windows.storage.streams.h"
#define WIDL_using_Windows_Security_Cryptography
#include "windows.security.cryptography.h"
WINE_DEFAULT_DEBUG_CHANNEL(crypto);
static const char *debugstr_hstring(HSTRING hstr)
{
const WCHAR *str;
UINT32 len;
if (hstr && !((ULONG_PTR)hstr >> 16)) return "(invalid)";
str = WindowsGetStringRawBuffer(hstr, &len);
return wine_dbgstr_wn(str, len);
}
struct cryptobuffer_factory
{
IActivationFactory IActivationFactory_iface;
ICryptographicBufferStatics ICryptographicBufferStatics_iface;
LONG refcount;
};
static inline struct cryptobuffer_factory *impl_from_IActivationFactory(IActivationFactory *iface)
{
return CONTAINING_RECORD(iface, struct cryptobuffer_factory, IActivationFactory_iface);
}
static inline struct cryptobuffer_factory *impl_from_ICryptographicBufferStatics(ICryptographicBufferStatics *iface)
{
return CONTAINING_RECORD(iface, struct cryptobuffer_factory, ICryptographicBufferStatics_iface);
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_factory_QueryInterface(
IActivationFactory *iface, REFIID iid, void **out)
{
struct cryptobuffer_factory *factory = impl_from_IActivationFactory(iface);
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
if (IsEqualGUID(iid, &IID_IUnknown) ||
IsEqualGUID(iid, &IID_IInspectable) ||
IsEqualGUID(iid, &IID_IAgileObject) ||
IsEqualGUID(iid, &IID_IActivationFactory))
{
IUnknown_AddRef(iface);
*out = &factory->IActivationFactory_iface;
return S_OK;
}
if (IsEqualGUID(iid, &IID_ICryptographicBufferStatics))
{
IUnknown_AddRef(iface);
*out = &factory->ICryptographicBufferStatics_iface;
return S_OK;
}
FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
*out = NULL;
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE cryptobuffer_factory_AddRef(IActivationFactory *iface)
{
struct cryptobuffer_factory *factory = impl_from_IActivationFactory(iface);
ULONG refcount = InterlockedIncrement(&factory->refcount);
TRACE("iface %p, refcount %lu.\n", iface, refcount);
return refcount;
}
static ULONG STDMETHODCALLTYPE cryptobuffer_factory_Release(IActivationFactory *iface)
{
struct cryptobuffer_factory *factory = impl_from_IActivationFactory(iface);
ULONG refcount = InterlockedDecrement(&factory->refcount);
TRACE("iface %p, refcount %lu.\n", iface, refcount);
return refcount;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_factory_GetIids(
IActivationFactory *iface, ULONG *iid_count, IID **iids)
{
FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_factory_GetRuntimeClassName(
IActivationFactory *iface, HSTRING *class_name)
{
FIXME("iface %p, class_name %p stub!\n", iface, class_name);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_factory_GetTrustLevel(
IActivationFactory *iface, TrustLevel *trust_level)
{
FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_factory_ActivateInstance(
IActivationFactory *iface, IInspectable **instance)
{
FIXME("iface %p, instance %p stub!\n", iface, instance);
return E_NOTIMPL;
}
static const struct IActivationFactoryVtbl cryptobuffer_factory_vtbl =
{
cryptobuffer_factory_QueryInterface,
cryptobuffer_factory_AddRef,
cryptobuffer_factory_Release,
/* IInspectable methods */
cryptobuffer_factory_GetIids,
cryptobuffer_factory_GetRuntimeClassName,
cryptobuffer_factory_GetTrustLevel,
/* IActivationFactory methods */
cryptobuffer_factory_ActivateInstance,
};
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_QueryInterface(
ICryptographicBufferStatics *iface, REFIID iid, void **object)
{
struct cryptobuffer_factory *factory = impl_from_ICryptographicBufferStatics(iface);
return IActivationFactory_QueryInterface(&factory->IActivationFactory_iface, iid, object);
}
static ULONG STDMETHODCALLTYPE cryptobuffer_statics_AddRef(ICryptographicBufferStatics *iface)
{
struct cryptobuffer_factory *factory = impl_from_ICryptographicBufferStatics(iface);
return IActivationFactory_AddRef(&factory->IActivationFactory_iface);
}
static ULONG STDMETHODCALLTYPE cryptobuffer_statics_Release(ICryptographicBufferStatics *iface)
{
struct cryptobuffer_factory *factory = impl_from_ICryptographicBufferStatics(iface);
return IActivationFactory_Release(&factory->IActivationFactory_iface);
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_GetIids(
ICryptographicBufferStatics *iface, ULONG *iid_count, IID **iids)
{
FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_GetRuntimeClassName(
ICryptographicBufferStatics *iface, HSTRING *class_name)
{
FIXME("iface %p, class_name %p stub!\n", iface, class_name);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_GetTrustLevel(
ICryptographicBufferStatics *iface, TrustLevel *trust_level)
{
FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_Compare(
ICryptographicBufferStatics *iface, IBuffer *object1, IBuffer *object2, boolean *is_equal)
{
FIXME("iface %p, object1 %p, object2 %p, is_equal %p stub!\n", iface, object1, object2, is_equal);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_GenerateRandom(
ICryptographicBufferStatics *iface, UINT32 length, IBuffer **buffer)
{
FIXME("iface %p, length %u, buffer %p stub!\n", iface, length, buffer);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_GenerateRandomNumber(
ICryptographicBufferStatics *iface, UINT32 *value)
{
FIXME("iface %p, value %p stub!\n", iface, value);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_CreateFromByteArray(
ICryptographicBufferStatics *iface, UINT32 value_size, BYTE *value, IBuffer **buffer)
{
FIXME("iface %p, value_size %u, value %p, buffer %p stub!\n", iface, value_size, value, buffer);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_CopyToByteArray(
ICryptographicBufferStatics *iface, IBuffer *buffer, UINT32 *value_size, BYTE **value)
{
FIXME("iface %p, buffer %p, value_size %p, value %p stub!\n", iface, buffer, value_size, value);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_DecodeFromHexString(
ICryptographicBufferStatics *iface, HSTRING value, IBuffer **buffer)
{
FIXME("iface %p, value %p, buffer %p stub!\n", iface, value, buffer);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_EncodeToHexString(
ICryptographicBufferStatics *iface, IBuffer *buffer, HSTRING *value)
{
FIXME("iface %p, buffer %p, value %p stub!\n", iface, buffer, value);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_DecodeFromBase64String(
ICryptographicBufferStatics *iface, HSTRING value, IBuffer **buffer)
{
FIXME("iface %p, value %p, buffer %p stub!\n", iface, value, buffer);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_EncodeToBase64String(
ICryptographicBufferStatics *iface, IBuffer *buffer, HSTRING *value)
{
FIXME("iface %p, buffer %p, value %p stub!\n", iface, buffer, value);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_ConvertStringToBinary(
ICryptographicBufferStatics *iface, HSTRING value, BinaryStringEncoding encoding,
IBuffer **buffer)
{
FIXME("iface %p, value %p, encoding %d, buffer %p stub!\n", iface, value, encoding, buffer);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_ConvertBinaryToString(
ICryptographicBufferStatics *iface, BinaryStringEncoding encoding, IBuffer *buffer, HSTRING *value)
{
FIXME("iface %p, encoding %d, buffer %p, value %p stub!\n", iface, encoding, buffer, value);
return E_NOTIMPL;
}
static const struct ICryptographicBufferStaticsVtbl cryptobuffer_statics_vtbl =
{
cryptobuffer_statics_QueryInterface,
cryptobuffer_statics_AddRef,
cryptobuffer_statics_Release,
/* IInspectable methods */
cryptobuffer_statics_GetIids,
cryptobuffer_statics_GetRuntimeClassName,
cryptobuffer_statics_GetTrustLevel,
/* ICryptographicBufferStatics methods */
cryptobuffer_statics_Compare,
cryptobuffer_statics_GenerateRandom,
cryptobuffer_statics_GenerateRandomNumber,
cryptobuffer_statics_CreateFromByteArray,
cryptobuffer_statics_CopyToByteArray,
cryptobuffer_statics_DecodeFromHexString,
cryptobuffer_statics_EncodeToHexString,
cryptobuffer_statics_DecodeFromBase64String,
cryptobuffer_statics_EncodeToBase64String,
cryptobuffer_statics_ConvertStringToBinary,
cryptobuffer_statics_ConvertBinaryToString,
};
static struct cryptobuffer_factory cryptobuffer_factory =
{
.IActivationFactory_iface.lpVtbl = &cryptobuffer_factory_vtbl,
.ICryptographicBufferStatics_iface.lpVtbl = &cryptobuffer_statics_vtbl,
.refcount = 1,
};
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **out)
{
FIXME("clsid %s, riid %s, out %p stub!\n", debugstr_guid(clsid), debugstr_guid(riid), out);
return CLASS_E_CLASSNOTAVAILABLE;
}
HRESULT WINAPI DllGetActivationFactory(HSTRING classid, IActivationFactory **factory)
{
const WCHAR *name = WindowsGetStringRawBuffer(classid, NULL);
TRACE("classid %s, factory %p.\n", debugstr_hstring(classid), factory);
*factory = NULL;
if (!wcscmp(name, RuntimeClass_Windows_Security_Cryptography_CryptographicBuffer))
{
*factory = &cryptobuffer_factory.IActivationFactory_iface;
IUnknown_AddRef(*factory);
}
if (*factory) return S_OK;
return CLASS_E_CLASSNOTAVAILABLE;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment