ReactOS 0.4.16-dev-292-gbbdcc14
sspi.c File Reference
#include "precomp.h"
#include <assert.h>
#include <lsass/lsass.h>
#include <wine/debug.h>
Include dependency graph for sspi.c:

Go to the source code of this file.

Classes

struct  _SecurePackageTable
 
struct  _SecureProviderTable
 

Macros

#define UNLEN   256
 

Typedefs

typedef struct _SecurePackageTable SecurePackageTable
 
typedef struct _SecureProviderTable SecureProviderTable
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (secur32)
 
static void SECUR32_initializeProviders (void)
 
void SECUR32_freeProviders (void)
 
PSecurityFunctionTableA WINAPI InitSecurityInterfaceA (void)
 
PSecurityFunctionTableW WINAPI InitSecurityInterfaceW (void)
 
static PWSTR SECUR32_strdupW (PCWSTR str)
 
PWSTR SECUR32_AllocWideFromMultiByte (PCSTR str)
 
PSTR SECUR32_AllocMultiByteFromWide (PCWSTR str)
 
static void _makeFnTableA (PSecurityFunctionTableA fnTableA, const SecurityFunctionTableA *inFnTableA, const SecurityFunctionTableW *inFnTableW)
 
static void _makeFnTableW (PSecurityFunctionTableW fnTableW, const SecurityFunctionTableA *inFnTableA, const SecurityFunctionTableW *inFnTableW)
 
static void _copyPackageInfo (PSecPkgInfoW info, const SecPkgInfoA *inInfoA, const SecPkgInfoW *inInfoW)
 
SecureProviderSECUR32_addProvider (const SecurityFunctionTableA *fnTableA, const SecurityFunctionTableW *fnTableW, PCWSTR moduleName)
 
void SECUR32_addPackages (SecureProvider *provider, ULONG toAdd, const SecPkgInfoA *infoA, const SecPkgInfoW *infoW)
 
static void _tryLoadProvider (PWSTR moduleName)
 
SecurePackageSECUR32_findPackageW (PCWSTR packageName)
 
SecurePackageSECUR32_findPackageA (PCSTR packageName)
 
SECURITY_STATUS WINAPI FreeContextBuffer (PVOID pv)
 
SECURITY_STATUS WINAPI EnumerateSecurityPackagesW (PULONG pcPackages, PSecPkgInfoW *ppPackageInfo)
 
static PSecPkgInfoA thunk_PSecPkgInfoWToA (ULONG cPackages, const SecPkgInfoW *info)
 
SECURITY_STATUS WINAPI EnumerateSecurityPackagesA (PULONG pcPackages, PSecPkgInfoA *ppPackageInfo)
 
BOOLEAN WINAPI GetComputerObjectNameA (EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG nSize)
 
BOOLEAN WINAPI GetComputerObjectNameW (EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize)
 
BOOLEAN WINAPI GetUserNameExA (EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG nSize)
 
BOOLEAN WINAPI GetUserNameExW (EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize)
 
BOOLEAN WINAPI TranslateNameA (LPCSTR lpAccountName, EXTENDED_NAME_FORMAT AccountNameFormat, EXTENDED_NAME_FORMAT DesiredNameFormat, LPSTR lpTranslatedName, PULONG nSize)
 
BOOLEAN WINAPI TranslateNameW (LPCWSTR lpAccountName, EXTENDED_NAME_FORMAT AccountNameFormat, EXTENDED_NAME_FORMAT DesiredNameFormat, LPWSTR lpTranslatedName, PULONG nSize)
 

Variables

static CRITICAL_SECTION cs = { &cs_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG cs_debug
 
static SecurePackageTablepackageTable = NULL
 
static SecureProviderTableproviderTable = NULL
 
static SecurityFunctionTableA securityFunctionTableA
 
static SecurityFunctionTableW securityFunctionTableW
 
static const WCHAR securityProvidersKeyW []
 
static const WCHAR securityProvidersW []
 

Macro Definition Documentation

◆ UNLEN

#define UNLEN   256

Definition at line 28 of file sspi.c.

Typedef Documentation

◆ SecurePackageTable

◆ SecureProviderTable

Function Documentation

◆ _copyPackageInfo()

static void _copyPackageInfo ( PSecPkgInfoW  info,
const SecPkgInfoA inInfoA,
const SecPkgInfoW inInfoW 
)
static

Definition at line 341 of file sspi.c.

343{
344 if (info && (inInfoA || inInfoW))
345 {
346 /* odd, I know, but up until Name and Comment the structures are
347 * identical
348 */
349 memcpy(info, inInfoW ? inInfoW : (const SecPkgInfoW *)inInfoA, sizeof(*info));
350 if (inInfoW)
351 {
352 info->Name = SECUR32_strdupW(inInfoW->Name);
353 info->Comment = SECUR32_strdupW(inInfoW->Comment);
354 }
355 else
356 {
357 info->Name = SECUR32_AllocWideFromMultiByte(inInfoA->Name);
358 info->Comment = SECUR32_AllocWideFromMultiByte(inInfoA->Comment);
359 }
360 }
361}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PWSTR SECUR32_strdupW(PCWSTR str)
Definition: sspi.c:138
PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str)
Definition: sspi.c:153
SEC_WCHAR * Comment
Definition: sspi.h:119
SEC_WCHAR * Name
Definition: sspi.h:118

◆ _makeFnTableA()

static void _makeFnTableA ( PSecurityFunctionTableA  fnTableA,
const SecurityFunctionTableA inFnTableA,
const SecurityFunctionTableW inFnTableW 
)
static

Definition at line 199 of file sspi.c.

202{
203 if (fnTableA)
204 {
205 if (inFnTableA)
206 {
207 /* The size of the version 1 table is based on platform sdk's
208 * sspi.h, though the sample ssp also provided with platform sdk
209 * implies only functions through QuerySecurityPackageInfoA are
210 * implemented (yikes)
211 */
212 size_t tableSize = inFnTableA->dwVersion == 1 ?
213 (const BYTE *)&inFnTableA->SetContextAttributesA -
214 (const BYTE *)inFnTableA : sizeof(SecurityFunctionTableA);
215
216 memcpy(fnTableA, inFnTableA, tableSize);
217 /* override this, since we can do it internally anyway */
218 fnTableA->QuerySecurityPackageInfoA =
220 }
221 else if (inFnTableW)
222 {
223 /* functions with thunks */
224 if (inFnTableW->AcquireCredentialsHandleW)
225 fnTableA->AcquireCredentialsHandleA =
227 if (inFnTableW->InitializeSecurityContextW)
230 if (inFnTableW->ImportSecurityContextW)
231 fnTableA->ImportSecurityContextA =
233 if (inFnTableW->AddCredentialsW)
234 fnTableA->AddCredentialsA =
236 if (inFnTableW->QueryCredentialsAttributesW)
239 if (inFnTableW->QueryContextAttributesW)
240 fnTableA->QueryContextAttributesA =
242 if (inFnTableW->SetContextAttributesW)
243 fnTableA->SetContextAttributesA =
245 /* this can't be thunked, there's no extra param to know which
246 * package to forward to */
248 /* functions with no thunks needed */
249 fnTableA->AcceptSecurityContext = inFnTableW->AcceptSecurityContext;
250 fnTableA->CompleteAuthToken = inFnTableW->CompleteAuthToken;
251 fnTableA->DeleteSecurityContext = inFnTableW->DeleteSecurityContext;
253 inFnTableW->ImpersonateSecurityContext;
254 fnTableA->RevertSecurityContext = inFnTableW->RevertSecurityContext;
255 fnTableA->MakeSignature = inFnTableW->MakeSignature;
256 fnTableA->VerifySignature = inFnTableW->VerifySignature;
257 fnTableA->FreeContextBuffer = inFnTableW->FreeContextBuffer;
258 fnTableA->QuerySecurityPackageInfoA =
260 fnTableA->ExportSecurityContext =
261 inFnTableW->ExportSecurityContext;
262 fnTableA->QuerySecurityContextToken =
263 inFnTableW->QuerySecurityContextToken;
264 fnTableA->EncryptMessage = inFnTableW->EncryptMessage;
265 fnTableA->DecryptMessage = inFnTableW->DecryptMessage;
266 }
267 }
268}
#define NULL
Definition: types.h:112
struct _SECURITY_FUNCTION_TABLE_A SecurityFunctionTableA
DELETE_SECURITY_CONTEXT_FN DeleteSecurityContext
Definition: sspi.h:964
FREE_CONTEXT_BUFFER_FN FreeContextBuffer
Definition: sspi.h:971
QUERY_SECURITY_PACKAGE_INFO_FN_A QuerySecurityPackageInfoA
Definition: sspi.h:972
QUERY_SECURITY_CONTEXT_TOKEN_FN QuerySecurityContextToken
Definition: sspi.h:979
ACQUIRE_CREDENTIALS_HANDLE_FN_A AcquireCredentialsHandleA
Definition: sspi.h:958
INITIALIZE_SECURITY_CONTEXT_FN_A InitializeSecurityContextA
Definition: sspi.h:961
EXPORT_SECURITY_CONTEXT_FN ExportSecurityContext
Definition: sspi.h:975
IMPORT_SECURITY_CONTEXT_FN_A ImportSecurityContextA
Definition: sspi.h:976
ENCRYPT_MESSAGE_FN EncryptMessage
Definition: sspi.h:980
VERIFY_SIGNATURE_FN VerifySignature
Definition: sspi.h:970
IMPERSONATE_SECURITY_CONTEXT_FN ImpersonateSecurityContext
Definition: sspi.h:967
MAKE_SIGNATURE_FN MakeSignature
Definition: sspi.h:969
REVERT_SECURITY_CONTEXT_FN RevertSecurityContext
Definition: sspi.h:968
ADD_CREDENTIALS_FN_A AddCredentialsA
Definition: sspi.h:977
ENUMERATE_SECURITY_PACKAGES_FN_A EnumerateSecurityPackagesA
Definition: sspi.h:956
QUERY_CREDENTIALS_ATTRIBUTES_FN_A QueryCredentialsAttributesA
Definition: sspi.h:957
COMPLETE_AUTH_TOKEN_FN CompleteAuthToken
Definition: sspi.h:963
SET_CONTEXT_ATTRIBUTES_FN_A SetContextAttributesA
Definition: sspi.h:982
DECRYPT_MESSAGE_FN DecryptMessage
Definition: sspi.h:981
ACCEPT_SECURITY_CONTEXT_FN AcceptSecurityContext
Definition: sspi.h:962
QUERY_CONTEXT_ATTRIBUTES_FN_A QueryContextAttributesA
Definition: sspi.h:966
ACCEPT_SECURITY_CONTEXT_FN AcceptSecurityContext
Definition: sspi.h:997
INITIALIZE_SECURITY_CONTEXT_FN_W InitializeSecurityContextW
Definition: sspi.h:996
DELETE_SECURITY_CONTEXT_FN DeleteSecurityContext
Definition: sspi.h:999
QUERY_SECURITY_CONTEXT_TOKEN_FN QuerySecurityContextToken
Definition: sspi.h:1014
ENCRYPT_MESSAGE_FN EncryptMessage
Definition: sspi.h:1015
VERIFY_SIGNATURE_FN VerifySignature
Definition: sspi.h:1005
EXPORT_SECURITY_CONTEXT_FN ExportSecurityContext
Definition: sspi.h:1010
ADD_CREDENTIALS_FN_W AddCredentialsW
Definition: sspi.h:1012
SET_CONTEXT_ATTRIBUTES_FN_W SetContextAttributesW
Definition: sspi.h:1017
ACQUIRE_CREDENTIALS_HANDLE_FN_W AcquireCredentialsHandleW
Definition: sspi.h:993
DECRYPT_MESSAGE_FN DecryptMessage
Definition: sspi.h:1016
FREE_CONTEXT_BUFFER_FN FreeContextBuffer
Definition: sspi.h:1006
COMPLETE_AUTH_TOKEN_FN CompleteAuthToken
Definition: sspi.h:998
REVERT_SECURITY_CONTEXT_FN RevertSecurityContext
Definition: sspi.h:1003
IMPORT_SECURITY_CONTEXT_FN_W ImportSecurityContextW
Definition: sspi.h:1011
MAKE_SIGNATURE_FN MakeSignature
Definition: sspi.h:1004
QUERY_CONTEXT_ATTRIBUTES_FN_W QueryContextAttributesW
Definition: sspi.h:1001
QUERY_CREDENTIALS_ATTRIBUTES_FN_W QueryCredentialsAttributesW
Definition: sspi.h:992
IMPERSONATE_SECURITY_CONTEXT_FN ImpersonateSecurityContext
Definition: sspi.h:1002
SECURITY_STATUS SEC_ENTRY thunk_ImportSecurityContextA(SEC_CHAR *pszPackage, PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
Definition: thunks.c:864
SECURITY_STATUS SEC_ENTRY thunk_SetContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
Definition: thunks.c:798
SECURITY_STATUS SEC_ENTRY thunk_AddCredentialsA(PCredHandle hCredentials, SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument, PTimeStamp ptsExpiry)
Definition: thunks.c:268
SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleA(SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: thunks.c:26
SECURITY_STATUS SEC_ENTRY thunk_QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
Definition: thunks.c:83
SECURITY_STATUS SEC_ENTRY thunk_QueryContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: thunks.c:540
SECURITY_STATUS SEC_ENTRY thunk_InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext, SEC_CHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: thunks.c:189
SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName, PSecPkgInfoA *ppPackageInfo)
Definition: wrapper.c:683
unsigned char BYTE
Definition: xxhash.c:193

Referenced by SECUR32_addProvider(), and SECUR32_findPackageW().

◆ _makeFnTableW()

static void _makeFnTableW ( PSecurityFunctionTableW  fnTableW,
const SecurityFunctionTableA inFnTableA,
const SecurityFunctionTableW inFnTableW 
)
static

Definition at line 270 of file sspi.c.

273{
274 if (fnTableW)
275 {
276 if (inFnTableW)
277 {
278 /* The size of the version 1 table is based on platform sdk's
279 * sspi.h, though the sample ssp also provided with platform sdk
280 * implies only functions through QuerySecurityPackageInfoA are
281 * implemented (yikes)
282 */
283 size_t tableSize = inFnTableW->dwVersion == 1 ?
284 (const BYTE *)&inFnTableW->SetContextAttributesW -
285 (const BYTE *)inFnTableW : sizeof(SecurityFunctionTableW);
286
287 memcpy(fnTableW, inFnTableW, tableSize);
288 /* override this, since we can do it internally anyway */
289 fnTableW->QuerySecurityPackageInfoW =
291 }
292 else if (inFnTableA)
293 {
294 /* functions with thunks */
295 if (inFnTableA->AcquireCredentialsHandleA)
296 fnTableW->AcquireCredentialsHandleW =
298 if (inFnTableA->InitializeSecurityContextA)
301 if (inFnTableA->ImportSecurityContextA)
302 fnTableW->ImportSecurityContextW =
304 if (inFnTableA->AddCredentialsA)
305 fnTableW->AddCredentialsW =
307 if (inFnTableA->QueryCredentialsAttributesA)
310 if (inFnTableA->QueryContextAttributesA)
311 fnTableW->QueryContextAttributesW =
313 if (inFnTableA->SetContextAttributesA)
314 fnTableW->SetContextAttributesW =
316 /* this can't be thunked, there's no extra param to know which
317 * package to forward to */
319 /* functions with no thunks needed */
320 fnTableW->AcceptSecurityContext = inFnTableA->AcceptSecurityContext;
321 fnTableW->CompleteAuthToken = inFnTableA->CompleteAuthToken;
322 fnTableW->DeleteSecurityContext = inFnTableA->DeleteSecurityContext;
324 inFnTableA->ImpersonateSecurityContext;
325 fnTableW->RevertSecurityContext = inFnTableA->RevertSecurityContext;
326 fnTableW->MakeSignature = inFnTableA->MakeSignature;
327 fnTableW->VerifySignature = inFnTableA->VerifySignature;
328 fnTableW->FreeContextBuffer = inFnTableA->FreeContextBuffer;
329 fnTableW->QuerySecurityPackageInfoW =
331 fnTableW->ExportSecurityContext =
332 inFnTableA->ExportSecurityContext;
333 fnTableW->QuerySecurityContextToken =
334 inFnTableA->QuerySecurityContextToken;
335 fnTableW->EncryptMessage = inFnTableA->EncryptMessage;
336 fnTableW->DecryptMessage = inFnTableA->DecryptMessage;
337 }
338 }
339}
struct _SECURITY_FUNCTION_TABLE_W SecurityFunctionTableW
QUERY_SECURITY_PACKAGE_INFO_FN_W QuerySecurityPackageInfoW
Definition: sspi.h:1007
ENUMERATE_SECURITY_PACKAGES_FN_W EnumerateSecurityPackagesW
Definition: sspi.h:991
SECURITY_STATUS SEC_ENTRY thunk_AddCredentialsW(PCredHandle hCredentials, SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument, PTimeStamp ptsExpiry)
Definition: thunks.c:308
SECURITY_STATUS SEC_ENTRY thunk_InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: thunks.c:229
SECURITY_STATUS SEC_ENTRY thunk_SetContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer, ULONG cbBuffer)
Definition: thunks.c:831
SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: thunks.c:53
SECURITY_STATUS SEC_ENTRY thunk_QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
Definition: thunks.c:136
SECURITY_STATUS SEC_ENTRY thunk_QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: thunks.c:766
SECURITY_STATUS SEC_ENTRY thunk_ImportSecurityContextW(SEC_WCHAR *pszPackage, PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
Definition: thunks.c:880
SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName, PSecPkgInfoW *ppPackageInfo)
Definition: wrapper.c:750

Referenced by SECUR32_addProvider(), and SECUR32_findPackageW().

◆ _tryLoadProvider()

static void _tryLoadProvider ( PWSTR  moduleName)
static

Definition at line 452 of file sspi.c.

453{
454 HMODULE lib = LoadLibraryW(moduleName);
455
456 if (lib)
457 {
458 INIT_SECURITY_INTERFACE_W pInitSecurityInterfaceW =
461 INIT_SECURITY_INTERFACE_A pInitSecurityInterfaceA =
464
465 TRACE("loaded %s, InitSecurityInterfaceA is %p, InitSecurityInterfaceW is %p\n",
466 debugstr_w(moduleName), pInitSecurityInterfaceA,
467 pInitSecurityInterfaceW);
468 if (pInitSecurityInterfaceW || pInitSecurityInterfaceA)
469 {
470 PSecurityFunctionTableA fnTableA = NULL;
471 PSecurityFunctionTableW fnTableW = NULL;
472 ULONG toAdd = 0;
476
477 if (pInitSecurityInterfaceA)
478 fnTableA = pInitSecurityInterfaceA();
479 if (pInitSecurityInterfaceW)
480 fnTableW = pInitSecurityInterfaceW();
481 if (fnTableW && fnTableW->EnumerateSecurityPackagesW)
482 {
483 if (fnTableW != &securityFunctionTableW)
484 ret = fnTableW->EnumerateSecurityPackagesW(&toAdd, &infoW);
485 else
486 TRACE("%s has built-in providers, skip adding\n", debugstr_w(moduleName));
487 }
488 else if (fnTableA && fnTableA->EnumerateSecurityPackagesA)
489 {
490 if (fnTableA != &securityFunctionTableA)
491 ret = fnTableA->EnumerateSecurityPackagesA(&toAdd, &infoA);
492 else
493 TRACE("%s has built-in providers, skip adding\n", debugstr_w(moduleName));
494 }
495 if (ret == SEC_E_OK && toAdd > 0 && (infoW || infoA))
496 {
498 moduleName);
499
500 if (provider)
501 SECUR32_addPackages(provider, toAdd, infoA, infoW);
502 if (infoW)
503 fnTableW->FreeContextBuffer(infoW);
504 else
505 fnTableA->FreeContextBuffer(infoA);
506 }
507 }
508 FreeLibrary(lib);
509 }
510 else
511 WARN("failed to load %s\n", debugstr_w(moduleName));
512}
#define WARN(fmt,...)
Definition: precomp.h:61
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
static const SecPkgInfoW infoW
Definition: kerberos.c:293
static const SecPkgInfoA infoA
Definition: kerberos.c:302
#define debugstr_w
Definition: kernel32.h:32
LONG SECURITY_STATUS
Definition: sspi.h:34
PSecurityFunctionTableW(SEC_ENTRY * INIT_SECURITY_INTERFACE_W)(void)
Definition: sspi.h:1031
PSecurityFunctionTableA(SEC_ENTRY * INIT_SECURITY_INTERFACE_A)(void)
Definition: sspi.h:1030
#define SECURITY_ENTRYPOINT_ANSIA
Definition: sspi.h:949
#define SECURITY_ENTRYPOINT_ANSIW
Definition: sspi.h:950
#define TRACE(s)
Definition: solgame.cpp:4
void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd, const SecPkgInfoA *infoA, const SecPkgInfoW *infoW)
Definition: sspi.c:411
SecureProvider * SECUR32_addProvider(const SecurityFunctionTableA *fnTableA, const SecurityFunctionTableW *fnTableW, PCWSTR moduleName)
Definition: sspi.c:364
static SecurityFunctionTableA securityFunctionTableA
Definition: sspi.c:58
static SecurityFunctionTableW securityFunctionTableW
Definition: sspi.c:89
uint32_t ULONG
Definition: typedefs.h:59
int ret
#define SEC_E_OK
Definition: winerror.h:2356

Referenced by SECUR32_initializeProviders().

◆ EnumerateSecurityPackagesA()

SECURITY_STATUS WINAPI EnumerateSecurityPackagesA ( PULONG  pcPackages,
PSecPkgInfoA ppPackageInfo 
)

Definition at line 855 of file sspi.c.

857{
860
861 ret = EnumerateSecurityPackagesW(pcPackages, &info);
862 if (ret == SEC_E_OK && *pcPackages && info)
863 {
864 *ppPackageInfo = thunk_PSecPkgInfoWToA(*pcPackages, info);
865 if (*pcPackages && !*ppPackageInfo)
866 {
867 *pcPackages = 0;
869 }
871 }
872 return ret;
873}
SECURITY_STATUS WINAPI EnumerateSecurityPackagesW(PULONG pcPackages, PSecPkgInfoW *ppPackageInfo)
Definition: sspi.c:709
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
Definition: sspi.c:699
static PSecPkgInfoA thunk_PSecPkgInfoWToA(ULONG cPackages, const SecPkgInfoW *info)
Definition: sspi.c:785
#define SEC_E_INSUFFICIENT_MEMORY
Definition: winerror.h:2909

Referenced by RpcBindingSetAuthInfoExA(), and testAcquireSecurityContext().

◆ EnumerateSecurityPackagesW()

SECURITY_STATUS WINAPI EnumerateSecurityPackagesW ( PULONG  pcPackages,
PSecPkgInfoW ppPackageInfo 
)

Definition at line 709 of file sspi.c.

711{
713
714 TRACE("(%p, %p)\n", pcPackages, ppPackageInfo);
715
716#ifdef __REACTOS__
717 if (!packageTable)
719#endif
720
721 /* windows just crashes if pcPackages or ppPackageInfo is NULL, so will I */
722 *pcPackages = 0;
724 if (packageTable)
725 {
726 SecurePackage *package;
727 size_t bytesNeeded;
728
729 bytesNeeded = packageTable->numPackages * sizeof(SecPkgInfoW);
731 {
732 if (package->infoW.Name)
733 bytesNeeded += (lstrlenW(package->infoW.Name) + 1) * sizeof(WCHAR);
734 if (package->infoW.Comment)
735 bytesNeeded += (lstrlenW(package->infoW.Comment) + 1) * sizeof(WCHAR);
736 }
737 if (bytesNeeded)
738 {
739 *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
740 if (*ppPackageInfo)
741 {
742 ULONG i = 0;
743 PWSTR nextString;
744
745 *pcPackages = packageTable->numPackages;
746 nextString = (PWSTR)((PBYTE)*ppPackageInfo +
749 {
750 PSecPkgInfoW pkgInfo = *ppPackageInfo + i++;
751
752 *pkgInfo = package->infoW;
753 if (package->infoW.Name)
754 {
755 TRACE("Name[%d] = %s\n", i - 1, debugstr_w(package->infoW.Name));
756 pkgInfo->Name = nextString;
757 lstrcpyW(nextString, package->infoW.Name);
758 nextString += lstrlenW(nextString) + 1;
759 }
760 else
761 pkgInfo->Name = NULL;
762 if (package->infoW.Comment)
763 {
764 TRACE("Comment[%d] = %s\n", i - 1, debugstr_w(package->infoW.Comment));
765 pkgInfo->Comment = nextString;
766 lstrcpyW(nextString, package->infoW.Comment);
767 nextString += lstrlenW(nextString) + 1;
768 }
769 else
770 pkgInfo->Comment = NULL;
771 }
772 }
773 else
775 }
776 }
778 TRACE("<-- 0x%08x\n", ret);
779 return ret;
780}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uint32_t entry
Definition: isohybrid.c:63
BYTE * PBYTE
Definition: pedump.c:66
struct _SecPkgInfoW SecPkgInfoW
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static SecurePackageTable * packageTable
Definition: sspi.c:55
static CRITICAL_SECTION cs
Definition: sspi.c:47
static void SECUR32_initializeProviders(void)
Definition: sspi.c:523
struct list table
Definition: secur32_wine.c:30
SecPkgInfoW infoW
Definition: schannel_priv.h:35
uint16_t * PWSTR
Definition: typedefs.h:56
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by EnumerateSecurityPackagesA(), find_security_package(), and RpcBindingSetAuthInfoExW().

◆ FreeContextBuffer()

◆ GetComputerObjectNameA()

BOOLEAN WINAPI GetComputerObjectNameA ( EXTENDED_NAME_FORMAT  NameFormat,
LPSTR  lpNameBuffer,
PULONG  nSize 
)

Definition at line 899 of file sspi.c.

901{
902 BOOLEAN rc;
903 LPWSTR bufferW = NULL;
904 ULONG sizeW = *nSize;
905 TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
906 if (lpNameBuffer) {
907 bufferW = HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR));
908 if (bufferW == NULL) {
910 return FALSE;
911 }
912 }
913 rc = GetComputerObjectNameW(NameFormat, bufferW, &sizeW);
914 if (rc && bufferW) {
915 ULONG len = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL);
917 *nSize = len;
918 }
919 else
920 *nSize = sizeW;
921 HeapFree(GetProcessHeap(), 0, bufferW);
922 return rc;
923}
unsigned char BOOLEAN
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define FALSE
Definition: types.h:117
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define WideCharToMultiByte
Definition: compat.h:111
static const WCHAR sizeW[]
Definition: editor.c:79
GLenum GLsizei len
Definition: glext.h:6722
static LPSTR lpNameBuffer
Definition: secur32.c:50
BOOLEAN WINAPI GetComputerObjectNameW(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize)
Definition: sspi.c:928
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2109
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ GetComputerObjectNameW()

BOOLEAN WINAPI GetComputerObjectNameW ( EXTENDED_NAME_FORMAT  NameFormat,
LPWSTR  lpNameBuffer,
PULONG  nSize 
)

Definition at line 928 of file sspi.c.

930{
931 LSA_HANDLE policyHandle;
932 LSA_OBJECT_ATTRIBUTES objectAttributes;
933 PPOLICY_DNS_DOMAIN_INFO domainInfo;
934 NTSTATUS ntStatus;
936 TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
937
938 if (NameFormat == NameUnknown)
939 {
941 return FALSE;
942 }
943
944 ZeroMemory(&objectAttributes, sizeof(objectAttributes));
945 objectAttributes.Length = sizeof(objectAttributes);
946
947 ntStatus = LsaOpenPolicy(NULL, &objectAttributes,
949 &policyHandle);
950 if (ntStatus != STATUS_SUCCESS)
951 {
953 WARN("LsaOpenPolicy failed with NT status %u\n", GetLastError());
954 return FALSE;
955 }
956
957 ntStatus = LsaQueryInformationPolicy(policyHandle,
959 (PVOID *)&domainInfo);
960 if (ntStatus != STATUS_SUCCESS)
961 {
963 WARN("LsaQueryInformationPolicy failed with NT status %u\n",
964 GetLastError());
965 LsaClose(policyHandle);
966 return FALSE;
967 }
968
969 if (domainInfo->Sid)
970 {
971 switch (NameFormat)
972 {
973 case NameSamCompatible:
974 {
976 DWORD size = sizeof(name)/sizeof(name[0]);
978 {
979 DWORD len = domainInfo->Name.Length + size + 3;
980 if (lpNameBuffer)
981 {
982 if (*nSize < len)
983 {
984 *nSize = len;
986 status = FALSE;
987 }
988 else
989 {
990 WCHAR bs[] = { '\\', 0 };
991 WCHAR ds[] = { '$', 0 };
992 lstrcpyW(lpNameBuffer, domainInfo->Name.Buffer);
996 status = TRUE;
997 }
998 }
999 else /* just requesting length required */
1000 {
1001 *nSize = len;
1002 status = TRUE;
1003 }
1004 }
1005 else
1006 {
1008 status = FALSE;
1009 }
1010 }
1011 break;
1012 case NameFullyQualifiedDN:
1013 case NameDisplay:
1014 case NameUniqueId:
1015 case NameCanonical:
1016 case NameUserPrincipal:
1017 case NameCanonicalEx:
1018 case NameServicePrincipal:
1019 case NameDnsDomain:
1020 FIXME("NameFormat %d not implemented\n", NameFormat);
1022 status = FALSE;
1023 break;
1024 default:
1026 status = FALSE;
1027 }
1028 }
1029 else
1030 {
1032 status = FALSE;
1033 }
1034
1035 LsaFreeMemory(domainInfo);
1036 LsaClose(policyHandle);
1037
1038 return status;
1039}
LONG NTSTATUS
Definition: precomp.h:26
#define FIXME(fmt,...)
Definition: precomp.h:53
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define TRUE
Definition: types.h:120
NTSTATUS WINAPI LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName OPTIONAL, IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes, IN ACCESS_MASK DesiredAccess, OUT PLSA_HANDLE PolicyHandle)
Definition: lsa.c:1183
ULONG WINAPI LsaNtStatusToWinError(IN NTSTATUS Status)
Definition: lsa.c:1131
NTSTATUS WINAPI LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle, IN POLICY_INFORMATION_CLASS InformationClass, OUT PVOID *Buffer)
Definition: lsa.c:1473
NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
Definition: lsa.c:701
NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
Definition: lsa.c:194
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
#define ds
Definition: i386-dis.c:443
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
@ PolicyDnsDomainInformation
Definition: ntsecapi.h:254
#define POLICY_VIEW_LOCAL_INFORMATION
Definition: ntsecapi.h:61
#define STATUS_SUCCESS
Definition: shellext.h:65
LSA_UNICODE_STRING Name
Definition: ntsecapi.h:574
Definition: name.c:39
Definition: ps.c:97
#define ZeroMemory
Definition: winbase.h:1737
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:269
#define ERROR_CANT_ACCESS_DOMAIN_INFO
Definition: winerror.h:832
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:840

Referenced by GetComputerObjectNameA().

◆ GetUserNameExA()

BOOLEAN WINAPI GetUserNameExA ( EXTENDED_NAME_FORMAT  NameFormat,
LPSTR  lpNameBuffer,
PULONG  nSize 
)

Definition at line 1044 of file sspi.c.

1046{
1047 BOOLEAN rc;
1048 LPWSTR bufferW = NULL;
1049 ULONG sizeW = *nSize;
1050 TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
1051 if (lpNameBuffer) {
1052 bufferW = HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR));
1053 if (bufferW == NULL) {
1055 return FALSE;
1056 }
1057 }
1058 rc = GetUserNameExW(NameFormat, bufferW, &sizeW);
1059 if (rc) {
1060 ULONG len = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL);
1061 if (len <= *nSize)
1062 {
1063 WideCharToMultiByte(CP_ACP, 0, bufferW, -1, lpNameBuffer, *nSize, NULL, NULL);
1064 *nSize = len - 1;
1065 }
1066 else
1067 {
1068 *nSize = len;
1069 rc = FALSE;
1071 }
1072 }
1073 else
1074 *nSize = sizeW;
1075 HeapFree(GetProcessHeap(), 0, bufferW);
1076 return rc;
1077}
#define ERROR_MORE_DATA
Definition: dderror.h:13
BOOLEAN WINAPI GetUserNameExW(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize)
Definition: sspi.c:1079

Referenced by START_TEST(), test_MsiSourceListAddSource(), and test_RpcServerInqDefaultPrincName().

◆ GetUserNameExW()

BOOLEAN WINAPI GetUserNameExW ( EXTENDED_NAME_FORMAT  NameFormat,
LPWSTR  lpNameBuffer,
PULONG  nSize 
)

Definition at line 1079 of file sspi.c.

1081{
1082 TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
1083
1084 switch (NameFormat)
1085 {
1086 case NameSamCompatible:
1087 {
1088 WCHAR samname[UNLEN + 1 + MAX_COMPUTERNAME_LENGTH + 1];
1089 LPWSTR out;
1090 DWORD len;
1091
1092 /* This assumes the current user is always a local account */
1094 if (GetComputerNameW(samname, &len))
1095 {
1096 out = samname + lstrlenW(samname);
1097 *out++ = '\\';
1098 len = UNLEN + 1;
1099 if (GetUserNameW(out, &len))
1100 {
1101 if (lstrlenW(samname) < *nSize)
1102 {
1103 lstrcpyW(lpNameBuffer, samname);
1104 *nSize = lstrlenW(samname);
1105 return TRUE;
1106 }
1107
1109 *nSize = lstrlenW(samname) + 1;
1110 }
1111 }
1112 return FALSE;
1113 }
1114
1115 case NameUnknown:
1116 case NameFullyQualifiedDN:
1117 case NameDisplay:
1118 case NameUniqueId:
1119 case NameCanonical:
1120 case NameUserPrincipal:
1121 case NameCanonicalEx:
1122 case NameServicePrincipal:
1123 case NameDnsDomain:
1125 return FALSE;
1126
1127 default:
1129 return FALSE;
1130 }
1131}
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
static FILE * out
Definition: regtests2xml.c:44
#define UNLEN
Definition: sspi.c:28
#define ERROR_NONE_MAPPED
Definition: winerror.h:814

Referenced by _LocalGetPrintServerHandleData(), GetUserNameExA(), RpcServerInqDefaultPrincNameW(), and WhoamiGetUser().

◆ InitSecurityInterfaceA()

PSecurityFunctionTableA WINAPI InitSecurityInterfaceA ( void  )

Definition at line 123 of file sspi.c.

124{
125 TRACE("InitSecurityInterfaceA() called\n");
127}

◆ InitSecurityInterfaceW()

PSecurityFunctionTableW WINAPI InitSecurityInterfaceW ( void  )

Definition at line 132 of file sspi.c.

133{
134 TRACE("InitSecurityInterfaceW() called\n");
136}

◆ SECUR32_addPackages()

void SECUR32_addPackages ( SecureProvider provider,
ULONG  toAdd,
const SecPkgInfoA infoA,
const SecPkgInfoW infoW 
)

Definition at line 411 of file sspi.c.

413{
414 ULONG i;
415
416 assert(provider);
417 assert(infoA || infoW);
418
420
421 if (!packageTable)
422 {
424 if (!packageTable)
425 {
427 return;
428 }
429
432 }
433
434 for (i = 0; i < toAdd; i++)
435 {
436 SecurePackage *package = HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackage));
437 if (!package)
438 continue;
439
440 list_add_tail(&packageTable->table, &package->entry);
441
442 package->provider = provider;
443 _copyPackageInfo(&package->infoW,
444 infoA ? &infoA[i] : NULL,
445 infoW ? &infoW[i] : NULL);
446 }
447 packageTable->numPackages += toAdd;
448
450}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_init(struct list_entry *head)
Definition: list.h:51
#define assert(x)
Definition: debug.h:53
static SecurePackageTable * packageTable
Definition: secur32_wine.c:52
static void _copyPackageInfo(PSecPkgInfoW info, const SecPkgInfoA *inInfoA, const SecPkgInfoW *inInfoW)
Definition: secur32_wine.c:292

Referenced by _tryLoadProvider(), SECUR32_initKerberosSP(), SECUR32_initNegotiateSP(), and SECUR32_initNTLMSP().

◆ SECUR32_addProvider()

SecureProvider * SECUR32_addProvider ( const SecurityFunctionTableA fnTableA,
const SecurityFunctionTableW fnTableW,
PCWSTR  moduleName 
)

Definition at line 364 of file sspi.c.

366{
368
370
371 if (!providerTable)
372 {
374 if (!providerTable)
375 {
377 return NULL;
378 }
379
381 }
382
384 if (!ret)
385 {
387 return NULL;
388 }
389
391 ret->lib = NULL;
392
393 if (fnTableA || fnTableW)
394 {
395 ret->moduleName = moduleName ? SECUR32_strdupW(moduleName) : NULL;
396 _makeFnTableA(&ret->fnTableA, fnTableA, fnTableW);
397 _makeFnTableW(&ret->fnTableW, fnTableA, fnTableW);
398 ret->loaded = !moduleName;
399 }
400 else
401 {
402 ret->moduleName = SECUR32_strdupW(moduleName);
403 ret->loaded = FALSE;
404 }
405
407 return ret;
408}
static void _makeFnTableA(PSecurityFunctionTableA fnTableA, const SecurityFunctionTableA *inFnTableA, const SecurityFunctionTableW *inFnTableW)
Definition: sspi.c:199
static void _makeFnTableW(PSecurityFunctionTableW fnTableW, const SecurityFunctionTableA *inFnTableA, const SecurityFunctionTableW *inFnTableW)
Definition: sspi.c:270
static SecureProviderTable * providerTable
Definition: sspi.c:56

Referenced by _tryLoadProvider(), SECUR32_initKerberosSP(), SECUR32_initNegotiateSP(), and SECUR32_initNTLMSP().

◆ SECUR32_AllocMultiByteFromWide()

PSTR SECUR32_AllocMultiByteFromWide ( PCWSTR  str)

Definition at line 175 of file sspi.c.

176{
177 PSTR ret;
178
179 if (str)
180 {
181 int charsNeeded = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0,
182 NULL, NULL);
183
184 if (charsNeeded)
185 {
186 ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded);
187 if (ret)
188 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, charsNeeded,
189 NULL, NULL);
190 }
191 else
192 ret = NULL;
193 }
194 else
195 ret = NULL;
196 return ret;
197}
const WCHAR * str
char * PSTR
Definition: typedefs.h:51

◆ SECUR32_AllocWideFromMultiByte()

PWSTR SECUR32_AllocWideFromMultiByte ( PCSTR  str)

Definition at line 153 of file sspi.c.

154{
155 PWSTR ret;
156
157 if (str)
158 {
159 int charsNeeded = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
160
161 if (charsNeeded)
162 {
163 ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded * sizeof(WCHAR));
164 if (ret)
165 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, charsNeeded);
166 }
167 else
168 ret = NULL;
169 }
170 else
171 ret = NULL;
172 return ret;
173}
#define MultiByteToWideChar
Definition: compat.h:110

Referenced by _copyPackageInfo().

◆ SECUR32_findPackageA()

SecurePackage * SECUR32_findPackageA ( PCSTR  packageName)

Definition at line 631 of file sspi.c.

632{
634
635 if (packageName)
636 {
637 UNICODE_STRING package;
638
639 RtlCreateUnicodeStringFromAsciiz(&package, packageName);
641 RtlFreeUnicodeString(&package);
642 }
643 else
644 ret = NULL;
645 return ret;
646}
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
SecurePackage * SECUR32_findPackageW(PCWSTR packageName)
Definition: sspi.c:577

◆ SECUR32_findPackageW()

SecurePackage * SECUR32_findPackageW ( PCWSTR  packageName)

Definition at line 577 of file sspi.c.

578{
580 BOOL matched = FALSE;
581
582#ifdef __REACTOS__
583 if (!packageTable)
585#endif
586
587 if (packageTable && packageName)
588 {
590 {
591 matched = !lstrcmpiW(ret->infoW.Name, packageName);
592 if (matched)
593 break;
594 }
595
596 if (!matched)
597 return NULL;
598
599 if (ret->provider && !ret->provider->loaded)
600 {
601 ret->provider->lib = LoadLibraryW(ret->provider->moduleName);
602 if (ret->provider->lib)
603 {
604 INIT_SECURITY_INTERFACE_W pInitSecurityInterfaceW =
607 INIT_SECURITY_INTERFACE_A pInitSecurityInterfaceA =
610 PSecurityFunctionTableA fnTableA = NULL;
611 PSecurityFunctionTableW fnTableW = NULL;
612
613 if (pInitSecurityInterfaceA)
614 fnTableA = pInitSecurityInterfaceA();
615 if (pInitSecurityInterfaceW)
616 fnTableW = pInitSecurityInterfaceW();
617 /* don't update built-in SecurityFunctionTable */
618 if (fnTableA != &securityFunctionTableA)
619 _makeFnTableA(&ret->provider->fnTableA, fnTableA, fnTableW);
620 if (fnTableW != &securityFunctionTableW)
621 _makeFnTableW(&ret->provider->fnTableW, fnTableA, fnTableW);
622 ret->provider->loaded = TRUE;
623 }
624 else
625 ret = NULL;
626 }
627 }
628 return ret;
629}
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4262
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by SECUR32_findPackageA().

◆ SECUR32_freeProviders()

void SECUR32_freeProviders ( void  )

Definition at line 648 of file sspi.c.

649{
650 TRACE("\n");
652
653#ifndef __REACTOS__
655#endif
656
657 if (packageTable)
658 {
659 SecurePackage *package, *package_next;
660 LIST_FOR_EACH_ENTRY_SAFE(package, package_next, &packageTable->table,
662 {
663 HeapFree(GetProcessHeap(), 0, package->infoW.Name);
664 HeapFree(GetProcessHeap(), 0, package->infoW.Comment);
665 HeapFree(GetProcessHeap(), 0, package);
666 }
667
670 }
671
672 if (providerTable)
673 {
674 SecureProvider *provider, *provider_next;
675 LIST_FOR_EACH_ENTRY_SAFE(provider, provider_next, &providerTable->table,
677 {
678 HeapFree(GetProcessHeap(), 0, provider->moduleName);
679 if (provider->lib)
680 FreeLibrary(provider->lib);
681 HeapFree(GetProcessHeap(), 0, provider);
682 }
683
686 }
687
690}
void SECUR32_deinitSchannelSP(void)
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by DllMain().

◆ SECUR32_initializeProviders()

static void SECUR32_initializeProviders ( void  )
static

Definition at line 523 of file sspi.c.

524{
525 HKEY key;
526 LSTATUS apiRet;
527
528 /* Now load providers from registry */
530 KEY_READ, &key);
531 if (apiRet == ERROR_SUCCESS)
532 {
533 WCHAR securityPkgNames[MAX_PATH]; /* arbitrary len */
534 DWORD size = sizeof(securityPkgNames), type;
535
537 (PBYTE)securityPkgNames, &size);
538 if (apiRet == ERROR_SUCCESS && type == REG_SZ)
539 {
540 WCHAR *ptr;
541
542 size = size / sizeof(WCHAR);
543 for (ptr = securityPkgNames;
544 ptr < securityPkgNames + size; )
545 {
546 WCHAR *comma;
547
548 for (comma = ptr; *comma && *comma != ','; comma++)
549 ;
550 if (*comma == ',')
551 *comma = '\0';
552 for (; *ptr && isspace(*ptr) && ptr < securityPkgNames + size;
553 ptr++)
554 ;
555 if (*ptr)
557 ptr += lstrlenW(ptr) + 1;
558 }
559 }
561 }
562
563 /* Now load the built-in providers (in Wine, this is done before the registry loading) */
564#ifdef __REACTOS__
566 /* First load built-in providers */
569 /* Load the Negotiate provider last so apps stumble over the working NTLM
570 * provider first. Attempting to fix bug #16905 while keeping the
571 * application reported on wine-users on 2006-09-12 working. */
573#endif
574
575}
#define isspace(c)
Definition: acclib.h:69
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define MAX_PATH
Definition: compat.h:34
void SECUR32_initNegotiateSP(void)
Definition: negotiate.c:516
void SECUR32_initNTLMSP(void)
Definition: ntlm.c:2026
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void SECUR32_initKerberosSP(void)
Definition: kerberos.c:311
#define REG_SZ
Definition: layer.c:22
static PVOID ptr
Definition: dispmode.c:27
#define KEY_READ
Definition: nt_native.h:1023
static const WCHAR securityProvidersKeyW[]
Definition: sspi.c:514
static void _tryLoadProvider(PWSTR moduleName)
Definition: sspi.c:452
static const WCHAR securityProvidersW[]
Definition: sspi.c:519
Definition: copy.c:22
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by EnumerateSecurityPackagesW(), and SECUR32_findPackageW().

◆ SECUR32_strdupW()

static PWSTR SECUR32_strdupW ( PCWSTR  str)
static

Definition at line 138 of file sspi.c.

139{
140 PWSTR ret;
141
142 if (str)
143 {
144 ret = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(str) + 1) * sizeof(WCHAR));
145 if (ret)
146 lstrcpyW(ret, str);
147 }
148 else
149 ret = NULL;
150 return ret;
151}

Referenced by _copyPackageInfo(), and SECUR32_addProvider().

◆ thunk_PSecPkgInfoWToA()

static PSecPkgInfoA thunk_PSecPkgInfoWToA ( ULONG  cPackages,
const SecPkgInfoW info 
)
static

Definition at line 785 of file sspi.c.

787{
789
790 if (info)
791 {
792 size_t bytesNeeded = cPackages * sizeof(SecPkgInfoA);
793 ULONG i;
794
795 for (i = 0; i < cPackages; i++)
796 {
797 if (info[i].Name)
798 bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info[i].Name,
799 -1, NULL, 0, NULL, NULL);
800 if (info[i].Comment)
801 bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info[i].Comment,
802 -1, NULL, 0, NULL, NULL);
803 }
804 ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
805 if (ret)
806 {
807 PSTR nextString;
808
809 nextString = (PSTR)((PBYTE)ret + cPackages * sizeof(SecPkgInfoA));
810 for (i = 0; i < cPackages; i++)
811 {
812 PSecPkgInfoA pkgInfo = ret + i;
813 int bytes;
814
815 memcpy(pkgInfo, &info[i], sizeof(SecPkgInfoA));
816 if (info[i].Name)
817 {
818 pkgInfo->Name = nextString;
819 /* just repeat back to WideCharToMultiByte how many bytes
820 * it requires, since we asked it earlier
821 */
823 NULL, 0, NULL, NULL);
825 pkgInfo->Name, bytes, NULL, NULL);
826 nextString += lstrlenA(nextString) + 1;
827 }
828 else
829 pkgInfo->Name = NULL;
830 if (info[i].Comment)
831 {
832 pkgInfo->Comment = nextString;
833 /* just repeat back to WideCharToMultiByte how many bytes
834 * it requires, since we asked it earlier
835 */
837 NULL, 0, NULL, NULL);
839 pkgInfo->Comment, bytes, NULL, NULL);
840 nextString += lstrlenA(nextString) + 1;
841 }
842 else
843 pkgInfo->Comment = NULL;
844 }
845 }
846 }
847 else
848 ret = NULL;
849 return ret;
850}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
@ Comment
Definition: asmpp.cpp:34
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
struct _SecPkgInfoA SecPkgInfoA
SEC_CHAR * Comment
Definition: sspi.h:109
SEC_CHAR * Name
Definition: sspi.h:108

Referenced by EnumerateSecurityPackagesA().

◆ TranslateNameA()

BOOLEAN WINAPI TranslateNameA ( LPCSTR  lpAccountName,
EXTENDED_NAME_FORMAT  AccountNameFormat,
EXTENDED_NAME_FORMAT  DesiredNameFormat,
LPSTR  lpTranslatedName,
PULONG  nSize 
)

Definition at line 1133 of file sspi.c.

1137{
1138 FIXME("%p %d %d %p %p\n", lpAccountName, AccountNameFormat,
1139 DesiredNameFormat, lpTranslatedName, nSize);
1140 return FALSE;
1141}
_In_ LPCSTR lpAccountName
Definition: winbase.h:2766

◆ TranslateNameW()

BOOLEAN WINAPI TranslateNameW ( LPCWSTR  lpAccountName,
EXTENDED_NAME_FORMAT  AccountNameFormat,
EXTENDED_NAME_FORMAT  DesiredNameFormat,
LPWSTR  lpTranslatedName,
PULONG  nSize 
)

Definition at line 1143 of file sspi.c.

1147{
1148 FIXME("%p %d %d %p %p\n", lpAccountName, AccountNameFormat,
1149 DesiredNameFormat, lpTranslatedName, nSize);
1150 return FALSE;
1151}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( secur32  )

Variable Documentation

◆ cs

CRITICAL_SECTION cs = { &cs_debug, -1, 0, 0, 0, 0 }
static

◆ cs_debug

CRITICAL_SECTION_DEBUG cs_debug
static
Initial value:
=
{
0, 0, &cs,
0, 0, { (DWORD_PTR)(__FILE__ ": cs") }
}
static CRITICAL_SECTION_DEBUG cs_debug
Definition: sspi.c:48
LIST_ENTRY ProcessLocksList
Definition: winbase.h:908
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 48 of file sspi.c.

◆ packageTable

◆ providerTable

SecureProviderTable* providerTable = NULL
static

Definition at line 56 of file sspi.c.

Referenced by SECUR32_addProvider(), and SECUR32_freeProviders().

◆ securityFunctionTableA

SecurityFunctionTableA securityFunctionTableA
static
Initial value:
= {
NULL,
NULL,
}
#define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION
Definition: sspi.h:1023
SECURITY_STATUS WINAPI EnumerateSecurityPackagesA(PULONG pcPackages, PSecPkgInfoA *ppPackageInfo)
Definition: sspi.c:855
SECURITY_STATUS WINAPI EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
Definition: wrapper.c:1006
SECURITY_STATUS WINAPI MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
Definition: wrapper.c:623
SECURITY_STATUS WINAPI ExportSecurityContext(PCtxtHandle phContext, ULONG fFlags, PSecBuffer pPackedContext, void **pToken)
Definition: wrapper.c:807
SECURITY_STATUS WINAPI CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken)
Definition: wrapper.c:420
SECURITY_STATUS WINAPI ImportSecurityContextA(SEC_CHAR *pszPackage, PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
Definition: wrapper.c:837
SECURITY_STATUS WINAPI DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
Definition: wrapper.c:1036
SECURITY_STATUS WINAPI VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
Definition: wrapper.c:653
SECURITY_STATUS WINAPI ApplyControlToken(PCtxtHandle phContext, PSecBufferDesc pInput)
Definition: wrapper.c:475
SECURITY_STATUS WINAPI QueryContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:505
SECURITY_STATUS WINAPI AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:365
SECURITY_STATUS WINAPI AcquireCredentialsHandleA(SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: wrapper.c:59
SECURITY_STATUS WINAPI QueryCredentialsAttributesA(PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:177
SECURITY_STATUS WINAPI InitializeSecurityContextA(PCredHandle phCredential, PCtxtHandle phContext, SEC_CHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:237
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
SECURITY_STATUS WINAPI ImpersonateSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:565
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
SECURITY_STATUS WINAPI RevertSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:594
SECURITY_STATUS WINAPI QuerySecurityContextToken(PCtxtHandle phContext, HANDLE *phToken)
Definition: wrapper.c:976
SECURITY_STATUS WINAPI AddCredentialsA(PCredHandle hCredentials, SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument, PTimeStamp ptsExpiry)
Definition: wrapper.c:906

Definition at line 58 of file sspi.c.

Referenced by _tryLoadProvider(), InitSecurityInterfaceA(), and SECUR32_findPackageW().

◆ securityFunctionTableW

SecurityFunctionTableW securityFunctionTableW
static
Initial value:
= {
NULL,
NULL,
}
SECURITY_STATUS WINAPI AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: wrapper.c:105
SECURITY_STATUS WINAPI AddCredentialsW(PCredHandle hCredentials, SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument, PTimeStamp ptsExpiry)
Definition: wrapper.c:941
SECURITY_STATUS WINAPI InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:301
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535
SECURITY_STATUS WINAPI ImportSecurityContextW(SEC_WCHAR *pszPackage, PSecBuffer pPackedContext, void *Token, PCtxtHandle phContext)
Definition: wrapper.c:872
SECURITY_STATUS WINAPI QueryCredentialsAttributesW(PCredHandle phCredential, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:207

Definition at line 89 of file sspi.c.

Referenced by _tryLoadProvider(), InitSecurityInterfaceW(), and SECUR32_findPackageW().

◆ securityProvidersKeyW

const WCHAR securityProvidersKeyW[]
static
Initial value:
= {
'S','Y','S','T','E','M','\\','C','u','r','r','e','n','t','C','o','n','t','r',
'o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','S','e','c','u','r',
'i','t','y','P','r','o','v','i','d','e','r','s','\0'
}

Definition at line 514 of file sspi.c.

Referenced by SECUR32_initializeProviders().

◆ securityProvidersW

const WCHAR securityProvidersW[]
static
Initial value:
= {
'S','e','c','u','r','i','t','y','P','r','o','v','i','d','e','r','s',0
}

Definition at line 519 of file sspi.c.

Referenced by SECUR32_initializeProviders().