Module: wine Branch: stable Commit: 05164887585495ec47bd2af3da9868a9a13c1862 URL: https://gitlab.winehq.org/wine/wine/-/commit/05164887585495ec47bd2af3da9868a...
Author: Santino Mazza mazzasantino1206@gmail.com Date: Wed Feb 16 15:13:04 2022 +0100
ncrypt: Make NCryptOpenStorageProvider return a valid stub pointer.
Some applications crash when the storage provider is null.
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com Signed-off-by: Hans Leidekker hans@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit cf3517b7905eceda3fe73977604863c80c9d1193) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/ncrypt/main.c | 21 ++++++++++++++++++++- dlls/ncrypt/ncrypt_internal.h | 44 +++++++++++++++++++++++++++++++++++++++++++ dlls/ncrypt/tests/ncrypt.c | 2 -- 3 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index f23b239d93f..44cfe781e7c 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -19,10 +19,12 @@ */
#include <stdarg.h> +#include <stdlib.h>
#include "windef.h" #include "winbase.h" #include "ncrypt.h" +#include "ncrypt_internal.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ncrypt); @@ -99,6 +101,14 @@ SECURITY_STATUS WINAPI NCryptGetProperty(NCRYPT_HANDLE object, const WCHAR *prop return NTE_NOT_SUPPORTED; }
+static struct object *allocate_object(enum object_type type) +{ + struct object *ret; + if (!(ret = calloc(1, sizeof(*ret)))) return NULL; + ret->type = type; + return ret; +} + SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_HANDLE decrypt_key, const WCHAR *type, NCryptBufferDesc *params, NCRYPT_KEY_HANDLE *key, PBYTE data, DWORD datasize, DWORD flags) @@ -131,8 +141,17 @@ SECURITY_STATUS WINAPI NCryptOpenKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_HAN
SECURITY_STATUS WINAPI NCryptOpenStorageProvider(NCRYPT_PROV_HANDLE *provider, const WCHAR *name, DWORD flags) { + struct object *object; + FIXME("(%p, %s, %u): stub\n", provider, wine_dbgstr_w(name), flags); - return NTE_NOT_SUPPORTED; + + if (!(object = allocate_object(STORAGE_PROVIDER))) + { + ERR("Error allocating memory.\n"); + return NTE_NO_MEMORY; + } + *provider = (NCRYPT_PROV_HANDLE)object; + return ERROR_SUCCESS; }
SECURITY_STATUS WINAPI NCryptSetProperty(NCRYPT_HANDLE object, const WCHAR *property, diff --git a/dlls/ncrypt/ncrypt_internal.h b/dlls/ncrypt/ncrypt_internal.h new file mode 100644 index 00000000000..7a2d96f8417 --- /dev/null +++ b/dlls/ncrypt/ncrypt_internal.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 Santino Mazza + * + * 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 + */ + +struct storage_provider +{ +}; + +enum object_type +{ + STORAGE_PROVIDER, +}; + +struct object_property +{ + WCHAR *key; + DWORD value_size; + void *value; +}; + +struct object +{ + enum object_type type; + DWORD num_properties; + struct object_property *properties; + union + { + struct storage_provider storage_provider; + }; +}; diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index 31c07f2dac7..336e53f7ff2 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -92,12 +92,10 @@ static void test_key_import_rsa(void) NCRYPT_KEY_HANDLE key; SECURITY_STATUS ret;
- todo_wine { prov = 0; ret = NCryptOpenStorageProvider(&prov, NULL, 0); ok(ret == ERROR_SUCCESS, "got %#x\n", ret); ok(prov, "got null handle\n"); - }
todo_wine { key = 0;