ReactOS  0.4.13-dev-100-gc8611ae
shellreg.c
Go to the documentation of this file.
1 /*
2  * Shell Registry Access
3  *
4  * Copyright 2000 Juergen Schmied
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #include <wine/config.h>
22 
23 #include <stdio.h>
24 
25 #define WIN32_NO_STATUS
26 #define _INC_WINDOWS
27 
28 #include <windef.h>
29 #include <winbase.h>
30 #include <shlobj.h>
31 
32 #include <wine/debug.h>
33 
35 
36 /*************************************************************************
37  * SHRegOpenKeyA [SHELL32.506]
38  *
39  */
41  HKEY hKey,
42  LPSTR lpSubKey,
43  PHKEY phkResult)
44 {
45  TRACE("(%p, %s, %p)\n", hKey, debugstr_a(lpSubKey), phkResult);
46  return RegOpenKeyA(hKey, lpSubKey, phkResult);
47 }
48 
49 /*************************************************************************
50  * SHRegOpenKeyW [SHELL32.507] NT 4.0
51  *
52  */
54  HKEY hkey,
55  LPCWSTR lpszSubKey,
56  PHKEY retkey)
57 {
58  WARN("%p %s %p\n",hkey,debugstr_w(lpszSubKey),retkey);
59  return RegOpenKeyW( hkey, lpszSubKey, retkey );
60 }
61 
62 /*************************************************************************
63  * SHRegQueryValueA [SHELL32.508]
64  *
65  */
66 HRESULT WINAPI SHRegQueryValueA(HKEY hkey, LPSTR lpSubKey, LPSTR lpValue, LPDWORD lpcbValue)
67 {
68  TRACE("(%p %s %p %p)\n", hkey, debugstr_a(lpSubKey), lpValue, lpcbValue);
69  return RegQueryValueA(hkey, lpSubKey, lpValue, (LONG*)lpcbValue);
70 }
71 
72 /*************************************************************************
73  * SHRegQueryValueExA [SHELL32.509]
74  *
75  */
77  HKEY hkey,
78  LPSTR lpValueName,
79  LPDWORD lpReserved,
80  LPDWORD lpType,
81  LPBYTE lpData,
82  LPDWORD lpcbData)
83 {
84  TRACE("%p %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
85  return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
86 }
87 
88 /*************************************************************************
89  * SHRegQueryValueW [SHELL32.510] NT4.0
90  *
91  */
93  HKEY hkey,
94  LPWSTR lpszSubKey,
95  LPWSTR lpszData,
96  LPDWORD lpcbData )
97 {
98  WARN("%p %s %p %p semi-stub\n",
99  hkey, debugstr_w(lpszSubKey), lpszData, lpcbData);
100  return RegQueryValueW( hkey, lpszSubKey, lpszData, (LONG*)lpcbData );
101 }
102 
103 /*************************************************************************
104  * SHRegQueryValueExW [SHELL32.511] NT4.0
105  *
106  * FIXME
107  * if the datatype REG_EXPAND_SZ then expand the string and change
108  * *pdwType to REG_SZ.
109  */
111  HKEY hkey,
112  LPWSTR pszValue,
114  LPDWORD pdwType,
115  LPVOID pvData,
117 {
118  DWORD ret;
119  WARN("%p %s %p %p %p %p semi-stub\n",
120  hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData);
121  ret = RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
122  return ret;
123 }
124 
125 /*************************************************************************
126  * SHRegDeleteKeyW [SHELL32.512]
127  */
129  HKEY hkey,
130  LPCWSTR pszSubKey)
131 {
132  FIXME("hkey=%p, %s\n", hkey, debugstr_w(pszSubKey));
133  return 0;
134 }
135 
136 /*************************************************************************
137  * SHRegCloseKey [SHELL32.505] NT 4.0
138  *
139  */
141 {
142  TRACE("%p\n",hkey);
143  return RegCloseKey( hkey );
144 }
145 
146 /*************************************************************************
147  * SHCreateSessionKey [SHELL32.723]
148  */
149 HRESULT
150 WINAPI
151 SHCreateSessionKey(REGSAM samDesired, PHKEY phKey)
152 {
153  HRESULT hr = S_OK;
154  static WCHAR wszSessionKey[256];
155  LONG Error;
156 
157  if (!wszSessionKey[0]) // FIXME: Critical Section
158  {
159  HANDLE hToken;
160 
162  {
163  TOKEN_STATISTICS Stats;
165 
166  if (GetTokenInformation(hToken, TokenStatistics, &Stats, sizeof(Stats), &ReturnLength))
167  {
168  swprintf(wszSessionKey,
169  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\SessionInfo\\%08x%08x",
171  }
172  else
174 
175  CloseHandle(hToken);
176  }
177  else
179  }
180 
181  if(SUCCEEDED(hr))
182  {
183  Error = RegCreateKeyExW(HKEY_LOCAL_MACHINE, wszSessionKey, 0, NULL,
184  REG_OPTION_VOLATILE, samDesired, NULL, phKey, NULL);
185  if (Error != ERROR_SUCCESS)
187  }
188 
189  return hr;
190 }
LUID AuthenticationId
Definition: setypes.h:1033
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3272
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4041
#define CloseHandle
Definition: compat.h:398
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
LSTATUS WINAPI RegQueryValueA(HKEY hkey, LPCSTR name, LPSTR data, LPLONG count)
Definition: reg.c:4243
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HRESULT WINAPI SHRegQueryValueExW(HKEY hkey, LPWSTR pszValue, LPDWORD pdwReserved, LPDWORD pdwType, LPVOID pvData, LPDWORD pcbData)
Definition: shellreg.c:110
HRESULT WINAPI SHRegOpenKeyA(HKEY hKey, LPSTR lpSubKey, PHKEY phkResult)
Definition: shellreg.c:40
HRESULT WINAPI SHRegDeleteKeyW(HKEY hkey, LPCWSTR pszSubKey)
Definition: shellreg.c:128
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
WINE_DEFAULT_DEBUG_CHANNEL(shell)
char * LPSTR
Definition: xmlstorage.h:182
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1094
HRESULT WINAPI SHRegQueryValueExA(HKEY hkey, LPSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData)
Definition: shellreg.c:76
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHRegQueryValueW(HKEY hkey, LPWSTR lpszSubKey, LPWSTR lpszData, LPDWORD lpcbData)
Definition: shellreg.c:92
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHCreateSessionKey(REGSAM samDesired, PHKEY phKey)
Definition: shellreg.c:151
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
DWORD LowPart
LONG HRESULT
Definition: typedefs.h:77
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
HRESULT WINAPI SHRegQueryValueA(HKEY hkey, LPSTR lpSubKey, LPSTR lpValue, LPDWORD lpcbValue)
Definition: shellreg.c:66
LSTATUS WINAPI RegQueryValueW(HKEY hkey, LPCWSTR name, LPWSTR data, LPLONG count)
Definition: reg.c:4272
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Error
Definition: chkdsk.c:66
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define TOKEN_READ
Definition: setypes.h:897
LONG HighPart
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
#define S_OK
Definition: intsafe.h:59
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
ACCESS_MASK REGSAM
Definition: winreg.h:69
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
HRESULT WINAPI SHRegOpenKeyW(HKEY hkey, LPCWSTR lpszSubKey, PHKEY retkey)
Definition: shellreg.c:53
HRESULT WINAPI SHRegCloseKey(HKEY hkey)
Definition: shellreg.c:140
uint32_t * LPDWORD
Definition: typedefs.h:57
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define SUCCEEDED(hr)
Definition: intsafe.h:57
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12