Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
61e836b9
Commit
61e836b9
authored
Oct 30, 2007
by
Rob Shearman
Committed by
Alexandre Julliard
Oct 31, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Implement CredEnumerateW.
parent
72bd8765
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
166 additions
and
8 deletions
+166
-8
advapi.c
dlls/advapi32/advapi.c
+0
-8
cred.c
dlls/advapi32/cred.c
+166
-0
No files found.
dlls/advapi32/advapi.c
View file @
61e836b9
...
...
@@ -301,11 +301,3 @@ BOOL WINAPI CredEnumerateA(LPCSTR filter, DWORD flags, DWORD *count,
credentials
);
return
FALSE
;
}
BOOL
WINAPI
CredEnumerateW
(
LPCWSTR
filter
,
DWORD
flags
,
DWORD
*
count
,
PCREDENTIALW
**
credentials
)
{
FIXME
(
"(%s, %08x, %p, %p)
\n
"
,
debugstr_w
(
filter
),
flags
,
count
,
credentials
);
return
FALSE
;
}
dlls/advapi32/cred.c
View file @
61e836b9
...
...
@@ -436,6 +436,172 @@ BOOL WINAPI CredDeleteW(LPCWSTR TargetName, DWORD Type, DWORD Flags)
return
TRUE
;
}
static
BOOL
credential_matches_filter
(
HKEY
hkeyCred
,
LPCWSTR
filter
)
{
if
(
!
filter
)
return
TRUE
;
FIXME
(
"%s
\n
"
,
debugstr_w
(
filter
));
return
TRUE
;
}
/******************************************************************************
* CredEnumerateW [ADVAPI32.@]
*/
BOOL
WINAPI
CredEnumerateW
(
LPCWSTR
Filter
,
DWORD
Flags
,
DWORD
*
Count
,
PCREDENTIALW
**
Credentials
)
{
HKEY
hkeyMgr
;
HKEY
hkeyCred
;
DWORD
ret
;
LPWSTR
target_name
;
DWORD
target_name_len
;
DWORD
len
;
char
*
buffer
;
DWORD
i
;
BYTE
key_data
[
KEY_SIZE
];
TRACE
(
"(%s, 0x%x, %p, %p)
\n
"
,
debugstr_w
(
Filter
),
Flags
,
Count
,
Credentials
);
if
(
Flags
)
{
SetLastError
(
ERROR_INVALID_FLAGS
);
return
FALSE
;
}
ret
=
open_cred_mgr_key
(
&
hkeyMgr
,
FALSE
);
if
(
ret
!=
ERROR_SUCCESS
)
{
WARN
(
"couldn't open/create manager key, error %d
\n
"
,
ret
);
SetLastError
(
ERROR_NO_SUCH_LOGON_SESSION
);
return
FALSE
;
}
ret
=
get_cred_mgr_encryption_key
(
hkeyMgr
,
key_data
);
if
(
ret
!=
ERROR_SUCCESS
)
{
RegCloseKey
(
hkeyMgr
);
SetLastError
(
ret
);
return
FALSE
;
}
ret
=
RegQueryInfoKeyW
(
hkeyMgr
,
NULL
,
NULL
,
NULL
,
NULL
,
&
target_name_len
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
ret
!=
ERROR_SUCCESS
)
{
RegCloseKey
(
hkeyMgr
);
SetLastError
(
ret
);
return
FALSE
;
}
target_name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
target_name_len
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
target_name
)
{
RegCloseKey
(
hkeyMgr
);
SetLastError
(
ERROR_OUTOFMEMORY
);
return
FALSE
;
}
*
Count
=
0
;
len
=
0
;
for
(
i
=
0
;;
i
++
)
{
ret
=
RegEnumKeyW
(
hkeyMgr
,
i
,
target_name
,
target_name_len
+
1
);
if
(
ret
==
ERROR_NO_MORE_ITEMS
)
{
ret
=
ERROR_SUCCESS
;
break
;
}
else
if
(
ret
!=
ERROR_SUCCESS
)
{
ret
=
ERROR_SUCCESS
;
continue
;
}
ret
=
RegOpenKeyExW
(
hkeyMgr
,
target_name
,
0
,
KEY_QUERY_VALUE
,
&
hkeyCred
);
if
(
ret
!=
ERROR_SUCCESS
)
{
ret
=
ERROR_SUCCESS
;
continue
;
}
if
(
!
credential_matches_filter
(
hkeyCred
,
Filter
))
{
RegCloseKey
(
hkeyCred
);
continue
;
}
len
+=
sizeof
(
CREDENTIALW
);
ret
=
read_credential
(
hkeyCred
,
NULL
,
key_data
,
NULL
,
&
len
);
RegCloseKey
(
hkeyCred
);
if
(
ret
!=
ERROR_SUCCESS
)
break
;
(
*
Count
)
++
;
}
if
(
ret
==
ERROR_SUCCESS
&&
*
Count
==
0
)
ret
=
ERROR_NOT_FOUND
;
if
(
ret
!=
ERROR_SUCCESS
)
{
HeapFree
(
GetProcessHeap
(),
0
,
target_name
);
RegCloseKey
(
hkeyMgr
);
SetLastError
(
ret
);
return
FALSE
;
}
len
+=
*
Count
+
sizeof
(
PCREDENTIALW
);
if
(
ret
==
ERROR_SUCCESS
)
{
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
*
Credentials
=
(
PCREDENTIALW
*
)
buffer
;
if
(
buffer
)
{
buffer
+=
*
Count
*
sizeof
(
PCREDENTIALW
);
*
Count
=
0
;
for
(
i
=
0
;;
i
++
)
{
ret
=
RegEnumKeyW
(
hkeyMgr
,
i
,
target_name
,
target_name_len
+
1
);
if
(
ret
==
ERROR_NO_MORE_ITEMS
)
{
ret
=
ERROR_SUCCESS
;
break
;
}
else
if
(
ret
!=
ERROR_SUCCESS
)
{
ret
=
ERROR_SUCCESS
;
continue
;
}
TRACE
(
"target_name = %s
\n
"
,
debugstr_w
(
target_name
));
ret
=
RegOpenKeyExW
(
hkeyMgr
,
target_name
,
0
,
KEY_QUERY_VALUE
,
&
hkeyCred
);
if
(
ret
!=
ERROR_SUCCESS
)
{
ret
=
ERROR_SUCCESS
;
continue
;
}
if
(
!
credential_matches_filter
(
hkeyCred
,
Filter
))
{
RegCloseKey
(
hkeyCred
);
continue
;
}
len
=
sizeof
(
CREDENTIALW
);
(
*
Credentials
)[
*
Count
]
=
(
PCREDENTIALW
)
buffer
;
ret
=
read_credential
(
hkeyCred
,
(
*
Credentials
)[
*
Count
],
key_data
,
buffer
+
sizeof
(
CREDENTIALW
),
&
len
);
RegCloseKey
(
hkeyCred
);
if
(
ret
!=
ERROR_SUCCESS
)
break
;
buffer
+=
len
;
(
*
Count
)
++
;
}
}
else
ret
=
ERROR_OUTOFMEMORY
;
}
HeapFree
(
GetProcessHeap
(),
0
,
target_name
);
RegCloseKey
(
hkeyMgr
);
if
(
ret
!=
ERROR_SUCCESS
)
{
SetLastError
(
ret
);
return
FALSE
;
}
return
TRUE
;
}
/******************************************************************************
* CredFree [ADVAPI32.@]
*/
...
...
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