From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/cryptowinrt/main.c | 63 +++--------------------------- dlls/cryptowinrt/private.h | 78 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 58 deletions(-) create mode 100644 dlls/cryptowinrt/private.h
diff --git a/dlls/cryptowinrt/main.c b/dlls/cryptowinrt/main.c index 720b137e4a9..3fa8e318cdc 100644 --- a/dlls/cryptowinrt/main.c +++ b/dlls/cryptowinrt/main.c @@ -16,32 +16,22 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include <stdarg.h> +#include "initguid.h" +#include "private.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" - #include "bcrypt.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 char *debugstr_hstring(HSTRING hstr) { const WCHAR *str; UINT32 len; @@ -62,11 +52,6 @@ static inline struct cryptobuffer_factory *impl_from_IActivationFactory(IActivat 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) { @@ -157,45 +142,7 @@ static const struct IActivationFactoryVtbl cryptobuffer_factory_vtbl = 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; -} +DEFINE_IINSPECTABLE(cryptobuffer_statics, ICryptographicBufferStatics, struct cryptobuffer_factory, IActivationFactory_iface);
static HRESULT STDMETHODCALLTYPE cryptobuffer_statics_Compare( ICryptographicBufferStatics *iface, IBuffer *object1, IBuffer *object2, boolean *is_equal) diff --git a/dlls/cryptowinrt/private.h b/dlls/cryptowinrt/private.h new file mode 100644 index 00000000000..dcf07750dd5 --- /dev/null +++ b/dlls/cryptowinrt/private.h @@ -0,0 +1,78 @@ +/* CryptoWinRT Implementation + * + * Copyright (C) 2022 Mohamad Al-Jaf + * + * 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 + */ + +#ifndef __WINE_CRYPTOWINRT_PRIVATE_H +#define __WINE_CRYPTOWINRT_PRIVATE_H + +#include <stdarg.h> + +#define COBJMACROS +#include "windef.h" +#include "winbase.h" +#include "winstring.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" + +extern const char *debugstr_hstring( HSTRING hstr ); + +#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ + static inline impl_type *impl_from( iface_type *iface ) \ + { \ + return CONTAINING_RECORD( iface, impl_type, iface_mem ); \ + } \ + static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_QueryInterface( (IInspectable *)(expr), iid, out ); \ + } \ + static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_AddRef( (IInspectable *)(expr) ); \ + } \ + static ULONG WINAPI pfx##_Release( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_Release( (IInspectable *)(expr) ); \ + } \ + static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetIids( (IInspectable *)(expr), iid_count, iids ); \ + } \ + static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetRuntimeClassName( (IInspectable *)(expr), class_name ); \ + } \ + static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetTrustLevel( (IInspectable *)(expr), trust_level ); \ + } +#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, &impl->base_iface ) + +#endif