ReactOS 0.4.15-dev-8145-ga541a46
main.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#include <sspi.h>
#include "wine/test.h"
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define SECURITY_WIN32
 
#define _SEC_ERR(x)   case (x): return #x;
 
#define X(flag)
 

Functions

static PSecurityFunctionTableA (SEC_ENTRY *pInitSecurityInterfaceA)(void)
 
static SECURITY_STATUS (SEC_ENTRY *pEnumerateSecurityPackagesA)(PULONG
 
static void InitFunctionPtrs (void)
 
static const chargetSecError (SECURITY_STATUS status)
 
static SECURITY_STATUS setupPackageA (SEC_CHAR *p_package_name, PSecPkgInfoA *p_pkg_info)
 
static void testInitSecurityInterface (void)
 
static void testEnumerateSecurityPackages (void)
 
static void testQuerySecurityPackageInfo (void)
 
 START_TEST (main)
 

Variables

static HMODULE secdll
 
static PSecPkgInfoA *static SEC_CHAR ULONG
 
static PSecPkgInfoA *static SEC_CHAR PLUID
 
static PSecPkgInfoA *static SEC_CHAR PVOID
 
static PSecPkgInfoA *static SEC_CHAR SEC_GET_KEY_FN
 
static PSecPkgInfoA *static SEC_CHAR PCredHandle
 
static PSecPkgInfoA *static SEC_CHAR PTimeStamp
 
static PCtxtHandle
 
static SEC_CHAR PSecBufferDesc
 
static SEC_CHAR PULONG
 

Macro Definition Documentation

◆ _SEC_ERR

#define _SEC_ERR (   x)    case (x): return #x;

◆ SECURITY_WIN32

#define SECURITY_WIN32

Definition at line 21 of file main.c.

◆ X

#define X (   flag)
Value:
if(pkg_info[i].fCapabilities & flag) \
trace("\t" #flag "\n")
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 flag
Definition: glfuncs.h:52
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

Function Documentation

◆ getSecError()

static const char * getSecError ( SECURITY_STATUS  status)
static

Definition at line 74 of file main.c.

75{
76 static char buf[20];
77
78#define _SEC_ERR(x) case (x): return #x;
79 switch(status)
80 {
100 default:
101 sprintf(buf, "%08x\n", status);
102 return buf;
103 }
104#undef _SEC_ERR
105}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define _SEC_ERR(x)
Definition: ps.c:97
#define SEC_E_OK
Definition: winerror.h:2356
#define SEC_E_INVALID_HANDLE
Definition: winerror.h:2910
#define SEC_E_LOGON_DENIED
Definition: winerror.h:2921
#define SEC_E_INTERNAL_ERROR
Definition: winerror.h:2913
#define SEC_E_CANNOT_INSTALL
Definition: winerror.h:2916
#define SEC_E_NO_IMPERSONATION
Definition: winerror.h:2920
#define SEC_E_UNSUPPORTED_FUNCTION
Definition: winerror.h:2911
#define SEC_E_NOT_OWNER
Definition: winerror.h:2915
#define SEC_E_BUFFER_TOO_SMALL
Definition: winerror.h:2937
#define SEC_E_ILLEGAL_MESSAGE
Definition: winerror.h:2943
#define SEC_E_SECPKG_NOT_FOUND
Definition: winerror.h:2914
#define SEC_E_CANNOT_PACK
Definition: winerror.h:2918
#define SEC_E_INVALID_TOKEN
Definition: winerror.h:2917
#define SEC_E_OUT_OF_SEQUENCE
Definition: winerror.h:2925
#define SEC_E_NO_CREDENTIALS
Definition: winerror.h:2923
#define SEC_E_QOP_NOT_SUPPORTED
Definition: winerror.h:2919
#define SEC_E_INSUFFICIENT_MEMORY
Definition: winerror.h:2909
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:2927
#define SEC_E_TARGET_UNKNOWN
Definition: winerror.h:2912

Referenced by testQuerySecurityPackageInfo().

◆ InitFunctionPtrs()

static void InitFunctionPtrs ( void  )
static

Definition at line 50 of file main.c.

51{
52 secdll = LoadLibraryA("secur32.dll");
53 if(!secdll)
54 secdll = LoadLibraryA("security.dll");
55 if(secdll)
56 {
57 pInitSecurityInterfaceA = (PVOID)GetProcAddress(secdll, "InitSecurityInterfaceA");
58 pEnumerateSecurityPackagesA = (PVOID)GetProcAddress(secdll, "EnumerateSecurityPackagesA");
59 pFreeContextBuffer = (PVOID)GetProcAddress(secdll, "FreeContextBuffer");
60 pQuerySecurityPackageInfoA = (PVOID)GetProcAddress(secdll, "QuerySecurityPackageInfoA");
61 pAcquireCredentialsHandleA = (PVOID)GetProcAddress(secdll, "AcquireCredentialsHandleA");
62 pInitializeSecurityContextA = (PVOID)GetProcAddress(secdll, "InitializeSecurityContextA");
63 pCompleteAuthToken = (PVOID)GetProcAddress(secdll, "CompleteAuthToken");
64 pAcceptSecurityContext = (PVOID)GetProcAddress(secdll, "AcceptSecurityContext");
65 pFreeCredentialsHandle = (PVOID)GetProcAddress(secdll, "FreeCredentialsHandle");
66 pDeleteSecurityContext = (PVOID)GetProcAddress(secdll, "DeleteSecurityContext");
67 pQueryContextAttributesA = (PVOID)GetProcAddress(secdll, "QueryContextAttributesA");
68 }
69}
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static HMODULE secdll
Definition: main.c:32
static QUERY_CONTEXT_ATTRIBUTES_FN_A pQueryContextAttributesA
Definition: schannel.c:32
void * PVOID
Definition: typedefs.h:50

Referenced by START_TEST().

◆ PSecurityFunctionTableA()

static PSecurityFunctionTableA ( SEC_ENTRY pInitSecurityInterfaceA)
static

◆ SECURITY_STATUS()

static SECURITY_STATUS ( SEC_ENTRY pEnumerateSecurityPackagesA)
static

◆ setupPackageA()

static SECURITY_STATUS setupPackageA ( SEC_CHAR p_package_name,
PSecPkgInfoA p_pkg_info 
)
static

Definition at line 110 of file main.c.

112{
114
115 ret = pQuerySecurityPackageInfoA( p_package_name, p_pkg_info);
116 return ret;
117}
LONG SECURITY_STATUS
Definition: sspi.h:34
int ret

Referenced by testQuerySecurityPackageInfo().

◆ START_TEST()

START_TEST ( main  )

Definition at line 247 of file main.c.

248{
250 if(pInitSecurityInterfaceA)
252 if(pFreeContextBuffer)
253 {
254 if(pEnumerateSecurityPackagesA)
256 if(pQuerySecurityPackageInfoA)
257 {
259 }
260 }
261 if(secdll)
263}
#define FreeLibrary(x)
Definition: compat.h:748
static void testEnumerateSecurityPackages(void)
Definition: main.c:131
static void testQuerySecurityPackageInfo(void)
Definition: main.c:202
static void InitFunctionPtrs(void)
Definition: main.c:50
static void testInitSecurityInterface(void)
Definition: main.c:122

◆ testEnumerateSecurityPackages()

static void testEnumerateSecurityPackages ( void  )
static

Definition at line 131 of file main.c.

132{
133
134 SECURITY_STATUS sec_status;
135 ULONG num_packages, i;
136 PSecPkgInfoA pkg_info = NULL;
137
138 trace("Running testEnumerateSecurityPackages\n");
139
140 sec_status = pEnumerateSecurityPackagesA(&num_packages, &pkg_info);
141
142 ok(sec_status == SEC_E_OK,
143 "EnumerateSecurityPackages() should return %d, not %08x\n",
144 SEC_E_OK, sec_status);
145
146 if (num_packages == 0)
147 {
149 ok(num_packages > 0, "Number of sec packages should be > 0 ,but is %d\n",
150 num_packages);
151 skip("no sec packages to check\n");
152 return;
153 }
154 else
155 ok(num_packages > 0, "Number of sec packages should be > 0 ,but is %d\n",
156 num_packages);
157
158 ok(pkg_info != NULL,
159 "pkg_info should not be NULL after EnumerateSecurityPackages\n");
160
161 trace("Number of packages: %d\n", num_packages);
162 for(i = 0; i < num_packages; ++i){
163 trace("%d: Package \"%s\"\n", i, pkg_info[i].Name);
164 trace("Supported flags:\n");
165#define X(flag) \
166 if(pkg_info[i].fCapabilities & flag) \
167 trace("\t" #flag "\n")
168
193#undef X
194 trace("Comment: %s\n", pkg_info[i].Comment);
195 trace("\n");
196 }
197
198 pFreeContextBuffer(pkg_info);
199}
@ Comment
Definition: asmpp.cpp:34
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
int trace
Definition: main.c:57
#define NULL
Definition: types.h:112
#define X(x)
#define todo_wine
Definition: custom.c:79
#define SECPKG_FLAG_APPCONTAINER_CHECKS
Definition: sspi.h:149
#define SECPKG_FLAG_TOKEN_ONLY
Definition: sspi.h:128
#define SECPKG_FLAG_IMPERSONATION
Definition: sspi.h:134
#define SECPKG_FLAG_CLIENT_ONLY
Definition: sspi.h:132
#define SECPKG_FLAG_APPCONTAINER_PASSTHROUGH
Definition: sspi.h:148
#define SECPKG_FLAG_STREAM
Definition: sspi.h:136
#define SECPKG_FLAG_EXTENDED_ERROR
Definition: sspi.h:133
#define SECPKG_FLAG_PRIVACY
Definition: sspi.h:127
#define SECPKG_FLAG_RESTRICTED_TOKENS
Definition: sspi.h:145
#define SECPKG_FLAG_MULTI_REQUIRED
Definition: sspi.h:131
#define SECPKG_FLAG_CONNECTION
Definition: sspi.h:130
#define SECPKG_FLAG_NEGOTIABLE
Definition: sspi.h:137
#define SECPKG_FLAG_DELEGATION
Definition: sspi.h:143
#define SECPKG_FLAG_INTEGRITY
Definition: sspi.h:126
#define SECPKG_FLAG_ASCII_BUFFERS
Definition: sspi.h:140
#define SECPKG_FLAG_MUTUAL_AUTH
Definition: sspi.h:142
#define SECPKG_FLAG_DATAGRAM
Definition: sspi.h:129
#define SECPKG_FLAG_NEGO_EXTENDER
Definition: sspi.h:146
#define SECPKG_FLAG_NEGOTIABLE2
Definition: sspi.h:147
#define SECPKG_FLAG_LOGON
Definition: sspi.h:139
#define SECPKG_FLAG_READONLY_WITH_CHECKSUM
Definition: sspi.h:144
#define SECPKG_FLAG_FRAGMENT
Definition: sspi.h:141
#define SECPKG_FLAG_ACCEPT_WIN32_NAME
Definition: sspi.h:135
#define SECPKG_FLAG_GSS_COMPATIBLE
Definition: sspi.h:138
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ testInitSecurityInterface()

static void testInitSecurityInterface ( void  )
static

Definition at line 122 of file main.c.

123{
124 PSecurityFunctionTableA sec_fun_table = NULL;
125
126 sec_fun_table = pInitSecurityInterfaceA();
127 ok(sec_fun_table != NULL, "InitSecurityInterface() returned NULL.\n");
128
129}

Referenced by START_TEST().

◆ testQuerySecurityPackageInfo()

static void testQuerySecurityPackageInfo ( void  )
static

Definition at line 202 of file main.c.

203{
204 SECURITY_STATUS sec_status;
205 PSecPkgInfoA pkg_info;
206 static SEC_CHAR ntlm[] = "NTLM",
207 winetest[] = "Winetest";
208
209 trace("Running testQuerySecurityPackageInfo\n");
210
211 /* Test with an existing package. Test should pass */
212
213 pkg_info = (void *)0xdeadbeef;
214 sec_status = setupPackageA(ntlm, &pkg_info);
215
216 ok((sec_status == SEC_E_OK) || (sec_status == SEC_E_SECPKG_NOT_FOUND) ||
217 broken(sec_status == SEC_E_UNSUPPORTED_FUNCTION), /* win95 */
218 "Return value of QuerySecurityPackageInfo() shouldn't be %s\n",
219 getSecError(sec_status) );
220
221 if (sec_status == SEC_E_OK)
222 {
223 ok(pkg_info != (void *)0xdeadbeef, "wrong pkg_info address %p\n", pkg_info);
224 ok(pkg_info->wVersion == 1, "wVersion always should be 1, but is %d\n", pkg_info->wVersion);
225 /* there is no point in testing pkg_info->cbMaxToken since it varies
226 * between implementations.
227 */
228
229 sec_status = pFreeContextBuffer(pkg_info);
230 ok( sec_status == SEC_E_OK,
231 "Return value of FreeContextBuffer() shouldn't be %s\n",
232 getSecError(sec_status) );
233 }
234
235 /* Test with a nonexistent package, test should fail */
236
237 pkg_info = (void *)0xdeadbeef;
238 sec_status = pQuerySecurityPackageInfoA(winetest, &pkg_info);
239
240 ok( sec_status == SEC_E_SECPKG_NOT_FOUND,
241 "Return value of QuerySecurityPackageInfo() should be %s for a nonexistent package\n",
243
244 ok(pkg_info == (void *)0xdeadbeef, "wrong pkg_info address %p\n", pkg_info);
245}
#define broken(x)
Definition: _sntprintf.h:21
static SECURITY_STATUS setupPackageA(SEC_CHAR *p_package_name, PSecPkgInfoA *p_pkg_info)
Definition: main.c:110
static const char * getSecError(SECURITY_STATUS status)
Definition: main.c:74
static CHAR winetest[]
Definition: info.c:56
CHAR SEC_CHAR
Definition: sspi.h:30
unsigned short wVersion
Definition: sspi.h:105

Referenced by START_TEST().

Variable Documentation

◆ PCredHandle

Definition at line 38 of file main.c.

◆ PCtxtHandle

Definition at line 39 of file main.c.

◆ PLUID

Definition at line 38 of file main.c.

◆ PSecBufferDesc

Definition at line 40 of file main.c.

◆ PTimeStamp

Definition at line 38 of file main.c.

◆ PULONG

Definition at line 41 of file main.c.

◆ PVOID

Definition at line 38 of file main.c.

◆ SEC_GET_KEY_FN

PSecPkgInfoA *static SEC_CHAR SEC_GET_KEY_FN

Definition at line 38 of file main.c.

◆ secdll

HMODULE secdll
static

Definition at line 32 of file main.c.

Referenced by InitFunctionPtrs(), and START_TEST().

◆ ULONG

Definition at line 38 of file main.c.