Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
63a643e5
Commit
63a643e5
authored
Aug 30, 2005
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Authors: James Hawkins <truiken@gmail.com>, Juan Lang <juan_lang@yahoo.com>
Use a standard wine list for packages and providers.
parent
28022e80
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
146 deletions
+75
-146
secur32.c
dlls/secur32/secur32.c
+70
-145
secur32_priv.h
dlls/secur32/secur32_priv.h
+4
-0
main.c
dlls/secur32/tests/main.c
+1
-1
No files found.
dlls/secur32/secur32.c
View file @
63a643e5
...
...
@@ -30,6 +30,7 @@
#include "ntsecapi.h"
#include "thunks.h"
#include "wine/list.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
secur32
);
...
...
@@ -42,34 +43,20 @@ typedef struct _SecurePackageTable
{
DWORD
numPackages
;
DWORD
numAllocated
;
SecurePackage
table
[
1
]
;
struct
list
table
;
}
SecurePackageTable
;
typedef
struct
_SecureProviderTable
{
DWORD
numProviders
;
DWORD
numAllocated
;
SecureProvider
table
[
1
]
;
struct
list
table
;
}
SecureProviderTable
;
/**
* Prototypes
*/
/* Makes sure table has space for at least howBig entries. If table is NULL,
* returns a newly allocated table. Otherwise returns the address of the
* modified table, which may not be the same was when called.
*/
static
SecurePackageTable
*
_resizePackageTable
(
SecurePackageTable
*
table
,
DWORD
howBig
);
/* Makes sure table has space for at least howBig entries. If table is NULL,
* returns a newly allocated table. Otherwise returns the address of the
* modified table, which may not be the same was when called.
*/
static
SecureProviderTable
*
_resizeProviderTable
(
SecureProviderTable
*
table
,
DWORD
howBig
);
/* Tries to load moduleName as a provider. If successful, enumerates what
* packages it can and adds them to the package and provider tables. Resizes
* tables as necessary.
...
...
@@ -173,89 +160,6 @@ PSecurityFunctionTableW WINAPI InitSecurityInterfaceW(void)
return
&
securityFunctionTableW
;
}
/* Allocates or resizes table to have space for at least howBig packages.
* Uses Heap functions, because needs to be able to reallocate.
*/
static
SecurePackageTable
*
_resizePackageTable
(
SecurePackageTable
*
table
,
DWORD
howBig
)
{
SecurePackageTable
*
ret
;
EnterCriticalSection
(
&
cs
);
if
(
table
)
{
if
(
table
->
numAllocated
<
howBig
)
{
ret
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
table
,
sizeof
(
SecurePackageTable
)
+
(
howBig
-
1
)
*
sizeof
(
SecurePackage
));
if
(
ret
)
{
ret
->
numAllocated
=
howBig
;
table
=
ret
;
}
}
else
ret
=
table
;
}
else
{
DWORD
numAllocated
=
(
howBig
>
1
?
howBig
:
1
);
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
SecurePackageTable
)
+
(
numAllocated
-
1
)
*
sizeof
(
SecurePackage
));
if
(
ret
)
{
ret
->
numAllocated
=
numAllocated
;
ret
->
numPackages
=
0
;
}
}
LeaveCriticalSection
(
&
cs
);
return
ret
;
}
/* Allocates or resizes table to have space for at least howBig providers.
* Uses Heap functions, because needs to be able to reallocate.
*/
static
SecureProviderTable
*
_resizeProviderTable
(
SecureProviderTable
*
table
,
DWORD
howBig
)
{
SecureProviderTable
*
ret
;
EnterCriticalSection
(
&
cs
);
if
(
table
)
{
if
(
table
->
numAllocated
<
howBig
)
{
ret
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
table
,
sizeof
(
SecureProviderTable
)
+
(
howBig
-
1
)
*
sizeof
(
SecureProvider
));
if
(
ret
)
{
ret
->
numAllocated
=
howBig
;
table
=
ret
;
}
}
else
ret
=
table
;
}
else
{
DWORD
numAllocated
=
(
howBig
>
1
?
howBig
:
1
);
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
SecureProviderTable
)
+
(
numAllocated
-
1
)
*
sizeof
(
SecureProvider
));
if
(
ret
)
{
ret
->
numAllocated
=
numAllocated
;
ret
->
numProviders
=
0
;
}
}
LeaveCriticalSection
(
&
cs
);
return
ret
;
}
PWSTR
SECUR32_strdupW
(
PCWSTR
str
)
{
PWSTR
ret
;
...
...
@@ -487,12 +391,23 @@ SecureProvider *SECUR32_addProvider(PSecurityFunctionTableA fnTableA,
SecureProvider
*
ret
;
EnterCriticalSection
(
&
cs
);
providerTable
=
_resizeProviderTable
(
providerTable
,
providerTable
?
providerTable
->
numProviders
+
1
:
1
);
if
(
providerTable
)
if
(
!
providerTable
)
{
ret
=
&
providerTable
->
table
[
providerTable
->
numProviders
++
];
providerTable
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
SecureProviderTable
));
if
(
!
providerTable
)
return
NULL
;
list_init
(
&
providerTable
->
table
);
}
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
SecureProvider
));
if
(
!
ret
)
return
NULL
;
list_add_tail
(
&
providerTable
->
table
,
&
ret
->
entry
);
ret
->
lib
=
NULL
;
if
(
fnTableA
||
fnTableW
)
{
ret
->
moduleName
=
NULL
;
...
...
@@ -505,9 +420,7 @@ SecureProvider *SECUR32_addProvider(PSecurityFunctionTableA fnTableA,
ret
->
moduleName
=
SECUR32_strdupW
(
moduleName
);
ret
->
loaded
=
FALSE
;
}
}
else
ret
=
NULL
;
LeaveCriticalSection
(
&
cs
);
return
ret
;
}
...
...
@@ -515,20 +428,30 @@ SecureProvider *SECUR32_addProvider(PSecurityFunctionTableA fnTableA,
void
SECUR32_addPackages
(
SecureProvider
*
provider
,
ULONG
toAdd
,
const
SecPkgInfoA
*
infoA
,
const
SecPkgInfoW
*
infoW
)
{
ULONG
i
;
assert
(
provider
);
assert
(
infoA
||
infoW
);
EnterCriticalSection
(
&
cs
);
packageTable
=
_resizePackageTable
(
packageTable
,
packageTable
?
packageTable
->
numPackages
+
toAdd
:
toAdd
);
if
(
packageTable
)
if
(
!
packageTable
)
{
ULONG
i
;
packageTable
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
SecurePackageTable
));
if
(
!
packageTable
)
return
;
packageTable
->
numPackages
=
0
;
list_init
(
&
packageTable
->
table
);
}
for
(
i
=
0
;
i
<
toAdd
;
i
++
)
{
SecurePackage
*
package
=
&
packageTable
->
table
[
packageTable
->
numPackages
+
i
];
SecurePackage
*
package
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
SecurePackage
));
if
(
!
package
)
continue
;
list_add_tail
(
&
packageTable
->
table
,
&
package
->
entry
);
package
->
provider
=
provider
;
_copyPackageInfo
(
&
package
->
infoW
,
...
...
@@ -536,7 +459,7 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
infoW
?
&
infoW
[
i
]
:
NULL
);
}
packageTable
->
numPackages
+=
toAdd
;
}
LeaveCriticalSection
(
&
cs
);
}
...
...
@@ -653,11 +576,12 @@ SecurePackage *SECUR32_findPackageW(PWSTR packageName)
if
(
packageTable
&&
packageName
)
{
DWORD
i
;
LIST_FOR_EACH_ENTRY
(
ret
,
&
packageTable
->
table
,
SecurePackage
,
entry
)
{
if
(
!
lstrcmpiW
(
ret
->
infoW
.
Name
,
packageName
))
break
;
}
for
(
i
=
0
,
ret
=
NULL
;
!
ret
&&
i
<
packageTable
->
numPackages
;
i
++
)
if
(
!
lstrcmpiW
(
packageTable
->
table
[
i
].
infoW
.
Name
,
packageName
))
ret
=
&
packageTable
->
table
[
i
];
if
(
ret
&&
ret
->
provider
&&
!
ret
->
provider
->
loaded
)
{
ret
->
provider
->
lib
=
LoadLibraryW
(
ret
->
provider
->
moduleName
);
...
...
@@ -706,32 +630,38 @@ SecurePackage *SECUR32_findPackageA(PSTR packageName)
static
void
SECUR32_freeProviders
(
void
)
{
DWORD
i
;
SecurePackage
*
package
;
SecureProvider
*
provider
;
TRACE
(
"
\n
"
);
EnterCriticalSection
(
&
cs
);
if
(
packageTable
)
{
for
(
i
=
0
;
i
<
packageTable
->
numPackages
;
i
++
)
LIST_FOR_EACH_ENTRY
(
package
,
&
packageTable
->
table
,
SecurePackage
,
entry
)
{
SECUR32_FREE
(
package
Table
->
table
[
i
].
infoW
.
Name
);
SECUR32_FREE
(
package
Table
->
table
[
i
].
infoW
.
Comment
);
SECUR32_FREE
(
package
->
infoW
.
Name
);
SECUR32_FREE
(
package
->
infoW
.
Comment
);
}
HeapFree
(
GetProcessHeap
(),
0
,
packageTable
);
packageTable
=
NULL
;
}
if
(
providerTable
)
{
for
(
i
=
0
;
i
<
providerTable
->
numProviders
;
i
++
)
LIST_FOR_EACH_ENTRY
(
provider
,
&
providerTable
->
table
,
SecureProvider
,
entry
)
{
if
(
provider
Table
->
table
[
i
].
moduleName
)
SECUR32_FREE
(
provider
Table
->
table
[
i
].
moduleName
);
if
(
provider
Table
->
table
[
i
].
lib
)
FreeLibrary
(
provider
Table
->
table
[
i
].
lib
);
if
(
provider
->
moduleName
)
SECUR32_FREE
(
provider
->
moduleName
);
if
(
provider
->
lib
)
FreeLibrary
(
provider
->
lib
);
}
HeapFree
(
GetProcessHeap
(),
0
,
providerTable
);
providerTable
=
NULL
;
}
LeaveCriticalSection
(
&
cs
);
DeleteCriticalSection
(
&
cs
);
}
...
...
@@ -773,50 +703,45 @@ SECURITY_STATUS WINAPI EnumerateSecurityPackagesW(PULONG pcPackages,
EnterCriticalSection
(
&
cs
);
if
(
packageTable
)
{
ULONG
i
;
SecurePackage
*
package
;
size_t
bytesNeeded
;
bytesNeeded
=
packageTable
->
numPackages
*
sizeof
(
SecPkgInfoW
);
for
(
i
=
0
;
i
<
packageTable
->
numPackages
;
i
++
)
LIST_FOR_EACH_ENTRY
(
package
,
&
packageTable
->
table
,
SecurePackage
,
entry
)
{
if
(
packageTable
->
table
[
i
].
infoW
.
Name
)
bytesNeeded
+=
(
lstrlenW
(
packageTable
->
table
[
i
].
infoW
.
Name
)
+
1
)
*
sizeof
(
WCHAR
);
if
(
packageTable
->
table
[
i
].
infoW
.
Comment
)
bytesNeeded
+=
(
lstrlenW
(
packageTable
->
table
[
i
].
infoW
.
Comment
)
+
1
)
*
sizeof
(
WCHAR
);
if
(
package
->
infoW
.
Name
)
bytesNeeded
+=
(
lstrlenW
(
package
->
infoW
.
Name
)
+
1
)
*
sizeof
(
WCHAR
);
if
(
package
->
infoW
.
Comment
)
bytesNeeded
+=
(
lstrlenW
(
package
->
infoW
.
Comment
)
+
1
)
*
sizeof
(
WCHAR
);
}
if
(
bytesNeeded
)
{
*
ppPackageInfo
=
(
PSecPkgInfoW
)
SECUR32_ALLOC
(
bytesNeeded
);
if
(
*
ppPackageInfo
)
{
ULONG
i
=
0
;
PWSTR
nextString
;
*
pcPackages
=
packageTable
->
numPackages
;
nextString
=
(
PWSTR
)((
PBYTE
)
*
ppPackageInfo
+
packageTable
->
numPackages
*
sizeof
(
SecPkgInfoW
));
for
(
i
=
0
;
i
<
packageTable
->
numPackages
;
i
++
)
LIST_FOR_EACH_ENTRY
(
package
,
&
packageTable
->
table
,
SecurePackage
,
entry
)
{
PSecPkgInfoW
pkgInfo
=
*
ppPackageInfo
+
i
;
PSecPkgInfoW
pkgInfo
=
*
ppPackageInfo
+
i
++
;
memcpy
(
pkgInfo
,
&
packageTable
->
table
[
i
].
infoW
,
sizeof
(
SecPkgInfoW
));
if
(
packageTable
->
table
[
i
].
infoW
.
Name
)
memcpy
(
pkgInfo
,
&
package
->
infoW
,
sizeof
(
SecPkgInfoW
));
if
(
package
->
infoW
.
Name
)
{
pkgInfo
->
Name
=
nextString
;
lstrcpyW
(
nextString
,
package
Table
->
table
[
i
].
infoW
.
Name
);
lstrcpyW
(
nextString
,
package
->
infoW
.
Name
);
nextString
+=
lstrlenW
(
nextString
)
+
1
;
}
else
pkgInfo
->
Name
=
NULL
;
if
(
package
Table
->
table
[
i
].
infoW
.
Comment
)
if
(
package
->
infoW
.
Comment
)
{
pkgInfo
->
Comment
=
nextString
;
lstrcpyW
(
nextString
,
packageTable
->
table
[
i
].
infoW
.
Comment
);
lstrcpyW
(
nextString
,
package
->
infoW
.
Comment
);
nextString
+=
lstrlenW
(
nextString
)
+
1
;
}
else
...
...
dlls/secur32/secur32_priv.h
View file @
63a643e5
...
...
@@ -21,6 +21,8 @@
#ifndef __SECUR32_PRIV_H__
#define __SECUR32_PRIV_H__
#include "wine/list.h"
/* Memory allocation functions for memory accessible by callers of secur32.
* There is no REALLOC, because LocalReAlloc can only work if used in
* conjunction with LMEM_MOVEABLE and LocalLock, but callers aren't using
...
...
@@ -34,6 +36,7 @@
typedef
struct
_SecureProvider
{
struct
list
entry
;
BOOL
loaded
;
PWSTR
moduleName
;
HMODULE
lib
;
...
...
@@ -43,6 +46,7 @@ typedef struct _SecureProvider
typedef
struct
_SecurePackage
{
struct
list
entry
;
SecPkgInfoW
infoW
;
SecureProvider
*
provider
;
}
SecurePackage
;
...
...
dlls/secur32/tests/main.c
View file @
63a643e5
...
...
@@ -224,7 +224,7 @@ static void testEnumerateSecurityPackages(void)
sec_status
=
EnumerateSecurityPackages
(
&
num_packages
,
&
pkg_info
);
ok
(
sec_status
==
SEC_E_OK
,
"EnumerateSecurityPackages() should return %ld, not %
ld
\n
"
,
"EnumerateSecurityPackages() should return %ld, not %
08lx
\n
"
,
(
LONG
)
SEC_E_OK
,
(
LONG
)
sec_status
);
ok
(
num_packages
>
0
,
"Number of sec packages should be > 0 ,but is %ld
\n
"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment