Wine-devel
Threads by month
- ----- 2026 -----
- March
- February
- January
- ----- 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
April 2020
- 87 participants
- 854 discussions
The QXL driver used by Windows 10 TestBots doesn't report
800x600 as a supported resolution. Switching to full screen
may fail even though some DXGI methods report success.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
Fix test failures like in https://test.winehq.org/data/7096ab45444d7b7cbb926b5a51af0cbc46960ed3/win10…
dlls/dxgi/tests/dxgi.c | 62 +++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 31 deletions(-)
diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c
index cc49c7b2ae1..eb22b0d212b 100644
--- a/dlls/dxgi/tests/dxgi.c
+++ b/dlls/dxgi/tests/dxgi.c
@@ -1522,8 +1522,8 @@ static void test_create_swapchain(void)
return;
}
- creation_desc.BufferDesc.Width = 800;
- creation_desc.BufferDesc.Height = 600;
+ creation_desc.BufferDesc.Width = 1024;
+ creation_desc.BufferDesc.Height = 768;
creation_desc.BufferDesc.RefreshRate.Numerator = 60;
creation_desc.BufferDesc.RefreshRate.Denominator = 60;
creation_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -2222,7 +2222,7 @@ static void test_swapchain_fullscreen_state(IDXGISwapChain *swapchain,
expected_state = *initial_state;
compute_expected_swapchain_fullscreen_state_after_fullscreen_change(&expected_state,
- &swapchain_desc, &initial_state->fullscreen_state.monitor_rect, 800, 600, NULL);
+ &swapchain_desc, &initial_state->fullscreen_state.monitor_rect, 1024, 768, NULL);
hr = IDXGISwapChain_GetContainingOutput(swapchain, &expected_state.target);
ok(SUCCEEDED(hr), "GetContainingOutput failed, hr %#x.\n", hr);
@@ -2291,7 +2291,7 @@ static void test_swapchain_fullscreen_state(IDXGISwapChain *swapchain,
expected_state.fullscreen_state.monitor = output_desc.Monitor;
expected_state.fullscreen_state.monitor_rect = orig_monitor_rect;
compute_expected_swapchain_fullscreen_state_after_fullscreen_change(&expected_state,
- &swapchain_desc, &orig_monitor_rect, 800, 600, NULL);
+ &swapchain_desc, &orig_monitor_rect, 1024, 768, NULL);
hr = IDXGISwapChain_SetFullscreenState(swapchain, TRUE, output);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
@@ -2376,8 +2376,8 @@ static void test_set_fullscreen(IUnknown *device, BOOL is_d3d12)
get_factory(device, is_d3d12, &factory);
- swapchain_desc.BufferDesc.Width = 800;
- swapchain_desc.BufferDesc.Height = 600;
+ swapchain_desc.BufferDesc.Width = 1024;
+ swapchain_desc.BufferDesc.Height = 768;
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
swapchain_desc.BufferDesc.RefreshRate.Denominator = 60;
swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -2808,8 +2808,8 @@ static void test_resize_target(IUnknown *device, BOOL is_d3d12)
get_factory(device, is_d3d12, &factory);
- swapchain_desc.BufferDesc.Width = 800;
- swapchain_desc.BufferDesc.Height = 600;
+ swapchain_desc.BufferDesc.Width = 1024;
+ swapchain_desc.BufferDesc.Height = 768;
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
swapchain_desc.BufferDesc.RefreshRate.Denominator = 1;
swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -2848,7 +2848,7 @@ static void test_resize_target(IUnknown *device, BOOL is_d3d12)
{
expected_state.fullscreen = TRUE;
compute_expected_swapchain_fullscreen_state_after_fullscreen_change(&expected_state,
- &swapchain_desc, &initial_state.fullscreen_state.monitor_rect, 800, 600, NULL);
+ &swapchain_desc, &initial_state.fullscreen_state.monitor_rect, 1024, 768, NULL);
hr = IDXGISwapChain_GetContainingOutput(swapchain, &expected_state.target);
ok(SUCCEEDED(hr) || broken(hr == DXGI_ERROR_UNSUPPORTED) /* Win 7 testbot */,
"GetContainingOutput failed, hr %#x.\n", hr);
@@ -2918,8 +2918,8 @@ static LRESULT CALLBACK resize_target_wndproc(HWND hwnd, unsigned int message, W
ok(!!swapchain, "GWLP_USERDATA is NULL.\n");
hr = IDXGISwapChain_GetDesc(swapchain, &desc);
ok(hr == S_OK, "Failed to get desc, hr %#x.\n", hr);
- ok(desc.BufferDesc.Width == 800, "Got unexpected buffer width %u.\n", desc.BufferDesc.Width);
- ok(desc.BufferDesc.Height == 600, "Got unexpected buffer height %u.\n", desc.BufferDesc.Height);
+ ok(desc.BufferDesc.Width == 1024, "Got unexpected buffer width %u.\n", desc.BufferDesc.Width);
+ ok(desc.BufferDesc.Height == 768, "Got unexpected buffer height %u.\n", desc.BufferDesc.Height);
return 0;
default:
@@ -3009,8 +3009,8 @@ static void test_resize_target_wndproc(void)
hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
ok(hr == S_OK, "Failed to get parent, hr %#x.\n", hr);
- swapchain_desc.BufferDesc.Width = 800;
- swapchain_desc.BufferDesc.Height = 600;
+ swapchain_desc.BufferDesc.Width = 1024;
+ swapchain_desc.BufferDesc.Height = 768;
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
swapchain_desc.BufferDesc.RefreshRate.Denominator = 1;
swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -3038,9 +3038,9 @@ static void test_resize_target_wndproc(void)
hr = IDXGISwapChain_GetDesc(swapchain, &swapchain_desc);
ok(hr == S_OK, "Getswapchain_desc failed, hr %#x.\n", hr);
- ok(swapchain_desc.BufferDesc.Width == 800,
+ ok(swapchain_desc.BufferDesc.Width == 1024,
"Got unexpected buffer width %u.\n", swapchain_desc.BufferDesc.Width);
- ok(swapchain_desc.BufferDesc.Height == 600,
+ ok(swapchain_desc.BufferDesc.Height == 768,
"Got unexpected buffer height %u.\n", swapchain_desc.BufferDesc.Height);
ret = GetClientRect(swapchain_desc.OutputWindow, &rect);
@@ -3102,8 +3102,8 @@ static void test_inexact_modes(void)
hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
ok(SUCCEEDED(hr), "GetParent failed, hr %#x.\n", hr);
- swapchain_desc.BufferDesc.Width = 800;
- swapchain_desc.BufferDesc.Height = 600;
+ swapchain_desc.BufferDesc.Width = 1024;
+ swapchain_desc.BufferDesc.Height = 768;
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
swapchain_desc.BufferDesc.RefreshRate.Denominator = 1;
swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -3202,8 +3202,8 @@ static void test_inexact_modes(void)
ok(!refcount, "IDXGISwapChain has %u references left.\n", refcount);
/* Test ResizeTarget(). */
- swapchain_desc.BufferDesc.Width = 800;
- swapchain_desc.BufferDesc.Height = 600;
+ swapchain_desc.BufferDesc.Width = 1024;
+ swapchain_desc.BufferDesc.Height = 768;
swapchain_desc.Windowed = TRUE;
hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)device, &swapchain_desc, &swapchain);
@@ -3220,8 +3220,8 @@ static void test_inexact_modes(void)
check_swapchain_fullscreen_state(swapchain, &expected_state);
hr = IDXGISwapChain_GetDesc(swapchain, &result_desc);
ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr);
- ok(result_desc.BufferDesc.Width == 800, "Got width %u.\n", result_desc.BufferDesc.Width);
- ok(result_desc.BufferDesc.Height == 600, "Got height %u.\n", result_desc.BufferDesc.Height);
+ ok(result_desc.BufferDesc.Width == 1024, "Got width %u.\n", result_desc.BufferDesc.Width);
+ ok(result_desc.BufferDesc.Height == 768, "Got height %u.\n", result_desc.BufferDesc.Height);
hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL);
ok(SUCCEEDED(hr), "SetFullscreenState failed, hr %#x.\n", hr);
@@ -4201,8 +4201,8 @@ static void test_swapchain_present(IUnknown *device, BOOL is_d3d12)
get_factory(device, is_d3d12, &factory);
- swapchain_desc.BufferDesc.Width = 800;
- swapchain_desc.BufferDesc.Height = 600;
+ swapchain_desc.BufferDesc.Width = 1024;
+ swapchain_desc.BufferDesc.Height = 768;
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
swapchain_desc.BufferDesc.RefreshRate.Denominator = 60;
swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -5288,8 +5288,8 @@ static void test_swapchain_window_messages(void)
ok(hr == S_OK, "Failed to get parent, hr %#x.\n", hr);
IDXGIAdapter_Release(adapter);
- swapchain_desc.BufferDesc.Width = 800;
- swapchain_desc.BufferDesc.Height = 600;
+ swapchain_desc.BufferDesc.Width = 1024;
+ swapchain_desc.BufferDesc.Height = 768;
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
swapchain_desc.BufferDesc.RefreshRate.Denominator = 60;
swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -5315,8 +5315,8 @@ static void test_swapchain_window_messages(void)
/* resize target */
expect_messages = resize_target_messages;
memset(&mode_desc, 0, sizeof(mode_desc));
- mode_desc.Width = 800;
- mode_desc.Height = 600;
+ mode_desc.Width = 1024;
+ mode_desc.Height = 768;
hr = IDXGISwapChain_ResizeTarget(swapchain, &mode_desc);
ok(hr == S_OK, "Failed to resize target, hr %#x.\n", hr);
flush_events();
@@ -5449,8 +5449,8 @@ static void test_swapchain_window_styles(void)
ok(hr == S_OK, "Failed to get parent, hr %#x.\n", hr);
IDXGIAdapter_Release(adapter);
- swapchain_desc.BufferDesc.Width = 800;
- swapchain_desc.BufferDesc.Height = 600;
+ swapchain_desc.BufferDesc.Width = 1024;
+ swapchain_desc.BufferDesc.Height = 768;
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
swapchain_desc.BufferDesc.RefreshRate.Denominator = 60;
swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -5889,8 +5889,8 @@ static void test_output_ownership(IUnknown *device, BOOL is_d3d12)
check_ownership_desc.VidPnSourceId = open_adapter_gdi_desc.VidPnSourceId;
wait_vidpn_exclusive_ownership(&check_ownership_desc, STATUS_SUCCESS, FALSE);
- swapchain_desc.BufferDesc.Width = 800;
- swapchain_desc.BufferDesc.Height = 600;
+ swapchain_desc.BufferDesc.Width = 1024;
+ swapchain_desc.BufferDesc.Height = 768;
swapchain_desc.BufferDesc.RefreshRate.Numerator = 60;
swapchain_desc.BufferDesc.RefreshRate.Denominator = 1;
swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
--
2.20.1
3
4
[PATCH 4/4] adsldp: Map "1.2.840.113556.1.4.906" to ADSTYPE_LARGE_INTEGER.
by Dmitry Timoshkov 07 Apr '20
by Dmitry Timoshkov 07 Apr '20
07 Apr '20
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/adsldp/adsldp.c | 23 +++++++++++++++++------
dlls/adsldp/schema.c | 2 ++
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/dlls/adsldp/adsldp.c b/dlls/adsldp/adsldp.c
index 8897545e4f..5504a376ba 100644
--- a/dlls/adsldp/adsldp.c
+++ b/dlls/adsldp/adsldp.c
@@ -1478,26 +1478,37 @@ static HRESULT add_column_values(LDAP_namespace *ldap, struct ldap_search_contex
}
case ADSTYPE_INTEGER:
+ case ADSTYPE_LARGE_INTEGER:
{
- WCHAR **values = ldap_get_valuesW(ldap->ld, ldap_ctx->entry, name);
+ struct berval **values = ldap_get_values_lenW(ldap->ld, ldap_ctx->entry, name);
if (!values)
return E_ADS_COLUMN_NOT_SET;
- count = ldap_count_valuesW(values);
+ count = ldap_count_values_len(values);
col->pADsValues = heap_alloc_zero(count * sizeof(col->pADsValues[0]));
if (!col->pADsValues)
{
- ldap_value_freeW(values);
+ ldap_value_free_len(values);
return E_OUTOFMEMORY;
}
for (i = 0; i < count; i++)
{
- col->pADsValues[i].u.Integer = wcstol(values[i], NULL, 10);
- TRACE("%s => %d\n", debugstr_w(values[i]), col->pADsValues[i].u.Integer);
+ col->pADsValues[i].dwType = type;
+
+ if (type == ADSTYPE_LARGE_INTEGER)
+ {
+ col->pADsValues[i].u.LargeInteger.QuadPart = _atoi64(values[i]->bv_val);
+ TRACE("%s => %s\n", debugstr_an(values[i]->bv_val, values[i]->bv_len), wine_dbgstr_longlong(col->pADsValues[i].u.LargeInteger.QuadPart));
+ }
+ else
+ {
+ col->pADsValues[i].u.Integer = atol(values[i]->bv_val);
+ TRACE("%s => %d\n", debugstr_an(values[i]->bv_val, values[i]->bv_len), col->pADsValues[i].u.Integer);
+ }
}
- ldap_value_freeW(values);
+ ldap_value_free_len(values);
col->hReserved = NULL;
break;
}
diff --git a/dlls/adsldp/schema.c b/dlls/adsldp/schema.c
index 6965dc3274..e997c6f98e 100644
--- a/dlls/adsldp/schema.c
+++ b/dlls/adsldp/schema.c
@@ -101,6 +101,8 @@ ADSTYPEENUM get_schema_type(const WCHAR *name, const struct attribute_type *at,
return ADSTYPE_CASE_IGNORE_STRING;
if (!wcscmp(type->syntax, L"1.3.6.1.4.1.1466.115.121.1.40"))
return ADSTYPE_OCTET_STRING;
+ if (!wcscmp(type->syntax, L"1.2.840.113556.1.4.906"))
+ return ADSTYPE_LARGE_INTEGER;
if (!wcscmp(type->syntax, L"1.2.840.113556.1.4.907"))
return ADSTYPE_NT_SECURITY_DESCRIPTOR;
--
2.25.2
1
0
[PATCH 3/4] adsldp: Map "1.3.6.1.4.1.1466.115.121.1.24" to ADSTYPE_UTC_TIME.
by Dmitry Timoshkov 07 Apr '20
by Dmitry Timoshkov 07 Apr '20
07 Apr '20
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/adsldp/adsldp.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
dlls/adsldp/schema.c | 2 ++
2 files changed, 46 insertions(+)
diff --git a/dlls/adsldp/adsldp.c b/dlls/adsldp/adsldp.c
index f2773262a6..8897545e4f 100644
--- a/dlls/adsldp/adsldp.c
+++ b/dlls/adsldp/adsldp.c
@@ -1528,6 +1528,50 @@ static HRESULT add_column_values(LDAP_namespace *ldap, struct ldap_search_contex
col->hReserved = values;
break;
}
+
+ case ADSTYPE_UTC_TIME:
+ {
+ struct berval **values = ldap_get_values_lenW(ldap->ld, ldap_ctx->entry, name);
+ if (!values)
+ return E_ADS_COLUMN_NOT_SET;
+ count = ldap_count_values_len(values);
+
+ col->pADsValues = heap_alloc_zero(count * sizeof(col->pADsValues[0]));
+ if (!col->pADsValues)
+ {
+ ldap_value_free_len(values);
+ return E_OUTOFMEMORY;
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ col->pADsValues[i].dwType = type;
+ if (values[i]->bv_len < 14 ||
+ _snscanf_l(values[i]->bv_val, values[i]->bv_len, "%04u%02u%02u%02u%02u%02u", NULL,
+ &col->pADsValues[i].u.UTCTime.wYear, &col->pADsValues[i].u.UTCTime.wMonth,
+ &col->pADsValues[i].u.UTCTime.wDay, &col->pADsValues[i].u.UTCTime.wHour,
+ &col->pADsValues[i].u.UTCTime.wMinute, &col->pADsValues[i].u.UTCTime.wSecond) != 6)
+ {
+ FIXME("not recognized UTCTime: %s\n", debugstr_an(values[i]->bv_val, values[i]->bv_len));
+ memset(&col->pADsValues[i].u.UTCTime, 0, sizeof(col->pADsValues[i].u.UTCTime));
+ continue;
+ }
+
+ if ((values[i]->bv_val[14] != '.' && values[i]->bv_val[14] != ',') ||
+ values[i]->bv_val[15] != '0' || values[i]->bv_val[16] != 'Z')
+ FIXME("not handled time zone: %s\n", debugstr_an(values[i]->bv_val + 14, values[i]->bv_len - 14));
+
+ TRACE("%s => %02u.%02u.%04u %02u:%02u:%02u\n", debugstr_an(values[i]->bv_val, values[i]->bv_len),
+ col->pADsValues[i].u.UTCTime.wDay, col->pADsValues[i].u.UTCTime.wMonth,
+ col->pADsValues[i].u.UTCTime.wYear, col->pADsValues[i].u.UTCTime.wHour,
+ col->pADsValues[i].u.UTCTime.wMinute, col->pADsValues[i].u.UTCTime.wSecond);
+ }
+
+ ldap_value_free_len(values);
+ col->hReserved = NULL;
+ break;
+ }
+
}
col->dwADsType = type;
diff --git a/dlls/adsldp/schema.c b/dlls/adsldp/schema.c
index f0ecfc3ac6..6965dc3274 100644
--- a/dlls/adsldp/schema.c
+++ b/dlls/adsldp/schema.c
@@ -93,6 +93,8 @@ ADSTYPEENUM get_schema_type(const WCHAR *name, const struct attribute_type *at,
return ADSTYPE_DN_STRING;
if (!wcscmp(type->syntax, L"1.3.6.1.4.1.1466.115.121.1.15"))
return ADSTYPE_CASE_IGNORE_STRING;
+ if (!wcscmp(type->syntax, L"1.3.6.1.4.1.1466.115.121.1.24"))
+ return ADSTYPE_UTC_TIME;
if (!wcscmp(type->syntax, L"1.3.6.1.4.1.1466.115.121.1.27"))
return ADSTYPE_INTEGER;
if (!wcscmp(type->syntax, L"1.3.6.1.4.1.1466.115.121.1.38"))
--
2.25.2
1
0
v2: Split from dsclient.h.
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/dsuiext/Makefile.in | 10 ++
dlls/dsuiext/dsuiext.c | 328 ++++++++++++++++++++++++++++++++++++++
dlls/dsuiext/dsuiext.idl | 25 +++
dlls/dsuiext/dsuiext.spec | 9 ++
4 files changed, 372 insertions(+)
create mode 100644 dlls/dsuiext/Makefile.in
create mode 100644 dlls/dsuiext/dsuiext.c
create mode 100644 dlls/dsuiext/dsuiext.idl
create mode 100644 dlls/dsuiext/dsuiext.spec
diff --git a/dlls/dsuiext/Makefile.in b/dlls/dsuiext/Makefile.in
new file mode 100644
index 0000000000..825ffd784c
--- /dev/null
+++ b/dlls/dsuiext/Makefile.in
@@ -0,0 +1,10 @@
+MODULE = dsuiext.dll
+IMPORTS = ole32 uuid
+
+EXTRADLLFLAGS = -mno-cygwin
+
+C_SRCS = \
+ dsuiext.c
+
+IDL_SRCS = \
+ dsuiext.idl
diff --git a/dlls/dsuiext/dsuiext.c b/dlls/dsuiext/dsuiext.c
new file mode 100644
index 0000000000..1978a8dd4e
--- /dev/null
+++ b/dlls/dsuiext/dsuiext.c
@@ -0,0 +1,328 @@
+/*
+ * Copyright 2020 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+#include "rpcproxy.h"
+#include "initguid.h"
+#include "iads.h"
+#include "dsclient.h"
+
+#include "wine/heap.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dsuiext);
+
+typedef struct
+{
+ IDsDisplaySpecifier IDsDisplaySpecifier_iface;
+ LONG ref;
+} DisplaySpec;
+
+static inline DisplaySpec *impl_from_IDsDisplaySpecifier(IDsDisplaySpecifier *iface)
+{
+ return CONTAINING_RECORD(iface, DisplaySpec, IDsDisplaySpecifier_iface);
+}
+
+static HRESULT WINAPI dispspec_QueryInterface(IDsDisplaySpecifier *iface, REFIID iid, void **obj)
+{
+ TRACE("%p,%s,%p\n", iface, debugstr_guid(iid), obj);
+
+ if (!iid || !obj) return E_INVALIDARG;
+
+ if (IsEqualGUID(iid, &IID_IUnknown) ||
+ IsEqualGUID(iid, &IID_IDsDisplaySpecifier))
+ {
+ iface->lpVtbl->AddRef(iface);
+ *obj = iface;
+ return S_OK;
+ }
+
+ FIXME("interface %s is not implemented\n", debugstr_guid(iid));
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI dispspec_AddRef(IDsDisplaySpecifier *iface)
+{
+ DisplaySpec *dispspec = impl_from_IDsDisplaySpecifier(iface);
+ return InterlockedIncrement(&dispspec->ref);
+}
+
+static ULONG WINAPI dispspec_Release(IDsDisplaySpecifier *iface)
+{
+ DisplaySpec *dispspec = impl_from_IDsDisplaySpecifier(iface);
+ LONG ref = InterlockedDecrement(&dispspec->ref);
+
+ if (!ref)
+ {
+ TRACE("destroying %p\n", iface);
+ heap_free(dispspec);
+ }
+
+ return ref;
+}
+
+static HRESULT WINAPI dispspec_SetServer(IDsDisplaySpecifier *iface, LPCWSTR server, LPCWSTR user,
+ LPCWSTR password, DWORD flags)
+{
+ FIXME("%p,%s,%s,%p,%08x: stub\n", iface, debugstr_w(server), debugstr_w(user), password, flags);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dispspec_SetLanguageID(IDsDisplaySpecifier *iface, LANGID lang)
+{
+ FIXME("%p,%08x: stub\n", iface, lang);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dispspec_GetDisplaySpecifier(IDsDisplaySpecifier *iface, LPCWSTR object,
+ REFIID iid, void **obj)
+{
+ FIXME("%p,%s,%s,%p: stub\n", iface, debugstr_w(object), debugstr_guid(iid), obj);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dispspec_GetIconLocation(IDsDisplaySpecifier *iface, LPCWSTR object,
+ DWORD flags, LPWSTR buffer, INT size, INT *id)
+{
+ FIXME("%p,%s,%08x,%p,%d,%p: stub\n", iface, debugstr_w(object), flags, buffer, size, id);
+ return E_NOTIMPL;
+}
+
+static HICON WINAPI dispspec_GetIcon(IDsDisplaySpecifier *iface, LPCWSTR object,
+ DWORD flags, INT cx, INT cy)
+{
+ FIXME("%p,%s,%08x,%dx%d: stub\n", iface, debugstr_w(object), flags, cx, cy);
+ return 0;
+}
+
+static HRESULT WINAPI dispspec_GetFriendlyClassName(IDsDisplaySpecifier *iface, LPCWSTR object,
+ LPWSTR buffer, INT size)
+{
+ FIXME("%p,%s,%p,%d: stub\n", iface, debugstr_w(object), buffer, size);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dispspec_GetFriendlyAttributeName(IDsDisplaySpecifier *iface, LPCWSTR object,
+ LPCWSTR name, LPWSTR buffer, UINT size)
+{
+ FIXME("%p,%s,%s,%p,%d: stub\n", iface, debugstr_w(object), debugstr_w(name), buffer, size);
+ return E_NOTIMPL;
+}
+
+static BOOL WINAPI dispspec_IsClassContainer(IDsDisplaySpecifier *iface, LPCWSTR object,
+ LPCWSTR path, DWORD flags)
+{
+ FIXME("%p,%s,%s,%08x: stub\n", iface, debugstr_w(object), debugstr_w(path), flags);
+ return FALSE;
+}
+
+static HRESULT WINAPI dispspec_GetClassCreationInfo(IDsDisplaySpecifier *iface, LPCWSTR object,
+ LPDSCLASSCREATIONINFO *info)
+{
+ FIXME("%p,%s,%p: stub\n", iface, debugstr_w(object), info);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dispspec_EnumClassAttributes(IDsDisplaySpecifier *iface, LPCWSTR object,
+ LPDSENUMATTRIBUTES cb, LPARAM param)
+{
+ FIXME("%p,%s,%p,%08lx: stub\n", iface, debugstr_w(object), cb, param);
+ return E_NOTIMPL;
+}
+
+static ADSTYPE WINAPI dispspec_GetAttributeADsType(IDsDisplaySpecifier *iface, LPCWSTR name)
+{
+ FIXME("%p,%s: stub\n", iface, debugstr_w(name));
+ return ADSTYPE_INVALID;
+}
+
+static const IDsDisplaySpecifierVtbl IDsDisplaySpecifier_vtbl =
+{
+ dispspec_QueryInterface,
+ dispspec_AddRef,
+ dispspec_Release,
+ dispspec_SetServer,
+ dispspec_SetLanguageID,
+ dispspec_GetDisplaySpecifier,
+ dispspec_GetIconLocation,
+ dispspec_GetIcon,
+ dispspec_GetFriendlyClassName,
+ dispspec_GetFriendlyAttributeName,
+ dispspec_IsClassContainer,
+ dispspec_GetClassCreationInfo,
+ dispspec_EnumClassAttributes,
+ dispspec_GetAttributeADsType
+};
+
+static HRESULT DsDisplaySpecifier_create(REFIID iid, void **obj)
+{
+ DisplaySpec *dispspec;
+ HRESULT hr;
+
+ dispspec = heap_alloc(sizeof(*dispspec));
+ if (!dispspec) return E_OUTOFMEMORY;
+
+ dispspec->IDsDisplaySpecifier_iface.lpVtbl = &IDsDisplaySpecifier_vtbl;
+ dispspec->ref = 1;
+
+ hr = dispspec->IDsDisplaySpecifier_iface.lpVtbl->QueryInterface(&dispspec->IDsDisplaySpecifier_iface, iid, obj);
+ dispspec->IDsDisplaySpecifier_iface.lpVtbl->Release(&dispspec->IDsDisplaySpecifier_iface);
+
+ return hr;
+}
+
+static const struct class_info
+{
+ const CLSID *clsid;
+ HRESULT (*constructor)(REFIID, void **);
+} class_info[] =
+{
+ { &CLSID_DsDisplaySpecifier, DsDisplaySpecifier_create }
+};
+
+typedef struct
+{
+ IClassFactory IClassFactory_iface;
+ LONG ref;
+ const struct class_info *info;
+} class_factory;
+
+static inline class_factory *impl_from_IClassFactory(IClassFactory *iface)
+{
+ return CONTAINING_RECORD(iface, class_factory, IClassFactory_iface);
+}
+
+static HRESULT WINAPI factory_QueryInterface(IClassFactory *iface, REFIID iid, LPVOID *obj)
+{
+ TRACE("%p,%s,%p\n", iface, debugstr_guid(iid), obj);
+
+ if (!iid || !obj) return E_INVALIDARG;
+
+ if (IsEqualIID(iid, &IID_IUnknown) ||
+ IsEqualIID(iid, &IID_IClassFactory))
+ {
+ IClassFactory_AddRef(iface);
+ *obj = iface;
+ return S_OK;
+ }
+
+ *obj = NULL;
+ FIXME("interface %s is not implemented\n", debugstr_guid(iid));
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI factory_AddRef(IClassFactory *iface)
+{
+ class_factory *factory = impl_from_IClassFactory(iface);
+ ULONG ref = InterlockedIncrement(&factory->ref);
+
+ TRACE("(%p) ref %u\n", iface, ref);
+
+ return ref;
+}
+
+static ULONG WINAPI factory_Release(IClassFactory *iface)
+{
+ class_factory *factory = impl_from_IClassFactory(iface);
+ ULONG ref = InterlockedDecrement(&factory->ref);
+
+ TRACE("(%p) ref %u\n", iface, ref);
+
+ if (!ref)
+ heap_free(factory);
+
+ return ref;
+}
+
+static HRESULT WINAPI factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID iid, void **obj)
+{
+ class_factory *factory = impl_from_IClassFactory(iface);
+
+ TRACE("%p,%s,%p\n", outer, debugstr_guid(iid), obj);
+
+ if (!iid || !obj) return E_INVALIDARG;
+
+ *obj = NULL;
+ if (outer) return CLASS_E_NOAGGREGATION;
+
+ return factory->info->constructor(iid, obj);
+}
+
+static HRESULT WINAPI factory_LockServer(IClassFactory *iface, BOOL lock)
+{
+ FIXME("%p,%d: stub\n", iface, lock);
+ return S_OK;
+}
+
+static const struct IClassFactoryVtbl factory_vtbl =
+{
+ factory_QueryInterface,
+ factory_AddRef,
+ factory_Release,
+ factory_CreateInstance,
+ factory_LockServer
+};
+
+static HRESULT factory_constructor(const struct class_info *info, REFIID riid, void **obj)
+{
+ class_factory *factory;
+ HRESULT hr;
+
+ factory = heap_alloc(sizeof(*factory));
+ if (!factory) return E_OUTOFMEMORY;
+
+ factory->IClassFactory_iface.lpVtbl = &factory_vtbl;
+ factory->ref = 1;
+ factory->info = info;
+
+ hr = IClassFactory_QueryInterface(&factory->IClassFactory_iface, riid, obj);
+ IClassFactory_Release(&factory->IClassFactory_iface);
+
+ return hr;
+}
+
+HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *obj)
+{
+ int i;
+
+ TRACE("%s,%s,%p\n", debugstr_guid(clsid), debugstr_guid(iid), obj);
+
+ if (!clsid || !iid || !obj) return E_INVALIDARG;
+
+ *obj = NULL;
+
+ for (i = 0; i < ARRAY_SIZE(class_info); i++)
+ {
+ if (IsEqualCLSID(class_info[i].clsid, clsid))
+ return factory_constructor(&class_info[i], iid, obj);
+ }
+
+ FIXME("class %s/%s is not implemented\n", debugstr_guid(clsid), debugstr_guid(iid));
+ return CLASS_E_CLASSNOTAVAILABLE;
+}
+
+HRESULT WINAPI DllCanUnloadNow(void)
+{
+ return S_FALSE;
+}
diff --git a/dlls/dsuiext/dsuiext.idl b/dlls/dsuiext/dsuiext.idl
new file mode 100644
index 0000000000..3fa84ca42b
--- /dev/null
+++ b/dlls/dsuiext/dsuiext.idl
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2020 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#pragma makedep register
+
+[
+ uuid(1ab4a8c0-6a0b-11d2-ad49-00c04fa31a86),
+ threading(apartment)
+]
+coclass DisplaySpecifier { interface IDsDisplaySpecifier; }
diff --git a/dlls/dsuiext/dsuiext.spec b/dlls/dsuiext/dsuiext.spec
new file mode 100644
index 0000000000..86925ec750
--- /dev/null
+++ b/dlls/dsuiext/dsuiext.spec
@@ -0,0 +1,9 @@
+@ stdcall -private DllCanUnloadNow()
+@ stdcall -private DllGetClassObject(ptr ptr ptr)
+@ stub DllInstall
+@ stub DllRegisterServer
+@ stub DllUnregisterServer
+@ stub DsBrowseForContainerA
+@ stub DsBrowseForContainerW
+@ stub DsGetFriendlyClassName
+@ stub DsGetIcon
--
2.25.2
1
0
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
include/Makefile.in | 1 +
include/dsclient.h | 61 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+)
create mode 100644 include/dsclient.h
diff --git a/include/Makefile.in b/include/Makefile.in
index eea1543822..32b72107b8 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -232,6 +232,7 @@ SOURCES = \
dplobby8.h \
dpnathlp.h \
drmexternals.idl \
+ dsclient.h \
dsconf.h \
dsgetdc.h \
dshow.h \
diff --git a/include/dsclient.h b/include/dsclient.h
new file mode 100644
index 0000000000..c19cf35e9b
--- /dev/null
+++ b/include/dsclient.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2020 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __DSCLIENT_H_
+#define __DSCLIENT_H_
+
+DEFINE_GUID(CLSID_DsDisplaySpecifier,0x1ab4a8c0,0x6a0b,0x11d2,0xad,0x49,0x00,0xc0,0x4f,0xa3,0x1a,0x86);
+#define IID_IDsDisplaySpecifier CLSID_DsDisplaySpecifier
+
+#define DSECAF_NOTLISTED 0x00000001
+
+typedef HRESULT (CALLBACK *LPDSENUMATTRIBUTES)(LPARAM, LPCWSTR, LPCWSTR, DWORD);
+
+#define DSCCIF_HASWIZARDDIALOG 0x00000001
+#define DSCCIF_HASWIZARDPRIMARYPAGE 0x00000002
+
+typedef struct
+{
+ DWORD dwFlags;
+ CLSID clsidWizardDialog;
+ CLSID clsidWizardPrimaryPage;
+ DWORD cWizardExtensions;
+ CLSID aWizardExtensions[1];
+} DSCLASSCREATIONINFO, *LPDSCLASSCREATIONINFO;
+
+#undef INTERFACE
+#define INTERFACE IDsDisplaySpecifier
+DECLARE_INTERFACE_IID_(IDsDisplaySpecifier, IUnknown, "1ab4a8c0-6a0b-11d2-ad49-00c04fa31a86")
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID iid, void **obj) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(SetServer)(THIS_ LPCWSTR server, LPCWSTR user, LPCWSTR password, DWORD flags) PURE;
+ STDMETHOD(SetLanguageID)(THIS_ LANGID lang) PURE;
+ STDMETHOD(GetDisplaySpecifier)(THIS_ LPCWSTR object, REFIID iid, void **obj) PURE;
+ STDMETHOD(GetIconLocation)(THIS_ LPCWSTR object, DWORD flags, LPWSTR buffer, INT size, INT *id) PURE;
+ STDMETHOD_(HICON,GetIcon)(THIS_ LPCWSTR object, DWORD flags, INT cx, INT cy) PURE;
+ STDMETHOD(GetFriendlyClassName)(THIS_ LPCWSTR object, LPWSTR buffer, INT size) PURE;
+ STDMETHOD(GetFriendlyAttributeName)(THIS_ LPCWSTR object, LPCWSTR name, LPWSTR buffer, UINT size) PURE;
+ STDMETHOD_(BOOL,IsClassContainer)(THIS_ LPCWSTR object, LPCWSTR path, DWORD flags) PURE;
+ STDMETHOD(GetClassCreationInfo)(THIS_ LPCWSTR object, LPDSCLASSCREATIONINFO *info) PURE;
+ STDMETHOD(EnumClassAttributes)(THIS_ LPCWSTR object, LPDSENUMATTRIBUTES cb, LPARAM param) PURE;
+ STDMETHOD_(ADSTYPE,GetAttributeADsType)(THIS_ LPCWSTR name) PURE;
+};
+
+#endif /* __DSCLIENT_H_ */
--
2.25.2
1
0
[resend PATCH] user32: Set PAINTSTRUCT fErase field depending on the last WM_ERASEBKGND result.
by Paul Gofman 07 Apr '20
by Paul Gofman 07 Apr '20
07 Apr '20
Fixes menu update in Diablo 1.
Signed-off-by: Paul Gofman <gofmanp(a)gmail.com>
---
dlls/user32/painting.c | 26 +++++++++++-
dlls/user32/tests/win.c | 94 +++++++++++++++++++++++++++++++++++++++++
dlls/user32/win.h | 1 +
3 files changed, 120 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c
index 313c5fa1e6..6ab53a2372 100644
--- a/dlls/user32/painting.c
+++ b/dlls/user32/painting.c
@@ -725,7 +725,20 @@ static BOOL send_erase( HWND hwnd, UINT flags, HRGN client_rgn,
{
/* don't erase if the clip box is empty */
if (type != NULLREGION)
+ {
+ WND *wnd_ptr;
+
need_erase = !SendMessageW( hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0 );
+ if ((wnd_ptr = WIN_GetPtr( hwnd )) && wnd_ptr != WND_OTHER_PROCESS && wnd_ptr != WND_DESKTOP)
+ {
+ if (need_erase)
+ wnd_ptr->flags |= WIN_PS_NEED_ERASE_BKGND;
+ else
+ wnd_ptr->flags &= ~WIN_PS_NEED_ERASE_BKGND;
+
+ WIN_ReleasePtr( wnd_ptr );
+ }
+ }
}
if (!hdc_ret) release_dc( hwnd, hdc, TRUE );
}
@@ -943,6 +956,7 @@ HDC WINAPI BeginPaint( HWND hwnd, PAINTSTRUCT *lps )
BOOL erase;
RECT rect;
UINT flags = UPDATE_NONCLIENT | UPDATE_ERASE | UPDATE_PAINT | UPDATE_INTERNALPAINT | UPDATE_NOCHILDREN;
+ WND *wnd_ptr;
HideCaret( hwnd );
@@ -957,7 +971,17 @@ HDC WINAPI BeginPaint( HWND hwnd, PAINTSTRUCT *lps )
release_dc( hwnd, hdc, TRUE );
return 0;
}
- lps->fErase = erase;
+
+ if (!(wnd_ptr = WIN_GetPtr( hwnd )) || wnd_ptr == WND_OTHER_PROCESS || wnd_ptr == WND_DESKTOP)
+ {
+ lps->fErase = erase;
+ }
+ else
+ {
+ lps->fErase = !!(wnd_ptr->flags & WIN_PS_NEED_ERASE_BKGND);
+ WIN_ReleasePtr( wnd_ptr );
+ }
+
lps->rcPaint = rect;
lps->hdc = hdc;
return hdc;
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 25d643f54a..c02af08a90 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -11830,6 +11830,99 @@ static void test_other_process_window(const char *argv0)
DestroyWindow(hwnd);
}
+static BOOL test_paintstruct_erase_bkgnd;
+static BOOL test_paintstruct_wm_erasebkgnd_received;
+static BOOL test_paintstruct_wm_paint_received, test_paintstruct_ferase;
+
+static LRESULT WINAPI paintstruct_erase_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ switch (msg)
+ {
+ case WM_ERASEBKGND:
+ {
+ test_paintstruct_wm_erasebkgnd_received = TRUE;
+ return test_paintstruct_erase_bkgnd;
+ }
+
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ HDC hdc;
+
+ test_paintstruct_wm_paint_received = TRUE;
+ hdc = BeginPaint(hwnd, &ps);
+ ok(!!hdc, "Null hdc.\n");
+ test_paintstruct_ferase = ps.fErase;
+ EndPaint(hwnd, &ps);
+ return 0;
+ }
+ }
+ return DefWindowProcA(hwnd, msg, wparam, lparam);
+}
+
+static void test_paintstruct_erase(void)
+{
+ WNDCLASSA cls;
+ HWND hwnd;
+ BOOL ret;
+
+ cls.style = 0;
+ cls.lpfnWndProc = paintstruct_erase_window_procA;
+ cls.cbClsExtra = 0;
+ cls.cbWndExtra = 0;
+ cls.hInstance = GetModuleHandleA(0);
+ cls.hIcon = 0;
+ cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
+ cls.hbrBackground = GetStockObject(WHITE_BRUSH);
+ cls.lpszMenuName = NULL;
+ cls.lpszClassName = "paintstruct_erase_class";
+ ret = RegisterClassA(&cls);
+ ok(ret, "Failed to register a test class.\n");
+
+ test_paintstruct_wm_paint_received = test_paintstruct_wm_erasebkgnd_received = FALSE;
+ test_paintstruct_erase_bkgnd = FALSE;
+ hwnd = CreateWindowExA(0, "paintstruct_erase_class", NULL, WS_POPUP | WS_VISIBLE,
+ 100, 100, 100, 100, 0, 0, NULL, NULL);
+ ok(!!hwnd, "CreateWindowEx failed.\n");
+
+ flush_events(TRUE);
+ ok(test_paintstruct_wm_erasebkgnd_received, "WM_ERASEBKGND not received.\n");
+ ok(test_paintstruct_wm_paint_received, "WM_PAINT not received.\n");
+ ok(test_paintstruct_ferase, "Unexpected fErase %#x.\n", test_paintstruct_ferase);
+
+ test_paintstruct_wm_paint_received = test_paintstruct_wm_erasebkgnd_received = FALSE;
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
+ flush_events(TRUE);
+ ok(!test_paintstruct_wm_erasebkgnd_received, "WM_ERASEBKGND received.\n");
+ ok(test_paintstruct_wm_paint_received, "WM_PAINT not received.\n");
+ ok(test_paintstruct_ferase, "Unexpected fErase %#x.\n", test_paintstruct_ferase);
+
+ test_paintstruct_wm_paint_received = test_paintstruct_wm_erasebkgnd_received = FALSE;
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
+ flush_events(TRUE);
+ ok(!test_paintstruct_wm_erasebkgnd_received, "WM_ERASEBKGND received.\n");
+ ok(test_paintstruct_wm_paint_received, "WM_PAINT not received.\n");
+ ok(test_paintstruct_ferase, "Unexpected fErase %#x.\n", test_paintstruct_ferase);
+
+ test_paintstruct_erase_bkgnd = TRUE;
+ test_paintstruct_wm_paint_received = test_paintstruct_wm_erasebkgnd_received = FALSE;
+ RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE);
+ flush_events(TRUE);
+ ok(test_paintstruct_wm_erasebkgnd_received, "WM_ERASEBKGND not received.\n");
+ ok(test_paintstruct_wm_paint_received, "WM_PAINT not received.\n");
+ ok(!test_paintstruct_ferase, "Unexpected fErase %#x.\n", test_paintstruct_ferase);
+
+ test_paintstruct_wm_paint_received = test_paintstruct_wm_erasebkgnd_received = FALSE;
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
+ flush_events(TRUE);
+ ok(!test_paintstruct_wm_erasebkgnd_received, "WM_ERASEBKGND received.\n");
+ ok(test_paintstruct_wm_paint_received, "WM_PAINT not received.\n");
+ ok(!test_paintstruct_ferase, "Unexpected fErase %#x.\n", test_paintstruct_ferase);
+
+ DestroyWindow(hwnd);
+ UnregisterClassA("paintstruct_erase_class", GetModuleHandleA(NULL));
+}
+
START_TEST(win)
{
char **argv;
@@ -11995,6 +12088,7 @@ START_TEST(win)
test_window_placement();
test_arrange_iconic_windows();
test_other_process_window(argv[0]);
+ test_paintstruct_erase();
/* add the tests above this line */
if (hhook) UnhookWindowsHookEx(hhook);
diff --git a/dlls/user32/win.h b/dlls/user32/win.h
index 1f51fd6331..eecfa20eea 100644
--- a/dlls/user32/win.h
+++ b/dlls/user32/win.h
@@ -79,6 +79,7 @@ typedef struct tagWND
#define WIN_NEEDS_SHOW_OWNEDPOPUP 0x0020 /* WM_SHOWWINDOW:SC_SHOW must be sent in the next ShowOwnedPopup call */
#define WIN_CHILDREN_MOVED 0x0040 /* children may have moved, ignore stored positions */
#define WIN_HAS_IME_WIN 0x0080 /* the window has been registered with imm32 */
+#define WIN_PS_NEED_ERASE_BKGND 0x0100 /* Need to set fErase in PAINTSTRUCT */
/* Window functions */
extern HWND get_hwnd_message_parent(void) DECLSPEC_HIDDEN;
--
2.25.2
2
1
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/winhttp/net.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c
index c88def5b51..2905d5c535 100644
--- a/dlls/winhttp/net.c
+++ b/dlls/winhttp/net.c
@@ -484,6 +484,10 @@ static DWORD read_ssl_chunk( struct netconn *conn, void *buf, SIZE_T buf_size, S
case SEC_E_OK:
break;
+ case SEC_I_RENEGOTIATE:
+ TRACE("renegotiate\n");
+ return ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED;
+
case SEC_I_CONTEXT_EXPIRED:
TRACE("context expired\n");
*eof = TRUE;
--
2.20.1
1
0
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/winhttp/cookie.c | 11 +-
dlls/winhttp/net.c | 177 +++++-----
dlls/winhttp/request.c | 572 ++++++++++++++++-----------------
dlls/winhttp/session.c | 2 +-
dlls/winhttp/winhttp_private.h | 16 +-
5 files changed, 385 insertions(+), 393 deletions(-)
diff --git a/dlls/winhttp/cookie.c b/dlls/winhttp/cookie.c
index 83efc7f85c..6247e379ec 100644
--- a/dlls/winhttp/cookie.c
+++ b/dlls/winhttp/cookie.c
@@ -319,10 +319,11 @@ end:
return ret;
}
-BOOL add_cookie_headers( struct request *request )
+DWORD add_cookie_headers( struct request *request )
{
struct list *domain_cursor;
struct session *session = request->connect->session;
+ DWORD ret = ERROR_SUCCESS;
EnterCriticalSection( &session->cs );
@@ -351,7 +352,7 @@ BOOL add_cookie_headers( struct request *request )
if (!(header = heap_alloc( (len + 1) * sizeof(WCHAR) )))
{
LeaveCriticalSection( &session->cs );
- return FALSE;
+ return ERROR_OUTOFMEMORY;
}
memcpy( header, cookieW, len_cookie * sizeof(WCHAR) );
@@ -363,8 +364,8 @@ BOOL add_cookie_headers( struct request *request )
}
TRACE("%s\n", debugstr_w(header));
- add_request_headers( request, header, len,
- WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON );
+ ret = add_request_headers( request, header, len,
+ WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON );
heap_free( header );
}
}
@@ -372,5 +373,5 @@ BOOL add_cookie_headers( struct request *request )
}
LeaveCriticalSection( &session->cs );
- return TRUE;
+ return ret;
}
diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c
index c9da098f52..c88def5b51 100644
--- a/dlls/winhttp/net.c
+++ b/dlls/winhttp/net.c
@@ -176,23 +176,24 @@ static void set_blocking( struct netconn *conn, BOOL blocking )
ioctlsocket( conn->socket, FIONBIO, &state );
}
-struct netconn *netconn_create( struct hostdata *host, const struct sockaddr_storage *sockaddr, int timeout )
+DWORD netconn_create( struct hostdata *host, const struct sockaddr_storage *sockaddr, int timeout,
+ struct netconn **ret_conn )
{
struct netconn *conn;
unsigned int addr_len;
- BOOL ret = FALSE;
+ DWORD ret;
winsock_init();
- conn = heap_alloc_zero(sizeof(*conn));
- if (!conn) return NULL;
+ if (!(conn = heap_alloc_zero( sizeof(*conn) ))) return ERROR_OUTOFMEMORY;
conn->host = host;
conn->sockaddr = *sockaddr;
if ((conn->socket = socket( sockaddr->ss_family, SOCK_STREAM, 0 )) == -1)
{
- WARN("unable to create socket (%u)\n", WSAGetLastError());
- heap_free(conn);
- return NULL;
+ ret = WSAGetLastError();
+ WARN("unable to create socket (%u)\n", ret);
+ heap_free( conn );
+ return ret;
}
switch (conn->sockaddr.ss_family)
@@ -206,16 +207,16 @@ struct netconn *netconn_create( struct hostdata *host, const struct sockaddr_sto
default:
ERR( "unhandled family %u\n", conn->sockaddr.ss_family );
heap_free( conn );
- return NULL;
+ return ERROR_INVALID_PARAMETER;
}
if (timeout > 0) set_blocking( conn, FALSE );
- if (!connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len )) ret = TRUE;
+ if (!connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len )) ret = ERROR_SUCCESS;
else
{
- DWORD err = WSAGetLastError();
- if (err == WSAEWOULDBLOCK || err == WSAEINPROGRESS)
+ ret = WSAGetLastError();
+ if (ret == WSAEWOULDBLOCK || ret == WSAEINPROGRESS)
{
FD_SET set;
TIMEVAL timeval = { 0, timeout * 1000 };
@@ -223,21 +224,23 @@ struct netconn *netconn_create( struct hostdata *host, const struct sockaddr_sto
FD_ZERO( &set );
FD_SET( conn->socket, &set );
- if ((res = select( conn->socket + 1, NULL, &set, NULL, &timeval )) > 0) ret = TRUE;
- else if (!res) SetLastError( ERROR_WINHTTP_TIMEOUT );
+ if ((res = select( conn->socket + 1, NULL, &set, NULL, &timeval )) > 0) ret = ERROR_SUCCESS;
+ else if (!res) ret = ERROR_WINHTTP_TIMEOUT;
}
}
if (timeout > 0) set_blocking( conn, TRUE );
- if (!ret)
+ if (ret)
{
- WARN("unable to connect to host (%u)\n", GetLastError());
+ WARN("unable to connect to host (%u)\n", ret);
closesocket( conn->socket );
heap_free( conn );
- return NULL;
+ return ret;
}
- return conn;
+
+ *ret_conn = conn;
+ return ERROR_SUCCESS;
}
void netconn_close( struct netconn *conn )
@@ -254,8 +257,8 @@ void netconn_close( struct netconn *conn )
heap_free(conn);
}
-BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD security_flags, CredHandle *cred_handle,
- BOOL check_revocation)
+DWORD netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD security_flags, CredHandle *cred_handle,
+ BOOL check_revocation )
{
SecBuffer out_buf = {0, SECBUFFER_TOKEN, NULL}, in_bufs[2] = {{0, SECBUFFER_TOKEN}, {0, SECBUFFER_EMPTY}};
SecBufferDesc out_desc = {SECBUFFER_VERSION, 1, &out_buf}, in_desc = {SECBUFFER_VERSION, 2, in_bufs};
@@ -271,9 +274,7 @@ BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD securi
const DWORD isc_req_flags = ISC_REQ_ALLOCATE_MEMORY|ISC_REQ_USE_SESSION_KEY|ISC_REQ_CONFIDENTIALITY
|ISC_REQ_SEQUENCE_DETECT|ISC_REQ_REPLAY_DETECT|ISC_REQ_MANUAL_CRED_VALIDATION;
- read_buf = heap_alloc(read_buf_size);
- if(!read_buf)
- return FALSE;
+ if (!(read_buf = heap_alloc( read_buf_size ))) return ERROR_OUTOFMEMORY;
status = InitializeSecurityContextW(cred_handle, NULL, hostname, isc_req_flags, 0, 0, NULL, 0,
&ctx, &out_desc, &attrs, NULL);
@@ -364,7 +365,7 @@ BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD securi
conn->ssl_buf = heap_alloc(conn->ssl_sizes.cbHeader + conn->ssl_sizes.cbMaximumMessage + conn->ssl_sizes.cbTrailer);
if(!conn->ssl_buf) {
- res = GetLastError();
+ res = ERROR_OUTOFMEMORY;
break;
}
}
@@ -377,18 +378,17 @@ BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD securi
heap_free(conn->ssl_buf);
conn->ssl_buf = NULL;
DeleteSecurityContext(&ctx);
- SetLastError(res ? res : ERROR_WINHTTP_SECURE_CHANNEL_ERROR);
- return FALSE;
+ return ERROR_WINHTTP_SECURE_CHANNEL_ERROR;
}
TRACE("established SSL connection\n");
conn->secure = TRUE;
conn->ssl_ctx = ctx;
- return TRUE;
+ return ERROR_SUCCESS;
}
-static BOOL send_ssl_chunk(struct netconn *conn, const void *msg, size_t size)
+static DWORD send_ssl_chunk( struct netconn *conn, const void *msg, size_t size )
{
SecBuffer bufs[4] = {
{conn->ssl_sizes.cbHeader, SECBUFFER_STREAM_HEADER, conn->ssl_buf},
@@ -399,46 +399,50 @@ static BOOL send_ssl_chunk(struct netconn *conn, const void *msg, size_t size)
SecBufferDesc buf_desc = {SECBUFFER_VERSION, ARRAY_SIZE(bufs), bufs};
SECURITY_STATUS res;
- memcpy(bufs[1].pvBuffer, msg, size);
- res = EncryptMessage(&conn->ssl_ctx, 0, &buf_desc, 0);
- if(res != SEC_E_OK) {
- WARN("EncryptMessage failed\n");
- return FALSE;
+ memcpy( bufs[1].pvBuffer, msg, size );
+ if ((res = EncryptMessage(&conn->ssl_ctx, 0, &buf_desc, 0)) != SEC_E_OK)
+ {
+ WARN("EncryptMessage failed: %08x\n", res);
+ return res;
}
- if(sock_send(conn->socket, conn->ssl_buf, bufs[0].cbBuffer+bufs[1].cbBuffer+bufs[2].cbBuffer, 0) < 1) {
+ if (sock_send( conn->socket, conn->ssl_buf, bufs[0].cbBuffer + bufs[1].cbBuffer + bufs[2].cbBuffer, 0 ) < 1)
+ {
WARN("send failed\n");
- return FALSE;
+ return WSAGetLastError();
}
- return TRUE;
+ return ERROR_SUCCESS;
}
-BOOL netconn_send( struct netconn *conn, const void *msg, size_t len, int *sent )
+DWORD netconn_send( struct netconn *conn, const void *msg, size_t len, int *sent )
{
if (conn->secure)
{
const BYTE *ptr = msg;
size_t chunk_size;
+ DWORD res;
*sent = 0;
-
- while(len) {
- chunk_size = min(len, conn->ssl_sizes.cbMaximumMessage);
- if(!send_ssl_chunk(conn, ptr, chunk_size))
- return FALSE;
+ while (len)
+ {
+ chunk_size = min( len, conn->ssl_sizes.cbMaximumMessage );
+ if ((res = send_ssl_chunk( conn, ptr, chunk_size )))
+ return res;
*sent += chunk_size;
ptr += chunk_size;
len -= chunk_size;
}
- return TRUE;
+ return ERROR_SUCCESS;
}
- return ((*sent = sock_send( conn->socket, msg, len, 0 )) != -1);
+
+ if ((*sent = sock_send( conn->socket, msg, len, 0 )) < 0) return WSAGetLastError();
+ return ERROR_SUCCESS;
}
-static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZE_T *ret_size, BOOL *eof)
+static DWORD read_ssl_chunk( struct netconn *conn, void *buf, SIZE_T buf_size, SIZE_T *ret_size, BOOL *eof )
{
const SIZE_T ssl_buf_size = conn->ssl_sizes.cbHeader+conn->ssl_sizes.cbMaximumMessage+conn->ssl_sizes.cbTrailer;
SecBuffer bufs[4];
@@ -456,13 +460,13 @@ static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZ
heap_free(conn->extra_buf);
conn->extra_buf = NULL;
}else {
- buf_len = sock_recv(conn->socket, conn->ssl_buf+conn->extra_len, ssl_buf_size-conn->extra_len, 0);
- if(buf_len < 0)
- return FALSE;
+ if ((buf_len = sock_recv( conn->socket, conn->ssl_buf + conn->extra_len, ssl_buf_size - conn->extra_len, 0)) < 0)
+ return WSAGetLastError();
- if(!buf_len) {
+ if (!buf_len)
+ {
*eof = TRUE;
- return TRUE;
+ return ERROR_SUCCESS;
}
}
@@ -475,28 +479,30 @@ static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZ
bufs[0].cbBuffer = buf_len;
bufs[0].pvBuffer = conn->ssl_buf;
- res = DecryptMessage(&conn->ssl_ctx, &buf_desc, 0, NULL);
- switch(res) {
+ switch ((res = DecryptMessage( &conn->ssl_ctx, &buf_desc, 0, NULL )))
+ {
case SEC_E_OK:
break;
+
case SEC_I_CONTEXT_EXPIRED:
TRACE("context expired\n");
*eof = TRUE;
- return TRUE;
+ return ERROR_SUCCESS;
+
case SEC_E_INCOMPLETE_MESSAGE:
assert(buf_len < ssl_buf_size);
- size = sock_recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, 0);
- if(size < 1)
- return FALSE;
+ if ((size = sock_recv( conn->socket, conn->ssl_buf + buf_len, ssl_buf_size - buf_len, 0 )) < 1)
+ return SEC_E_INCOMPLETE_MESSAGE;
buf_len += size;
continue;
+
default:
WARN("failed: %08x\n", res);
- return FALSE;
+ return res;
}
- } while(res != SEC_E_OK);
+ } while (res != SEC_E_OK);
for(i = 0; i < ARRAY_SIZE(bufs); i++) {
if(bufs[i].BufferType == SECBUFFER_DATA) {
@@ -506,7 +512,7 @@ static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZ
assert(!conn->peek_len);
conn->peek_msg_mem = conn->peek_msg = heap_alloc(bufs[i].cbBuffer - size);
if(!conn->peek_msg)
- return FALSE;
+ return ERROR_OUTOFMEMORY;
conn->peek_len = bufs[i].cbBuffer-size;
memcpy(conn->peek_msg, (char*)bufs[i].pvBuffer+size, conn->peek_len);
}
@@ -519,25 +525,26 @@ static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZ
if(bufs[i].BufferType == SECBUFFER_EXTRA) {
conn->extra_buf = heap_alloc(bufs[i].cbBuffer);
if(!conn->extra_buf)
- return FALSE;
+ return ERROR_OUTOFMEMORY;
conn->extra_len = bufs[i].cbBuffer;
memcpy(conn->extra_buf, bufs[i].pvBuffer, conn->extra_len);
}
}
- return TRUE;
+ return ERROR_SUCCESS;
}
-BOOL netconn_recv( struct netconn *conn, void *buf, size_t len, int flags, int *recvd )
+DWORD netconn_recv( struct netconn *conn, void *buf, size_t len, int flags, int *recvd )
{
*recvd = 0;
- if (!len) return TRUE;
+ if (!len) return ERROR_SUCCESS;
if (conn->secure)
{
- SIZE_T size, cread;
- BOOL res, eof;
+ SIZE_T size;
+ DWORD res;
+ BOOL eof;
if (conn->peek_msg)
{
@@ -553,32 +560,35 @@ BOOL netconn_recv( struct netconn *conn, void *buf, size_t len, int flags, int *
conn->peek_msg = NULL;
}
/* check if we have enough data from the peek buffer */
- if (!(flags & MSG_WAITALL) || *recvd == len) return TRUE;
+ if (!(flags & MSG_WAITALL) || *recvd == len) return ERROR_SUCCESS;
}
size = *recvd;
- do {
- res = read_ssl_chunk(conn, (BYTE*)buf+size, len-size, &cread, &eof);
- if(!res) {
- WARN("read_ssl_chunk failed\n");
- if(!size)
- return FALSE;
+ do
+ {
+ SIZE_T cread = 0;
+ if ((res = read_ssl_chunk( conn, (BYTE *)buf + size, len - size, &cread, &eof )))
+ {
+ WARN("read_ssl_chunk failed: %u\n", res);
+ if (!size) return res;
break;
}
-
- if(eof) {
+ if (eof)
+ {
TRACE("EOF\n");
break;
}
-
size += cread;
- }while(!size || ((flags & MSG_WAITALL) && size < len));
+
+ } while (!size || ((flags & MSG_WAITALL) && size < len));
TRACE("received %ld bytes\n", size);
*recvd = size;
- return TRUE;
+ return ERROR_SUCCESS;
}
- return ((*recvd = sock_recv( conn->socket, buf, len, flags )) != -1);
+
+ if ((*recvd = sock_recv( conn->socket, buf, len, flags )) < 0) return WSAGetLastError();
+ return ERROR_SUCCESS;
}
ULONG netconn_query_data_available( struct netconn *conn )
@@ -666,7 +676,7 @@ static void CALLBACK resolve_proc( TP_CALLBACK_INSTANCE *instance, void *ctx )
SetEvent( async->done );
}
-BOOL netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr_storage *addr, int timeout )
+DWORD netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr_storage *addr, int timeout )
{
DWORD ret;
@@ -678,23 +688,18 @@ BOOL netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr_stora
async.hostname = hostname;
async.port = port;
async.addr = addr;
- if (!(async.done = CreateEventW( NULL, FALSE, FALSE, NULL ))) return FALSE;
+ if (!(async.done = CreateEventW( NULL, FALSE, FALSE, NULL ))) return GetLastError();
if (!TrySubmitThreadpoolCallback( resolve_proc, &async, NULL ))
{
CloseHandle( async.done );
- return FALSE;
+ return GetLastError();
}
if (WaitForSingleObject( async.done, timeout ) != WAIT_OBJECT_0) ret = ERROR_WINHTTP_TIMEOUT;
else ret = async.result;
CloseHandle( async.done );
}
- if (ret)
- {
- SetLastError( ret );
- return FALSE;
- }
- return TRUE;
+ return ret;
}
const void *netconn_get_certificate( struct netconn *conn )
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 7c8e6ba89e..fbccf0228b 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -173,18 +173,18 @@ static void CALLBACK task_proc( TP_CALLBACK_INSTANCE *instance, void *ctx )
}
}
-static BOOL queue_task( struct task_header *task )
+static DWORD queue_task( struct task_header *task )
{
struct request *request = task->request;
if (!request->task_wait)
{
- if (!(request->task_wait = CreateEventW( NULL, FALSE, FALSE, NULL ))) return FALSE;
+ if (!(request->task_wait = CreateEventW( NULL, FALSE, FALSE, NULL ))) return ERROR_OUTOFMEMORY;
if (!(request->task_cancel = CreateEventW( NULL, FALSE, FALSE, NULL )))
{
CloseHandle( request->task_wait );
request->task_wait = NULL;
- return FALSE;
+ return ERROR_OUTOFMEMORY;
}
if (!TrySubmitThreadpoolCallback( task_proc, request, NULL ))
{
@@ -192,7 +192,7 @@ static BOOL queue_task( struct task_header *task )
request->task_wait = NULL;
CloseHandle( request->task_cancel );
request->task_cancel = NULL;
- return FALSE;
+ return GetLastError();
}
request->task_proc_running = TRUE;
InitializeCriticalSection( &request->task_cs );
@@ -205,7 +205,7 @@ static BOOL queue_task( struct task_header *task )
LeaveCriticalSection( &request->task_cs );
SetEvent( request->task_wait );
- return TRUE;
+ return ERROR_SUCCESS;
}
static void free_header( struct header *header )
@@ -307,7 +307,7 @@ static int get_header_index( struct request *request, const WCHAR *field, int re
return index;
}
-static BOOL insert_header( struct request *request, struct header *header )
+static DWORD insert_header( struct request *request, struct header *header )
{
DWORD count = request->num_headers + 1;
struct header *hdrs;
@@ -316,20 +316,19 @@ static BOOL insert_header( struct request *request, struct header *header )
hdrs = heap_realloc_zero( request->headers, sizeof(struct header) * count );
else
hdrs = heap_alloc_zero( sizeof(struct header) );
- if (!hdrs) return FALSE;
+ if (!hdrs) return ERROR_OUTOFMEMORY;
request->headers = hdrs;
request->headers[count - 1].field = strdupW( header->field );
request->headers[count - 1].value = strdupW( header->value );
request->headers[count - 1].is_request = header->is_request;
request->num_headers = count;
- return TRUE;
+ return ERROR_SUCCESS;
}
-static BOOL delete_header( struct request *request, DWORD index )
+static void delete_header( struct request *request, DWORD index )
{
- if (!request->num_headers) return FALSE;
- if (index >= request->num_headers) return FALSE;
+ if (!request->num_headers || index >= request->num_headers) return;
request->num_headers--;
heap_free( request->headers[index].field );
@@ -338,10 +337,9 @@ static BOOL delete_header( struct request *request, DWORD index )
memmove( &request->headers[index], &request->headers[index + 1],
(request->num_headers - index) * sizeof(struct header) );
memset( &request->headers[request->num_headers], 0, sizeof(struct header) );
- return TRUE;
}
-BOOL process_header( struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only )
+DWORD process_header( struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only )
{
int index;
struct header hdr;
@@ -350,7 +348,7 @@ BOOL process_header( struct request *request, const WCHAR *field, const WCHAR *v
if ((index = get_header_index( request, field, 0, request_only )) >= 0)
{
- if (flags & WINHTTP_ADDREQ_FLAG_ADD_IF_NEW) return FALSE;
+ if (flags & WINHTTP_ADDREQ_FLAG_ADD_IF_NEW) return ERROR_WINHTTP_HEADER_ALREADY_EXISTS;
}
if (flags & WINHTTP_ADDREQ_FLAG_REPLACE)
@@ -358,13 +356,9 @@ BOOL process_header( struct request *request, const WCHAR *field, const WCHAR *v
if (index >= 0)
{
delete_header( request, index );
- if (!value || !value[0]) return TRUE;
- }
- else if (!(flags & WINHTTP_ADDREQ_FLAG_ADD))
- {
- SetLastError( ERROR_WINHTTP_HEADER_NOT_FOUND );
- return FALSE;
+ if (!value || !value[0]) return ERROR_SUCCESS;
}
+ else if (!(flags & WINHTTP_ADDREQ_FLAG_ADD)) return ERROR_WINHTTP_HEADER_NOT_FOUND;
hdr.field = (LPWSTR)field;
hdr.value = (LPWSTR)value;
@@ -385,14 +379,14 @@ BOOL process_header( struct request *request, const WCHAR *field, const WCHAR *v
len_value = lstrlenW( value );
len = len_orig + len_value + 2;
- if (!(tmp = heap_realloc( header->value, (len + 1) * sizeof(WCHAR) ))) return FALSE;
+ if (!(tmp = heap_realloc( header->value, (len + 1) * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
header->value = tmp;
header->value[len_orig++] = (flags & WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA) ? ',' : ';';
header->value[len_orig++] = ' ';
memcpy( &header->value[len_orig], value, len_value * sizeof(WCHAR) );
header->value[len] = 0;
- return TRUE;
+ return ERROR_SUCCESS;
}
else
{
@@ -403,18 +397,18 @@ BOOL process_header( struct request *request, const WCHAR *field, const WCHAR *v
}
}
- return TRUE;
+ return ERROR_SUCCESS;
}
-BOOL add_request_headers( struct request *request, const WCHAR *headers, DWORD len, DWORD flags )
+DWORD add_request_headers( struct request *request, const WCHAR *headers, DWORD len, DWORD flags )
{
- BOOL ret = FALSE;
+ DWORD ret = ERROR_WINHTTP_INVALID_HEADER;
WCHAR *buffer, *p, *q;
struct header *header;
if (len == ~0u) len = lstrlenW( headers );
- if (!len) return TRUE;
- if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
+ if (!len) return ERROR_SUCCESS;
+ if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
memcpy( buffer, headers, len * sizeof(WCHAR) );
buffer[len] = 0;
@@ -444,7 +438,7 @@ BOOL add_request_headers( struct request *request, const WCHAR *headers, DWORD l
free_header( header );
}
p = q;
- } while (ret);
+ } while (!ret);
heap_free( buffer );
return ret;
@@ -455,7 +449,7 @@ BOOL add_request_headers( struct request *request, const WCHAR *headers, DWORD l
*/
BOOL WINAPI WinHttpAddRequestHeaders( HINTERNET hrequest, LPCWSTR headers, DWORD len, DWORD flags )
{
- BOOL ret;
+ DWORD ret;
struct request *request;
TRACE("%p, %s, %u, 0x%08x\n", hrequest, debugstr_wn(headers, len), len, flags);
@@ -480,8 +474,8 @@ BOOL WINAPI WinHttpAddRequestHeaders( HINTERNET hrequest, LPCWSTR headers, DWORD
ret = add_request_headers( request, headers, len, flags );
release_object( &request->hdr );
- if (ret) SetLastError( ERROR_SUCCESS );
- return ret;
+ SetLastError( ret );
+ return !ret;
}
static WCHAR *build_absolute_request_path( struct request *request, const WCHAR **path )
@@ -556,13 +550,13 @@ static WCHAR *build_request_string( struct request *request )
#define QUERY_MODIFIER_MASK (WINHTTP_QUERY_FLAG_REQUEST_HEADERS | WINHTTP_QUERY_FLAG_SYSTEMTIME | WINHTTP_QUERY_FLAG_NUMBER)
-static BOOL query_headers( struct request *request, DWORD level, const WCHAR *name, void *buffer, DWORD *buflen,
- DWORD *index )
+static DWORD query_headers( struct request *request, DWORD level, const WCHAR *name, void *buffer, DWORD *buflen,
+ DWORD *index )
{
struct header *header = NULL;
- BOOL request_only, ret = FALSE;
+ BOOL request_only;
int requested_index, header_index = -1;
- DWORD attr, len;
+ DWORD attr, len, ret = ERROR_WINHTTP_HEADER_NOT_FOUND;
request_only = level & WINHTTP_QUERY_FLAG_REQUEST_HEADERS;
requested_index = index ? *index : 0;
@@ -584,11 +578,10 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
else
headers = request->raw_headers;
- if (!(p = headers)) return FALSE;
+ if (!(p = headers)) return ERROR_OUTOFMEMORY;
for (len = 0; *p; p++) if (*p != '\r') len++;
- if (!buffer || len * sizeof(WCHAR) > *buflen)
- SetLastError( ERROR_INSUFFICIENT_BUFFER );
+ if (!buffer || len * sizeof(WCHAR) > *buflen) ret = ERROR_INSUFFICIENT_BUFFER;
else
{
for (p = headers, q = buffer; *p; p++, q++)
@@ -602,7 +595,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
}
TRACE("returning data: %s\n", debugstr_wn(buffer, len));
if (len) len--;
- ret = TRUE;
+ ret = ERROR_SUCCESS;
}
*buflen = len * sizeof(WCHAR);
if (request_only) heap_free( headers );
@@ -617,18 +610,18 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
else
headers = request->raw_headers;
- if (!headers) return FALSE;
+ if (!headers) return ERROR_OUTOFMEMORY;
len = lstrlenW( headers ) * sizeof(WCHAR);
if (!buffer || len + sizeof(WCHAR) > *buflen)
{
len += sizeof(WCHAR);
- SetLastError( ERROR_INSUFFICIENT_BUFFER );
+ ret = ERROR_INSUFFICIENT_BUFFER;
}
else
{
memcpy( buffer, headers, len + sizeof(WCHAR) );
TRACE("returning data: %s\n", debugstr_wn(buffer, len / sizeof(WCHAR)));
- ret = TRUE;
+ ret = ERROR_SUCCESS;
}
*buflen = len;
if (request_only) heap_free( headers );
@@ -639,13 +632,13 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
if (!buffer || len + sizeof(WCHAR) > *buflen)
{
len += sizeof(WCHAR);
- SetLastError( ERROR_INSUFFICIENT_BUFFER );
+ ret = ERROR_INSUFFICIENT_BUFFER;
}
else
{
lstrcpyW( buffer, request->version );
TRACE("returning string: %s\n", debugstr_w(buffer));
- ret = TRUE;
+ ret = ERROR_SUCCESS;
}
*buflen = len;
return ret;
@@ -655,13 +648,13 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
if (!buffer || len + sizeof(WCHAR) > *buflen)
{
len += sizeof(WCHAR);
- SetLastError( ERROR_INSUFFICIENT_BUFFER );
+ ret = ERROR_INSUFFICIENT_BUFFER;
}
else
{
lstrcpyW( buffer, request->status_text );
TRACE("returning string: %s\n", debugstr_w(buffer));
- ret = TRUE;
+ ret = ERROR_SUCCESS;
}
*buflen = len;
return ret;
@@ -671,28 +664,23 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
if (!buffer || len + sizeof(WCHAR) > *buflen)
{
len += sizeof(WCHAR);
- SetLastError( ERROR_INSUFFICIENT_BUFFER );
+ ret = ERROR_INSUFFICIENT_BUFFER;
}
else
{
lstrcpyW( buffer, request->verb );
TRACE("returning string: %s\n", debugstr_w(buffer));
- ret = TRUE;
+ ret = ERROR_SUCCESS;
}
*buflen = len;
return ret;
default:
- if (attr >= ARRAY_SIZE(attribute_table))
- {
- SetLastError( ERROR_INVALID_PARAMETER );
- return FALSE;
- }
+ if (attr >= ARRAY_SIZE(attribute_table)) return ERROR_INVALID_PARAMETER;
if (!attribute_table[attr])
{
FIXME("attribute %u not implemented\n", attr);
- SetLastError( ERROR_WINHTTP_HEADER_NOT_FOUND );
- return FALSE;
+ return ERROR_WINHTTP_HEADER_NOT_FOUND;
}
TRACE("attribute %s\n", debugstr_w(attribute_table[attr]));
header_index = get_header_index( request, attribute_table[attr], requested_index, request_only );
@@ -703,38 +691,29 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
{
header = &request->headers[header_index];
}
- if (!header || (request_only && !header->is_request))
- {
- SetLastError( ERROR_WINHTTP_HEADER_NOT_FOUND );
- return FALSE;
- }
+ if (!header || (request_only && !header->is_request)) return ERROR_WINHTTP_HEADER_NOT_FOUND;
if (level & WINHTTP_QUERY_FLAG_NUMBER)
{
- if (!buffer || sizeof(int) > *buflen)
- {
- SetLastError( ERROR_INSUFFICIENT_BUFFER );
- }
+ if (!buffer || sizeof(int) > *buflen) ret = ERROR_INSUFFICIENT_BUFFER;
else
{
int *number = buffer;
*number = wcstol( header->value, NULL, 10 );
TRACE("returning number: %d\n", *number);
- ret = TRUE;
+ ret = ERROR_SUCCESS;
}
*buflen = sizeof(int);
}
else if (level & WINHTTP_QUERY_FLAG_SYSTEMTIME)
{
SYSTEMTIME *st = buffer;
- if (!buffer || sizeof(SYSTEMTIME) > *buflen)
- {
- SetLastError( ERROR_INSUFFICIENT_BUFFER );
- }
- else if ((ret = WinHttpTimeToSystemTime( header->value, st )))
+ if (!buffer || sizeof(SYSTEMTIME) > *buflen) ret = ERROR_INSUFFICIENT_BUFFER;
+ else if (WinHttpTimeToSystemTime( header->value, st ))
{
TRACE("returning time: %04d/%02d/%02d - %d - %02d:%02d:%02d.%02d\n",
st->wYear, st->wMonth, st->wDay, st->wDayOfWeek,
st->wHour, st->wMinute, st->wSecond, st->wMilliseconds);
+ ret = ERROR_SUCCESS;
}
*buflen = sizeof(SYSTEMTIME);
}
@@ -744,17 +723,17 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
if (!buffer || len + sizeof(WCHAR) > *buflen)
{
len += sizeof(WCHAR);
- SetLastError( ERROR_INSUFFICIENT_BUFFER );
+ ret = ERROR_INSUFFICIENT_BUFFER;
}
else
{
lstrcpyW( buffer, header->value );
TRACE("returning string: %s\n", debugstr_w(buffer));
- ret = TRUE;
+ ret = ERROR_SUCCESS;
}
*buflen = len;
}
- if (ret && index) *index += 1;
+ if (!ret && index) *index += 1;
return ret;
}
@@ -763,7 +742,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
*/
BOOL WINAPI WinHttpQueryHeaders( HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index )
{
- BOOL ret;
+ DWORD ret;
struct request *request;
TRACE("%p, 0x%08x, %s, %p, %p, %p\n", hrequest, level, debugstr_w(name), buffer, buflen, index);
@@ -783,8 +762,8 @@ BOOL WINAPI WinHttpQueryHeaders( HINTERNET hrequest, DWORD level, LPCWSTR name,
ret = query_headers( request, level, name, buffer, buflen, index );
release_object( &request->hdr );
- if (ret) SetLastError( ERROR_SUCCESS );
- return ret;
+ SetLastError( ret );
+ return !ret;
}
static const struct
@@ -822,10 +801,9 @@ static DWORD auth_scheme_from_header( const WCHAR *header )
return 0;
}
-static BOOL query_auth_schemes( struct request *request, DWORD level, DWORD *supported, DWORD *first )
+static DWORD query_auth_schemes( struct request *request, DWORD level, DWORD *supported, DWORD *first )
{
- DWORD index = 0, supported_schemes = 0, first_scheme = 0;
- BOOL ret = FALSE;
+ DWORD ret, index = 0, supported_schemes = 0, first_scheme = 0;
for (;;)
{
@@ -833,14 +811,18 @@ static BOOL query_auth_schemes( struct request *request, DWORD level, DWORD *sup
DWORD size, scheme;
size = 0;
- query_headers( request, level, NULL, NULL, &size, &index );
- if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) break;
+ ret = query_headers( request, level, NULL, NULL, &size, &index );
+ if (ret != ERROR_INSUFFICIENT_BUFFER)
+ {
+ if (index) ret = ERROR_SUCCESS;
+ break;
+ }
- if (!(buffer = heap_alloc( size ))) return FALSE;
- if (!query_headers( request, level, NULL, buffer, &size, &index ))
+ if (!(buffer = heap_alloc( size ))) return ERROR_OUTOFMEMORY;
+ if ((ret = query_headers( request, level, NULL, buffer, &size, &index )))
{
heap_free( buffer );
- return FALSE;
+ return ret;
}
scheme = auth_scheme_from_header( buffer );
heap_free( buffer );
@@ -848,11 +830,9 @@ static BOOL query_auth_schemes( struct request *request, DWORD level, DWORD *sup
if (!first_scheme) first_scheme = scheme;
supported_schemes |= scheme;
-
- ret = TRUE;
}
- if (ret)
+ if (!ret)
{
*supported = supported_schemes;
*first = first_scheme;
@@ -865,7 +845,7 @@ static BOOL query_auth_schemes( struct request *request, DWORD level, DWORD *sup
*/
BOOL WINAPI WinHttpQueryAuthSchemes( HINTERNET hrequest, LPDWORD supported, LPDWORD first, LPDWORD target )
{
- BOOL ret = FALSE;
+ DWORD ret;
struct request *request;
TRACE("%p, %p, %p, %p\n", hrequest, supported, first, target);
@@ -889,21 +869,19 @@ BOOL WINAPI WinHttpQueryAuthSchemes( HINTERNET hrequest, LPDWORD supported, LPDW
}
- if (query_auth_schemes( request, WINHTTP_QUERY_WWW_AUTHENTICATE, supported, first ))
+ if (!(ret = query_auth_schemes( request, WINHTTP_QUERY_WWW_AUTHENTICATE, supported, first )))
{
*target = WINHTTP_AUTH_TARGET_SERVER;
- ret = TRUE;
}
- else if (query_auth_schemes( request, WINHTTP_QUERY_PROXY_AUTHENTICATE, supported, first ))
+ else if (!(ret = query_auth_schemes( request, WINHTTP_QUERY_PROXY_AUTHENTICATE, supported, first )))
{
*target = WINHTTP_AUTH_TARGET_PROXY;
- ret = TRUE;
}
- else SetLastError( ERROR_INVALID_OPERATION );
+ else ret = ERROR_INVALID_OPERATION;
release_object( &request->hdr );
- if (ret) SetLastError( ERROR_SUCCESS );
- return ret;
+ SetLastError( ret );
+ return !ret;
}
static UINT encode_base64( const char *bin, unsigned int len, WCHAR *base64 )
@@ -1056,7 +1034,7 @@ static BOOL get_authvalue( struct request *request, DWORD level, DWORD scheme, W
for (;;)
{
size = len;
- if (!query_headers( request, level, NULL, buffer, &size, &index )) return FALSE;
+ if (query_headers( request, level, NULL, buffer, &size, &index )) return FALSE;
if (auth_scheme_from_header( buffer ) == scheme) break;
}
return TRUE;
@@ -1286,7 +1264,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
encode_base64( authinfo->data, authinfo->data_len, auth_reply + len_scheme + 1 );
flags = WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE;
- ret = process_header( request, auth_target, auth_reply, flags, TRUE );
+ ret = !process_header( request, auth_target, auth_reply, flags, TRUE );
heap_free( auth_reply );
return ret;
}
@@ -1335,24 +1313,24 @@ static WCHAR *build_proxy_connect_string( struct request *request )
return ret;
}
-static BOOL read_reply( struct request *request );
+static DWORD read_reply( struct request *request );
-static BOOL secure_proxy_connect( struct request *request )
+static DWORD secure_proxy_connect( struct request *request )
{
WCHAR *str;
char *strA;
int len, bytes_sent;
- BOOL ret;
+ DWORD ret;
- if (!(str = build_proxy_connect_string( request ))) return FALSE;
+ if (!(str = build_proxy_connect_string( request ))) return ERROR_OUTOFMEMORY;
strA = strdupWA( str );
heap_free( str );
- if (!strA) return FALSE;
+ if (!strA) return ERROR_OUTOFMEMORY;
len = strlen( strA );
ret = netconn_send( request->netconn, strA, len, &bytes_sent );
heap_free( strA );
- if (ret) ret = read_reply( request );
+ if (!ret) ret = read_reply( request );
return ret;
}
@@ -1476,11 +1454,11 @@ static DWORD map_secure_protocols( DWORD mask )
return ret;
}
-static BOOL ensure_cred_handle( struct request *request )
+static DWORD ensure_cred_handle( struct request *request )
{
SECURITY_STATUS status = SEC_E_OK;
- if (request->cred_handle_initialized) return TRUE;
+ if (request->cred_handle_initialized) return ERROR_SUCCESS;
if (!request->cred_handle_initialized)
{
@@ -1502,12 +1480,12 @@ static BOOL ensure_cred_handle( struct request *request )
if (status != SEC_E_OK)
{
WARN( "AcquireCredentialsHandleW failed: 0x%08x\n", status );
- return FALSE;
+ return status;
}
- return TRUE;
+ return ERROR_SUCCESS;
}
-static BOOL open_connection( struct request *request )
+static DWORD open_connection( struct request *request )
{
BOOL is_secure = request->hdr.flags & WINHTTP_FLAG_SECURE;
struct hostdata *host = NULL, *iter;
@@ -1515,7 +1493,7 @@ static BOOL open_connection( struct request *request )
struct connect *connect;
WCHAR *addressW = NULL;
INTERNET_PORT port;
- DWORD len;
+ DWORD ret, len;
if (request->netconn) goto done;
@@ -1556,7 +1534,7 @@ static BOOL open_connection( struct request *request )
LeaveCriticalSection( &connection_pool_cs );
- if (!host) return FALSE;
+ if (!host) return ERROR_OUTOFMEMORY;
for (;;)
{
@@ -1586,17 +1564,17 @@ static BOOL open_connection( struct request *request )
len = lstrlenW( host->hostname ) + 1;
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, host->hostname, len );
- if (!netconn_resolve( host->hostname, port, &connect->sockaddr, request->resolve_timeout ))
+ if ((ret = netconn_resolve( host->hostname, port, &connect->sockaddr, request->resolve_timeout )))
{
release_host( host );
- return FALSE;
+ return ret;
}
connect->resolved = TRUE;
if (!(addressW = addr_to_str( &connect->sockaddr )))
{
release_host( host );
- return FALSE;
+ return ERROR_OUTOFMEMORY;
}
len = lstrlenW( addressW ) + 1;
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, addressW, len );
@@ -1607,18 +1585,18 @@ static BOOL open_connection( struct request *request )
if (!addressW && !(addressW = addr_to_str( &connect->sockaddr )))
{
release_host( host );
- return FALSE;
+ return ERROR_OUTOFMEMORY;
}
TRACE("connecting to %s:%u\n", debugstr_w(addressW), port);
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, addressW, 0 );
- if (!(netconn = netconn_create( host, &connect->sockaddr, request->connect_timeout )))
+ if ((ret = netconn_create( host, &connect->sockaddr, request->connect_timeout, &netconn )))
{
heap_free( addressW );
release_host( host );
- return FALSE;
+ return ret;
}
netconn_set_timeout( netconn, TRUE, request->send_timeout );
netconn_set_timeout( netconn, FALSE, request->receive_response_timeout );
@@ -1627,29 +1605,28 @@ static BOOL open_connection( struct request *request )
if (is_secure)
{
- if (connect->session->proxy_server &&
- wcsicmp( connect->hostname, connect->servername ))
+ if (connect->session->proxy_server && wcsicmp( connect->hostname, connect->servername ))
{
- if (!secure_proxy_connect( request ))
+ if ((ret = secure_proxy_connect( request )))
{
request->netconn = NULL;
heap_free( addressW );
netconn_close( netconn );
- return FALSE;
+ return ret;
}
}
CertFreeCertificateContext( request->server_cert );
request->server_cert = NULL;
- if (!ensure_cred_handle( request ) ||
- !netconn_secure_connect( netconn, connect->hostname, request->security_flags,
- &request->cred_handle, request->check_revocation ))
+ if ((ret = ensure_cred_handle( request )) ||
+ (ret = netconn_secure_connect( netconn, connect->hostname, request->security_flags,
+ &request->cred_handle, request->check_revocation )))
{
request->netconn = NULL;
heap_free( addressW );
netconn_close( netconn );
- return FALSE;
+ return ret;
}
}
@@ -1668,7 +1645,7 @@ static BOOL open_connection( struct request *request )
{
heap_free( addressW );
netconn_close( netconn );
- return FALSE;
+ return ERROR_WINHTTP_SECURE_FAILURE;
}
done:
@@ -1677,7 +1654,7 @@ done:
request->read_chunked_size = ~0u;
request->read_chunked_eof = FALSE;
heap_free( addressW );
- return TRUE;
+ return ERROR_SUCCESS;
}
void close_connection( struct request *request )
@@ -1690,10 +1667,9 @@ void close_connection( struct request *request )
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, 0, 0 );
}
-static BOOL add_host_header( struct request *request, DWORD modifier )
+static DWORD add_host_header( struct request *request, DWORD modifier )
{
- BOOL ret;
- DWORD len;
+ DWORD ret, len;
WCHAR *host;
struct connect *connect = request->connect;
INTERNET_PORT port;
@@ -1705,7 +1681,7 @@ static BOOL add_host_header( struct request *request, DWORD modifier )
return process_header( request, L"Host", connect->hostname, modifier, TRUE );
}
len = lstrlenW( connect->hostname ) + 7; /* sizeof(":65335") */
- if (!(host = heap_alloc( len * sizeof(WCHAR) ))) return FALSE;
+ if (!(host = heap_alloc( len * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
swprintf( host, len, L"%s:%u", connect->hostname, port );
ret = process_header( request, L"Host", host, modifier, TRUE );
heap_free( host );
@@ -1734,12 +1710,12 @@ static void remove_data( struct request *request, int count )
}
/* read some more data into the read buffer */
-static BOOL read_more_data( struct request *request, int maxlen, BOOL notify )
+static DWORD read_more_data( struct request *request, int maxlen, BOOL notify )
{
int len;
- BOOL ret;
+ DWORD ret;
- if (request->read_chunked_eof) return FALSE;
+ if (request->read_chunked_eof) return ERROR_INSUFFICIENT_BUFFER;
if (request->read_size && request->read_pos)
{
@@ -1761,8 +1737,9 @@ static BOOL read_more_data( struct request *request, int maxlen, BOOL notify )
}
/* discard data contents until we reach end of line */
-static BOOL discard_eol( struct request *request, BOOL notify )
+static DWORD discard_eol( struct request *request, BOOL notify )
{
+ DWORD ret;
do
{
char *eol = memchr( request->read_buf + request->read_pos, '\n', request->read_size );
@@ -1772,22 +1749,22 @@ static BOOL discard_eol( struct request *request, BOOL notify )
break;
}
request->read_pos = request->read_size = 0; /* discard everything */
- if (!read_more_data( request, -1, notify )) return FALSE;
+ if ((ret = read_more_data( request, -1, notify ))) return ret;
} while (request->read_size);
- return TRUE;
+ return ERROR_SUCCESS;
}
/* read the size of the next chunk */
-static BOOL start_next_chunk( struct request *request, BOOL notify )
+static DWORD start_next_chunk( struct request *request, BOOL notify )
{
- DWORD chunk_size = 0;
+ DWORD ret, chunk_size = 0;
assert(!request->read_chunked_size || request->read_chunked_size == ~0u);
- if (request->read_chunked_eof) return FALSE;
+ if (request->read_chunked_eof) return ERROR_INSUFFICIENT_BUFFER;
/* read terminator for the previous chunk */
- if (!request->read_chunked_size && !discard_eol( request, notify )) return FALSE;
+ if (!request->read_chunked_size && (ret = discard_eol( request, notify ))) return ret;
for (;;)
{
@@ -1811,26 +1788,27 @@ static BOOL start_next_chunk( struct request *request, BOOL notify )
}
remove_data( request, 1 );
}
- if (!read_more_data( request, -1, notify )) return FALSE;
+ if ((ret = read_more_data( request, -1, notify ))) return ret;
if (!request->read_size)
{
request->content_length = request->content_read = 0;
request->read_chunked_size = 0;
- return TRUE;
+ return ERROR_SUCCESS;
}
}
}
-static BOOL refill_buffer( struct request *request, BOOL notify )
+static DWORD refill_buffer( struct request *request, BOOL notify )
{
int len = sizeof(request->read_buf);
+ DWORD ret;
if (request->read_chunked)
{
- if (request->read_chunked_eof) return FALSE;
+ if (request->read_chunked_eof) return ERROR_INSUFFICIENT_BUFFER;
if (request->read_chunked_size == ~0u || !request->read_chunked_size)
{
- if (!start_next_chunk( request, notify )) return FALSE;
+ if ((ret = start_next_chunk( request, notify ))) return ret;
}
len = min( len, request->read_chunked_size );
}
@@ -1839,10 +1817,10 @@ static BOOL refill_buffer( struct request *request, BOOL notify )
len = min( len, request->content_length - request->content_read );
}
- if (len <= request->read_size) return TRUE;
- if (!read_more_data( request, len, notify )) return FALSE;
+ if (len <= request->read_size) return ERROR_SUCCESS;
+ if ((ret = read_more_data( request, len, notify ))) return ret;
if (!request->read_size) request->content_length = request->content_read = 0;
- return TRUE;
+ return ERROR_SUCCESS;
}
static void finished_reading( struct request *request )
@@ -1854,8 +1832,8 @@ static void finished_reading( struct request *request )
if (!request->netconn) return;
if (request->hdr.disable_flags & WINHTTP_DISABLE_KEEP_ALIVE) close = TRUE;
- else if (query_headers( request, WINHTTP_QUERY_CONNECTION, NULL, connection, &size, NULL ) ||
- query_headers( request, WINHTTP_QUERY_PROXY_CONNECTION, NULL, connection, &size, NULL ))
+ else if (!query_headers( request, WINHTTP_QUERY_CONNECTION, NULL, connection, &size, NULL ) ||
+ !query_headers( request, WINHTTP_QUERY_PROXY_CONNECTION, NULL, connection, &size, NULL ))
{
if (!wcsicmp( connection, L"close" )) close = TRUE;
}
@@ -1886,10 +1864,10 @@ static BOOL end_of_read_data( struct request *request )
return (request->content_length == request->content_read);
}
-static BOOL read_data( struct request *request, void *buffer, DWORD size, DWORD *read, BOOL async )
+static DWORD read_data( struct request *request, void *buffer, DWORD size, DWORD *read, BOOL async )
{
int count, bytes_read = 0;
- BOOL ret = TRUE;
+ DWORD ret = ERROR_SUCCESS;
if (end_of_read_data( request )) goto done;
@@ -1897,7 +1875,7 @@ static BOOL read_data( struct request *request, void *buffer, DWORD size, DWORD
{
if (!(count = get_available_data( request )))
{
- if (!(ret = refill_buffer( request, async ))) goto done;
+ if ((ret = refill_buffer( request, async ))) goto done;
if (!(count = get_available_data( request ))) goto done;
}
count = min( count, size );
@@ -1915,17 +1893,17 @@ done:
TRACE( "retrieved %u bytes (%u/%u)\n", bytes_read, request->content_read, request->content_length );
if (async)
{
- if (ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, buffer, bytes_read );
+ if (!ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, buffer, bytes_read );
else
{
WINHTTP_ASYNC_RESULT result;
result.dwResult = API_READ_DATA;
- result.dwError = GetLastError();
+ result.dwError = ret;
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, &result, sizeof(result) );
}
}
- if (ret && read) *read = bytes_read;
+ if (!ret && read) *read = bytes_read;
if (end_of_read_data( request )) finished_reading( request );
return ret;
}
@@ -1945,7 +1923,7 @@ static void drain_content( struct request *request )
if (bytes_total >= bytes_left) return;
size = min( sizeof(buffer), bytes_left - bytes_total );
}
- if (!read_data( request, buffer, size, &bytes_read, FALSE ) || !bytes_read) return;
+ if (read_data( request, buffer, size, &bytes_read, FALSE ) || !bytes_read) return;
bytes_total += bytes_read;
}
}
@@ -2120,15 +2098,14 @@ static char *build_wire_request( struct request *request, DWORD *len )
return ret;
}
-static BOOL send_request( struct request *request, const WCHAR *headers, DWORD headers_len, void *optional,
- DWORD optional_len, DWORD total_len, DWORD_PTR context, BOOL async )
+static DWORD send_request( struct request *request, const WCHAR *headers, DWORD headers_len, void *optional,
+ DWORD optional_len, DWORD total_len, DWORD_PTR context, BOOL async )
{
- BOOL ret = FALSE;
struct connect *connect = request->connect;
struct session *session = connect->session;
char *wire_req;
int bytes_sent;
- DWORD len;
+ DWORD ret, len;
clear_response_headers( request );
drain_content( request );
@@ -2157,32 +2134,37 @@ static BOOL send_request( struct request *request, const WCHAR *headers, DWORD h
process_header( request, L"Pragma", L"no-cache", WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE );
process_header( request, L"Cache-Control", L"no-cache", WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE );
}
- if (headers && !add_request_headers( request, headers, headers_len, WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE ))
+ if (headers && (ret = add_request_headers( request, headers, headers_len,
+ WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE )))
{
- TRACE("failed to add request headers\n");
- return FALSE;
+ TRACE("failed to add request headers: %u\n", ret);
+ return ret;
}
- if (!(request->hdr.disable_flags & WINHTTP_DISABLE_COOKIES) && !add_cookie_headers( request ))
+ if (!(request->hdr.disable_flags & WINHTTP_DISABLE_COOKIES) && (ret = add_cookie_headers( request )))
{
- WARN("failed to add cookie headers\n");
- return FALSE;
+ WARN("failed to add cookie headers: %u\n", ret);
+ return ret;
}
if (context) request->hdr.context = context;
- if (!(ret = open_connection( request ))) goto end;
- if (!(wire_req = build_wire_request( request, &len ))) goto end;
+ if ((ret = open_connection( request ))) goto end;
+ if (!(wire_req = build_wire_request( request, &len )))
+ {
+ ret = ERROR_OUTOFMEMORY;
+ goto end;
+ }
TRACE("full request: %s\n", debugstr_a(wire_req));
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, NULL, 0 );
ret = netconn_send( request->netconn, wire_req, len, &bytes_sent );
heap_free( wire_req );
- if (!ret) goto end;
+ if (ret) goto end;
if (optional_len)
{
- if (!netconn_send( request->netconn, optional, optional_len, &bytes_sent )) goto end;
+ if ((ret = netconn_send( request->netconn, optional, optional_len, &bytes_sent ))) goto end;
request->optional = optional;
request->optional_len = optional_len;
len += optional_len;
@@ -2192,12 +2174,12 @@ static BOOL send_request( struct request *request, const WCHAR *headers, DWORD h
end:
if (async)
{
- if (ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE, NULL, 0 );
+ if (!ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE, NULL, 0 );
else
{
WINHTTP_ASYNC_RESULT result;
result.dwResult = API_SEND_REQUEST;
- result.dwError = GetLastError();
+ result.dwError = ret;
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, &result, sizeof(result) );
}
}
@@ -2217,7 +2199,7 @@ static void task_send_request( struct task_header *task )
BOOL WINAPI WinHttpSendRequest( HINTERNET hrequest, LPCWSTR headers, DWORD headers_len,
LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context )
{
- BOOL ret;
+ DWORD ret;
struct request *request;
TRACE("%p, %s, %u, %p, %u, %u, %lx\n", hrequest, debugstr_wn(headers, headers_len), headers_len, optional,
@@ -2258,19 +2240,18 @@ BOOL WINAPI WinHttpSendRequest( HINTERNET hrequest, LPCWSTR headers, DWORD heade
ret = send_request( request, headers, headers_len, optional, optional_len, total_len, context, FALSE );
release_object( &request->hdr );
- if (ret) SetLastError( ERROR_SUCCESS );
- return ret;
+ SetLastError( ret );
+ return !ret;
}
-static BOOL set_credentials( struct request *request, DWORD target, DWORD scheme_flag, const WCHAR *username,
- const WCHAR *password )
+static DWORD set_credentials( struct request *request, DWORD target, DWORD scheme_flag, const WCHAR *username,
+ const WCHAR *password )
{
enum auth_scheme scheme = scheme_from_flag( scheme_flag );
if (scheme == SCHEME_INVALID || ((scheme == SCHEME_BASIC || scheme == SCHEME_DIGEST) && (!username || !password)))
{
- SetLastError( ERROR_INVALID_PARAMETER );
- return FALSE;
+ return ERROR_INVALID_PARAMETER;
}
switch (target)
{
@@ -2278,29 +2259,29 @@ static BOOL set_credentials( struct request *request, DWORD target, DWORD scheme
{
heap_free( request->creds[TARGET_SERVER][scheme].username );
if (!username) request->creds[TARGET_SERVER][scheme].username = NULL;
- else if (!(request->creds[TARGET_SERVER][scheme].username = strdupW( username ))) return FALSE;
+ else if (!(request->creds[TARGET_SERVER][scheme].username = strdupW( username ))) return ERROR_OUTOFMEMORY;
heap_free( request->creds[TARGET_SERVER][scheme].password );
if (!password) request->creds[TARGET_SERVER][scheme].password = NULL;
- else if (!(request->creds[TARGET_SERVER][scheme].password = strdupW( password ))) return FALSE;
+ else if (!(request->creds[TARGET_SERVER][scheme].password = strdupW( password ))) return ERROR_OUTOFMEMORY;
break;
}
case WINHTTP_AUTH_TARGET_PROXY:
{
heap_free( request->creds[TARGET_PROXY][scheme].username );
if (!username) request->creds[TARGET_PROXY][scheme].username = NULL;
- else if (!(request->creds[TARGET_PROXY][scheme].username = strdupW( username ))) return FALSE;
+ else if (!(request->creds[TARGET_PROXY][scheme].username = strdupW( username ))) return ERROR_OUTOFMEMORY;
heap_free( request->creds[TARGET_PROXY][scheme].password );
if (!password) request->creds[TARGET_PROXY][scheme].password = NULL;
- else if (!(request->creds[TARGET_PROXY][scheme].password = strdupW( password ))) return FALSE;
+ else if (!(request->creds[TARGET_PROXY][scheme].password = strdupW( password ))) return ERROR_OUTOFMEMORY;
break;
}
default:
WARN("unknown target %u\n", target);
- return FALSE;
+ return ERROR_INVALID_PARAMETER;
}
- return TRUE;
+ return ERROR_SUCCESS;
}
/***********************************************************************
@@ -2309,7 +2290,7 @@ static BOOL set_credentials( struct request *request, DWORD target, DWORD scheme
BOOL WINAPI WinHttpSetCredentials( HINTERNET hrequest, DWORD target, DWORD scheme, LPCWSTR username,
LPCWSTR password, LPVOID params )
{
- BOOL ret;
+ DWORD ret;
struct request *request;
TRACE("%p, %x, 0x%08x, %s, %p, %p\n", hrequest, target, scheme, debugstr_w(username), password, params);
@@ -2329,13 +2310,13 @@ BOOL WINAPI WinHttpSetCredentials( HINTERNET hrequest, DWORD target, DWORD schem
ret = set_credentials( request, target, scheme, username, password );
release_object( &request->hdr );
- if (ret) SetLastError( ERROR_SUCCESS );
- return ret;
+ SetLastError( ret );
+ return !ret;
}
-static BOOL handle_authorization( struct request *request, DWORD status )
+static DWORD handle_authorization( struct request *request, DWORD status )
{
- DWORD i, schemes, first, level, target;
+ DWORD ret, i, schemes, first, level, target;
switch (status)
{
@@ -2350,24 +2331,24 @@ static BOOL handle_authorization( struct request *request, DWORD status )
break;
default:
- WARN("unhandled status %u\n", status);
- return FALSE;
+ ERR("unhandled status %u\n", status);
+ return ERROR_WINHTTP_INTERNAL_ERROR;
}
- if (!query_auth_schemes( request, level, &schemes, &first )) return FALSE;
- if (do_authorization( request, target, first )) return TRUE;
+ if ((ret = query_auth_schemes( request, level, &schemes, &first ))) return ret;
+ if (do_authorization( request, target, first )) return ERROR_SUCCESS;
schemes &= ~first;
for (i = 0; i < ARRAY_SIZE( auth_schemes ); i++)
{
if (!(schemes & auth_schemes[i].scheme)) continue;
- if (do_authorization( request, target, auth_schemes[i].scheme )) return TRUE;
+ if (do_authorization( request, target, auth_schemes[i].scheme )) return ERROR_SUCCESS;
}
- return FALSE;
+ return ERROR_WINHTTP_LOGIN_FAILURE;
}
/* set the request content length based on the headers */
-static DWORD set_content_length( struct request *request, DWORD status )
+static void set_content_length( struct request *request, DWORD status )
{
WCHAR encoding[20];
DWORD buflen = sizeof(request->content_length);
@@ -2376,12 +2357,12 @@ static DWORD set_content_length( struct request *request, DWORD status )
request->content_length = 0;
else
{
- if (!query_headers( request, WINHTTP_QUERY_CONTENT_LENGTH|WINHTTP_QUERY_FLAG_NUMBER,
- NULL, &request->content_length, &buflen, NULL ))
+ if (query_headers( request, WINHTTP_QUERY_CONTENT_LENGTH|WINHTTP_QUERY_FLAG_NUMBER,
+ NULL, &request->content_length, &buflen, NULL ))
request->content_length = ~0u;
buflen = sizeof(encoding);
- if (query_headers( request, WINHTTP_QUERY_TRANSFER_ENCODING, NULL, encoding, &buflen, NULL ) &&
+ if (!query_headers( request, WINHTTP_QUERY_TRANSFER_ENCODING, NULL, encoding, &buflen, NULL ) &&
!wcsicmp( encoding, L"chunked" ))
{
request->content_length = ~0u;
@@ -2391,12 +2372,12 @@ static DWORD set_content_length( struct request *request, DWORD status )
}
}
request->content_read = 0;
- return request->content_length;
}
-static BOOL read_line( struct request *request, char *buffer, DWORD *len )
+static DWORD read_line( struct request *request, char *buffer, DWORD *len )
{
int count, bytes_read, pos = 0;
+ DWORD ret;
for (;;)
{
@@ -2414,12 +2395,12 @@ static BOOL read_line( struct request *request, char *buffer, DWORD *len )
remove_data( request, bytes_read );
if (eol) break;
- if (!read_more_data( request, -1, TRUE )) return FALSE;
+ if ((ret = read_more_data( request, -1, TRUE ))) return ret;
if (!request->read_size)
{
*len = 0;
TRACE("returning empty string\n");
- return FALSE;
+ return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
}
}
if (pos < *len)
@@ -2429,32 +2410,32 @@ static BOOL read_line( struct request *request, char *buffer, DWORD *len )
}
buffer[*len - 1] = 0;
TRACE("returning %s\n", debugstr_a(buffer));
- return TRUE;
+ return ERROR_SUCCESS;
}
#define MAX_REPLY_LEN 1460
#define INITIAL_HEADER_BUFFER_LEN 512
-static BOOL read_reply( struct request *request )
+static DWORD read_reply( struct request *request )
{
char buffer[MAX_REPLY_LEN];
- DWORD buflen, len, offset, crlf_len = 2; /* lstrlenW(crlf) */
+ DWORD ret, buflen, len, offset, crlf_len = 2; /* lstrlenW(crlf) */
char *status_code, *status_text;
WCHAR *versionW, *status_textW, *raw_headers;
WCHAR status_codeW[4]; /* sizeof("nnn") */
- if (!request->netconn) return FALSE;
+ if (!request->netconn) return ERROR_WINHTTP_INCORRECT_HANDLE_STATE;
do
{
buflen = MAX_REPLY_LEN;
- if (!read_line( request, buffer, &buflen )) return FALSE;
+ if ((ret = read_line( request, buffer, &buflen ))) return ret;
/* first line should look like 'HTTP/1.x nnn OK' where nnn is the status code */
- if (!(status_code = strchr( buffer, ' ' ))) return FALSE;
+ if (!(status_code = strchr( buffer, ' ' ))) return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
status_code++;
- if (!(status_text = strchr( status_code, ' ' ))) return FALSE;
- if ((len = status_text - status_code) != sizeof("nnn") - 1) return FALSE;
+ if (!(status_text = strchr( status_code, ' ' ))) return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
+ if ((len = status_text - status_code) != sizeof("nnn") - 1) return ERROR_WINHTTP_INVALID_SERVER_RESPONSE;
status_text++;
TRACE("version [%s] status code [%s] status text [%s]\n",
@@ -2467,12 +2448,11 @@ static BOOL read_reply( struct request *request )
/* we rely on the fact that the protocol is ascii */
MultiByteToWideChar( CP_ACP, 0, status_code, len, status_codeW, len );
status_codeW[len] = 0;
- if (!(process_header( request, L"Status", status_codeW,
- WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE, FALSE )))
- return FALSE;
+ if ((ret = process_header( request, L"Status", status_codeW,
+ WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE, FALSE ))) return ret;
len = status_code - buffer;
- if (!(versionW = heap_alloc( len * sizeof(WCHAR) ))) return FALSE;
+ if (!(versionW = heap_alloc( len * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
MultiByteToWideChar( CP_ACP, 0, buffer, len - 1, versionW, len -1 );
versionW[len - 1] = 0;
@@ -2480,14 +2460,14 @@ static BOOL read_reply( struct request *request )
request->version = versionW;
len = buflen - (status_text - buffer);
- if (!(status_textW = heap_alloc( len * sizeof(WCHAR) ))) return FALSE;
+ if (!(status_textW = heap_alloc( len * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
MultiByteToWideChar( CP_ACP, 0, status_text, len, status_textW, len );
heap_free( request->status_text );
request->status_text = status_textW;
len = max( buflen + crlf_len, INITIAL_HEADER_BUFFER_LEN );
- if (!(raw_headers = heap_alloc( len * sizeof(WCHAR) ))) return FALSE;
+ if (!(raw_headers = heap_alloc( len * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
MultiByteToWideChar( CP_ACP, 0, buffer, buflen, raw_headers, buflen );
memcpy( raw_headers + buflen - 1, L"\r\n", sizeof(L"\r\n") );
@@ -2500,14 +2480,14 @@ static BOOL read_reply( struct request *request )
struct header *header;
buflen = MAX_REPLY_LEN;
- if (!read_line( request, buffer, &buflen )) return TRUE;
+ if (read_line( request, buffer, &buflen )) return ERROR_SUCCESS;
if (!*buffer) buflen = 1;
while (len - offset < buflen + crlf_len)
{
WCHAR *tmp;
len *= 2;
- if (!(tmp = heap_realloc( raw_headers, len * sizeof(WCHAR) ))) return FALSE;
+ if (!(tmp = heap_realloc( raw_headers, len * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
request->raw_headers = raw_headers = tmp;
}
if (!*buffer)
@@ -2518,7 +2498,7 @@ static BOOL read_reply( struct request *request )
MultiByteToWideChar( CP_ACP, 0, buffer, buflen, raw_headers + offset, buflen );
if (!(header = parse_header( raw_headers + offset ))) break;
- if (!(process_header( request, header->field, header->value, WINHTTP_ADDREQ_FLAG_ADD, FALSE )))
+ if ((ret = process_header( request, header->field, header->value, WINHTTP_ADDREQ_FLAG_ADD, FALSE )))
{
free_header( header );
break;
@@ -2529,7 +2509,7 @@ static BOOL read_reply( struct request *request )
}
TRACE("raw headers: %s\n", debugstr_w(raw_headers));
- return TRUE;
+ return ret;
}
static void record_cookies( struct request *request )
@@ -2546,31 +2526,34 @@ static void record_cookies( struct request *request )
}
}
-static WCHAR *get_redirect_url( struct request *request, DWORD *len )
+static DWORD get_redirect_url( struct request *request, WCHAR **ret_url, DWORD *ret_len )
{
- DWORD size;
- WCHAR *ret;
+ DWORD size, ret;
+ WCHAR *url;
- query_headers( request, WINHTTP_QUERY_LOCATION, NULL, NULL, &size, NULL );
- if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return NULL;
- if (!(ret = heap_alloc( size ))) return NULL;
- *len = size / sizeof(WCHAR) - 1;
- if (query_headers( request, WINHTTP_QUERY_LOCATION, NULL, ret, &size, NULL )) return ret;
- heap_free( ret );
- return NULL;
+ ret = query_headers( request, WINHTTP_QUERY_LOCATION, NULL, NULL, &size, NULL );
+ if (ret != ERROR_INSUFFICIENT_BUFFER) return ret;
+ if (!(url = heap_alloc( size ))) return ERROR_OUTOFMEMORY;
+ if ((ret = query_headers( request, WINHTTP_QUERY_LOCATION, NULL, url, &size, NULL )))
+ {
+ heap_free( url );
+ return ret;
+ }
+ *ret_url = url;
+ *ret_len = size / sizeof(WCHAR);
+ return ERROR_SUCCESS;
}
-static BOOL handle_redirect( struct request *request, DWORD status )
+static DWORD handle_redirect( struct request *request, DWORD status )
{
- BOOL ret = FALSE;
- DWORD len, len_loc;
+ DWORD ret, len, len_loc = 0;
URL_COMPONENTS uc;
struct connect *connect = request->connect;
INTERNET_PORT port;
- WCHAR *hostname = NULL, *location;
+ WCHAR *hostname = NULL, *location = NULL;
int index;
- if (!(location = get_redirect_url( request, &len_loc ))) return FALSE;
+ if ((ret = get_redirect_url( request, &location, &len_loc ))) return ret;
memset( &uc, 0, sizeof(uc) );
uc.dwStructSize = sizeof(uc);
@@ -2580,6 +2563,7 @@ static BOOL handle_redirect( struct request *request, DWORD status )
{
WCHAR *path, *p;
+ ret = ERROR_OUTOFMEMORY;
if (location[0] == '/')
{
if (!(path = heap_alloc( (len_loc + 1) * sizeof(WCHAR) ))) goto end;
@@ -2605,7 +2589,11 @@ static BOOL handle_redirect( struct request *request, DWORD status )
{
if (uc.nScheme == INTERNET_SCHEME_HTTP && request->hdr.flags & WINHTTP_FLAG_SECURE)
{
- if (request->hdr.redirect_policy == WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP) goto end;
+ if (request->hdr.redirect_policy == WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP)
+ {
+ ret = ERROR_WINHTTP_REDIRECT_FAILED;
+ goto end;
+ }
TRACE("redirect from secure page to non-secure page\n");
request->hdr.flags &= ~WINHTTP_FLAG_SECURE;
}
@@ -2618,7 +2606,11 @@ static BOOL handle_redirect( struct request *request, DWORD status )
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_REDIRECT, location, len_loc + 1 );
len = uc.dwHostNameLength;
- if (!(hostname = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end;
+ if (!(hostname = heap_alloc( (len + 1) * sizeof(WCHAR) )))
+ {
+ ret = ERROR_OUTOFMEMORY;
+ goto end;
+ }
memcpy( hostname, uc.lpszHostName, len * sizeof(WCHAR) );
hostname[len] = 0;
@@ -2628,7 +2620,11 @@ static BOOL handle_redirect( struct request *request, DWORD status )
heap_free( connect->hostname );
connect->hostname = hostname;
connect->hostport = port;
- if (!(ret = set_server_for_hostname( connect, hostname, port ))) goto end;
+ if (!set_server_for_hostname( connect, hostname, port ))
+ {
+ ret = ERROR_OUTOFMEMORY;
+ goto end;
+ }
netconn_close( request->netconn );
request->netconn = NULL;
@@ -2638,8 +2634,8 @@ static BOOL handle_redirect( struct request *request, DWORD status )
}
else heap_free( hostname );
- if (!(ret = add_host_header( request, WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE ))) goto end;
- if (!(ret = open_connection( request ))) goto end;
+ if ((ret = add_host_header( request, WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE ))) goto end;
+ if ((ret = open_connection( request ))) goto end;
heap_free( request->path );
request->path = NULL;
@@ -2664,7 +2660,6 @@ static BOOL handle_redirect( struct request *request, DWORD status )
request->optional = NULL;
request->optional_len = 0;
}
- ret = TRUE;
end:
heap_free( location );
@@ -2678,7 +2673,7 @@ static BOOL is_passport_request( struct request *request )
DWORD len = ARRAY_SIZE(buf);
if (!(request->connect->session->passport_flags & WINHTTP_ENABLE_PASSPORT_AUTH) ||
- !query_headers( request, WINHTTP_QUERY_WWW_AUTHENTICATE, NULL, buf, &len, NULL )) return FALSE;
+ query_headers( request, WINHTTP_QUERY_WWW_AUTHENTICATE, NULL, buf, &len, NULL )) return FALSE;
if (!wcsnicmp( buf, passportW, ARRAY_SIZE(passportW) ) &&
(buf[ARRAY_SIZE(passportW)] == ' ' || !buf[ARRAY_SIZE(passportW)])) return TRUE;
@@ -2686,13 +2681,13 @@ static BOOL is_passport_request( struct request *request )
return FALSE;
}
-static BOOL handle_passport_redirect( struct request *request )
+static DWORD handle_passport_redirect( struct request *request )
{
- DWORD flags = WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE;
+ DWORD ret, flags = WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE;
int i, len = lstrlenW( request->raw_headers );
WCHAR *p = request->raw_headers;
- if (!process_header( request, L"Status", L"401", flags, FALSE )) return FALSE;
+ if ((ret = process_header( request, L"Status", L"401", flags, FALSE ))) return ret;
for (i = 0; i < len; i++)
{
@@ -2703,31 +2698,23 @@ static BOOL handle_passport_redirect( struct request *request )
break;
}
}
- return TRUE;
+ return ERROR_SUCCESS;
}
-static BOOL receive_response( struct request *request, BOOL async )
+static DWORD receive_response( struct request *request, BOOL async )
{
- BOOL ret;
- DWORD size, query, status;
+ DWORD ret, size, query, status;
- if (!request->netconn)
- {
- SetLastError( ERROR_WINHTTP_INCORRECT_HANDLE_STATE );
- return FALSE;
- }
+ if (!request->netconn) return ERROR_WINHTTP_INCORRECT_HANDLE_STATE;
netconn_set_timeout( request->netconn, FALSE, request->receive_response_timeout );
for (;;)
{
- if (!(ret = read_reply( request )))
- {
- SetLastError( ERROR_WINHTTP_INVALID_SERVER_RESPONSE );
- break;
- }
+ if ((ret = read_reply( request ))) break;
+
size = sizeof(DWORD);
query = WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER;
- if (!(ret = query_headers( request, query, NULL, &status, &size, NULL ))) break;
+ if ((ret = query_headers( request, query, NULL, &status, &size, NULL ))) break;
set_content_length( request, status );
@@ -2742,19 +2729,19 @@ static BOOL receive_response( struct request *request, BOOL async )
if (request->hdr.disable_flags & WINHTTP_DISABLE_REDIRECTS ||
request->hdr.redirect_policy == WINHTTP_OPTION_REDIRECT_POLICY_NEVER) break;
- if (!(ret = handle_redirect( request, status ))) break;
+ if ((ret = handle_redirect( request, status ))) break;
/* recurse synchronously */
- if ((ret = send_request( request, NULL, 0, request->optional, request->optional_len, 0, 0, FALSE ))) continue;
+ if (!(ret = send_request( request, NULL, 0, request->optional, request->optional_len, 0, 0, FALSE ))) continue;
}
else if (status == HTTP_STATUS_DENIED || status == HTTP_STATUS_PROXY_AUTH_REQ)
{
if (request->hdr.disable_flags & WINHTTP_DISABLE_AUTHENTICATION) break;
- if (!handle_authorization( request, status )) break;
+ if ((ret = handle_authorization( request, status ))) break;
/* recurse synchronously */
- if ((ret = send_request( request, NULL, 0, request->optional, request->optional_len, 0, 0, FALSE ))) continue;
+ if (!(ret = send_request( request, NULL, 0, request->optional, request->optional_len, 0, 0, FALSE ))) continue;
}
break;
}
@@ -2764,12 +2751,12 @@ static BOOL receive_response( struct request *request, BOOL async )
if (async)
{
- if (ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE, NULL, 0 );
+ if (!ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE, NULL, 0 );
else
{
WINHTTP_ASYNC_RESULT result;
result.dwResult = API_RECEIVE_RESPONSE;
- result.dwError = GetLastError();
+ result.dwError = ret;
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, &result, sizeof(result) );
}
}
@@ -2787,7 +2774,7 @@ static void task_receive_response( struct task_header *task )
*/
BOOL WINAPI WinHttpReceiveResponse( HINTERNET hrequest, LPVOID reserved )
{
- BOOL ret;
+ DWORD ret;
struct request *request;
TRACE("%p, %p\n", hrequest, reserved);
@@ -2819,14 +2806,13 @@ BOOL WINAPI WinHttpReceiveResponse( HINTERNET hrequest, LPVOID reserved )
ret = receive_response( request, FALSE );
release_object( &request->hdr );
- if (ret) SetLastError( ERROR_SUCCESS );
- return ret;
+ SetLastError( ret );
+ return !ret;
}
-static BOOL query_data_available( struct request *request, DWORD *available, BOOL async )
+static DWORD query_data_available( struct request *request, DWORD *available, BOOL async )
{
- DWORD count = 0;
- BOOL ret = TRUE;
+ DWORD ret = ERROR_SUCCESS, count = 0;
if (end_of_read_data( request )) goto done;
@@ -2834,7 +2820,7 @@ static BOOL query_data_available( struct request *request, DWORD *available, BOO
if (!request->read_chunked && request->netconn) count += netconn_query_data_available( request->netconn );
if (!count)
{
- if (!(ret = refill_buffer( request, async ))) goto done;
+ if ((ret = refill_buffer( request, async ))) goto done;
count = get_available_data( request );
if (!request->read_chunked && request->netconn) count += netconn_query_data_available( request->netconn );
}
@@ -2843,17 +2829,17 @@ done:
TRACE("%u bytes available\n", count);
if (async)
{
- if (ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE, &count, sizeof(count) );
+ if (!ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE, &count, sizeof(count) );
else
{
WINHTTP_ASYNC_RESULT result;
result.dwResult = API_QUERY_DATA_AVAILABLE;
- result.dwError = GetLastError();
+ result.dwError = ret;
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, &result, sizeof(result) );
}
}
- if (ret && available) *available = count;
+ if (!ret && available) *available = count;
return ret;
}
@@ -2868,7 +2854,7 @@ static void task_query_data_available( struct task_header *task )
*/
BOOL WINAPI WinHttpQueryDataAvailable( HINTERNET hrequest, LPDWORD available )
{
- BOOL ret;
+ DWORD ret;
struct request *request;
TRACE("%p, %p\n", hrequest, available);
@@ -2901,8 +2887,8 @@ BOOL WINAPI WinHttpQueryDataAvailable( HINTERNET hrequest, LPDWORD available )
ret = query_data_available( request, available, FALSE );
release_object( &request->hdr );
- if (ret) SetLastError( ERROR_SUCCESS );
- return ret;
+ SetLastError( ret );
+ return !ret;
}
static void task_read_data( struct task_header *task )
@@ -2916,7 +2902,7 @@ static void task_read_data( struct task_header *task )
*/
BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read )
{
- BOOL ret;
+ DWORD ret;
struct request *request;
TRACE("%p, %p, %d, %p\n", hrequest, buffer, to_read, read);
@@ -2951,29 +2937,29 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, L
ret = read_data( request, buffer, to_read, read, FALSE );
release_object( &request->hdr );
- if (ret) SetLastError( ERROR_SUCCESS );
- return ret;
+ SetLastError( ret );
+ return !ret;
}
-static BOOL write_data( struct request *request, const void *buffer, DWORD to_write, DWORD *written, BOOL async )
+static DWORD write_data( struct request *request, const void *buffer, DWORD to_write, DWORD *written, BOOL async )
{
- BOOL ret;
+ DWORD ret;
int num_bytes;
ret = netconn_send( request->netconn, buffer, to_write, &num_bytes );
if (async)
{
- if (ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE, &num_bytes, sizeof(num_bytes) );
+ if (!ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE, &num_bytes, sizeof(num_bytes) );
else
{
WINHTTP_ASYNC_RESULT result;
result.dwResult = API_WRITE_DATA;
- result.dwError = GetLastError();
+ result.dwError = ret;
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, &result, sizeof(result) );
}
}
- if (ret && written) *written = num_bytes;
+ if (!ret && written) *written = num_bytes;
return ret;
}
@@ -2988,7 +2974,7 @@ static void task_write_data( struct task_header *task )
*/
BOOL WINAPI WinHttpWriteData( HINTERNET hrequest, LPCVOID buffer, DWORD to_write, LPDWORD written )
{
- BOOL ret;
+ DWORD ret;
struct request *request;
TRACE("%p, %p, %d, %p\n", hrequest, buffer, to_write, written);
@@ -3023,8 +3009,8 @@ BOOL WINAPI WinHttpWriteData( HINTERNET hrequest, LPCVOID buffer, DWORD to_write
ret = write_data( request, buffer, to_write, written, FALSE );
release_object( &request->hdr );
- if (ret) SetLastError( ERROR_SUCCESS );
- return ret;
+ SetLastError( ret );
+ return !ret;
}
enum request_state
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index dabbe9b195..24455d858a 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -1063,7 +1063,7 @@ static BOOL add_accept_types_header( struct request *request, const WCHAR **type
if (!types) return TRUE;
while (*types)
{
- if (!process_header( request, L"Accept", *types, flags, TRUE )) return FALSE;
+ if (process_header( request, L"Accept", *types, flags, TRUE )) return FALSE;
types++;
}
return TRUE;
diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h
index b3f7092d85..657f82f642 100644
--- a/dlls/winhttp/winhttp_private.h
+++ b/dlls/winhttp/winhttp_private.h
@@ -256,27 +256,27 @@ void send_callback( struct object_header *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDD
void close_connection( struct request * ) DECLSPEC_HIDDEN;
void netconn_close( struct netconn * ) DECLSPEC_HIDDEN;
-struct netconn *netconn_create( struct hostdata *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
+DWORD netconn_create( struct hostdata *, const struct sockaddr_storage *, int, struct netconn ** ) DECLSPEC_HIDDEN;
void netconn_unload( void ) DECLSPEC_HIDDEN;
ULONG netconn_query_data_available( struct netconn * ) DECLSPEC_HIDDEN;
-BOOL netconn_recv( struct netconn *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
-BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
-BOOL netconn_secure_connect( struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL ) DECLSPEC_HIDDEN;
-BOOL netconn_send( struct netconn *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
+DWORD netconn_recv( struct netconn *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
+DWORD netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
+DWORD netconn_secure_connect( struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL ) DECLSPEC_HIDDEN;
+DWORD netconn_send( struct netconn *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
DWORD netconn_set_timeout( struct netconn *, BOOL, int ) DECLSPEC_HIDDEN;
BOOL netconn_is_alive( struct netconn * ) DECLSPEC_HIDDEN;
const void *netconn_get_certificate( struct netconn * ) DECLSPEC_HIDDEN;
int netconn_get_cipher_strength( struct netconn * ) DECLSPEC_HIDDEN;
BOOL set_cookies( struct request *, const WCHAR * ) DECLSPEC_HIDDEN;
-BOOL add_cookie_headers( struct request * ) DECLSPEC_HIDDEN;
-BOOL add_request_headers( struct request *, const WCHAR *, DWORD, DWORD ) DECLSPEC_HIDDEN;
+DWORD add_cookie_headers( struct request * ) DECLSPEC_HIDDEN;
+DWORD add_request_headers( struct request *, const WCHAR *, DWORD, DWORD ) DECLSPEC_HIDDEN;
void destroy_cookies( struct session * ) DECLSPEC_HIDDEN;
BOOL set_server_for_hostname( struct connect *, const WCHAR *, INTERNET_PORT ) DECLSPEC_HIDDEN;
void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
void release_host( struct hostdata * ) DECLSPEC_HIDDEN;
-BOOL process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL ) DECLSPEC_HIDDEN;
+DWORD process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL ) DECLSPEC_HIDDEN;
extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
void release_typelib( void ) DECLSPEC_HIDDEN;
--
2.20.1
1
0
07 Apr '20
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/secur32/schannel_gnutls.c | 5 +++++
include/winerror.h | 20 +++++++++++---------
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/dlls/secur32/schannel_gnutls.c b/dlls/secur32/schannel_gnutls.c
index 8ac5bee9ff..31a901932a 100644
--- a/dlls/secur32/schannel_gnutls.c
+++ b/dlls/secur32/schannel_gnutls.c
@@ -586,6 +586,11 @@ again:
return SEC_I_CONTINUE_NEEDED;
}
+ else if (ret == GNUTLS_E_REHANDSHAKE)
+ {
+ TRACE("Rehandshake requested\n");
+ return SEC_I_RENEGOTIATE;
+ }
else
{
pgnutls_perror(ret);
diff --git a/include/winerror.h b/include/winerror.h
index 2958d7e181..4ebb48c124 100644
--- a/include/winerror.h
+++ b/include/winerror.h
@@ -3169,10 +3169,6 @@ static inline HRESULT HRESULT_FROM_WIN32(unsigned int x)
#define SEC_E_MESSAGE_ALTERED _HRESULT_TYPEDEF_(0x8009030F)
#define SEC_E_OUT_OF_SEQUENCE _HRESULT_TYPEDEF_(0x80090310)
#define SEC_E_NO_AUTHENTICATING_AUTHORITY _HRESULT_TYPEDEF_(0x80090311)
-#define SEC_I_CONTINUE_NEEDED _HRESULT_TYPEDEF_(0x00090312)
-#define SEC_I_COMPLETE_NEEDED _HRESULT_TYPEDEF_(0x00090313)
-#define SEC_I_COMPLETE_AND_CONTINUE _HRESULT_TYPEDEF_(0x00090314)
-#define SEC_I_CONTEXT_EXPIRED _HRESULT_TYPEDEF_(0x00090317)
#define SEC_E_BAD_PKGID _HRESULT_TYPEDEF_(0x80090316)
#define SEC_E_CONTEXT_EXPIRED _HRESULT_TYPEDEF_(0x80090317)
#define SEC_E_INCOMPLETE_MESSAGE _HRESULT_TYPEDEF_(0x80090318)
@@ -3222,21 +3218,27 @@ static inline HRESULT HRESULT_FROM_WIN32(unsigned int x)
#define SEC_E_ISSUING_CA_UNTRUSTED_KDC _HRESULT_TYPEDEF_(0x80090359)
#define SEC_E_KDC_CERT_EXPIRED _HRESULT_TYPEDEF_(0x8009035A)
#define SEC_E_KDC_CERT_REVOKED _HRESULT_TYPEDEF_(0x8009035B)
-#define SEC_I_SIGNATURE_NEEDED _HRESULT_TYPEDEF_(0x0009035C)
#define SEC_E_INVALID_PARAMETER _HRESULT_TYPEDEF_(0x8009035D)
#define SEC_E_DELEGATION_POLICY _HRESULT_TYPEDEF_(0x8009035E)
#define SEC_E_POLICY_NLTM_ONLY _HRESULT_TYPEDEF_(0x8009035F)
-#define SEC_I_NO_RENEGOTIATION _HRESULT_TYPEDEF_(0x00090360)
#define SEC_E_NO_CONTEXT _HRESULT_TYPEDEF_(0x80090361)
#define SEC_E_PKU2U_CERT_FAILURE _HRESULT_TYPEDEF_(0x80090362)
#define SEC_E_MUTUAL_AUTH_FAILED _HRESULT_TYPEDEF_(0x80090363)
-#define SEC_I_MESSAGE_FRAGMENT _HRESULT_TYPEDEF_(0x00090364)
#define SEC_E_ONLY_HTTPS_ALLOWED _HRESULT_TYPEDEF_(0x80090365)
-#define SEC_I_CONTINUE_NEEDED_MESSAGE_OK _HRESULT_TYPEDEF_(0x00090366)
#define SEC_E_APPLICATION_PROTOCOL_MISMATCH _HRESULT_TYPEDEF_(0x80090367)
-#define SEC_I_ASYNC_CALL_PENDING _HRESULT_TYPEDEF_(0x00090368)
#define SEC_E_INVALID_UPN_NAME _HRESULT_TYPEDEF_(0x80090369)
+#define SEC_I_CONTINUE_NEEDED _HRESULT_TYPEDEF_(0x00090312)
+#define SEC_I_COMPLETE_NEEDED _HRESULT_TYPEDEF_(0x00090313)
+#define SEC_I_COMPLETE_AND_CONTINUE _HRESULT_TYPEDEF_(0x00090314)
+#define SEC_I_CONTEXT_EXPIRED _HRESULT_TYPEDEF_(0x00090317)
+#define SEC_I_RENEGOTIATE _HRESULT_TYPEDEF_(0x00090321)
+#define SEC_I_SIGNATURE_NEEDED _HRESULT_TYPEDEF_(0x0009035C)
+#define SEC_I_NO_RENEGOTIATION _HRESULT_TYPEDEF_(0x00090360)
+#define SEC_I_MESSAGE_FRAGMENT _HRESULT_TYPEDEF_(0x00090364)
+#define SEC_I_CONTINUE_NEEDED_MESSAGE_OK _HRESULT_TYPEDEF_(0x00090366)
+#define SEC_I_ASYNC_CALL_PENDING _HRESULT_TYPEDEF_(0x00090368)
+
#define CRYPT_E_MSG_ERROR _HRESULT_TYPEDEF_(0x80091001)
#define CRYPT_E_UNKNOWN_ALGO _HRESULT_TYPEDEF_(0x80091002)
#define CRYPT_E_OID_FORMAT _HRESULT_TYPEDEF_(0x80091003)
--
2.20.1
1
0
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/mf/sar.c | 145 ++++++++++++++++++++++++++++++++++++++++++++-
dlls/mf/tests/mf.c | 19 +++---
2 files changed, 152 insertions(+), 12 deletions(-)
diff --git a/dlls/mf/sar.c b/dlls/mf/sar.c
index 4f20472748..eda3957ac2 100644
--- a/dlls/mf/sar.c
+++ b/dlls/mf/sar.c
@@ -26,13 +26,154 @@
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
-static HRESULT sar_create_object(IMFAttributes *attributes, void *user_context, IUnknown **obj)
+struct audio_renderer
+{
+ IMFMediaSink IMFMediaSink_iface;
+ LONG refcount;
+};
+
+static struct audio_renderer *impl_from_IMFMediaSink(IMFMediaSink *iface)
+{
+ return CONTAINING_RECORD(iface, struct audio_renderer, IMFMediaSink_iface);
+}
+
+static HRESULT audio_renderer_sink_QueryInterface(IMFMediaSink *iface, REFIID riid, void **obj)
+{
+ TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
+
+ if (IsEqualIID(riid, &IID_IMFMediaSink) ||
+ IsEqualIID(riid, &IID_IUnknown))
+ {
+ *obj = iface;
+ IMFMediaSink_AddRef(iface);
+ return S_OK;
+ }
+
+ WARN("Unsupported %s.\n", debugstr_guid(riid));
+ *obj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI audio_renderer_sink_AddRef(IMFMediaSink *iface)
+{
+ struct audio_renderer *renderer = impl_from_IMFMediaSink(iface);
+ ULONG refcount = InterlockedIncrement(&renderer->refcount);
+ TRACE("%p, refcount %u.\n", iface, refcount);
+ return refcount;
+}
+
+static ULONG WINAPI audio_renderer_sink_Release(IMFMediaSink *iface)
+{
+ struct audio_renderer *renderer = impl_from_IMFMediaSink(iface);
+ ULONG refcount = InterlockedDecrement(&renderer->refcount);
+
+ TRACE("%p, refcount %u.\n", iface, refcount);
+
+ if (!refcount)
+ heap_free(renderer);
+
+ return refcount;
+}
+
+static HRESULT WINAPI audio_renderer_sink_GetCharacteristics(IMFMediaSink *iface, DWORD *flags)
+{
+ FIXME("%p, %p.\n", iface, flags);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI audio_renderer_sink_AddStreamSink(IMFMediaSink *iface, DWORD stream_sink_id,
+ IMFMediaType *media_type, IMFStreamSink **stream_sink)
+{
+ FIXME("%p, %#x, %p, %p.\n", iface, stream_sink_id, media_type, stream_sink);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI audio_renderer_sink_RemoveStreamSink(IMFMediaSink *iface, DWORD stream_sink_id)
+{
+ FIXME("%p, %#x.\n", iface, stream_sink_id);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI audio_renderer_sink_GetStreamSinkCount(IMFMediaSink *iface, DWORD *count)
{
- FIXME("%p, %p, %p.\n", attributes, user_context, obj);
+ FIXME("%p, %p.\n", iface, count);
return E_NOTIMPL;
}
+static HRESULT WINAPI audio_renderer_sink_GetStreamSinkByIndex(IMFMediaSink *iface, DWORD index,
+ IMFStreamSink **stream)
+{
+ FIXME("%p, %u, %p.\n", iface, index, stream);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI audio_renderer_sink_GetStreamSinkById(IMFMediaSink *iface, DWORD stream_sink_id,
+ IMFStreamSink **stream)
+{
+ FIXME("%p, %#x, %p.\n", iface, stream_sink_id, stream);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI audio_renderer_sink_SetPresentationClock(IMFMediaSink *iface, IMFPresentationClock *clock)
+{
+ FIXME("%p, %p.\n", iface, clock);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI audio_renderer_sink_GetPresentationClock(IMFMediaSink *iface, IMFPresentationClock **clock)
+{
+ FIXME("%p, %p.\n", iface, clock);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI audio_renderer_sink_Shutdown(IMFMediaSink *iface)
+{
+ FIXME("%p.\n", iface);
+
+ return E_NOTIMPL;
+}
+
+static const IMFMediaSinkVtbl audio_renderer_sink_vtbl =
+{
+ audio_renderer_sink_QueryInterface,
+ audio_renderer_sink_AddRef,
+ audio_renderer_sink_Release,
+ audio_renderer_sink_GetCharacteristics,
+ audio_renderer_sink_AddStreamSink,
+ audio_renderer_sink_RemoveStreamSink,
+ audio_renderer_sink_GetStreamSinkCount,
+ audio_renderer_sink_GetStreamSinkByIndex,
+ audio_renderer_sink_GetStreamSinkById,
+ audio_renderer_sink_SetPresentationClock,
+ audio_renderer_sink_GetPresentationClock,
+ audio_renderer_sink_Shutdown,
+};
+
+static HRESULT sar_create_object(IMFAttributes *attributes, void *user_context, IUnknown **obj)
+{
+ struct audio_renderer *renderer;
+
+ TRACE("%p, %p, %p.\n", attributes, user_context, obj);
+
+ if (!(renderer = heap_alloc_zero(sizeof(*renderer))))
+ return E_OUTOFMEMORY;
+
+ renderer->IMFMediaSink_iface.lpVtbl = &audio_renderer_sink_vtbl;
+ renderer->refcount = 1;
+
+ *obj = (IUnknown *)&renderer->IMFMediaSink_iface;
+
+ return S_OK;
+}
+
static void sar_shutdown_object(void *user_context, IUnknown *obj)
{
/* FIXME: shut down sink */
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c
index dfbd928f60..46024d3fba 100644
--- a/dlls/mf/tests/mf.c
+++ b/dlls/mf/tests/mf.c
@@ -2650,15 +2650,14 @@ static void test_sar(void)
CoUninitialize();
return;
}
-
-todo_wine
ok(hr == S_OK, "Failed to create renderer, hr %#x.\n", hr);
-if (SUCCEEDED(hr))
-{
hr = IMFMediaSink_QueryInterface(sink, &IID_IMFPresentationTimeSource, (void **)&time_source);
+todo_wine
ok(hr == S_OK, "Failed to get time source interface, hr %#x.\n", hr);
+if (SUCCEEDED(hr))
+{
hr = IMFPresentationTimeSource_GetUnderlyingClock(time_source, &clock);
ok(hr == MF_E_NO_CLOCK, "Unexpected hr %#x.\n", hr);
@@ -2679,31 +2678,30 @@ if (SUCCEEDED(hr))
IMFClockStateSink_Release(state_sink);
IMFPresentationTimeSource_Release(time_source);
-
- IMFMediaSink_Release(sink);
}
+ IMFMediaSink_Release(sink);
+
/* Activation */
hr = MFCreateAudioRendererActivate(&activate);
ok(hr == S_OK, "Failed to create activation object, hr %#x.\n", hr);
hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink);
-todo_wine
ok(hr == S_OK, "Failed to activate, hr %#x.\n", hr);
-if (hr == S_OK)
-{
hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink2);
ok(hr == S_OK, "Failed to activate, hr %#x.\n", hr);
ok(sink == sink2, "Unexpected instance.\n");
IMFMediaSink_Release(sink2);
hr = IMFMediaSink_GetCharacteristics(sink, &flags);
+todo_wine
ok(hr == S_OK, "Failed to get sink flags, hr %#x.\n", hr);
hr = IMFActivate_ShutdownObject(activate);
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
hr = IMFMediaSink_GetCharacteristics(sink, &flags);
+todo_wine
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
IMFMediaSink_Release(sink);
@@ -2712,13 +2710,14 @@ if (hr == S_OK)
ok(hr == S_OK, "Failed to activate, hr %#x.\n", hr);
hr = IMFMediaSink_GetCharacteristics(sink, &flags);
+todo_wine
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
IMFMediaSink_Release(sink);
hr = IMFActivate_DetachObject(activate);
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
-}
+
IMFActivate_Release(activate);
CoUninitialize();
--
2.25.1
2
9