This implementation is based on the Geoff Chappell description.
Based off patch by Dmitry Timoshkov.
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/shell32/shellreg.c | 25 ++++++++++++++++++++++--- dlls/shell32/tests/shellole.c | 29 +++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/dlls/shell32/shellreg.c b/dlls/shell32/shellreg.c index 356ec4e..514f994 100644 --- a/dlls/shell32/shellreg.c +++ b/dlls/shell32/shellreg.c @@ -34,6 +34,7 @@
#include "undocshell.h"
+#include "wine/unicode.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(shell); @@ -154,7 +155,25 @@ HRESULT WINAPI SHRegCloseKey (HKEY hkey) */ HRESULT WINAPI SHCreateSessionKey(REGSAM access, HKEY *hkey) { - FIXME("stub: %d %p\n", access, hkey); - *hkey = NULL; - return E_NOTIMPL; + static const WCHAR session_format[] = { + 'S','o','f','t','w','a','r','e','\','M','i','c','r','o','s','o','f','t','\', + 'W','i','n','d','o','w','s','\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\', + 'E','x','p','l','o','r','e','r','\','S','e','s','s','i','o','n','I','n','f','o','\','%','d',0}; + DWORD session; + static WCHAR session_reg_str[sizeof(session_format) + 16]; + + if(hkey) + *hkey = NULL; + + if(!access) + return E_ACCESSDENIED; + + if(!ProcessIdToSessionId( GetCurrentProcessId(), &session)) + return E_INVALIDARG; + + sprintfW(session_reg_str, session_format, session); + + TRACE("using session key %s\n", debugstr_w(session_reg_str)); + return RegCreateKeyExW(HKEY_CURRENT_USER, session_reg_str, 0, NULL, + REG_OPTION_VOLATILE, access, NULL, hkey, NULL); } diff --git a/dlls/shell32/tests/shellole.c b/dlls/shell32/tests/shellole.c index f611faf..9e3836a 100644 --- a/dlls/shell32/tests/shellole.c +++ b/dlls/shell32/tests/shellole.c @@ -862,8 +862,15 @@ static void test_DragQueryFile(void)
static void test_SHCreateSessionKey(void) { + static const WCHAR session_format[] = { + 'S','o','f','t','w','a','r','e','\','M','i','c','r','o','s','o','f','t','\', + 'W','i','n','d','o','w','s','\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\', + 'E','x','p','l','o','r','e','r','\','S','e','s','s','i','o','n','I','n','f','o','\','%','d',0}; HKEY hkey, hkey2; HRESULT hr; + DWORD session; + WCHAR sessionW[MAX_PATH]; + LONG ret;
if (!pSHCreateSessionKey) { @@ -876,18 +883,32 @@ static void test_SHCreateSessionKey(void)
hkey = (HKEY)0xdeadbeef; hr = pSHCreateSessionKey(0, &hkey); - todo_wine ok(hr == E_ACCESSDENIED, "got 0x%08x\n", hr); + ok(hr == E_ACCESSDENIED, "got 0x%08x\n", hr); ok(hkey == NULL, "got %p\n", hkey);
hr = pSHCreateSessionKey(KEY_READ, &hkey); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "got 0x%08x\n", hr);
hr = pSHCreateSessionKey(KEY_READ, &hkey2); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); - todo_wine ok(hkey != hkey2, "got %p, %p\n", hkey, hkey2); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hkey != hkey2, "got %p, %p\n", hkey, hkey2);
RegCloseKey(hkey); RegCloseKey(hkey2); + + /* Check the registery */ + if(ProcessIdToSessionId( GetCurrentProcessId(), &session)) + { + wsprintfW(sessionW, session_format, session); + + trace("key: %016x\n", session); + + ret = RegOpenKeyW(HKEY_CURRENT_USER, sessionW, &hkey); + ok(!ret, "key not found\n"); + RegCloseKey(hkey); + } + else + win_skip("Skipping registry check (%d).\n", GetLastError()); }
static void test_dragdrophelper(void)
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=37811
Your paranoid android.
=== wxppro (32 bit shellole) === shellole.c:907: Test failed: key not found
=== w2003std (32 bit shellole) === shellole.c:907: Test failed: key not found
Alistair Leslie-Hughes leslie_alistair@hotmail.com wrote:
- static const WCHAR session_format[] = {
'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'E','x','p','l','o','r','e','r','\\','S','e','s','s','i','o','n','I','n','f','o','\\','%','d',0};
- DWORD session;
'session' is unsigned, 'session_format' should use appropriate format specifier.
- WCHAR sessionW[MAX_PATH];
Why MAX_PATH?
- static WCHAR session_reg_str[sizeof(session_format) + 16];
- if(hkey)
*hkey = NULL;
- if(!access)
return E_ACCESSDENIED;
- if(!ProcessIdToSessionId( GetCurrentProcessId(), &session))
return E_INVALIDARG;
Please add a space after 'if' as in the original patch, and remove a stray space after '('. Same comment applies for the tests.
- sprintfW(session_reg_str, session_format, session);
- TRACE("using session key %s\n", debugstr_w(session_reg_str));
- return RegCreateKeyExW(HKEY_CURRENT_USER, session_reg_str, 0, NULL,
REG_OPTION_VOLATILE, access, NULL, hkey, NULL);
REG_OPTION_VOLATILE indentation should be aligned as in the original patch.