1 /* Copyright (C) 2004 Juan Lang
3 * This file implements loading of SSP DLLs.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include <wine/debug.h>
25 WINE_DEFAULT_DEBUG_CHANNEL(secur32
);
27 typedef struct _SecurePackageTable
34 typedef struct _SecureProviderTable
39 } SecureProviderTable
;
41 static CRITICAL_SECTION cs
;
42 static CRITICAL_SECTION_DEBUG cs_debug
=
45 { &cs_debug
.ProcessLocksList
, &cs_debug
.ProcessLocksList
},
46 0, 0, { (DWORD_PTR
)(__FILE__
": cs") }
48 static CRITICAL_SECTION cs
= { &cs_debug
, -1, 0, 0, 0, 0 };
49 static SecurePackageTable
*packageTable
= NULL
;
50 static SecureProviderTable
*providerTable
= NULL
;
52 static SecurityFunctionTableA securityFunctionTableA
=
54 SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION
,
55 EnumerateSecurityPackagesA
,
56 QueryCredentialsAttributesA
,
57 AcquireCredentialsHandleA
,
58 FreeCredentialsHandle
,
60 InitializeSecurityContextA
,
61 AcceptSecurityContext
,
63 DeleteSecurityContext
,
65 QueryContextAttributesA
,
66 ImpersonateSecurityContext
,
67 RevertSecurityContext
,
71 QuerySecurityPackageInfoA
,
72 EncryptMessage
, /* Reserved3 */
73 DecryptMessage
, /* Reserved4 */
74 ExportSecurityContext
,
75 ImportSecurityContextA
,
78 QuerySecurityContextToken
,
84 static SecurityFunctionTableW securityFunctionTableW
=
86 SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION
,
87 EnumerateSecurityPackagesW
,
88 QueryCredentialsAttributesW
,
89 AcquireCredentialsHandleW
,
90 FreeCredentialsHandle
,
92 InitializeSecurityContextW
,
93 AcceptSecurityContext
,
95 DeleteSecurityContext
,
97 QueryContextAttributesW
,
98 ImpersonateSecurityContext
,
99 RevertSecurityContext
,
103 QuerySecurityPackageInfoW
,
104 EncryptMessage
, /* Reserved3 */
105 DecryptMessage
, /* Reserved4 */
106 ExportSecurityContext
,
107 ImportSecurityContextW
,
109 NULL
, /* Reserved8 */
110 QuerySecurityContextToken
,
116 /***********************************************************************
117 * EnumerateSecurityPackagesW (SECUR32.@)
119 SECURITY_STATUS WINAPI
EnumerateSecurityPackagesW(PULONG pcPackages
,
120 PSecPkgInfoW
*ppPackageInfo
)
122 SECURITY_STATUS ret
= SEC_E_OK
;
124 TRACE("(%p, %p)\n", pcPackages
, ppPackageInfo
);
126 /* windows just crashes if pcPackages or ppPackageInfo is NULL, so will I */
128 EnterCriticalSection(&cs
);
131 SecurePackage
*package
;
134 bytesNeeded
= packageTable
->numPackages
* sizeof(SecPkgInfoW
);
135 LIST_FOR_EACH_ENTRY(package
, &packageTable
->table
, SecurePackage
, entry
)
137 if (package
->infoW
.Name
)
138 bytesNeeded
+= (lstrlenW(package
->infoW
.Name
) + 1) * sizeof(WCHAR
);
139 if (package
->infoW
.Comment
)
140 bytesNeeded
+= (lstrlenW(package
->infoW
.Comment
) + 1) * sizeof(WCHAR
);
144 *ppPackageInfo
= HeapAlloc(GetProcessHeap(), 0, bytesNeeded
);
150 *pcPackages
= packageTable
->numPackages
;
151 nextString
= (PWSTR
)((PBYTE
)*ppPackageInfo
+
152 packageTable
->numPackages
* sizeof(SecPkgInfoW
));
153 LIST_FOR_EACH_ENTRY(package
, &packageTable
->table
, SecurePackage
, entry
)
155 PSecPkgInfoW pkgInfo
= *ppPackageInfo
+ i
++;
157 *pkgInfo
= package
->infoW
;
158 if (package
->infoW
.Name
)
160 TRACE("Name[%d] = %S\n", i
- 1, package
->infoW
.Name
);
161 pkgInfo
->Name
= nextString
;
162 lstrcpyW(nextString
, package
->infoW
.Name
);
163 nextString
+= lstrlenW(nextString
) + 1;
166 pkgInfo
->Name
= NULL
;
167 if (package
->infoW
.Comment
)
169 TRACE("Comment[%d] = %S\n", i
- 1, package
->infoW
.Comment
);
170 pkgInfo
->Comment
= nextString
;
171 lstrcpyW(nextString
, package
->infoW
.Comment
);
172 nextString
+= lstrlenW(nextString
) + 1;
175 pkgInfo
->Comment
= NULL
;
179 ret
= SEC_E_INSUFFICIENT_MEMORY
;
182 LeaveCriticalSection(&cs
);
183 TRACE("<-- 0x%08x\n", ret
);
187 /* Converts info (which is assumed to be an array of cPackages SecPkgInfoW
188 * structures) into an array of SecPkgInfoA structures, which it returns.
190 static PSecPkgInfoA
thunk_PSecPkgInfoWToA(ULONG cPackages
,
191 const SecPkgInfoW
*info
)
197 size_t bytesNeeded
= cPackages
* sizeof(SecPkgInfoA
);
200 for (i
= 0; i
< cPackages
; i
++)
203 bytesNeeded
+= WideCharToMultiByte(CP_ACP
, 0, info
[i
].Name
,
204 -1, NULL
, 0, NULL
, NULL
);
206 bytesNeeded
+= WideCharToMultiByte(CP_ACP
, 0, info
[i
].Comment
,
207 -1, NULL
, 0, NULL
, NULL
);
209 ret
= HeapAlloc(GetProcessHeap(), 0, bytesNeeded
);
214 nextString
= (PSTR
)((PBYTE
)ret
+ cPackages
* sizeof(SecPkgInfoA
));
215 for (i
= 0; i
< cPackages
; i
++)
217 PSecPkgInfoA pkgInfo
= ret
+ i
;
220 memcpy(pkgInfo
, &info
[i
], sizeof(SecPkgInfoA
));
223 pkgInfo
->Name
= nextString
;
224 /* just repeat back to WideCharToMultiByte how many bytes
225 * it requires, since we asked it earlier
227 bytes
= WideCharToMultiByte(CP_ACP
, 0, info
[i
].Name
, -1,
228 NULL
, 0, NULL
, NULL
);
229 WideCharToMultiByte(CP_ACP
, 0, info
[i
].Name
, -1,
230 pkgInfo
->Name
, bytes
, NULL
, NULL
);
231 nextString
+= lstrlenA(nextString
) + 1;
234 pkgInfo
->Name
= NULL
;
237 pkgInfo
->Comment
= nextString
;
238 /* just repeat back to WideCharToMultiByte how many bytes
239 * it requires, since we asked it earlier
241 bytes
= WideCharToMultiByte(CP_ACP
, 0, info
[i
].Comment
, -1,
242 NULL
, 0, NULL
, NULL
);
243 WideCharToMultiByte(CP_ACP
, 0, info
[i
].Comment
, -1,
244 pkgInfo
->Comment
, bytes
, NULL
, NULL
);
245 nextString
+= lstrlenA(nextString
) + 1;
248 pkgInfo
->Comment
= NULL
;
257 /***********************************************************************
258 * EnumerateSecurityPackagesA (SECUR32.@)
260 SECURITY_STATUS WINAPI
EnumerateSecurityPackagesA(PULONG pcPackages
,
261 PSecPkgInfoA
*ppPackageInfo
)
266 ret
= EnumerateSecurityPackagesW(pcPackages
, &info
);
267 if (ret
== SEC_E_OK
&& *pcPackages
&& info
)
269 *ppPackageInfo
= thunk_PSecPkgInfoWToA(*pcPackages
, info
);
270 if (*pcPackages
&& !*ppPackageInfo
)
273 ret
= SEC_E_INSUFFICIENT_MEMORY
;
275 FreeContextBuffer(info
);
286 HeapFree(GetProcessHeap(), 0, pvoid
);
290 PSecurityFunctionTableW
292 InitSecurityInterfaceW(VOID
)
294 TRACE("InitSecurityInterfaceW() called\n");
295 return &securityFunctionTableW
;
298 PSecurityFunctionTableA
300 InitSecurityInterfaceA(VOID
)
302 TRACE("InitSecurityInterfaceA() called\n");
303 return &securityFunctionTableA
;
309 LPCSTR lpAccountName
,
310 EXTENDED_NAME_FORMAT AccountNameFormat
,
311 EXTENDED_NAME_FORMAT DesiredNameFormat
,
312 LPSTR lpTranslatedName
,
323 LPCWSTR lpAccountName
,
324 EXTENDED_NAME_FORMAT AccountNameFormat
,
325 EXTENDED_NAME_FORMAT DesiredNameFormat
,
326 LPWSTR lpTranslatedName
,
334 /*** PRIVATE FUNCTIONS ***************************************************************************/
336 static PWSTR
SECUR32_strdupW(PCWSTR str
)
342 ret
= HeapAlloc(GetProcessHeap(), 0, (lstrlenW(str
) + 1) * sizeof(WCHAR
));
351 PWSTR
SECUR32_AllocWideFromMultiByte(PCSTR str
)
357 int charsNeeded
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
361 ret
= HeapAlloc(GetProcessHeap(), 0, charsNeeded
* sizeof(WCHAR
));
363 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, charsNeeded
);
373 PSTR
SECUR32_AllocMultiByteFromWide(PCWSTR str
)
379 int charsNeeded
= WideCharToMultiByte(CP_ACP
, 0, str
, -1, NULL
, 0,
384 ret
= HeapAlloc(GetProcessHeap(), 0, charsNeeded
);
386 WideCharToMultiByte(CP_ACP
, 0, str
, -1, ret
, charsNeeded
,
397 static void _makeFnTableA(PSecurityFunctionTableA fnTableA
,
398 const SecurityFunctionTableA
*inFnTableA
,
399 const SecurityFunctionTableW
*inFnTableW
)
405 /* The size of the version 1 table is based on platform sdk's
406 * sspi.h, though the sample ssp also provided with platform sdk
407 * implies only functions through QuerySecurityPackageInfoA are
408 * implemented (yikes)
410 size_t tableSize
= inFnTableA
->dwVersion
== 1 ?
411 (const BYTE
*)&inFnTableA
->SetContextAttributesA
-
412 (const BYTE
*)inFnTableA
: sizeof(SecurityFunctionTableA
);
414 memcpy(fnTableA
, inFnTableA
, tableSize
);
415 /* override this, since we can do it internally anyway */
416 fnTableA
->QuerySecurityPackageInfoA
=
417 QuerySecurityPackageInfoA
;
421 /* functions with thunks */
422 if (inFnTableW
->AcquireCredentialsHandleW
)
423 fnTableA
->AcquireCredentialsHandleA
=
424 thunk_AcquireCredentialsHandleA
;
425 if (inFnTableW
->InitializeSecurityContextW
)
426 fnTableA
->InitializeSecurityContextA
=
427 thunk_InitializeSecurityContextA
;
428 if (inFnTableW
->ImportSecurityContextW
)
429 fnTableA
->ImportSecurityContextA
=
430 thunk_ImportSecurityContextA
;
431 if (inFnTableW
->AddCredentialsW
)
432 fnTableA
->AddCredentialsA
=
433 thunk_AddCredentialsA
;
434 if (inFnTableW
->QueryCredentialsAttributesW
)
435 fnTableA
->QueryCredentialsAttributesA
=
436 thunk_QueryCredentialsAttributesA
;
437 if (inFnTableW
->QueryContextAttributesW
)
438 fnTableA
->QueryContextAttributesA
=
439 thunk_QueryContextAttributesA
;
440 if (inFnTableW
->SetContextAttributesW
)
441 fnTableA
->SetContextAttributesA
=
442 thunk_SetContextAttributesA
;
443 /* this can't be thunked, there's no extra param to know which
444 * package to forward to */
445 fnTableA
->EnumerateSecurityPackagesA
= NULL
;
446 /* functions with no thunks needed */
447 fnTableA
->AcceptSecurityContext
= inFnTableW
->AcceptSecurityContext
;
448 fnTableA
->CompleteAuthToken
= inFnTableW
->CompleteAuthToken
;
449 fnTableA
->DeleteSecurityContext
= inFnTableW
->DeleteSecurityContext
;
450 fnTableA
->ImpersonateSecurityContext
=
451 inFnTableW
->ImpersonateSecurityContext
;
452 fnTableA
->RevertSecurityContext
= inFnTableW
->RevertSecurityContext
;
453 fnTableA
->MakeSignature
= inFnTableW
->MakeSignature
;
454 fnTableA
->VerifySignature
= inFnTableW
->VerifySignature
;
455 fnTableA
->FreeContextBuffer
= inFnTableW
->FreeContextBuffer
;
456 fnTableA
->QuerySecurityPackageInfoA
=
457 QuerySecurityPackageInfoA
;
458 fnTableA
->ExportSecurityContext
=
459 inFnTableW
->ExportSecurityContext
;
460 fnTableA
->QuerySecurityContextToken
=
461 inFnTableW
->QuerySecurityContextToken
;
462 fnTableA
->EncryptMessage
= inFnTableW
->EncryptMessage
;
463 fnTableA
->DecryptMessage
= inFnTableW
->DecryptMessage
;
468 static void _makeFnTableW(PSecurityFunctionTableW fnTableW
,
469 const SecurityFunctionTableA
*inFnTableA
,
470 const SecurityFunctionTableW
*inFnTableW
)
476 /* The size of the version 1 table is based on platform sdk's
477 * sspi.h, though the sample ssp also provided with platform sdk
478 * implies only functions through QuerySecurityPackageInfoA are
479 * implemented (yikes)
481 size_t tableSize
= inFnTableW
->dwVersion
== 1 ?
482 (const BYTE
*)&inFnTableW
->SetContextAttributesW
-
483 (const BYTE
*)inFnTableW
: sizeof(SecurityFunctionTableW
);
485 memcpy(fnTableW
, inFnTableW
, tableSize
);
486 /* override this, since we can do it internally anyway */
487 fnTableW
->QuerySecurityPackageInfoW
=
488 QuerySecurityPackageInfoW
;
492 /* functions with thunks */
493 if (inFnTableA
->AcquireCredentialsHandleA
)
494 fnTableW
->AcquireCredentialsHandleW
=
495 thunk_AcquireCredentialsHandleW
;
496 if (inFnTableA
->InitializeSecurityContextA
)
497 fnTableW
->InitializeSecurityContextW
=
498 thunk_InitializeSecurityContextW
;
499 if (inFnTableA
->ImportSecurityContextA
)
500 fnTableW
->ImportSecurityContextW
=
501 thunk_ImportSecurityContextW
;
502 if (inFnTableA
->AddCredentialsA
)
503 fnTableW
->AddCredentialsW
=
504 thunk_AddCredentialsW
;
505 if (inFnTableA
->QueryCredentialsAttributesA
)
506 fnTableW
->QueryCredentialsAttributesW
=
507 thunk_QueryCredentialsAttributesW
;
508 if (inFnTableA
->QueryContextAttributesA
)
509 fnTableW
->QueryContextAttributesW
=
510 thunk_QueryContextAttributesW
;
511 if (inFnTableA
->SetContextAttributesA
)
512 fnTableW
->SetContextAttributesW
=
513 thunk_SetContextAttributesW
;
514 /* this can't be thunked, there's no extra param to know which
515 * package to forward to */
516 fnTableW
->EnumerateSecurityPackagesW
= NULL
;
517 /* functions with no thunks needed */
518 fnTableW
->AcceptSecurityContext
= inFnTableA
->AcceptSecurityContext
;
519 fnTableW
->CompleteAuthToken
= inFnTableA
->CompleteAuthToken
;
520 fnTableW
->DeleteSecurityContext
= inFnTableA
->DeleteSecurityContext
;
521 fnTableW
->ImpersonateSecurityContext
=
522 inFnTableA
->ImpersonateSecurityContext
;
523 fnTableW
->RevertSecurityContext
= inFnTableA
->RevertSecurityContext
;
524 fnTableW
->MakeSignature
= inFnTableA
->MakeSignature
;
525 fnTableW
->VerifySignature
= inFnTableA
->VerifySignature
;
526 fnTableW
->FreeContextBuffer
= inFnTableA
->FreeContextBuffer
;
527 fnTableW
->QuerySecurityPackageInfoW
=
528 QuerySecurityPackageInfoW
;
529 fnTableW
->ExportSecurityContext
=
530 inFnTableA
->ExportSecurityContext
;
531 fnTableW
->QuerySecurityContextToken
=
532 inFnTableA
->QuerySecurityContextToken
;
533 fnTableW
->EncryptMessage
= inFnTableA
->EncryptMessage
;
534 fnTableW
->DecryptMessage
= inFnTableA
->DecryptMessage
;
539 static void _copyPackageInfo(PSecPkgInfoW info
, const SecPkgInfoA
*inInfoA
,
540 const SecPkgInfoW
*inInfoW
)
542 if (info
&& (inInfoA
|| inInfoW
))
544 /* odd, I know, but up until Name and Comment the structures are
547 memcpy(info
, inInfoW
? inInfoW
: (const SecPkgInfoW
*)inInfoA
, sizeof(*info
));
550 info
->Name
= SECUR32_strdupW(inInfoW
->Name
);
551 info
->Comment
= SECUR32_strdupW(inInfoW
->Comment
);
555 info
->Name
= SECUR32_AllocWideFromMultiByte(inInfoA
->Name
);
556 info
->Comment
= SECUR32_AllocWideFromMultiByte(inInfoA
->Comment
);
562 SecureProvider
*SECUR32_addProvider(const SecurityFunctionTableA
*fnTableA
,
563 const SecurityFunctionTableW
*fnTableW
, PCWSTR moduleName
)
567 EnterCriticalSection(&cs
);
571 providerTable
= HeapAlloc(GetProcessHeap(), 0, sizeof(SecureProviderTable
));
574 LeaveCriticalSection(&cs
);
578 list_init(&providerTable
->table
);
581 ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(SecureProvider
));
584 LeaveCriticalSection(&cs
);
588 list_add_tail(&providerTable
->table
, &ret
->entry
);
591 if (fnTableA
|| fnTableW
)
593 ret
->moduleName
= moduleName
? SECUR32_strdupW(moduleName
) : NULL
;
594 _makeFnTableA(&ret
->fnTableA
, fnTableA
, fnTableW
);
595 _makeFnTableW(&ret
->fnTableW
, fnTableA
, fnTableW
);
596 ret
->loaded
= !moduleName
;
600 ret
->moduleName
= SECUR32_strdupW(moduleName
);
604 LeaveCriticalSection(&cs
);
609 void SECUR32_addPackages(SecureProvider
*provider
, ULONG toAdd
,
610 const SecPkgInfoA
*infoA
, const SecPkgInfoW
*infoW
)
615 assert(infoA
|| infoW
);
617 EnterCriticalSection(&cs
);
621 packageTable
= HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackageTable
));
624 LeaveCriticalSection(&cs
);
628 packageTable
->numPackages
= 0;
629 list_init(&packageTable
->table
);
632 for (i
= 0; i
< toAdd
; i
++)
634 SecurePackage
*package
= HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackage
));
638 list_add_tail(&packageTable
->table
, &package
->entry
);
640 package
->provider
= provider
;
641 _copyPackageInfo(&package
->infoW
,
642 infoA
? &infoA
[i
] : NULL
,
643 infoW
? &infoW
[i
] : NULL
);
645 packageTable
->numPackages
+= toAdd
;
647 LeaveCriticalSection(&cs
);
650 static void _tryLoadProvider(PWSTR moduleName
)
652 HMODULE lib
= LoadLibraryW(moduleName
);
656 INIT_SECURITY_INTERFACE_W pInitSecurityInterfaceW
=
657 (INIT_SECURITY_INTERFACE_W
)GetProcAddress(lib
,
658 SECURITY_ENTRYPOINT_ANSIW
);
659 INIT_SECURITY_INTERFACE_A pInitSecurityInterfaceA
=
660 (INIT_SECURITY_INTERFACE_A
)GetProcAddress(lib
,
661 SECURITY_ENTRYPOINT_ANSIA
);
663 TRACE("loaded %S, InitSecurityInterfaceA is %p, InitSecurityInterfaceW is %p\n",
664 moduleName
, pInitSecurityInterfaceA
,
665 pInitSecurityInterfaceW
);
666 if (pInitSecurityInterfaceW
|| pInitSecurityInterfaceA
)
668 PSecurityFunctionTableA fnTableA
= NULL
;
669 PSecurityFunctionTableW fnTableW
= NULL
;
671 PSecPkgInfoA infoA
= NULL
;
672 PSecPkgInfoW infoW
= NULL
;
673 SECURITY_STATUS ret
= SEC_E_OK
;
675 if (pInitSecurityInterfaceA
)
676 fnTableA
= pInitSecurityInterfaceA();
677 if (pInitSecurityInterfaceW
)
678 fnTableW
= pInitSecurityInterfaceW();
679 if (fnTableW
&& fnTableW
->EnumerateSecurityPackagesW
)
681 if (fnTableW
!= &securityFunctionTableW
)
682 ret
= fnTableW
->EnumerateSecurityPackagesW(&toAdd
, &infoW
);
684 TRACE("%S has built-in providers, skip adding\n", moduleName
);
686 else if (fnTableA
&& fnTableA
->EnumerateSecurityPackagesA
)
688 if (fnTableA
!= &securityFunctionTableA
)
689 ret
= fnTableA
->EnumerateSecurityPackagesA(&toAdd
, &infoA
);
691 TRACE("%S has built-in providers, skip adding\n", moduleName
);
693 if (ret
== SEC_E_OK
&& toAdd
> 0 && (infoW
|| infoA
))
695 SecureProvider
*provider
= SECUR32_addProvider(NULL
, NULL
,
699 SECUR32_addPackages(provider
, toAdd
, infoA
, infoW
);
701 fnTableW
->FreeContextBuffer(infoW
);
703 fnTableA
->FreeContextBuffer(infoA
);
709 WARN("failed to load %S\n", moduleName
);
712 static const WCHAR securityProvidersKeyW
[] = {
713 'S','Y','S','T','E','M','\\','C','u','r','r','e','n','t','C','o','n','t','r',
714 'o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','S','e','c','u','r',
715 'i','t','y','P','r','o','v','i','d','e','r','s','\0'
717 static const WCHAR securityProvidersW
[] = {
718 'S','e','c','u','r','i','t','y','P','r','o','v','i','d','e','r','s',0
721 static void SECUR32_initializeProviders(void)
726 /* Now load providers from registry */
727 apiRet
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, securityProvidersKeyW
, 0,
729 if (apiRet
== ERROR_SUCCESS
)
731 WCHAR securityPkgNames
[MAX_PATH
]; /* arbitrary len */
732 DWORD size
= sizeof(securityPkgNames
) / sizeof(WCHAR
), type
;
734 apiRet
= RegQueryValueExW(key
, securityProvidersW
, NULL
, &type
,
735 (PBYTE
)securityPkgNames
, &size
);
736 if (apiRet
== ERROR_SUCCESS
&& type
== REG_SZ
)
740 size
= size
/ sizeof(WCHAR
);
741 for (ptr
= securityPkgNames
;
742 ptr
< securityPkgNames
+ size
; )
746 for (comma
= ptr
; *comma
&& *comma
!= ','; comma
++)
750 for (; *ptr
&& isspace(*ptr
) && ptr
< securityPkgNames
+ size
;
754 _tryLoadProvider(ptr
);
755 ptr
+= lstrlenW(ptr
) + 1;
762 SecurePackage
*SECUR32_findPackageW(PCWSTR packageName
)
764 SecurePackage
*ret
= NULL
;
765 BOOL matched
= FALSE
;
768 SECUR32_initializeProviders();
770 if (packageTable
&& packageName
)
772 LIST_FOR_EACH_ENTRY(ret
, &packageTable
->table
, SecurePackage
, entry
)
774 matched
= !lstrcmpiW(ret
->infoW
.Name
, packageName
);
782 if (ret
->provider
&& !ret
->provider
->loaded
)
784 ret
->provider
->lib
= LoadLibraryW(ret
->provider
->moduleName
);
785 if (ret
->provider
->lib
)
787 INIT_SECURITY_INTERFACE_W pInitSecurityInterfaceW
=
788 (INIT_SECURITY_INTERFACE_W
) GetProcAddress(ret
->provider
->lib
,
789 SECURITY_ENTRYPOINT_ANSIW
);
790 INIT_SECURITY_INTERFACE_A pInitSecurityInterfaceA
=
791 (INIT_SECURITY_INTERFACE_A
) GetProcAddress(ret
->provider
->lib
,
792 SECURITY_ENTRYPOINT_ANSIA
);
793 PSecurityFunctionTableA fnTableA
= NULL
;
794 PSecurityFunctionTableW fnTableW
= NULL
;
796 if (pInitSecurityInterfaceA
)
797 fnTableA
= pInitSecurityInterfaceA();
798 if (pInitSecurityInterfaceW
)
799 fnTableW
= pInitSecurityInterfaceW();
800 /* don't update built-in SecurityFunctionTable */
801 if (fnTableA
!= &securityFunctionTableA
)
802 _makeFnTableA(&ret
->provider
->fnTableA
, fnTableA
, fnTableW
);
803 if (fnTableW
!= &securityFunctionTableW
)
804 _makeFnTableW(&ret
->provider
->fnTableW
, fnTableA
, fnTableW
);
805 ret
->provider
->loaded
= TRUE
;
814 SecurePackage
*SECUR32_findPackageA(PCSTR packageName
)
820 UNICODE_STRING package
;
822 RtlCreateUnicodeStringFromAsciiz(&package
, packageName
);
823 ret
= SECUR32_findPackageW(package
.Buffer
);
824 RtlFreeUnicodeString(&package
);