ReactOS 0.4.15-dev-7942-gd23573b
secur32_wine.c File Reference
#include "precomp.h"
#include <assert.h>
Include dependency graph for secur32_wine.c:

Go to the source code of this file.

Classes

struct  _SecurePackageTable
 
struct  _SecureProviderTable
 

Typedefs

typedef struct _SecurePackageTable SecurePackageTable
 
typedef struct _SecureProviderTable SecureProviderTable
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (schannel)
 
SECURITY_STATUS WINAPI schan_EnumerateSecurityPackagesW (PULONG pcPackages, PSecPkgInfoW *ppPackageInfo)
 
static PSecPkgInfoA thunk_PSecPkgInfoWToA (ULONG cPackages, const SecPkgInfoW *info)
 
SECURITY_STATUS WINAPI schan_EnumerateSecurityPackagesA (PULONG pcPackages, PSecPkgInfoA *ppPackageInfo)
 
SECURITY_STATUS WINAPI schan_FreeContextBuffer (PVOID pvoid)
 
static PWSTR SECUR32_strdupW (PCWSTR str)
 
PWSTR SECUR32_AllocWideFromMultiByte (PCSTR str)
 
PSTR SECUR32_AllocMultiByteFromWide (PCWSTR str)
 
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)
 

Variables

static CRITICAL_SECTION cs = { &cs_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG cs_debug
 
static SecurePackageTablepackageTable = NULL
 
static SecureProviderTableproviderTable = NULL
 

Typedef Documentation

◆ SecurePackageTable

◆ SecureProviderTable

Function Documentation

◆ _copyPackageInfo()

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

Definition at line 292 of file secur32_wine.c.

294{
295 if (info && (inInfoA || inInfoW))
296 {
297 /* odd, I know, but up until Name and Comment the structures are
298 * identical
299 */
300 memcpy(info, inInfoW ? inInfoW : (const SecPkgInfoW *)inInfoA, sizeof(*info));
301 if (inInfoW)
302 {
303 info->Name = SECUR32_strdupW(inInfoW->Name);
304 info->Comment = SECUR32_strdupW(inInfoW->Comment);
305 }
306 else
307 {
308 info->Name = SECUR32_AllocWideFromMultiByte(inInfoA->Name);
309 info->Comment = SECUR32_AllocWideFromMultiByte(inInfoA->Comment);
310 }
311 }
312}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PWSTR SECUR32_strdupW(PCWSTR str)
Definition: secur32_wine.c:231
PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str)
Definition: secur32_wine.c:246
SEC_WCHAR * Comment
Definition: sspi.h:119
SEC_WCHAR * Name
Definition: sspi.h:118

Referenced by SECUR32_addPackages().

◆ schan_EnumerateSecurityPackagesA()

SECURITY_STATUS WINAPI schan_EnumerateSecurityPackagesA ( PULONG  pcPackages,
PSecPkgInfoA ppPackageInfo 
)

Definition at line 199 of file secur32_wine.c.

201{
204
206 if (ret == SEC_E_OK && *pcPackages && info)
207 {
208 *ppPackageInfo = thunk_PSecPkgInfoWToA(*pcPackages, info);
209 if (*pcPackages && !*ppPackageInfo)
210 {
211 *pcPackages = 0;
213 }
215 }
216 return ret;
217}
LONG SECURITY_STATUS
Definition: sspi.h:34
SECURITY_STATUS WINAPI schan_EnumerateSecurityPackagesW(PULONG pcPackages, PSecPkgInfoW *ppPackageInfo)
Definition: secur32_wine.c:58
SECURITY_STATUS WINAPI schan_FreeContextBuffer(PVOID pvoid)
Definition: secur32_wine.c:221
static PSecPkgInfoA thunk_PSecPkgInfoWToA(ULONG cPackages, const SecPkgInfoW *info)
Definition: secur32_wine.c:129
int ret
#define SEC_E_OK
Definition: winerror.h:2356
#define SEC_E_INSUFFICIENT_MEMORY
Definition: winerror.h:2909

◆ schan_EnumerateSecurityPackagesW()

SECURITY_STATUS WINAPI schan_EnumerateSecurityPackagesW ( PULONG  pcPackages,
PSecPkgInfoW ppPackageInfo 
)

Definition at line 58 of file secur32_wine.c.

60{
62
63 TRACE("(%p, %p)\n", pcPackages, ppPackageInfo);
64
65 /* windows just crashes if pcPackages or ppPackageInfo is NULL, so will I */
66 *pcPackages = 0;
68 if (packageTable)
69 {
70 SecurePackage *package;
71 size_t bytesNeeded;
72
73 bytesNeeded = packageTable->numPackages * sizeof(SecPkgInfoW);
75 {
76 if (package->infoW.Name)
77 bytesNeeded += (lstrlenW(package->infoW.Name) + 1) * sizeof(WCHAR);
78 if (package->infoW.Comment)
79 bytesNeeded += (lstrlenW(package->infoW.Comment) + 1) * sizeof(WCHAR);
80 }
81 if (bytesNeeded)
82 {
83 *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
84 if (*ppPackageInfo)
85 {
86 ULONG i = 0;
87 PWSTR nextString;
88
89 *pcPackages = packageTable->numPackages;
90 nextString = (PWSTR)((PBYTE)*ppPackageInfo +
93 {
94 PSecPkgInfoW pkgInfo = *ppPackageInfo + i++;
95
96 *pkgInfo = package->infoW;
97 if (package->infoW.Name)
98 {
99 TRACE("Name[%d] = %S\n", i - 1, package->infoW.Name);
100 pkgInfo->Name = nextString;
101 lstrcpyW(nextString, package->infoW.Name);
102 nextString += lstrlenW(nextString) + 1;
103 }
104 else
105 pkgInfo->Name = NULL;
106 if (package->infoW.Comment)
107 {
108 TRACE("Comment[%d] = %S\n", i - 1, package->infoW.Comment);
109 pkgInfo->Comment = nextString;
110 lstrcpyW(nextString, package->infoW.Comment);
111 nextString += lstrlenW(nextString) + 1;
112 }
113 else
114 pkgInfo->Comment = NULL;
115 }
116 }
117 else
119 }
120 }
122 TRACE("<-- 0x%08x\n", ret);
123 return ret;
124}
#define NULL
Definition: types.h:112
#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: secur32_wine.c:52
static CRITICAL_SECTION cs
Definition: secur32_wine.c:44
#define TRACE(s)
Definition: solgame.cpp:4
struct list table
Definition: secur32_wine.c:30
SecPkgInfoW infoW
Definition: schannel_priv.h:35
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by schan_EnumerateSecurityPackagesA().

◆ schan_FreeContextBuffer()

SECURITY_STATUS WINAPI schan_FreeContextBuffer ( PVOID  pvoid)

Definition at line 221 of file secur32_wine.c.

224{
225 HeapFree(GetProcessHeap(), 0, pvoid);
226 return SEC_E_OK;
227}
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by schan_EnumerateSecurityPackagesA().

◆ SECUR32_addPackages()

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

Definition at line 362 of file secur32_wine.c.

364{
365 ULONG i;
366
367 assert(provider);
368 assert(infoA || infoW);
369
371
372 if (!packageTable)
373 {
375 if (!packageTable)
376 {
378 return;
379 }
380
383 }
384
385 for (i = 0; i < toAdd; i++)
386 {
387 SecurePackage *package = HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackage));
388 if (!package)
389 continue;
390
391 list_add_tail(&packageTable->table, &package->entry);
392
393 package->provider = provider;
394 _copyPackageInfo(&package->infoW,
395 infoA ? &infoA[i] : NULL,
396 infoW ? &infoW[i] : NULL);
397 }
398 packageTable->numPackages += toAdd;
399
401}
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 const SecPkgInfoW infoW
Definition: kerberos.c:293
static const SecPkgInfoA infoA
Definition: kerberos.c:302
static void _copyPackageInfo(PSecPkgInfoW info, const SecPkgInfoA *inInfoA, const SecPkgInfoW *inInfoW)
Definition: secur32_wine.c:292

◆ SECUR32_addProvider()

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

Definition at line 314 of file secur32_wine.c.

316{
318
320
321 if (!providerTable)
322 {
324 if (!providerTable)
325 {
327 return NULL;
328 }
329
331 }
332
334 if (!ret)
335 {
337 return NULL;
338 }
339
341 ret->lib = NULL;
342
343#ifndef __REACTOS__
344 if (fnTableA || fnTableW)
345 {
346 ret->moduleName = moduleName ? SECUR32_strdupW(moduleName) : NULL;
347 _makeFnTableA(&ret->fnTableA, fnTableA, fnTableW);
348 _makeFnTableW(&ret->fnTableW, fnTableA, fnTableW);
349 ret->loaded = !moduleName;
350 }
351 else
352#endif
353 {
354 ret->moduleName = SECUR32_strdupW(moduleName);
355 ret->loaded = FALSE;
356 }
357
359 return ret;
360}
#define FALSE
Definition: types.h:117
static SecureProviderTable * providerTable
Definition: secur32_wine.c:53
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

◆ SECUR32_AllocMultiByteFromWide()

PSTR SECUR32_AllocMultiByteFromWide ( PCWSTR  str)

Definition at line 268 of file secur32_wine.c.

269{
270 PSTR ret;
271
272 if (str)
273 {
274 int charsNeeded = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0,
275 NULL, NULL);
276
277 if (charsNeeded)
278 {
279 ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded);
280 if (ret)
281 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, charsNeeded,
282 NULL, NULL);
283 }
284 else
285 ret = NULL;
286 }
287 else
288 ret = NULL;
289 return ret;
290}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
const WCHAR * str
char * PSTR
Definition: typedefs.h:51

Referenced by thunk_AcquireCredentialsHandleW(), thunk_AddCredentialsW(), thunk_ContextAttributesWToA(), thunk_InitializeSecurityContextW(), and thunk_QueryCredentialsAttributesA().

◆ SECUR32_AllocWideFromMultiByte()

PWSTR SECUR32_AllocWideFromMultiByte ( PCSTR  str)

Definition at line 246 of file secur32_wine.c.

247{
248 PWSTR ret;
249
250 if (str)
251 {
252 int charsNeeded = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
253
254 if (charsNeeded)
255 {
256 ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded * sizeof(WCHAR));
257 if (ret)
258 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, charsNeeded);
259 }
260 else
261 ret = NULL;
262 }
263 else
264 ret = NULL;
265 return ret;
266}
#define MultiByteToWideChar
Definition: compat.h:110

Referenced by _copyPackageInfo(), thunk_ContextAttributesAToW(), and thunk_QueryCredentialsAttributesW().

◆ SECUR32_strdupW()

static PWSTR SECUR32_strdupW ( PCWSTR  str)
static

Definition at line 231 of file secur32_wine.c.

232{
233 PWSTR ret;
234
235 if (str)
236 {
237 ret = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(str) + 1) * sizeof(WCHAR));
238 if (ret)
239 lstrcpyW(ret, str);
240 }
241 else
242 ret = NULL;
243 return ret;
244}

Referenced by _copyPackageInfo(), and SECUR32_addProvider().

◆ thunk_PSecPkgInfoWToA()

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

Definition at line 129 of file secur32_wine.c.

131{
133
134 if (info)
135 {
136 size_t bytesNeeded = cPackages * sizeof(SecPkgInfoA);
137 ULONG i;
138
139 for (i = 0; i < cPackages; i++)
140 {
141 if (info[i].Name)
142 bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info[i].Name,
143 -1, NULL, 0, NULL, NULL);
144 if (info[i].Comment)
145 bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info[i].Comment,
146 -1, NULL, 0, NULL, NULL);
147 }
148 ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
149 if (ret)
150 {
151 PSTR nextString;
152
153 nextString = (PSTR)((PBYTE)ret + cPackages * sizeof(SecPkgInfoA));
154 for (i = 0; i < cPackages; i++)
155 {
156 PSecPkgInfoA pkgInfo = ret + i;
157 int bytes;
158
159 memcpy(pkgInfo, &info[i], sizeof(SecPkgInfoA));
160 if (info[i].Name)
161 {
162 pkgInfo->Name = nextString;
163 /* just repeat back to WideCharToMultiByte how many bytes
164 * it requires, since we asked it earlier
165 */
167 NULL, 0, NULL, NULL);
169 pkgInfo->Name, bytes, NULL, NULL);
170 nextString += lstrlenA(nextString) + 1;
171 }
172 else
173 pkgInfo->Name = NULL;
174 if (info[i].Comment)
175 {
176 pkgInfo->Comment = nextString;
177 /* just repeat back to WideCharToMultiByte how many bytes
178 * it requires, since we asked it earlier
179 */
181 NULL, 0, NULL, NULL);
183 pkgInfo->Comment, bytes, NULL, NULL);
184 nextString += lstrlenA(nextString) + 1;
185 }
186 else
187 pkgInfo->Comment = NULL;
188 }
189 }
190 }
191 else
192 ret = NULL;
193 return ret;
194}
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 schan_EnumerateSecurityPackagesA().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( schannel  )

Variable Documentation

◆ cs

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

Globals

Definition at line 44 of file secur32_wine.c.

Referenced by schan_EnumerateSecurityPackagesW(), SECUR32_addPackages(), and SECUR32_addProvider().

◆ 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: secur32_wine.c:45
LIST_ENTRY ProcessLocksList
Definition: winbase.h:883
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 45 of file secur32_wine.c.

◆ packageTable

SecurePackageTable* packageTable = NULL
static

Definition at line 52 of file secur32_wine.c.

Referenced by schan_EnumerateSecurityPackagesW(), and SECUR32_addPackages().

◆ providerTable

SecureProviderTable* providerTable = NULL
static

Definition at line 53 of file secur32_wine.c.

Referenced by SECUR32_addProvider().