Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- 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
February 2018
- 74 participants
- 1541 messages
[PATCH 6/9] secur32: Implement VerifySignature in the SSP/AP wrapper.
by Dmitry Timoshkov
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/secur32/lsa.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/secur32/lsa.c b/dlls/secur32/lsa.c
index 832303f7bb..8752ba1ad8 100644
--- a/dlls/secur32/lsa.c
+++ b/dlls/secur32/lsa.c
@@ -601,6 +601,27 @@ static SECURITY_STATUS WINAPI lsa_MakeSignature(CtxtHandle *context, ULONG quali
return lsa_package->user_api->MakeSignature(lsa_context, quality_of_protection, message, message_seq_no);
}
+static SECURITY_STATUS WINAPI lsa_VerifySignature(CtxtHandle *context, SecBufferDesc *message,
+ ULONG message_seq_no, ULONG *quality_of_protection)
+{
+ struct lsa_package *lsa_package;
+ LSA_SEC_HANDLE lsa_context;
+
+ TRACE("%p %p %u %p)\n", context, message, message_seq_no, quality_of_protection);
+
+ if (!context) return SEC_E_INVALID_HANDLE;
+
+ lsa_package = (struct lsa_package *)context->dwUpper;
+ lsa_context = (LSA_SEC_HANDLE)context->dwLower;
+
+ if (!lsa_package) return SEC_E_INVALID_HANDLE;
+
+ if (!lsa_package->user_api || !lsa_package->user_api->VerifySignature)
+ return SEC_E_UNSUPPORTED_FUNCTION;
+
+ return lsa_package->user_api->VerifySignature(lsa_context, message, message_seq_no, quality_of_protection);
+}
+
static const SecurityFunctionTableW lsa_sspi_tableW =
{
1,
@@ -618,7 +639,7 @@ static const SecurityFunctionTableW lsa_sspi_tableW =
NULL, /* ImpersonateSecurityContext */
NULL, /* RevertSecurityContext */
lsa_MakeSignature,
- NULL, /* VerifySignature */
+ lsa_VerifySignature,
NULL, /* FreeContextBuffer */
NULL, /* QuerySecurityPackageInfoW */
NULL, /* Reserved3 */
@@ -650,7 +671,7 @@ static const SecurityFunctionTableA lsa_sspi_tableA =
NULL, /* ImpersonateSecurityContext */
NULL, /* RevertSecurityContext */
lsa_MakeSignature,
- NULL, /* VerifySignature */
+ lsa_VerifySignature,
NULL, /* FreeContextBuffer */
NULL, /* QuerySecurityPackageInfoA */
NULL, /* Reserved3 */
--
2.15.1
Feb. 1, 2018
[PATCH 5/9] secur32: Implement MakeSignature in the SSP/AP wrapper.
by Dmitry Timoshkov
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/secur32/lsa.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/secur32/lsa.c b/dlls/secur32/lsa.c
index 479a2d233d..832303f7bb 100644
--- a/dlls/secur32/lsa.c
+++ b/dlls/secur32/lsa.c
@@ -580,6 +580,27 @@ static SECURITY_STATUS WINAPI lsa_QueryContextAttributesA(CtxtHandle *context, U
return SEC_E_UNSUPPORTED_FUNCTION;
}
+static SECURITY_STATUS WINAPI lsa_MakeSignature(CtxtHandle *context, ULONG quality_of_protection,
+ SecBufferDesc *message, ULONG message_seq_no)
+{
+ struct lsa_package *lsa_package;
+ LSA_SEC_HANDLE lsa_context;
+
+ TRACE("%p %#x %p %u)\n", context, quality_of_protection, message, message_seq_no);
+
+ if (!context) return SEC_E_INVALID_HANDLE;
+
+ lsa_package = (struct lsa_package *)context->dwUpper;
+ lsa_context = (LSA_SEC_HANDLE)context->dwLower;
+
+ if (!lsa_package) return SEC_E_INVALID_HANDLE;
+
+ if (!lsa_package->user_api || !lsa_package->user_api->MakeSignature)
+ return SEC_E_UNSUPPORTED_FUNCTION;
+
+ return lsa_package->user_api->MakeSignature(lsa_context, quality_of_protection, message, message_seq_no);
+}
+
static const SecurityFunctionTableW lsa_sspi_tableW =
{
1,
@@ -596,7 +617,7 @@ static const SecurityFunctionTableW lsa_sspi_tableW =
lsa_QueryContextAttributesW,
NULL, /* ImpersonateSecurityContext */
NULL, /* RevertSecurityContext */
- NULL, /* MakeSignature */
+ lsa_MakeSignature,
NULL, /* VerifySignature */
NULL, /* FreeContextBuffer */
NULL, /* QuerySecurityPackageInfoW */
@@ -628,7 +649,7 @@ static const SecurityFunctionTableA lsa_sspi_tableA =
lsa_QueryContextAttributesA,
NULL, /* ImpersonateSecurityContext */
NULL, /* RevertSecurityContext */
- NULL, /* MakeSignature */
+ lsa_MakeSignature,
NULL, /* VerifySignature */
NULL, /* FreeContextBuffer */
NULL, /* QuerySecurityPackageInfoA */
--
2.15.1
Feb. 1, 2018
[PATCH 4/9] secur32: Implement QueryContextAttributes in the SSP/AP wrapper.
by Dmitry Timoshkov
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/secur32/lsa.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
diff --git a/dlls/secur32/lsa.c b/dlls/secur32/lsa.c
index c4f408fcf4..479a2d233d 100644
--- a/dlls/secur32/lsa.c
+++ b/dlls/secur32/lsa.c
@@ -526,6 +526,60 @@ static SECURITY_STATUS WINAPI lsa_DeleteSecurityContext(CtxtHandle *context)
return lsa_package->lsa_api->DeleteContext(lsa_context);
}
+static SECURITY_STATUS WINAPI lsa_QueryContextAttributesW(CtxtHandle *context, ULONG attribute, void *buffer)
+{
+ struct lsa_package *lsa_package;
+ LSA_SEC_HANDLE lsa_context;
+
+ TRACE("%p %d %p\n", context, attribute, buffer);
+
+ if (!context) return SEC_E_INVALID_HANDLE;
+
+ lsa_package = (struct lsa_package *)context->dwUpper;
+ lsa_context = (LSA_SEC_HANDLE)context->dwLower;
+
+ if (!lsa_package) return SEC_E_INVALID_HANDLE;
+
+ if (!lsa_package->lsa_api || !lsa_package->lsa_api->SpQueryContextAttributes)
+ return SEC_E_UNSUPPORTED_FUNCTION;
+
+ return lsa_package->lsa_api->SpQueryContextAttributes(lsa_context, attribute, buffer);
+}
+
+static SECURITY_STATUS WINAPI lsa_QueryContextAttributesA(CtxtHandle *context, ULONG attribute, void *buffer)
+{
+ TRACE("%p %d %p\n", context, attribute, buffer);
+
+ if (!context) return SEC_E_INVALID_HANDLE;
+
+ switch (attribute)
+ {
+ case SECPKG_ATTR_SIZES:
+ return lsa_QueryContextAttributesW( context, attribute, buffer );
+
+#define X(x) case (x) : FIXME(#x" stub\n"); break
+ X(SECPKG_ATTR_ACCESS_TOKEN);
+ X(SECPKG_ATTR_AUTHORITY);
+ X(SECPKG_ATTR_DCE_INFO);
+ X(SECPKG_ATTR_KEY_INFO);
+ X(SECPKG_ATTR_LIFESPAN);
+ X(SECPKG_ATTR_NAMES);
+ X(SECPKG_ATTR_NATIVE_NAMES);
+ X(SECPKG_ATTR_PACKAGE_INFO);
+ X(SECPKG_ATTR_PASSWORD_EXPIRY);
+ X(SECPKG_ATTR_SESSION_KEY);
+ X(SECPKG_ATTR_STREAM_SIZES);
+ X(SECPKG_ATTR_TARGET_INFORMATION);
+ X(SECPKG_ATTR_NEGOTIATION_INFO);
+#undef X
+ default:
+ FIXME( "unknown attribute %u\n", attribute );
+ break;
+ }
+
+ return SEC_E_UNSUPPORTED_FUNCTION;
+}
+
static const SecurityFunctionTableW lsa_sspi_tableW =
{
1,
@@ -539,7 +593,7 @@ static const SecurityFunctionTableW lsa_sspi_tableW =
NULL, /* CompleteAuthToken */
lsa_DeleteSecurityContext,
NULL, /* ApplyControlToken */
- NULL, /* QueryContextAttributesW */
+ lsa_QueryContextAttributesW,
NULL, /* ImpersonateSecurityContext */
NULL, /* RevertSecurityContext */
NULL, /* MakeSignature */
@@ -571,7 +625,7 @@ static const SecurityFunctionTableA lsa_sspi_tableA =
NULL, /* CompleteAuthToken */
lsa_DeleteSecurityContext,
NULL, /* ApplyControlToken */
- NULL, /* QueryContextAttributesA */
+ lsa_QueryContextAttributesA,
NULL, /* ImpersonateSecurityContext */
NULL, /* RevertSecurityContext */
NULL, /* MakeSignature */
--
2.15.1
Feb. 1, 2018
[PATCH 3/9] secur32: Implement AcceptSecurityContext in the SSP/AP wrapper. (v4)
by Dmitry Timoshkov
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/secur32/lsa.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 42 insertions(+), 2 deletions(-)
diff --git a/dlls/secur32/lsa.c b/dlls/secur32/lsa.c
index 43b69a5ad3..c4f408fcf4 100644
--- a/dlls/secur32/lsa.c
+++ b/dlls/secur32/lsa.c
@@ -466,6 +466,46 @@ static SECURITY_STATUS WINAPI lsa_InitializeSecurityContextA(
return status;
}
+static SECURITY_STATUS WINAPI lsa_AcceptSecurityContext(
+ CredHandle *credential, CtxtHandle *context, SecBufferDesc *input,
+ ULONG context_req, ULONG target_data_rep, CtxtHandle *new_context,
+ SecBufferDesc *output, ULONG *context_attr, TimeStamp *ts_expiry)
+{
+ SECURITY_STATUS status;
+ struct lsa_package *lsa_package = NULL;
+ LSA_SEC_HANDLE lsa_credential = 0, lsa_context = 0, new_lsa_context;
+ BOOLEAN mapped_context;
+
+ TRACE("%p %p %p %#x %#x %p %p %p %p\n", credential, context, input,
+ context_req, target_data_rep, new_context, output, context_attr, ts_expiry);
+
+ if (context)
+ {
+ lsa_package = (struct lsa_package *)context->dwUpper;
+ lsa_context = (LSA_SEC_HANDLE)context->dwLower;
+ }
+ else if (credential)
+ {
+ lsa_package = (struct lsa_package *)credential->dwUpper;
+ lsa_credential = (LSA_SEC_HANDLE)credential->dwLower;
+ }
+
+ if (!lsa_package || !new_context) return SEC_E_INVALID_HANDLE;
+
+ if (!lsa_package->lsa_api || !lsa_package->lsa_api->AcceptLsaModeContext)
+ return SEC_E_UNSUPPORTED_FUNCTION;
+
+ status = lsa_package->lsa_api->AcceptLsaModeContext(lsa_credential, lsa_context,
+ input, context_req, target_data_rep, &new_lsa_context, output, context_attr,
+ ts_expiry, &mapped_context, NULL /* FIXME */);
+ if (status == SEC_E_OK || status == SEC_I_CONTINUE_NEEDED)
+ {
+ new_context->dwLower = (ULONG_PTR)new_lsa_context;
+ new_context->dwUpper = (ULONG_PTR)lsa_package;
+ }
+ return status;
+}
+
static SECURITY_STATUS WINAPI lsa_DeleteSecurityContext(CtxtHandle *context)
{
struct lsa_package *lsa_package;
@@ -495,7 +535,7 @@ static const SecurityFunctionTableW lsa_sspi_tableW =
lsa_FreeCredentialsHandle,
NULL, /* Reserved2 */
lsa_InitializeSecurityContextW,
- NULL, /* AcceptSecurityContext */
+ lsa_AcceptSecurityContext,
NULL, /* CompleteAuthToken */
lsa_DeleteSecurityContext,
NULL, /* ApplyControlToken */
@@ -527,7 +567,7 @@ static const SecurityFunctionTableA lsa_sspi_tableA =
lsa_FreeCredentialsHandle,
NULL, /* Reserved2 */
lsa_InitializeSecurityContextA,
- NULL, /* AcceptSecurityContext */
+ lsa_AcceptSecurityContext,
NULL, /* CompleteAuthToken */
lsa_DeleteSecurityContext,
NULL, /* ApplyControlToken */
--
2.15.1
Feb. 1, 2018
[PATCH 2/9] secur32: Implement DeleteSecurityContext in the SSP/AP wrapper.
by Dmitry Timoshkov
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/secur32/lsa.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/dlls/secur32/lsa.c b/dlls/secur32/lsa.c
index 8da3a61cfd..43b69a5ad3 100644
--- a/dlls/secur32/lsa.c
+++ b/dlls/secur32/lsa.c
@@ -466,6 +466,26 @@ static SECURITY_STATUS WINAPI lsa_InitializeSecurityContextA(
return status;
}
+static SECURITY_STATUS WINAPI lsa_DeleteSecurityContext(CtxtHandle *context)
+{
+ struct lsa_package *lsa_package;
+ LSA_SEC_HANDLE lsa_context;
+
+ TRACE("%p\n", context);
+
+ if (!context) return SEC_E_INVALID_HANDLE;
+
+ lsa_package = (struct lsa_package *)context->dwUpper;
+ lsa_context = (LSA_SEC_HANDLE)context->dwLower;
+
+ if (!lsa_package) return SEC_E_INVALID_HANDLE;
+
+ if (!lsa_package->lsa_api || !lsa_package->lsa_api->DeleteContext)
+ return SEC_E_UNSUPPORTED_FUNCTION;
+
+ return lsa_package->lsa_api->DeleteContext(lsa_context);
+}
+
static const SecurityFunctionTableW lsa_sspi_tableW =
{
1,
@@ -477,7 +497,7 @@ static const SecurityFunctionTableW lsa_sspi_tableW =
lsa_InitializeSecurityContextW,
NULL, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
- NULL, /* DeleteSecurityContext */
+ lsa_DeleteSecurityContext,
NULL, /* ApplyControlToken */
NULL, /* QueryContextAttributesW */
NULL, /* ImpersonateSecurityContext */
@@ -509,7 +529,7 @@ static const SecurityFunctionTableA lsa_sspi_tableA =
lsa_InitializeSecurityContextA,
NULL, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
- NULL, /* DeleteSecurityContext */
+ lsa_DeleteSecurityContext,
NULL, /* ApplyControlToken */
NULL, /* QueryContextAttributesA */
NULL, /* ImpersonateSecurityContext */
--
2.15.1
Feb. 1, 2018
[PATCH 1/9] secur32: Implement InitializeSecurityContext in the SSP/AP wrapper. (v4)
by Dmitry Timoshkov
Partially based on Hans Leidekker's work.
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/secur32/lsa.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 72 insertions(+), 2 deletions(-)
diff --git a/dlls/secur32/lsa.c b/dlls/secur32/lsa.c
index 1916aa4b3a..8da3a61cfd 100644
--- a/dlls/secur32/lsa.c
+++ b/dlls/secur32/lsa.c
@@ -396,6 +396,76 @@ static SECURITY_STATUS WINAPI lsa_FreeCredentialsHandle(CredHandle *credential)
return lsa_package->lsa_api->FreeCredentialsHandle(lsa_credential);
}
+static SECURITY_STATUS WINAPI lsa_InitializeSecurityContextW(
+ CredHandle *credential, CtxtHandle *context, SEC_WCHAR *target_name, ULONG context_req,
+ ULONG reserved1, ULONG target_data_rep, SecBufferDesc *input, ULONG reserved2,
+ CtxtHandle *new_context, SecBufferDesc *output, ULONG *context_attr, TimeStamp *ts_expiry)
+{
+ SECURITY_STATUS status;
+ struct lsa_package *lsa_package = NULL;
+ LSA_SEC_HANDLE lsa_credential = 0, lsa_context = 0, new_lsa_context;
+ UNICODE_STRING target_name_us;
+ BOOLEAN mapped_context;
+
+ TRACE("%p %p %s %#x %d %d %p %d %p %p %p %p\n", credential, context,
+ debugstr_w(target_name), context_req, reserved1, target_data_rep, input,
+ reserved2, new_context, output, context_attr, ts_expiry);
+
+ if (context)
+ {
+ lsa_package = (struct lsa_package *)context->dwUpper;
+ lsa_context = (LSA_SEC_HANDLE)context->dwLower;
+ }
+ else if (credential)
+ {
+ lsa_package = (struct lsa_package *)credential->dwUpper;
+ lsa_credential = (LSA_SEC_HANDLE)credential->dwLower;
+ }
+
+ if (!lsa_package || !new_context) return SEC_E_INVALID_HANDLE;
+
+ if (!lsa_package->lsa_api || !lsa_package->lsa_api->InitLsaModeContext)
+ return SEC_E_UNSUPPORTED_FUNCTION;
+
+ if (target_name)
+ RtlInitUnicodeString(&target_name_us, target_name);
+
+ status = lsa_package->lsa_api->InitLsaModeContext(lsa_credential, lsa_context,
+ target_name ? &target_name_us : NULL, context_req, target_data_rep, input,
+ &new_lsa_context, output, context_attr, ts_expiry, &mapped_context, NULL /* FIXME */);
+ if (status == SEC_E_OK || status == SEC_I_CONTINUE_NEEDED)
+ {
+ new_context->dwLower = (ULONG_PTR)new_lsa_context;
+ new_context->dwUpper = (ULONG_PTR)lsa_package;
+ }
+ return status;
+}
+
+static SECURITY_STATUS WINAPI lsa_InitializeSecurityContextA(
+ CredHandle *credential, CtxtHandle *context, SEC_CHAR *target_name, ULONG context_req,
+ ULONG reserved1, ULONG target_data_rep, SecBufferDesc *input, ULONG reserved2,
+ CtxtHandle *new_context, SecBufferDesc *output, ULONG *context_attr, TimeStamp *ts_expiry)
+{
+ SECURITY_STATUS status;
+ SEC_WCHAR *targetW = NULL;
+
+ TRACE("%p %p %s %#x %d %d %p %d %p %p %p %p\n", credential, context,
+ debugstr_a(target_name), context_req, reserved1, target_data_rep, input,
+ reserved2, new_context, output, context_attr, ts_expiry);
+
+ if (target_name)
+ {
+ int len = MultiByteToWideChar( CP_ACP, 0, target_name, -1, NULL, 0 );
+ if (!(targetW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
+ MultiByteToWideChar( CP_ACP, 0, target_name, -1, targetW, len );
+ }
+
+ status = lsa_InitializeSecurityContextW( credential, context, targetW, context_req, reserved1, target_data_rep,
+ input, reserved2, new_context, output, context_attr, ts_expiry );
+ HeapFree( GetProcessHeap(), 0, targetW );
+ return status;
+}
+
static const SecurityFunctionTableW lsa_sspi_tableW =
{
1,
@@ -404,7 +474,7 @@ static const SecurityFunctionTableW lsa_sspi_tableW =
lsa_AcquireCredentialsHandleW,
lsa_FreeCredentialsHandle,
NULL, /* Reserved2 */
- NULL, /* InitializeSecurityContextW */
+ lsa_InitializeSecurityContextW,
NULL, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
NULL, /* DeleteSecurityContext */
@@ -436,7 +506,7 @@ static const SecurityFunctionTableA lsa_sspi_tableA =
lsa_AcquireCredentialsHandleA,
lsa_FreeCredentialsHandle,
NULL, /* Reserved2 */
- NULL, /* InitializeSecurityContextA */
+ lsa_InitializeSecurityContextA,
NULL, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
NULL, /* DeleteSecurityContext */
--
2.15.1
Feb. 1, 2018
Re: [PATCH 1/9] secur32: Implement InitializeSecurityContext in the SSP/AP wrapper. (v3)
by Dmitry Timoshkov
Hans Leidekker <hans(a)codeweavers.com> wrote:
> > + if (context)
> > + {
> > + lsa_package = (struct lsa_package *)credential->dwUpper;
> > + lsa_context = (LSA_SEC_HANDLE)context->dwLower;
> > + }
> > + else if (credential)
> > + {
> > + lsa_package = (struct lsa_package *)context->dwUpper;
> > + lsa_credential = (LSA_SEC_HANDLE)credential->dwLower;
> > + }
>
> It's still mixed up.
Urgh. Thanks for catching this once again.
--
Dmitry.
Feb. 1, 2018
Re: [PATCH 1/9] secur32: Implement InitializeSecurityContext in the SSP/AP wrapper. (v3)
by Hans Leidekker
On Thu, 2018-02-01 at 11:52 +0800, Dmitry Timoshkov wrote:
> Partially based on Hans Leidekker's work.
>
> v2:
> switch order of context vs. credentials initialization
> initialize context also in case of SEC_I_CONTINUE_NEEDED
> v3:
> actually switch order of context vs. credentials initialization
>
> > Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
> ---
> dlls/secur32/lsa.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 72 insertions(+), 2 deletions(-)
>
> diff --git a/dlls/secur32/lsa.c b/dlls/secur32/lsa.c
> index 1916aa4b3a..ce4fb62a9d 100644
> --- a/dlls/secur32/lsa.c
> +++ b/dlls/secur32/lsa.c
> @@ -396,6 +396,76 @@ static SECURITY_STATUS WINAPI lsa_FreeCredentialsHandle(CredHandle *credential)
> return lsa_package->lsa_api->FreeCredentialsHandle(lsa_credential);
> }
>
> +static SECURITY_STATUS WINAPI lsa_InitializeSecurityContextW(
> + CredHandle *credential, CtxtHandle *context, SEC_WCHAR *target_name, ULONG context_req,
> + ULONG reserved1, ULONG target_data_rep, SecBufferDesc *input, ULONG reserved2,
> + CtxtHandle *new_context, SecBufferDesc *output, ULONG *context_attr, TimeStamp *ts_expiry)
> +{
> + SECURITY_STATUS status;
> + struct lsa_package *lsa_package = NULL;
> + LSA_SEC_HANDLE lsa_credential = 0, lsa_context = 0, new_lsa_context;
> + UNICODE_STRING target_name_us;
> + BOOLEAN mapped_context;
> +
> + TRACE("%p %p %s %#x %d %d %p %d %p %p %p %p\n", credential, context,
> + debugstr_w(target_name), context_req, reserved1, target_data_rep, input,
> + reserved2, new_context, output, context_attr, ts_expiry);
> +
> + if (context)
> + {
> + lsa_package = (struct lsa_package *)credential->dwUpper;
> + lsa_context = (LSA_SEC_HANDLE)context->dwLower;
> + }
> + else if (credential)
> + {
> + lsa_package = (struct lsa_package *)context->dwUpper;
> + lsa_credential = (LSA_SEC_HANDLE)credential->dwLower;
> + }
It's still mixed up.
Feb. 1, 2018
[PATCH] winedbg: Use longer module names when printing module list
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
programs/winedbg/info.c | 69 ++++++++++++++++++++++++++++---------------------
1 file changed, 40 insertions(+), 29 deletions(-)
diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c
index 89a2dc43fa..c1de158228 100644
--- a/programs/winedbg/info.c
+++ b/programs/winedbg/info.c
@@ -147,50 +147,61 @@ static const char* get_symtype_str(const IMAGEHLP_MODULE64* mi)
struct info_module
{
- IMAGEHLP_MODULE64* mi;
+ IMAGEHLP_MODULE64 mi;
+ char name[64];
+};
+
+struct info_modules
+{
+ struct info_module *modules;
unsigned num_alloc;
unsigned num_used;
};
-static void module_print_info(const IMAGEHLP_MODULE64* mi, BOOL is_embedded)
+static void module_print_info(const struct info_module *module, BOOL is_embedded)
{
dbg_printf("%*.*s-%*.*s\t%-16s%s\n",
- ADDRWIDTH, ADDRWIDTH, wine_dbgstr_longlong(mi->BaseOfImage),
- ADDRWIDTH, ADDRWIDTH, wine_dbgstr_longlong(mi->BaseOfImage + mi->ImageSize),
- is_embedded ? "\\" : get_symtype_str(mi), mi->ModuleName);
+ ADDRWIDTH, ADDRWIDTH, wine_dbgstr_longlong(module->mi.BaseOfImage),
+ ADDRWIDTH, ADDRWIDTH, wine_dbgstr_longlong(module->mi.BaseOfImage + module->mi.ImageSize),
+ is_embedded ? "\\" : get_symtype_str(&module->mi), module->name);
}
static int module_compare(const void* p1, const void* p2)
{
- LONGLONG val = ((const IMAGEHLP_MODULE64*)p1)->BaseOfImage -
- ((const IMAGEHLP_MODULE64*)p2)->BaseOfImage;
+ struct info_module *left = (struct info_module *)p1;
+ struct info_module *right = (struct info_module *)p2;
+ LONGLONG val = left->mi.BaseOfImage - right->mi.BaseOfImage;
+
if (val < 0) return -1;
else if (val > 0) return 1;
else return 0;
}
-static inline BOOL module_is_container(const IMAGEHLP_MODULE64* wmod_cntnr,
- const IMAGEHLP_MODULE64* wmod_child)
+static inline BOOL module_is_container(const struct info_module *wmod_cntnr,
+ const struct info_module *wmod_child)
{
- return wmod_cntnr->BaseOfImage <= wmod_child->BaseOfImage &&
- wmod_cntnr->BaseOfImage + wmod_cntnr->ImageSize >=
- wmod_child->BaseOfImage + wmod_child->ImageSize;
+ return wmod_cntnr->mi.BaseOfImage <= wmod_child->mi.BaseOfImage &&
+ wmod_cntnr->mi.BaseOfImage + wmod_cntnr->mi.ImageSize >=
+ wmod_child->mi.BaseOfImage + wmod_child->mi.ImageSize;
}
static BOOL CALLBACK info_mod_cb(PCSTR mod_name, DWORD64 base, PVOID ctx)
{
- struct info_module* im = ctx;
+ struct info_modules *im = ctx;
if (im->num_used + 1 > im->num_alloc)
{
im->num_alloc += 16;
- im->mi = dbg_heap_realloc(im->mi, im->num_alloc * sizeof(*im->mi));
+ im->modules = dbg_heap_realloc(im->modules, im->num_alloc * sizeof(*im->modules));
}
- im->mi[im->num_used].SizeOfStruct = sizeof(im->mi[im->num_used]);
- if (SymGetModuleInfo64(dbg_curr_process->handle, base, &im->mi[im->num_used]))
+ im->modules[im->num_used].mi.SizeOfStruct = sizeof(im->modules[im->num_used].mi);
+ if (SymGetModuleInfo64(dbg_curr_process->handle, base, &im->modules[im->num_used].mi))
{
+ const int dst_len = sizeof(im->modules[im->num_used].name);
+ lstrcpynA(im->modules[im->num_used].name, mod_name, dst_len - 1);
+ im->modules[im->num_used].name[dst_len - 1] = 0;
im->num_used++;
- }
+ }
return TRUE;
}
@@ -201,7 +212,7 @@ static BOOL CALLBACK info_mod_cb(PCSTR mod_name, DWORD64 base, PVOID ctx)
*/
void info_win32_module(DWORD64 base)
{
- struct info_module im;
+ struct info_modules im;
UINT i, j, num_printed = 0;
DWORD opt;
@@ -211,7 +222,7 @@ void info_win32_module(DWORD64 base)
return;
}
- im.mi = NULL;
+ im.modules = NULL;
im.num_alloc = im.num_used = 0;
/* this is a wine specific options to return also ELF modules in the
@@ -221,7 +232,7 @@ void info_win32_module(DWORD64 base)
SymEnumerateModules64(dbg_curr_process->handle, info_mod_cb, &im);
SymSetOptions(opt);
- qsort(im.mi, im.num_used, sizeof(im.mi[0]), module_compare);
+ qsort(im.modules, im.num_used, sizeof(im.modules[0]), module_compare);
dbg_printf("Module\tAddress\t\t\t%sDebug info\tName (%d modules)\n",
ADDRWIDTH == 16 ? "\t\t" : "", im.num_used);
@@ -229,19 +240,19 @@ void info_win32_module(DWORD64 base)
for (i = 0; i < im.num_used; i++)
{
if (base &&
- (base < im.mi[i].BaseOfImage || base >= im.mi[i].BaseOfImage + im.mi[i].ImageSize))
+ (base < im.modules[i].mi.BaseOfImage || base >= im.modules[i].mi.BaseOfImage + im.modules[i].mi.ImageSize))
continue;
- if (strstr(im.mi[i].ModuleName, "<elf>"))
+ if (strstr(im.modules[i].name, "<elf>"))
{
dbg_printf("ELF\t");
- module_print_info(&im.mi[i], FALSE);
+ module_print_info(&im.modules[i], FALSE);
/* print all modules embedded in this one */
for (j = 0; j < im.num_used; j++)
{
- if (!strstr(im.mi[j].ModuleName, "<elf>") && module_is_container(&im.mi[i], &im.mi[j]))
+ if (!strstr(im.modules[j].name, "<elf>") && module_is_container(&im.modules[i], &im.modules[j]))
{
dbg_printf(" \\-PE\t");
- module_print_info(&im.mi[j], TRUE);
+ module_print_info(&im.modules[j], TRUE);
}
}
}
@@ -250,19 +261,19 @@ void info_win32_module(DWORD64 base)
/* check module is not embedded in another module */
for (j = 0; j < im.num_used; j++)
{
- if (strstr(im.mi[j].ModuleName, "<elf>") && module_is_container(&im.mi[j], &im.mi[i]))
+ if (strstr(im.modules[j].name, "<elf>") && module_is_container(&im.modules[j], &im.modules[i]))
break;
}
if (j < im.num_used) continue;
- if (strstr(im.mi[i].ModuleName, ".so") || strchr(im.mi[i].ModuleName, '<'))
+ if (strstr(im.modules[i].name, ".so") || strchr(im.modules[i].name, '<'))
dbg_printf("ELF\t");
else
dbg_printf("PE\t");
- module_print_info(&im.mi[i], FALSE);
+ module_print_info(&im.modules[i], FALSE);
}
num_printed++;
}
- HeapFree(GetProcessHeap(), 0, im.mi);
+ HeapFree(GetProcessHeap(), 0, im.modules);
if (base && !num_printed)
dbg_printf("'0x%x%08x' is not a valid module address\n", (DWORD)(base >> 32), (DWORD)base);
--
2.15.1
Feb. 1, 2018
[PATCH v3 3/3] d3d10core/tests: Add test for resource access flags.
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
Version 3: Mark NO_OVERWRITE for constant buffers and shader access
buffers as broken().
---
dlls/d3d10core/tests/device.c | 330 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 330 insertions(+)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 86a8f43d4e93..a77f04f36805 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -8186,6 +8186,335 @@ static void test_copy_subresource_region(void)
release_test_context(&test_context);
}
+#define check_buffer_cpu_access(a, b, c, d) check_buffer_cpu_access_(__LINE__, a, b, c, d)
+static void check_buffer_cpu_access_(unsigned int line, ID3D10Buffer *buffer,
+ D3D10_USAGE usage, UINT bind_flags, UINT cpu_access)
+{
+ BOOL cpu_write = cpu_access & D3D10_CPU_ACCESS_WRITE;
+ BOOL cpu_read = cpu_access & D3D10_CPU_ACCESS_READ;
+ BOOL dynamic = usage == D3D10_USAGE_DYNAMIC;
+ HRESULT hr, expected_hr;
+ ID3D10Device *device;
+ void *data;
+
+ expected_hr = cpu_read ? S_OK : E_INVALIDARG;
+ hr = ID3D10Buffer_Map(buffer, D3D10_MAP_READ, 0, &data);
+ todo_wine_if(expected_hr != S_OK)
+ ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for READ.\n", hr);
+ if (SUCCEEDED(hr))
+ ID3D10Buffer_Unmap(buffer);
+
+ expected_hr = !dynamic && cpu_write ? S_OK : E_INVALIDARG;
+ hr = ID3D10Buffer_Map(buffer, D3D10_MAP_WRITE, 0, &data);
+ todo_wine_if(expected_hr != S_OK)
+ ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for WRITE.\n", hr);
+ if (SUCCEEDED(hr))
+ ID3D10Buffer_Unmap(buffer);
+
+ expected_hr = cpu_read && cpu_write ? S_OK : E_INVALIDARG;
+ hr = ID3D10Buffer_Map(buffer, D3D10_MAP_READ_WRITE, 0, &data);
+ todo_wine_if(expected_hr != S_OK)
+ ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for READ_WRITE.\n", hr);
+ if (SUCCEEDED(hr))
+ ID3D10Buffer_Unmap(buffer);
+
+ expected_hr = dynamic ? S_OK : E_INVALIDARG;
+ hr = ID3D10Buffer_Map(buffer, D3D10_MAP_WRITE_DISCARD, 0, &data);
+ todo_wine_if(expected_hr != S_OK)
+ ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for WRITE_DISCARD.\n", hr);
+ if (SUCCEEDED(hr))
+ ID3D10Buffer_Unmap(buffer);
+
+ if (!dynamic)
+ return;
+
+ ID3D10Buffer_GetDevice(buffer, &device);
+
+ expected_hr = S_OK;
+ hr = ID3D10Buffer_Map(buffer, D3D10_MAP_WRITE_NO_OVERWRITE, 0, &data);
+ todo_wine_if(expected_hr != S_OK)
+ ok_(__FILE__, line)(hr == expected_hr
+ || broken(bind_flags & (D3D10_BIND_CONSTANT_BUFFER | D3D10_BIND_SHADER_RESOURCE)),
+ "Got hr %#x for WRITE_NO_OVERWRITE.\n", hr);
+ if (SUCCEEDED(hr))
+ ID3D10Buffer_Unmap(buffer);
+
+ ID3D10Device_Release(device);
+}
+
+#define check_texture_cpu_access(a, b, c, d) check_texture_cpu_access_(__LINE__, a, b, c, d)
+static void check_texture_cpu_access_(unsigned int line, ID3D10Texture2D *texture,
+ D3D10_USAGE usage, UINT bind_flags, UINT cpu_access)
+{
+ BOOL cpu_write = cpu_access & D3D10_CPU_ACCESS_WRITE;
+ BOOL cpu_read = cpu_access & D3D10_CPU_ACCESS_READ;
+ BOOL dynamic = usage == D3D10_USAGE_DYNAMIC;
+ D3D10_MAPPED_TEXTURE2D map_desc;
+ HRESULT hr, expected_hr;
+
+ expected_hr = cpu_read ? S_OK : E_INVALIDARG;
+ hr = ID3D10Texture2D_Map(texture, 0, D3D10_MAP_READ, 0, &map_desc);
+ todo_wine_if(expected_hr != S_OK)
+ ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for READ.\n", hr);
+ if (SUCCEEDED(hr))
+ ID3D10Texture2D_Unmap(texture, 0);
+
+ expected_hr = !dynamic && cpu_write ? S_OK : E_INVALIDARG;
+ hr = ID3D10Texture2D_Map(texture, 0, D3D10_MAP_WRITE, 0, &map_desc);
+ todo_wine_if(expected_hr != S_OK)
+ ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for WRITE.\n", hr);
+ if (SUCCEEDED(hr))
+ ID3D10Texture2D_Unmap(texture, 0);
+
+ expected_hr = cpu_read && cpu_write ? S_OK : E_INVALIDARG;
+ hr = ID3D10Texture2D_Map(texture, 0, D3D10_MAP_READ_WRITE, 0, &map_desc);
+ todo_wine_if(expected_hr != S_OK)
+ ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for READ_WRITE.\n", hr);
+ if (SUCCEEDED(hr))
+ ID3D10Texture2D_Unmap(texture, 0);
+
+ expected_hr = dynamic ? S_OK : E_INVALIDARG;
+ hr = ID3D10Texture2D_Map(texture, 0, D3D10_MAP_WRITE_DISCARD, 0, &map_desc);
+ todo_wine_if(expected_hr != S_OK)
+ ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x for WRITE_DISCARD.\n", hr);
+ if (SUCCEEDED(hr))
+ ID3D10Texture2D_Unmap(texture, 0);
+
+ if (!dynamic)
+ return;
+
+ hr = ID3D10Texture2D_Map(texture, 0, D3D10_MAP_WRITE_NO_OVERWRITE, 0, &map_desc);
+ todo_wine
+ ok_(__FILE__, line)(hr == E_INVALIDARG, "Got hr %#x for WRITE_NO_OVERWRITE.\n", hr);
+ if (SUCCEEDED(hr))
+ ID3D10Texture2D_Unmap(texture, 0);
+}
+
+static void test_resource_access(void)
+{
+ D3D10_TEXTURE2D_DESC texture_desc;
+ D3D10_BUFFER_DESC buffer_desc;
+ D3D10_SUBRESOURCE_DATA data;
+ BOOL cpu_write, cpu_read;
+ BOOL required_cpu_access;
+ ID3D10Texture2D *texture;
+ HRESULT hr, expected_hr;
+ BOOL broken_validation;
+ ID3D10Device *device;
+ ID3D10Buffer *buffer;
+ unsigned int i;
+ ULONG refcount;
+
+ static const struct
+ {
+ D3D10_USAGE usage;
+ UINT bind_flags;
+ BOOL is_valid;
+ UINT allowed_cpu_access;
+ }
+ tests[] =
+ {
+ /* Default resources cannot be written by CPU. */
+ {D3D10_USAGE_DEFAULT, D3D10_BIND_VERTEX_BUFFER, TRUE, 0},
+ {D3D10_USAGE_DEFAULT, D3D10_BIND_INDEX_BUFFER, TRUE, 0},
+ {D3D10_USAGE_DEFAULT, D3D10_BIND_CONSTANT_BUFFER, TRUE, 0},
+ {D3D10_USAGE_DEFAULT, D3D10_BIND_SHADER_RESOURCE, TRUE, 0},
+ {D3D10_USAGE_DEFAULT, D3D10_BIND_STREAM_OUTPUT, TRUE, 0},
+ {D3D10_USAGE_DEFAULT, D3D10_BIND_RENDER_TARGET, TRUE, 0},
+ {D3D10_USAGE_DEFAULT, D3D10_BIND_DEPTH_STENCIL, TRUE, 0},
+
+ /* Immutable resources cannot be written by CPU and GPU. */
+ {D3D10_USAGE_IMMUTABLE, 0, FALSE, 0},
+ {D3D10_USAGE_IMMUTABLE, D3D10_BIND_VERTEX_BUFFER, TRUE, 0},
+ {D3D10_USAGE_IMMUTABLE, D3D10_BIND_INDEX_BUFFER, TRUE, 0},
+ {D3D10_USAGE_IMMUTABLE, D3D10_BIND_CONSTANT_BUFFER, TRUE, 0},
+ {D3D10_USAGE_IMMUTABLE, D3D10_BIND_SHADER_RESOURCE, TRUE, 0},
+ {D3D10_USAGE_IMMUTABLE, D3D10_BIND_STREAM_OUTPUT, FALSE, 0},
+ {D3D10_USAGE_IMMUTABLE, D3D10_BIND_RENDER_TARGET, FALSE, 0},
+ {D3D10_USAGE_IMMUTABLE, D3D10_BIND_DEPTH_STENCIL, FALSE, 0},
+
+ /* Dynamic resources cannot be written by GPU. */
+ {D3D10_USAGE_DYNAMIC, 0, FALSE, D3D10_CPU_ACCESS_WRITE},
+ {D3D10_USAGE_DYNAMIC, D3D10_BIND_VERTEX_BUFFER, TRUE, D3D10_CPU_ACCESS_WRITE},
+ {D3D10_USAGE_DYNAMIC, D3D10_BIND_INDEX_BUFFER, TRUE, D3D10_CPU_ACCESS_WRITE},
+ {D3D10_USAGE_DYNAMIC, D3D10_BIND_CONSTANT_BUFFER, TRUE, D3D10_CPU_ACCESS_WRITE},
+ {D3D10_USAGE_DYNAMIC, D3D10_BIND_SHADER_RESOURCE, TRUE, D3D10_CPU_ACCESS_WRITE},
+ {D3D10_USAGE_DYNAMIC, D3D10_BIND_STREAM_OUTPUT, FALSE, D3D10_CPU_ACCESS_WRITE},
+ {D3D10_USAGE_DYNAMIC, D3D10_BIND_RENDER_TARGET, FALSE, D3D10_CPU_ACCESS_WRITE},
+ {D3D10_USAGE_DYNAMIC, D3D10_BIND_DEPTH_STENCIL, FALSE, D3D10_CPU_ACCESS_WRITE},
+
+ /* Staging resources support only data transfer. */
+ {D3D10_USAGE_STAGING, 0, TRUE, D3D10_CPU_ACCESS_WRITE | D3D10_CPU_ACCESS_READ},
+ {D3D10_USAGE_STAGING, D3D10_BIND_VERTEX_BUFFER, FALSE, 0},
+ {D3D10_USAGE_STAGING, D3D10_BIND_INDEX_BUFFER, FALSE, 0},
+ {D3D10_USAGE_STAGING, D3D10_BIND_CONSTANT_BUFFER, FALSE, 0},
+ {D3D10_USAGE_STAGING, D3D10_BIND_SHADER_RESOURCE, FALSE, 0},
+ {D3D10_USAGE_STAGING, D3D10_BIND_STREAM_OUTPUT, FALSE, 0},
+ {D3D10_USAGE_STAGING, D3D10_BIND_RENDER_TARGET, FALSE, 0},
+ {D3D10_USAGE_STAGING, D3D10_BIND_DEPTH_STENCIL, FALSE, 0},
+ };
+
+ if (!(device = create_device()))
+ {
+ skip("Failed to create device.\n");
+ return;
+ }
+
+ data.SysMemPitch = 0;
+ data.SysMemSlicePitch = 0;
+ data.pSysMem = HeapAlloc(GetProcessHeap(), 0, 10240);
+ ok(!!data.pSysMem, "Failed to allocate memory.\n");
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ if (tests[i].bind_flags == D3D10_BIND_DEPTH_STENCIL)
+ continue;
+
+ required_cpu_access = tests[i].usage == D3D10_USAGE_DYNAMIC || tests[i].usage == D3D10_USAGE_STAGING;
+ cpu_write = tests[i].allowed_cpu_access & D3D10_CPU_ACCESS_WRITE;
+ cpu_read = tests[i].allowed_cpu_access & D3D10_CPU_ACCESS_READ;
+
+ buffer_desc.ByteWidth = 1024;
+ buffer_desc.Usage = tests[i].usage;
+ buffer_desc.BindFlags = tests[i].bind_flags;
+ buffer_desc.MiscFlags = 0;
+
+ buffer_desc.CPUAccessFlags = 0;
+ expected_hr = tests[i].is_valid && !required_cpu_access ? S_OK : E_INVALIDARG;
+ hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &data, &buffer);
+ ok(hr == expected_hr, "Got hr %#x, expected %#x, test %u.\n", hr, expected_hr, i);
+ if (SUCCEEDED(hr))
+ {
+ check_buffer_cpu_access(buffer, buffer_desc.Usage,
+ buffer_desc.BindFlags, buffer_desc.CPUAccessFlags);
+ ID3D10Buffer_Release(buffer);
+ }
+
+ buffer_desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
+ expected_hr = tests[i].is_valid && cpu_write ? S_OK : E_INVALIDARG;
+ hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &data, &buffer);
+ ok(hr == expected_hr, "Got hr %#x, expected %#x, test %u.\n", hr, expected_hr, i);
+ if (SUCCEEDED(hr))
+ {
+ check_buffer_cpu_access(buffer, buffer_desc.Usage,
+ buffer_desc.BindFlags, buffer_desc.CPUAccessFlags);
+ ID3D10Buffer_Release(buffer);
+ }
+
+ buffer_desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ;
+ expected_hr = tests[i].is_valid && cpu_read ? S_OK : E_INVALIDARG;
+ hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &data, &buffer);
+ ok(hr == expected_hr, "Got hr %#x, expected %#x, test %u.\n", hr, expected_hr, i);
+ if (SUCCEEDED(hr))
+ {
+ check_buffer_cpu_access(buffer, buffer_desc.Usage,
+ buffer_desc.BindFlags, buffer_desc.CPUAccessFlags);
+ ID3D10Buffer_Release(buffer);
+ }
+
+ buffer_desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE | D3D10_CPU_ACCESS_READ;
+ expected_hr = tests[i].is_valid && cpu_write && cpu_read ? S_OK : E_INVALIDARG;
+ hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &data, &buffer);
+ ok(hr == expected_hr, "Got hr %#x, expected %#x, test %u.\n", hr, expected_hr, i);
+ if (SUCCEEDED(hr))
+ {
+ check_buffer_cpu_access(buffer, buffer_desc.Usage,
+ buffer_desc.BindFlags, buffer_desc.CPUAccessFlags);
+ ID3D10Buffer_Release(buffer);
+ }
+ }
+
+ data.SysMemPitch = 16;
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ if (tests[i].bind_flags == D3D10_BIND_VERTEX_BUFFER
+ || tests[i].bind_flags == D3D10_BIND_INDEX_BUFFER
+ || tests[i].bind_flags == D3D10_BIND_CONSTANT_BUFFER
+ || tests[i].bind_flags == D3D10_BIND_STREAM_OUTPUT)
+ continue;
+
+ broken_validation = tests[i].usage == D3D10_USAGE_DEFAULT
+ && (tests[i].bind_flags == D3D10_BIND_SHADER_RESOURCE
+ || tests[i].bind_flags == D3D10_BIND_RENDER_TARGET);
+
+ required_cpu_access = tests[i].usage == D3D10_USAGE_DYNAMIC || tests[i].usage == D3D10_USAGE_STAGING;
+ cpu_write = tests[i].allowed_cpu_access & D3D10_CPU_ACCESS_WRITE;
+ cpu_read = tests[i].allowed_cpu_access & D3D10_CPU_ACCESS_READ;
+
+ texture_desc.Width = 4;
+ texture_desc.Height = 4;
+ texture_desc.MipLevels = 1;
+ texture_desc.ArraySize = 1;
+ texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ texture_desc.SampleDesc.Count = 1;
+ texture_desc.SampleDesc.Quality = 0;
+ texture_desc.Usage = tests[i].usage;
+ texture_desc.BindFlags = tests[i].bind_flags;
+ texture_desc.MiscFlags = 0;
+ if (tests[i].bind_flags == D3D10_BIND_DEPTH_STENCIL)
+ texture_desc.Format = DXGI_FORMAT_D16_UNORM;
+
+ texture_desc.CPUAccessFlags = 0;
+ expected_hr = tests[i].is_valid && !required_cpu_access ? S_OK : E_INVALIDARG;
+ hr = ID3D10Device_CreateTexture2D(device, &texture_desc, &data, &texture);
+ ok(hr == expected_hr, "Got hr %#x, expected %#x, test %u.\n", hr, expected_hr, i);
+ if (SUCCEEDED(hr))
+ {
+ check_texture_cpu_access(texture, texture_desc.Usage,
+ texture_desc.BindFlags, texture_desc.CPUAccessFlags);
+ ID3D10Texture2D_Release(texture);
+ }
+
+ texture_desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
+ expected_hr = tests[i].is_valid && cpu_write ? S_OK : E_INVALIDARG;
+ hr = ID3D10Device_CreateTexture2D(device, &texture_desc, &data, &texture);
+ ok(hr == expected_hr || (hr == S_OK && broken_validation),
+ "Got hr %#x, expected %#x, test %u.\n", hr, expected_hr, i);
+ if (SUCCEEDED(hr))
+ {
+ if (broken_validation)
+ texture_desc.CPUAccessFlags = 0;
+ check_texture_cpu_access(texture, texture_desc.Usage,
+ texture_desc.BindFlags, texture_desc.CPUAccessFlags);
+ ID3D10Texture2D_Release(texture);
+ }
+
+ texture_desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ;
+ expected_hr = tests[i].is_valid && cpu_read ? S_OK : E_INVALIDARG;
+ hr = ID3D10Device_CreateTexture2D(device, &texture_desc, &data, &texture);
+ ok(hr == expected_hr || (hr == S_OK && broken_validation),
+ "Got hr %#x, expected %#x, test %u.\n", hr, expected_hr, i);
+ if (SUCCEEDED(hr))
+ {
+ if (broken_validation)
+ texture_desc.CPUAccessFlags = 0;
+ check_texture_cpu_access(texture, texture_desc.Usage,
+ texture_desc.BindFlags, texture_desc.CPUAccessFlags);
+ ID3D10Texture2D_Release(texture);
+ }
+
+ texture_desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE | D3D10_CPU_ACCESS_READ;
+ expected_hr = tests[i].is_valid && cpu_write && cpu_read ? S_OK : E_INVALIDARG;
+ hr = ID3D10Device_CreateTexture2D(device, &texture_desc, &data, &texture);
+ ok(hr == expected_hr || (hr == S_OK && broken_validation),
+ "Got hr %#x, expected %#x, test %u.\n", hr, expected_hr, i);
+ if (SUCCEEDED(hr))
+ {
+ if (broken_validation)
+ texture_desc.CPUAccessFlags = 0;
+ check_texture_cpu_access(texture, texture_desc.Usage,
+ texture_desc.BindFlags, texture_desc.CPUAccessFlags);
+ ID3D10Texture2D_Release(texture);
+ }
+ }
+
+ HeapFree(GetProcessHeap(), 0, (void *)data.pSysMem);
+
+ refcount = ID3D10Device_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+}
+
static void test_check_multisample_quality_levels(void)
{
ID3D10Device *device;
@@ -13882,6 +14211,7 @@ START_TEST(device)
test_fragment_coords();
test_update_subresource();
test_copy_subresource_region();
+ test_resource_access();
test_check_multisample_quality_levels();
test_cb_relative_addressing();
test_vs_input_relative_addressing();
--
2.13.6
Feb. 1, 2018