1 /* Copyright (C) 2004 Juan Lang
3 * This file implements thunks between wide char and multibyte functions for
4 * SSPs that only provide one or the other.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "secur32_priv.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(secur32
);
34 SECURITY_STATUS SEC_ENTRY
thunk_AcquireCredentialsHandleA(
35 SEC_CHAR
*pszPrincipal
, SEC_CHAR
*pszPackage
, ULONG fCredentialsUse
,
36 PLUID pvLogonID
, PVOID pAuthData
, SEC_GET_KEY_FN pGetKeyFn
,
37 PVOID pvGetKeyArgument
, PCredHandle phCredential
, PTimeStamp ptsExpiry
)
41 TRACE("%s %s %ld %p %p %p %p %p %p\n", debugstr_a(pszPrincipal
),
42 debugstr_a(pszPackage
), fCredentialsUse
, pvLogonID
, pAuthData
, pGetKeyFn
,
43 pvGetKeyArgument
, phCredential
, ptsExpiry
);
46 UNICODE_STRING principal
, package
;
48 RtlCreateUnicodeStringFromAsciiz(&principal
, pszPrincipal
);
49 RtlCreateUnicodeStringFromAsciiz(&package
, pszPackage
);
50 ret
= AcquireCredentialsHandleW(principal
.Buffer
, package
.Buffer
,
51 fCredentialsUse
, pvLogonID
, pAuthData
, pGetKeyFn
, pvGetKeyArgument
,
52 phCredential
, ptsExpiry
);
53 RtlFreeUnicodeString(&principal
);
54 RtlFreeUnicodeString(&package
);
57 ret
= SEC_E_SECPKG_NOT_FOUND
;
61 SECURITY_STATUS SEC_ENTRY
thunk_AcquireCredentialsHandleW(
62 SEC_WCHAR
*pszPrincipal
, SEC_WCHAR
*pszPackage
, ULONG fCredentialsUse
,
63 PLUID pvLogonID
, PVOID pAuthData
, SEC_GET_KEY_FN pGetKeyFn
,
64 PVOID pvGetKeyArgument
, PCredHandle phCredential
, PTimeStamp ptsExpiry
)
68 TRACE("%s %s %ld %p %p %p %p %p %p\n", debugstr_w(pszPrincipal
),
69 debugstr_w(pszPackage
), fCredentialsUse
, pvLogonID
, pAuthData
, pGetKeyFn
,
70 pvGetKeyArgument
, phCredential
, ptsExpiry
);
73 PSTR principal
, package
;
75 principal
= SECUR32_AllocMultiByteFromWide(pszPrincipal
);
76 package
= SECUR32_AllocMultiByteFromWide(pszPackage
);
77 ret
= AcquireCredentialsHandleA(principal
, package
, fCredentialsUse
,
78 pvLogonID
, pAuthData
, pGetKeyFn
, pvGetKeyArgument
, phCredential
,
80 SECUR32_FREE(principal
);
81 SECUR32_FREE(package
);
84 ret
= SEC_E_SECPKG_NOT_FOUND
;
88 /* thunking is pretty dicey for these--the output type depends on ulAttribute,
89 * so we have to know about every type the caller does
91 SECURITY_STATUS SEC_ENTRY
thunk_QueryCredentialsAttributesA(
92 PCredHandle phCredential
, unsigned long ulAttribute
, void *pBuffer
)
96 TRACE("%p %ld %p\n", phCredential
, ulAttribute
, pBuffer
);
99 SecurePackage
*package
= (SecurePackage
*)phCredential
->dwUpper
;
100 PCredHandle cred
= (PCredHandle
)phCredential
->dwLower
;
102 if (package
&& package
->provider
)
104 if (package
->provider
->fnTableW
.QueryCredentialsAttributesW
)
106 ret
= package
->provider
->fnTableW
.QueryCredentialsAttributesW(
107 cred
, ulAttribute
, pBuffer
);
112 case SECPKG_CRED_ATTR_NAMES
:
114 PSecPkgCredentials_NamesW names
=
115 (PSecPkgCredentials_NamesW
)pBuffer
;
116 SEC_WCHAR
*oldUser
= names
->sUserName
;
121 (PWSTR
)SECUR32_AllocMultiByteFromWide(oldUser
);
122 package
->provider
->fnTableW
.FreeContextBuffer(
128 WARN("attribute type %ld unknown\n", ulAttribute
);
129 ret
= SEC_E_INTERNAL_ERROR
;
134 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
137 ret
= SEC_E_INVALID_HANDLE
;
140 ret
= SEC_E_INVALID_HANDLE
;
144 SECURITY_STATUS SEC_ENTRY
thunk_QueryCredentialsAttributesW(
145 PCredHandle phCredential
, unsigned long ulAttribute
, void *pBuffer
)
149 TRACE("%p %ld %p\n", phCredential
, ulAttribute
, pBuffer
);
152 SecurePackage
*package
= (SecurePackage
*)phCredential
->dwUpper
;
153 PCredHandle cred
= (PCredHandle
)phCredential
->dwLower
;
155 if (package
&& package
->provider
)
157 if (package
->provider
->fnTableA
.QueryCredentialsAttributesA
)
159 ret
= package
->provider
->fnTableA
.QueryCredentialsAttributesA(
160 cred
, ulAttribute
, pBuffer
);
165 case SECPKG_CRED_ATTR_NAMES
:
167 PSecPkgCredentials_NamesA names
=
168 (PSecPkgCredentials_NamesA
)pBuffer
;
169 SEC_CHAR
*oldUser
= names
->sUserName
;
174 (PSTR
)SECUR32_AllocWideFromMultiByte(oldUser
);
175 package
->provider
->fnTableA
.FreeContextBuffer(
181 WARN("attribute type %ld unknown\n", ulAttribute
);
182 ret
= SEC_E_INTERNAL_ERROR
;
187 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
190 ret
= SEC_E_INVALID_HANDLE
;
193 ret
= SEC_E_INVALID_HANDLE
;
197 SECURITY_STATUS SEC_ENTRY
thunk_InitializeSecurityContextA(
198 PCredHandle phCredential
, PCtxtHandle phContext
,
199 SEC_CHAR
*pszTargetName
, unsigned long fContextReq
,
200 unsigned long Reserved1
, unsigned long TargetDataRep
, PSecBufferDesc pInput
,
201 unsigned long Reserved2
, PCtxtHandle phNewContext
, PSecBufferDesc pOutput
,
202 unsigned long *pfContextAttr
, PTimeStamp ptsExpiry
)
206 TRACE("%p %p %s %ld %ld %ld %p %ld %p %p %p %p\n", phCredential
, phContext
,
207 debugstr_a(pszTargetName
), fContextReq
, Reserved1
, TargetDataRep
, pInput
,
208 Reserved1
, phNewContext
, pOutput
, pfContextAttr
, ptsExpiry
);
211 SecurePackage
*package
= (SecurePackage
*)phCredential
->dwUpper
;
213 if (package
&& package
->provider
)
215 if (package
->provider
->fnTableW
.InitializeSecurityContextW
)
217 UNICODE_STRING target
;
219 RtlCreateUnicodeStringFromAsciiz(&target
, pszTargetName
);
220 ret
= package
->provider
->fnTableW
.InitializeSecurityContextW(
221 phCredential
, phContext
, target
.Buffer
, fContextReq
, Reserved1
,
222 TargetDataRep
, pInput
, Reserved2
, phNewContext
, pOutput
,
223 pfContextAttr
, ptsExpiry
);
224 RtlFreeUnicodeString(&target
);
227 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
230 ret
= SEC_E_INVALID_HANDLE
;
233 ret
= SEC_E_INVALID_HANDLE
;
237 SECURITY_STATUS SEC_ENTRY
thunk_InitializeSecurityContextW(
238 PCredHandle phCredential
, PCtxtHandle phContext
,
239 SEC_WCHAR
*pszTargetName
, unsigned long fContextReq
,
240 unsigned long Reserved1
, unsigned long TargetDataRep
, PSecBufferDesc pInput
,
241 unsigned long Reserved2
, PCtxtHandle phNewContext
, PSecBufferDesc pOutput
,
242 unsigned long *pfContextAttr
, PTimeStamp ptsExpiry
)
246 TRACE("%p %p %s %ld %ld %ld %p %ld %p %p %p %p\n", phCredential
, phContext
,
247 debugstr_w(pszTargetName
), fContextReq
, Reserved1
, TargetDataRep
, pInput
,
248 Reserved1
, phNewContext
, pOutput
, pfContextAttr
, ptsExpiry
);
251 SecurePackage
*package
= (SecurePackage
*)phCredential
->dwUpper
;
253 if (package
&& package
->provider
)
255 if (package
->provider
->fnTableA
.InitializeSecurityContextA
)
257 PSTR target
= SECUR32_AllocMultiByteFromWide(pszTargetName
);
259 ret
= package
->provider
->fnTableA
.InitializeSecurityContextA(
260 phCredential
, phContext
, target
, fContextReq
, Reserved1
,
261 TargetDataRep
, pInput
, Reserved2
, phNewContext
, pOutput
,
262 pfContextAttr
, ptsExpiry
);
263 SECUR32_FREE(target
);
266 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
269 ret
= SEC_E_INVALID_HANDLE
;
272 ret
= SEC_E_INVALID_HANDLE
;
276 SECURITY_STATUS SEC_ENTRY
thunk_AddCredentialsA(PCredHandle hCredentials
,
277 SEC_CHAR
*pszPrincipal
, SEC_CHAR
*pszPackage
, unsigned long fCredentialUse
,
278 void *pAuthData
, SEC_GET_KEY_FN pGetKeyFn
, void *pvGetKeyArgument
,
279 PTimeStamp ptsExpiry
)
283 TRACE("%p %s %s %ld %p %p %p %p\n", hCredentials
, debugstr_a(pszPrincipal
),
284 debugstr_a(pszPackage
), fCredentialUse
, pAuthData
, pGetKeyFn
,
285 pvGetKeyArgument
, ptsExpiry
);
288 SecurePackage
*package
= (SecurePackage
*)hCredentials
->dwUpper
;
289 PCredHandle cred
= (PCtxtHandle
)hCredentials
->dwLower
;
291 if (package
&& package
->provider
)
293 if (package
->provider
->fnTableW
.AddCredentialsW
)
295 UNICODE_STRING szPrincipal
, szPackage
;
297 RtlCreateUnicodeStringFromAsciiz(&szPrincipal
, pszPrincipal
);
298 RtlCreateUnicodeStringFromAsciiz(&szPackage
, pszPackage
);
299 ret
= package
->provider
->fnTableW
.AddCredentialsW(
300 cred
, szPrincipal
.Buffer
, szPackage
.Buffer
, fCredentialUse
,
301 pAuthData
, pGetKeyFn
, pvGetKeyArgument
, ptsExpiry
);
302 RtlFreeUnicodeString(&szPrincipal
);
303 RtlFreeUnicodeString(&szPackage
);
306 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
309 ret
= SEC_E_INVALID_HANDLE
;
312 ret
= SEC_E_INVALID_HANDLE
;
316 SECURITY_STATUS SEC_ENTRY
thunk_AddCredentialsW(PCredHandle hCredentials
,
317 SEC_WCHAR
*pszPrincipal
, SEC_WCHAR
*pszPackage
, unsigned long fCredentialUse
,
318 void *pAuthData
, SEC_GET_KEY_FN pGetKeyFn
, void *pvGetKeyArgument
,
319 PTimeStamp ptsExpiry
)
323 TRACE("%p %s %s %ld %p %p %p %p\n", hCredentials
, debugstr_w(pszPrincipal
),
324 debugstr_w(pszPackage
), fCredentialUse
, pAuthData
, pGetKeyFn
,
325 pvGetKeyArgument
, ptsExpiry
);
328 SecurePackage
*package
= (SecurePackage
*)hCredentials
->dwUpper
;
329 PCredHandle cred
= (PCtxtHandle
)hCredentials
->dwLower
;
331 if (package
&& package
->provider
)
333 if (package
->provider
->fnTableA
.AddCredentialsA
)
335 PSTR szPrincipal
= SECUR32_AllocMultiByteFromWide(pszPrincipal
);
336 PSTR szPackage
= SECUR32_AllocMultiByteFromWide(pszPackage
);
338 ret
= package
->provider
->fnTableA
.AddCredentialsA(
339 cred
, szPrincipal
, szPackage
, fCredentialUse
, pAuthData
,
340 pGetKeyFn
, pvGetKeyArgument
, ptsExpiry
);
341 SECUR32_FREE(szPrincipal
);
342 SECUR32_FREE(szPackage
);
345 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
348 ret
= SEC_E_INVALID_HANDLE
;
351 ret
= SEC_E_INVALID_HANDLE
;
355 static PSecPkgInfoA
_copyPackageInfoFlatWToA(PSecPkgInfoW infoW
)
361 size_t bytesNeeded
= sizeof(SecPkgInfoA
);
362 int nameLen
= 0, commentLen
= 0;
366 nameLen
= WideCharToMultiByte(CP_ACP
, 0, infoW
->Name
, -1,
367 NULL
, 0, NULL
, NULL
);
368 bytesNeeded
+= nameLen
;
372 commentLen
= WideCharToMultiByte(CP_ACP
, 0, infoW
->Comment
, -1,
373 NULL
, 0, NULL
, NULL
);
374 bytesNeeded
+= commentLen
;
376 ret
= (PSecPkgInfoA
)SECUR32_ALLOC(bytesNeeded
);
379 PSTR nextString
= (PSTR
)((PBYTE
)ret
+ sizeof(SecPkgInfoA
));
381 memcpy(ret
, infoW
, sizeof(SecPkgInfoA
));
384 ret
->Name
= nextString
;
385 WideCharToMultiByte(CP_ACP
, 0, infoW
->Name
, -1, nextString
,
386 nameLen
, NULL
, NULL
);
387 nextString
+= nameLen
;
393 ret
->Comment
= nextString
;
394 WideCharToMultiByte(CP_ACP
, 0, infoW
->Comment
, -1, nextString
,
395 nameLen
, NULL
, NULL
);
406 static SECURITY_STATUS
thunk_ContextAttributesWToA(SecurePackage
*package
,
407 unsigned long ulAttribute
, void *pBuffer
)
409 SECURITY_STATUS ret
= SEC_E_OK
;
411 if (package
&& pBuffer
)
415 case SECPKG_ATTR_NAMES
:
417 PSecPkgContext_NamesW names
= (PSecPkgContext_NamesW
)pBuffer
;
418 SEC_WCHAR
*oldUser
= names
->sUserName
;
423 (PWSTR
)SECUR32_AllocMultiByteFromWide(oldUser
);
424 package
->provider
->fnTableW
.FreeContextBuffer(oldUser
);
428 case SECPKG_ATTR_AUTHORITY
:
430 PSecPkgContext_AuthorityW names
=
431 (PSecPkgContext_AuthorityW
)pBuffer
;
432 SEC_WCHAR
*oldAuth
= names
->sAuthorityName
;
436 names
->sAuthorityName
=
437 (PWSTR
)SECUR32_AllocMultiByteFromWide(oldAuth
);
438 package
->provider
->fnTableW
.FreeContextBuffer(oldAuth
);
442 case SECPKG_ATTR_KEY_INFO
:
444 PSecPkgContext_KeyInfoW info
= (PSecPkgContext_KeyInfoW
)pBuffer
;
445 SEC_WCHAR
*oldSigAlgName
= info
->sSignatureAlgorithmName
;
446 SEC_WCHAR
*oldEncAlgName
= info
->sEncryptAlgorithmName
;
450 info
->sSignatureAlgorithmName
=
451 (PWSTR
)SECUR32_AllocMultiByteFromWide(oldSigAlgName
);
452 package
->provider
->fnTableW
.FreeContextBuffer(
457 info
->sEncryptAlgorithmName
=
458 (PWSTR
)SECUR32_AllocMultiByteFromWide(oldEncAlgName
);
459 package
->provider
->fnTableW
.FreeContextBuffer(
464 case SECPKG_ATTR_PACKAGE_INFO
:
466 PSecPkgContext_PackageInfoW info
=
467 (PSecPkgContext_PackageInfoW
)pBuffer
;
468 PSecPkgInfoW oldPkgInfo
= info
->PackageInfo
;
472 info
->PackageInfo
= (PSecPkgInfoW
)
473 _copyPackageInfoFlatWToA(oldPkgInfo
);
474 package
->provider
->fnTableW
.FreeContextBuffer(oldPkgInfo
);
478 case SECPKG_ATTR_NEGOTIATION_INFO
:
480 PSecPkgContext_NegotiationInfoW info
=
481 (PSecPkgContext_NegotiationInfoW
)pBuffer
;
482 PSecPkgInfoW oldPkgInfo
= info
->PackageInfo
;
486 info
->PackageInfo
= (PSecPkgInfoW
)
487 _copyPackageInfoFlatWToA(oldPkgInfo
);
488 package
->provider
->fnTableW
.FreeContextBuffer(oldPkgInfo
);
492 case SECPKG_ATTR_NATIVE_NAMES
:
494 PSecPkgContext_NativeNamesW names
=
495 (PSecPkgContext_NativeNamesW
)pBuffer
;
496 PWSTR oldClient
= names
->sClientName
;
497 PWSTR oldServer
= names
->sServerName
;
501 names
->sClientName
= (PWSTR
)SECUR32_AllocMultiByteFromWide(
503 package
->provider
->fnTableW
.FreeContextBuffer(oldClient
);
507 names
->sServerName
= (PWSTR
)SECUR32_AllocMultiByteFromWide(
509 package
->provider
->fnTableW
.FreeContextBuffer(oldServer
);
513 case SECPKG_ATTR_CREDENTIAL_NAME
:
515 PSecPkgContext_CredentialNameW name
=
516 (PSecPkgContext_CredentialNameW
)pBuffer
;
517 PWSTR oldCred
= name
->sCredentialName
;
521 name
->sCredentialName
=
522 (PWSTR
)SECUR32_AllocMultiByteFromWide(oldCred
);
523 package
->provider
->fnTableW
.FreeContextBuffer(oldCred
);
527 /* no thunking needed: */
528 case SECPKG_ATTR_ACCESS_TOKEN
:
529 case SECPKG_ATTR_DCE_INFO
:
530 case SECPKG_ATTR_FLAGS
:
531 case SECPKG_ATTR_LIFESPAN
:
532 case SECPKG_ATTR_PASSWORD_EXPIRY
:
533 case SECPKG_ATTR_SESSION_KEY
:
534 case SECPKG_ATTR_SIZES
:
535 case SECPKG_ATTR_STREAM_SIZES
:
536 case SECPKG_ATTR_TARGET_INFORMATION
:
539 WARN("attribute type %ld unknown\n", ulAttribute
);
540 ret
= SEC_E_INTERNAL_ERROR
;
544 ret
= SEC_E_INVALID_TOKEN
;
548 SECURITY_STATUS SEC_ENTRY
thunk_QueryContextAttributesA(PCtxtHandle phContext
,
549 unsigned long ulAttribute
, void *pBuffer
)
553 TRACE("%p %ld %p\n", phContext
, ulAttribute
, pBuffer
);
556 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
557 PCtxtHandle ctxt
= (PCtxtHandle
)phContext
->dwLower
;
559 if (package
&& package
->provider
)
561 if (package
->provider
->fnTableW
.QueryContextAttributesW
)
563 ret
= package
->provider
->fnTableW
.QueryContextAttributesW(
564 ctxt
, ulAttribute
, pBuffer
);
566 ret
= thunk_ContextAttributesWToA(package
, ulAttribute
,
570 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
573 ret
= SEC_E_INVALID_HANDLE
;
576 ret
= SEC_E_INVALID_HANDLE
;
580 static PSecPkgInfoW
_copyPackageInfoFlatAToW(PSecPkgInfoA infoA
)
586 size_t bytesNeeded
= sizeof(SecPkgInfoW
);
587 int nameLen
= 0, commentLen
= 0;
591 nameLen
= MultiByteToWideChar(CP_ACP
, 0, infoA
->Name
, -1,
593 bytesNeeded
+= nameLen
* sizeof(WCHAR
);
597 commentLen
= MultiByteToWideChar(CP_ACP
, 0, infoA
->Comment
, -1,
599 bytesNeeded
+= commentLen
* sizeof(WCHAR
);
601 ret
= (PSecPkgInfoW
)SECUR32_ALLOC(bytesNeeded
);
604 PWSTR nextString
= (PWSTR
)((PBYTE
)ret
+ sizeof(SecPkgInfoW
));
606 memcpy(ret
, infoA
, sizeof(SecPkgInfoA
));
609 ret
->Name
= nextString
;
610 MultiByteToWideChar(CP_ACP
, 0, infoA
->Name
, -1, nextString
,
612 nextString
+= nameLen
;
618 ret
->Comment
= nextString
;
619 MultiByteToWideChar(CP_ACP
, 0, infoA
->Comment
, -1, nextString
,
631 static SECURITY_STATUS
thunk_ContextAttributesAToW(SecurePackage
*package
,
632 unsigned long ulAttribute
, void *pBuffer
)
634 SECURITY_STATUS ret
= SEC_E_OK
;
636 if (package
&& pBuffer
)
640 case SECPKG_ATTR_NAMES
:
642 PSecPkgContext_NamesA names
= (PSecPkgContext_NamesA
)pBuffer
;
643 SEC_CHAR
*oldUser
= names
->sUserName
;
648 (PSTR
)SECUR32_AllocWideFromMultiByte(oldUser
);
649 package
->provider
->fnTableW
.FreeContextBuffer(oldUser
);
653 case SECPKG_ATTR_AUTHORITY
:
655 PSecPkgContext_AuthorityA names
=
656 (PSecPkgContext_AuthorityA
)pBuffer
;
657 SEC_CHAR
*oldAuth
= names
->sAuthorityName
;
661 names
->sAuthorityName
=
662 (PSTR
)SECUR32_AllocWideFromMultiByte(oldAuth
);
663 package
->provider
->fnTableW
.FreeContextBuffer(oldAuth
);
667 case SECPKG_ATTR_KEY_INFO
:
669 PSecPkgContext_KeyInfoA info
= (PSecPkgContext_KeyInfoA
)pBuffer
;
670 SEC_CHAR
*oldSigAlgName
= info
->sSignatureAlgorithmName
;
671 SEC_CHAR
*oldEncAlgName
= info
->sEncryptAlgorithmName
;
675 info
->sSignatureAlgorithmName
=
676 (PSTR
)SECUR32_AllocWideFromMultiByte(oldSigAlgName
);
677 package
->provider
->fnTableW
.FreeContextBuffer(
682 info
->sEncryptAlgorithmName
=
683 (PSTR
)SECUR32_AllocWideFromMultiByte(
685 package
->provider
->fnTableW
.FreeContextBuffer(
690 case SECPKG_ATTR_PACKAGE_INFO
:
692 PSecPkgContext_PackageInfoA info
=
693 (PSecPkgContext_PackageInfoA
)pBuffer
;
694 PSecPkgInfoA oldPkgInfo
= info
->PackageInfo
;
698 info
->PackageInfo
= (PSecPkgInfoA
)
699 _copyPackageInfoFlatAToW(oldPkgInfo
);
700 package
->provider
->fnTableW
.FreeContextBuffer(oldPkgInfo
);
704 case SECPKG_ATTR_NEGOTIATION_INFO
:
706 PSecPkgContext_NegotiationInfoA info
=
707 (PSecPkgContext_NegotiationInfoA
)pBuffer
;
708 PSecPkgInfoA oldPkgInfo
= info
->PackageInfo
;
712 info
->PackageInfo
= (PSecPkgInfoA
)
713 _copyPackageInfoFlatAToW(oldPkgInfo
);
714 package
->provider
->fnTableW
.FreeContextBuffer(oldPkgInfo
);
718 case SECPKG_ATTR_NATIVE_NAMES
:
720 PSecPkgContext_NativeNamesA names
=
721 (PSecPkgContext_NativeNamesA
)pBuffer
;
722 PSTR oldClient
= names
->sClientName
;
723 PSTR oldServer
= names
->sServerName
;
727 names
->sClientName
= (PSTR
)SECUR32_AllocWideFromMultiByte(
729 package
->provider
->fnTableW
.FreeContextBuffer(oldClient
);
733 names
->sServerName
= (PSTR
)SECUR32_AllocWideFromMultiByte(
735 package
->provider
->fnTableW
.FreeContextBuffer(oldServer
);
739 case SECPKG_ATTR_CREDENTIAL_NAME
:
741 PSecPkgContext_CredentialNameA name
=
742 (PSecPkgContext_CredentialNameA
)pBuffer
;
743 PSTR oldCred
= name
->sCredentialName
;
747 name
->sCredentialName
=
748 (PSTR
)SECUR32_AllocWideFromMultiByte(oldCred
);
749 package
->provider
->fnTableW
.FreeContextBuffer(oldCred
);
753 /* no thunking needed: */
754 case SECPKG_ATTR_ACCESS_TOKEN
:
755 case SECPKG_ATTR_DCE_INFO
:
756 case SECPKG_ATTR_FLAGS
:
757 case SECPKG_ATTR_LIFESPAN
:
758 case SECPKG_ATTR_PASSWORD_EXPIRY
:
759 case SECPKG_ATTR_SESSION_KEY
:
760 case SECPKG_ATTR_SIZES
:
761 case SECPKG_ATTR_STREAM_SIZES
:
762 case SECPKG_ATTR_TARGET_INFORMATION
:
765 WARN("attribute type %ld unknown\n", ulAttribute
);
766 ret
= SEC_E_INTERNAL_ERROR
;
770 ret
= SEC_E_INVALID_TOKEN
;
774 SECURITY_STATUS SEC_ENTRY
thunk_QueryContextAttributesW(PCtxtHandle phContext
,
775 unsigned long ulAttribute
, void *pBuffer
)
779 TRACE("%p %ld %p\n", phContext
, ulAttribute
, pBuffer
);
782 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
783 PCtxtHandle ctxt
= (PCtxtHandle
)phContext
->dwLower
;
785 if (package
&& package
->provider
)
787 if (package
->provider
->fnTableA
.QueryContextAttributesA
)
789 ret
= package
->provider
->fnTableA
.QueryContextAttributesA(
790 ctxt
, ulAttribute
, pBuffer
);
792 ret
= thunk_ContextAttributesAToW(package
, ulAttribute
,
796 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
799 ret
= SEC_E_INVALID_HANDLE
;
802 ret
= SEC_E_INVALID_HANDLE
;
806 SECURITY_STATUS SEC_ENTRY
thunk_SetContextAttributesA(PCtxtHandle phContext
,
807 unsigned long ulAttribute
, void *pBuffer
, unsigned long cbBuffer
)
811 TRACE("%p %ld %p %ld\n", phContext
, ulAttribute
, pBuffer
, cbBuffer
);
814 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
815 PCtxtHandle ctxt
= (PCtxtHandle
)phContext
->dwLower
;
817 if (package
&& package
->provider
&& pBuffer
&& cbBuffer
)
819 if (package
->provider
->fnTableW
.SetContextAttributesW
)
821 /* TODO: gotta validate size too! */
822 ret
= thunk_ContextAttributesWToA(package
, ulAttribute
,
825 ret
= package
->provider
->fnTableW
.SetContextAttributesW(
826 ctxt
, ulAttribute
, pBuffer
, cbBuffer
);
829 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
832 ret
= SEC_E_INVALID_HANDLE
;
835 ret
= SEC_E_INVALID_HANDLE
;
839 SECURITY_STATUS SEC_ENTRY
thunk_SetContextAttributesW(PCtxtHandle phContext
,
840 unsigned long ulAttribute
, void *pBuffer
, unsigned long cbBuffer
)
844 TRACE("%p %ld %p %ld\n", phContext
, ulAttribute
, pBuffer
, cbBuffer
);
847 SecurePackage
*package
= (SecurePackage
*)phContext
->dwUpper
;
848 PCtxtHandle ctxt
= (PCtxtHandle
)phContext
->dwLower
;
850 if (package
&& package
->provider
&& pBuffer
&& cbBuffer
)
852 if (package
->provider
->fnTableA
.SetContextAttributesA
)
854 /* TODO: gotta validate size too! */
855 ret
= thunk_ContextAttributesAToW(package
, ulAttribute
,
858 ret
= package
->provider
->fnTableA
.SetContextAttributesA(
859 ctxt
, ulAttribute
, pBuffer
, cbBuffer
);
862 ret
= SEC_E_UNSUPPORTED_FUNCTION
;
865 ret
= SEC_E_INVALID_HANDLE
;
868 ret
= SEC_E_INVALID_HANDLE
;
872 SECURITY_STATUS SEC_ENTRY
thunk_ImportSecurityContextA(
873 SEC_CHAR
*pszPackage
, PSecBuffer pPackedContext
, void *Token
,
874 PCtxtHandle phContext
)
877 UNICODE_STRING package
;
879 TRACE("%s %p %p %p\n", debugstr_a(pszPackage
), pPackedContext
, Token
,
881 RtlCreateUnicodeStringFromAsciiz(&package
, pszPackage
);
882 ret
= ImportSecurityContextW(package
.Buffer
, pPackedContext
, Token
,
884 RtlFreeUnicodeString(&package
);
888 SECURITY_STATUS SEC_ENTRY
thunk_ImportSecurityContextW(
889 SEC_WCHAR
*pszPackage
, PSecBuffer pPackedContext
, void *Token
,
890 PCtxtHandle phContext
)
893 PSTR package
= SECUR32_AllocMultiByteFromWide(pszPackage
);
895 TRACE("%s %p %p %p\n", debugstr_w(pszPackage
), pPackedContext
, Token
,
897 ret
= ImportSecurityContextA(package
, pPackedContext
, Token
, phContext
);
898 SECUR32_FREE(package
);