wininet: Added INTERNET_OPTION_ERROR_MASK flag handling to InternetSetOptionW.
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index eb3c8e2..9e32046 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -2484,8 +2484,19 @@
break;
case INTERNET_OPTION_ERROR_MASK:
{
- ULONG flags = *(ULONG *)lpBuffer;
- FIXME("Option INTERNET_OPTION_ERROR_MASK(%d): STUB\n", flags);
+ if(!lpwhh) {
+ SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
+ return FALSE;
+ } else if(*(ULONG*)lpBuffer & (~(INTERNET_ERROR_MASK_INSERT_CDROM|
+ INTERNET_ERROR_MASK_COMBINED_SEC_CERT|
+ INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY))) {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ ret = FALSE;
+ } else if(dwBufferLength != sizeof(ULONG)) {
+ SetLastError(ERROR_INTERNET_BAD_OPTION_LENGTH);
+ ret = FALSE;
+ } else
+ lpwhh->ErrorMask = *(ULONG*)lpBuffer;
}
break;
case INTERNET_OPTION_CODEPAGE:
diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h
index 6fdb5dc..64bfdaa 100644
--- a/dlls/wininet/internet.h
+++ b/dlls/wininet/internet.h
@@ -156,6 +156,7 @@
DWORD dwFlags;
DWORD_PTR dwContext;
DWORD dwError;
+ ULONG ErrorMask;
DWORD dwInternalFlags;
LONG refs;
INTERNET_STATUS_CALLBACK lpfnStatusCB;
diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c
index fa28b0c..4da9c21 100644
--- a/dlls/wininet/tests/internet.c
+++ b/dlls/wininet/tests/internet.c
@@ -835,27 +835,75 @@
ok(ret == 0, "expected ret == 0, got %u\n", ret);
}
-static void test_Option_Policy(void)
+static void test_InternetSetOption(void)
{
- HINTERNET hinet;
+ HINTERNET ses, con, req;
+ ULONG ulArg;
+ DWORD size;
BOOL ret;
- hinet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- ok(hinet != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
+ ses = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
+ con = InternetConnect(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
+ req = HttpOpenRequest(con, "GET", "/", NULL, NULL, NULL, 0, 0);
+ ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
+ /* INTERNET_OPTION_POLICY tests */
SetLastError(0xdeadbeef);
- ret = InternetSetOptionW(hinet, INTERNET_OPTION_POLICY, NULL, 0);
+ ret = InternetSetOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
ok(ret == FALSE, "InternetSetOption should've failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
"given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = InternetQueryOptionW(hinet, INTERNET_OPTION_POLICY, NULL, 0);
+ ret = InternetQueryOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
ok(ret == FALSE, "InternetQueryOption should've failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
"given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
- ret = InternetCloseHandle(hinet);
+ /* INTERNET_OPTION_ERROR_MASK tests */
+ SetLastError(0xdeadbeef);
+ size = sizeof(ulArg);
+ ret = InternetQueryOptionW(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, &size);
+ ok(ret == FALSE, "InternetQueryOption should've failed\n");
+ ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ulArg = 11;
+ ret = InternetSetOption(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
+ ok(ret == FALSE, "InternetQueryOption should've failed\n");
+ ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ulArg = 11;
+ ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, 20);
+ ok(ret == FALSE, "InternetQueryOption should've failed\n");
+ ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ulArg = 11;
+ ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
+ ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
+ ok(GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ulArg = 4;
+ ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
+ ok(ret == FALSE, "InternetQueryOption should've failed\n");
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ulArg = 16;
+ ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
+ ok(ret == FALSE, "InternetQueryOption should've failed\n");
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
+
+ ret = InternetCloseHandle(req);
+ ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
+ ret = InternetCloseHandle(con);
+ ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
+ ret = InternetCloseHandle(ses);
ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
}
@@ -1097,7 +1145,6 @@
test_complicated_cookie();
test_version();
test_null();
- test_Option_Policy();
test_Option_PerConnectionOption();
test_Option_PerConnectionOptionA();
@@ -1123,4 +1170,6 @@
test_PrivacyGetSetZonePreferenceW();
else
win_skip("Privacy[SG]etZonePreferenceW are not available\n");
+
+ test_InternetSetOption();
}
diff --git a/include/wininet.h b/include/wininet.h
index 1cb0508..a0ec408 100644
--- a/include/wininet.h
+++ b/include/wininet.h
@@ -122,6 +122,9 @@
)
#define INTERNET_ERROR_MASK_INSERT_CDROM 0x1
+#define INTERNET_ERROR_MASK_COMBINED_SEC_CERT 0x2
+#define INTERNET_ERROR_MASK_NEED_MSN_SSPI_PKG 0x4
+#define INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY 0x8
#define INTERNET_OPTIONS_MASK (~INTERNET_FLAGS_MASK)
#define WININET_API_FLAG_ASYNC 0x00000001