Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johnny Cai
wine
Commits
b2b8a0d1
Commit
b2b8a0d1
authored
21 years ago
by
Michael McCormack
Committed by
Alexandre Julliard
21 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Implemented password caching.
parent
5f175508
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dlls/mpr/pwcache.c
+101
-7
101 additions, 7 deletions
dlls/mpr/pwcache.c
include/winnetwk.h
+5
-1
5 additions, 1 deletion
include/winnetwk.h
with
106 additions
and
8 deletions
dlls/mpr/pwcache.c
+
101
−
7
View file @
b2b8a0d1
...
...
@@ -2,6 +2,7 @@
* MPR Password Cache functions
*
* Copyright 1999 Ulrich Weigand
* Copyright 2003 Mike McCormack for Codeweavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -18,12 +19,33 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include
<stdio.h>
#include
"winbase.h"
#include
"winnetwk.h"
#include
"winreg.h"
#include
"wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
mpr
);
static
const
char
mpr_key
[]
=
"Software
\\
Wine
\\
Wine
\\
Mpr
\\
"
;
static
LPSTR
MPR_GetValueName
(
LPSTR
pbResource
,
WORD
cbResource
,
BYTE
nType
)
{
LPSTR
name
;
DWORD
i
,
x
=
0
;
/* just a hash so the value name doesn't get too large */
for
(
i
=
0
;
i
<
cbResource
;
i
++
)
x
=
((
x
<<
7
)
|
(
x
>>
25
))
^
toupper
(
pbResource
[
i
]);
name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
0x10
);
if
(
name
)
sprintf
(
name
,
"I-%08lX-%02X"
,
x
,
nType
);
TRACE
(
"Value is %s
\n
"
,
name
);
return
name
;
}
/**************************************************************************
* WNetCachePassword [MPR.@] Saves password in cache
*
...
...
@@ -45,12 +67,36 @@ DWORD WINAPI WNetCachePassword(
WORD
x
)
{
FIXME
(
"(%p(%s), %d, %p(%s), %d, %d, 0x%08x): stub
\n
"
,
HKEY
hkey
;
DWORD
r
;
LPSTR
valname
;
WARN
(
"(%p(%s), %d, %p(%s), %d, %d, 0x%08x): totally insecure
\n
"
,
pbResource
,
debugstr_a
(
pbResource
),
cbResource
,
pbPassword
,
debugstr_a
(
pbPassword
),
cbPassword
,
nType
,
x
);
return
WN_NOT_SUPPORTED
;
r
=
RegCreateKeyA
(
HKEY_CURRENT_USER
,
mpr_key
,
&
hkey
);
if
(
r
)
return
WN_ACCESS_DENIED
;
valname
=
MPR_GetValueName
(
pbResource
,
cbResource
,
nType
);
if
(
valname
)
{
r
=
RegSetValueExA
(
hkey
,
valname
,
0
,
REG_BINARY
,
pbPassword
,
cbPassword
);
if
(
r
)
r
=
WN_ACCESS_DENIED
;
else
r
=
WN_SUCCESS
;
HeapFree
(
GetProcessHeap
(),
0
,
valname
);
}
else
r
=
WN_OUT_OF_MEMORY
;
RegCloseKey
(
hkey
);
return
r
;
}
/*****************************************************************
...
...
@@ -59,10 +105,31 @@ DWORD WINAPI WNetCachePassword(
UINT
WINAPI
WNetRemoveCachedPassword
(
LPSTR
pbResource
,
WORD
cbResource
,
BYTE
nType
)
{
FIXME
(
"(%p(%s), %d, %d): stub
\n
"
,
HKEY
hkey
;
DWORD
r
;
LPSTR
valname
;
WARN
(
"(%p(%s), %d, %d): totally insecure
\n
"
,
pbResource
,
debugstr_a
(
pbResource
),
cbResource
,
nType
);
return
WN_NOT_SUPPORTED
;
r
=
RegCreateKeyA
(
HKEY_CURRENT_USER
,
mpr_key
,
&
hkey
);
if
(
r
)
return
WN_ACCESS_DENIED
;
valname
=
MPR_GetValueName
(
pbResource
,
cbResource
,
nType
);
if
(
valname
)
{
r
=
RegDeleteValueA
(
hkey
,
valname
);
if
(
r
)
r
=
WN_ACCESS_DENIED
;
else
r
=
WN_SUCCESS
;
HeapFree
(
GetProcessHeap
(),
0
,
valname
);
}
else
r
=
WN_OUT_OF_MEMORY
;
return
r
;
}
/*****************************************************************
...
...
@@ -89,11 +156,34 @@ DWORD WINAPI WNetGetCachedPassword(
LPWORD
pcbPassword
,
/* [out] Receives size of password */
BYTE
nType
)
/* [in] Type of password to retrieve */
{
FIXME
(
"(%p(%s), %d, %p, %p, %d): stub
\n
"
,
HKEY
hkey
;
DWORD
r
,
type
=
0
,
sz
;
LPSTR
valname
;
WARN
(
"(%p(%s), %d, %p, %p, %d): stub
\n
"
,
pbResource
,
debugstr_a
(
pbResource
),
cbResource
,
pbPassword
,
pcbPassword
,
nType
);
return
WN_NOT_SUPPORTED
;
r
=
RegCreateKeyA
(
HKEY_CURRENT_USER
,
mpr_key
,
&
hkey
);
if
(
r
)
return
WN_ACCESS_DENIED
;
valname
=
MPR_GetValueName
(
pbResource
,
cbResource
,
nType
);
if
(
valname
)
{
sz
=
*
pcbPassword
;
r
=
RegQueryValueExA
(
hkey
,
valname
,
0
,
&
type
,
pbPassword
,
&
sz
);
*
pcbPassword
=
sz
;
if
(
r
)
r
=
WN_ACCESS_DENIED
;
else
r
=
WN_SUCCESS
;
HeapFree
(
GetProcessHeap
(),
0
,
valname
);
}
else
r
=
WN_OUT_OF_MEMORY
;
return
r
;
}
/*******************************************************************
...
...
@@ -101,6 +191,10 @@ DWORD WINAPI WNetGetCachedPassword(
*
* NOTES
* the parameter count is verifyed
*
* This function is a huge security risk, as virii and such can use
* it to grab all the passwords in the cache. It's bad enough to
* store the passwords (insecurely).
*
* observed values:
* arg1 ptr 0x40xxxxxx -> (no string)
...
...
@@ -115,7 +209,7 @@ DWORD WINAPI WNetGetCachedPassword(
UINT
WINAPI
WNetEnumCachedPasswords
(
LPSTR
pbPrefix
,
WORD
cbPrefix
,
BYTE
nType
,
ENUMPASSWORDPROC
enumPasswordProc
,
DWORD
x
)
{
FIXME
(
"(%p(%s), %d, %d, %p, 0x%08lx):
stub
\n
"
,
WARN
(
"(%p(%s), %d, %d, %p, 0x%08lx):
don't implement this
\n
"
,
pbPrefix
,
debugstr_a
(
pbPrefix
),
cbPrefix
,
nType
,
enumPasswordProc
,
x
);
...
...
This diff is collapsed.
Click to expand it.
include/winnetwk.h
+
5
−
1
View file @
b2b8a0d1
...
...
@@ -68,7 +68,8 @@
#define RESOURCEUSAGE_CONTAINER 0x00000002
#define RESOURCEUSAGE_NOLOCALDEVICE 0x00000004
#define RESOURCEUSAGE_SIBLING 0x00000008
#define RESOURCEUSAGE_ALL (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER)
#define RESOURCEUSAGE_ATTACHED 0x00000010
#define RESOURCEUSAGE_ALL (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED)
#define RESOURCEUSAGE_RESERVED 0x80000000
#define RESOURCEDISPLAYTYPE_GENERIC 0x00000000
...
...
@@ -388,5 +389,8 @@ typedef struct tagPASSWORD_CACHE_ENTRY
typedef
BOOL
(
CALLBACK
*
ENUMPASSWORDPROC
)(
PASSWORD_CACHE_ENTRY
*
,
DWORD
);
UINT
WINAPI
WNetEnumCachedPasswords
(
LPSTR
,
WORD
,
BYTE
,
ENUMPASSWORDPROC
,
DWORD
);
DWORD
WINAPI
WNetGetCachedPassword
(
LPSTR
,
WORD
,
LPSTR
,
LPWORD
,
BYTE
);
DWORD
WINAPI
WNetCachePassword
(
LPSTR
,
WORD
,
LPSTR
,
WORD
,
BYTE
,
WORD
);
#endif
/* _WINNETWK_H_ */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment