Wine-devel
Threads by month
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
May 2021
- 86 participants
- 705 discussions
07 May '21
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
For Red Dead Redemption 2.
v2:
- store hwnd in struct wine_vk_surface instead of a dedicated flag.
v3:
- create_dummy_client_window() function name in comment;
- formatting.
dlls/vulkan-1/tests/vulkan.c | 112 ++++++++++++++++++++++++++++++++++-
dlls/winex11.drv/vulkan.c | 38 +++++++++---
dlls/winex11.drv/window.c | 18 ++++++
dlls/winex11.drv/x11drv.h | 1 +
4 files changed, 158 insertions(+), 11 deletions(-)
diff --git a/dlls/vulkan-1/tests/vulkan.c b/dlls/vulkan-1/tests/vulkan.c
index 9061b2b6db8..e516d0d61c8 100644
--- a/dlls/vulkan-1/tests/vulkan.c
+++ b/dlls/vulkan-1/tests/vulkan.c
@@ -437,7 +437,102 @@ static void test_private_data(VkPhysicalDevice vk_physical_device)
vkDestroyDevice(vk_device, NULL);
}
-static void for_each_device(void (*test_func)(VkPhysicalDevice))
+static const char *test_null_hwnd_extensions[] =
+{
+ "VK_KHR_surface",
+ "VK_KHR_win32_surface",
+};
+
+static void test_null_hwnd(VkInstance vk_instance, VkPhysicalDevice vk_physical_device)
+{
+ PFN_vkGetPhysicalDeviceSurfacePresentModesKHR pvkGetPhysicalDeviceSurfacePresentModesKHR;
+ VkDeviceGroupPresentModeFlagsKHR present_mode_flags;
+ VkWin32SurfaceCreateInfoKHR surface_create_info;
+ VkSurfaceCapabilitiesKHR surf_caps;
+ VkSurfaceFormatKHR *formats;
+ uint32_t queue_family_index;
+ VkPresentModeKHR *modes;
+ VkSurfaceKHR surface;
+ VkDevice vk_device;
+ uint32_t count;
+ VkRect2D rect;
+ VkBool32 bval;
+ VkResult vr;
+
+ pvkGetPhysicalDeviceSurfacePresentModesKHR = (void *)vkGetInstanceProcAddr(vk_instance,
+ "vkGetPhysicalDeviceSurfacePresentModesKHR");
+ surface_create_info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
+ surface_create_info.pNext = NULL;
+ surface_create_info.flags = 0;
+ surface_create_info.hinstance = NULL;
+ surface_create_info.hwnd = NULL;
+
+ bval = find_queue_family(vk_physical_device, VK_QUEUE_GRAPHICS_BIT, &queue_family_index);
+ ok(bval, "Could not find presentation queue.\n");
+
+ surface = 0xdeadbeef;
+ vr = vkCreateWin32SurfaceKHR(vk_instance, &surface_create_info, NULL, &surface);
+ ok(vr == VK_SUCCESS, "Got unexpected vr %d.\n", vr);
+ ok(surface != 0xdeadbeef, "Surface not created.\n");
+
+ count = 0;
+ vr = vkGetPhysicalDeviceSurfaceFormatsKHR(vk_physical_device, surface, &count, NULL);
+ ok(vr == VK_SUCCESS, "Got unexpected vr %d.\n", vr);
+ ok(count, "Got zero count.\n");
+ formats = heap_alloc(sizeof(*formats) * count);
+ vr = vkGetPhysicalDeviceSurfaceFormatsKHR(vk_physical_device, surface, &count, formats);
+ ok(vr == VK_SUCCESS, "Got unexpected vr %d.\n", vr);
+ heap_free(formats);
+
+ vr = vkGetPhysicalDeviceSurfaceSupportKHR(vk_physical_device, queue_family_index, surface, &bval);
+ ok(vr == VK_SUCCESS, "Got unexpected vr %d.\n", vr);
+
+ vr = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(vk_physical_device, surface, &surf_caps);
+ ok(vr, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR succeeded.\n");
+
+ count = 0;
+ vr = pvkGetPhysicalDeviceSurfacePresentModesKHR(vk_physical_device, surface, &count, NULL);
+ ok(vr == VK_SUCCESS, "Got unexpected vr %d.\n", vr);
+ ok(count, "Got zero count.\n");
+ modes = heap_alloc(sizeof(*modes) * count);
+ vr = pvkGetPhysicalDeviceSurfacePresentModesKHR(vk_physical_device, surface, &count, modes);
+ ok(vr == VK_SUCCESS, "Got unexpected vr %d.\n", vr);
+ heap_free(modes);
+
+ count = 0;
+ vr = vkGetPhysicalDevicePresentRectanglesKHR(vk_physical_device, surface, &count, NULL);
+ ok(vr == VK_SUCCESS, "Got unexpected vr %d.\n", vr);
+ ok(count == 1, "Got unexpected count %u.\n", count);
+ memset(&rect, 0xcc, sizeof(rect));
+ vr = vkGetPhysicalDevicePresentRectanglesKHR(vk_physical_device, surface, &count, &rect);
+ if (vr == VK_SUCCESS) /* Fails on AMD, succeeds on Nvidia. */
+ {
+ ok(count == 1, "Got unexpected count %u.\n", count);
+ ok(!rect.offset.x && !rect.offset.y && !rect.extent.width && !rect.extent.height,
+ "Got unexpected rect %d, %d, %u, %u.\n",
+ rect.offset.x, rect.offset.y, rect.extent.width, rect.extent.height);
+ }
+
+ if ((vr = create_device(vk_physical_device, 0, NULL, NULL, &vk_device)) < 0)
+ {
+ skip("Failed to create device, vr %d.\n", vr);
+ vkDestroySurfaceKHR(vk_instance, surface, NULL);
+ return;
+ }
+
+ if (0)
+ {
+ /* Causes access violation on Windows. */
+ vr = vkGetDeviceGroupSurfacePresentModesKHR(vk_device, surface, &present_mode_flags);
+ ok(vr == VK_SUCCESS, "Got unexpected vr %d.\n", vr);
+ }
+
+ vkDestroyDevice(vk_device, NULL);
+ vkDestroySurfaceKHR(vk_instance, surface, NULL);
+}
+
+static void for_each_device_instance(uint32_t extension_count, const char * const *enabled_extensions,
+ void (*test_func_instance)(VkInstance, VkPhysicalDevice), void (*test_func)(VkPhysicalDevice))
{
VkPhysicalDevice *vk_physical_devices;
VkInstance vk_instance;
@@ -445,7 +540,7 @@ static void for_each_device(void (*test_func)(VkPhysicalDevice))
uint32_t count;
VkResult vr;
- if ((vr = create_instance_skip(0, NULL, &vk_instance)) < 0)
+ if ((vr = create_instance_skip(extension_count, enabled_extensions, &vk_instance)) < 0)
return;
ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr);
@@ -463,13 +558,23 @@ static void for_each_device(void (*test_func)(VkPhysicalDevice))
ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr);
for (i = 0; i < count; ++i)
- test_func(vk_physical_devices[i]);
+ {
+ if (test_func_instance)
+ test_func_instance(vk_instance, vk_physical_devices[i]);
+ else
+ test_func(vk_physical_devices[i]);
+ }
heap_free(vk_physical_devices);
vkDestroyInstance(vk_instance, NULL);
}
+static void for_each_device(void (*test_func)(VkPhysicalDevice))
+{
+ for_each_device_instance(0, NULL, NULL, test_func);
+}
+
START_TEST(vulkan)
{
test_instance_version();
@@ -481,4 +586,5 @@ START_TEST(vulkan)
test_unsupported_instance_extensions();
for_each_device(test_unsupported_device_extensions);
for_each_device(test_private_data);
+ for_each_device_instance(ARRAY_SIZE(test_null_hwnd_extensions), test_null_hwnd_extensions, test_null_hwnd, NULL);
}
diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c
index 139faf6b407..bdc287afeea 100644
--- a/dlls/winex11.drv/vulkan.c
+++ b/dlls/winex11.drv/vulkan.c
@@ -62,6 +62,7 @@ struct wine_vk_surface
LONG ref;
Window window;
VkSurfaceKHR surface; /* native surface */
+ HWND hwnd;
};
typedef struct VkXlibSurfaceCreateInfoKHR
@@ -255,14 +256,18 @@ static VkResult X11DRV_vkCreateSwapchainKHR(VkDevice device,
const VkSwapchainCreateInfoKHR *create_info,
const VkAllocationCallbacks *allocator, VkSwapchainKHR *swapchain)
{
+ struct wine_vk_surface *x11_surface = surface_from_handle(create_info->surface);
VkSwapchainCreateInfoKHR create_info_host;
TRACE("%p %p %p %p\n", device, create_info, allocator, swapchain);
if (allocator)
FIXME("Support for allocation callbacks not implemented yet\n");
+ if (!x11_surface->hwnd)
+ return VK_ERROR_SURFACE_LOST_KHR;
+
create_info_host = *create_info;
- create_info_host.surface = surface_from_handle(create_info->surface)->surface;
+ create_info_host.surface = x11_surface->surface;
return pvkCreateSwapchainKHR(device, &create_info_host, NULL /* allocator */, swapchain);
}
@@ -281,7 +286,7 @@ static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance,
FIXME("Support for allocation callbacks not implemented yet\n");
/* TODO: support child window rendering. */
- if (GetAncestor(create_info->hwnd, GA_PARENT) != GetDesktopWindow())
+ if (create_info->hwnd && GetAncestor(create_info->hwnd, GA_PARENT) != GetDesktopWindow())
{
FIXME("Application requires child window rendering, which is not implemented yet!\n");
return VK_ERROR_INCOMPATIBLE_DRIVER;
@@ -292,8 +297,10 @@ static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance,
return VK_ERROR_OUT_OF_HOST_MEMORY;
x11_surface->ref = 1;
+ x11_surface->hwnd = create_info->hwnd;
+ x11_surface->window = x11_surface->hwnd ? create_client_window(create_info->hwnd, &default_visual)
+ : create_dummy_client_window();
- x11_surface->window = create_client_window(create_info->hwnd, &default_visual);
if (!x11_surface->window)
{
ERR("Failed to allocate client window for hwnd=%p\n", create_info->hwnd);
@@ -316,13 +323,16 @@ static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance,
goto err;
}
- EnterCriticalSection(&context_section);
- if (!XFindContext(gdi_display, (XID)create_info->hwnd, vulkan_hwnd_context, (char **)&prev))
+ if (x11_surface->hwnd)
{
- wine_vk_surface_release(prev);
+ EnterCriticalSection(&context_section);
+ if (!XFindContext(gdi_display, (XID)create_info->hwnd, vulkan_hwnd_context, (char **)&prev))
+ {
+ wine_vk_surface_release(prev);
+ }
+ XSaveContext(gdi_display, (XID)create_info->hwnd, vulkan_hwnd_context, (char *)wine_vk_surface_grab(x11_surface));
+ LeaveCriticalSection(&context_section);
}
- XSaveContext(gdi_display, (XID)create_info->hwnd, vulkan_hwnd_context, (char *)wine_vk_surface_grab(x11_surface));
- LeaveCriticalSection(&context_section);
*surface = (uintptr_t)x11_surface;
@@ -456,6 +466,15 @@ static VkResult X11DRV_vkGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice
TRACE("%p, 0x%s, %p, %p\n", phys_dev, wine_dbgstr_longlong(surface), count, rects);
+ if (!x11_surface->hwnd)
+ {
+ if (rects)
+ return VK_ERROR_SURFACE_LOST_KHR;
+
+ *count = 1;
+ return VK_SUCCESS;
+ }
+
return pvkGetPhysicalDevicePresentRectanglesKHR(phys_dev, x11_surface->surface, count, rects);
}
@@ -485,6 +504,9 @@ static VkResult X11DRV_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevic
TRACE("%p, 0x%s, %p\n", phys_dev, wine_dbgstr_longlong(surface), capabilities);
+ if (!x11_surface->hwnd)
+ return VK_ERROR_SURFACE_LOST_KHR;
+
return pvkGetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev, x11_surface->surface, capabilities);
}
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index baaa30d74e3..b3ae5c54408 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -1466,6 +1466,24 @@ static Window get_dummy_parent(void)
}
+/**********************************************************************
+ * create_dummy_client_window
+ */
+Window create_dummy_client_window(void)
+{
+ XSetWindowAttributes attr;
+
+ attr.colormap = default_colormap;
+ attr.bit_gravity = NorthWestGravity;
+ attr.win_gravity = NorthWestGravity;
+ attr.backing_store = NotUseful;
+ attr.border_pixel = 0;
+
+ return XCreateWindow( gdi_display, get_dummy_parent(), 0, 0, 1, 1, 0,
+ default_visual.depth, InputOutput, default_visual.visual,
+ CWBitGravity | CWWinGravity | CWBackingStore | CWColormap | CWBorderPixel, &attr );
+}
+
/**********************************************************************
* create_client_window
*/
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 45855976607..2362dfd9563 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -601,6 +601,7 @@ extern void update_user_time( Time time ) DECLSPEC_HIDDEN;
extern void read_net_wm_states( Display *display, struct x11drv_win_data *data ) DECLSPEC_HIDDEN;
extern void update_net_wm_states( struct x11drv_win_data *data ) DECLSPEC_HIDDEN;
extern void make_window_embedded( struct x11drv_win_data *data ) DECLSPEC_HIDDEN;
+extern Window create_dummy_client_window(void) DECLSPEC_HIDDEN;
extern Window create_client_window( HWND hwnd, const XVisualInfo *visual ) DECLSPEC_HIDDEN;
extern void set_window_visual( struct x11drv_win_data *data, const XVisualInfo *vis, BOOL use_alpha ) DECLSPEC_HIDDEN;
extern void change_systray_owner( Display *display, Window systray_window ) DECLSPEC_HIDDEN;
--
2.31.1
3
5
[PATCH v2 1/2] mfreadwrite/tests: Test setting a non-native bit depth on the reader.
by Giovanni Mascellani 07 May '21
by Giovanni Mascellani 07 May '21
07 May '21
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
dlls/mfreadwrite/tests/mfplat.c | 52 +++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c
index 8ea4e5038f6..8381e535d26 100644
--- a/dlls/mfreadwrite/tests/mfplat.c
+++ b/dlls/mfreadwrite/tests/mfplat.c
@@ -362,6 +362,8 @@ static HRESULT WINAPI test_source_CreatePresentationDescriptor(IMFMediaSource *i
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, 32);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = MFCreateStreamDescriptor(i, 1, &media_type, &sds[i]);
ok(hr == S_OK, "Failed to create stream descriptor, hr %#x.\n", hr);
@@ -897,6 +899,7 @@ static void test_source_reader_from_media_source(void)
struct async_callback *callback;
IMFSourceReader *reader;
IMFMediaSource *source;
+ IMFMediaType *media_type;
HRESULT hr;
DWORD actual_index, stream_flags;
IMFSample *sample;
@@ -1042,6 +1045,55 @@ static void test_source_reader_from_media_source(void)
IMFSourceReader_Release(reader);
IMFMediaSource_Release(source);
+ /* Request a non-native bit depth. */
+ source = create_test_source(1);
+ ok(!!source, "Failed to create test source.\n");
+
+ hr = MFCreateSourceReaderFromMediaSource(source, NULL, &reader);
+ ok(hr == S_OK, "Failed to create source reader, hr %#x.\n", hr);
+
+ hr = MFCreateMediaType(&media_type);
+ ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, 16);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+
+ hr = IMFSourceReader_SetCurrentMediaType(reader, 0, NULL, media_type);
+todo_wine
+ ok(hr == MF_E_TOPO_CODEC_NOT_FOUND, "Unexpected success setting current media type, hr %#x.\n", hr);
+
+ IMFMediaType_Release(media_type);
+
+ hr = MFCreateMediaType(&media_type);
+ ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, 32);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+
+ hr = IMFSourceReader_SetCurrentMediaType(reader, 0, NULL, media_type);
+ ok(hr == S_OK, "Failed to set current media type, hr %#x.\n", hr);
+
+ hr = IMFSourceReader_SetStreamSelection(reader, 0, TRUE);
+ ok(hr == S_OK, "Failed to select a stream, hr %#x.\n", hr);
+
+ hr = IMFSourceReader_ReadSample(reader, 0, 0, &actual_index, &stream_flags, ×tamp, &sample);
+ ok(hr == S_OK, "Failed to get a sample, hr %#x.\n", hr);
+ ok(actual_index == 0, "Unexpected stream index %u\n", actual_index);
+ ok(!stream_flags, "Unexpected stream flags %#x.\n", stream_flags);
+ ok(timestamp == 123, "Unexpected timestamp.\n");
+ ok(!!sample, "Expected sample object.\n");
+ IMFSample_Release(sample);
+
+ IMFMediaType_Release(media_type);
+ IMFSourceReader_Release(reader);
+ IMFMediaSource_Release(source);
+
/* Async mode. */
source = create_test_source(3);
ok(!!source, "Failed to create test source.\n");
--
2.31.1
2
3
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/mfplat/mediatype.c | 27 +++++++++++++++++++++++++++
dlls/mfplat/mfplat.spec | 2 +-
include/mfapi.h | 1 +
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c
index fb90053c605..92d219f26e1 100644
--- a/dlls/mfplat/mediatype.c
+++ b/dlls/mfplat/mediatype.c
@@ -3063,6 +3063,33 @@ HRESULT WINAPI MFCreateVideoMediaTypeFromSubtype(const GUID *subtype, IMFVideoMe
return S_OK;
}
+/***********************************************************************
+ * MFCreateAudioMediaType (mfplat.@)
+ */
+HRESULT WINAPI MFCreateAudioMediaType(const WAVEFORMATEX *format, IMFAudioMediaType **media_type)
+{
+ struct media_type *object;
+ HRESULT hr;
+
+ TRACE("%p, %p.\n", format, media_type);
+
+ if (!media_type)
+ return E_INVALIDARG;
+
+ if (FAILED(hr = create_media_type(&object)))
+ return hr;
+
+ if (FAILED(hr = MFInitMediaTypeFromWaveFormatEx(&object->IMFMediaType_iface, format, sizeof(*format) + format->cbSize)))
+ {
+ IMFMediaType_Release(&object->IMFMediaType_iface);
+ return hr;
+ }
+
+ *media_type = &object->IMFAudioMediaType_iface;
+
+ return S_OK;
+}
+
static void media_type_get_ratio(IMFMediaType *media_type, const GUID *attr, UINT32 *numerator,
UINT32 *denominator)
{
diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec
index e8dc01c200c..9a78c2fb0bc 100644
--- a/dlls/mfplat/mfplat.spec
+++ b/dlls/mfplat/mfplat.spec
@@ -43,7 +43,7 @@
@ stdcall MFCreateAlignedMemoryBuffer(long long ptr)
@ stdcall MFCreateAsyncResult(ptr ptr ptr ptr) rtworkq.RtwqCreateAsyncResult
@ stdcall MFCreateAttributes(ptr long)
-@ stub MFCreateAudioMediaType
+@ stdcall MFCreateAudioMediaType(ptr ptr)
@ stdcall MFCreateCollection(ptr)
@ stdcall MFCreateDXGIDeviceManager(ptr ptr)
@ stdcall MFCreateDXGISurfaceBuffer(ptr ptr long long ptr)
diff --git a/include/mfapi.h b/include/mfapi.h
index 986f5b9e3e4..2ac70793d7a 100644
--- a/include/mfapi.h
+++ b/include/mfapi.h
@@ -508,6 +508,7 @@ HRESULT WINAPI MFCreate2DMediaBuffer(DWORD width, DWORD height, DWORD fourcc, BO
HRESULT WINAPI MFCreateAlignedMemoryBuffer(DWORD max_length, DWORD alignment, IMFMediaBuffer **buffer);
HRESULT WINAPI MFCreateAttributes(IMFAttributes **attributes, UINT32 size);
HRESULT WINAPI MFCreateAsyncResult(IUnknown *object, IMFAsyncCallback *callback, IUnknown *state, IMFAsyncResult **result);
+HRESULT WINAPI MFCreateAudioMediaType(const WAVEFORMATEX *audioformat, IMFAudioMediaType **mediatype);
HRESULT WINAPI MFCreateCollection(IMFCollection **collection);
HRESULT WINAPI MFCreateDXGIDeviceManager(UINT *token, IMFDXGIDeviceManager **manager);
HRESULT WINAPI MFCreateDXGISurfaceBuffer(REFIID riid, IUnknown *surface, UINT subresource, BOOL bottomup,
--
2.30.2
1
0
[PATCH 1/2] mfreadwrite/tests: Test setting a non-native bit depth on the reader.
by Giovanni Mascellani 07 May '21
by Giovanni Mascellani 07 May '21
07 May '21
---
dlls/mfreadwrite/tests/mfplat.c | 52 +++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c
index 8ea4e5038f6..8381e535d26 100644
--- a/dlls/mfreadwrite/tests/mfplat.c
+++ b/dlls/mfreadwrite/tests/mfplat.c
@@ -362,6 +362,8 @@ static HRESULT WINAPI test_source_CreatePresentationDescriptor(IMFMediaSource *i
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, 32);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = MFCreateStreamDescriptor(i, 1, &media_type, &sds[i]);
ok(hr == S_OK, "Failed to create stream descriptor, hr %#x.\n", hr);
@@ -897,6 +899,7 @@ static void test_source_reader_from_media_source(void)
struct async_callback *callback;
IMFSourceReader *reader;
IMFMediaSource *source;
+ IMFMediaType *media_type;
HRESULT hr;
DWORD actual_index, stream_flags;
IMFSample *sample;
@@ -1042,6 +1045,55 @@ static void test_source_reader_from_media_source(void)
IMFSourceReader_Release(reader);
IMFMediaSource_Release(source);
+ /* Request a non-native bit depth. */
+ source = create_test_source(1);
+ ok(!!source, "Failed to create test source.\n");
+
+ hr = MFCreateSourceReaderFromMediaSource(source, NULL, &reader);
+ ok(hr == S_OK, "Failed to create source reader, hr %#x.\n", hr);
+
+ hr = MFCreateMediaType(&media_type);
+ ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, 16);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+
+ hr = IMFSourceReader_SetCurrentMediaType(reader, 0, NULL, media_type);
+todo_wine
+ ok(hr == MF_E_TOPO_CODEC_NOT_FOUND, "Unexpected success setting current media type, hr %#x.\n", hr);
+
+ IMFMediaType_Release(media_type);
+
+ hr = MFCreateMediaType(&media_type);
+ ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, 32);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+
+ hr = IMFSourceReader_SetCurrentMediaType(reader, 0, NULL, media_type);
+ ok(hr == S_OK, "Failed to set current media type, hr %#x.\n", hr);
+
+ hr = IMFSourceReader_SetStreamSelection(reader, 0, TRUE);
+ ok(hr == S_OK, "Failed to select a stream, hr %#x.\n", hr);
+
+ hr = IMFSourceReader_ReadSample(reader, 0, 0, &actual_index, &stream_flags, ×tamp, &sample);
+ ok(hr == S_OK, "Failed to get a sample, hr %#x.\n", hr);
+ ok(actual_index == 0, "Unexpected stream index %u\n", actual_index);
+ ok(!stream_flags, "Unexpected stream flags %#x.\n", stream_flags);
+ ok(timestamp == 123, "Unexpected timestamp.\n");
+ ok(!!sample, "Expected sample object.\n");
+ IMFSample_Release(sample);
+
+ IMFMediaType_Release(media_type);
+ IMFSourceReader_Release(reader);
+ IMFMediaSource_Release(source);
+
/* Async mode. */
source = create_test_source(3);
ok(!!source, "Failed to create test source.\n");
--
2.31.0
2
5
[PATCH] vulkan-1/tests: Consider vkGetPhysicalDevicePresentRectanglesKHR absense in test_null_hwnd().
by Paul Gofman 07 May '21
by Paul Gofman 07 May '21
07 May '21
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
dlls/vulkan-1/tests/vulkan.c | 45 ++++++++++++++++++++++++------------
1 file changed, 30 insertions(+), 15 deletions(-)
diff --git a/dlls/vulkan-1/tests/vulkan.c b/dlls/vulkan-1/tests/vulkan.c
index e516d0d61c8..1d23c4112cf 100644
--- a/dlls/vulkan-1/tests/vulkan.c
+++ b/dlls/vulkan-1/tests/vulkan.c
@@ -441,11 +441,13 @@ static const char *test_null_hwnd_extensions[] =
{
"VK_KHR_surface",
"VK_KHR_win32_surface",
+ "VK_KHR_device_group_creation",
};
static void test_null_hwnd(VkInstance vk_instance, VkPhysicalDevice vk_physical_device)
{
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR pvkGetPhysicalDeviceSurfacePresentModesKHR;
+ PFN_vkGetPhysicalDevicePresentRectanglesKHR pvkGetPhysicalDevicePresentRectanglesKHR;
VkDeviceGroupPresentModeFlagsKHR present_mode_flags;
VkWin32SurfaceCreateInfoKHR surface_create_info;
VkSurfaceCapabilitiesKHR surf_caps;
@@ -461,6 +463,9 @@ static void test_null_hwnd(VkInstance vk_instance, VkPhysicalDevice vk_physical_
pvkGetPhysicalDeviceSurfacePresentModesKHR = (void *)vkGetInstanceProcAddr(vk_instance,
"vkGetPhysicalDeviceSurfacePresentModesKHR");
+ pvkGetPhysicalDevicePresentRectanglesKHR = (void *)vkGetInstanceProcAddr(vk_instance,
+ "vkGetPhysicalDevicePresentRectanglesKHR");
+
surface_create_info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
surface_create_info.pNext = NULL;
surface_create_info.flags = 0;
@@ -499,25 +504,35 @@ static void test_null_hwnd(VkInstance vk_instance, VkPhysicalDevice vk_physical_
ok(vr == VK_SUCCESS, "Got unexpected vr %d.\n", vr);
heap_free(modes);
- count = 0;
- vr = vkGetPhysicalDevicePresentRectanglesKHR(vk_physical_device, surface, &count, NULL);
- ok(vr == VK_SUCCESS, "Got unexpected vr %d.\n", vr);
- ok(count == 1, "Got unexpected count %u.\n", count);
- memset(&rect, 0xcc, sizeof(rect));
- vr = vkGetPhysicalDevicePresentRectanglesKHR(vk_physical_device, surface, &count, &rect);
- if (vr == VK_SUCCESS) /* Fails on AMD, succeeds on Nvidia. */
+ if (pvkGetPhysicalDevicePresentRectanglesKHR)
{
+ count = 0;
+ vr = pvkGetPhysicalDevicePresentRectanglesKHR(vk_physical_device, surface, &count, NULL);
+ ok(vr == VK_SUCCESS, "Got unexpected vr %d.\n", vr);
ok(count == 1, "Got unexpected count %u.\n", count);
- ok(!rect.offset.x && !rect.offset.y && !rect.extent.width && !rect.extent.height,
- "Got unexpected rect %d, %d, %u, %u.\n",
- rect.offset.x, rect.offset.y, rect.extent.width, rect.extent.height);
- }
+ memset(&rect, 0xcc, sizeof(rect));
+ vr = pvkGetPhysicalDevicePresentRectanglesKHR(vk_physical_device, surface, &count, &rect);
+ if (vr == VK_SUCCESS) /* Fails on AMD, succeeds on Nvidia. */
+ {
+ ok(count == 1, "Got unexpected count %u.\n", count);
+ ok(!rect.offset.x && !rect.offset.y && !rect.extent.width && !rect.extent.height,
+ "Got unexpected rect %d, %d, %u, %u.\n",
+ rect.offset.x, rect.offset.y, rect.extent.width, rect.extent.height);
+ }
- if ((vr = create_device(vk_physical_device, 0, NULL, NULL, &vk_device)) < 0)
+ if ((vr = create_device(vk_physical_device, 0, NULL, NULL, &vk_device)) < 0)
+ {
+ skip("Failed to create device, vr %d.\n", vr);
+ vkDestroySurfaceKHR(vk_instance, surface, NULL);
+ return;
+ }
+ }
+ else
{
- skip("Failed to create device, vr %d.\n", vr);
- vkDestroySurfaceKHR(vk_instance, surface, NULL);
- return;
+ /* The function should be available in practice with VK_KHR_device_group_creation, but spec lists
+ * it as a part of VK_KHR_device_group device extension which we don't check, so consider the
+ * absence of the function. */
+ win_skip("pvkGetPhysicalDevicePresentRectanglesKHR is no available.\n");
}
if (0)
--
2.31.1
1
0
07 May '21
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/secur32/schannel.c | 252 ++++++++++++++++++-------
dlls/secur32/schannel_gnutls.c | 323 +++++++++++++--------------------
dlls/secur32/schannel_macosx.c | 210 ++++++++++++---------
dlls/secur32/secur32.c | 3 +
dlls/secur32/secur32_priv.h | 81 +++++----
5 files changed, 477 insertions(+), 392 deletions(-)
diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c
index 1dd3a029401..5f6b96903c4 100644
--- a/dlls/secur32/schannel.c
+++ b/dlls/secur32/schannel.c
@@ -17,9 +17,8 @@
*
* This file implements the schannel provider, or, the SSL/TLS implementations.
*/
-#include "config.h"
-#include "wine/port.h"
+#include <assert.h>
#include <stdarg.h>
#include <errno.h>
@@ -28,6 +27,7 @@
#include "winbase.h"
#include "winreg.h"
#include "winnls.h"
+#include "lmcons.h"
#include "sspi.h"
#include "schannel.h"
#include "secur32_priv.h"
@@ -37,7 +37,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
-#if defined(SONAME_LIBGNUTLS) || defined (HAVE_SECURITY_SECURITY_H)
+const struct schan_funcs *schan_funcs = NULL;
#define SCHAN_INVALID_HANDLE ~0UL
@@ -56,7 +56,7 @@ struct schan_handle
struct schan_context
{
- schan_imp_session session;
+ schan_session session;
struct schan_transport transport;
ULONG req_ctx_attr;
const CERT_CONTEXT *cert;
@@ -242,7 +242,7 @@ static void read_config(void)
RegCloseKey(protocols_key);
- config_enabled_protocols = enabled & schan_imp_enabled_protocols();
+ config_enabled_protocols = enabled & schan_funcs->get_enabled_protocols();
config_default_disabled_protocols = default_disabled;
config_read = TRUE;
@@ -389,6 +389,116 @@ static SECURITY_STATUS get_cert(const SCHANNEL_CRED *cred, CERT_CONTEXT const **
return status;
}
+static WCHAR *get_key_container_path(const CERT_CONTEXT *ctx)
+{
+ static const WCHAR rsabaseW[] =
+ {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\','C','r','y','p','t','o','\\','R','S','A','\\',0};
+ CERT_KEY_CONTEXT keyctx;
+ DWORD size = sizeof(keyctx), prov_size = 0;
+ CRYPT_KEY_PROV_INFO *prov;
+ WCHAR username[UNLEN + 1], *ret = NULL;
+ DWORD len = ARRAY_SIZE(username);
+
+ if (CertGetCertificateContextProperty(ctx, CERT_KEY_CONTEXT_PROP_ID, &keyctx, &size))
+ {
+ char *str;
+ if (!CryptGetProvParam(keyctx.hCryptProv, PP_CONTAINER, NULL, &size, 0)) return NULL;
+ if (!(str = RtlAllocateHeap(GetProcessHeap(), 0, size))) return NULL;
+ if (!CryptGetProvParam(keyctx.hCryptProv, PP_CONTAINER, (BYTE *)str, &size, 0)) return NULL;
+
+ len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+ if (!(ret = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(rsabaseW) + len * sizeof(WCHAR))))
+ {
+ RtlFreeHeap(GetProcessHeap(), 0, str);
+ return NULL;
+ }
+ strcpyW(ret, rsabaseW);
+ MultiByteToWideChar(CP_ACP, 0, str, -1, ret + strlenW(ret), len);
+ RtlFreeHeap(GetProcessHeap(), 0, str);
+ }
+ else if (CertGetCertificateContextProperty(ctx, CERT_KEY_PROV_INFO_PROP_ID, NULL, &prov_size))
+ {
+ if (!(prov = RtlAllocateHeap(GetProcessHeap(), 0, prov_size))) return NULL;
+ if (!CertGetCertificateContextProperty(ctx, CERT_KEY_PROV_INFO_PROP_ID, prov, &prov_size))
+ {
+ RtlFreeHeap(GetProcessHeap(), 0, prov);
+ return NULL;
+ }
+ if (!(ret = RtlAllocateHeap(GetProcessHeap(), 0,
+ sizeof(rsabaseW) + strlenW(prov->pwszContainerName) * sizeof(WCHAR))))
+ {
+ RtlFreeHeap(GetProcessHeap(), 0, prov);
+ return NULL;
+ }
+ strcpyW(ret, rsabaseW);
+ strcatW(ret, prov->pwszContainerName);
+ RtlFreeHeap(GetProcessHeap(), 0, prov);
+ }
+
+ if (!ret && GetUserNameW(username, &len) && (ret = RtlAllocateHeap(GetProcessHeap(), 0,
+ sizeof(rsabaseW) + len * sizeof(WCHAR))))
+ {
+ strcpyW(ret, rsabaseW);
+ strcatW(ret, username);
+ }
+
+ return ret;
+}
+
+#define MAX_LEAD_BYTES 8
+static BYTE *get_key_blob(const CERT_CONTEXT *ctx, DWORD *size)
+{
+ static const WCHAR keyexchangeW[] =
+ {'K','e','y','E','x','c','h','a','n','g','e','K','e','y','P','a','i','r',0};
+ static const WCHAR signatureW[] =
+ {'S','i','g','n','a','t','u','r','e','K','e','y','P','a','i','r',0};
+ BYTE *buf, *ret = NULL;
+ DATA_BLOB blob_in, blob_out;
+ DWORD spec = 0, type, len;
+ WCHAR *path;
+ HKEY hkey;
+
+ if (!(path = get_key_container_path(ctx))) return NULL;
+ if (RegOpenKeyExW(HKEY_CURRENT_USER, path, 0, KEY_READ, &hkey))
+ {
+ RtlFreeHeap(GetProcessHeap(), 0, path);
+ return NULL;
+ }
+ RtlFreeHeap(GetProcessHeap(), 0, path);
+
+ if (!RegQueryValueExW(hkey, keyexchangeW, 0, &type, NULL, &len)) spec = AT_KEYEXCHANGE;
+ else if (!RegQueryValueExW(hkey, signatureW, 0, &type, NULL, &len)) spec = AT_SIGNATURE;
+ else
+ {
+ RegCloseKey(hkey);
+ return NULL;
+ }
+
+ if (!(buf = RtlAllocateHeap(GetProcessHeap(), 0, len + MAX_LEAD_BYTES)))
+ {
+ RegCloseKey(hkey);
+ return NULL;
+ }
+
+ if (!RegQueryValueExW(hkey, (spec == AT_KEYEXCHANGE) ? keyexchangeW : signatureW, 0, &type, buf, &len))
+ {
+ blob_in.pbData = buf;
+ blob_in.cbData = len;
+ if (CryptUnprotectData(&blob_in, NULL, NULL, NULL, NULL, 0, &blob_out))
+ {
+ assert(blob_in.cbData >= blob_out.cbData);
+ memcpy(buf, blob_out.pbData, blob_out.cbData);
+ LocalFree(blob_out.pbData);
+ *size = blob_out.cbData + MAX_LEAD_BYTES;
+ ret = buf;
+ }
+ }
+ else RtlFreeHeap(GetProcessHeap(), 0, buf);
+
+ RegCloseKey(hkey);
+ return ret;
+}
+
static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schanCred,
PCredHandle phCredential, PTimeStamp ptsExpiry)
{
@@ -397,6 +507,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
ULONG_PTR handle;
SECURITY_STATUS status = SEC_E_OK;
const CERT_CONTEXT *cert = NULL;
+ DATA_BLOB key_blob = {0};
TRACE("schanCred %p, phCredential %p, ptsExpiry %p\n", schanCred, phCredential, ptsExpiry);
@@ -426,20 +537,17 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
return SEC_E_NO_AUTHENTICATING_AUTHORITY;
}
- creds = heap_alloc(sizeof(*creds));
- if (!creds) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(creds = heap_alloc(sizeof(*creds)))) return SEC_E_INSUFFICIENT_MEMORY;
+ creds->credential_use = SECPKG_CRED_OUTBOUND;
+ creds->enabled_protocols = enabled_protocols;
+
+ if (cert && !(key_blob.pbData = get_key_blob(cert, &key_blob.cbData))) goto fail;
+ if (!schan_funcs->allocate_certificate_credentials(creds, cert, &key_blob)) goto fail;
+ RtlFreeHeap(GetProcessHeap(), 0, key_blob.pbData);
handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED);
if (handle == SCHAN_INVALID_HANDLE) goto fail;
- creds->credential_use = SECPKG_CRED_OUTBOUND;
- if (!schan_imp_allocate_certificate_credentials(creds, cert))
- {
- schan_free_handle(handle, SCHAN_HANDLE_CRED);
- goto fail;
- }
-
- creds->enabled_protocols = enabled_protocols;
phCredential->dwLower = handle;
phCredential->dwUpper = 0;
@@ -454,6 +562,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
fail:
heap_free(creds);
+ RtlFreeHeap(GetProcessHeap(), 0, key_blob.pbData);
return SEC_E_INTERNAL_ERROR;
}
@@ -542,10 +651,8 @@ static SECURITY_STATUS SEC_ENTRY schan_FreeCredentialsHandle(
creds = schan_free_handle(phCredential->dwLower, SCHAN_HANDLE_CRED);
if (!creds) return SEC_E_INVALID_HANDLE;
- if (creds->credential_use == SECPKG_CRED_OUTBOUND)
- schan_imp_free_certificate_credentials(creds);
+ if (creds->credential_use == SECPKG_CRED_OUTBOUND) schan_funcs->free_certificate_credentials(creds);
heap_free(creds);
-
return SEC_E_OK;
}
@@ -599,7 +706,7 @@ static void schan_resize_current_buffer(const struct schan_buffers *s, SIZE_T mi
b->pvBuffer = new_data;
}
-char *schan_get_buffer(const struct schan_transport *t, struct schan_buffers *s, SIZE_T *count)
+static char * CDECL schan_get_buffer(const struct schan_transport *t, struct schan_buffers *s, SIZE_T *count)
{
SIZE_T max_count;
PSecBuffer buffer;
@@ -672,7 +779,7 @@ char *schan_get_buffer(const struct schan_transport *t, struct schan_buffers *s,
* another errno-style error value on failure
*
*/
-int schan_pull(struct schan_transport *t, void *buff, size_t *buff_len)
+static int CDECL schan_pull(struct schan_transport *t, void *buff, size_t *buff_len)
{
char *b;
SIZE_T local_len = *buff_len;
@@ -711,7 +818,7 @@ int schan_pull(struct schan_transport *t, void *buff, size_t *buff_len)
* another errno-style error value on failure
*
*/
-int schan_push(struct schan_transport *t, const void *buff, size_t *buff_len)
+static int CDECL schan_push(struct schan_transport *t, const void *buff, size_t *buff_len)
{
char *b;
SIZE_T local_len = *buff_len;
@@ -733,7 +840,7 @@ int schan_push(struct schan_transport *t, const void *buff, size_t *buff_len)
return 0;
}
-schan_imp_session schan_session_for_transport(struct schan_transport* t)
+static schan_session CDECL schan_get_session_for_transport(struct schan_transport* t)
{
return t->ctx->session;
}
@@ -845,7 +952,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
return SEC_E_INTERNAL_ERROR;
}
- if (!schan_imp_create_session(&ctx->session, cred))
+ if (!schan_funcs->create_session(&ctx->session, cred))
{
schan_free_handle(handle, SCHAN_HANDLE_CTX);
heap_free(ctx);
@@ -858,7 +965,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
ctx->header_size = HEADER_SIZE_TLS;
ctx->transport.ctx = ctx;
- schan_imp_set_session_transport(ctx->session, &ctx->transport);
+ schan_funcs->set_session_transport(ctx->session, &ctx->transport);
if (pszTargetName && *pszTargetName)
{
@@ -868,7 +975,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
if (target)
{
WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, target, len, NULL, NULL );
- schan_imp_set_session_target( ctx->session, target );
+ schan_funcs->set_session_target( ctx->session, target );
heap_free( target );
}
}
@@ -876,13 +983,13 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
if (pInput && (idx = schan_find_sec_buffer_idx(pInput, 0, SECBUFFER_APPLICATION_PROTOCOLS)) != -1)
{
buffer = &pInput->pBuffers[idx];
- schan_imp_set_application_protocols(ctx->session, buffer->pvBuffer, buffer->cbBuffer);
+ schan_funcs->set_application_protocols(ctx->session, buffer->pvBuffer, buffer->cbBuffer);
}
if (pInput && (idx = schan_find_sec_buffer_idx(pInput, 0, SECBUFFER_DTLS_MTU)) != -1)
{
buffer = &pInput->pBuffers[idx];
- if (buffer->cbBuffer >= sizeof(WORD)) schan_imp_set_dtls_mtu(ctx->session, *(WORD *)buffer->pvBuffer);
+ if (buffer->cbBuffer >= sizeof(WORD)) schan_funcs->set_dtls_mtu(ctx->session, *(WORD *)buffer->pvBuffer);
else WARN("invalid buffer size %u\n", buffer->cbBuffer);
}
@@ -935,7 +1042,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
init_schan_buffers(&ctx->transport.out, pOutput, schan_init_sec_ctx_get_next_output_buffer);
/* Perform the TLS handshake */
- ret = schan_imp_handshake(ctx->session);
+ ret = schan_funcs->handshake(ctx->session);
out_buffers = &ctx->transport.out;
if (out_buffers->current_buffer_idx != -1)
@@ -1027,18 +1134,33 @@ static void *get_alg_name(ALG_ID id, BOOL wide)
static SECURITY_STATUS ensure_remote_cert(struct schan_context *ctx)
{
- HCERTSTORE cert_store;
+ HCERTSTORE store;
+ PCCERT_CONTEXT cert = NULL;
SECURITY_STATUS status;
+ struct schan_cert_list list;
- if(ctx->cert)
- return SEC_E_OK;
-
- cert_store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
- if(!cert_store)
+ if (ctx->cert) return SEC_E_OK;
+ if (!(store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL)))
return GetLastError();
- status = schan_imp_get_session_peer_certificate(ctx->session, cert_store, &ctx->cert);
- CertCloseStore(cert_store, 0);
+ if ((status = schan_funcs->get_session_peer_certificate(ctx->session, &list)) == SEC_E_OK)
+ {
+ unsigned int i;
+ for (i = 0; i < list.count; i++)
+ {
+ if (!CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, list.certs[i].pbData,
+ list.certs[i].cbData, CERT_STORE_ADD_REPLACE_EXISTING,
+ i ? NULL : &cert))
+ {
+ if (i) CertFreeCertificateContext(cert);
+ return GetLastError();
+ }
+ }
+ RtlFreeHeap(GetProcessHeap(), 0, list.certs);
+ }
+
+ ctx->cert = cert;
+ CertCloseStore(store, 0);
return status;
}
@@ -1059,13 +1181,13 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
case SECPKG_ATTR_STREAM_SIZES:
{
SecPkgContext_ConnectionInfo info;
- status = schan_imp_get_connection_info(ctx->session, &info);
+ status = schan_funcs->get_connection_info(ctx->session, &info);
if (status == SEC_E_OK)
{
SecPkgContext_StreamSizes *stream_sizes = buffer;
SIZE_T mac_size = info.dwHashStrength;
- unsigned int block_size = schan_imp_get_session_cipher_block_size(ctx->session);
- unsigned int message_size = schan_imp_get_max_message_size(ctx->session);
+ unsigned int block_size = schan_funcs->get_session_cipher_block_size(ctx->session);
+ unsigned int message_size = schan_funcs->get_max_message_size(ctx->session);
TRACE("Using header size %lu mac bytes %lu, message size %u, block size %u\n",
ctx->header_size, mac_size, message_size, block_size);
@@ -1083,12 +1205,12 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
case SECPKG_ATTR_KEY_INFO:
{
SecPkgContext_ConnectionInfo conn_info;
- status = schan_imp_get_connection_info(ctx->session, &conn_info);
+ status = schan_funcs->get_connection_info(ctx->session, &conn_info);
if (status == SEC_E_OK)
{
SecPkgContext_KeyInfoW *info = buffer;
info->KeySize = conn_info.dwCipherStrength;
- info->SignatureAlgorithm = schan_imp_get_key_signature_algorithm(ctx->session);
+ info->SignatureAlgorithm = schan_funcs->get_key_signature_algorithm(ctx->session);
info->EncryptAlgorithm = conn_info.aiCipher;
info->sSignatureAlgorithmName = get_alg_name(info->SignatureAlgorithm, TRUE);
info->sEncryptAlgorithmName = get_alg_name(info->EncryptAlgorithm, TRUE);
@@ -1109,7 +1231,7 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
case SECPKG_ATTR_CONNECTION_INFO:
{
SecPkgContext_ConnectionInfo *info = buffer;
- return schan_imp_get_connection_info(ctx->session, info);
+ return schan_funcs->get_connection_info(ctx->session, info);
}
case SECPKG_ATTR_ENDPOINT_BINDINGS:
{
@@ -1154,12 +1276,12 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
case SECPKG_ATTR_UNIQUE_BINDINGS:
{
SecPkgContext_Bindings *bindings = buffer;
- return schan_imp_get_unique_channel_binding(ctx->session, bindings);
+ return schan_funcs->get_unique_channel_binding(ctx->session, bindings);
}
case SECPKG_ATTR_APPLICATION_PROTOCOL:
{
SecPkgContext_ApplicationProtocol *protocol = buffer;
- return schan_imp_get_application_protocol(ctx->session, protocol);
+ return schan_funcs->get_application_protocol(ctx->session, protocol);
}
default:
@@ -1289,7 +1411,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle
init_schan_buffers(&ctx->transport.out, message, schan_encrypt_message_get_next_buffer_token);
length = data_size;
- status = schan_imp_send(ctx->session, data, &length);
+ status = schan_funcs->send(ctx->session, data, &length);
TRACE("Sent %ld bytes.\n", length);
@@ -1422,7 +1544,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
while (received < data_size)
{
SIZE_T length = data_size - received;
- status = schan_imp_recv(ctx->session, data + received, &length);
+ status = schan_funcs->recv(ctx->session, data + received, &length);
if (status == SEC_I_RENEGOTIATE)
break;
@@ -1478,11 +1600,9 @@ static SECURITY_STATUS SEC_ENTRY schan_DeleteSecurityContext(PCtxtHandle context
ctx = schan_free_handle(context_handle->dwLower, SCHAN_HANDLE_CTX);
if (!ctx) return SEC_E_INVALID_HANDLE;
- if (ctx->cert)
- CertFreeCertificateContext(ctx->cert);
- schan_imp_dispose_session(ctx->session);
+ if (ctx->cert) CertFreeCertificateContext(ctx->cert);
+ schan_funcs->dispose_session(ctx->session);
heap_free(ctx);
-
return SEC_E_OK;
}
@@ -1552,6 +1672,14 @@ static const WCHAR schannelComment[] = { 'S','c','h','a','n','n','e','l',' ',
'S','e','c','u','r','i','t','y',' ','P','a','c','k','a','g','e',0 };
static const WCHAR schannelDllName[] = { 's','c','h','a','n','n','e','l','.','d','l','l',0 };
+const struct schan_callbacks schan_callbacks =
+{
+ schan_get_buffer,
+ schan_get_session_for_transport,
+ schan_pull,
+ schan_push,
+};
+
void SECUR32_initSchannelSP(void)
{
/* This is what Windows reports. This shouldn't break any applications
@@ -1578,8 +1706,11 @@ void SECUR32_initSchannelSP(void)
};
SecureProvider *provider;
- if (!schan_imp_init())
+ if (!schan_funcs && __wine_init_unix_lib(hsecur32, DLL_PROCESS_ATTACH, &schan_callbacks, &schan_funcs))
+ {
+ ERR( "no schannel support, expect problems\n" );
return;
+ }
schan_handle_table = heap_alloc(64 * sizeof(*schan_handle_table));
if (!schan_handle_table)
@@ -1597,13 +1728,11 @@ void SECUR32_initSchannelSP(void)
}
SECUR32_addPackages(provider, ARRAY_SIZE(info), NULL, info);
-
return;
fail:
heap_free(schan_handle_table);
schan_handle_table = NULL;
- schan_imp_deinit();
return;
}
@@ -1620,7 +1749,7 @@ void SECUR32_deinitSchannelSP(void)
if (schan_handle_table[i].type == SCHAN_HANDLE_CTX)
{
struct schan_context *ctx = schan_free_handle(i, SCHAN_HANDLE_CTX);
- schan_imp_dispose_session(ctx->session);
+ schan_funcs->dispose_session(ctx->session);
heap_free(ctx);
}
}
@@ -1631,21 +1760,12 @@ void SECUR32_deinitSchannelSP(void)
{
struct schan_credentials *cred;
cred = schan_free_handle(i, SCHAN_HANDLE_CRED);
- schan_imp_free_certificate_credentials(cred);
+ schan_funcs->free_certificate_credentials(cred);
heap_free(cred);
}
}
heap_free(schan_handle_table);
- schan_imp_deinit();
-}
-
-#else /* SONAME_LIBGNUTLS || HAVE_SECURITY_SECURITY_H */
-void SECUR32_initSchannelSP(void)
-{
- ERR("TLS library not found, SSL connections will fail\n");
+ __wine_init_unix_lib(hsecur32, DLL_PROCESS_DETACH, NULL, NULL);
+ schan_funcs = NULL;
}
-
-void SECUR32_deinitSchannelSP(void) {}
-
-#endif /* SONAME_LIBGNUTLS || HAVE_SECURITY_SECURITY_H */
diff --git a/dlls/secur32/schannel_gnutls.c b/dlls/secur32/schannel_gnutls.c
index 785430ddf58..76ab230137d 100644
--- a/dlls/secur32/schannel_gnutls.c
+++ b/dlls/secur32/schannel_gnutls.c
@@ -19,23 +19,27 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#if 0
+#pragma makedep unix
+#endif
+
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#include <stdio.h>
-#include <assert.h>
#ifdef SONAME_LIBGNUTLS
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
#include <gnutls/abstract.h>
#endif
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "sspi.h"
#include "schannel.h"
-#include "lmcons.h"
#include "winreg.h"
#include "secur32_priv.h"
@@ -47,6 +51,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
WINE_DECLARE_DEBUG_CHANNEL(winediag);
+static const struct schan_callbacks *callbacks;
+
/* Not present in gnutls version < 2.9.10. */
static int (*pgnutls_cipher_get_block_size)(gnutls_cipher_algorithm_t);
@@ -192,13 +198,12 @@ static void compat_gnutls_dtls_set_mtu(gnutls_session_t session, unsigned int mt
FIXME("\n");
}
-static ssize_t schan_pull_adapter(gnutls_transport_ptr_t transport,
- void *buff, size_t buff_len)
+static ssize_t pull_adapter(gnutls_transport_ptr_t transport, void *buff, size_t buff_len)
{
struct schan_transport *t = (struct schan_transport*)transport;
- gnutls_session_t s = (gnutls_session_t)schan_session_for_transport(t);
+ gnutls_session_t s = (gnutls_session_t)callbacks->get_session_for_transport(t);
- int ret = schan_pull(transport, buff, &buff_len);
+ int ret = callbacks->pull(transport, buff, &buff_len);
if (ret)
{
pgnutls_transport_set_errno(s, ret);
@@ -208,13 +213,12 @@ static ssize_t schan_pull_adapter(gnutls_transport_ptr_t transport,
return buff_len;
}
-static ssize_t schan_push_adapter(gnutls_transport_ptr_t transport,
- const void *buff, size_t buff_len)
+static ssize_t push_adapter(gnutls_transport_ptr_t transport, const void *buff, size_t buff_len)
{
struct schan_transport *t = (struct schan_transport*)transport;
- gnutls_session_t s = (gnutls_session_t)schan_session_for_transport(t);
+ gnutls_session_t s = (gnutls_session_t)callbacks->get_session_for_transport(t);
- int ret = schan_push(transport, buff, &buff_len);
+ int ret = callbacks->push(transport, buff, &buff_len);
if (ret)
{
pgnutls_transport_set_errno(s, ret);
@@ -270,21 +274,21 @@ static void check_supported_protocols(void)
pgnutls_deinit(session);
}
-DWORD schan_imp_enabled_protocols(void)
+static DWORD CDECL schan_get_enabled_protocols(void)
{
return supported_protocols;
}
-static int schan_pull_timeout(gnutls_transport_ptr_t transport, unsigned int timeout)
+static int pull_timeout(gnutls_transport_ptr_t transport, unsigned int timeout)
{
struct schan_transport *t = (struct schan_transport *)transport;
SIZE_T count = 0;
- if (schan_get_buffer(t, &t->in, &count)) return 1;
+ if (callbacks->get_buffer(t, &t->in, &count)) return 1;
return 0;
}
-BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cred)
+static BOOL CDECL schan_create_session(schan_session *session, schan_credentials *cred)
{
gnutls_session_t *s = (gnutls_session_t*)session;
char priority[128] = "NORMAL:%LATEST_RECORD_VERSION", *p;
@@ -347,34 +351,32 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre
return FALSE;
}
- pgnutls_transport_set_pull_function(*s, schan_pull_adapter);
- if (flags & GNUTLS_DATAGRAM) pgnutls_transport_set_pull_timeout_function(*s, schan_pull_timeout);
- pgnutls_transport_set_push_function(*s, schan_push_adapter);
+ pgnutls_transport_set_pull_function(*s, pull_adapter);
+ if (flags & GNUTLS_DATAGRAM) pgnutls_transport_set_pull_timeout_function(*s, pull_timeout);
+ pgnutls_transport_set_push_function(*s, push_adapter);
return TRUE;
}
-void schan_imp_dispose_session(schan_imp_session session)
+static void CDECL schan_dispose_session(schan_session session)
{
gnutls_session_t s = (gnutls_session_t)session;
pgnutls_deinit(s);
}
-void schan_imp_set_session_transport(schan_imp_session session,
- struct schan_transport *t)
+static void CDECL schan_set_session_transport(schan_session session, struct schan_transport *t)
{
gnutls_session_t s = (gnutls_session_t)session;
pgnutls_transport_set_ptr(s, (gnutls_transport_ptr_t)t);
}
-void schan_imp_set_session_target(schan_imp_session session, const char *target)
+static void CDECL schan_set_session_target(schan_session session, const char *target)
{
gnutls_session_t s = (gnutls_session_t)session;
-
pgnutls_server_name_set( s, GNUTLS_NAME_DNS, target, strlen(target) );
}
-SECURITY_STATUS schan_imp_handshake(schan_imp_session session)
+static SECURITY_STATUS CDECL schan_handshake(schan_session session)
{
gnutls_session_t s = (gnutls_session_t)session;
int err;
@@ -422,7 +424,7 @@ SECURITY_STATUS schan_imp_handshake(schan_imp_session session)
return SEC_E_OK;
}
-static DWORD schannel_get_protocol(gnutls_protocol_t proto)
+static DWORD get_protocol(gnutls_protocol_t proto)
{
/* FIXME: currently schannel only implements client connections, but
* there's no reason it couldn't be used for servers as well. The
@@ -442,7 +444,7 @@ static DWORD schannel_get_protocol(gnutls_protocol_t proto)
}
}
-static ALG_ID schannel_get_cipher_algid(gnutls_cipher_algorithm_t cipher)
+static ALG_ID get_cipher_algid(gnutls_cipher_algorithm_t cipher)
{
switch (cipher)
{
@@ -464,7 +466,7 @@ static ALG_ID schannel_get_cipher_algid(gnutls_cipher_algorithm_t cipher)
}
}
-static ALG_ID schannel_get_mac_algid(gnutls_mac_algorithm_t mac, gnutls_cipher_algorithm_t cipher)
+static ALG_ID get_mac_algid(gnutls_mac_algorithm_t mac, gnutls_cipher_algorithm_t cipher)
{
switch (mac)
{
@@ -493,7 +495,7 @@ static ALG_ID schannel_get_mac_algid(gnutls_mac_algorithm_t mac, gnutls_cipher_a
}
}
-static ALG_ID schannel_get_kx_algid(int kx)
+static ALG_ID get_kx_algid(int kx)
{
switch (kx)
{
@@ -513,19 +515,18 @@ static ALG_ID schannel_get_kx_algid(int kx)
}
}
-unsigned int schan_imp_get_session_cipher_block_size(schan_imp_session session)
+static unsigned int CDECL schan_get_session_cipher_block_size(schan_session session)
{
gnutls_session_t s = (gnutls_session_t)session;
return pgnutls_cipher_get_block_size(pgnutls_cipher_get(s));
}
-unsigned int schan_imp_get_max_message_size(schan_imp_session session)
+static unsigned int CDECL schan_get_max_message_size(schan_session session)
{
return pgnutls_record_get_max_size((gnutls_session_t)session);
}
-SECURITY_STATUS schan_imp_get_connection_info(schan_imp_session session,
- SecPkgContext_ConnectionInfo *info)
+static SECURITY_STATUS CDECL schan_get_connection_info(schan_session session, SecPkgContext_ConnectionInfo *info)
{
gnutls_session_t s = (gnutls_session_t)session;
gnutls_protocol_t proto = pgnutls_protocol_get_version(s);
@@ -533,19 +534,18 @@ SECURITY_STATUS schan_imp_get_connection_info(schan_imp_session session,
gnutls_mac_algorithm_t mac = pgnutls_mac_get(s);
gnutls_kx_algorithm_t kx = pgnutls_kx_get(s);
- info->dwProtocol = schannel_get_protocol(proto);
- info->aiCipher = schannel_get_cipher_algid(alg);
+ info->dwProtocol = get_protocol(proto);
+ info->aiCipher = get_cipher_algid(alg);
info->dwCipherStrength = pgnutls_cipher_get_key_size(alg) * 8;
- info->aiHash = schannel_get_mac_algid(mac, alg);
+ info->aiHash = get_mac_algid(mac, alg);
info->dwHashStrength = pgnutls_mac_get_key_size(mac) * 8;
- info->aiExch = schannel_get_kx_algid(kx);
+ info->aiExch = get_kx_algid(kx);
/* FIXME: info->dwExchStrength? */
info->dwExchStrength = 0;
return SEC_E_OK;
}
-SECURITY_STATUS schan_imp_get_unique_channel_binding(schan_imp_session session,
- SecPkgContext_Bindings *bindings)
+static SECURITY_STATUS CDECL schan_get_unique_channel_binding(schan_session session, SecPkgContext_Bindings *bindings)
{
static const char prefix[] = "tls-unique:";
gnutls_datum_t datum;
@@ -562,7 +562,7 @@ SECURITY_STATUS schan_imp_get_unique_channel_binding(schan_imp_session session,
}
bindings->BindingsLength = sizeof(SEC_CHANNEL_BINDINGS) + sizeof(prefix)-1 + datum.size;
- bindings->Bindings = heap_alloc_zero(bindings->BindingsLength);
+ bindings->Bindings = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, bindings->BindingsLength);
if (!bindings->Bindings)
ret = SEC_E_INSUFFICIENT_MEMORY;
else
@@ -579,7 +579,7 @@ SECURITY_STATUS schan_imp_get_unique_channel_binding(schan_imp_session session,
return ret;
}
-ALG_ID schan_imp_get_key_signature_algorithm(schan_imp_session session)
+static ALG_ID CDECL schan_get_key_signature_algorithm(schan_session session)
{
gnutls_session_t s = (gnutls_session_t)session;
gnutls_kx_algorithm_t kx = pgnutls_kx_get(s);
@@ -600,35 +600,32 @@ ALG_ID schan_imp_get_key_signature_algorithm(schan_imp_session session)
}
}
-SECURITY_STATUS schan_imp_get_session_peer_certificate(schan_imp_session session, HCERTSTORE store,
- PCCERT_CONTEXT *ret)
+static SECURITY_STATUS CDECL schan_get_session_peer_certificate(schan_session session, struct schan_cert_list *list)
{
gnutls_session_t s = (gnutls_session_t)session;
- PCCERT_CONTEXT cert = NULL;
const gnutls_datum_t *datum;
- unsigned list_size, i;
- BOOL res;
+ unsigned int i, size;
+ BYTE *ptr;
- datum = pgnutls_certificate_get_peers(s, &list_size);
- if(!datum)
- return SEC_E_INTERNAL_ERROR;
+ if (!(datum = pgnutls_certificate_get_peers(s, &list->count))) return SEC_E_INTERNAL_ERROR;
- for(i = 0; i < list_size; i++) {
- res = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, datum[i].data, datum[i].size,
- CERT_STORE_ADD_REPLACE_EXISTING, i ? NULL : &cert);
- if(!res) {
- if(i)
- CertFreeCertificateContext(cert);
- return GetLastError();
- }
+ size = list->count * sizeof(list->certs[0]);
+ for (i = 0; i < list->count; i++) size += datum[i].size;
+ if (!(list->certs = RtlAllocateHeap(GetProcessHeap(), 0, size))) return SEC_E_INSUFFICIENT_MEMORY;
+
+ ptr = (BYTE *)&list->certs[list->count];
+ for (i = 0; i < list->count; i++)
+ {
+ list->certs[i].cbData = datum[i].size;
+ list->certs[i].pbData = ptr;
+ memcpy(list->certs[i].pbData, datum[i].data, datum[i].size);
+ ptr += datum[i].size;
}
- *ret = cert;
return SEC_E_OK;
}
-SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer,
- SIZE_T *length)
+static SECURITY_STATUS CDECL schan_send(schan_session session, const void *buffer, SIZE_T *length)
{
gnutls_session_t s = (gnutls_session_t)session;
SSIZE_T ret, total = 0;
@@ -647,7 +644,7 @@ SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer,
struct schan_transport *t = (struct schan_transport *)pgnutls_transport_get_ptr(s);
SIZE_T count = 0;
- if (schan_get_buffer(t, &t->out, &count)) continue;
+ if (callbacks->get_buffer(t, &t->out, &count)) continue;
return SEC_I_CONTINUE_NEEDED;
}
else
@@ -658,8 +655,7 @@ SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer,
}
}
-SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer,
- SIZE_T *length)
+static SECURITY_STATUS CDECL schan_recv(schan_session session, void *buffer, SIZE_T *length)
{
gnutls_session_t s = (gnutls_session_t)session;
ssize_t ret;
@@ -674,7 +670,7 @@ again:
struct schan_transport *t = (struct schan_transport *)pgnutls_transport_get_ptr(s);
SIZE_T count = 0;
- if (schan_get_buffer(t, &t->in, &count))
+ if (callbacks->get_buffer(t, &t->in, &count))
goto again;
return SEC_I_CONTINUE_NEEDED;
@@ -715,7 +711,7 @@ static unsigned int parse_alpn_protocol_list(unsigned char *buffer, unsigned int
return count;
}
-void schan_imp_set_application_protocols(schan_imp_session session, unsigned char *buffer, unsigned int buflen)
+static void CDECL schan_set_application_protocols(schan_session session, unsigned char *buffer, unsigned int buflen)
{
gnutls_session_t s = (gnutls_session_t)session;
unsigned int extension_len, extension, count = 0, offset = 0;
@@ -742,7 +738,7 @@ void schan_imp_set_application_protocols(schan_imp_session session, unsigned cha
if (offset + list_len > buflen) return;
count = parse_alpn_protocol_list(&buffer[offset], list_len, NULL);
- if (!count || !(protocols = heap_alloc(count * sizeof(*protocols)))) return;
+ if (!count || !(protocols = RtlAllocateHeap(GetProcessHeap(), 0, count * sizeof(*protocols)))) return;
parse_alpn_protocol_list(&buffer[offset], list_len, protocols);
if ((ret = pgnutls_alpn_set_protocols(s, protocols, count, GNUTLS_ALPN_SERVER_PRECEDENCE) < 0))
@@ -750,11 +746,11 @@ void schan_imp_set_application_protocols(schan_imp_session session, unsigned cha
pgnutls_perror(ret);
}
- heap_free(protocols);
+ RtlFreeHeap(GetProcessHeap(), 0, protocols);
}
-SECURITY_STATUS schan_imp_get_application_protocol(schan_imp_session session,
- SecPkgContext_ApplicationProtocol *protocol)
+static SECURITY_STATUS CDECL schan_get_application_protocol(schan_session session,
+ SecPkgContext_ApplicationProtocol *protocol)
{
gnutls_session_t s = (gnutls_session_t)session;
gnutls_datum_t selected;
@@ -768,12 +764,12 @@ SECURITY_STATUS schan_imp_get_application_protocol(schan_imp_session session,
protocol->ProtoNegoExt = SecApplicationProtocolNegotiationExt_ALPN;
protocol->ProtocolIdSize = selected.size;
memcpy(protocol->ProtocolId, selected.data, selected.size);
- TRACE("returning %s\n", debugstr_an((const char *)selected.data, selected.size));
+ TRACE("returning %s\n", wine_dbgstr_an((const char *)selected.data, selected.size));
}
return SEC_E_OK;
}
-SECURITY_STATUS schan_imp_set_dtls_mtu(schan_imp_session session, unsigned int mtu)
+static SECURITY_STATUS CDECL schan_set_dtls_mtu(schan_session session, unsigned int mtu)
{
gnutls_session_t s = (gnutls_session_t)session;
@@ -782,114 +778,6 @@ SECURITY_STATUS schan_imp_set_dtls_mtu(schan_imp_session session, unsigned int m
return SEC_E_OK;
}
-static WCHAR *get_key_container_path(const CERT_CONTEXT *ctx)
-{
- static const WCHAR rsabaseW[] =
- {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\','C','r','y','p','t','o','\\','R','S','A','\\',0};
- CERT_KEY_CONTEXT keyctx;
- DWORD size = sizeof(keyctx), prov_size = 0;
- CRYPT_KEY_PROV_INFO *prov;
- WCHAR username[UNLEN + 1], *ret = NULL;
- DWORD len = ARRAY_SIZE(username);
-
- if (CertGetCertificateContextProperty(ctx, CERT_KEY_CONTEXT_PROP_ID, &keyctx, &size))
- {
- char *str;
- if (!CryptGetProvParam(keyctx.hCryptProv, PP_CONTAINER, NULL, &size, 0)) return NULL;
- if (!(str = heap_alloc(size))) return NULL;
- if (!CryptGetProvParam(keyctx.hCryptProv, PP_CONTAINER, (BYTE *)str, &size, 0)) return NULL;
-
- len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
- if (!(ret = heap_alloc(sizeof(rsabaseW) + len * sizeof(WCHAR))))
- {
- heap_free(str);
- return NULL;
- }
- strcpyW(ret, rsabaseW);
- MultiByteToWideChar(CP_ACP, 0, str, -1, ret + strlenW(ret), len);
- heap_free(str);
- }
- else if (CertGetCertificateContextProperty(ctx, CERT_KEY_PROV_INFO_PROP_ID, NULL, &prov_size))
- {
- if (!(prov = heap_alloc(prov_size))) return NULL;
- if (!CertGetCertificateContextProperty(ctx, CERT_KEY_PROV_INFO_PROP_ID, prov, &prov_size))
- {
- heap_free(prov);
- return NULL;
- }
- if (!(ret = heap_alloc(sizeof(rsabaseW) + strlenW(prov->pwszContainerName) * sizeof(WCHAR))))
- {
- heap_free(prov);
- return NULL;
- }
- strcpyW(ret, rsabaseW);
- strcatW(ret, prov->pwszContainerName);
- heap_free(prov);
- }
-
- if (!ret && GetUserNameW(username, &len) && (ret = heap_alloc(sizeof(rsabaseW) + len * sizeof(WCHAR))))
- {
- strcpyW(ret, rsabaseW);
- strcatW(ret, username);
- }
-
- return ret;
-}
-
-#define MAX_LEAD_BYTES 8
-static BYTE *get_key_blob(const CERT_CONTEXT *ctx, ULONG *size)
-{
- static const WCHAR keyexchangeW[] =
- {'K','e','y','E','x','c','h','a','n','g','e','K','e','y','P','a','i','r',0};
- static const WCHAR signatureW[] =
- {'S','i','g','n','a','t','u','r','e','K','e','y','P','a','i','r',0};
- BYTE *buf, *ret = NULL;
- DATA_BLOB blob_in, blob_out;
- DWORD spec = 0, type, len;
- WCHAR *path;
- HKEY hkey;
-
- if (!(path = get_key_container_path(ctx))) return NULL;
- if (RegOpenKeyExW(HKEY_CURRENT_USER, path, 0, KEY_READ, &hkey))
- {
- heap_free(path);
- return NULL;
- }
- heap_free(path);
-
- if (!RegQueryValueExW(hkey, keyexchangeW, 0, &type, NULL, &len)) spec = AT_KEYEXCHANGE;
- else if (!RegQueryValueExW(hkey, signatureW, 0, &type, NULL, &len)) spec = AT_SIGNATURE;
- else
- {
- RegCloseKey(hkey);
- return NULL;
- }
-
- if (!(buf = heap_alloc(len + MAX_LEAD_BYTES)))
- {
- RegCloseKey(hkey);
- return NULL;
- }
-
- if (!RegQueryValueExW(hkey, (spec == AT_KEYEXCHANGE) ? keyexchangeW : signatureW, 0, &type, buf, &len))
- {
- blob_in.pbData = buf;
- blob_in.cbData = len;
- if (CryptUnprotectData(&blob_in, NULL, NULL, NULL, NULL, 0, &blob_out))
- {
- assert(blob_in.cbData >= blob_out.cbData);
- memcpy(buf, blob_out.pbData, blob_out.cbData);
- LocalFree(blob_out.pbData);
- *size = blob_out.cbData + MAX_LEAD_BYTES;
- ret = buf;
- }
- }
- else heap_free(buf);
-
- RegCloseKey(hkey);
- return ret;
-}
-
static inline void reverse_bytes(BYTE *buf, ULONG len)
{
BYTE tmp;
@@ -917,20 +805,19 @@ static ULONG set_component(gnutls_datum_t *comp, BYTE *data, ULONG len, ULONG *b
return comp->size;
}
-static gnutls_x509_privkey_t get_x509_key(const CERT_CONTEXT *ctx)
+static gnutls_x509_privkey_t get_x509_key(const DATA_BLOB *key_blob)
{
gnutls_privkey_t key = NULL;
gnutls_x509_privkey_t x509key = NULL;
gnutls_datum_t m, e, d, p, q, u, e1, e2;
- BYTE *ptr, *buffer;
+ BYTE *ptr;
RSAPUBKEY *rsakey;
- DWORD size;
+ DWORD size = key_blob->cbData;
int ret;
- if (!(buffer = get_key_blob(ctx, &size))) return NULL;
- if (size < sizeof(BLOBHEADER)) goto done;
+ if (size < sizeof(BLOBHEADER)) return NULL;
- rsakey = (RSAPUBKEY *)(buffer + sizeof(BLOBHEADER));
+ rsakey = (RSAPUBKEY *)(key_blob->pbData + sizeof(BLOBHEADER));
TRACE("RSA key bitlen %u pubexp %u\n", rsakey->bitlen, rsakey->pubexp);
size -= sizeof(BLOBHEADER) + FIELD_OFFSET(RSAPUBKEY, pubexp);
@@ -948,23 +835,17 @@ static gnutls_x509_privkey_t get_x509_key(const CERT_CONTEXT *ctx)
if ((ret = pgnutls_privkey_init(&key)) < 0)
{
pgnutls_perror(ret);
- goto done;
- }
-
- if ((ret = pgnutls_privkey_import_rsa_raw(key, &m, &e, &d, &p, &q, &u, &e1, &e2)) < 0)
- {
- pgnutls_perror(ret);
- goto done;
+ return NULL;
}
- if ((ret = pgnutls_privkey_export_x509(key, &x509key)) < 0)
+ if (((ret = pgnutls_privkey_import_rsa_raw(key, &m, &e, &d, &p, &q, &u, &e1, &e2)) < 0) ||
+ (ret = pgnutls_privkey_export_x509(key, &x509key)) < 0)
{
pgnutls_perror(ret);
+ pgnutls_privkey_deinit(key);
+ return NULL;
}
-done:
- heap_free(buffer);
- pgnutls_privkey_deinit(key);
return x509key;
}
@@ -999,7 +880,8 @@ static gnutls_x509_crt_t get_x509_crt(const CERT_CONTEXT *ctx)
return crt;
}
-BOOL schan_imp_allocate_certificate_credentials(schan_credentials *c, const CERT_CONTEXT *ctx)
+static BOOL CDECL schan_allocate_certificate_credentials(schan_credentials *c, const CERT_CONTEXT *ctx,
+ const DATA_BLOB *key_blob )
{
gnutls_certificate_credentials_t creds;
gnutls_x509_crt_t crt;
@@ -1025,7 +907,7 @@ BOOL schan_imp_allocate_certificate_credentials(schan_credentials *c, const CERT
return FALSE;
}
- if (!(key = get_x509_key(ctx)))
+ if (!(key = get_x509_key(key_blob)))
{
pgnutls_x509_crt_deinit(crt);
pgnutls_certificate_free_credentials(creds);
@@ -1046,17 +928,17 @@ BOOL schan_imp_allocate_certificate_credentials(schan_credentials *c, const CERT
return TRUE;
}
-void schan_imp_free_certificate_credentials(schan_credentials *c)
+static void CDECL schan_free_certificate_credentials(schan_credentials *c)
{
pgnutls_certificate_free_credentials(c->credentials);
}
-static void schan_gnutls_log(int level, const char *msg)
+static void gnutls_log(int level, const char *msg)
{
TRACE("<%d> %s", level, msg);
}
-BOOL schan_imp_init(void)
+static BOOL gnutls_initialize(void)
{
const char *env_str;
int ret;
@@ -1171,7 +1053,7 @@ BOOL schan_imp_init(void)
if (TRACE_ON(secur32))
{
pgnutls_global_set_log_level(4);
- pgnutls_global_set_log_function(schan_gnutls_log);
+ pgnutls_global_set_log_function(gnutls_log);
}
check_supported_protocols();
@@ -1183,11 +1065,50 @@ fail:
return FALSE;
}
-void schan_imp_deinit(void)
+static void gnutls_uninitialize(void)
{
pgnutls_global_deinit();
dlclose(libgnutls_handle);
libgnutls_handle = NULL;
}
+static const struct schan_funcs funcs =
+{
+ schan_allocate_certificate_credentials,
+ schan_create_session,
+ schan_dispose_session,
+ schan_free_certificate_credentials,
+ schan_get_application_protocol,
+ schan_get_connection_info,
+ schan_get_enabled_protocols,
+ schan_get_key_signature_algorithm,
+ schan_get_max_message_size,
+ schan_get_session_cipher_block_size,
+ schan_get_session_peer_certificate,
+ schan_get_unique_channel_binding,
+ schan_handshake,
+ schan_recv,
+ schan_send,
+ schan_set_application_protocols,
+ schan_set_dtls_mtu,
+ schan_set_session_target,
+ schan_set_session_transport,
+};
+
+NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
+{
+ switch (reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ if (!gnutls_initialize()) return STATUS_DLL_NOT_FOUND;
+ callbacks = ptr_in;
+ *(const struct schan_funcs **)ptr_out = &funcs;
+ break;
+ case DLL_PROCESS_DETACH:
+ if (libgnutls_handle) gnutls_uninitialize();
+ break;
+ }
+ return STATUS_SUCCESS;
+}
+
#endif /* SONAME_LIBGNUTLS && !HAVE_SECURITY_SECURITY_H */
diff --git a/dlls/secur32/schannel_macosx.c b/dlls/secur32/schannel_macosx.c
index 841f928eef3..daf9d835835 100644
--- a/dlls/secur32/schannel_macosx.c
+++ b/dlls/secur32/schannel_macosx.c
@@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#if 0
+#pragma makedep unix
+#endif
+
#include "config.h"
#include "wine/port.h"
@@ -33,10 +37,13 @@
#undef LoadResource
#endif
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "sspi.h"
#include "schannel.h"
+#include "winternl.h"
#include "secur32_priv.h"
#include "wine/debug.h"
@@ -44,6 +51,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
+static const struct schan_callbacks *callbacks;
+
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
/* Defined in <Security/CipherSuite.h> in the 10.6 SDK or later. */
enum {
@@ -444,7 +453,7 @@ static const struct cipher_suite* get_cipher_suite(SSLCipherSuite cipher_suite)
}
-static DWORD schan_get_session_protocol(struct mac_session* s)
+static DWORD get_session_protocol(struct mac_session* s)
{
SSLProtocol protocol;
int status;
@@ -473,7 +482,7 @@ static DWORD schan_get_session_protocol(struct mac_session* s)
}
}
-static ALG_ID schan_get_cipher_algid(const struct cipher_suite* c)
+static ALG_ID get_cipher_algid(const struct cipher_suite* c)
{
TRACE("(%#x)\n", (unsigned int)c->suite);
@@ -503,7 +512,7 @@ static ALG_ID schan_get_cipher_algid(const struct cipher_suite* c)
}
}
-static unsigned int schan_get_cipher_key_size(const struct cipher_suite* c)
+static unsigned int get_cipher_key_size(const struct cipher_suite* c)
{
TRACE("(%#x)\n", (unsigned int)c->suite);
@@ -533,7 +542,7 @@ static unsigned int schan_get_cipher_key_size(const struct cipher_suite* c)
}
}
-static ALG_ID schan_get_mac_algid(const struct cipher_suite* c)
+static ALG_ID get_mac_algid(const struct cipher_suite* c)
{
TRACE("(%#x)\n", (unsigned int)c->suite);
@@ -551,7 +560,7 @@ static ALG_ID schan_get_mac_algid(const struct cipher_suite* c)
}
}
-static unsigned int schan_get_mac_key_size(const struct cipher_suite* c)
+static unsigned int get_mac_key_size(const struct cipher_suite* c)
{
TRACE("(%#x)\n", (unsigned int)c->suite);
@@ -569,7 +578,7 @@ static unsigned int schan_get_mac_key_size(const struct cipher_suite* c)
}
}
-static ALG_ID schan_get_kx_algid(const struct cipher_suite* c)
+static ALG_ID get_kx_algid(const struct cipher_suite* c)
{
TRACE("(%#x)\n", (unsigned int)c->suite);
@@ -608,7 +617,7 @@ static ALG_ID schan_get_kx_algid(const struct cipher_suite* c)
}
-/* schan_pull_adapter
+/* pull_adapter
* Callback registered with SSLSetIOFuncs as the read function for a
* session. Reads data from the session connection. Conforms to the
* SSLReadFunc type.
@@ -629,8 +638,7 @@ static ALG_ID schan_get_kx_algid(const struct cipher_suite* c)
* more data to be read.
* other error code for failure.
*/
-static OSStatus schan_pull_adapter(SSLConnectionRef transport, void *buff,
- SIZE_T *buff_len)
+static OSStatus pull_adapter(SSLConnectionRef transport, void *buff, SIZE_T *buff_len)
{
struct mac_session *s = (struct mac_session*)transport;
size_t requested = *buff_len;
@@ -645,7 +653,7 @@ static OSStatus schan_pull_adapter(SSLConnectionRef transport, void *buff,
return noErr;
}
- status = schan_pull(s->transport, buff, buff_len);
+ status = callbacks->pull(s->transport, buff, buff_len);
if (status == 0)
{
if (*buff_len == 0)
@@ -678,7 +686,7 @@ static OSStatus schan_pull_adapter(SSLConnectionRef transport, void *buff,
return ret;
}
-/* schan_push_adapter
+/* push_adapter
* Callback registered with SSLSetIOFuncs as the write function for a
* session. Writes data to the session connection. Conforms to the
* SSLWriteFunc type.
@@ -695,8 +703,7 @@ static OSStatus schan_pull_adapter(SSLConnectionRef transport, void *buff,
* caller should try again.
* other error code for failure.
*/
-static OSStatus schan_push_adapter(SSLConnectionRef transport, const void *buff,
- SIZE_T *buff_len)
+static OSStatus push_adapter(SSLConnectionRef transport, const void *buff, SIZE_T *buff_len)
{
struct mac_session *s = (struct mac_session*)transport;
int status;
@@ -710,7 +717,7 @@ static OSStatus schan_push_adapter(SSLConnectionRef transport, const void *buff,
return noErr;
}
- status = schan_push(s->transport, buff, buff_len);
+ status = callbacks->push(s->transport, buff, buff_len);
if (status == 0)
{
TRACE("Pushed %lu bytes\n", *buff_len);
@@ -743,12 +750,12 @@ static const struct {
static DWORD supported_protocols;
-DWORD schan_imp_enabled_protocols(void)
+static DWORD CDECL schan_get_enabled_protocols(void)
{
return supported_protocols;
}
-BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cred)
+static BOOL CDECL schan_create_session(schan_session *session, schan_credentials *cred)
{
struct mac_session *s;
unsigned i;
@@ -756,9 +763,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre
TRACE("(%p)\n", session);
- s = heap_alloc(sizeof(*s));
- if (!s)
- return FALSE;
+ if (!(s = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(*s)))) return FALSE;
pthread_mutex_init(&s->mutex, NULL);
@@ -796,7 +801,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre
}
}
- status = SSLSetIOFuncs(s->context, schan_pull_adapter, schan_push_adapter);
+ status = SSLSetIOFuncs(s->context, pull_adapter, push_adapter);
if (status != noErr)
{
ERR("Failed to set session I/O funcs: %d\n", status);
@@ -807,15 +812,15 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre
TRACE(" -> %p/%p\n", s, s->context);
- *session = (schan_imp_session)s;
+ *session = (schan_session)s;
return TRUE;
fail:
- heap_free(s);
+ RtlFreeHeap(GetProcessHeap(), 0, s);
return FALSE;
}
-void schan_imp_dispose_session(schan_imp_session session)
+static void CDECL schan_dispose_session(schan_session session)
{
struct mac_session *s = (struct mac_session*)session;
int status;
@@ -826,11 +831,10 @@ void schan_imp_dispose_session(schan_imp_session session)
if (status != noErr)
ERR("Failed to dispose of session context: %d\n", status);
pthread_mutex_destroy(&s->mutex);
- heap_free(s);
+ RtlFreeHeap(GetProcessHeap(), 0, s);
}
-void schan_imp_set_session_transport(schan_imp_session session,
- struct schan_transport *t)
+static void CDECL schan_set_session_transport(schan_session session, struct schan_transport *t)
{
struct mac_session *s = (struct mac_session*)session;
@@ -839,7 +843,7 @@ void schan_imp_set_session_transport(schan_imp_session session,
s->transport = t;
}
-void schan_imp_set_session_target(schan_imp_session session, const char *target)
+static void CDECL schan_set_session_target(schan_session session, const char *target)
{
struct mac_session *s = (struct mac_session*)session;
@@ -848,7 +852,7 @@ void schan_imp_set_session_target(schan_imp_session session, const char *target)
SSLSetPeerDomainName( s->context, target, strlen(target) );
}
-SECURITY_STATUS schan_imp_handshake(schan_imp_session session)
+static SECURITY_STATUS CDECL schan_handshake(schan_session session)
{
struct mac_session *s = (struct mac_session*)session;
int status;
@@ -885,7 +889,7 @@ SECURITY_STATUS schan_imp_handshake(schan_imp_session session)
return SEC_E_OK;
}
-unsigned int schan_imp_get_session_cipher_block_size(schan_imp_session session)
+static unsigned int CDECL schan_get_session_cipher_block_size(schan_session session)
{
struct mac_session* s = (struct mac_session*)session;
SSLCipherSuite cipherSuite;
@@ -934,13 +938,13 @@ unsigned int schan_imp_get_session_cipher_block_size(schan_imp_session session)
}
}
-unsigned int schan_imp_get_max_message_size(schan_imp_session session)
+static unsigned int CDECL schan_get_max_message_size(schan_session session)
{
FIXME("Returning 1 << 14.\n");
return 1 << 14;
}
-ALG_ID schan_imp_get_key_signature_algorithm(schan_imp_session session)
+static ALG_ID CDECL schan_get_key_signature_algorithm(schan_session session)
{
struct mac_session* s = (struct mac_session*)session;
SSLCipherSuite cipherSuite;
@@ -1002,8 +1006,7 @@ ALG_ID schan_imp_get_key_signature_algorithm(schan_imp_session session)
}
}
-SECURITY_STATUS schan_imp_get_connection_info(schan_imp_session session,
- SecPkgContext_ConnectionInfo *info)
+static SECURITY_STATUS CDECL schan_get_connection_info(schan_session session, SecPkgContext_ConnectionInfo *info)
{
struct mac_session* s = (struct mac_session*)session;
SSLCipherSuite cipherSuite;
@@ -1026,46 +1029,44 @@ SECURITY_STATUS schan_imp_get_connection_info(schan_imp_session session,
return SEC_E_INTERNAL_ERROR;
}
- info->dwProtocol = schan_get_session_protocol(s);
- info->aiCipher = schan_get_cipher_algid(c);
- info->dwCipherStrength = schan_get_cipher_key_size(c);
- info->aiHash = schan_get_mac_algid(c);
- info->dwHashStrength = schan_get_mac_key_size(c);
- info->aiExch = schan_get_kx_algid(c);
+ info->dwProtocol = get_session_protocol(s);
+ info->aiCipher = get_cipher_algid(c);
+ info->dwCipherStrength = get_cipher_key_size(c);
+ info->aiHash = get_mac_algid(c);
+ info->dwHashStrength = get_mac_key_size(c);
+ info->aiExch = get_kx_algid(c);
/* FIXME: info->dwExchStrength? */
info->dwExchStrength = 0;
return SEC_E_OK;
}
-SECURITY_STATUS schan_imp_get_unique_channel_binding(schan_imp_session session,
- SecPkgContext_Bindings *bindings)
+static SECURITY_STATUS CDECL schan_get_unique_channel_binding(schan_session session, SecPkgContext_Bindings *bindings)
{
FIXME("SECPKG_ATTR_UNIQUE_BINDINGS is unsupported on MacOS\n");
return SEC_E_UNSUPPORTED_FUNCTION;
}
#ifndef HAVE_SSLCOPYPEERCERTIFICATES
-static void schan_imp_cf_release(const void *arg, void *ctx)
+static void cf_release(const void *arg, void *ctx)
{
CFRelease(arg);
}
#endif
-SECURITY_STATUS schan_imp_get_session_peer_certificate(schan_imp_session session, HCERTSTORE store,
- PCCERT_CONTEXT *ret_cert)
+static SECURITY_STATUS CDECL schan_get_session_peer_certificate(schan_session session, struct schan_cert_list *list)
{
- struct mac_session* s = (struct mac_session*)session;
+ struct mac_session *s = (struct mac_session *)session;
SECURITY_STATUS ret = SEC_E_OK;
- PCCERT_CONTEXT cert = NULL;
- SecCertificateRef mac_cert;
+ SecCertificateRef cert;
CFArrayRef cert_array;
int status;
- CFIndex cnt, i;
+ unsigned int size;
+ CFIndex i;
CFDataRef data;
- BOOL res;
+ BYTE *ptr;
- TRACE("(%p/%p, %p)\n", s, s->context, cert);
+ TRACE("(%p/%p, %p)\n", s, s->context, list);
#ifdef HAVE_SSLCOPYPEERCERTIFICATES
status = SSLCopyPeerCertificates(s->context, &cert_array);
@@ -1078,45 +1079,55 @@ SECURITY_STATUS schan_imp_get_session_peer_certificate(schan_imp_session session
return SEC_E_INTERNAL_ERROR;
}
- cnt = CFArrayGetCount(cert_array);
- for (i=0; i < cnt; i++) {
- if (!(mac_cert = (SecCertificateRef)CFArrayGetValueAtIndex(cert_array, i)) ||
- (SecKeychainItemExport(mac_cert, kSecFormatX509Cert, 0, NULL, &data) != noErr))
+ list->count = CFArrayGetCount(cert_array);
+ size = list->count * sizeof(list->certs[0]);
+
+ for (i = 0; i < list->count; i++)
+ {
+ if (!(cert = (SecCertificateRef)CFArrayGetValueAtIndex(cert_array, i)) ||
+ (SecKeychainItemExport(cert, kSecFormatX509Cert, 0, NULL, &data) != noErr))
{
WARN("Couldn't extract certificate data\n");
ret = SEC_E_INTERNAL_ERROR;
- break;
+ goto done;
}
-
- res = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, CFDataGetBytePtr(data), CFDataGetLength(data),
- CERT_STORE_ADD_REPLACE_EXISTING, i ? NULL : &cert);
+ size += CFDataGetLength(data);
CFRelease(data);
- if (!res)
+ }
+
+ if (!(list->certs = RtlAllocateHeap(GetProcessHeap(), 0, size)))
+ {
+ ret = SEC_E_INSUFFICIENT_MEMORY;
+ goto done;
+ }
+
+ ptr = (BYTE *)&list->certs[list->count];
+ for (i = 0; i < list->count; i++)
+ {
+ if (!(cert = (SecCertificateRef)CFArrayGetValueAtIndex(cert_array, i)) ||
+ (SecKeychainItemExport(cert, kSecFormatX509Cert, 0, NULL, &data) != noErr))
{
- ret = GetLastError();
- WARN("CertAddEncodedCertificateToStore failed: %x\n", ret);
- break;
+ WARN("Couldn't extract certificate data\n");
+ ret = SEC_E_INTERNAL_ERROR;
+ goto done;
}
+ list->certs[i].cbData = CFDataGetLength(data);
+ list->certs[i].pbData = ptr;
+ memcpy(list->certs[i].pbData, CFDataGetBytePtr(data), CFDataGetLength(data));
+ ptr += CFDataGetLength(data);
+ CFRelease(data);
}
+done:
#ifndef HAVE_SSLCOPYPEERCERTIFICATES
/* This is why SSLGetPeerCertificates was deprecated */
- CFArrayApplyFunction(cert_array, CFRangeMake(0, CFArrayGetCount(cert_array)),
- schan_imp_cf_release, NULL);
+ CFArrayApplyFunction(cert_array, CFRangeMake(0, CFArrayGetCount(cert_array)), cf_release, NULL);
#endif
CFRelease(cert_array);
- if (ret != SEC_E_OK) {
- if(cert)
- CertFreeCertificateContext(cert);
- return ret;
- }
-
- *ret_cert = cert;
- return SEC_E_OK;
+ return ret;
}
-SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer,
- SIZE_T *length)
+static SECURITY_STATUS CDECL schan_send(schan_session session, const void *buffer, SIZE_T *length)
{
struct mac_session* s = (struct mac_session*)session;
int status;
@@ -1152,8 +1163,7 @@ SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer,
return SEC_E_OK;
}
-SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer,
- SIZE_T *length)
+static SECURITY_STATUS CDECL schan_recv(schan_session session, void *buffer, SIZE_T *length)
{
struct mac_session* s = (struct mac_session*)session;
int status;
@@ -1189,36 +1199,37 @@ SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer,
return SEC_E_OK;
}
-BOOL schan_imp_allocate_certificate_credentials(schan_credentials *c, const CERT_CONTEXT *cert)
+static BOOL CDECL schan_allocate_certificate_credentials(schan_credentials *c, const CERT_CONTEXT *cert,
+ const DATA_BLOB *key_blob)
{
if (cert) FIXME("no support for certificate credentials on this platform\n");
c->credentials = NULL;
return TRUE;
}
-void schan_imp_free_certificate_credentials(schan_credentials *c)
+static void CDECL schan_free_certificate_credentials(schan_credentials *c)
{
}
-void schan_imp_set_application_protocols(schan_imp_session session, unsigned char *buffer, unsigned int buflen)
+static void CDECL schan_set_application_protocols(schan_session session, unsigned char *buffer, unsigned int buflen)
{
FIXME("no support for application protocols on this platform\n");
}
-SECURITY_STATUS schan_imp_get_application_protocol(schan_imp_session session,
- SecPkgContext_ApplicationProtocol *protocol)
+static SECURITY_STATUS CDECL schan_get_application_protocol(schan_session session,
+ SecPkgContext_ApplicationProtocol *protocol)
{
FIXME("no support for application protocols on this platform\n");
return SEC_E_UNSUPPORTED_FUNCTION;
}
-SECURITY_STATUS schan_imp_set_dtls_mtu(schan_imp_session session, unsigned int mtu)
+static SECURITY_STATUS CDECL schan_set_dtls_mtu(schan_session session, unsigned int mtu)
{
FIXME("no support for setting dtls mtu on this platform\n");
return SEC_E_UNSUPPORTED_FUNCTION;
}
-BOOL schan_imp_init(void)
+static void ssl_init(void)
{
TRACE("()\n");
@@ -1245,13 +1256,38 @@ BOOL schan_imp_init(void)
}
}
#endif
-
- return TRUE;
}
-void schan_imp_deinit(void)
+static const struct schan_funcs funcs =
{
- TRACE("()\n");
+ schan_allocate_certificate_credentials,
+ schan_create_session,
+ schan_dispose_session,
+ schan_free_certificate_credentials,
+ schan_get_application_protocol,
+ schan_get_connection_info,
+ schan_get_enabled_protocols,
+ schan_get_key_signature_algorithm,
+ schan_get_max_message_size,
+ schan_get_session_cipher_block_size,
+ schan_get_session_peer_certificate,
+ schan_get_unique_channel_binding,
+ schan_handshake,
+ schan_recv,
+ schan_send,
+ schan_set_application_protocols,
+ schan_set_dtls_mtu,
+ schan_set_session_target,
+ schan_set_session_transport,
+};
+
+NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
+{
+ if (reason != DLL_PROCESS_ATTACH) return STATUS_SUCCESS;
+ ssl_init();
+ callbacks = ptr_in;
+ *(const struct schan_funcs **)ptr_out = &funcs;
+ return STATUS_SUCCESS;
}
#endif /* HAVE_SECURITY_SECURITY_H */
diff --git a/dlls/secur32/secur32.c b/dlls/secur32/secur32.c
index 4382ec55174..04cb52dbec9 100644
--- a/dlls/secur32/secur32.c
+++ b/dlls/secur32/secur32.c
@@ -40,6 +40,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
+HINSTANCE hsecur32;
+
/**
* Type definitions
*/
@@ -1246,6 +1248,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
switch (reason)
{
case DLL_PROCESS_ATTACH:
+ hsecur32 = hinstDLL;
DisableThreadLibraryCalls(hinstDLL);
SECUR32_initializeProviders();
break;
diff --git a/dlls/secur32/secur32_priv.h b/dlls/secur32/secur32_priv.h
index 5571ac290e1..9d191fc4872 100644
--- a/dlls/secur32/secur32_priv.h
+++ b/dlls/secur32/secur32_priv.h
@@ -27,6 +27,8 @@
#include "wine/list.h"
#include "schannel.h"
+extern HINSTANCE hsecur32 DECLSPEC_HIDDEN;
+
typedef struct _SecureProvider
{
struct list entry;
@@ -83,7 +85,7 @@ void load_auth_packages(void) DECLSPEC_HIDDEN;
void SECUR32_deinitSchannelSP(void) DECLSPEC_HIDDEN;
/* schannel internal interface */
-typedef struct schan_imp_session_opaque *schan_imp_session;
+typedef struct schan_session_opaque *schan_session;
typedef struct schan_credentials
{
@@ -111,40 +113,43 @@ struct schan_transport
struct schan_buffers out;
};
-char *schan_get_buffer(const struct schan_transport *t, struct schan_buffers *s, SIZE_T *count) DECLSPEC_HIDDEN;
-extern int schan_pull(struct schan_transport *t, void *buff, size_t *buff_len) DECLSPEC_HIDDEN;
-extern int schan_push(struct schan_transport *t, const void *buff, size_t *buff_len) DECLSPEC_HIDDEN;
-
-extern schan_imp_session schan_session_for_transport(struct schan_transport* t) DECLSPEC_HIDDEN;
-
-/* schannel implementation interface */
-extern BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cred) DECLSPEC_HIDDEN;
-extern void schan_imp_dispose_session(schan_imp_session session) DECLSPEC_HIDDEN;
-extern void schan_imp_set_session_transport(schan_imp_session session,
- struct schan_transport *t) DECLSPEC_HIDDEN;
-extern void schan_imp_set_session_target(schan_imp_session session, const char *target) DECLSPEC_HIDDEN;
-extern SECURITY_STATUS schan_imp_handshake(schan_imp_session session) DECLSPEC_HIDDEN;
-extern unsigned int schan_imp_get_session_cipher_block_size(schan_imp_session session) DECLSPEC_HIDDEN;
-extern unsigned int schan_imp_get_max_message_size(schan_imp_session session) DECLSPEC_HIDDEN;
-extern ALG_ID schan_imp_get_key_signature_algorithm(schan_imp_session session) DECLSPEC_HIDDEN;
-extern SECURITY_STATUS schan_imp_get_connection_info(schan_imp_session session,
- SecPkgContext_ConnectionInfo *info) DECLSPEC_HIDDEN;
-extern SECURITY_STATUS schan_imp_get_unique_channel_binding(schan_imp_session session,
- SecPkgContext_Bindings *bindings) DECLSPEC_HIDDEN;
-extern SECURITY_STATUS schan_imp_get_session_peer_certificate(schan_imp_session session, HCERTSTORE,
- PCCERT_CONTEXT *cert) DECLSPEC_HIDDEN;
-extern SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer,
- SIZE_T *length) DECLSPEC_HIDDEN;
-extern SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer,
- SIZE_T *length) DECLSPEC_HIDDEN;
-extern BOOL schan_imp_allocate_certificate_credentials(schan_credentials *, const CERT_CONTEXT *) DECLSPEC_HIDDEN;
-extern void schan_imp_free_certificate_credentials(schan_credentials*) DECLSPEC_HIDDEN;
-extern DWORD schan_imp_enabled_protocols(void) DECLSPEC_HIDDEN;
-extern BOOL schan_imp_init(void) DECLSPEC_HIDDEN;
-extern void schan_imp_deinit(void) DECLSPEC_HIDDEN;
-extern void schan_imp_set_application_protocols(schan_imp_session, unsigned char *, unsigned int) DECLSPEC_HIDDEN;
-extern SECURITY_STATUS schan_imp_get_application_protocol(schan_imp_session,
- SecPkgContext_ApplicationProtocol *) DECLSPEC_HIDDEN;
-extern SECURITY_STATUS schan_imp_set_dtls_mtu(schan_imp_session, unsigned int) DECLSPEC_HIDDEN;
-
-#endif /* ndef __SECUR32_PRIV_H__ */
+struct schan_cert_list
+{
+ unsigned int count;
+ CERT_BLOB *certs;
+};
+
+struct schan_funcs
+{
+ BOOL (CDECL *allocate_certificate_credentials)(schan_credentials *, const CERT_CONTEXT *, const DATA_BLOB *);
+ BOOL (CDECL *create_session)(schan_session *, schan_credentials *);
+ void (CDECL *dispose_session)(schan_session);
+ void (CDECL *free_certificate_credentials)(schan_credentials *);
+ SECURITY_STATUS (CDECL *get_application_protocol)(schan_session, SecPkgContext_ApplicationProtocol *);
+ SECURITY_STATUS (CDECL *get_connection_info)(schan_session, SecPkgContext_ConnectionInfo *);
+ DWORD (CDECL *get_enabled_protocols)(void);
+ ALG_ID (CDECL *get_key_signature_algorithm)(schan_session);
+ unsigned int (CDECL *get_max_message_size)(schan_session);
+ unsigned int (CDECL *get_session_cipher_block_size)(schan_session);
+ SECURITY_STATUS (CDECL *get_session_peer_certificate)(schan_session, struct schan_cert_list *);
+ SECURITY_STATUS (CDECL *get_unique_channel_binding)(schan_session, SecPkgContext_Bindings *);
+ SECURITY_STATUS (CDECL *handshake)(schan_session session);
+ SECURITY_STATUS (CDECL *recv)(schan_session, void *, SIZE_T *);
+ SECURITY_STATUS (CDECL *send)(schan_session, const void *, SIZE_T *);
+ void (CDECL *set_application_protocols)(schan_session, unsigned char *, unsigned int);
+ SECURITY_STATUS (CDECL *set_dtls_mtu)(schan_session, unsigned int);
+ void (CDECL *set_session_target)(schan_session, const char *);
+ void (CDECL *set_session_transport)(schan_session, struct schan_transport *);
+};
+
+struct schan_callbacks
+{
+ char * (CDECL *get_buffer)(const struct schan_transport *, struct schan_buffers *, SIZE_T *);
+ schan_session (CDECL *get_session_for_transport)(struct schan_transport *);
+ int CDECL (CDECL *pull)(struct schan_transport *, void *, size_t *);
+ int CDECL (CDECL *push)(struct schan_transport *, const void *, size_t *);
+};
+
+extern const struct schan_funcs *schan_funcs;
+
+#endif /* __SECUR32_PRIV_H__ */
--
2.30.2
2
2
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/secur32/lsa.c | 56 ++++-----
dlls/secur32/negotiate.c | 41 ++++---
dlls/secur32/schannel.c | 64 +++++-----
dlls/secur32/secur32.c | 148 ++++++++---------------
dlls/secur32/secur32_priv.h | 8 +-
dlls/secur32/thunks.c | 235 ++++++++++++++++--------------------
dlls/secur32/wrapper.c | 40 +++---
7 files changed, 255 insertions(+), 337 deletions(-)
diff --git a/dlls/secur32/lsa.c b/dlls/secur32/lsa.c
index 6e586eb03c2..74eba65e10c 100644
--- a/dlls/secur32/lsa.c
+++ b/dlls/secur32/lsa.c
@@ -21,6 +21,7 @@
*/
#include <stdarg.h>
+#include <stdlib.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
@@ -32,9 +33,9 @@
#include "ntsecpkg.h"
#include "winternl.h"
#include "rpc.h"
-#include "secur32_priv.h"
#include "wine/debug.h"
+#include "secur32_priv.h"
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
@@ -91,7 +92,7 @@ NTSTATUS WINAPI LsaCallAuthenticationPackage(HANDLE lsa_handle, ULONG package_id
static struct lsa_connection *alloc_lsa_connection(void)
{
struct lsa_connection *ret;
- if (!(ret = heap_alloc(sizeof(*ret)))) return NULL;
+ if (!(ret = malloc(sizeof(*ret)))) return NULL;
ret->magic = LSA_MAGIC;
return ret;
}
@@ -127,7 +128,7 @@ NTSTATUS WINAPI LsaDeregisterLogonProcess(HANDLE LsaHandle)
if (!lsa_conn || lsa_conn->magic != LSA_MAGIC) return STATUS_INVALID_HANDLE;
lsa_conn->magic = 0;
- heap_free(lsa_conn);
+ free(lsa_conn);
return STATUS_SUCCESS;
}
@@ -145,7 +146,7 @@ NTSTATUS WINAPI LsaEnumerateLogonSessions(PULONG LogonSessionCount,
NTSTATUS WINAPI LsaFreeReturnBuffer(PVOID buffer)
{
TRACE("%p\n", buffer);
- heap_free(buffer);
+ free(buffer);
return STATUS_SUCCESS;
}
@@ -209,26 +210,26 @@ static NTSTATUS NTAPI lsa_DeleteCredential(LUID *logon_id, ULONG package_id, LSA
static void * NTAPI lsa_AllocateLsaHeap(ULONG size)
{
TRACE("%u\n", size);
- return heap_alloc(size);
+ return malloc(size);
}
static void NTAPI lsa_FreeLsaHeap(void *p)
{
TRACE("%p\n", p);
- heap_free(p);
+ free(p);
}
static NTSTATUS NTAPI lsa_AllocateClientBuffer(PLSA_CLIENT_REQUEST req, ULONG size, void **p)
{
TRACE("%p,%u,%p\n", req, size, p);
- *p = heap_alloc(size);
+ *p = malloc(size);
return *p ? STATUS_SUCCESS : STATUS_NO_MEMORY;
}
static NTSTATUS NTAPI lsa_FreeClientBuffer(PLSA_CLIENT_REQUEST req, void *p)
{
TRACE("%p,%p\n", req, p);
- heap_free(p);
+ free(p);
return STATUS_SUCCESS;
}
@@ -351,13 +352,13 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
if (principal)
{
int len = MultiByteToWideChar( CP_ACP, 0, principal, -1, NULL, 0 );
- if (!(principalW = heap_alloc( len * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(principalW = malloc( len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, principal, -1, principalW, len );
}
if (package)
{
int len = MultiByteToWideChar( CP_ACP, 0, package, -1, NULL, 0 );
- if (!(packageW = heap_alloc( len * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(packageW = malloc( len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, package, -1, packageW, len );
}
if (auth_data)
@@ -366,23 +367,23 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
if (id->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
{
- if (!(auth_dataW = heap_alloc( sizeof(SEC_WINNT_AUTH_IDENTITY_W) ))) goto done;
+ if (!(auth_dataW = malloc( sizeof(SEC_WINNT_AUTH_IDENTITY_W) ))) goto done;
if (id->UserLength)
{
len_user = MultiByteToWideChar( CP_ACP, 0, (char *)id->User, id->UserLength, NULL, 0 );
- if (!(user = heap_alloc( len_user * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(user = malloc( len_user * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (char *)id->User, id->UserLength, user, len_user );
}
if (id->DomainLength)
{
len_domain = MultiByteToWideChar( CP_ACP, 0, (char *)id->Domain, id->DomainLength, NULL, 0 );
- if (!(domain = heap_alloc( len_domain * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(domain = malloc( len_domain * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (char *)id->Domain, id->DomainLength, domain, len_domain );
}
if (id->PasswordLength)
{
len_passwd = MultiByteToWideChar( CP_ACP, 0, (char *)id->Password, id->PasswordLength, NULL, 0 );
- if (!(passwd = heap_alloc( len_passwd * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(passwd = malloc( len_passwd * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (char *)id->Password, id->PasswordLength, passwd, len_passwd );
}
auth_dataW->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
@@ -399,12 +400,12 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
status = lsa_AcquireCredentialsHandleW( principalW, packageW, credentials_use, logon_id, auth_dataW, get_key_fn,
get_key_arg, credential, ts_expiry );
done:
- if (auth_dataW != (SEC_WINNT_AUTH_IDENTITY_W *)id) heap_free( auth_dataW );
- heap_free( packageW );
- heap_free( principalW );
- heap_free( user );
- heap_free( domain );
- heap_free( passwd );
+ if (auth_dataW != (SEC_WINNT_AUTH_IDENTITY_W *)id) free( auth_dataW );
+ free( packageW );
+ free( principalW );
+ free( user );
+ free( domain );
+ free( passwd );
return status;
}
@@ -487,13 +488,13 @@ static SECURITY_STATUS WINAPI lsa_InitializeSecurityContextA(
if (target_name)
{
int len = MultiByteToWideChar( CP_ACP, 0, target_name, -1, NULL, 0 );
- if (!(targetW = heap_alloc( len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(targetW = malloc( len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar( CP_ACP, 0, target_name, -1, targetW, len );
}
status = lsa_InitializeSecurityContextW( credential, context, targetW, context_req, reserved1, target_data_rep,
input, reserved2, new_context, output, context_attr, ts_expiry );
- heap_free( targetW );
+ free( targetW );
return status;
}
@@ -583,7 +584,8 @@ static SecPkgInfoA *package_infoWtoA( const SecPkgInfoW *info )
int size_name = WideCharToMultiByte( CP_ACP, 0, info->Name, -1, NULL, 0, NULL, NULL );
int size_comment = WideCharToMultiByte( CP_ACP, 0, info->Comment, -1, NULL, 0, NULL, NULL );
- if (!(ret = heap_alloc( sizeof(*ret) + size_name + size_comment ))) return NULL;
+ /* freed with FreeContextBuffer */
+ if (!(ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*ret) + size_name + size_comment ))) return NULL;
ret->fCapabilities = info->fCapabilities;
ret->wVersion = info->wVersion;
ret->wRPCID = info->wRPCID;
@@ -801,9 +803,9 @@ static void add_package(struct lsa_package *package)
struct lsa_package *new_loaded_packages;
if (!loaded_packages)
- new_loaded_packages = heap_alloc(sizeof(*new_loaded_packages));
+ new_loaded_packages = malloc(sizeof(*new_loaded_packages));
else
- new_loaded_packages = heap_realloc(loaded_packages, sizeof(*new_loaded_packages) * (loaded_packages_count + 1));
+ new_loaded_packages = realloc(loaded_packages, sizeof(*new_loaded_packages) * (loaded_packages_count + 1));
if (new_loaded_packages)
{
@@ -904,7 +906,7 @@ void load_auth_packages(void)
{
SecPkgInfoW *info;
- info = heap_alloc(loaded_packages[i].lsa_table_count * sizeof(*info));
+ info = malloc(loaded_packages[i].lsa_table_count * sizeof(*info));
if (info)
{
NTSTATUS status;
@@ -913,7 +915,7 @@ void load_auth_packages(void)
if (status == STATUS_SUCCESS)
SECUR32_addPackages(provider, loaded_packages[i].lsa_table_count, NULL, info);
- heap_free(info);
+ free(info);
}
}
}
diff --git a/dlls/secur32/negotiate.c b/dlls/secur32/negotiate.c
index 6d45d0c5d54..498ef9ec35a 100644
--- a/dlls/secur32/negotiate.c
+++ b/dlls/secur32/negotiate.c
@@ -18,6 +18,7 @@
*/
#include <stdarg.h>
+#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "sspi.h"
@@ -78,7 +79,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
if (!pszPackage) return SEC_E_SECPKG_NOT_FOUND;
- if (!(cred = heap_alloc_zero( sizeof(*cred) ))) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(cred = calloc( 1, sizeof(*cred) ))) return SEC_E_INSUFFICIENT_MEMORY;
if ((package = SECUR32_findPackageW( kerberosW )))
{
@@ -103,7 +104,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
return SEC_E_OK;
}
- heap_free( cred );
+ free( cred );
return ret;
}
@@ -126,7 +127,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
if (pszPackage)
{
int package_len = MultiByteToWideChar( CP_ACP, 0, pszPackage, -1, NULL, 0 );
- if (!(package = heap_alloc( package_len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(package = malloc( package_len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar( CP_ACP, 0, pszPackage, -1, package, package_len );
}
if (pAuthData)
@@ -136,14 +137,14 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
if (identity->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
{
- if (!(identityW = heap_alloc( sizeof(*identityW) ))) goto done;
+ if (!(identityW = malloc( sizeof(*identityW) ))) goto done;
if (!identity->UserLength) user_len = 0;
else
{
user_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->User,
identity->UserLength, NULL, 0 );
- if (!(user = heap_alloc( user_len * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(user = malloc( user_len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->User, identity->UserLength,
user, user_len );
}
@@ -152,7 +153,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
{
domain_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Domain,
identity->DomainLength, NULL, 0 );
- if (!(domain = heap_alloc( domain_len * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(domain = malloc( domain_len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Domain, identity->DomainLength,
domain, domain_len );
}
@@ -161,7 +162,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
{
passwd_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Password,
identity->PasswordLength, NULL, 0 );
- if (!(passwd = heap_alloc( passwd_len * sizeof(SEC_WCHAR) ))) goto done;
+ if (!(passwd = malloc( passwd_len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Password, identity->PasswordLength,
passwd, passwd_len );
}
@@ -178,11 +179,11 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
ret = nego_AcquireCredentialsHandleW( NULL, package, fCredentialUse, pLogonID, identityW,
pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry );
done:
- heap_free( package );
- heap_free( user );
- heap_free( domain );
- heap_free( passwd );
- heap_free( identityW );
+ free( package );
+ free( user );
+ free( domain );
+ free( passwd );
+ free( identityW );
return ret;
}
@@ -210,7 +211,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
else if (phCredential)
{
handle = cred = (struct sec_handle *)phCredential->dwLower;
- if (!(new_ctxt = ctxt = heap_alloc_zero( sizeof(*ctxt) ))) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(new_ctxt = ctxt = calloc( 1, sizeof(*ctxt) ))) return SEC_E_INSUFFICIENT_MEMORY;
ctxt->krb = cred->krb;
ctxt->ntlm = cred->ntlm;
}
@@ -244,7 +245,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
}
}
- heap_free( new_ctxt );
+ free( new_ctxt );
return ret;
}
@@ -268,13 +269,13 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextA(
if (pszTargetName)
{
int target_len = MultiByteToWideChar( CP_ACP, 0, pszTargetName, -1, NULL, 0 );
- if (!(target = heap_alloc( target_len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(target = malloc( target_len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar( CP_ACP, 0, pszTargetName, -1, target, target_len );
}
ret = nego_InitializeSecurityContextW( phCredential, phContext, target, fContextReq,
Reserved1, TargetDataRep, pInput, Reserved2,
phNewContext, pOutput, pfContextAttr, ptsExpiry );
- heap_free( target );
+ free( target );
return ret;
}
@@ -300,7 +301,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
else if (phCredential)
{
handle = cred = (struct sec_handle *)phCredential->dwLower;
- if (!(new_ctxt = ctxt = heap_alloc_zero( sizeof(*ctxt) ))) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(new_ctxt = ctxt = calloc( 1, sizeof(*ctxt) ))) return SEC_E_INSUFFICIENT_MEMORY;
ctxt->krb = cred->krb;
ctxt->ntlm = cred->ntlm;
}
@@ -334,7 +335,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
}
}
- heap_free( new_ctxt );
+ free( new_ctxt );
return ret;
}
@@ -374,7 +375,7 @@ static SECURITY_STATUS SEC_ENTRY nego_DeleteSecurityContext(PCtxtHandle phContex
ret = ctxt->ntlm->fnTableW.DeleteSecurityContext( &ctxt->handle_ntlm );
}
TRACE( "freeing %p\n", ctxt );
- heap_free( ctxt );
+ free( ctxt );
return ret;
}
@@ -533,7 +534,7 @@ static SECURITY_STATUS SEC_ENTRY nego_FreeCredentialsHandle(PCredHandle phCreden
if (cred->krb) cred->krb->fnTableW.FreeCredentialsHandle( &cred->handle_krb );
if (cred->ntlm) cred->ntlm->fnTableW.FreeCredentialsHandle( &cred->handle_ntlm );
- heap_free( cred );
+ free( cred );
return SEC_E_OK;
}
diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c
index 9d092f109fe..50a1c848c0e 100644
--- a/dlls/secur32/schannel.c
+++ b/dlls/secur32/schannel.c
@@ -20,6 +20,7 @@
#include <assert.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <errno.h>
#define NONAMELESSUNION
@@ -98,7 +99,7 @@ static ULONG_PTR schan_alloc_handle(void *object, enum schan_handle_type type)
{
/* Grow the table */
SIZE_T new_size = schan_handle_table_size + (schan_handle_table_size >> 1);
- struct schan_handle *new_table = heap_realloc(schan_handle_table, new_size * sizeof(*schan_handle_table));
+ struct schan_handle *new_table = realloc(schan_handle_table, new_size * sizeof(*schan_handle_table));
if (!new_table)
{
ERR("Failed to grow the handle table\n");
@@ -521,7 +522,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
return SEC_E_NO_AUTHENTICATING_AUTHORITY;
}
- if (!(creds = heap_alloc(sizeof(*creds)))) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(creds = malloc(sizeof(*creds)))) return SEC_E_INSUFFICIENT_MEMORY;
creds->credential_use = SECPKG_CRED_OUTBOUND;
creds->enabled_protocols = enabled_protocols;
@@ -545,7 +546,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
return status;
fail:
- heap_free(creds);
+ free(creds);
RtlFreeHeap(GetProcessHeap(), 0, key_blob.pbData);
return SEC_E_INTERNAL_ERROR;
}
@@ -566,14 +567,13 @@ static SECURITY_STATUS schan_AcquireServerCredentials(const SCHANNEL_CRED *schan
ULONG_PTR handle;
struct schan_credentials *creds;
- creds = heap_alloc_zero(sizeof(*creds));
- if (!creds) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(creds = calloc(1, sizeof(*creds)))) return SEC_E_INSUFFICIENT_MEMORY;
creds->credential_use = SECPKG_CRED_INBOUND;
handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED);
if (handle == SCHAN_INVALID_HANDLE)
{
- heap_free(creds);
+ free(creds);
return SEC_E_INTERNAL_ERROR;
}
@@ -636,7 +636,7 @@ static SECURITY_STATUS SEC_ENTRY schan_FreeCredentialsHandle(
if (!creds) return SEC_E_INVALID_HANDLE;
if (creds->credential_use == SECPKG_CRED_OUTBOUND) schan_funcs->free_certificate_credentials(creds);
- heap_free(creds);
+ free(creds);
return SEC_E_OK;
}
@@ -675,10 +675,10 @@ static void schan_resize_current_buffer(const struct schan_buffers *s, SIZE_T mi
while (new_size < min_size) new_size *= 2;
- if (b->pvBuffer)
- new_data = heap_realloc(b->pvBuffer, new_size);
+ if (b->pvBuffer) /* freed with FreeContextBuffer */
+ new_data = RtlReAllocateHeap(GetProcessHeap(), 0, b->pvBuffer, new_size);
else
- new_data = heap_alloc(new_size);
+ new_data = RtlAllocateHeap(GetProcessHeap(), 0, new_size);
if (!new_data)
{
@@ -925,21 +925,20 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
return SEC_E_INVALID_HANDLE;
}
- ctx = heap_alloc(sizeof(*ctx));
- if (!ctx) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(ctx = malloc(sizeof(*ctx)))) return SEC_E_INSUFFICIENT_MEMORY;
ctx->cert = NULL;
handle = schan_alloc_handle(ctx, SCHAN_HANDLE_CTX);
if (handle == SCHAN_INVALID_HANDLE)
{
- heap_free(ctx);
+ free(ctx);
return SEC_E_INTERNAL_ERROR;
}
if (!schan_funcs->create_session(&ctx->session, cred))
{
schan_free_handle(handle, SCHAN_HANDLE_CTX);
- heap_free(ctx);
+ free(ctx);
return SEC_E_INTERNAL_ERROR;
}
@@ -954,13 +953,13 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
if (pszTargetName && *pszTargetName)
{
UINT len = WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, NULL, 0, NULL, NULL );
- char *target = heap_alloc( len );
+ char *target = malloc( len );
if (target)
{
WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, target, len, NULL, NULL );
schan_funcs->set_session_target( ctx->session, target );
- heap_free( target );
+ free( target );
}
}
@@ -1077,7 +1076,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA(
if (pszTargetName)
{
INT len = MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, NULL, 0);
- if (!(target_name = heap_alloc(len * sizeof(*target_name)))) return SEC_E_INSUFFICIENT_MEMORY;
+ if (!(target_name = malloc(len * sizeof(*target_name)))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, target_name, len);
}
@@ -1085,7 +1084,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA(
fContextReq, Reserved1, TargetDataRep, pInput, Reserved2,
phNewContext, pOutput, pfContextAttr, ptsExpiry);
- heap_free(target_name);
+ free(target_name);
return ret;
}
@@ -1244,7 +1243,8 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
return GetLastError();
bindings->BindingsLength = sizeof(*bindings->Bindings) + sizeof(prefix)-1 + hash_size;
- bindings->Bindings = heap_alloc_zero(bindings->BindingsLength);
+ /* freed with FreeContextBuffer */
+ bindings->Bindings = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, bindings->BindingsLength);
if(!bindings->Bindings)
return SEC_E_INSUFFICIENT_MEMORY;
@@ -1386,7 +1386,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle
buffer = &message->pBuffers[idx];
data_size = buffer->cbBuffer;
- data = heap_alloc(data_size);
+ data = malloc(data_size);
memcpy(data, buffer->pvBuffer, data_size);
if (schan_find_sec_buffer_idx(message, 0, SECBUFFER_STREAM_HEADER) != -1)
@@ -1404,7 +1404,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle
b = &ctx->transport.out;
b->desc->pBuffers[b->current_buffer_idx].cbBuffer = b->offset;
- heap_free(data);
+ free(data);
TRACE("Returning %#x.\n", status);
@@ -1520,7 +1520,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
}
data_size = expected_size - ctx->header_size;
- data = heap_alloc(data_size);
+ data = malloc(data_size);
init_schan_buffers(&ctx->transport.in, message, schan_decrypt_message_get_next_buffer);
ctx->transport.in.limit = expected_size;
@@ -1541,7 +1541,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
if (status != SEC_E_OK)
{
- heap_free(data);
+ free(data);
ERR("Returning %x\n", status);
return status;
}
@@ -1555,7 +1555,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
TRACE("Received %ld bytes\n", received);
memcpy(buf_ptr + ctx->header_size, data, received);
- heap_free(data);
+ free(data);
schan_decrypt_fill_buffer(message, SECBUFFER_DATA,
buf_ptr + ctx->header_size, received);
@@ -1586,7 +1586,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DeleteSecurityContext(PCtxtHandle context
if (ctx->cert) CertFreeCertificateContext(ctx->cert);
schan_funcs->dispose_session(ctx->session);
- heap_free(ctx);
+ free(ctx);
return SEC_E_OK;
}
@@ -1597,7 +1597,7 @@ static const SecurityFunctionTableA schanTableA = {
schan_AcquireCredentialsHandleA,
schan_FreeCredentialsHandle,
NULL, /* Reserved2 */
- schan_InitializeSecurityContextA,
+ schan_InitializeSecurityContextA,
NULL, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
schan_DeleteSecurityContext,
@@ -1628,7 +1628,7 @@ static const SecurityFunctionTableW schanTableW = {
schan_AcquireCredentialsHandleW,
schan_FreeCredentialsHandle,
NULL, /* Reserved2 */
- schan_InitializeSecurityContextW,
+ schan_InitializeSecurityContextW,
NULL, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
schan_DeleteSecurityContext,
@@ -1691,7 +1691,7 @@ void SECUR32_initSchannelSP(void)
return;
}
- schan_handle_table = heap_alloc(64 * sizeof(*schan_handle_table));
+ schan_handle_table = malloc(64 * sizeof(*schan_handle_table));
if (!schan_handle_table)
{
ERR("Failed to allocate schannel handle table.\n");
@@ -1710,7 +1710,7 @@ void SECUR32_initSchannelSP(void)
return;
fail:
- heap_free(schan_handle_table);
+ free(schan_handle_table);
schan_handle_table = NULL;
return;
}
@@ -1729,7 +1729,7 @@ void SECUR32_deinitSchannelSP(void)
{
struct schan_context *ctx = schan_free_handle(i, SCHAN_HANDLE_CTX);
schan_funcs->dispose_session(ctx->session);
- heap_free(ctx);
+ free(ctx);
}
}
i = schan_handle_count;
@@ -1740,10 +1740,10 @@ void SECUR32_deinitSchannelSP(void)
struct schan_credentials *cred;
cred = schan_free_handle(i, SCHAN_HANDLE_CRED);
schan_funcs->free_certificate_credentials(cred);
- heap_free(cred);
+ free(cred);
}
}
- heap_free(schan_handle_table);
+ free(schan_handle_table);
__wine_init_unix_lib(hsecur32, DLL_PROCESS_DETACH, NULL, NULL);
schan_funcs = NULL;
diff --git a/dlls/secur32/secur32.c b/dlls/secur32/secur32.c
index fda7d7ef865..08bac24686a 100644
--- a/dlls/secur32/secur32.c
+++ b/dlls/secur32/secur32.c
@@ -174,56 +174,10 @@ PSecurityFunctionTableW WINAPI InitSecurityInterfaceW(void)
return &securityFunctionTableW;
}
-static WCHAR *SECUR32_strdupW(const WCHAR *str)
+static WCHAR *strdupW( const WCHAR *str )
{
WCHAR *ret = NULL;
- if (str && (ret = heap_alloc((wcslen(str) + 1) * sizeof(WCHAR)))) wcscpy(ret, str);
- return ret;
-}
-
-PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str)
-{
- PWSTR ret;
-
- if (str)
- {
- int charsNeeded = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
-
- if (charsNeeded)
- {
- ret = heap_alloc(charsNeeded * sizeof(WCHAR));
- if (ret)
- MultiByteToWideChar(CP_ACP, 0, str, -1, ret, charsNeeded);
- }
- else
- ret = NULL;
- }
- else
- ret = NULL;
- return ret;
-}
-
-PSTR SECUR32_AllocMultiByteFromWide(PCWSTR str)
-{
- PSTR ret;
-
- if (str)
- {
- int charsNeeded = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0,
- NULL, NULL);
-
- if (charsNeeded)
- {
- ret = heap_alloc(charsNeeded);
- if (ret)
- WideCharToMultiByte(CP_ACP, 0, str, -1, ret, charsNeeded,
- NULL, NULL);
- }
- else
- ret = NULL;
- }
- else
- ret = NULL;
+ if (str && (ret = malloc( (wcslen(str) + 1) * sizeof(WCHAR) ))) wcscpy( ret, str );
return ret;
}
@@ -369,6 +323,17 @@ static void _makeFnTableW(PSecurityFunctionTableW fnTableW,
}
}
+static WCHAR *strdupAW( const char *str )
+{
+ WCHAR *ret = NULL;
+ if (str)
+ {
+ int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
+ if ((ret = malloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
+ }
+ return ret;
+}
+
static void _copyPackageInfo(PSecPkgInfoW info, const SecPkgInfoA *inInfoA,
const SecPkgInfoW *inInfoW)
{
@@ -380,13 +345,13 @@ static void _copyPackageInfo(PSecPkgInfoW info, const SecPkgInfoA *inInfoA,
memcpy(info, inInfoW ? inInfoW : (const SecPkgInfoW *)inInfoA, sizeof(*info));
if (inInfoW)
{
- info->Name = SECUR32_strdupW(inInfoW->Name);
- info->Comment = SECUR32_strdupW(inInfoW->Comment);
+ info->Name = strdupW(inInfoW->Name);
+ info->Comment = strdupW(inInfoW->Comment);
}
else
{
- info->Name = SECUR32_AllocWideFromMultiByte(inInfoA->Name);
- info->Comment = SECUR32_AllocWideFromMultiByte(inInfoA->Comment);
+ info->Name = strdupAW(inInfoA->Name);
+ info->Comment = strdupAW(inInfoA->Comment);
}
}
}
@@ -400,8 +365,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
if (!providerTable)
{
- providerTable = heap_alloc(sizeof(SecureProviderTable));
- if (!providerTable)
+ if (!(providerTable = malloc(sizeof(*ret))))
{
LeaveCriticalSection(&cs);
return NULL;
@@ -410,8 +374,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
list_init(&providerTable->table);
}
- ret = heap_alloc(sizeof(SecureProvider));
- if (!ret)
+ if (!(ret = malloc(sizeof(*ret))))
{
LeaveCriticalSection(&cs);
return NULL;
@@ -422,17 +385,17 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
if (fnTableA || fnTableW)
{
- ret->moduleName = moduleName ? SECUR32_strdupW(moduleName) : NULL;
+ ret->moduleName = moduleName ? strdupW(moduleName) : NULL;
_makeFnTableA(&ret->fnTableA, fnTableA, fnTableW);
_makeFnTableW(&ret->fnTableW, fnTableA, fnTableW);
ret->loaded = !moduleName;
}
else
{
- ret->moduleName = SECUR32_strdupW(moduleName);
+ ret->moduleName = strdupW(moduleName);
ret->loaded = FALSE;
}
-
+
LeaveCriticalSection(&cs);
return ret;
}
@@ -449,8 +412,7 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
if (!packageTable)
{
- packageTable = heap_alloc(sizeof(SecurePackageTable));
- if (!packageTable)
+ if (!(packageTable = malloc(sizeof(*packageTable))))
{
LeaveCriticalSection(&cs);
return;
@@ -459,19 +421,17 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
packageTable->numPackages = 0;
list_init(&packageTable->table);
}
-
+
for (i = 0; i < toAdd; i++)
{
- SecurePackage *package = heap_alloc(sizeof(SecurePackage));
- if (!package)
- continue;
+ SecurePackage *package;
+
+ if (!(package = malloc(sizeof(*package)))) continue;
list_add_tail(&packageTable->table, &package->entry);
package->provider = provider;
- _copyPackageInfo(&package->infoW,
- infoA ? &infoA[i] : NULL,
- infoW ? &infoW[i] : NULL);
+ _copyPackageInfo(&package->infoW, infoA ? &infoA[i] : NULL, infoW ? &infoW[i] : NULL);
}
packageTable->numPackages += toAdd;
@@ -599,14 +559,11 @@ SecurePackage *SECUR32_findPackageW(PCWSTR packageName)
LIST_FOR_EACH_ENTRY(ret, &packageTable->table, SecurePackage, entry)
{
matched = !lstrcmpiW(ret->infoW.Name, packageName);
- if (matched)
- break;
+ if (matched) break;
}
-
- if (!matched)
- return NULL;
+ if (!matched) return NULL;
- if (ret->provider && !ret->provider->loaded)
+ if (ret->provider && !ret->provider->loaded)
{
ret->provider->lib = LoadLibraryW(ret->provider->moduleName);
if (ret->provider->lib)
@@ -668,28 +625,26 @@ static void SECUR32_freeProviders(void)
LIST_FOR_EACH_ENTRY_SAFE(package, package_next, &packageTable->table,
SecurePackage, entry)
{
- heap_free(package->infoW.Name);
- heap_free(package->infoW.Comment);
- heap_free(package);
+ free(package->infoW.Name);
+ free(package->infoW.Comment);
+ free(package);
}
- heap_free(packageTable);
+ free(packageTable);
packageTable = NULL;
}
if (providerTable)
{
SecureProvider *provider, *provider_next;
- LIST_FOR_EACH_ENTRY_SAFE(provider, provider_next, &providerTable->table,
- SecureProvider, entry)
+ LIST_FOR_EACH_ENTRY_SAFE(provider, provider_next, &providerTable->table, SecureProvider, entry)
{
- heap_free(provider->moduleName);
- if (provider->lib)
- FreeLibrary(provider->lib);
- heap_free(provider);
+ free(provider->moduleName);
+ if (provider->lib) FreeLibrary(provider->lib);
+ free(provider);
}
- heap_free(providerTable);
+ free(providerTable);
providerTable = NULL;
}
@@ -704,9 +659,9 @@ static void SECUR32_freeProviders(void)
* The sample ssp seems to use LocalAlloc/LocalFee, but there doesn't seem to
* be any guarantee, nor is there an alloc function in secur32.
*/
-SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
+SECURITY_STATUS WINAPI FreeContextBuffer( void *pv )
{
- heap_free(pv);
+ RtlFreeHeap( GetProcessHeap(), 0, pv );
return SEC_E_OK;
}
@@ -738,8 +693,8 @@ SECURITY_STATUS WINAPI EnumerateSecurityPackagesW(PULONG pcPackages,
}
if (bytesNeeded)
{
- *ppPackageInfo = heap_alloc(bytesNeeded);
- if (*ppPackageInfo)
+ /* freed with FeeContextBuffer */
+ if ((*ppPackageInfo = RtlAllocateHeap(GetProcessHeap(), 0, bytesNeeded)))
{
ULONG i = 0;
PWSTR nextString;
@@ -803,8 +758,8 @@ static PSecPkgInfoA thunk_PSecPkgInfoWToA(ULONG cPackages,
bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info[i].Comment,
-1, NULL, 0, NULL, NULL);
}
- ret = heap_alloc(bytesNeeded);
- if (ret)
+ /* freed with FreeContextBuffer */
+ if ((ret = RtlAllocateHeap(GetProcessHeap(), 0, bytesNeeded)))
{
PSTR nextString;
@@ -895,7 +850,7 @@ SECURITY_STATUS WINAPI EnumerateSecurityPackagesA(PULONG pcPackages,
* nSize returns the number of characters written when lpNameBuffer is not
* NULL or the size of the buffer needed to hold the name when the buffer
* is too short or lpNameBuffer is NULL.
- *
+ *
* It the buffer is too short, ERROR_INSUFFICIENT_BUFFER error will be set.
*/
BOOLEAN WINAPI GetComputerObjectNameA(
@@ -908,8 +863,7 @@ BOOLEAN WINAPI GetComputerObjectNameA(
TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
if (lpNameBuffer) {
- bufferW = heap_alloc(sizeW * sizeof(WCHAR));
- if (bufferW == NULL) {
+ if (!(bufferW = malloc(sizeW * sizeof(WCHAR)))) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
@@ -922,7 +876,7 @@ BOOLEAN WINAPI GetComputerObjectNameA(
}
else
*nSize = sizeW;
- heap_free(bufferW);
+ free(bufferW);
return rc;
}
@@ -1115,7 +1069,7 @@ BOOLEAN WINAPI GetUserNameExA(
ULONG sizeW = *nSize;
TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
if (lpNameBuffer) {
- bufferW = heap_alloc(sizeW * sizeof(WCHAR));
+ bufferW = malloc(sizeW * sizeof(WCHAR));
if (bufferW == NULL) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
@@ -1138,7 +1092,7 @@ BOOLEAN WINAPI GetUserNameExA(
}
else
*nSize = sizeW;
- heap_free(bufferW);
+ free(bufferW);
return rc;
}
diff --git a/dlls/secur32/secur32_priv.h b/dlls/secur32/secur32_priv.h
index 9d191fc4872..75c6cde2e42 100644
--- a/dlls/secur32/secur32_priv.h
+++ b/dlls/secur32/secur32_priv.h
@@ -23,9 +23,8 @@
#include <sys/types.h>
#include <limits.h>
-#include "wine/heap.h"
-#include "wine/list.h"
#include "schannel.h"
+#include "wine/list.h"
extern HINSTANCE hsecur32 DECLSPEC_HIDDEN;
@@ -71,11 +70,6 @@ SecurePackage *SECUR32_findPackageW(PCWSTR packageName) DECLSPEC_HIDDEN;
*/
SecurePackage *SECUR32_findPackageA(PCSTR packageName) DECLSPEC_HIDDEN;
-/* A few string helpers; will return NULL if str is NULL. Free return with
- * HeapFree */
-PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str) DECLSPEC_HIDDEN;
-PSTR SECUR32_AllocMultiByteFromWide(PCWSTR str) DECLSPEC_HIDDEN;
-
/* Initialization functions for built-in providers */
void SECUR32_initSchannelSP(void) DECLSPEC_HIDDEN;
void SECUR32_initNegotiateSP(void) DECLSPEC_HIDDEN;
diff --git a/dlls/secur32/thunks.c b/dlls/secur32/thunks.c
index 7a59c4ee3ca..7087696ca35 100644
--- a/dlls/secur32/thunks.c
+++ b/dlls/secur32/thunks.c
@@ -58,6 +58,18 @@ SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleA(
return ret;
}
+static char *strdupWA( const WCHAR *str )
+{
+ char *ret = NULL;
+ if (str)
+ {
+ int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
+ if ((ret = RtlAllocateHeap( GetProcessHeap(), 0, len )))
+ WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
+ }
+ return ret;
+}
+
SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleW(
SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse,
PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
@@ -70,15 +82,14 @@ SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleW(
pvGetKeyArgument, phCredential, ptsExpiry);
if (pszPackage)
{
- PSTR principal, package;
+ char *principal, *package;
- principal = SECUR32_AllocMultiByteFromWide(pszPrincipal);
- package = SECUR32_AllocMultiByteFromWide(pszPackage);
+ principal = strdupWA(pszPrincipal);
+ package = strdupWA(pszPackage);
ret = AcquireCredentialsHandleA(principal, package, fCredentialsUse,
- pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential,
- ptsExpiry);
- heap_free(principal);
- heap_free(package);
+ pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, ptsExpiry);
+ RtlFreeHeap(GetProcessHeap(), 0, principal);
+ RtlFreeHeap(GetProcessHeap(), 0, package);
}
else
ret = SEC_E_SECPKG_NOT_FOUND;
@@ -103,24 +114,20 @@ SECURITY_STATUS SEC_ENTRY thunk_QueryCredentialsAttributesA(
{
if (package->provider->fnTableW.QueryCredentialsAttributesW)
{
- ret = package->provider->fnTableW.QueryCredentialsAttributesW(
- cred, ulAttribute, pBuffer);
+ ret = package->provider->fnTableW.QueryCredentialsAttributesW( cred, ulAttribute, pBuffer);
if (ret == SEC_E_OK)
{
switch (ulAttribute)
{
case SECPKG_CRED_ATTR_NAMES:
{
- PSecPkgCredentials_NamesW names =
- (PSecPkgCredentials_NamesW)pBuffer;
+ PSecPkgCredentials_NamesW names = (PSecPkgCredentials_NamesW)pBuffer;
SEC_WCHAR *oldUser = names->sUserName;
if (oldUser)
{
- names->sUserName =
- (PWSTR)SECUR32_AllocMultiByteFromWide(oldUser);
- package->provider->fnTableW.FreeContextBuffer(
- oldUser);
+ names->sUserName = (WCHAR *)strdupWA(oldUser);
+ package->provider->fnTableW.FreeContextBuffer(oldUser);
}
break;
}
@@ -141,6 +148,18 @@ SECURITY_STATUS SEC_ENTRY thunk_QueryCredentialsAttributesA(
return ret;
}
+static WCHAR *strdupAW( const char *str )
+{
+ WCHAR *ret = NULL;
+ if (str)
+ {
+ int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
+ if ((ret = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
+ MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
+ }
+ return ret;
+}
+
SECURITY_STATUS SEC_ENTRY thunk_QueryCredentialsAttributesW(
PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
{
@@ -156,24 +175,20 @@ SECURITY_STATUS SEC_ENTRY thunk_QueryCredentialsAttributesW(
{
if (package->provider->fnTableA.QueryCredentialsAttributesA)
{
- ret = package->provider->fnTableA.QueryCredentialsAttributesA(
- cred, ulAttribute, pBuffer);
+ ret = package->provider->fnTableA.QueryCredentialsAttributesA(cred, ulAttribute, pBuffer);
if (ret == SEC_E_OK)
{
switch (ulAttribute)
{
case SECPKG_CRED_ATTR_NAMES:
{
- PSecPkgCredentials_NamesA names =
- (PSecPkgCredentials_NamesA)pBuffer;
+ PSecPkgCredentials_NamesA names = (PSecPkgCredentials_NamesA)pBuffer;
SEC_CHAR *oldUser = names->sUserName;
if (oldUser)
{
- names->sUserName =
- (PSTR)SECUR32_AllocWideFromMultiByte(oldUser);
- package->provider->fnTableA.FreeContextBuffer(
- oldUser);
+ names->sUserName = (char *)strdupAW(oldUser);
+ package->provider->fnTableA.FreeContextBuffer(oldUser);
}
break;
}
@@ -254,13 +269,13 @@ SECURITY_STATUS SEC_ENTRY thunk_InitializeSecurityContextW(
{
if (package->provider->fnTableA.InitializeSecurityContextA)
{
- PSTR target = SECUR32_AllocMultiByteFromWide(pszTargetName);
+ char *target = strdupWA(pszTargetName);
ret = package->provider->fnTableA.InitializeSecurityContextA(
phCredential, phContext, target, fContextReq, Reserved1,
TargetDataRep, pInput, Reserved2, phNewContext, pOutput,
pfContextAttr, ptsExpiry);
- heap_free(target);
+ RtlFreeHeap(GetProcessHeap(), 0, target);
}
else
ret = SEC_E_UNSUPPORTED_FUNCTION;
@@ -332,14 +347,14 @@ SECURITY_STATUS SEC_ENTRY thunk_AddCredentialsW(PCredHandle hCredentials,
{
if (package->provider->fnTableA.AddCredentialsA)
{
- PSTR szPrincipal = SECUR32_AllocMultiByteFromWide(pszPrincipal);
- PSTR szPackage = SECUR32_AllocMultiByteFromWide(pszPackage);
+ char *szPrincipal = strdupWA(pszPrincipal);
+ char *szPackage = strdupWA(pszPackage);
ret = package->provider->fnTableA.AddCredentialsA(
cred, szPrincipal, szPackage, fCredentialUse, pAuthData,
pGetKeyFn, pvGetKeyArgument, ptsExpiry);
- heap_free(szPrincipal);
- heap_free(szPackage);
+ RtlFreeHeap(GetProcessHeap(), 0, szPrincipal);
+ RtlFreeHeap(GetProcessHeap(), 0, szPackage);
}
else
ret = SEC_E_UNSUPPORTED_FUNCTION;
@@ -373,17 +388,15 @@ static PSecPkgInfoA _copyPackageInfoFlatWToA(const SecPkgInfoW *infoW)
NULL, 0, NULL, NULL);
bytesNeeded += commentLen;
}
- ret = heap_alloc(bytesNeeded);
- if (ret)
+ if ((ret = RtlAllocateHeap(GetProcessHeap(), 0, bytesNeeded)))
{
- PSTR nextString = (PSTR)((PBYTE)ret + sizeof(SecPkgInfoA));
+ char *nextString = (char *)ret + sizeof(SecPkgInfoA);
memcpy(ret, infoW, sizeof(SecPkgInfoA));
if (infoW->Name)
{
ret->Name = nextString;
- WideCharToMultiByte(CP_ACP, 0, infoW->Name, -1, nextString,
- nameLen, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, infoW->Name, -1, nextString, nameLen, NULL, NULL);
nextString += nameLen;
}
else
@@ -391,8 +404,7 @@ static PSecPkgInfoA _copyPackageInfoFlatWToA(const SecPkgInfoW *infoW)
if (infoW->Comment)
{
ret->Comment = nextString;
- WideCharToMultiByte(CP_ACP, 0, infoW->Comment, -1, nextString,
- nameLen, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, infoW->Comment, -1, nextString, nameLen, NULL, NULL);
}
else
ret->Comment = NULL;
@@ -419,22 +431,19 @@ static SECURITY_STATUS thunk_ContextAttributesWToA(SecurePackage *package,
if (oldUser)
{
- names->sUserName =
- (PWSTR)SECUR32_AllocMultiByteFromWide(oldUser);
+ names->sUserName = (WCHAR *)strdupWA(oldUser);
package->provider->fnTableW.FreeContextBuffer(oldUser);
}
break;
}
case SECPKG_ATTR_AUTHORITY:
{
- PSecPkgContext_AuthorityW names =
- (PSecPkgContext_AuthorityW)pBuffer;
+ PSecPkgContext_AuthorityW names = (PSecPkgContext_AuthorityW)pBuffer;
SEC_WCHAR *oldAuth = names->sAuthorityName;
if (oldAuth)
{
- names->sAuthorityName =
- (PWSTR)SECUR32_AllocMultiByteFromWide(oldAuth);
+ names->sAuthorityName = (WCHAR *)strdupWA(oldAuth);
package->provider->fnTableW.FreeContextBuffer(oldAuth);
}
break;
@@ -447,24 +456,19 @@ static SECURITY_STATUS thunk_ContextAttributesWToA(SecurePackage *package,
if (oldSigAlgName)
{
- info->sSignatureAlgorithmName =
- (PWSTR)SECUR32_AllocMultiByteFromWide(oldSigAlgName);
- package->provider->fnTableW.FreeContextBuffer(
- oldSigAlgName);
+ info->sSignatureAlgorithmName = (WCHAR *)strdupWA(oldSigAlgName);
+ package->provider->fnTableW.FreeContextBuffer(oldSigAlgName);
}
if (oldEncAlgName)
{
- info->sEncryptAlgorithmName =
- (PWSTR)SECUR32_AllocMultiByteFromWide(oldEncAlgName);
- package->provider->fnTableW.FreeContextBuffer(
- oldEncAlgName);
+ info->sEncryptAlgorithmName = (WCHAR *)strdupWA(oldEncAlgName);
+ package->provider->fnTableW.FreeContextBuffer(oldEncAlgName);
}
break;
}
case SECPKG_ATTR_PACKAGE_INFO:
{
- PSecPkgContext_PackageInfoW info =
- (PSecPkgContext_PackageInfoW)pBuffer;
+ PSecPkgContext_PackageInfoW info = (PSecPkgContext_PackageInfoW)pBuffer;
PSecPkgInfoW oldPkgInfo = info->PackageInfo;
if (oldPkgInfo)
@@ -477,8 +481,7 @@ static SECURITY_STATUS thunk_ContextAttributesWToA(SecurePackage *package,
}
case SECPKG_ATTR_NEGOTIATION_INFO:
{
- PSecPkgContext_NegotiationInfoW info =
- (PSecPkgContext_NegotiationInfoW)pBuffer;
+ PSecPkgContext_NegotiationInfoW info = (PSecPkgContext_NegotiationInfoW)pBuffer;
PSecPkgInfoW oldPkgInfo = info->PackageInfo;
if (oldPkgInfo)
@@ -491,35 +494,30 @@ static SECURITY_STATUS thunk_ContextAttributesWToA(SecurePackage *package,
}
case SECPKG_ATTR_NATIVE_NAMES:
{
- PSecPkgContext_NativeNamesW names =
- (PSecPkgContext_NativeNamesW)pBuffer;
- PWSTR oldClient = names->sClientName;
- PWSTR oldServer = names->sServerName;
+ PSecPkgContext_NativeNamesW names = (PSecPkgContext_NativeNamesW)pBuffer;
+ WCHAR *oldClient = names->sClientName;
+ WCHAR *oldServer = names->sServerName;
if (oldClient)
{
- names->sClientName = (PWSTR)SECUR32_AllocMultiByteFromWide(
- oldClient);
+ names->sClientName = (WCHAR *)strdupWA(oldClient);
package->provider->fnTableW.FreeContextBuffer(oldClient);
}
if (oldServer)
{
- names->sServerName = (PWSTR)SECUR32_AllocMultiByteFromWide(
- oldServer);
+ names->sServerName = (WCHAR *)strdupWA(oldServer);
package->provider->fnTableW.FreeContextBuffer(oldServer);
}
break;
}
case SECPKG_ATTR_CREDENTIAL_NAME:
{
- PSecPkgContext_CredentialNameW name =
- (PSecPkgContext_CredentialNameW)pBuffer;
- PWSTR oldCred = name->sCredentialName;
+ PSecPkgContext_CredentialNameW name = (PSecPkgContext_CredentialNameW)pBuffer;
+ WCHAR *oldCred = name->sCredentialName;
if (oldCred)
{
- name->sCredentialName =
- (PWSTR)SECUR32_AllocMultiByteFromWide(oldCred);
+ name->sCredentialName = (WCHAR *)strdupWA(oldCred);
package->provider->fnTableW.FreeContextBuffer(oldCred);
}
break;
@@ -560,11 +558,9 @@ SECURITY_STATUS SEC_ENTRY thunk_QueryContextAttributesA(PCtxtHandle phContext,
{
if (package->provider->fnTableW.QueryContextAttributesW)
{
- ret = package->provider->fnTableW.QueryContextAttributesW(
- ctxt, ulAttribute, pBuffer);
+ ret = package->provider->fnTableW.QueryContextAttributesW( ctxt, ulAttribute, pBuffer);
if (ret == SEC_E_OK)
- ret = thunk_ContextAttributesWToA(package, ulAttribute,
- pBuffer);
+ ret = thunk_ContextAttributesWToA(package, ulAttribute, pBuffer);
}
else
ret = SEC_E_UNSUPPORTED_FUNCTION;
@@ -588,27 +584,23 @@ static PSecPkgInfoW _copyPackageInfoFlatAToW(const SecPkgInfoA *infoA)
if (infoA->Name)
{
- nameLen = MultiByteToWideChar(CP_ACP, 0, infoA->Name, -1,
- NULL, 0);
+ nameLen = MultiByteToWideChar(CP_ACP, 0, infoA->Name, -1, NULL, 0);
bytesNeeded += nameLen * sizeof(WCHAR);
}
if (infoA->Comment)
{
- commentLen = MultiByteToWideChar(CP_ACP, 0, infoA->Comment, -1,
- NULL, 0);
+ commentLen = MultiByteToWideChar(CP_ACP, 0, infoA->Comment, -1, NULL, 0);
bytesNeeded += commentLen * sizeof(WCHAR);
}
- ret = heap_alloc(bytesNeeded);
- if (ret)
+ if ((ret = RtlAllocateHeap(GetProcessHeap(), 0, bytesNeeded)))
{
- PWSTR nextString = (PWSTR)((PBYTE)ret + sizeof(SecPkgInfoW));
+ WCHAR *nextString = (WCHAR *)(char *)ret + sizeof(SecPkgInfoW);
memcpy(ret, infoA, sizeof(SecPkgInfoA));
if (infoA->Name)
{
ret->Name = nextString;
- MultiByteToWideChar(CP_ACP, 0, infoA->Name, -1, nextString,
- nameLen);
+ MultiByteToWideChar(CP_ACP, 0, infoA->Name, -1, nextString, nameLen);
nextString += nameLen;
}
else
@@ -616,8 +608,7 @@ static PSecPkgInfoW _copyPackageInfoFlatAToW(const SecPkgInfoA *infoA)
if (infoA->Comment)
{
ret->Comment = nextString;
- MultiByteToWideChar(CP_ACP, 0, infoA->Comment, -1, nextString,
- commentLen);
+ MultiByteToWideChar(CP_ACP, 0, infoA->Comment, -1, nextString, commentLen);
}
else
ret->Comment = NULL;
@@ -644,22 +635,19 @@ static SECURITY_STATUS thunk_ContextAttributesAToW(SecurePackage *package,
if (oldUser)
{
- names->sUserName =
- (PSTR)SECUR32_AllocWideFromMultiByte(oldUser);
+ names->sUserName = (char *)strdupAW(oldUser);
package->provider->fnTableW.FreeContextBuffer(oldUser);
}
break;
}
case SECPKG_ATTR_AUTHORITY:
{
- PSecPkgContext_AuthorityA names =
- (PSecPkgContext_AuthorityA)pBuffer;
+ PSecPkgContext_AuthorityA names = (PSecPkgContext_AuthorityA)pBuffer;
SEC_CHAR *oldAuth = names->sAuthorityName;
if (oldAuth)
{
- names->sAuthorityName =
- (PSTR)SECUR32_AllocWideFromMultiByte(oldAuth);
+ names->sAuthorityName = (char *)strdupAW(oldAuth);
package->provider->fnTableW.FreeContextBuffer(oldAuth);
}
break;
@@ -672,25 +660,19 @@ static SECURITY_STATUS thunk_ContextAttributesAToW(SecurePackage *package,
if (oldSigAlgName)
{
- info->sSignatureAlgorithmName =
- (PSTR)SECUR32_AllocWideFromMultiByte(oldSigAlgName);
- package->provider->fnTableW.FreeContextBuffer(
- oldSigAlgName);
+ info->sSignatureAlgorithmName = (char *)strdupAW(oldSigAlgName);
+ package->provider->fnTableW.FreeContextBuffer(oldSigAlgName);
}
if (oldEncAlgName)
{
- info->sEncryptAlgorithmName =
- (PSTR)SECUR32_AllocWideFromMultiByte(
- oldEncAlgName);
- package->provider->fnTableW.FreeContextBuffer(
- oldEncAlgName);
+ info->sEncryptAlgorithmName = (char *)strdupAW(oldEncAlgName);
+ package->provider->fnTableW.FreeContextBuffer(oldEncAlgName);
}
break;
}
case SECPKG_ATTR_PACKAGE_INFO:
{
- PSecPkgContext_PackageInfoA info =
- (PSecPkgContext_PackageInfoA)pBuffer;
+ PSecPkgContext_PackageInfoA info = (PSecPkgContext_PackageInfoA)pBuffer;
PSecPkgInfoA oldPkgInfo = info->PackageInfo;
if (oldPkgInfo)
@@ -703,8 +685,7 @@ static SECURITY_STATUS thunk_ContextAttributesAToW(SecurePackage *package,
}
case SECPKG_ATTR_NEGOTIATION_INFO:
{
- PSecPkgContext_NegotiationInfoA info =
- (PSecPkgContext_NegotiationInfoA)pBuffer;
+ PSecPkgContext_NegotiationInfoA info = (PSecPkgContext_NegotiationInfoA)pBuffer;
PSecPkgInfoA oldPkgInfo = info->PackageInfo;
if (oldPkgInfo)
@@ -717,35 +698,30 @@ static SECURITY_STATUS thunk_ContextAttributesAToW(SecurePackage *package,
}
case SECPKG_ATTR_NATIVE_NAMES:
{
- PSecPkgContext_NativeNamesA names =
- (PSecPkgContext_NativeNamesA)pBuffer;
- PSTR oldClient = names->sClientName;
- PSTR oldServer = names->sServerName;
+ PSecPkgContext_NativeNamesA names = (PSecPkgContext_NativeNamesA)pBuffer;
+ char *oldClient = names->sClientName;
+ char *oldServer = names->sServerName;
if (oldClient)
{
- names->sClientName = (PSTR)SECUR32_AllocWideFromMultiByte(
- oldClient);
+ names->sClientName = (char *)strdupAW(oldClient);
package->provider->fnTableW.FreeContextBuffer(oldClient);
}
if (oldServer)
{
- names->sServerName = (PSTR)SECUR32_AllocWideFromMultiByte(
- oldServer);
+ names->sServerName = (char *)strdupAW(oldServer);
package->provider->fnTableW.FreeContextBuffer(oldServer);
}
break;
}
case SECPKG_ATTR_CREDENTIAL_NAME:
{
- PSecPkgContext_CredentialNameA name =
- (PSecPkgContext_CredentialNameA)pBuffer;
- PSTR oldCred = name->sCredentialName;
+ PSecPkgContext_CredentialNameA name = (PSecPkgContext_CredentialNameA)pBuffer;
+ char *oldCred = name->sCredentialName;
if (oldCred)
{
- name->sCredentialName =
- (PSTR)SECUR32_AllocWideFromMultiByte(oldCred);
+ name->sCredentialName = (char *)strdupAW(oldCred);
package->provider->fnTableW.FreeContextBuffer(oldCred);
}
break;
@@ -786,11 +762,9 @@ SECURITY_STATUS SEC_ENTRY thunk_QueryContextAttributesW(PCtxtHandle phContext,
{
if (package->provider->fnTableA.QueryContextAttributesA)
{
- ret = package->provider->fnTableA.QueryContextAttributesA(
- ctxt, ulAttribute, pBuffer);
+ ret = package->provider->fnTableA.QueryContextAttributesA(ctxt, ulAttribute, pBuffer);
if (ret == SEC_E_OK)
- ret = thunk_ContextAttributesAToW(package, ulAttribute,
- pBuffer);
+ ret = thunk_ContextAttributesAToW(package, ulAttribute, pBuffer);
}
else
ret = SEC_E_UNSUPPORTED_FUNCTION;
@@ -819,11 +793,9 @@ SECURITY_STATUS SEC_ENTRY thunk_SetContextAttributesA(PCtxtHandle phContext,
if (package->provider->fnTableW.SetContextAttributesW)
{
/* TODO: gotta validate size too! */
- ret = thunk_ContextAttributesWToA(package, ulAttribute,
- pBuffer);
+ ret = thunk_ContextAttributesWToA(package, ulAttribute, pBuffer);
if (ret == SEC_E_OK)
- ret = package->provider->fnTableW.SetContextAttributesW(
- ctxt, ulAttribute, pBuffer, cbBuffer);
+ ret = package->provider->fnTableW.SetContextAttributesW(ctxt, ulAttribute, pBuffer, cbBuffer);
}
else
ret = SEC_E_UNSUPPORTED_FUNCTION;
@@ -852,11 +824,9 @@ SECURITY_STATUS SEC_ENTRY thunk_SetContextAttributesW(PCtxtHandle phContext,
if (package->provider->fnTableA.SetContextAttributesA)
{
/* TODO: gotta validate size too! */
- ret = thunk_ContextAttributesAToW(package, ulAttribute,
- pBuffer);
+ ret = thunk_ContextAttributesAToW(package, ulAttribute, pBuffer);
if (ret == SEC_E_OK)
- ret = package->provider->fnTableA.SetContextAttributesA(
- ctxt, ulAttribute, pBuffer, cbBuffer);
+ ret = package->provider->fnTableA.SetContextAttributesA(ctxt, ulAttribute, pBuffer, cbBuffer);
}
else
ret = SEC_E_UNSUPPORTED_FUNCTION;
@@ -876,11 +846,9 @@ SECURITY_STATUS SEC_ENTRY thunk_ImportSecurityContextA(
SECURITY_STATUS ret;
UNICODE_STRING package;
- TRACE("%s %p %p %p\n", debugstr_a(pszPackage), pPackedContext, Token,
- phContext);
+ TRACE("%s %p %p %p\n", debugstr_a(pszPackage), pPackedContext, Token, phContext);
RtlCreateUnicodeStringFromAsciiz(&package, pszPackage);
- ret = ImportSecurityContextW(package.Buffer, pPackedContext, Token,
- phContext);
+ ret = ImportSecurityContextW(package.Buffer, pPackedContext, Token, phContext);
RtlFreeUnicodeString(&package);
return ret;
}
@@ -890,11 +858,10 @@ SECURITY_STATUS SEC_ENTRY thunk_ImportSecurityContextW(
PCtxtHandle phContext)
{
SECURITY_STATUS ret;
- PSTR package = SECUR32_AllocMultiByteFromWide(pszPackage);
+ char *package = strdupWA(pszPackage);
- TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token,
- phContext);
+ TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token, phContext);
ret = ImportSecurityContextA(package, pPackedContext, Token, phContext);
- heap_free(package);
+ RtlFreeHeap(GetProcessHeap(), 0, package);
return ret;
}
diff --git a/dlls/secur32/wrapper.c b/dlls/secur32/wrapper.c
index 7e36f293f62..4748de83d4f 100644
--- a/dlls/secur32/wrapper.c
+++ b/dlls/secur32/wrapper.c
@@ -18,8 +18,10 @@
*/
#include <stdarg.h>
+#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
+#include "winternl.h"
#include "winnls.h"
#include "sspi.h"
@@ -32,8 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(secur32);
* phSec->dwUpper) and a copy of realHandle (stored in phSec->dwLower).
* SecHandle is equivalent to both a CredHandle and a CtxtHandle.
*/
-static SECURITY_STATUS SECUR32_makeSecHandle(PSecHandle phSec,
- SecurePackage *package, PSecHandle realHandle)
+static SECURITY_STATUS make_sec_handle(PSecHandle phSec, SecurePackage *package, PSecHandle realHandle)
{
SECURITY_STATUS ret;
@@ -41,8 +42,7 @@ static SECURITY_STATUS SECUR32_makeSecHandle(PSecHandle phSec,
if (phSec && package && realHandle)
{
- PSecHandle newSec = heap_alloc(sizeof(SecHandle));
-
+ PSecHandle newSec = malloc(sizeof(*newSec));
if (newSec)
{
*newSec = *realHandle;
@@ -87,7 +87,7 @@ SECURITY_STATUS WINAPI AcquireCredentialsHandleA(
ptsExpiry);
if (ret == SEC_E_OK)
{
- ret = SECUR32_makeSecHandle(phCredential, package, &myCred);
+ ret = make_sec_handle(phCredential, package, &myCred);
if (ret != SEC_E_OK)
package->provider->fnTableW.FreeCredentialsHandle(
&myCred);
@@ -133,7 +133,7 @@ SECURITY_STATUS WINAPI AcquireCredentialsHandleW(
ptsExpiry);
if (ret == SEC_E_OK)
{
- ret = SECUR32_makeSecHandle(phCredential, package, &myCred);
+ ret = make_sec_handle(phCredential, package, &myCred);
if (ret != SEC_E_OK)
package->provider->fnTableW.FreeCredentialsHandle(
&myCred);
@@ -169,7 +169,7 @@ SECURITY_STATUS WINAPI FreeCredentialsHandle(
ret = package->provider->fnTableW.FreeCredentialsHandle(cred);
else
ret = SEC_E_INVALID_HANDLE;
- heap_free(cred);
+ free(cred);
}
else
ret = SEC_E_INVALID_HANDLE;
@@ -287,7 +287,7 @@ SECURITY_STATUS WINAPI InitializeSecurityContextA(
phNewContext && phNewContext != phContext)
{
SECURITY_STATUS ret2;
- ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
+ ret2 = make_sec_handle(phNewContext, package, &myCtxt);
if (ret2 != SEC_E_OK)
package->provider->fnTableA.DeleteSecurityContext(&myCtxt);
}
@@ -351,7 +351,7 @@ SECURITY_STATUS WINAPI InitializeSecurityContextW(
phNewContext && phNewContext != phContext)
{
SECURITY_STATUS ret2;
- ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
+ ret2 = make_sec_handle(phNewContext, package, &myCtxt);
if (ret2 != SEC_E_OK)
package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
}
@@ -395,7 +395,7 @@ SECURITY_STATUS WINAPI AcceptSecurityContext(
myCtxt.dwUpper = realCtxt->dwUpper;
myCtxt.dwLower = realCtxt->dwLower;
}
-
+
ret = package->provider->fnTableW.AcceptSecurityContext(
cred, phContext ? &myCtxt : NULL, pInput, fContextReq,
TargetDataRep, &myCtxt, pOutput, pfContextAttr, ptsExpiry);
@@ -403,7 +403,7 @@ SECURITY_STATUS WINAPI AcceptSecurityContext(
phNewContext && phNewContext != phContext)
{
SECURITY_STATUS ret2;
- ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
+ ret2 = make_sec_handle(phNewContext, package, &myCtxt);
if (ret2 != SEC_E_OK)
package->provider->fnTableW.DeleteSecurityContext(
&myCtxt);
@@ -468,7 +468,7 @@ SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
ret = package->provider->fnTableW.DeleteSecurityContext(ctxt);
else
ret = SEC_E_INVALID_HANDLE;
- heap_free(ctxt);
+ free(ctxt);
}
else
ret = SEC_E_INVALID_HANDLE;
@@ -690,7 +690,7 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
PSecPkgInfoA *ppPackageInfo)
{
SECURITY_STATUS ret;
-
+
TRACE("%s %p\n", debugstr_a(pszPackageName), ppPackageInfo);
if (pszPackageName)
{
@@ -713,8 +713,8 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
package->infoW.Comment, -1, NULL, 0, NULL, NULL);
bytesNeeded += commentLen;
}
- *ppPackageInfo = heap_alloc(bytesNeeded);
- if (*ppPackageInfo)
+ /* freed with FreeContextBuffer */
+ if ((*ppPackageInfo = RtlAllocateHeap(GetProcessHeap(), 0, bytesNeeded)))
{
PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo +
sizeof(SecPkgInfoA));
@@ -775,8 +775,8 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName,
commentLen = lstrlenW(package->infoW.Comment) + 1;
bytesNeeded += commentLen * sizeof(WCHAR);
}
- *ppPackageInfo = heap_alloc(bytesNeeded);
- if (*ppPackageInfo)
+ /* freed with FreeContextBuffer */
+ if ((*ppPackageInfo = RtlAllocateHeap(GetProcessHeap(), 0, bytesNeeded)))
{
PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo +
sizeof(SecPkgInfoW));
@@ -845,7 +845,7 @@ SECURITY_STATUS WINAPI ImportSecurityContextA(SEC_CHAR *pszPackage,
{
SECURITY_STATUS ret;
SecurePackage *package = SECUR32_findPackageA(pszPackage);
-
+
TRACE("%s %p %p %p\n", debugstr_a(pszPackage), pPackedContext, Token,
phContext);
if (package && package->provider)
@@ -858,7 +858,7 @@ SECURITY_STATUS WINAPI ImportSecurityContextA(SEC_CHAR *pszPackage,
pszPackage, pPackedContext, Token, &myCtxt);
if (ret == SEC_E_OK)
{
- ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
+ ret = make_sec_handle(phContext, package, &myCtxt);
if (ret != SEC_E_OK)
package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
}
@@ -893,7 +893,7 @@ SECURITY_STATUS WINAPI ImportSecurityContextW(SEC_WCHAR *pszPackage,
pszPackage, pPackedContext, Token, &myCtxt);
if (ret == SEC_E_OK)
{
- ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
+ ret = make_sec_handle(phContext, package, &myCtxt);
if (ret != SEC_E_OK)
package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
}
--
2.30.2
1
0
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/secur32/lsa.c | 5 +--
dlls/secur32/schannel.c | 91 ++++++++++++++++-------------------------
dlls/secur32/secur32.c | 44 +++++++-------------
3 files changed, 50 insertions(+), 90 deletions(-)
diff --git a/dlls/secur32/lsa.c b/dlls/secur32/lsa.c
index 694971d7146..6e586eb03c2 100644
--- a/dlls/secur32/lsa.c
+++ b/dlls/secur32/lsa.c
@@ -863,14 +863,11 @@ static BOOL load_package(const WCHAR *name, struct lsa_package *package, ULONG p
void load_auth_packages(void)
{
- static const WCHAR LSA_KEY[] = { 'S','y','s','t','e','m','\\',
- 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
- 'C','o','n','t','r','o','l','\\','L','s','a',0 };
DWORD err, i;
HKEY root;
SecureProvider *provider;
- err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, LSA_KEY, 0, KEY_READ, &root);
+ err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Lsa", 0, KEY_READ, &root);
if (err != ERROR_SUCCESS) return;
i = 0;
diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c
index adbc6a810ed..9d092f109fe 100644
--- a/dlls/secur32/schannel.c
+++ b/dlls/secur32/schannel.c
@@ -162,45 +162,34 @@ static void read_config(void)
DWORD res;
static BOOL config_read = FALSE;
-
- static const WCHAR protocol_config_key_name[] = {
- 'S','Y','S','T','E','M','\\',
- 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
- 'C','o','n','t','r','o','l','\\',
- 'S','e','c','u','r','i','t','y','P','r','o','v','i','d','e','r','s','\\',
- 'S','C','H','A','N','N','E','L','\\',
- 'P','r','o','t','o','c','o','l','s',0 };
-
- static const WCHAR clientW[] = {'\\','C','l','i','e','n','t',0};
- static const WCHAR enabledW[] = {'e','n','a','b','l','e','d',0};
- static const WCHAR disabledbydefaultW[] = {'D','i','s','a','b','l','e','d','B','y','D','e','f','a','u','l','t',0};
-
static const struct {
WCHAR key_name[20];
DWORD prot_client_flag;
BOOL enabled; /* If no config is present, enable the protocol */
BOOL disabled_by_default; /* Disable if caller asks for default protocol set */
} protocol_config_keys[] = {
- {{'S','S','L',' ','2','.','0',0}, SP_PROT_SSL2_CLIENT, FALSE, TRUE}, /* NOTE: TRUE, TRUE on Windows */
- {{'S','S','L',' ','3','.','0',0}, SP_PROT_SSL3_CLIENT, TRUE, FALSE},
- {{'T','L','S',' ','1','.','0',0}, SP_PROT_TLS1_0_CLIENT, TRUE, FALSE},
- {{'T','L','S',' ','1','.','1',0}, SP_PROT_TLS1_1_CLIENT, TRUE, FALSE /* NOTE: not enabled by default on Windows */ },
- {{'T','L','S',' ','1','.','2',0}, SP_PROT_TLS1_2_CLIENT, TRUE, FALSE /* NOTE: not enabled by default on Windows */ },
- {{'D','T','L','S',' ','1','.','0',0}, SP_PROT_DTLS1_0_CLIENT, TRUE, TRUE },
- {{'D','T','L','S',' ','1','.','2',0}, SP_PROT_DTLS1_2_CLIENT, TRUE, TRUE },
+ { L"SSL 2.0", SP_PROT_SSL2_CLIENT, FALSE, TRUE }, /* NOTE: TRUE, TRUE on Windows */
+ { L"SSL 3.0", SP_PROT_SSL3_CLIENT, TRUE, FALSE },
+ { L"TLS 1.0", SP_PROT_TLS1_0_CLIENT, TRUE, FALSE },
+ { L"TLS 1.1", SP_PROT_TLS1_1_CLIENT, TRUE, FALSE /* NOTE: not enabled by default on Windows */ },
+ { L"TLS 1.2", SP_PROT_TLS1_2_CLIENT, TRUE, FALSE /* NOTE: not enabled by default on Windows */ },
+ { L"DTLS 1.0", SP_PROT_DTLS1_0_CLIENT, TRUE, TRUE },
+ { L"DTLS 1.2", SP_PROT_DTLS1_2_CLIENT, TRUE, TRUE },
};
/* No need for thread safety */
if(config_read)
return;
- res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, protocol_config_key_name, 0, KEY_READ, &protocols_key);
+ res = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Control\\SecurityProviders\\SCHANNEL\\Protocols", 0, KEY_READ,
+ &protocols_key);
if(res == ERROR_SUCCESS) {
DWORD type, size, value;
for(i = 0; i < ARRAY_SIZE(protocol_config_keys); i++) {
wcscpy(subkey_name, protocol_config_keys[i].key_name);
- wcscat(subkey_name, clientW);
+ wcscat(subkey_name, L"\\Client");
res = RegOpenKeyExW(protocols_key, subkey_name, 0, KEY_READ, &key);
if(res != ERROR_SUCCESS) {
if(protocol_config_keys[i].enabled)
@@ -211,7 +200,7 @@ static void read_config(void)
}
size = sizeof(value);
- res = RegQueryValueExW(key, enabledW, NULL, &type, (BYTE*)&value, &size);
+ res = RegQueryValueExW(key, L"enabled", NULL, &type, (BYTE *)&value, &size);
if(res == ERROR_SUCCESS) {
if(type == REG_DWORD && value)
enabled |= protocol_config_keys[i].prot_client_flag;
@@ -220,7 +209,7 @@ static void read_config(void)
}
size = sizeof(value);
- res = RegQueryValueExW(key, disabledbydefaultW, NULL, &type, (BYTE*)&value, &size);
+ res = RegQueryValueExW(key, L"DisabledByDefault", NULL, &type, (BYTE *)&value, &size);
if(res == ERROR_SUCCESS) {
if(type != REG_DWORD || value)
default_disabled |= protocol_config_keys[i].prot_client_flag;
@@ -391,8 +380,6 @@ static SECURITY_STATUS get_cert(const SCHANNEL_CRED *cred, CERT_CONTEXT const **
static WCHAR *get_key_container_path(const CERT_CONTEXT *ctx)
{
- static const WCHAR rsabaseW[] =
- {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\','C','r','y','p','t','o','\\','R','S','A','\\',0};
CERT_KEY_CONTEXT keyctx;
DWORD size = sizeof(keyctx), prov_size = 0;
CRYPT_KEY_PROV_INFO *prov;
@@ -407,12 +394,12 @@ static WCHAR *get_key_container_path(const CERT_CONTEXT *ctx)
if (!CryptGetProvParam(keyctx.hCryptProv, PP_CONTAINER, (BYTE *)str, &size, 0)) return NULL;
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
- if (!(ret = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(rsabaseW) + len * sizeof(WCHAR))))
+ if (!(ret = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(L"Software\\Wine\\Crypto\\RSA\\") + len * sizeof(WCHAR))))
{
RtlFreeHeap(GetProcessHeap(), 0, str);
return NULL;
}
- wcscpy(ret, rsabaseW);
+ wcscpy(ret, L"Software\\Wine\\Crypto\\RSA\\");
MultiByteToWideChar(CP_ACP, 0, str, -1, ret + wcslen(ret), len);
RtlFreeHeap(GetProcessHeap(), 0, str);
}
@@ -425,20 +412,20 @@ static WCHAR *get_key_container_path(const CERT_CONTEXT *ctx)
return NULL;
}
if (!(ret = RtlAllocateHeap(GetProcessHeap(), 0,
- sizeof(rsabaseW) + wcslen(prov->pwszContainerName) * sizeof(WCHAR))))
+ sizeof(L"Software\\Wine\\Crypto\\RSA\\") + wcslen(prov->pwszContainerName) * sizeof(WCHAR))))
{
RtlFreeHeap(GetProcessHeap(), 0, prov);
return NULL;
}
- wcscpy(ret, rsabaseW);
+ wcscpy(ret, L"Software\\Wine\\Crypto\\RSA\\");
wcscat(ret, prov->pwszContainerName);
RtlFreeHeap(GetProcessHeap(), 0, prov);
}
- if (!ret && GetUserNameW(username, &len) && (ret = RtlAllocateHeap(GetProcessHeap(), 0,
- sizeof(rsabaseW) + len * sizeof(WCHAR))))
+ if (!ret && GetUserNameW(username, &len) &&
+ (ret = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(L"Software\\Wine\\Crypto\\RSA\\") + len * sizeof(WCHAR))))
{
- wcscpy(ret, rsabaseW);
+ wcscpy(ret, L"Software\\Wine\\Crypto\\RSA\\");
wcscat(ret, username);
}
@@ -448,10 +435,6 @@ static WCHAR *get_key_container_path(const CERT_CONTEXT *ctx)
#define MAX_LEAD_BYTES 8
static BYTE *get_key_blob(const CERT_CONTEXT *ctx, DWORD *size)
{
- static const WCHAR keyexchangeW[] =
- {'K','e','y','E','x','c','h','a','n','g','e','K','e','y','P','a','i','r',0};
- static const WCHAR signatureW[] =
- {'S','i','g','n','a','t','u','r','e','K','e','y','P','a','i','r',0};
BYTE *buf, *ret = NULL;
DATA_BLOB blob_in, blob_out;
DWORD spec = 0, type, len;
@@ -466,8 +449,8 @@ static BYTE *get_key_blob(const CERT_CONTEXT *ctx, DWORD *size)
}
RtlFreeHeap(GetProcessHeap(), 0, path);
- if (!RegQueryValueExW(hkey, keyexchangeW, 0, &type, NULL, &len)) spec = AT_KEYEXCHANGE;
- else if (!RegQueryValueExW(hkey, signatureW, 0, &type, NULL, &len)) spec = AT_SIGNATURE;
+ if (!RegQueryValueExW(hkey, L"KeyExchangeKeyPair", 0, &type, NULL, &len)) spec = AT_KEYEXCHANGE;
+ else if (!RegQueryValueExW(hkey, L"SignatureKeyPair", 0, &type, NULL, &len)) spec = AT_SIGNATURE;
else
{
RegCloseKey(hkey);
@@ -480,7 +463,8 @@ static BYTE *get_key_blob(const CERT_CONTEXT *ctx, DWORD *size)
return NULL;
}
- if (!RegQueryValueExW(hkey, (spec == AT_KEYEXCHANGE) ? keyexchangeW : signatureW, 0, &type, buf, &len))
+ if (!RegQueryValueExW(hkey, (spec == AT_KEYEXCHANGE) ? L"KeyExchangeKeyPair" : L"SignatureKeyPair", 0,
+ &type, buf, &len))
{
blob_in.pbData = buf;
blob_in.cbData = len;
@@ -1112,15 +1096,15 @@ static void *get_alg_name(ALG_ID id, BOOL wide)
const char* name;
const WCHAR nameW[8];
} alg_name_map[] = {
- { CALG_ECDSA, "ECDSA", {'E','C','D','S','A',0} },
- { CALG_RSA_SIGN, "RSA", {'R','S','A',0} },
- { CALG_DES, "DES", {'D','E','S',0} },
- { CALG_RC2, "RC2", {'R','C','2',0} },
- { CALG_3DES, "3DES", {'3','D','E','S',0} },
- { CALG_AES_128, "AES", {'A','E','S',0} },
- { CALG_AES_192, "AES", {'A','E','S',0} },
- { CALG_AES_256, "AES", {'A','E','S',0} },
- { CALG_RC4, "RC4", {'R','C','4',0} },
+ { CALG_ECDSA, "ECDSA", L"ECDSA" },
+ { CALG_RSA_SIGN, "RSA", L"RSA" },
+ { CALG_DES, "DES", L"DES" },
+ { CALG_RC2, "RC2", L"RC2" },
+ { CALG_3DES, "3DES", L"3DES" },
+ { CALG_AES_128, "AES", L"AES" },
+ { CALG_AES_192, "AES", L"AES" },
+ { CALG_AES_256, "AES", L"AES" },
+ { CALG_RC4, "RC4", L"RC4" },
};
unsigned i;
@@ -1668,10 +1652,6 @@ static const SecurityFunctionTableW schanTableW = {
NULL, /* SetContextAttributesW */
};
-static const WCHAR schannelComment[] = { 'S','c','h','a','n','n','e','l',' ',
- 'S','e','c','u','r','i','t','y',' ','P','a','c','k','a','g','e',0 };
-static const WCHAR schannelDllName[] = { 's','c','h','a','n','n','e','l','.','d','l','l',0 };
-
const struct schan_callbacks schan_callbacks =
{
schan_get_buffer,
@@ -1701,8 +1681,7 @@ void SECUR32_initSchannelSP(void)
*schannel = (SEC_WCHAR *)SCHANNEL_NAME_W;
const SecPkgInfoW info[] = {
{ caps, version, UNISP_RPC_ID, maxToken, uniSPName, uniSPName },
- { caps, version, UNISP_RPC_ID, maxToken, schannel,
- (SEC_WCHAR *)schannelComment },
+ { caps, version, UNISP_RPC_ID, maxToken, schannel, (SEC_WCHAR *)L"Schannel Security Package" },
};
SecureProvider *provider;
@@ -1720,7 +1699,7 @@ void SECUR32_initSchannelSP(void)
}
schan_handle_table_size = 64;
- provider = SECUR32_addProvider(&schanTableA, &schanTableW, schannelDllName);
+ provider = SECUR32_addProvider(&schanTableA, &schanTableW, L"schannel.dll");
if (!provider)
{
ERR("Failed to add schannel provider.\n");
diff --git a/dlls/secur32/secur32.c b/dlls/secur32/secur32.c
index 374030d0064..fda7d7ef865 100644
--- a/dlls/secur32/secur32.c
+++ b/dlls/secur32/secur32.c
@@ -540,15 +540,6 @@ static void _tryLoadProvider(PWSTR moduleName)
WARN("failed to load %s\n", debugstr_w(moduleName));
}
-static const WCHAR securityProvidersKeyW[] = {
- 'S','Y','S','T','E','M','\\','C','u','r','r','e','n','t','C','o','n','t','r',
- 'o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','S','e','c','u','r',
- 'i','t','y','P','r','o','v','i','d','e','r','s','\0'
- };
-static const WCHAR securityProvidersW[] = {
- 'S','e','c','u','r','i','t','y','P','r','o','v','i','d','e','r','s',0
- };
-
static void SECUR32_initializeProviders(void)
{
HKEY key;
@@ -564,15 +555,14 @@ static void SECUR32_initializeProviders(void)
* application reported on wine-users on 2006-09-12 working. */
SECUR32_initNegotiateSP();
/* Now load providers from registry */
- apiRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, securityProvidersKeyW, 0,
- KEY_READ, &key);
+ apiRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\SecurityProviders", 0,
+ KEY_READ, &key);
if (apiRet == ERROR_SUCCESS)
{
WCHAR securityPkgNames[MAX_PATH]; /* arbitrary len */
DWORD size = sizeof(securityPkgNames), type;
- apiRet = RegQueryValueExW(key, securityProvidersW, NULL, &type,
- (PBYTE)securityPkgNames, &size);
+ apiRet = RegQueryValueExW(key, L"SecurityProviders", NULL, &type, (PBYTE)securityPkgNames, &size);
if (apiRet == ERROR_SUCCESS && type == REG_SZ)
{
WCHAR *ptr;
@@ -994,17 +984,15 @@ BOOLEAN WINAPI GetComputerObjectNameW(
DWORD len = domainInfo->Name.Length + size + 3;
if (lpNameBuffer && *nSize >= len)
{
- static const WCHAR bs[] = { '\\', 0 };
- static const WCHAR ds[] = { '$', 0 };
if (domainInfo->Name.Buffer)
{
lstrcpyW(lpNameBuffer, domainInfo->Name.Buffer);
- lstrcatW(lpNameBuffer, bs);
+ lstrcatW(lpNameBuffer, L"\\");
}
else
*lpNameBuffer = 0;
lstrcatW(lpNameBuffer, name);
- lstrcatW(lpNameBuffer, ds);
+ lstrcatW(lpNameBuffer, L"$");
status = TRUE;
}
else /* just requesting length required */
@@ -1023,10 +1011,6 @@ BOOLEAN WINAPI GetComputerObjectNameW(
break;
case NameFullyQualifiedDN:
{
- static const WCHAR cnW[] = { 'C','N','=',0 };
- static const WCHAR ComputersW[] = { 'C','N','=','C','o','m','p','u','t','e','r','s',0 };
- static const WCHAR dcW[] = { 'D','C','=',0 };
- static const WCHAR commaW[] = { ',',0 };
WCHAR name[MAX_COMPUTERNAME_LENGTH + 1];
DWORD len, size;
WCHAR *suffix;
@@ -1038,14 +1022,14 @@ BOOLEAN WINAPI GetComputerObjectNameW(
break;
}
- len = wcslen(cnW) + size + 1 + wcslen(ComputersW) + 1 + wcslen(dcW);
+ len = wcslen(L"CN=") + size + 1 + wcslen(L"CN=Computers") + 1 + wcslen(L"DC=");
if (domainInfo->DnsDomainName.Buffer)
{
suffix = wcsrchr(domainInfo->DnsDomainName.Buffer, '.');
if (suffix)
{
*suffix++ = 0;
- len += 1 + wcslen(dcW) + wcslen(suffix);
+ len += 1 + wcslen(L"DC=") + wcslen(suffix);
}
len += wcslen(domainInfo->DnsDomainName.Buffer);
}
@@ -1054,19 +1038,19 @@ BOOLEAN WINAPI GetComputerObjectNameW(
if (lpNameBuffer && *nSize > len)
{
- lstrcpyW(lpNameBuffer, cnW);
+ lstrcpyW(lpNameBuffer, L"CN=");
lstrcatW(lpNameBuffer, name);
- lstrcatW(lpNameBuffer, commaW);
- lstrcatW(lpNameBuffer, ComputersW);
+ lstrcatW(lpNameBuffer, L",");
+ lstrcatW(lpNameBuffer, L"CN=Computers");
if (domainInfo->DnsDomainName.Buffer)
{
- lstrcatW(lpNameBuffer, commaW);
- lstrcatW(lpNameBuffer, dcW);
+ lstrcatW(lpNameBuffer, L",");
+ lstrcatW(lpNameBuffer, L"DC=");
lstrcatW(lpNameBuffer, domainInfo->DnsDomainName.Buffer);
if (suffix)
{
- lstrcatW(lpNameBuffer, commaW);
- lstrcatW(lpNameBuffer, dcW);
+ lstrcatW(lpNameBuffer, L",");
+ lstrcatW(lpNameBuffer, L"DC=");
lstrcatW(lpNameBuffer, suffix);
}
}
--
2.30.2
1
0
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/secur32/Makefile.in | 2 ++
dlls/secur32/negotiate.c | 3 +--
dlls/secur32/schannel.c | 22 +++++++++++-----------
dlls/secur32/secur32.c | 28 ++++++++++------------------
dlls/secur32/thunks.c | 5 +++--
dlls/secur32/wrapper.c | 3 ++-
6 files changed, 29 insertions(+), 34 deletions(-)
diff --git a/dlls/secur32/Makefile.in b/dlls/secur32/Makefile.in
index a5aa3b52691..458f62bb99f 100644
--- a/dlls/secur32/Makefile.in
+++ b/dlls/secur32/Makefile.in
@@ -5,6 +5,8 @@ DELAYIMPORTS = crypt32
EXTRAINCL = $(GNUTLS_CFLAGS)
EXTRALIBS = $(SECURITY_LIBS) $(PTHREAD_LIBS)
+EXTRADLLFLAGS = -mno-cygwin
+
C_SRCS = \
lsa.c \
negotiate.c \
diff --git a/dlls/secur32/negotiate.c b/dlls/secur32/negotiate.c
index aeddbccd4f4..6d45d0c5d54 100644
--- a/dlls/secur32/negotiate.c
+++ b/dlls/secur32/negotiate.c
@@ -23,10 +23,9 @@
#include "sspi.h"
#include "rpc.h"
#include "wincred.h"
-#include "secur32_priv.h"
#include "wine/debug.h"
-#include "wine/unicode.h"
+#include "secur32_priv.h"
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c
index 5f6b96903c4..adbc6a810ed 100644
--- a/dlls/secur32/schannel.c
+++ b/dlls/secur32/schannel.c
@@ -25,15 +25,15 @@
#define NONAMELESSUNION
#include "windef.h"
#include "winbase.h"
+#include "winternl.h"
#include "winreg.h"
#include "winnls.h"
#include "lmcons.h"
#include "sspi.h"
#include "schannel.h"
-#include "secur32_priv.h"
-#include "wine/unicode.h"
#include "wine/debug.h"
+#include "secur32_priv.h"
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
@@ -199,8 +199,8 @@ static void read_config(void)
DWORD type, size, value;
for(i = 0; i < ARRAY_SIZE(protocol_config_keys); i++) {
- strcpyW(subkey_name, protocol_config_keys[i].key_name);
- strcatW(subkey_name, clientW);
+ wcscpy(subkey_name, protocol_config_keys[i].key_name);
+ wcscat(subkey_name, clientW);
res = RegOpenKeyExW(protocols_key, subkey_name, 0, KEY_READ, &key);
if(res != ERROR_SUCCESS) {
if(protocol_config_keys[i].enabled)
@@ -412,8 +412,8 @@ static WCHAR *get_key_container_path(const CERT_CONTEXT *ctx)
RtlFreeHeap(GetProcessHeap(), 0, str);
return NULL;
}
- strcpyW(ret, rsabaseW);
- MultiByteToWideChar(CP_ACP, 0, str, -1, ret + strlenW(ret), len);
+ wcscpy(ret, rsabaseW);
+ MultiByteToWideChar(CP_ACP, 0, str, -1, ret + wcslen(ret), len);
RtlFreeHeap(GetProcessHeap(), 0, str);
}
else if (CertGetCertificateContextProperty(ctx, CERT_KEY_PROV_INFO_PROP_ID, NULL, &prov_size))
@@ -425,21 +425,21 @@ static WCHAR *get_key_container_path(const CERT_CONTEXT *ctx)
return NULL;
}
if (!(ret = RtlAllocateHeap(GetProcessHeap(), 0,
- sizeof(rsabaseW) + strlenW(prov->pwszContainerName) * sizeof(WCHAR))))
+ sizeof(rsabaseW) + wcslen(prov->pwszContainerName) * sizeof(WCHAR))))
{
RtlFreeHeap(GetProcessHeap(), 0, prov);
return NULL;
}
- strcpyW(ret, rsabaseW);
- strcatW(ret, prov->pwszContainerName);
+ wcscpy(ret, rsabaseW);
+ wcscat(ret, prov->pwszContainerName);
RtlFreeHeap(GetProcessHeap(), 0, prov);
}
if (!ret && GetUserNameW(username, &len) && (ret = RtlAllocateHeap(GetProcessHeap(), 0,
sizeof(rsabaseW) + len * sizeof(WCHAR))))
{
- strcpyW(ret, rsabaseW);
- strcatW(ret, username);
+ wcscpy(ret, rsabaseW);
+ wcscat(ret, username);
}
return ret;
diff --git a/dlls/secur32/secur32.c b/dlls/secur32/secur32.c
index 04cb52dbec9..374030d0064 100644
--- a/dlls/secur32/secur32.c
+++ b/dlls/secur32/secur32.c
@@ -16,6 +16,7 @@
* 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 <assert.h>
#include <stdarg.h>
@@ -28,7 +29,6 @@
#include "winternl.h"
#include "shlwapi.h"
#include "sspi.h"
-#include "secur32_priv.h"
#include "secext.h"
#include "ntsecapi.h"
#include "thunks.h"
@@ -36,7 +36,7 @@
#include "wine/list.h"
#include "wine/debug.h"
-#include "wine/unicode.h"
+#include "secur32_priv.h"
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
@@ -174,18 +174,10 @@ PSecurityFunctionTableW WINAPI InitSecurityInterfaceW(void)
return &securityFunctionTableW;
}
-static PWSTR SECUR32_strdupW(PCWSTR str)
+static WCHAR *SECUR32_strdupW(const WCHAR *str)
{
- PWSTR ret;
-
- if (str)
- {
- ret = heap_alloc((lstrlenW(str) + 1) * sizeof(WCHAR));
- if (ret)
- lstrcpyW(ret, str);
- }
- else
- ret = NULL;
+ WCHAR *ret = NULL;
+ if (str && (ret = heap_alloc((wcslen(str) + 1) * sizeof(WCHAR)))) wcscpy(ret, str);
return ret;
}
@@ -595,7 +587,7 @@ static void SECUR32_initializeProviders(void)
;
if (*comma == ',')
*comma = '\0';
- for (; *ptr && isspaceW(*ptr) && ptr < securityPkgNames + size;
+ for (; *ptr && iswspace(*ptr) && ptr < securityPkgNames + size;
ptr++)
;
if (*ptr)
@@ -1046,16 +1038,16 @@ BOOLEAN WINAPI GetComputerObjectNameW(
break;
}
- len = strlenW(cnW) + size + 1 + strlenW(ComputersW) + 1 + strlenW(dcW);
+ len = wcslen(cnW) + size + 1 + wcslen(ComputersW) + 1 + wcslen(dcW);
if (domainInfo->DnsDomainName.Buffer)
{
- suffix = strrchrW(domainInfo->DnsDomainName.Buffer, '.');
+ suffix = wcsrchr(domainInfo->DnsDomainName.Buffer, '.');
if (suffix)
{
*suffix++ = 0;
- len += 1 + strlenW(dcW) + strlenW(suffix);
+ len += 1 + wcslen(dcW) + wcslen(suffix);
}
- len += strlenW(domainInfo->DnsDomainName.Buffer);
+ len += wcslen(domainInfo->DnsDomainName.Buffer);
}
else
suffix = NULL;
diff --git a/dlls/secur32/thunks.c b/dlls/secur32/thunks.c
index 09b20d54abe..7a59c4ee3ca 100644
--- a/dlls/secur32/thunks.c
+++ b/dlls/secur32/thunks.c
@@ -17,16 +17,17 @@
* 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 "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
#include "sspi.h"
-#include "secur32_priv.h"
-#include "thunks.h"
#include "wine/debug.h"
+#include "secur32_priv.h"
+#include "thunks.h"
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
diff --git a/dlls/secur32/wrapper.c b/dlls/secur32/wrapper.c
index 67c5b5a7215..7e36f293f62 100644
--- a/dlls/secur32/wrapper.c
+++ b/dlls/secur32/wrapper.c
@@ -16,14 +16,15 @@
* 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 "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "sspi.h"
-#include "secur32_priv.h"
#include "wine/debug.h"
+#include "secur32_priv.h"
WINE_DEFAULT_DEBUG_CHANNEL(secur32);
--
2.30.2
1
0
07 May '21
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/secur32/Makefile.in | 2 +-
dlls/secur32/schannel_macosx.c | 17 ++++++++---------
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/dlls/secur32/Makefile.in b/dlls/secur32/Makefile.in
index 89a7c8bd078..a5aa3b52691 100644
--- a/dlls/secur32/Makefile.in
+++ b/dlls/secur32/Makefile.in
@@ -3,7 +3,7 @@ IMPORTLIB = secur32
IMPORTS = advapi32
DELAYIMPORTS = crypt32
EXTRAINCL = $(GNUTLS_CFLAGS)
-EXTRALIBS = $(SECURITY_LIBS)
+EXTRALIBS = $(SECURITY_LIBS) $(PTHREAD_LIBS)
C_SRCS = \
lsa.c \
diff --git a/dlls/secur32/schannel_macosx.c b/dlls/secur32/schannel_macosx.c
index ab97615014d..841f928eef3 100644
--- a/dlls/secur32/schannel_macosx.c
+++ b/dlls/secur32/schannel_macosx.c
@@ -23,6 +23,7 @@
#include "wine/port.h"
#include <stdarg.h>
+#include <pthread.h>
#ifdef HAVE_SECURITY_SECURITY_H
#include <Security/Security.h>
#define GetCurrentThread GetCurrentThread_Mac
@@ -190,10 +191,9 @@ struct mac_session {
SSLContextRef context;
struct schan_transport *transport;
enum schan_mode mode;
- CRITICAL_SECTION cs;
+ pthread_mutex_t mutex;
};
-
enum {
schan_proto_SSL,
schan_proto_TLS,
@@ -760,8 +760,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre
if (!s)
return FALSE;
- InitializeCriticalSection(&s->cs);
- s->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": mac_session.cs");
+ pthread_mutex_init(&s->mutex, NULL);
status = SSLNewContext(cred->credential_use == SECPKG_CRED_INBOUND, &s->context);
if (status != noErr)
@@ -826,7 +825,7 @@ void schan_imp_dispose_session(schan_imp_session session)
status = SSLDisposeContext(s->context);
if (status != noErr)
ERR("Failed to dispose of session context: %d\n", status);
- DeleteCriticalSection(&s->cs);
+ pthread_mutex_destroy(&s->mutex);
heap_free(s);
}
@@ -1124,13 +1123,13 @@ SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer,
TRACE("(%p/%p, %p, %p/%lu)\n", s, s->context, buffer, length, *length);
- EnterCriticalSection(&s->cs);
+ pthread_mutex_lock(&s->mutex);
s->mode = schan_mode_WRITE;
status = SSLWrite(s->context, buffer, *length, length);
s->mode = schan_mode_NONE;
- LeaveCriticalSection(&s->cs);
+ pthread_mutex_unlock(&s->mutex);
if (status == noErr)
TRACE("Wrote %lu bytes\n", *length);
@@ -1161,13 +1160,13 @@ SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer,
TRACE("(%p/%p, %p, %p/%lu)\n", s, s->context, buffer, length, *length);
- EnterCriticalSection(&s->cs);
+ pthread_mutex_lock(&s->mutex);
s->mode = schan_mode_READ;
status = SSLRead(s->context, buffer, *length, length);
s->mode = schan_mode_NONE;
- LeaveCriticalSection(&s->cs);
+ pthread_mutex_unlock(&s->mutex);
if (status == noErr || status == errSSLClosedGraceful)
TRACE("Read %lu bytes\n", *length);
--
2.30.2
1
0