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
November 2019
- 85 participants
- 778 discussions
Signed-off-by: Jeff Smith <whydoubt(a)gmail.com>
---
dlls/msvcrt/tests/time.c | 209 ++++++++++++---------------------------
1 file changed, 63 insertions(+), 146 deletions(-)
diff --git a/dlls/msvcrt/tests/time.c b/dlls/msvcrt/tests/time.c
index cf79e5971e..c8acd848bf 100644
--- a/dlls/msvcrt/tests/time.c
+++ b/dlls/msvcrt/tests/time.c
@@ -588,13 +588,59 @@ static void test_daylight(void)
static void test_strftime(void)
{
+ const struct {
+ const char *format;
+ } tests_einval[] = {
+ {"%C"},
+ {"%D"},
+ {"%e"},
+ {"%F"},
+ {"%h"},
+ {"%n"},
+ {"%R"},
+ {"%t"},
+ {"%T"},
+ {"%u"},
+ };
+
+ const struct {
+ const char *format;
+ const char *ret;
+ struct tm tm;
+ BOOL todo;
+ } tests[] = {
+ {"e%#%e", "e%e", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%c", "01/01/70 00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%c", "02/30/70 00:00:00", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE},
+ {"%x", "01/01/70", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%X", "00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%a", "Thu", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%A", "Thursday", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%b", "Jan", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%B", "January", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%d", "01", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%#d", "1", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%H", "00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%I", "12", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%j", "001", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%m", "01", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%#M", "0", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%p", "AM", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%U", "00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%W", "00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
+ {"%U", "01", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
+ {"%W", "00", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
+ {"%U", "53", { 0, 0, 0, 1, 0, 70, 0, 365, 0 }},
+ {"%W", "52", { 0, 0, 0, 1, 0, 70, 0, 365, 0 }},
+ };
+
static const wchar_t cW[] = { '%','c',0 };
- static const char expected[] = "01/01/70 00:00:00";
time_t gmt;
struct tm* gmt_tm;
char buf[256], bufA[256];
WCHAR bufW[256];
long retA, retW;
+ int i;
if (!p_strftime || !p_wcsftime || !p_gmtime)
{
@@ -608,55 +654,13 @@ static void test_strftime(void)
gmt_tm = p_gmtime(&gmt);
ok(gmt_tm != NULL, "gmtime failed\n");
- errno = 0xdeadbeef;
- retA = p_strftime(bufA, 256, "%C", gmt_tm);
- ok(retA == 0, "expected 0, got %ld\n", retA);
- ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
-
- errno = 0xdeadbeef;
- retA = p_strftime(bufA, 256, "%D", gmt_tm);
- ok(retA == 0, "expected 0, got %ld\n", retA);
- ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
-
- errno = 0xdeadbeef;
- retA = p_strftime(bufA, 256, "%e", gmt_tm);
- ok(retA == 0, "expected 0, got %ld\n", retA);
- ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
-
- errno = 0xdeadbeef;
- retA = p_strftime(bufA, 256, "%F", gmt_tm);
- ok(retA == 0, "expected 0, got %ld\n", retA);
- ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
-
- errno = 0xdeadbeef;
- retA = p_strftime(bufA, 256, "%h", gmt_tm);
- ok(retA == 0, "expected 0, got %ld\n", retA);
- ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
-
- errno = 0xdeadbeef;
- retA = p_strftime(bufA, 256, "%n", gmt_tm);
- ok(retA == 0, "expected 0, got %ld\n", retA);
- ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
-
- errno = 0xdeadbeef;
- retA = p_strftime(bufA, 256, "%R", gmt_tm);
- ok(retA == 0, "expected 0, got %ld\n", retA);
- ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
-
- errno = 0xdeadbeef;
- retA = p_strftime(bufA, 256, "%t", gmt_tm);
- ok(retA == 0, "expected 0, got %ld\n", retA);
- ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
-
- errno = 0xdeadbeef;
- retA = p_strftime(bufA, 256, "%T", gmt_tm);
- ok(retA == 0, "expected 0, got %ld\n", retA);
- ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
-
- errno = 0xdeadbeef;
- retA = p_strftime(bufA, 256, "%u", gmt_tm);
- ok(retA == 0, "expected 0, got %ld\n", retA);
- ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
+ for (i=0; i<ARRAY_SIZE(tests_einval); i++)
+ {
+ errno = 0xdeadbeef;
+ retA = p_strftime(bufA, 256, tests_einval[i].format, gmt_tm);
+ ok(retA == 0, "%d) ret = %ld\n", i, retA);
+ ok(errno==EINVAL || broken(errno==0xdeadbeef), "%d) errno = %d\n", i, errno);
+ }
errno = 0xdeadbeef;
retA = p_strftime(NULL, 0, "copy", gmt_tm);
@@ -691,14 +695,17 @@ static void test_strftime(void)
ok(errno == EINVAL, "errno = %d\n", errno);
}
- retA = p_strftime(bufA, 256, "e%#%e", gmt_tm);
- ok(retA == 3, "expected 3, got %ld\n", retA);
- ok(!strcmp(bufA, "e%e"), "got %s\n", bufA);
+ for (i=0; i<ARRAY_SIZE(tests); i++)
+ {
+ retA = p_strftime(bufA, 256, tests[i].format, &tests[i].tm);
+ todo_wine_if(tests[i].todo) {
+ ok(retA == strlen(tests[i].ret), "%d) ret = %ld\n", i, retA);
+ ok(!strcmp(bufA, tests[i].ret), "%d) buf = \"%s\", expected \"%s\"\n",
+ i, bufA, tests[i].ret);
+ }
+ }
retA = p_strftime(bufA, 256, "%c", gmt_tm);
- ok(retA == 17, "expected 17, got %ld\n", retA);
- ok(strcmp(bufA, expected) == 0, "expected %s, got %s\n", expected, bufA);
-
retW = p_wcsftime(bufW, 256, cW, gmt_tm);
ok(retW == 17, "expected 17, got %ld\n", retW);
ok(retA == retW, "expected %ld, got %ld\n", retA, retW);
@@ -707,96 +714,6 @@ static void test_strftime(void)
buf[retA] = 0;
ok(strcmp(bufA, buf) == 0, "expected %s, got %s\n", bufA, buf);
- retA = p_strftime(bufA, 256, "%x", gmt_tm);
- ok(retA == 8, "expected 8, got %ld\n", retA);
- ok(!strcmp(bufA, "01/01/70"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%X", gmt_tm);
- ok(retA == 8, "expected 8, got %ld\n", retA);
- ok(!strcmp(bufA, "00:00:00"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%a", gmt_tm);
- ok(retA == 3, "expected 3, got %ld\n", retA);
- ok(!strcmp(bufA, "Thu"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%A", gmt_tm);
- ok(retA == 8, "expected 8, got %ld\n", retA);
- ok(!strcmp(bufA, "Thursday"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%b", gmt_tm);
- ok(retA == 3, "expected 3, got %ld\n", retA);
- ok(!strcmp(bufA, "Jan"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%B", gmt_tm);
- ok(retA == 7, "expected 7, got %ld\n", retA);
- ok(!strcmp(bufA, "January"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%d", gmt_tm);
- ok(retA == 2, "expected 2, got %ld\n", retA);
- ok(!strcmp(bufA, "01"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%#d", gmt_tm);
- ok(retA == 1, "expected 1, got %ld\n", retA);
- ok(!strcmp(bufA, "1"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%H", gmt_tm);
- ok(retA == 2, "expected 2, got %ld\n", retA);
- ok(!strcmp(bufA, "00"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%I", gmt_tm);
- ok(retA == 2, "expected 2, got %ld\n", retA);
- ok(!strcmp(bufA, "12"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%j", gmt_tm);
- ok(retA == 3, "expected 3, got %ld\n", retA);
- ok(!strcmp(bufA, "001"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%m", gmt_tm);
- ok(retA == 2, "expected 2, got %ld\n", retA);
- ok(!strcmp(bufA, "01"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%#M", gmt_tm);
- ok(retA == 1, "expected 1, got %ld\n", retA);
- ok(!strcmp(bufA, "0"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%p", gmt_tm);
- ok(retA == 2, "expected 2, got %ld\n", retA);
- ok(!strcmp(bufA, "AM"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%U", gmt_tm);
- ok(retA == 2, "expected 2, got %ld\n", retA);
- ok(!strcmp(bufA, "00"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%W", gmt_tm);
- ok(retA == 2, "expected 2, got %ld\n", retA);
- ok(!strcmp(bufA, "00"), "got %s\n", bufA);
-
- gmt_tm->tm_wday = 0;
- retA = p_strftime(bufA, 256, "%U", gmt_tm);
- ok(retA == 2, "expected 2, got %ld\n", retA);
- ok(!strcmp(bufA, "01"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%W", gmt_tm);
- ok(retA == 2, "expected 2, got %ld\n", retA);
- ok(!strcmp(bufA, "00"), "got %s\n", bufA);
-
- gmt_tm->tm_yday = 365;
- retA = p_strftime(bufA, 256, "%U", gmt_tm);
- ok(retA == 2, "expected 2, got %ld\n", retA);
- ok(!strcmp(bufA, "53"), "got %s\n", bufA);
-
- retA = p_strftime(bufA, 256, "%W", gmt_tm);
- ok(retA == 2, "expected 2, got %ld\n", retA);
- ok(!strcmp(bufA, "52"), "got %s\n", bufA);
-
- gmt_tm->tm_mon = 1;
- gmt_tm->tm_mday = 30;
- retA = p_strftime(bufA, 256, "%c", gmt_tm);
- todo_wine {
- ok(retA == 17, "expected 17, got %ld\n", retA);
- ok(!strcmp(bufA, "02/30/70 00:00:00"), "got %s\n", bufA);
- }
-
if(!setlocale(LC_ALL, "Japanese_Japan.932")) {
win_skip("Japanese_Japan.932 locale not available\n");
return;
--
2.23.0
3
8
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/winhttp/Makefile.in | 2 +
dlls/winhttp/cookie.c | 36 +++---
dlls/winhttp/handle.c | 3 +-
dlls/winhttp/main.c | 5 +-
dlls/winhttp/net.c | 15 ++-
dlls/winhttp/request.c | 218 ++++++++++++++++-----------------
dlls/winhttp/session.c | 90 +++++++-------
dlls/winhttp/url.c | 48 ++++----
dlls/winhttp/winhttp_private.h | 9 +-
9 files changed, 208 insertions(+), 218 deletions(-)
diff --git a/dlls/winhttp/Makefile.in b/dlls/winhttp/Makefile.in
index f4fc317c5f..6e9f8b82e4 100644
--- a/dlls/winhttp/Makefile.in
+++ b/dlls/winhttp/Makefile.in
@@ -3,6 +3,8 @@ IMPORTLIB = winhttp
IMPORTS = uuid jsproxy user32 advapi32 ws2_32
DELAYIMPORTS = oleaut32 ole32 crypt32 secur32 iphlpapi dhcpcsvc
+EXTRADLLFLAGS = -mno-cygwin
+
C_SRCS = \
cookie.c \
handle.c \
diff --git a/dlls/winhttp/cookie.c b/dlls/winhttp/cookie.c
index 40c11c6f71..3166290eab 100644
--- a/dlls/winhttp/cookie.c
+++ b/dlls/winhttp/cookie.c
@@ -16,12 +16,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "ws2tcpip.h"
#include <stdarg.h>
+#include <wchar.h>
#include "windef.h"
#include "winbase.h"
+#include "ws2tcpip.h"
#include "winhttp.h"
#include "wine/debug.h"
@@ -69,7 +69,7 @@ static struct cookie *find_cookie( struct domain *domain, const WCHAR *path, con
LIST_FOR_EACH( item, &domain->cookies )
{
cookie = LIST_ENTRY( item, struct cookie, entry );
- if (!strcmpW( cookie->path, path ) && !strcmpW( cookie->name, name ))
+ if (!wcscmp( cookie->path, path ) && !wcscmp( cookie->name, name ))
{
TRACE("found %s=%s\n", debugstr_w(cookie->name), debugstr_w(cookie->value));
return cookie;
@@ -82,8 +82,8 @@ static BOOL domain_match( const WCHAR *name, struct domain *domain, BOOL partial
{
TRACE("comparing %s with %s\n", debugstr_w(name), debugstr_w(domain->name));
- if (partial && !strstrW( name, domain->name )) return FALSE;
- else if (!partial && strcmpW( name, domain->name )) return FALSE;
+ if (partial && !wcsstr( name, domain->name )) return FALSE;
+ else if (!partial && wcscmp( name, domain->name )) return FALSE;
return TRUE;
}
@@ -165,7 +165,7 @@ static struct cookie *parse_cookie( const WCHAR *string )
const WCHAR *p;
int len;
- if (!(p = strchrW( string, '=' ))) p = string + strlenW( string );
+ if (!(p = wcschr( string, '=' ))) p = string + lstrlenW( string );
len = p - string;
while (len && string[len - 1] == ' ') len--;
if (!len) return NULL;
@@ -184,7 +184,7 @@ static struct cookie *parse_cookie( const WCHAR *string )
if (*p++ == '=')
{
while (*p == ' ') p++;
- len = strlenW( p );
+ len = lstrlenW( p );
while (len && p[len - 1] == ' ') len--;
if (!(cookie->value = heap_alloc( (len + 1) * sizeof(WCHAR) )))
@@ -272,9 +272,9 @@ BOOL set_cookies( struct request *request, const WCHAR *cookies )
struct cookie *cookie;
int len, used;
- len = strlenW( cookies );
+ len = lstrlenW( cookies );
if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
- strcpyW( buffer, cookies );
+ lstrcpyW( buffer, cookies );
p = buffer;
while (*p && *p != ';') p++;
@@ -284,15 +284,15 @@ BOOL set_cookies( struct request *request, const WCHAR *cookies )
heap_free( buffer );
return FALSE;
}
- len = strlenW( p );
+ len = lstrlenW( p );
while (len && (attr = parse_attr( p, &used )))
{
- if (!strcmpiW( attr->name, domainW ))
+ if (!wcsicmp( attr->name, domainW ))
{
domain = attr;
cookie_domain = attr->value;
}
- else if (!strcmpiW( attr->name, pathW ))
+ else if (!wcsicmp( attr->name, pathW ))
{
path = attr;
cookie_path = attr->value;
@@ -308,7 +308,7 @@ BOOL set_cookies( struct request *request, const WCHAR *cookies )
if (!cookie_domain && !(cookie_domain = strdupW( request->connect->servername ))) goto end;
if (!cookie_path && !(cookie_path = strdupW( request->path ))) goto end;
- if ((p = strrchrW( cookie_path, '/' )) && p != cookie_path) *p = 0;
+ if ((p = wcsrchr( cookie_path, '/' )) && p != cookie_path) *p = 0;
ret = add_cookie( session, cookie, cookie_domain, cookie_path );
end:
@@ -342,14 +342,14 @@ BOOL add_cookie_headers( struct request *request )
TRACE("comparing path %s with %s\n", debugstr_w(request->path), debugstr_w(cookie->path));
- if (strstrW( request->path, cookie->path ) == request->path)
+ if (wcsstr( request->path, cookie->path ) == request->path)
{
static const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '};
- int len, len_cookie = ARRAY_SIZE( cookieW ), len_name = strlenW( cookie->name );
+ int len, len_cookie = ARRAY_SIZE( cookieW ), len_name = lstrlenW( cookie->name );
WCHAR *header;
len = len_cookie + len_name;
- if (cookie->value) len += strlenW( cookie->value ) + 1;
+ if (cookie->value) len += lstrlenW( cookie->value ) + 1;
if (!(header = heap_alloc( (len + 1) * sizeof(WCHAR) )))
{
LeaveCriticalSection( &session->cs );
@@ -357,11 +357,11 @@ BOOL add_cookie_headers( struct request *request )
}
memcpy( header, cookieW, len_cookie * sizeof(WCHAR) );
- strcpyW( header + len_cookie, cookie->name );
+ lstrcpyW( header + len_cookie, cookie->name );
if (cookie->value)
{
header[len_cookie + len_name] = '=';
- strcpyW( header + len_cookie + len_name + 1, cookie->value );
+ lstrcpyW( header + len_cookie + len_name + 1, cookie->value );
}
TRACE("%s\n", debugstr_w(header));
diff --git a/dlls/winhttp/handle.c b/dlls/winhttp/handle.c
index 6711cd9172..9c77d5166a 100644
--- a/dlls/winhttp/handle.c
+++ b/dlls/winhttp/handle.c
@@ -18,12 +18,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "ws2tcpip.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
+#include "ws2tcpip.h"
#include "winhttp.h"
#include "wine/debug.h"
diff --git a/dlls/winhttp/main.c b/dlls/winhttp/main.c
index e6c084b979..3b570fee6d 100644
--- a/dlls/winhttp/main.c
+++ b/dlls/winhttp/main.c
@@ -16,13 +16,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#define COBJMACROS
-#include "config.h"
-#include "ws2tcpip.h"
#include <stdarg.h>
+#define COBJMACROS
#include "windef.h"
#include "winbase.h"
+#include "ws2tcpip.h"
#include "objbase.h"
#include "rpcproxy.h"
#include "httprequest.h"
diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c
index a1ad0461d4..c9da098f52 100644
--- a/dlls/winhttp/net.c
+++ b/dlls/winhttp/net.c
@@ -17,20 +17,17 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#define NONAMELESSUNION
-#include "ws2tcpip.h"
-#include <stdarg.h>
-#include <stdio.h>
#include <assert.h>
+#include <stdarg.h>
+#define NONAMELESSUNION
#include "windef.h"
#include "winbase.h"
+#include "ws2tcpip.h"
#include "winhttp.h"
#include "schannel.h"
#include "wine/debug.h"
-#include "wine/library.h"
#include "winhttp_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
@@ -207,7 +204,9 @@ struct netconn *netconn_create( struct hostdata *host, const struct sockaddr_sto
addr_len = sizeof(struct sockaddr_in6);
break;
default:
- assert(0);
+ ERR( "unhandled family %u\n", conn->sockaddr.ss_family );
+ heap_free( conn );
+ return NULL;
}
if (timeout > 0) set_blocking( conn, FALSE );
@@ -374,7 +373,7 @@ BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD securi
heap_free(read_buf);
if(status != SEC_E_OK || res != ERROR_SUCCESS) {
- WARN("Failed to initialize security context failed: %08x\n", status);
+ WARN("Failed to initialize security context: %08x\n", status);
heap_free(conn->ssl_buf);
conn->ssl_buf = NULL;
DeleteSecurityContext(&ctx);
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 46a47f3bc2..0fd1d1abe9 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#define COBJMACROS
-#include "config.h"
-#include "ws2tcpip.h"
-#include <stdarg.h>
#include <assert.h>
+#include <stdarg.h>
+#include <wchar.h>
+#define COBJMACROS
#include "windef.h"
#include "winbase.h"
+#include "ws2tcpip.h"
#include "ole2.h"
#include "initguid.h"
#include "httprequest.h"
@@ -300,7 +300,7 @@ static struct header *parse_header( const WCHAR *string )
int len;
p = string;
- if (!(q = strchrW( p, ':' )))
+ if (!(q = wcschr( p, ':' )))
{
WARN("no ':' in line %s\n", debugstr_w(string));
return NULL;
@@ -331,7 +331,7 @@ static struct header *parse_header( const WCHAR *string )
q++; /* skip past colon */
while (*q == ' ') q++;
- len = strlenW( q );
+ len = lstrlenW( q );
if (!(header->value = heap_alloc( (len + 1) * sizeof(WCHAR) )))
{
@@ -352,7 +352,7 @@ static int get_header_index( struct request *request, const WCHAR *field, int re
for (index = 0; index < request->num_headers; index++)
{
- if (strcmpiW( request->headers[index].field, field )) continue;
+ if (wcsicmp( request->headers[index].field, field )) continue;
if (request_only && !request->headers[index].is_request) continue;
if (!request_only && request->headers[index].is_request) continue;
@@ -438,8 +438,8 @@ BOOL process_header( struct request *request, const WCHAR *field, const WCHAR *v
int len, len_orig, len_value;
struct header *header = &request->headers[index];
- len_orig = strlenW( header->value );
- len_value = strlenW( value );
+ len_orig = lstrlenW( header->value );
+ len_value = lstrlenW( value );
len = len_orig + len_value + 2;
if (!(tmp = heap_realloc( header->value, (len + 1) * sizeof(WCHAR) ))) return FALSE;
@@ -469,7 +469,7 @@ BOOL add_request_headers( struct request *request, const WCHAR *headers, DWORD l
WCHAR *buffer, *p, *q;
struct header *header;
- if (len == ~0u) len = strlenW( headers );
+ if (len == ~0u) len = lstrlenW( headers );
if (!len) return TRUE;
if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
memcpy( buffer, headers, len * sizeof(WCHAR) );
@@ -548,24 +548,24 @@ static WCHAR *build_absolute_request_path( struct request *request, const WCHAR
static const WCHAR fmt[] = {'%','s',':','/','/','%','s',0};
const WCHAR *scheme;
WCHAR *ret;
- int len;
+ int len, offset;
scheme = (request->netconn ? request->netconn->secure : (request->hdr.flags & WINHTTP_FLAG_SECURE)) ? https : http;
- len = strlenW( scheme ) + strlenW( request->connect->hostname ) + 4; /* '://' + nul */
+ len = lstrlenW( scheme ) + lstrlenW( request->connect->hostname ) + 4; /* '://' + nul */
if (request->connect->hostport) len += 6; /* ':' between host and port, up to 5 for port */
- len += strlenW( request->path );
+ len += lstrlenW( request->path );
if ((ret = heap_alloc( len * sizeof(WCHAR) )))
{
- len = sprintfW( ret, fmt, scheme, request->connect->hostname );
+ offset = swprintf( ret, len, fmt, scheme, request->connect->hostname );
if (request->connect->hostport)
{
static const WCHAR port_fmt[] = {':','%','u',0};
- len += sprintfW( ret + len, port_fmt, request->connect->hostport );
+ offset += swprintf( ret + offset, len - offset, port_fmt, request->connect->hostport );
}
- strcpyW( ret + len, request->path );
- if (path) *path = ret + len;
+ lstrcpyW( ret + offset, request->path );
+ if (path) *path = ret + offset;
}
return ret;
@@ -578,39 +578,39 @@ static WCHAR *build_request_string( struct request *request )
WCHAR *path, *ret;
unsigned int i, len;
- if (!strcmpiW( request->connect->hostname, request->connect->servername )) path = request->path;
+ if (!wcsicmp( request->connect->hostname, request->connect->servername )) path = request->path;
else if (!(path = build_absolute_request_path( request, NULL ))) return NULL;
- len = strlenW( request->verb ) + 1 /* ' ' */;
- len += strlenW( path ) + 1 /* ' ' */;
- len += strlenW( request->version );
+ len = lstrlenW( request->verb ) + 1 /* ' ' */;
+ len += lstrlenW( path ) + 1 /* ' ' */;
+ len += lstrlenW( request->version );
for (i = 0; i < request->num_headers; i++)
{
if (request->headers[i].is_request)
- len += strlenW( request->headers[i].field ) + strlenW( request->headers[i].value ) + 4; /* '\r\n: ' */
+ len += lstrlenW( request->headers[i].field ) + lstrlenW( request->headers[i].value ) + 4; /* '\r\n: ' */
}
len += 4; /* '\r\n\r\n' */
if ((ret = heap_alloc( (len + 1) * sizeof(WCHAR) )))
{
- strcpyW( ret, request->verb );
- strcatW( ret, spaceW );
- strcatW( ret, path );
- strcatW( ret, spaceW );
- strcatW( ret, request->version );
+ lstrcpyW( ret, request->verb );
+ lstrcatW( ret, spaceW );
+ lstrcatW( ret, path );
+ lstrcatW( ret, spaceW );
+ lstrcatW( ret, request->version );
for (i = 0; i < request->num_headers; i++)
{
if (request->headers[i].is_request)
{
- strcatW( ret, crlfW );
- strcatW( ret, request->headers[i].field );
- strcatW( ret, colonW );
- strcatW( ret, request->headers[i].value );
+ lstrcatW( ret, crlfW );
+ lstrcatW( ret, request->headers[i].field );
+ lstrcatW( ret, colonW );
+ lstrcatW( ret, request->headers[i].value );
}
}
- strcatW( ret, twocrlfW );
+ lstrcatW( ret, twocrlfW );
}
if (path != request->path) heap_free( path );
@@ -681,7 +681,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
headers = request->raw_headers;
if (!headers) return FALSE;
- len = strlenW( headers ) * sizeof(WCHAR);
+ len = lstrlenW( headers ) * sizeof(WCHAR);
if (!buffer || len + sizeof(WCHAR) > *buflen)
{
len += sizeof(WCHAR);
@@ -698,7 +698,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
return ret;
}
case WINHTTP_QUERY_VERSION:
- len = strlenW( request->version ) * sizeof(WCHAR);
+ len = lstrlenW( request->version ) * sizeof(WCHAR);
if (!buffer || len + sizeof(WCHAR) > *buflen)
{
len += sizeof(WCHAR);
@@ -706,7 +706,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
}
else
{
- strcpyW( buffer, request->version );
+ lstrcpyW( buffer, request->version );
TRACE("returning string: %s\n", debugstr_w(buffer));
ret = TRUE;
}
@@ -714,7 +714,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
return ret;
case WINHTTP_QUERY_STATUS_TEXT:
- len = strlenW( request->status_text ) * sizeof(WCHAR);
+ len = lstrlenW( request->status_text ) * sizeof(WCHAR);
if (!buffer || len + sizeof(WCHAR) > *buflen)
{
len += sizeof(WCHAR);
@@ -722,7 +722,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
}
else
{
- strcpyW( buffer, request->status_text );
+ lstrcpyW( buffer, request->status_text );
TRACE("returning string: %s\n", debugstr_w(buffer));
ret = TRUE;
}
@@ -730,7 +730,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
return ret;
case WINHTTP_QUERY_REQUEST_METHOD:
- len = strlenW( request->verb ) * sizeof(WCHAR);
+ len = lstrlenW( request->verb ) * sizeof(WCHAR);
if (!buffer || len + sizeof(WCHAR) > *buflen)
{
len += sizeof(WCHAR);
@@ -738,7 +738,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
}
else
{
- strcpyW( buffer, request->verb );
+ lstrcpyW( buffer, request->verb );
TRACE("returning string: %s\n", debugstr_w(buffer));
ret = TRUE;
}
@@ -780,7 +780,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
else
{
int *number = buffer;
- *number = atoiW( header->value );
+ *number = wcstol( header->value, NULL, 10 );
TRACE("returning number: %d\n", *number);
ret = TRUE;
}
@@ -803,7 +803,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
}
else if (header->value)
{
- len = strlenW( header->value ) * sizeof(WCHAR);
+ len = lstrlenW( header->value ) * sizeof(WCHAR);
if (!buffer || len + sizeof(WCHAR) > *buflen)
{
len += sizeof(WCHAR);
@@ -811,7 +811,7 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
}
else
{
- strcpyW( buffer, header->value );
+ lstrcpyW( buffer, header->value );
TRACE("returning string: %s\n", debugstr_w(buffer));
ret = TRUE;
}
@@ -885,7 +885,7 @@ static DWORD auth_scheme_from_header( const WCHAR *header )
for (i = 0; i < ARRAY_SIZE( auth_schemes ); i++)
{
- if (!strncmpiW( header, auth_schemes[i].str, auth_schemes[i].len ) &&
+ if (!wcsnicmp( header, auth_schemes[i].str, auth_schemes[i].len ) &&
(header[auth_schemes[i].len] == ' ' || !header[auth_schemes[i].len])) return auth_schemes[i].scheme;
}
return 0;
@@ -1194,8 +1194,8 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
if (!username || !password) return FALSE;
if ((!authinfo && !(authinfo = alloc_authinfo())) || authinfo->finished) return FALSE;
- userlen = WideCharToMultiByte( CP_UTF8, 0, username, strlenW( username ), NULL, 0, NULL, NULL );
- passlen = WideCharToMultiByte( CP_UTF8, 0, password, strlenW( password ), NULL, 0, NULL, NULL );
+ userlen = WideCharToMultiByte( CP_UTF8, 0, username, lstrlenW( username ), NULL, 0, NULL, NULL );
+ passlen = WideCharToMultiByte( CP_UTF8, 0, password, lstrlenW( password ), NULL, 0, NULL, NULL );
authinfo->data_len = userlen + 1 + passlen;
if (!(authinfo->data = heap_alloc( authinfo->data_len ))) return FALSE;
@@ -1228,7 +1228,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
first = TRUE;
domain = (WCHAR *)username;
- user = strchrW( username, '\\' );
+ user = wcschr( username, '\\' );
if (user) user++;
else
@@ -1238,11 +1238,11 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
}
id.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
id.User = user;
- id.UserLength = strlenW( user );
+ id.UserLength = lstrlenW( user );
id.Domain = domain;
id.DomainLength = domain ? user - domain - 1 : 0;
id.Password = (WCHAR *)password;
- id.PasswordLength = strlenW( password );
+ id.PasswordLength = lstrlenW( password );
status = AcquireCredentialsHandleW( NULL, (SEC_WCHAR *)auth_schemes[scheme].str,
SECPKG_CRED_OUTBOUND, NULL, &id, NULL, NULL,
@@ -1268,8 +1268,8 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
}
else if (authinfo->finished) return FALSE;
- if ((strlenW( auth_value ) < auth_schemes[authinfo->scheme].len ||
- strncmpiW( auth_value, auth_schemes[authinfo->scheme].str, auth_schemes[authinfo->scheme].len )))
+ if ((lstrlenW( auth_value ) < auth_schemes[authinfo->scheme].len ||
+ wcsnicmp( auth_value, auth_schemes[authinfo->scheme].str, auth_schemes[authinfo->scheme].len )))
{
ERR("authentication scheme changed from %s to %s\n",
debugstr_w(auth_schemes[authinfo->scheme].str), debugstr_w(auth_value));
@@ -1288,7 +1288,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
p = auth_value + auth_schemes[scheme].len;
if (*p == ' ')
{
- int len = strlenW( ++p );
+ int len = lstrlenW( ++p );
in.cbBuffer = decode_base64( p, len, NULL );
if (!(in.pvBuffer = heap_alloc( in.cbBuffer ))) {
destroy_authinfo( authinfo );
@@ -1368,10 +1368,10 @@ static WCHAR *build_proxy_connect_string( struct request *request )
static const WCHAR twocrlfW[] = {'\r','\n','\r','\n',0};
WCHAR *ret, *host;
unsigned int i;
- int len;
+ int len = lstrlenW( request->connect->hostname ) + 7;
- if (!(host = heap_alloc( (strlenW( request->connect->hostname ) + 7) * sizeof(WCHAR) ))) return NULL;
- len = sprintfW( host, fmtW, request->connect->hostname, request->connect->hostport );
+ if (!(host = heap_alloc( len * sizeof(WCHAR) ))) return NULL;
+ len = swprintf( host, len, fmtW, request->connect->hostname, request->connect->hostport );
len += ARRAY_SIZE(connectW);
len += ARRAY_SIZE(http1_1);
@@ -1379,29 +1379,29 @@ static WCHAR *build_proxy_connect_string( struct request *request )
for (i = 0; i < request->num_headers; i++)
{
if (request->headers[i].is_request)
- len += strlenW( request->headers[i].field ) + strlenW( request->headers[i].value ) + 4; /* '\r\n: ' */
+ len += lstrlenW( request->headers[i].field ) + lstrlenW( request->headers[i].value ) + 4; /* '\r\n: ' */
}
len += 4; /* '\r\n\r\n' */
if ((ret = heap_alloc( (len + 1) * sizeof(WCHAR) )))
{
- strcpyW( ret, connectW );
- strcatW( ret, spaceW );
- strcatW( ret, host );
- strcatW( ret, spaceW );
- strcatW( ret, http1_1 );
+ lstrcpyW( ret, connectW );
+ lstrcatW( ret, spaceW );
+ lstrcatW( ret, host );
+ lstrcatW( ret, spaceW );
+ lstrcatW( ret, http1_1 );
for (i = 0; i < request->num_headers; i++)
{
if (request->headers[i].is_request)
{
- strcatW( ret, crlfW );
- strcatW( ret, request->headers[i].field );
- strcatW( ret, colonW );
- strcatW( ret, request->headers[i].value );
+ lstrcatW( ret, crlfW );
+ lstrcatW( ret, request->headers[i].field );
+ lstrcatW( ret, colonW );
+ lstrcatW( ret, request->headers[i].value );
}
}
- strcatW( ret, twocrlfW );
+ lstrcatW( ret, twocrlfW );
}
heap_free( host );
@@ -1599,7 +1599,7 @@ static BOOL open_connection( struct request *request )
LIST_FOR_EACH_ENTRY( iter, &connection_pool, struct hostdata, entry )
{
- if (iter->port == port && !strcmpW( connect->servername, iter->hostname ) && !is_secure == !iter->secure)
+ if (iter->port == port && !wcscmp( connect->servername, iter->hostname ) && !is_secure == !iter->secure)
{
host = iter;
host->ref++;
@@ -1656,7 +1656,7 @@ static BOOL open_connection( struct request *request )
if (!connect->resolved)
{
- len = strlenW( host->hostname ) + 1;
+ 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 ))
@@ -1671,7 +1671,7 @@ static BOOL open_connection( struct request *request )
release_host( host );
return FALSE;
}
- len = strlenW( addressW ) + 1;
+ len = lstrlenW( addressW ) + 1;
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, addressW, len );
}
@@ -1701,7 +1701,7 @@ static BOOL open_connection( struct request *request )
if (is_secure)
{
if (connect->session->proxy_server &&
- strcmpiW( connect->hostname, connect->servername ))
+ wcsicmp( connect->hostname, connect->servername ))
{
if (!secure_proxy_connect( request ))
{
@@ -1726,7 +1726,7 @@ static BOOL open_connection( struct request *request )
}
}
- send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, addressW, strlenW(addressW) + 1 );
+ send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, addressW, lstrlenW(addressW) + 1 );
}
else
{
@@ -1778,9 +1778,9 @@ static BOOL add_host_header( struct request *request, DWORD modifier )
{
return process_header( request, attr_host, connect->hostname, modifier, TRUE );
}
- len = strlenW( connect->hostname ) + 7; /* sizeof(":65335") */
+ len = lstrlenW( connect->hostname ) + 7; /* sizeof(":65335") */
if (!(host = heap_alloc( len * sizeof(WCHAR) ))) return FALSE;
- sprintfW( host, fmt, connect->hostname, port );
+ swprintf( host, len, fmt, connect->hostname, port );
ret = process_header( request, attr_host, host, modifier, TRUE );
heap_free( host );
return ret;
@@ -1933,9 +1933,9 @@ static void finished_reading( struct request *request )
else if (query_headers( request, WINHTTP_QUERY_CONNECTION, NULL, connection, &size, NULL ) ||
query_headers( request, WINHTTP_QUERY_PROXY_CONNECTION, NULL, connection, &size, NULL ))
{
- if (!strcmpiW( connection, closeW )) close = TRUE;
+ if (!wcsicmp( connection, closeW )) close = TRUE;
}
- else if (!strcmpW( request->version, http1_0 )) close = TRUE;
+ else if (!wcscmp( request->version, http1_0 )) close = TRUE;
if (close)
{
close_connection( request );
@@ -2092,7 +2092,7 @@ static DWORD str_to_wire( const WCHAR *src, int src_len, char *dst, enum escape_
DWORD len;
char *utf8;
- if (src_len < 0) src_len = strlenW( src );
+ if (src_len < 0) src_len = lstrlenW( src );
len = WideCharToMultiByte( CP_UTF8, 0, src, src_len, NULL, 0, NULL, NULL );
if (!(utf8 = heap_alloc( len ))) return 0;
@@ -2111,16 +2111,16 @@ static char *build_wire_path( struct request *request, DWORD *ret_len )
enum escape_flags path_flags, query_flags;
char *ret;
- if (!strcmpiW( request->connect->hostname, request->connect->servername )) start = full_path = request->path;
+ if (!wcsicmp( request->connect->hostname, request->connect->servername )) start = full_path = request->path;
else if (!(full_path = build_absolute_request_path( request, &start ))) return NULL;
- len = strlenW( full_path );
- if ((path = strchrW( start, '/' )))
+ len = lstrlenW( full_path );
+ if ((path = wcschr( start, '/' )))
{
- len_path = strlenW( path );
- if ((query = strchrW( path, '?' )))
+ len_path = lstrlenW( path );
+ if ((query = wcschr( path, '?' )))
{
- len_query = strlenW( query );
+ len_query = lstrlenW( query );
len_path -= len_query;
}
}
@@ -2222,10 +2222,10 @@ static BOOL send_request( struct request *request, const WCHAR *headers, DWORD h
if (request->creds[TARGET_SERVER][SCHEME_BASIC].username)
do_authorization( request, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC );
- if (total_len || (request->verb && !strcmpW( request->verb, postW )))
+ if (total_len || (request->verb && !wcscmp( request->verb, postW )))
{
WCHAR length[21]; /* decimal long int + null */
- sprintfW( length, length_fmt, total_len );
+ swprintf( length, ARRAY_SIZE(length), length_fmt, total_len );
process_header( request, attr_content_length, length, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE );
}
if (!(request->hdr.disable_flags & WINHTTP_DISABLE_KEEP_ALIVE))
@@ -2315,7 +2315,7 @@ BOOL WINAPI WinHttpSendRequest( HINTERNET hrequest, LPCWSTR headers, DWORD heade
return FALSE;
}
- if (headers && !headers_len) headers_len = strlenW( headers );
+ if (headers && !headers_len) headers_len = lstrlenW( headers );
if (request->connect->hdr.flags & WINHTTP_FLAG_ASYNC)
{
@@ -2452,7 +2452,7 @@ static DWORD set_content_length( struct request *request, DWORD status )
WCHAR encoding[20];
DWORD buflen = sizeof(request->content_length);
- if (status == HTTP_STATUS_NO_CONTENT || status == HTTP_STATUS_NOT_MODIFIED || !strcmpW( request->verb, headW ))
+ if (status == HTTP_STATUS_NO_CONTENT || status == HTTP_STATUS_NOT_MODIFIED || !wcscmp( request->verb, headW ))
request->content_length = 0;
else
{
@@ -2462,7 +2462,7 @@ static DWORD set_content_length( struct request *request, DWORD status )
buflen = sizeof(encoding);
if (query_headers( request, WINHTTP_QUERY_TRANSFER_ENCODING, NULL, encoding, &buflen, NULL ) &&
- !strcmpiW( encoding, chunkedW ))
+ !wcsicmp( encoding, chunkedW ))
{
request->content_length = ~0u;
request->read_chunked = TRUE;
@@ -2520,7 +2520,7 @@ static BOOL read_reply( struct request *request )
static const WCHAR crlf[] = {'\r','\n',0};
char buffer[MAX_REPLY_LEN];
- DWORD buflen, len, offset, crlf_len = 2; /* strlenW(crlf) */
+ DWORD 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") */
@@ -2621,7 +2621,7 @@ static void record_cookies( struct request *request )
for (i = 0; i < request->num_headers; i++)
{
struct header *set_cookie = &request->headers[i];
- if (!strcmpiW( set_cookie->field, attr_set_cookie ) && !set_cookie->is_request)
+ if (!wcsicmp( set_cookie->field, attr_set_cookie ) && !set_cookie->is_request)
{
set_cookies( request, set_cookie->value );
}
@@ -2670,12 +2670,12 @@ static BOOL handle_redirect( struct request *request, DWORD status )
}
else
{
- if ((p = strrchrW( request->path, '/' ))) *p = 0;
- len = strlenW( request->path ) + 1 + len_loc;
+ if ((p = wcsrchr( request->path, '/' ))) *p = 0;
+ len = lstrlenW( request->path ) + 1 + len_loc;
if (!(path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end;
- strcpyW( path, request->path );
- strcatW( path, slashW );
- memcpy( path + strlenW(path), location, len_loc * sizeof(WCHAR) );
+ lstrcpyW( path, request->path );
+ lstrcatW( path, slashW );
+ memcpy( path + lstrlenW(path), location, len_loc * sizeof(WCHAR) );
path[len_loc] = 0;
}
heap_free( request->path );
@@ -2705,7 +2705,7 @@ static BOOL handle_redirect( struct request *request, DWORD status )
hostname[len] = 0;
port = uc.nPort ? uc.nPort : (uc.nScheme == INTERNET_SCHEME_HTTPS ? 443 : 80);
- if (strcmpiW( connect->hostname, hostname ) || connect->serverport != port)
+ if (wcsicmp( connect->hostname, hostname ) || connect->serverport != port)
{
heap_free( connect->hostname );
connect->hostname = hostname;
@@ -2739,7 +2739,7 @@ static BOOL handle_redirect( struct request *request, DWORD status )
if ((index = get_header_index( request, attr_content_type, 0, TRUE )) >= 0) delete_header( request, index );
if ((index = get_header_index( request, attr_content_length, 0, TRUE )) >= 0 ) delete_header( request, index );
- if (status != HTTP_STATUS_REDIRECT_KEEP_VERB && !strcmpW( request->verb, postW ))
+ if (status != HTTP_STATUS_REDIRECT_KEEP_VERB && !wcscmp( request->verb, postW ))
{
heap_free( request->verb );
request->verb = strdupW( getW );
@@ -2762,7 +2762,7 @@ static BOOL is_passport_request( struct request *request )
if (!(request->connect->session->passport_flags & WINHTTP_ENABLE_PASSPORT_AUTH) ||
!query_headers( request, WINHTTP_QUERY_WWW_AUTHENTICATE, NULL, buf, &len, NULL )) return FALSE;
- if (!strncmpiW( buf, passportW, ARRAY_SIZE(passportW) ) &&
+ if (!wcsnicmp( buf, passportW, ARRAY_SIZE(passportW) ) &&
(buf[ARRAY_SIZE(passportW)] == ' ' || !buf[ARRAY_SIZE(passportW)])) return TRUE;
return FALSE;
@@ -2772,7 +2772,7 @@ static BOOL handle_passport_redirect( struct request *request )
{
static const WCHAR status401W[] = {'4','0','1',0};
DWORD flags = WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE;
- int i, len = strlenW( request->raw_headers );
+ int i, len = lstrlenW( request->raw_headers );
WCHAR *p = request->raw_headers;
if (!process_header( request, attr_status, status401W, flags, FALSE )) return FALSE;
@@ -3677,14 +3677,14 @@ static HRESULT WINAPI winhttp_request_SetRequestHeader(
err = ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND;
goto done;
}
- len = strlenW( header ) + 4;
- if (value) len += strlenW( value );
+ len = lstrlenW( header ) + 4;
+ if (value) len += lstrlenW( value );
if (!(str = heap_alloc( (len + 1) * sizeof(WCHAR) )))
{
err = ERROR_OUTOFMEMORY;
goto done;
}
- sprintfW( str, fmtW, header, value ? value : emptyW );
+ swprintf( str, len + 1, fmtW, header, value ? value : emptyW );
if (!WinHttpAddRequestHeaders( request->hrequest, str, len,
WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE ))
{
@@ -3843,7 +3843,7 @@ static HRESULT request_receive( struct winhttp_request *request )
return HRESULT_FROM_WIN32( GetLastError() );
}
if ((err = wait_for_completion( request ))) return HRESULT_FROM_WIN32( err );
- if (!strcmpW( request->verb, headW ))
+ if (!wcscmp( request->verb, headW ))
{
request->state = REQUEST_STATE_RESPONSE_RECEIVED;
return S_OK;
@@ -3920,9 +3920,9 @@ static void request_set_utf8_content_type( struct winhttp_request *request )
WCHAR headerW[64];
int len;
- len = sprintfW( headerW, fmtW, attr_content_type, text_plainW );
+ len = swprintf( headerW, ARRAY_SIZE(headerW), fmtW, attr_content_type, text_plainW );
WinHttpAddRequestHeaders( request->hrequest, headerW, len, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW );
- len = sprintfW( headerW, fmtW, attr_content_type, charset_utf8W );
+ len = swprintf( headerW, ARRAY_SIZE(headerW), fmtW, attr_content_type, charset_utf8W );
WinHttpAddRequestHeaders( request->hrequest, headerW, len, WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON );
}
@@ -3936,14 +3936,14 @@ static HRESULT request_send( struct winhttp_request *request )
DWORD err;
if ((err = request_set_parameters( request ))) return HRESULT_FROM_WIN32( err );
- if (strcmpW( request->verb, getW ))
+ if (wcscmp( request->verb, getW ))
{
VariantInit( &data );
if (V_VT( &request->data ) == VT_BSTR)
{
UINT cp = CP_ACP;
const WCHAR *str = V_BSTR( &request->data );
- int i, len = strlenW( str );
+ int i, len = lstrlenW( str );
for (i = 0; i < len; i++)
{
@@ -4153,14 +4153,14 @@ static DWORD request_get_codepage( struct winhttp_request *request, UINT *codepa
{
return GetLastError();
}
- if ((p = strstrW( buffer, charsetW )))
+ if ((p = wcsstr( buffer, charsetW )))
{
- p += strlenW( charsetW );
+ p += lstrlenW( charsetW );
while (*p == ' ') p++;
if (*p++ == '=')
{
while (*p == ' ') p++;
- if (!strcmpiW( p, utf8W )) *codepage = CP_UTF8;
+ if (!wcsicmp( p, utf8W )) *codepage = CP_UTF8;
}
}
heap_free( buffer );
@@ -4506,7 +4506,7 @@ static HRESULT WINAPI winhttp_request_put_Option(
request->url_codepage = V_UI4( &cp );
TRACE("URL codepage: %u\n", request->url_codepage);
}
- else if (V_VT( &value ) == VT_BSTR && !strcmpiW( V_BSTR( &value ), utf8W ))
+ else if (V_VT( &value ) == VT_BSTR && !wcsicmp( V_BSTR( &value ), utf8W ))
{
TRACE("URL codepage: UTF-8\n");
request->url_codepage = CP_UTF8;
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index 042b4f7203..690b42ab56 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -16,9 +16,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
#include <stdarg.h>
-#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
@@ -379,7 +377,7 @@ static BOOL domain_matches(LPCWSTR server, LPCWSTR domain)
static const WCHAR localW[] = { '<','l','o','c','a','l','>',0 };
BOOL ret = FALSE;
- if (!strcmpiW( domain, localW ) && !strchrW( server, '.' ))
+ if (!wcsicmp( domain, localW ) && !wcschr( server, '.' ))
ret = TRUE;
else if (*domain == '*')
{
@@ -391,12 +389,12 @@ static BOOL domain_matches(LPCWSTR server, LPCWSTR domain)
* the wildcard exactly. E.g. if the wildcard is *.a.b, and the
* hostname is www.foo.a.b, it matches, but a.b does not.
*/
- dot = strchrW( server, '.' );
+ dot = wcschr( server, '.' );
if (dot)
{
- int len = strlenW( dot + 1 );
+ int len = lstrlenW( dot + 1 );
- if (len > strlenW( domain + 2 ))
+ if (len > lstrlenW( domain + 2 ))
{
LPCWSTR ptr;
@@ -404,8 +402,8 @@ static BOOL domain_matches(LPCWSTR server, LPCWSTR domain)
* could be a subdomain. Compare the last portion of the
* server's domain.
*/
- ptr = dot + len + 1 - strlenW( domain + 2 );
- if (!strcmpiW( ptr, domain + 2 ))
+ ptr = dot + len + 1 - lstrlenW( domain + 2 );
+ if (!wcsicmp( ptr, domain + 2 ))
{
/* This is only a match if the preceding character is
* a '.', i.e. that it is a matching domain. E.g.
@@ -416,12 +414,12 @@ static BOOL domain_matches(LPCWSTR server, LPCWSTR domain)
}
}
else
- ret = !strcmpiW( dot + 1, domain + 2 );
+ ret = !wcsicmp( dot + 1, domain + 2 );
}
}
}
else
- ret = !strcmpiW( server, domain );
+ ret = !wcsicmp( server, domain );
return ret;
}
@@ -438,9 +436,9 @@ static BOOL should_bypass_proxy(struct session *session, LPCWSTR server)
do {
LPCWSTR tmp = ptr;
- ptr = strchrW( ptr, ';' );
+ ptr = wcschr( ptr, ';' );
if (!ptr)
- ptr = strchrW( tmp, ' ' );
+ ptr = wcschr( tmp, ' ' );
if (ptr)
{
if (ptr - tmp < MAX_HOST_NAME_LENGTH)
@@ -468,9 +466,9 @@ BOOL set_server_for_hostname( struct connect *connect, const WCHAR *server, INTE
{
LPCWSTR colon;
- if ((colon = strchrW( session->proxy_server, ':' )))
+ if ((colon = wcschr( session->proxy_server, ':' )))
{
- if (!connect->servername || strncmpiW( connect->servername,
+ if (!connect->servername || wcsnicmp( connect->servername,
session->proxy_server, colon - session->proxy_server - 1 ))
{
heap_free( connect->servername );
@@ -485,14 +483,14 @@ BOOL set_server_for_hostname( struct connect *connect, const WCHAR *server, INTE
(colon - session->proxy_server) * sizeof(WCHAR) );
connect->servername[colon - session->proxy_server] = 0;
if (*(colon + 1))
- connect->serverport = atoiW( colon + 1 );
+ connect->serverport = wcstol( colon + 1, NULL, 10 );
else
connect->serverport = INTERNET_DEFAULT_PORT;
}
}
else
{
- if (!connect->servername || strcmpiW( connect->servername,
+ if (!connect->servername || wcsicmp( connect->servername,
session->proxy_server ))
{
heap_free( connect->servername );
@@ -635,7 +633,7 @@ static void request_destroy( struct object_header *hdr )
static void str_to_buffer( WCHAR *buffer, const WCHAR *str, LPDWORD buflen )
{
int len = 0;
- if (str) len = strlenW( str );
+ if (str) len = lstrlenW( str );
if (buffer && *buflen > len)
{
if (str) memcpy( buffer, str, len * sizeof(WCHAR) );
@@ -1075,13 +1073,13 @@ static BOOL add_accept_types_header( struct request *request, const WCHAR **type
static WCHAR *get_request_path( const WCHAR *object )
{
- int len = object ? strlenW(object) : 0;
+ int len = object ? lstrlenW(object) : 0;
WCHAR *p, *ret;
if (!object || object[0] != '/') len++;
if (!(p = ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
if (!object || object[0] != '/') *p++ = '/';
- if (object) strcpyW( p, object );
+ if (object) lstrcpyW( p, object );
ret[len] = 0;
return ret;
}
@@ -1421,12 +1419,12 @@ static WCHAR *build_wpad_url( const char *hostname, const struct addrinfo *ai )
if (!reverse_lookup( ai, name, sizeof(name) )) hostname = name;
- len = strlenW( httpW ) + strlen( hostname ) + strlenW( wpadW );
+ len = lstrlenW( httpW ) + strlen( hostname ) + lstrlenW( wpadW );
if (!(ret = p = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) return NULL;
- strcpyW( p, httpW );
- p += strlenW( httpW );
+ lstrcpyW( p, httpW );
+ p += lstrlenW( httpW );
while (*hostname) { *p++ = *hostname++; }
- strcpyW( p, wpadW );
+ lstrcpyW( p, wpadW );
return ret;
}
@@ -2007,9 +2005,9 @@ BOOL WINAPI WinHttpSetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
if (info->dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY)
{
- size += strlenW( info->lpszProxy );
+ size += lstrlenW( info->lpszProxy );
if (info->lpszProxyBypass)
- size += strlenW( info->lpszProxyBypass );
+ size += lstrlenW( info->lpszProxyBypass );
}
buf = heap_alloc( size );
if (buf)
@@ -2025,14 +2023,14 @@ BOOL WINAPI WinHttpSetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
BYTE *dst;
hdr->flags = PROXY_TYPE_PROXY;
- *len++ = strlenW( info->lpszProxy );
+ *len++ = lstrlenW( info->lpszProxy );
for (dst = (BYTE *)len, src = info->lpszProxy; *src;
src++, dst++)
*dst = *src;
len = (DWORD *)dst;
if (info->lpszProxyBypass)
{
- *len++ = strlenW( info->lpszProxyBypass );
+ *len++ = lstrlenW( info->lpszProxyBypass );
for (dst = (BYTE *)len, src = info->lpszProxyBypass; *src;
src++, dst++)
*dst = *src;
@@ -2176,7 +2174,7 @@ BOOL WINAPI WinHttpTimeFromSystemTime( const SYSTEMTIME *time, LPWSTR string )
return FALSE;
}
- sprintfW( string, format,
+ swprintf( string, WINHTTP_TIME_FORMAT_BUFSIZE / sizeof(WCHAR), format,
wkday[time->wDayOfWeek],
time->wDay,
month[time->wMonth - 1],
@@ -2215,15 +2213,15 @@ BOOL WINAPI WinHttpTimeToSystemTime( LPCWSTR string, SYSTEMTIME *time )
SetLastError( ERROR_SUCCESS );
- while (*s && !isalphaW( *s )) s++;
+ while (*s && !iswalpha( *s )) s++;
if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
time->wDayOfWeek = 7;
for (i = 0; i < 7; i++)
{
- if (toupperW( wkday[i][0] ) == toupperW( s[0] ) &&
- toupperW( wkday[i][1] ) == toupperW( s[1] ) &&
- toupperW( wkday[i][2] ) == toupperW( s[2] ) )
+ if (towupper( wkday[i][0] ) == towupper( s[0] ) &&
+ towupper( wkday[i][1] ) == towupper( s[1] ) &&
+ towupper( wkday[i][2] ) == towupper( s[2] ) )
{
time->wDayOfWeek = i;
break;
@@ -2231,19 +2229,19 @@ BOOL WINAPI WinHttpTimeToSystemTime( LPCWSTR string, SYSTEMTIME *time )
}
if (time->wDayOfWeek > 6) return TRUE;
- while (*s && !isdigitW( *s )) s++;
- time->wDay = strtolW( s, &end, 10 );
+ while (*s && !iswdigit( *s )) s++;
+ time->wDay = wcstol( s, &end, 10 );
s = end;
- while (*s && !isalphaW( *s )) s++;
+ while (*s && !iswalpha( *s )) s++;
if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
time->wMonth = 0;
for (i = 0; i < 12; i++)
{
- if (toupperW( month[i][0]) == toupperW( s[0] ) &&
- toupperW( month[i][1]) == toupperW( s[1] ) &&
- toupperW( month[i][2]) == toupperW( s[2] ) )
+ if (towupper( month[i][0]) == towupper( s[0] ) &&
+ towupper( month[i][1]) == towupper( s[1] ) &&
+ towupper( month[i][2]) == towupper( s[2] ) )
{
time->wMonth = i + 1;
break;
@@ -2251,24 +2249,24 @@ BOOL WINAPI WinHttpTimeToSystemTime( LPCWSTR string, SYSTEMTIME *time )
}
if (time->wMonth == 0) return TRUE;
- while (*s && !isdigitW( *s )) s++;
+ while (*s && !iswdigit( *s )) s++;
if (*s == '\0') return TRUE;
- time->wYear = strtolW( s, &end, 10 );
+ time->wYear = wcstol( s, &end, 10 );
s = end;
- while (*s && !isdigitW( *s )) s++;
+ while (*s && !iswdigit( *s )) s++;
if (*s == '\0') return TRUE;
- time->wHour = strtolW( s, &end, 10 );
+ time->wHour = wcstol( s, &end, 10 );
s = end;
- while (*s && !isdigitW( *s )) s++;
+ while (*s && !iswdigit( *s )) s++;
if (*s == '\0') return TRUE;
- time->wMinute = strtolW( s, &end, 10 );
+ time->wMinute = wcstol( s, &end, 10 );
s = end;
- while (*s && !isdigitW( *s )) s++;
+ while (*s && !iswdigit( *s )) s++;
if (*s == '\0') return TRUE;
- time->wSecond = strtolW( s, &end, 10 );
+ time->wSecond = wcstol( s, &end, 10 );
time->wMilliseconds = 0;
return TRUE;
diff --git a/dlls/winhttp/url.c b/dlls/winhttp/url.c
index e1255bd6b1..d405090409 100644
--- a/dlls/winhttp/url.c
+++ b/dlls/winhttp/url.c
@@ -16,12 +16,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "ws2tcpip.h"
-#include <stdarg.h>
-
+#include <wchar.h>
#include "windef.h"
#include "winbase.h"
+#include "ws2tcpip.h"
#include "winreg.h"
#include "winhttp.h"
#include "shlwapi.h"
@@ -74,12 +72,12 @@ static WCHAR *decode_url( LPCWSTR url, DWORD *len )
q = ret;
while (*len > 0)
{
- if (p[0] == '%' && isxdigitW( p[1] ) && isxdigitW( p[2] ))
+ if (p[0] == '%' && iswxdigit( p[1] ) && iswxdigit( p[2] ))
{
hex[0] = p[1];
hex[1] = p[2];
hex[2] = 0;
- *q++ = strtolW( hex, NULL, 16 );
+ *q++ = wcstol( hex, NULL, 16 );
p += 3;
*len -= 3;
}
@@ -139,7 +137,7 @@ static DWORD escape_url( const WCHAR *url, DWORD *len, WCHAR **ret )
const WCHAR *p;
DWORD len_base, len_path;
- if ((p = strrchrW( url, '/' )))
+ if ((p = wcsrchr( url, '/' )))
{
len_base = p - url;
if (!escape_string( p, *len - len_base, NULL, &len_path )) return ERROR_INVALID_PARAMETER;
@@ -164,7 +162,7 @@ static DWORD parse_port( const WCHAR *str, DWORD len, INTERNET_PORT *ret )
{
const WCHAR *p = str;
DWORD port = 0;
- while (len && isdigitW( *p ))
+ while (len && iswdigit( *p ))
{
if ((port = port * 10 + *p - '0') > 65535) return ERROR_WINHTTP_INVALID_URL;
p++; len--;
@@ -191,7 +189,7 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
- if (!len) len = strlenW( url );
+ if (!len) len = lstrlenW( url );
if (flags & ICU_ESCAPE)
{
@@ -211,13 +209,13 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
}
url = url_decoded;
}
- if (!(p = strchrW( url, ':' )))
+ if (!(p = wcschr( url, ':' )))
{
SetLastError( ERROR_WINHTTP_UNRECOGNIZED_SCHEME );
return FALSE;
}
- if (p - url == 4 && !strncmpiW( url, scheme_http, 4 )) scheme_number = INTERNET_SCHEME_HTTP;
- else if (p - url == 5 && !strncmpiW( url, scheme_https, 5 )) scheme_number = INTERNET_SCHEME_HTTPS;
+ if (p - url == 4 && !wcsnicmp( url, scheme_http, 4 )) scheme_number = INTERNET_SCHEME_HTTP;
+ else if (p - url == 5 && !wcsnicmp( url, scheme_https, 5 )) scheme_number = INTERNET_SCHEME_HTTPS;
else
{
err = ERROR_WINHTTP_UNRECOGNIZED_SCHEME;
@@ -248,10 +246,10 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
password.str = &uc->lpszPassword;
password.len = &uc->dwPasswordLength;
- if ((q = memchrW( p, '@', len - (p - url) )) && !(memchrW( p, '/', q - p )))
+ if ((q = wmemchr( p, '@', len - (p - url) )) && !(wmemchr( p, '/', q - p )))
{
- if ((r = memchrW( p, ':', q - p )))
+ if ((r = wmemchr( p, ':', q - p )))
{
if ((err = set_component( &username, p, r - p, flags, &overflow ))) goto exit;
r++;
@@ -279,9 +277,9 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
extra.str = &uc->lpszExtraInfo;
extra.len = &uc->dwExtraInfoLength;
- if ((q = memchrW( p, '/', len - (p - url) )))
+ if ((q = wmemchr( p, '/', len - (p - url) )))
{
- if ((r = memchrW( p, ':', q - p )))
+ if ((r = wmemchr( p, ':', q - p )))
{
if ((err = set_component( &hostname, p, r - p, flags, &overflow ))) goto exit;
r++;
@@ -294,7 +292,7 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT;
}
- if ((r = memchrW( q, '?', len - (q - url) )))
+ if ((r = wmemchr( q, '?', len - (q - url) )))
{
if (*extra.len)
{
@@ -311,7 +309,7 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
}
else
{
- if ((r = memchrW( p, ':', len - (p - url) )))
+ if ((r = wmemchr( p, ':', len - (p - url) )))
{
if ((err = set_component( &hostname, p, r - p, flags, &overflow ))) goto exit;
r++;
@@ -345,8 +343,8 @@ exit:
static INTERNET_SCHEME get_scheme( const WCHAR *scheme, DWORD len )
{
- if (!strncmpW( scheme, scheme_http, len )) return INTERNET_SCHEME_HTTP;
- if (!strncmpW( scheme, scheme_https, len )) return INTERNET_SCHEME_HTTPS;
+ if (!wcsncmp( scheme, scheme_http, len )) return INTERNET_SCHEME_HTTP;
+ if (!wcsncmp( scheme, scheme_https, len )) return INTERNET_SCHEME_HTTPS;
return 0;
}
@@ -369,7 +367,7 @@ static DWORD get_comp_length( DWORD len, DWORD flags, WCHAR *comp )
DWORD ret;
unsigned int i;
- ret = len ? len : strlenW( comp );
+ ret = len ? len : lstrlenW( comp );
if (!(flags & ICU_ESCAPE)) return ret;
for (i = 0; i < len; i++) if (need_escape( comp[i] )) ret += 2;
return ret;
@@ -391,7 +389,7 @@ static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len )
{
scheme = uc->nScheme;
if (!scheme) scheme = INTERNET_SCHEME_HTTP;
- *len += strlenW( get_scheme_string( scheme ) );
+ *len += lstrlenW( get_scheme_string( scheme ) );
}
*len += 3; /* "://" */
@@ -421,7 +419,7 @@ static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len )
{
WCHAR port[sizeof("65535")];
- *len += sprintfW( port, formatW, uc->nPort );
+ *len += swprintf( port, ARRAY_SIZE(port), formatW, uc->nPort );
*len += 1; /* ":" */
}
if (uc->lpszUrlPath && *uc->lpszUrlPath != '/') *len += 1; /* '/' */
@@ -480,7 +478,7 @@ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDW
if (!scheme) scheme = INTERNET_SCHEME_HTTP;
schemeW = get_scheme_string( scheme );
- len = strlenW( schemeW );
+ len = lstrlenW( schemeW );
memcpy( url, schemeW, len * sizeof(WCHAR) );
url += len;
}
@@ -513,7 +511,7 @@ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDW
if (!uses_default_port( scheme, uc->nPort ))
{
*url++ = ':';
- url += sprintfW( url, formatW, uc->nPort );
+ url += swprintf( url, sizeof("65535"), formatW, uc->nPort );
}
/* add slash between hostname and path if necessary */
diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h
index 734a1ad52a..a820241734 100644
--- a/dlls/winhttp/winhttp_private.h
+++ b/dlls/winhttp/winhttp_private.h
@@ -19,13 +19,8 @@
#ifndef _WINE_WINHTTP_PRIVATE_H_
#define _WINE_WINHTTP_PRIVATE_H_
-#ifndef __WINE_CONFIG_H
-# error You must include config.h to use this header
-#endif
-
#include "wine/heap.h"
#include "wine/list.h"
-#include "wine/unicode.h"
#include "ole2.h"
#include "sspi.h"
@@ -304,8 +299,8 @@ static inline WCHAR *strdupW( const WCHAR *src )
WCHAR *dst;
if (!src) return NULL;
- dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) );
- if (dst) strcpyW( dst, src );
+ dst = heap_alloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) );
+ if (dst) lstrcpyW( dst, src );
return dst;
}
--
2.20.1
2
1
20 Nov '19
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/winhttp/winhttp_private.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h
index 93cf0f7125..734a1ad52a 100644
--- a/dlls/winhttp/winhttp_private.h
+++ b/dlls/winhttp/winhttp_private.h
@@ -314,7 +314,7 @@ static inline WCHAR *strdupAW( const char *src )
WCHAR *dst = NULL;
if (src)
{
- DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
+ int len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
if ((dst = heap_alloc( len * sizeof(WCHAR) )))
MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
}
@@ -341,7 +341,7 @@ static inline char *strdupWA_sized( const WCHAR *src, DWORD size )
int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
if ((dst = heap_alloc( len )))
{
- WideCharToMultiByte( CP_ACP, 0, src, len, dst, size, NULL, NULL );
+ WideCharToMultiByte( CP_ACP, 0, src, size, dst, len, NULL, NULL );
dst[len - 1] = 0;
}
}
--
2.20.1
1
0
[PATCH 1/3] winhttp: Add support for detecting the proxy config URL via DHCP.
by Hans Leidekker 20 Nov '19
by Hans Leidekker 20 Nov '19
20 Nov '19
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/winhttp/Makefile.in | 3 +-
dlls/winhttp/session.c | 214 ++++++++++++++++++++++-----------------
2 files changed, 121 insertions(+), 96 deletions(-)
diff --git a/dlls/winhttp/Makefile.in b/dlls/winhttp/Makefile.in
index 659b5821df..f4fc317c5f 100644
--- a/dlls/winhttp/Makefile.in
+++ b/dlls/winhttp/Makefile.in
@@ -1,8 +1,7 @@
MODULE = winhttp.dll
IMPORTLIB = winhttp
IMPORTS = uuid jsproxy user32 advapi32 ws2_32
-DELAYIMPORTS = oleaut32 ole32 crypt32 secur32
-EXTRALIBS = $(CORESERVICES_LIBS)
+DELAYIMPORTS = oleaut32 ole32 crypt32 secur32 iphlpapi dhcpcsvc
C_SRCS = \
cookie.c \
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index ef4bb17469..042b4f7203 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -20,14 +20,6 @@
#include <stdarg.h>
#include <stdlib.h>
-#ifdef HAVE_CORESERVICES_CORESERVICES_H
-#define GetCurrentThread MacGetCurrentThread
-#define LoadResource MacLoadResource
-#include <CoreServices/CoreServices.h>
-#undef GetCurrentThread
-#undef LoadResource
-#endif
-
#include "windef.h"
#include "winbase.h"
#include "winsock2.h"
@@ -36,6 +28,8 @@
#include "winhttp.h"
#include "winreg.h"
#include "winternl.h"
+#include "iphlpapi.h"
+#include "dhcpcsdk.h"
#define COBJMACROS
#include "ole2.h"
#include "dispex.h"
@@ -1310,6 +1304,80 @@ BOOL WINAPI WinHttpSetOption( HINTERNET handle, DWORD option, LPVOID buffer, DWO
return ret;
}
+static IP_ADAPTER_ADDRESSES *get_adapters(void)
+{
+ ULONG err, size = 1024, flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST |
+ GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME;
+ IP_ADAPTER_ADDRESSES *tmp, *ret;
+
+ if (!(ret = heap_alloc( size ))) return NULL;
+ err = GetAdaptersAddresses( AF_UNSPEC, flags, NULL, ret, &size );
+ while (err == ERROR_BUFFER_OVERFLOW)
+ {
+ if (!(tmp = heap_realloc( ret, size ))) break;
+ ret = tmp;
+ err = GetAdaptersAddresses( AF_UNSPEC, flags, NULL, ret, &size );
+ }
+ if (err == ERROR_SUCCESS) return ret;
+ heap_free( ret );
+ return NULL;
+}
+
+static WCHAR *detect_autoproxyconfig_url_dhcp(void)
+{
+ IP_ADAPTER_ADDRESSES *adapters, *ptr;
+ DHCPCAPI_PARAMS_ARRAY send_params, recv_params;
+ DHCPCAPI_PARAMS param;
+ WCHAR name[MAX_ADAPTER_NAME_LENGTH + 1], *ret = NULL;
+ DWORD err, size;
+ BYTE *tmp, *buf = NULL;
+
+ if (!(adapters = get_adapters())) return NULL;
+
+ memset( &send_params, 0, sizeof(send_params) );
+ memset( ¶m, 0, sizeof(param) );
+ param.OptionId = OPTION_MSFT_IE_PROXY;
+ recv_params.nParams = 1;
+ recv_params.Params = ¶m;
+
+ for (ptr = adapters; ptr; ptr = ptr->Next)
+ {
+ MultiByteToWideChar( CP_ACP, 0, ptr->AdapterName, -1, name, ARRAY_SIZE(name) );
+ TRACE( "adapter '%s' type %u dhcpv4 enabled %d\n", wine_dbgstr_w(name), ptr->IfType, ptr->Dhcpv4Enabled );
+
+ if (ptr->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
+ /* FIXME: also skip adapters where DHCP is disabled */
+
+ size = 256;
+ if (!(buf = heap_alloc( size ))) goto done;
+ err = DhcpRequestParams( DHCPCAPI_REQUEST_SYNCHRONOUS, NULL, name, NULL, send_params, recv_params,
+ buf, &size, NULL );
+ while (err == ERROR_MORE_DATA)
+ {
+ if (!(tmp = heap_realloc( buf, size ))) goto done;
+ buf = tmp;
+ err = DhcpRequestParams( DHCPCAPI_REQUEST_SYNCHRONOUS, NULL, name, NULL, send_params, recv_params,
+ buf, &size, NULL );
+ }
+ if (err == ERROR_SUCCESS && param.nBytesData)
+ {
+ int len = MultiByteToWideChar( CP_ACP, 0, (const char *)param.Data, param.nBytesData, NULL, 0 );
+ if ((ret = heap_alloc( (len + 1) * sizeof(WCHAR) )))
+ {
+ MultiByteToWideChar( CP_ACP, 0, (const char *)param.Data, param.nBytesData, ret, len );
+ ret[len] = 0;
+ }
+ TRACE("returning %s\n", debugstr_w(ret));
+ break;
+ }
+ }
+
+done:
+ heap_free( buf );
+ heap_free( adapters );
+ return ret;
+}
+
static char *get_computer_name( COMPUTER_NAME_FORMAT format )
{
char *ret;
@@ -1362,50 +1430,57 @@ static WCHAR *build_wpad_url( const char *hostname, const struct addrinfo *ai )
return ret;
}
-static BOOL get_system_proxy_autoconfig_url( char *buf, DWORD buflen )
+static WCHAR *detect_autoproxyconfig_url_dns(void)
{
-#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
- CFDictionaryRef settings = CFNetworkCopySystemProxySettings();
- const void *ref;
- BOOL ret = FALSE;
-
- if (!settings) return FALSE;
+ char *fqdn, *domain, *p;
+ WCHAR *ret;
- if (!(ref = CFDictionaryGetValue( settings, kCFNetworkProxiesProxyAutoConfigURLString )))
+ if (!(fqdn = get_computer_name( ComputerNamePhysicalDnsFullyQualified ))) return NULL;
+ if (!(domain = get_computer_name( ComputerNamePhysicalDnsDomain )))
{
- CFRelease( settings );
- return FALSE;
+ heap_free( fqdn );
+ return NULL;
}
- if (CFStringGetCString( ref, buf, buflen, kCFStringEncodingASCII ))
+ p = fqdn;
+ while ((p = strchr( p, '.' )) && is_domain_suffix( p + 1, domain ))
{
- TRACE( "returning %s\n", debugstr_a(buf) );
- ret = TRUE;
+ char *name;
+ struct addrinfo *ai;
+ int res;
+
+ if (!(name = heap_alloc( sizeof("wpad") + strlen(p) )))
+ {
+ heap_free( fqdn );
+ heap_free( domain );
+ return NULL;
+ }
+ strcpy( name, "wpad" );
+ strcat( name, p );
+ res = getaddrinfo( name, NULL, NULL, &ai );
+ if (!res)
+ {
+ ret = build_wpad_url( name, ai );
+ freeaddrinfo( ai );
+ if (ret)
+ {
+ TRACE("returning %s\n", debugstr_w(ret));
+ heap_free( name );
+ break;
+ }
+ }
+ heap_free( name );
+ p++;
}
- CFRelease( settings );
+ heap_free( domain );
+ heap_free( fqdn );
return ret;
-#else
- static BOOL first = TRUE;
- if (first)
- {
- FIXME( "no support on this platform\n" );
- first = FALSE;
- }
- else
- TRACE( "no support on this platform\n" );
- return FALSE;
-#endif
}
-#define INTERNET_MAX_URL_LENGTH 2084
-
/***********************************************************************
* WinHttpDetectAutoProxyConfigUrl (winhttp.@)
*/
BOOL WINAPI WinHttpDetectAutoProxyConfigUrl( DWORD flags, LPWSTR *url )
{
- BOOL ret = FALSE;
- char system_url[INTERNET_MAX_URL_LENGTH + 1];
-
TRACE("0x%08x, %p\n", flags, url);
if (!flags || !url)
@@ -1413,71 +1488,22 @@ BOOL WINAPI WinHttpDetectAutoProxyConfigUrl( DWORD flags, LPWSTR *url )
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
- if (get_system_proxy_autoconfig_url( system_url, sizeof(system_url) ))
- {
- WCHAR *urlW;
-
- if (!(urlW = strdupAW( system_url ))) return FALSE;
- *url = urlW;
- SetLastError( ERROR_SUCCESS );
- return TRUE;
- }
+ *url = NULL;
if (flags & WINHTTP_AUTO_DETECT_TYPE_DHCP)
{
- static int fixme_shown;
- if (!fixme_shown++) FIXME("discovery via DHCP not supported\n");
+ *url = detect_autoproxyconfig_url_dhcp();
}
if (flags & WINHTTP_AUTO_DETECT_TYPE_DNS_A)
{
- char *fqdn, *domain, *p;
-
- if (!(fqdn = get_computer_name( ComputerNamePhysicalDnsFullyQualified ))) return FALSE;
- if (!(domain = get_computer_name( ComputerNamePhysicalDnsDomain )))
- {
- heap_free( fqdn );
- return FALSE;
- }
- p = fqdn;
- while ((p = strchr( p, '.' )) && is_domain_suffix( p + 1, domain ))
- {
- struct addrinfo *ai;
- char *name;
- int res;
-
- if (!(name = heap_alloc( sizeof("wpad") + strlen(p) )))
- {
- heap_free( fqdn );
- heap_free( domain );
- return FALSE;
- }
- strcpy( name, "wpad" );
- strcat( name, p );
- res = getaddrinfo( name, NULL, NULL, &ai );
- if (!res)
- {
- *url = build_wpad_url( name, ai );
- freeaddrinfo( ai );
- if (*url)
- {
- TRACE("returning %s\n", debugstr_w(*url));
- heap_free( name );
- ret = TRUE;
- break;
- }
- }
- heap_free( name );
- p++;
- }
- heap_free( domain );
- heap_free( fqdn );
+ if (!*url) *url = detect_autoproxyconfig_url_dns();
}
- if (!ret)
+ if (!*url)
{
SetLastError( ERROR_WINHTTP_AUTODETECTION_FAILED );
- *url = NULL;
+ return FALSE;
}
- else SetLastError( ERROR_SUCCESS );
- return ret;
+ SetLastError( ERROR_SUCCESS );
+ return TRUE;
}
static const WCHAR Connections[] = {
--
2.20.1
1
0
[PATCH] mountmgr.sys: Fix the build on macOS when dbus libraries are present.
by Hans Leidekker 20 Nov '19
by Hans Leidekker 20 Nov '19
20 Nov '19
Reported by Gijs Vermeulen.
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/mountmgr.sys/dbus.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dlls/mountmgr.sys/dbus.c b/dlls/mountmgr.sys/dbus.c
index f85c2e3707..fbdcdb9e2e 100644
--- a/dlls/mountmgr.sys/dbus.c
+++ b/dlls/mountmgr.sys/dbus.c
@@ -771,6 +771,8 @@ void initialize_dbus(void)
CloseHandle( handle );
}
+#if !defined(HAVE_SYSTEMCONFIGURATION_SCDYNAMICSTORECOPYDHCPINFO_H) || !defined(HAVE_SYSTEMCONFIGURATION_SCNETWORKCONFIGURATION_H)
+
/* The udisks dispatch loop will block all threads using the same connection, so we'll
use a private connection. Multiple threads can make methods calls at the same time
on the same connection, according to the documentation.
@@ -1033,6 +1035,7 @@ ULONG get_dhcp_request_param( const WCHAR *adapter, struct mountmgr_dhcp_request
p_dbus_message_unref( reply );
return ret;
}
+#endif
#else /* SONAME_LIBDBUS_1 */
--
2.20.1
1
0
[PATCH v3 1/4] server: Add support for additional fields in set_console_output_info.
by Gijs Vermeulen 20 Nov '19
by Gijs Vermeulen 20 Nov '19
20 Nov '19
Signed-off-by: Gijs Vermeulen <gijsvrm(a)codeweavers.com>
---
programs/wineconsole/wineconsole.c | 3 +++
server/console.c | 34 +++++++++++++++++++++++++-----
server/protocol.def | 33 ++++++++++++++++-------------
3 files changed, 50 insertions(+), 20 deletions(-)
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
index 439099c37a..ebcfce1011 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -458,6 +458,9 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf
req->max_height = (r.bottom - r.top - GetSystemMetrics(SM_CYCAPTION)) / cfg->cell_height;
req->font_width = cfg->cell_width;
req->font_height = cfg->cell_height;
+ req->font_weight = cfg->font_weight;
+ req->font_pitch_family = FIXED_PITCH | FF_DONTCARE;
+ wine_server_add_data( req, cfg->face_name, lstrlenW(cfg->face_name) * sizeof(WCHAR) );
wine_server_call( req );
}
SERVER_END_REQ;
diff --git a/server/console.c b/server/console.c
index 7d1fc5d268..d40da275e9 100644
--- a/server/console.c
+++ b/server/console.c
@@ -131,6 +131,9 @@ struct font_info
{
short int width;
short int height;
+ short int weight;
+ short int pitch_family;
+ struct unicode_str face_name;
};
struct screen_buffer
@@ -433,6 +436,10 @@ static struct screen_buffer *create_console_output( struct console_input *consol
screen_buffer->data = NULL;
screen_buffer->font.width = 0;
screen_buffer->font.height = 0;
+ screen_buffer->font.weight = FW_NORMAL;
+ screen_buffer->font.pitch_family = FIXED_PITCH | FF_DONTCARE;
+ screen_buffer->font.face_name.str = NULL;
+ screen_buffer->font.face_name.len = 0;
memset( screen_buffer->color_map, 0, sizeof(screen_buffer->color_map) );
list_add_head( &screen_buffer_list, &screen_buffer->entry );
@@ -896,6 +903,8 @@ static int set_console_output_info( struct screen_buffer *screen_buffer,
const struct set_console_output_info_request *req )
{
struct console_renderer_event evt;
+ data_size_t font_name_len, offset;
+ WCHAR *font_name;
memset(&evt.u, 0, sizeof(evt.u));
if (req->mask & SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM)
@@ -1039,15 +1048,29 @@ static int set_console_output_info( struct screen_buffer *screen_buffer,
screen_buffer->max_width = req->max_width;
screen_buffer->max_height = req->max_height;
}
+ if (req->mask & SET_CONSOLE_OUTPUT_INFO_COLORTABLE)
+ {
+ memcpy( screen_buffer->color_map, get_req_data(), min( get_req_data_size(), sizeof(screen_buffer->color_map) ));
+ }
if (req->mask & SET_CONSOLE_OUTPUT_INFO_FONT)
{
screen_buffer->font.width = req->font_width;
screen_buffer->font.height = req->font_height;
- }
- if (req->mask & SET_CONSOLE_OUTPUT_INFO_COLORTABLE)
- {
- memcpy( screen_buffer->color_map, get_req_data(),
- min( sizeof(screen_buffer->color_map), get_req_data_size() ));
+ screen_buffer->font.weight = req->font_weight;
+ screen_buffer->font.pitch_family = req->font_pitch_family;
+ offset = req->mask & SET_CONSOLE_OUTPUT_INFO_COLORTABLE ? sizeof(screen_buffer->color_map) : 0;
+ if (get_req_data_size() > offset)
+ {
+ font_name_len = (get_req_data_size() - offset) / sizeof(WCHAR) * sizeof(WCHAR);
+ font_name = mem_alloc( font_name_len );
+ if (font_name)
+ {
+ memcpy( font_name, (char*)get_req_data() + offset, font_name_len );
+ free( (WCHAR *)screen_buffer->font.face_name.str );
+ screen_buffer->font.face_name.str = font_name;
+ screen_buffer->font.face_name.len = font_name_len;
+ }
+ }
}
return 1;
@@ -1183,6 +1206,7 @@ static void screen_buffer_destroy( struct object *obj )
}
if (screen_buffer->fd) release_object( screen_buffer->fd );
free( screen_buffer->data );
+ free( (WCHAR *)screen_buffer->font.face_name.str );
}
static struct fd *screen_buffer_get_fd( struct object *obj )
diff --git a/server/protocol.def b/server/protocol.def
index 3a0df20bdb..4dc9a278ad 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1615,25 +1615,28 @@ struct console_renderer_event
/* Set info about a console (output only) */
@REQ(set_console_output_info)
- obj_handle_t handle; /* handle to the console */
- int mask; /* setting mask (see below) */
- short int cursor_size; /* size of cursor (percentage filled) */
- short int cursor_visible;/* cursor visibility flag */
- short int cursor_x; /* position of cursor (x, y) */
+ obj_handle_t handle; /* handle to the console */
+ int mask; /* setting mask (see below) */
+ short int cursor_size; /* size of cursor (percentage filled) */
+ short int cursor_visible; /* cursor visibility flag */
+ short int cursor_x; /* position of cursor (x, y) */
short int cursor_y;
- short int width; /* width of the screen buffer */
- short int height; /* height of the screen buffer */
- short int attr; /* default fill attributes (screen colors) */
- short int popup_attr; /* pop-up color attributes */
- short int win_left; /* window actually displayed by renderer */
- short int win_top; /* the rect area is expressed within the */
- short int win_right; /* boundaries of the screen buffer */
+ short int width; /* width of the screen buffer */
+ short int height; /* height of the screen buffer */
+ short int attr; /* default fill attributes (screen colors) */
+ short int popup_attr; /* pop-up color attributes */
+ short int win_left; /* window actually displayed by renderer */
+ short int win_top; /* the rect area is expressed within the */
+ short int win_right; /* boundaries of the screen buffer */
short int win_bottom;
- short int max_width; /* maximum size (width x height) for the window */
+ short int max_width; /* maximum size (width x height) for the window */
short int max_height;
- short int font_width; /* font size (width x height) */
+ short int font_width; /* font size (width x height) */
short int font_height;
- VARARG(colors,uints); /* color table */
+ short int font_weight; /* font weight */
+ short int font_pitch_family; /* font pitch & family */
+ VARARG(colors,uints); /* color table */
+ VARARG(face_name,unicode_str); /* font face name */
@END
#define SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM 0x0001
#define SET_CONSOLE_OUTPUT_INFO_CURSOR_POS 0x0002
--
2.24.0
2
6
[PATCH v2] wineboot: Automatically create ProfileList key for current user.
by Dmitry Timoshkov 20 Nov '19
by Dmitry Timoshkov 20 Nov '19
20 Nov '19
This patch aims to replace the appropriate patchset from wine-staging.
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
programs/wineboot/wineboot.c | 43 ++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c
index cd5c9505b3..9710b78ab7 100644
--- a/programs/wineboot/wineboot.c
+++ b/programs/wineboot/wineboot.c
@@ -61,6 +61,7 @@
#include <unistd.h>
#include <windows.h>
#include <winternl.h>
+#include <sddl.h>
#include <wine/svcctl.h>
#include <wine/asm.h>
#include <wine/debug.h>
@@ -1174,6 +1175,47 @@ static void install_root_pnp_devices(void)
SetupDiDestroyDeviceInfoList(set);
}
+static void update_user_profile(void)
+{
+ static const WCHAR profile_list[] = {'S','o','f','t','w','a','r','e','\\',
+ 'M','i','c','r','o','s','o','f','t','\\',
+ 'W','i','n','d','o','w','s',' ','N','T','\\',
+ 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
+ 'P','r','o','f','i','l','e','L','i','s','t',0};
+ static const WCHAR profile_image_path[] = {'P','r','o','f','i','l','e','I','m','a','g','e','P','a','t','h',0};
+ char token_buf[sizeof(TOKEN_USER) + sizeof(SID) + sizeof(DWORD) * SID_MAX_SUB_AUTHORITIES];
+ HANDLE token;
+ WCHAR profile[MAX_PATH], *sid;
+ DWORD size;
+ HKEY hkey, profile_hkey;
+
+ if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token))
+ return;
+
+ size = sizeof(token_buf);
+ GetTokenInformation(token, TokenUser, token_buf, size, &size);
+ CloseHandle(token);
+
+ ConvertSidToStringSidW(((TOKEN_USER *)token_buf)->User.Sid, &sid);
+
+ if (!RegCreateKeyExW(HKEY_LOCAL_MACHINE, profile_list, 0, NULL, 0,
+ KEY_ALL_ACCESS, NULL, &hkey, NULL))
+ {
+ if (!RegCreateKeyExW(hkey, sid, 0, NULL, 0,
+ KEY_ALL_ACCESS, NULL, &profile_hkey, NULL))
+ {
+ if (SHGetSpecialFolderPathW(NULL, profile, CSIDL_PROFILE, TRUE))
+ set_reg_value(profile_hkey, profile_image_path, profile);
+
+ RegCloseKey(profile_hkey);
+ }
+
+ RegCloseKey(hkey);
+ }
+
+ LocalFree(sid);
+}
+
/* execute rundll32 on the wine.inf file if necessary */
static void update_wineprefix( BOOL force )
{
@@ -1218,6 +1260,7 @@ static void update_wineprefix( BOOL force )
DestroyWindow( hwnd );
}
install_root_pnp_devices();
+ update_user_profile();
WINE_MESSAGE( "wine: configuration in '%s' has been updated.\n", prettyprint_configdir() );
}
--
2.20.1
1
0
[PATCH v2] ntdll: Fix find_free_area outside of reserved areas with zero_bits != 0.
by Rémi Bernon 20 Nov '19
by Rémi Bernon 20 Nov '19
20 Nov '19
The search was initiated with base == 0, which returns NULL immediately
if MEM_TOP_DOWN is not used. Using address_space_start instead fixes
this issue.
Then we assumed that all mmapped regions are known by Wine view tree,
which is obviously not the case with external allocations. This could
lead to memory corruption when find_free_area returns an expected free
region which is already mmapped. Using MAP_FIXED forces mmap to succeed
and corrupts the mapping.
This patch uses safe mmap calls to check if the expected free memory is
actually free, and iterates over the expected free ranges until it
succeeds.
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
Based on a patch from Paul Gofman <gofmanp(a)gmail.com>
v2: Fix try_map_free_area step condition.
dlls/ntdll/virtual.c | 62 +++++++++++++++++++++++++++++++++++++-------
1 file changed, 52 insertions(+), 10 deletions(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 68249de902e..b2c17f2c005 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -496,6 +496,35 @@ static struct file_view *find_view_range( const void *addr, size_t size )
return NULL;
}
+/***********************************************************************
+ * try_map_free_area
+ *
+ * Try mmaping some expected free memory region, eventually stepping and
+ * retrying inside it, and return where it actually succeeded, or NULL.
+ */
+static void* try_map_free_area( void *base, void *end, ptrdiff_t step,
+ void *start, size_t size, int unix_prot )
+{
+ void *ptr;
+
+ while (start && base <= start && (char*)start + size <= (char*)end)
+ {
+ if ((ptr = wine_anon_mmap( start, size, unix_prot, 0 )) == start)
+ return start;
+ TRACE( "Found free area is already mapped, start %p.\n", start );
+
+ if (ptr != (void *)-1)
+ munmap( ptr, size );
+
+ if ((step > 0 && (char *)end - (char *)start < step) ||
+ (step < 0 && (char *)start - (char *)base < -step) ||
+ step == 0)
+ break;
+ start = (char *)start + step;
+ }
+
+ return NULL;
+}
/***********************************************************************
* find_free_area
@@ -503,9 +532,11 @@ static struct file_view *find_view_range( const void *addr, size_t size )
* Find a free area between views inside the specified range.
* The csVirtual section must be held by caller.
*/
-static void *find_free_area( void *base, void *end, size_t size, size_t mask, int top_down )
+static void *find_free_area( void *base, void *end, size_t size, size_t mask, int top_down,
+ int map_area, int unix_prot )
{
struct wine_rb_entry *first = NULL, *ptr = views_tree.root;
+ ptrdiff_t step = top_down ? -(mask + 1) : (mask + 1);
void *start;
/* find the first (resp. last) view inside the range */
@@ -538,7 +569,10 @@ static void *find_free_area( void *base, void *end, size_t size, size_t mask, in
{
struct file_view *view = WINE_RB_ENTRY_VALUE( first, struct file_view, entry );
- if ((char *)view->base + view->size <= (char *)start) break;
+ if (!map_area && (char *)view->base + view->size <= (char *)start) break;
+ if (map_area && (start = try_map_free_area( (char *)view->base + view->size,
+ (char *)start + size, step,
+ start, size, unix_prot ))) break;
start = ROUND_ADDR( (char *)view->base - size, mask );
/* stop if remaining space is not large enough */
if (!start || start >= end || start < base) return NULL;
@@ -554,13 +588,17 @@ static void *find_free_area( void *base, void *end, size_t size, size_t mask, in
{
struct file_view *view = WINE_RB_ENTRY_VALUE( first, struct file_view, entry );
- if ((char *)view->base >= (char *)start + size) break;
+ if (!map_area && (char *)view->base >= (char *)start + size) break;
+ if (map_area && (start = try_map_free_area( start, view->base, step,
+ start, size, unix_prot ))) break;
start = ROUND_ADDR( (char *)view->base + view->size + mask, mask );
/* stop if remaining space is not large enough */
if (!start || start >= end || (char *)end - (char *)start < size) return NULL;
first = wine_rb_next( first );
}
}
+
+ if (!first && map_area) return try_map_free_area( base, end, step, start, size, unix_prot );
return start;
}
@@ -1054,13 +1092,13 @@ static int alloc_reserved_area_callback( void *start, size_t size, void *arg )
{
/* range is split in two by the preloader reservation, try first part */
if ((alloc->result = find_free_area( start, preload_reserve_start, alloc->size,
- alloc->mask, alloc->top_down )))
+ alloc->mask, alloc->top_down, FALSE, 0 )))
return 1;
/* then fall through to try second part */
start = preload_reserve_end;
}
}
- if ((alloc->result = find_free_area( start, end, alloc->size, alloc->mask, alloc->top_down )))
+ if ((alloc->result = find_free_area( start, end, alloc->size, alloc->mask, alloc->top_down, FALSE, 0 )))
return 1;
return 0;
@@ -1163,14 +1201,18 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
goto done;
}
- for (;;)
+ if (zero_bits_64)
{
- if (!zero_bits_64)
- ptr = NULL;
- else if (!(ptr = find_free_area( (void*)0, alloc.limit, view_size, mask, top_down )))
+ if (!(ptr = find_free_area( address_space_start, alloc.limit, size,
+ mask, top_down, TRUE, VIRTUAL_GetUnixProt(vprot) )))
return STATUS_NO_MEMORY;
+ TRACE( "got mem with find_free_area %p-%p\n", ptr, (char *)ptr + size );
+ goto done;
+ }
- if ((ptr = wine_anon_mmap( ptr, view_size, VIRTUAL_GetUnixProt(vprot), ptr ? MAP_FIXED : 0 )) == (void *)-1)
+ for (;;)
+ {
+ if ((ptr = wine_anon_mmap( NULL, view_size, VIRTUAL_GetUnixProt(vprot), 0 )) == (void *)-1)
{
if (errno == ENOMEM) return STATUS_NO_MEMORY;
return STATUS_INVALID_PARAMETER;
--
2.24.0.rc2
2
2
[PATCH] wineboot: Automatically create ProfileList key for current user.
by Dmitry Timoshkov 20 Nov '19
by Dmitry Timoshkov 20 Nov '19
20 Nov '19
This patch aims to replace the appropriate patchset from wine-staging.
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
programs/wineboot/wineboot.c | 54 ++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c
index cd5c9505b3..4615f62a74 100644
--- a/programs/wineboot/wineboot.c
+++ b/programs/wineboot/wineboot.c
@@ -1174,6 +1174,59 @@ static void install_root_pnp_devices(void)
SetupDiDestroyDeviceInfoList(set);
}
+static void update_user_profile(void)
+{
+ static const WCHAR pfx[] = {'S',0};
+ static const WCHAR fmt[] = {'-','%','u',0};
+ static const WCHAR profile_list[] = {'S','o','f','t','w','a','r','e','\\',
+ 'M','i','c','r','o','s','o','f','t','\\',
+ 'W','i','n','d','o','w','s',' ','N','T','\\',
+ 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
+ 'P','r','o','f','i','l','e','L','i','s','t',0};
+ static const WCHAR profile_image_path[] = {'P','r','o','f','i','l','e','I','m','a','g','e','P','a','t','h',0};
+ char token_buf[sizeof(TOKEN_USER) + sizeof(SID) + sizeof(DWORD) * SID_MAX_SUB_AUTHORITIES];
+ HANDLE token;
+ PISID sid;
+ WCHAR sid_buf[1 + 10 + 10 + 10 * SID_MAX_SUB_AUTHORITIES], profile[MAX_PATH], *p;
+ DWORD size, i;
+ HKEY hkey, profile_hkey;
+
+ if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token))
+ return;
+
+ size = sizeof(token_buf);
+ GetTokenInformation(token, TokenUser, token_buf, size, &size);
+ CloseHandle(token);
+
+ sid = ((TOKEN_USER *)token_buf)->User.Sid;
+
+ p = sid_buf;
+ lstrcpyW(p, pfx);
+ p += lstrlenW(pfx);
+ p += wsprintfW(p, fmt, sid->Revision);
+ p += wsprintfW(p, fmt, MAKELONG(MAKEWORD(sid->IdentifierAuthority.Value[5],
+ sid->IdentifierAuthority.Value[4]),
+ MAKEWORD(sid->IdentifierAuthority.Value[3],
+ sid->IdentifierAuthority.Value[2])));
+ for (i = 0; i < sid->SubAuthorityCount; i++)
+ p += wsprintfW(p, fmt, sid->SubAuthority[i]);
+
+ if (!RegCreateKeyExW(HKEY_LOCAL_MACHINE, profile_list, 0, NULL, 0,
+ KEY_ALL_ACCESS, NULL, &hkey, NULL))
+ {
+ if (!RegCreateKeyExW(hkey, sid_buf, 0, NULL, 0,
+ KEY_ALL_ACCESS, NULL, &profile_hkey, NULL))
+ {
+ if (SHGetSpecialFolderPathW(NULL, profile, CSIDL_PROFILE, TRUE))
+ set_reg_value(profile_hkey, profile_image_path, profile);
+
+ RegCloseKey(profile_hkey);
+ }
+
+ RegCloseKey(hkey);
+ }
+}
+
/* execute rundll32 on the wine.inf file if necessary */
static void update_wineprefix( BOOL force )
{
@@ -1218,6 +1271,7 @@ static void update_wineprefix( BOOL force )
DestroyWindow( hwnd );
}
install_root_pnp_devices();
+ update_user_profile();
WINE_MESSAGE( "wine: configuration in '%s' has been updated.\n", prettyprint_configdir() );
}
--
2.20.1
2
2
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48104
Signed-off-by: Paul Gofman <gofmanp(a)gmail.com>
---
v2:
- rename helper function;
- reorder max_z estimation.
dlls/ddraw/tests/ddraw7.c | 191 +++++++++++++++++++++++----------
dlls/wined3d/device.c | 7 +-
dlls/wined3d/state.c | 15 ++-
dlls/wined3d/wined3d_private.h | 8 ++
4 files changed, 159 insertions(+), 62 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 143f6d4b6b..20b0e09a95 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -277,7 +277,8 @@ static D3DCOLOR get_surface_color(IDirectDrawSurface7 *surface, UINT x, UINT y)
return color;
}
-static void check_rect(IDirectDrawSurface7 *surface, RECT r, const char *message)
+#define check_rect(a, b, c) check_rect_(__LINE__, a, b, c)
+static void check_rect_(unsigned int line, IDirectDrawSurface7 *surface, RECT r, const char *message)
{
LONG x_coords[2][2] =
{
@@ -308,7 +309,7 @@ static void check_rect(IDirectDrawSurface7 *surface, RECT r, const char *message
if (x < 0 || x >= 640 || y < 0 || y >= 480)
continue;
color = get_surface_color(surface, x, y);
- ok(color == expected, "%s: Pixel (%d, %d) has color %08x, expected %08x.\n",
+ ok_(__FILE__, line)(color == expected, "%s: Pixel (%d, %d) has color %08x, expected %08x.\n",
message, x, y, color, expected);
}
}
@@ -543,17 +544,17 @@ static void test_process_vertices(void)
}
hr = IDirect3DDevice7_GetDirect3D(device, &d3d7);
- ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&vb_desc, 0, sizeof(vb_desc));
vb_desc.dwSize = sizeof(vb_desc);
vb_desc.dwFVF = D3DFVF_XYZ;
vb_desc.dwNumVertices = 4;
hr = IDirect3D7_CreateVertexBuffer(d3d7, &vb_desc, &src_vb, 0);
- ok(SUCCEEDED(hr), "Failed to create source vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DVertexBuffer7_Lock(src_vb, 0, (void **)&src_data, NULL);
- ok(SUCCEEDED(hr), "Failed to lock source vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
src_data[0].x = 0.0f;
src_data[0].y = 0.0f;
src_data[0].z = 0.0f;
@@ -567,7 +568,7 @@ static void test_process_vertices(void)
src_data[3].y = -0.5f;
src_data[3].z = 0.25f;
hr = IDirect3DVertexBuffer7_Unlock(src_vb);
- ok(SUCCEEDED(hr), "Failed to unlock source vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&vb_desc, 0, sizeof(vb_desc));
vb_desc.dwSize = sizeof(vb_desc);
@@ -575,7 +576,7 @@ static void test_process_vertices(void)
vb_desc.dwNumVertices = 4;
/* MSDN says that the last parameter must be 0 - check that. */
hr = IDirect3D7_CreateVertexBuffer(d3d7, &vb_desc, &dst_vb1, 4);
- ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&vb_desc, 0, sizeof(vb_desc));
vb_desc.dwSize = sizeof(vb_desc);
@@ -583,7 +584,7 @@ static void test_process_vertices(void)
vb_desc.dwNumVertices = 5;
/* MSDN says that the last parameter must be 0 - check that. */
hr = IDirect3D7_CreateVertexBuffer(d3d7, &vb_desc, &dst_vb2, 12345678);
- ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&vp, 0, sizeof(vp));
vp.dwX = 64;
@@ -593,15 +594,15 @@ static void test_process_vertices(void)
vp.dvMinZ = 0.0f;
vp.dvMaxZ = 1.0f;
hr = IDirect3DDevice7_SetViewport(device, &vp);
- ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb1, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
- ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb2, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
- ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DVertexBuffer7_Lock(dst_vb1, 0, (void **)&dst_data, NULL);
- ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ok(compare_vec4(&dst_data[0], +1.280e+2f, +1.280e+2f, +0.000e+0f, +1.000e+0f, 4096),
"Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -615,10 +616,10 @@ static void test_process_vertices(void)
"Got unexpected vertex 3 {%.8e, %.8e, %.8e, %.8e}.\n",
dst_data[3].x, dst_data[3].y, dst_data[3].z, dst_data[3].w);
hr = IDirect3DVertexBuffer7_Unlock(dst_vb1);
- ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DVertexBuffer7_Lock(dst_vb2, 0, (void **)&dst_data2, NULL);
- ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
/* Small thing without much practical meaning, but I stumbled upon it,
* so let's check for it: If the output vertex buffer has no RHW value,
* the RHW value of the last vertex is written into the next vertex. */
@@ -626,7 +627,62 @@ static void test_process_vertices(void)
"Got unexpected vertex 4 {%.8e, %.8e, %.8e}.\n",
dst_data2[4].x, dst_data2[4].y, dst_data2[4].z);
hr = IDirect3DVertexBuffer7_Unlock(dst_vb2);
- ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+
+ /* Test degenerate viewport z ranges. */
+ vp.dvMinZ = 0.0f;
+ vp.dvMaxZ = 0.0f;
+ hr = IDirect3DDevice7_SetViewport(device, &vp);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb1, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb2, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DVertexBuffer7_Lock(dst_vb1, 0, (void **)&dst_data, NULL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ ok(compare_vec4(&dst_data[0], +1.280e+2f, +1.280e+2f, +0.000e+0f, +1.000e+0f, 4096),
+ "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
+ dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
+ ok(compare_vec4(&dst_data[1], +1.920e+2f, +6.400e+1f, +1.000e-3f, +1.000e+0f, 4096),
+ "Got unexpected vertex 1 {%.8e, %.8e, %.8e, %.8e}.\n",
+ dst_data[1].x, dst_data[1].y, dst_data[1].z, dst_data[1].w);
+ ok(compare_vec4(&dst_data[2], +6.400e+1f, +1.920e+2f, +5.000e-4f, +1.000e+0f, 4096),
+ "Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
+ dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
+ ok(compare_vec4(&dst_data[3], +1.600e+2f, +1.600e+2f, +2.500e-4f, +1.000e+0f, 4096),
+ "Got unexpected vertex 3 {%.8e, %.8e, %.8e, %.8e}.\n",
+ dst_data[3].x, dst_data[3].y, dst_data[3].z, dst_data[3].w);
+ hr = IDirect3DVertexBuffer7_Unlock(dst_vb1);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+
+ vp.dvMinZ = 1.0f;
+ vp.dvMaxZ = 0.0f;
+ hr = IDirect3DDevice7_SetViewport(device, &vp);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb1, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb2, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DVertexBuffer7_Lock(dst_vb1, 0, (void **)&dst_data, NULL);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ ok(compare_vec4(&dst_data[0], +1.280e+2f, +1.280e+2f, +1.000e+0f, +1.000e+0f, 4096),
+ "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
+ dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
+ ok(compare_vec4(&dst_data[1], +1.920e+2f, +6.400e+1f, +1.001e+0f, +1.000e+0f, 4096),
+ "Got unexpected vertex 1 {%.8e, %.8e, %.8e, %.8e}.\n",
+ dst_data[1].x, dst_data[1].y, dst_data[1].z, dst_data[1].w);
+ ok(compare_vec4(&dst_data[2], +6.400e+1f, +1.920e+2f, +1.0005e+0f, +1.000e+0f, 4096),
+ "Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
+ dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
+ ok(compare_vec4(&dst_data[3], +1.600e+2f, +1.600e+2f, +1.00025e+0f, +1.000e+0f, 4096),
+ "Got unexpected vertex 3 {%.8e, %.8e, %.8e, %.8e}.\n",
+ dst_data[3].x, dst_data[3].y, dst_data[3].z, dst_data[3].w);
+ hr = IDirect3DVertexBuffer7_Unlock(dst_vb1);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
/* Try a more complicated viewport, same vertices. */
memset(&vp, 0, sizeof(vp));
@@ -637,13 +693,13 @@ static void test_process_vertices(void)
vp.dvMinZ = -2.0f;
vp.dvMaxZ = 4.0f;
hr = IDirect3DDevice7_SetViewport(device, &vp);
- ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb1, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
- ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DVertexBuffer7_Lock(dst_vb1, 0, (void **)&dst_data, NULL);
- ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ok(compare_vec4(&dst_data[0], +1.330e+2f, +7.000e+1f, -2.000e+0f, +1.000e+0f, 4096),
"Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -657,20 +713,20 @@ static void test_process_vertices(void)
"Got unexpected vertex 3 {%.8e, %.8e, %.8e, %.8e}.\n",
dst_data[3].x, dst_data[3].y, dst_data[3].z, dst_data[3].w);
hr = IDirect3DVertexBuffer7_Unlock(dst_vb1);
- ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &world);
- ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &view);
- ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &proj);
- ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb1, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
- ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DVertexBuffer7_Lock(dst_vb1, 0, (void **)&dst_data, NULL);
- ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ok(compare_vec4(&dst_data[0], +2.560e+2f, +7.000e+1f, -2.000e+0f, +3.333e-1f, 4096),
"Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -684,7 +740,7 @@ static void test_process_vertices(void)
"Got unexpected vertex 3 {%.8e, %.8e, %.8e, %.8e}.\n",
dst_data[3].x, dst_data[3].y, dst_data[3].z, dst_data[3].w);
hr = IDirect3DVertexBuffer7_Unlock(dst_vb1);
- ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
IDirect3DVertexBuffer7_Release(dst_vb2);
IDirect3DVertexBuffer7_Release(dst_vb1);
@@ -14877,24 +14933,27 @@ static void test_viewport(void)
static struct
{
D3DVIEWPORT7 vp;
+ float expected_z;
RECT expected_rect;
const char *message;
}
tests[] =
{
- {{ 0, 0, 640, 480}, { 0, 120, 479, 359}, "Viewport (0, 0) - (640, 480)"},
- {{ 0, 0, 320, 240}, { 0, 60, 239, 179}, "Viewport (0, 0) - (320, 240)"},
- {{ 0, 0, 1280, 960}, { 0, 240, 639, 479}, "Viewport (0, 0) - (1280, 960)"},
- {{ 0, 0, 2000, 1600}, {-10, -10, -10, -10}, "Viewport (0, 0) - (2000, 1600)"},
- {{100, 100, 640, 480}, {100, 220, 579, 459}, "Viewport (100, 100) - (640, 480)"},
- {{ 0, 0, 8192, 8192}, {-10, -10, -10, -10}, "Viewport (0, 0) - (8192, 8192)"},
+ {{ 0, 0, 640, 480}, 0.001f, { 0, 120, 479, 359}, "Viewport (0, 0) - (640, 480)"},
+ {{ 0, 0, 640, 480, 0.5f, 0.0f}, 0.501f,
+ {0, 120, 479, 359}, "Viewport (0, 0, 0.5) - (640, 480, 0.0)"},
+ {{ 0, 0, 320, 240}, 0.001f, { 0, 60, 239, 179}, "Viewport (0, 0) - (320, 240)"},
+ {{ 0, 0, 1280, 960}, 0.001f, { 0, 240, 639, 479}, "Viewport (0, 0) - (1280, 960)"},
+ {{ 0, 0, 2000, 1600}, 0.001f, {-10, -10, -10, -10}, "Viewport (0, 0) - (2000, 1600)"},
+ {{100, 100, 640, 480}, 0.001f, {100, 220, 579, 459}, "Viewport (100, 100) - (640, 480)"},
+ {{ 0, 0, 8192, 8192}, 0.001f, {-10, -10, -10, -10}, "Viewport (0, 0) - (8192, 8192)"},
};
static struct vec3 quad[] =
{
- {-1.5f, -0.5f, 0.1f},
- {-1.5f, 0.5f, 0.1f},
- { 0.5f, -0.5f, 0.1f},
- { 0.5f, 0.5f, 0.1f},
+ {-1.5f, -0.5f, 1.0f},
+ {-1.5f, 0.5f, 1.0f},
+ { 0.5f, -0.5f, 1.0f},
+ { 0.5f, 0.5f, 1.0f},
};
static const struct vec2 rt_sizes[] =
{
@@ -14902,6 +14961,7 @@ static void test_viewport(void)
};
IDirectDrawSurface7 *rt, *ds;
DDSURFACEDESC2 surface_desc;
+ const float z_eps = 0.0001;
IDirect3DDevice7 *device;
IDirectDraw7 *ddraw;
DDPIXELFORMAT z_fmt;
@@ -14921,18 +14981,16 @@ static void test_viewport(void)
}
hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
- ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
- ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
IDirect3D7_Release(d3d);
- hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
- ok(SUCCEEDED(hr), "Failed to disable depth test, hr %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
- ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetViewport(device, NULL);
- ok(hr == E_INVALIDARG, "Setting NULL viewport data returned unexpected hr %#x.\n", hr);
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
ds = get_depth_stencil(device);
memset(&surface_desc, 0, sizeof(surface_desc));
@@ -14951,56 +15009,79 @@ static void test_viewport(void)
surface_desc.dwHeight = rt_sizes[i].y;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &rt, NULL);
- ok(SUCCEEDED(hr), "Failed to create render target, hr %#x (i %u).\n", hr, i);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
U4(surface_desc).ddpfPixelFormat = z_fmt;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &ds, NULL);
- ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x (i %u).\n", hr, i);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
hr = IDirectDrawSurface7_AddAttachedSurface(rt, ds);
- ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x (i %u).\n", hr, i);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
hr = IDirect3DDevice7_SetRenderTarget(device, rt, 0);
- ok(SUCCEEDED(hr), "Failed to set render target, hr %#x (i %u).\n", hr, i);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
}
else
{
hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
- ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
}
for (j = 0; j < ARRAY_SIZE(tests); ++j)
{
- hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0);
- ok(SUCCEEDED(hr), "Failed to clear, hr %#x (i %u, j %u).\n", hr, i, j);
+ hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000,
+ tests[j].expected_z - z_eps, 0);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_GREATER);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, !i);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
hr = IDirect3DDevice7_SetViewport(device, &tests[j].vp);
if (tests[j].vp.dwX + tests[j].vp.dwWidth > rt_sizes[i].x
|| tests[j].vp.dwY + tests[j].vp.dwHeight > rt_sizes[i].y)
{
- ok(hr == E_INVALIDARG, "Setting the viewport returned unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
continue;
}
else
{
- ok(SUCCEEDED(hr), "Failed to set the viewport, hr %#x (i %u, j %u).\n", hr, i, j);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
}
hr = IDirect3DDevice7_BeginScene(device);
- ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x (i %u, j %u).\n", hr, i, j);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
- ok(SUCCEEDED(hr), "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
hr = IDirect3DDevice7_EndScene(device);
- ok(SUCCEEDED(hr), "Failed to end scene, hr %#x (i %u, j %u).\n", hr, i, j);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
check_rect(rt, tests[j].expected_rect, tests[j].message);
+
+ if (!i)
+ {
+ hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000,
+ tests[j].expected_z + z_eps, 0);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_LESS);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+
+ hr = IDirect3DDevice7_BeginScene(device);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+ hr = IDirect3DDevice7_EndScene(device);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+
+ check_rect(rt, tests[j].expected_rect, tests[j].message);
+ }
}
hr = IDirectDrawSurface7_DeleteAttachedSurface(rt, 0, ds);
- ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x (i %u).\n", hr, i);
+ ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
IDirectDrawSurface7_Release(ds);
-
IDirectDrawSurface7_Release(rt);
}
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 3049be69ef..d017a54245 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3573,6 +3573,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
struct lights_settings ls;
unsigned int vertex_size;
BOOL do_clip, lighting;
+ float min_z, max_z;
unsigned int i;
BYTE *dest_ptr;
HRESULT hr;
@@ -3656,6 +3657,8 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
init_transformed_lights(&ls, state, device->adapter->d3d_info.wined3d_creation_flags
& WINED3D_LEGACY_FFP_LIGHTING, lighting);
+ wined3d_viewport_get_z_range(&vp, &min_z, &max_z);
+
for (i = 0; i < dwCount; ++i)
{
const struct wined3d_stream_info_element *position_element = &stream_info->elements[WINED3D_FFP_POSITION];
@@ -3728,11 +3731,11 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
x *= vp.width / 2;
y *= vp.height / 2;
- z *= vp.max_z - vp.min_z;
+ z *= max_z - min_z;
x += vp.width / 2 + vp.x;
y += vp.height / 2 + vp.y;
- z += vp.min_z;
+ z += min_z;
rhw = 1 / rhw;
} else {
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 0f84cc22f7..87e1ca4bac 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4037,6 +4037,7 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
{
const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info;
struct wined3d_viewport vp[WINED3D_MAX_VIEWPORTS];
+ float min_z, max_z;
if (gl_info->supported[ARB_VIEWPORT_ARRAY])
{
@@ -4048,8 +4049,9 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
get_viewports(context, state, state->viewport_count, vp);
for (i = 0; i < state->viewport_count; ++i)
{
- depth_ranges[i * 2] = vp[i].min_z;
- depth_ranges[i * 2 + 1] = vp[i].max_z;
+ wined3d_viewport_get_z_range(&vp[i], &min_z, &max_z);
+ depth_ranges[i * 2] = min_z;
+ depth_ranges[i * 2 + 1] = max_z;
viewports[i * 4] = vp[i].x;
viewports[i * 4 + 1] = vp[i].y;
@@ -4073,7 +4075,8 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
else
{
get_viewports(context, state, 1, vp);
- gl_info->gl_ops.gl.p_glDepthRange(vp[0].min_z, vp[0].max_z);
+ wined3d_viewport_get_z_range(&vp[0], &min_z, &max_z);
+ gl_info->gl_ops.gl.p_glDepthRange(min_z, max_z);
gl_info->gl_ops.gl.p_glViewport(vp[0].x, vp[0].y, vp[0].width, vp[0].height);
}
checkGLcall("setting clip space and viewport");
@@ -4090,6 +4093,7 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
GLdouble depth_ranges[2 * WINED3D_MAX_VIEWPORTS];
GLfloat viewports[4 * WINED3D_MAX_VIEWPORTS];
unsigned int i, reset_count = 0;
+ float min_z, max_z;
get_viewports(context, state, state->viewport_count, vp);
@@ -4097,8 +4101,9 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
for (i = 0; i < state->viewport_count; ++i)
{
- depth_ranges[i * 2] = vp[i].min_z;
- depth_ranges[i * 2 + 1] = vp[i].max_z;
+ wined3d_viewport_get_z_range(&vp[i], &min_z, &max_z);
+ depth_ranges[i * 2] = min_z;
+ depth_ranges[i * 2 + 1] = max_z;
viewports[i * 4] = vp[i].x + pixel_center_offset;
viewports[i * 4 + 1] = vp[i].y + pixel_center_offset;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 8ca2e73703..4fca229b92 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -5345,6 +5345,14 @@ static inline BOOL wined3d_resource_check_fbo_attached(const struct wined3d_stat
return FALSE;
}
+static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport *vp, float *min_z, float *max_z)
+{
+ *min_z = vp->min_z;
+
+ /* The magic constant is derived from tests. */
+ *max_z = max(vp->max_z, vp->min_z + 0.001f);
+}
+
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
#define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
--
2.23.0
3
4