Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Registry management |
| 3 | * |
| 4 | * Copyright (C) 1999 Alexandre Julliard |
| 5 | * |
| 6 | * Based on misc/registry.c code |
| 7 | * Copyright (C) 1996 Marcus Meissner |
| 8 | * Copyright (C) 1998 Matthew Becker |
| 9 | * Copyright (C) 1999 Sylvain St-Germain |
| 10 | * |
| 11 | * This file is concerned about handle management and interaction with the Wine server. |
| 12 | * Registry file I/O is in misc/registry.c. |
| 13 | */ |
| 14 | |
| 15 | #include <stdlib.h> |
Alexandre Julliard | 383da68 | 2000-02-10 22:15:21 +0000 | [diff] [blame] | 16 | #include <stdio.h> |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 17 | #include <unistd.h> |
| 18 | |
| 19 | #include "winbase.h" |
| 20 | #include "winreg.h" |
| 21 | #include "winerror.h" |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 22 | #include "wine/unicode.h" |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 23 | #include "heap.h" |
| 24 | #include "server.h" |
| 25 | #include "debugtools.h" |
| 26 | |
Alexandre Julliard | 383da68 | 2000-02-10 22:15:21 +0000 | [diff] [blame] | 27 | DEFAULT_DEBUG_CHANNEL(reg); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 28 | |
| 29 | |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 30 | /* check if value type needs string conversion (Ansi<->Unicode) */ |
| 31 | static inline int is_string( DWORD type ) |
| 32 | { |
| 33 | return (type == REG_SZ) || (type == REG_EXPAND_SZ) || (type == REG_MULTI_SZ); |
| 34 | } |
| 35 | |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 36 | |
| 37 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 38 | * RegCreateKeyExW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 39 | * |
| 40 | * PARAMS |
| 41 | * hkey [I] Handle of an open key |
| 42 | * name [I] Address of subkey name |
| 43 | * reserved [I] Reserved - must be 0 |
| 44 | * class [I] Address of class string |
| 45 | * options [I] Special options flag |
| 46 | * access [I] Desired security access |
| 47 | * sa [I] Address of key security structure |
| 48 | * retkey [O] Address of buffer for opened handle |
| 49 | * dispos [O] Receives REG_CREATED_NEW_KEY or REG_OPENED_EXISTING_KEY |
Juergen Schmied | f94761b | 2000-01-09 21:10:18 +0000 | [diff] [blame] | 50 | * |
| 51 | * NOTES |
Juergen Schmied | 927525a | 2000-01-15 23:38:49 +0000 | [diff] [blame] | 52 | * in case of failing retkey remains untouched |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 53 | */ |
| 54 | DWORD WINAPI RegCreateKeyExW( HKEY hkey, LPCWSTR name, DWORD reserved, LPWSTR class, |
| 55 | DWORD options, REGSAM access, SECURITY_ATTRIBUTES *sa, |
| 56 | LPHKEY retkey, LPDWORD dispos ) |
| 57 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 58 | OBJECT_ATTRIBUTES attr; |
| 59 | UNICODE_STRING nameW, classW; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 60 | |
| 61 | if (reserved) return ERROR_INVALID_PARAMETER; |
| 62 | if (!(access & KEY_ALL_ACCESS) || (access & ~KEY_ALL_ACCESS)) return ERROR_ACCESS_DENIED; |
| 63 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 64 | attr.Length = sizeof(attr); |
| 65 | attr.RootDirectory = hkey; |
| 66 | attr.ObjectName = &nameW; |
| 67 | attr.Attributes = 0; |
| 68 | attr.SecurityDescriptor = NULL; |
| 69 | attr.SecurityQualityOfService = NULL; |
| 70 | RtlInitUnicodeString( &nameW, name ); |
| 71 | RtlInitUnicodeString( &classW, class ); |
| 72 | |
| 73 | return RtlNtStatusToDosError( NtCreateKey( retkey, access, &attr, 0, |
| 74 | &classW, options, dispos ) ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | |
| 78 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 79 | * RegCreateKeyExA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 80 | */ |
| 81 | DWORD WINAPI RegCreateKeyExA( HKEY hkey, LPCSTR name, DWORD reserved, LPSTR class, |
| 82 | DWORD options, REGSAM access, SECURITY_ATTRIBUTES *sa, |
| 83 | LPHKEY retkey, LPDWORD dispos ) |
| 84 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 85 | OBJECT_ATTRIBUTES attr; |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 86 | UNICODE_STRING classW; |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 87 | ANSI_STRING nameA, classA; |
| 88 | NTSTATUS status; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 89 | |
| 90 | if (reserved) return ERROR_INVALID_PARAMETER; |
| 91 | if (!(access & KEY_ALL_ACCESS) || (access & ~KEY_ALL_ACCESS)) return ERROR_ACCESS_DENIED; |
| 92 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 93 | attr.Length = sizeof(attr); |
| 94 | attr.RootDirectory = hkey; |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 95 | attr.ObjectName = &NtCurrentTeb()->StaticUnicodeString; |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 96 | attr.Attributes = 0; |
| 97 | attr.SecurityDescriptor = NULL; |
| 98 | attr.SecurityQualityOfService = NULL; |
| 99 | RtlInitAnsiString( &nameA, name ); |
| 100 | RtlInitAnsiString( &classA, class ); |
| 101 | |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 102 | if (!(status = RtlAnsiStringToUnicodeString( &NtCurrentTeb()->StaticUnicodeString, |
| 103 | &nameA, FALSE ))) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 104 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 105 | if (!(status = RtlAnsiStringToUnicodeString( &classW, &classA, TRUE ))) |
| 106 | { |
| 107 | status = NtCreateKey( retkey, access, &attr, 0, &classW, options, dispos ); |
| 108 | RtlFreeUnicodeString( &classW ); |
| 109 | } |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 110 | } |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 111 | return RtlNtStatusToDosError( status ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | |
| 115 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 116 | * RegCreateKeyW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 117 | */ |
| 118 | DWORD WINAPI RegCreateKeyW( HKEY hkey, LPCWSTR name, LPHKEY retkey ) |
| 119 | { |
| 120 | /* FIXME: previous implementation converted ERROR_INVALID_HANDLE to ERROR_BADKEY, */ |
| 121 | /* but at least my version of NT (4.0 SP5) doesn't do this. -- AJ */ |
| 122 | return RegCreateKeyExW( hkey, name, 0, NULL, REG_OPTION_NON_VOLATILE, |
| 123 | KEY_ALL_ACCESS, NULL, retkey, NULL ); |
| 124 | } |
| 125 | |
| 126 | |
| 127 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 128 | * RegCreateKeyA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 129 | */ |
| 130 | DWORD WINAPI RegCreateKeyA( HKEY hkey, LPCSTR name, LPHKEY retkey ) |
| 131 | { |
| 132 | return RegCreateKeyExA( hkey, name, 0, NULL, REG_OPTION_NON_VOLATILE, |
| 133 | KEY_ALL_ACCESS, NULL, retkey, NULL ); |
| 134 | } |
| 135 | |
| 136 | |
| 137 | |
| 138 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 139 | * RegOpenKeyExW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 140 | * |
| 141 | * Opens the specified key |
| 142 | * |
| 143 | * Unlike RegCreateKeyEx, this does not create the key if it does not exist. |
| 144 | * |
| 145 | * PARAMS |
| 146 | * hkey [I] Handle of open key |
| 147 | * name [I] Name of subkey to open |
| 148 | * reserved [I] Reserved - must be zero |
| 149 | * access [I] Security access mask |
| 150 | * retkey [O] Handle to open key |
| 151 | * |
| 152 | * RETURNS |
| 153 | * Success: ERROR_SUCCESS |
| 154 | * Failure: Error code |
Juergen Schmied | f94761b | 2000-01-09 21:10:18 +0000 | [diff] [blame] | 155 | * |
| 156 | * NOTES |
| 157 | * in case of failing is retkey = 0 |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 158 | */ |
| 159 | DWORD WINAPI RegOpenKeyExW( HKEY hkey, LPCWSTR name, DWORD reserved, REGSAM access, LPHKEY retkey ) |
| 160 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 161 | OBJECT_ATTRIBUTES attr; |
| 162 | UNICODE_STRING nameW; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 163 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 164 | attr.Length = sizeof(attr); |
| 165 | attr.RootDirectory = hkey; |
| 166 | attr.ObjectName = &nameW; |
| 167 | attr.Attributes = 0; |
| 168 | attr.SecurityDescriptor = NULL; |
| 169 | attr.SecurityQualityOfService = NULL; |
| 170 | RtlInitUnicodeString( &nameW, name ); |
| 171 | return RtlNtStatusToDosError( NtOpenKey( retkey, access, &attr ) ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | |
| 175 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 176 | * RegOpenKeyExA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 177 | */ |
| 178 | DWORD WINAPI RegOpenKeyExA( HKEY hkey, LPCSTR name, DWORD reserved, REGSAM access, LPHKEY retkey ) |
| 179 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 180 | OBJECT_ATTRIBUTES attr; |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 181 | STRING nameA; |
| 182 | NTSTATUS status; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 183 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 184 | attr.Length = sizeof(attr); |
| 185 | attr.RootDirectory = hkey; |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 186 | attr.ObjectName = &NtCurrentTeb()->StaticUnicodeString; |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 187 | attr.Attributes = 0; |
| 188 | attr.SecurityDescriptor = NULL; |
| 189 | attr.SecurityQualityOfService = NULL; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 190 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 191 | RtlInitAnsiString( &nameA, name ); |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 192 | if (!(status = RtlAnsiStringToUnicodeString( &NtCurrentTeb()->StaticUnicodeString, |
| 193 | &nameA, FALSE ))) |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 194 | { |
| 195 | status = NtOpenKey( retkey, access, &attr ); |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 196 | } |
| 197 | return RtlNtStatusToDosError( status ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | |
| 201 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 202 | * RegOpenKeyW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 203 | * |
| 204 | * PARAMS |
| 205 | * hkey [I] Handle of open key |
| 206 | * name [I] Address of name of subkey to open |
| 207 | * retkey [O] Handle to open key |
| 208 | * |
| 209 | * RETURNS |
| 210 | * Success: ERROR_SUCCESS |
| 211 | * Failure: Error code |
Juergen Schmied | f94761b | 2000-01-09 21:10:18 +0000 | [diff] [blame] | 212 | * |
| 213 | * NOTES |
| 214 | * in case of failing is retkey = 0 |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 215 | */ |
| 216 | DWORD WINAPI RegOpenKeyW( HKEY hkey, LPCWSTR name, LPHKEY retkey ) |
| 217 | { |
| 218 | return RegOpenKeyExW( hkey, name, 0, KEY_ALL_ACCESS, retkey ); |
| 219 | } |
| 220 | |
| 221 | |
| 222 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 223 | * RegOpenKeyA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 224 | */ |
| 225 | DWORD WINAPI RegOpenKeyA( HKEY hkey, LPCSTR name, LPHKEY retkey ) |
| 226 | { |
| 227 | return RegOpenKeyExA( hkey, name, 0, KEY_ALL_ACCESS, retkey ); |
| 228 | } |
| 229 | |
| 230 | |
David Elliott | 44f84b5 | 2000-10-29 01:24:54 +0000 | [diff] [blame] | 231 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 232 | * RegOpenCurrentUser [ADVAPI32.@] |
David Elliott | 44f84b5 | 2000-10-29 01:24:54 +0000 | [diff] [blame] | 233 | * FIXME: This function is supposed to retrieve a handle to the |
| 234 | * HKEY_CURRENT_USER for the user the current thread is impersonating. |
| 235 | * Since Wine does not currently allow threads to impersonate other users, |
| 236 | * this stub should work fine. |
| 237 | */ |
| 238 | DWORD WINAPI RegOpenCurrentUser( REGSAM access, PHKEY retkey ) |
| 239 | { |
| 240 | return RegOpenKeyExA( HKEY_CURRENT_USER, "", 0, access, retkey ); |
| 241 | } |
| 242 | |
| 243 | |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 244 | |
| 245 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 246 | * RegEnumKeyExW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 247 | * |
| 248 | * PARAMS |
| 249 | * hkey [I] Handle to key to enumerate |
| 250 | * index [I] Index of subkey to enumerate |
| 251 | * name [O] Buffer for subkey name |
| 252 | * name_len [O] Size of subkey buffer |
| 253 | * reserved [I] Reserved |
| 254 | * class [O] Buffer for class string |
| 255 | * class_len [O] Size of class buffer |
| 256 | * ft [O] Time key last written to |
| 257 | */ |
| 258 | DWORD WINAPI RegEnumKeyExW( HKEY hkey, DWORD index, LPWSTR name, LPDWORD name_len, |
| 259 | LPDWORD reserved, LPWSTR class, LPDWORD class_len, FILETIME *ft ) |
| 260 | { |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 261 | NTSTATUS status; |
| 262 | char buffer[256], *buf_ptr = buffer; |
| 263 | KEY_NODE_INFORMATION *info = (KEY_NODE_INFORMATION *)buffer; |
| 264 | DWORD total_size; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 265 | |
| 266 | TRACE( "(0x%x,%ld,%p,%p(%ld),%p,%p,%p,%p)\n", hkey, index, name, name_len, |
| 267 | name_len ? *name_len : -1, reserved, class, class_len, ft ); |
| 268 | |
| 269 | if (reserved) return ERROR_INVALID_PARAMETER; |
| 270 | |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 271 | status = NtEnumerateKey( hkey, index, KeyNodeInformation, |
| 272 | buffer, sizeof(buffer), &total_size ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 273 | |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 274 | while (status == STATUS_BUFFER_OVERFLOW) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 275 | { |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 276 | /* retry with a dynamically allocated buffer */ |
| 277 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 278 | if (!(buf_ptr = HeapAlloc( GetProcessHeap(), 0, total_size ))) |
| 279 | return ERROR_NOT_ENOUGH_MEMORY; |
| 280 | info = (KEY_NODE_INFORMATION *)buf_ptr; |
| 281 | status = NtEnumerateKey( hkey, index, KeyNodeInformation, |
| 282 | buf_ptr, total_size, &total_size ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 283 | } |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 284 | |
| 285 | if (!status) |
| 286 | { |
| 287 | DWORD len = info->NameLength / sizeof(WCHAR); |
| 288 | DWORD cls_len = info->ClassLength / sizeof(WCHAR); |
| 289 | |
| 290 | if (ft) *ft = info->LastWriteTime; |
| 291 | |
| 292 | if (len >= *name_len || (class_len && (cls_len >= *class_len))) |
| 293 | status = STATUS_BUFFER_OVERFLOW; |
| 294 | else |
| 295 | { |
| 296 | *name_len = len; |
| 297 | memcpy( name, info->Name, info->NameLength ); |
| 298 | name[len] = 0; |
| 299 | if (class_len) |
| 300 | { |
| 301 | *class_len = cls_len; |
| 302 | if (class) |
| 303 | { |
| 304 | memcpy( class, buf_ptr + info->ClassOffset, info->ClassLength ); |
| 305 | class[cls_len] = 0; |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 312 | return RtlNtStatusToDosError( status ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | |
| 316 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 317 | * RegEnumKeyExA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 318 | */ |
| 319 | DWORD WINAPI RegEnumKeyExA( HKEY hkey, DWORD index, LPSTR name, LPDWORD name_len, |
| 320 | LPDWORD reserved, LPSTR class, LPDWORD class_len, FILETIME *ft ) |
| 321 | { |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 322 | NTSTATUS status; |
| 323 | char buffer[256], *buf_ptr = buffer; |
| 324 | KEY_NODE_INFORMATION *info = (KEY_NODE_INFORMATION *)buffer; |
| 325 | DWORD total_size; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 326 | |
| 327 | TRACE( "(0x%x,%ld,%p,%p(%ld),%p,%p,%p,%p)\n", hkey, index, name, name_len, |
| 328 | name_len ? *name_len : -1, reserved, class, class_len, ft ); |
| 329 | |
| 330 | if (reserved) return ERROR_INVALID_PARAMETER; |
| 331 | |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 332 | status = NtEnumerateKey( hkey, index, KeyNodeInformation, |
| 333 | buffer, sizeof(buffer), &total_size ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 334 | |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 335 | while (status == STATUS_BUFFER_OVERFLOW) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 336 | { |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 337 | /* retry with a dynamically allocated buffer */ |
| 338 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 339 | if (!(buf_ptr = HeapAlloc( GetProcessHeap(), 0, total_size ))) |
| 340 | return ERROR_NOT_ENOUGH_MEMORY; |
| 341 | info = (KEY_NODE_INFORMATION *)buf_ptr; |
| 342 | status = NtEnumerateKey( hkey, index, KeyNodeInformation, |
| 343 | buf_ptr, total_size, &total_size ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 344 | } |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 345 | |
| 346 | if (!status) |
| 347 | { |
| 348 | DWORD len = WideCharToMultiByte( CP_ACP, 0, info->Name, info->NameLength/sizeof(WCHAR), |
| 349 | NULL, 0, NULL, NULL ); |
| 350 | DWORD cls_len = WideCharToMultiByte( CP_ACP, 0, (WCHAR *)(buf_ptr + info->ClassOffset), |
| 351 | info->ClassLength / sizeof(WCHAR), |
| 352 | NULL, 0, NULL, NULL ); |
| 353 | |
| 354 | if (ft) *ft = info->LastWriteTime; |
| 355 | |
| 356 | if (len >= *name_len || (class_len && (cls_len >= *class_len))) |
| 357 | status = STATUS_BUFFER_OVERFLOW; |
| 358 | else |
| 359 | { |
| 360 | *name_len = len; |
| 361 | WideCharToMultiByte( CP_ACP, 0, info->Name, info->NameLength/sizeof(WCHAR), |
| 362 | name, len, NULL, NULL ); |
| 363 | name[len] = 0; |
| 364 | if (class_len) |
| 365 | { |
| 366 | *class_len = cls_len; |
| 367 | if (class) |
| 368 | { |
| 369 | WideCharToMultiByte( CP_ACP, 0, (WCHAR *)(buf_ptr + info->ClassOffset), |
| 370 | info->ClassLength / sizeof(WCHAR), |
| 371 | class, cls_len, NULL, NULL ); |
| 372 | class[cls_len] = 0; |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 379 | return RtlNtStatusToDosError( status ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | |
| 383 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 384 | * RegEnumKeyW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 385 | */ |
| 386 | DWORD WINAPI RegEnumKeyW( HKEY hkey, DWORD index, LPWSTR name, DWORD name_len ) |
| 387 | { |
| 388 | return RegEnumKeyExW( hkey, index, name, &name_len, NULL, NULL, NULL, NULL ); |
| 389 | } |
| 390 | |
| 391 | |
| 392 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 393 | * RegEnumKeyA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 394 | */ |
| 395 | DWORD WINAPI RegEnumKeyA( HKEY hkey, DWORD index, LPSTR name, DWORD name_len ) |
| 396 | { |
| 397 | return RegEnumKeyExA( hkey, index, name, &name_len, NULL, NULL, NULL, NULL ); |
| 398 | } |
| 399 | |
| 400 | |
| 401 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 402 | * RegQueryInfoKeyW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 403 | * |
| 404 | * PARAMS |
| 405 | * hkey [I] Handle to key to query |
| 406 | * class [O] Buffer for class string |
| 407 | * class_len [O] Size of class string buffer |
| 408 | * reserved [I] Reserved |
| 409 | * subkeys [O] Buffer for number of subkeys |
| 410 | * max_subkey [O] Buffer for longest subkey name length |
| 411 | * max_class [O] Buffer for longest class string length |
| 412 | * values [O] Buffer for number of value entries |
| 413 | * max_value [O] Buffer for longest value name length |
| 414 | * max_data [O] Buffer for longest value data length |
| 415 | * security [O] Buffer for security descriptor length |
| 416 | * modif [O] Modification time |
| 417 | * |
| 418 | * - win95 allows class to be valid and class_len to be NULL |
| 419 | * - winnt returns ERROR_INVALID_PARAMETER if class is valid and class_len is NULL |
| 420 | * - both allow class to be NULL and class_len to be NULL |
| 421 | * (it's hard to test validity, so test !NULL instead) |
| 422 | */ |
| 423 | DWORD WINAPI RegQueryInfoKeyW( HKEY hkey, LPWSTR class, LPDWORD class_len, LPDWORD reserved, |
| 424 | LPDWORD subkeys, LPDWORD max_subkey, LPDWORD max_class, |
| 425 | LPDWORD values, LPDWORD max_value, LPDWORD max_data, |
| 426 | LPDWORD security, FILETIME *modif ) |
| 427 | { |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 428 | NTSTATUS status; |
| 429 | char buffer[256], *buf_ptr = buffer; |
| 430 | KEY_FULL_INFORMATION *info = (KEY_FULL_INFORMATION *)buffer; |
| 431 | DWORD total_size; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 432 | |
| 433 | TRACE( "(0x%x,%p,%ld,%p,%p,%p,%p,%p,%p,%p,%p)\n", hkey, class, class_len ? *class_len : 0, |
| 434 | reserved, subkeys, max_subkey, values, max_value, max_data, security, modif ); |
| 435 | |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 436 | if (class && !class_len && !(GetVersion() & 0x80000000 /*NT*/)) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 437 | return ERROR_INVALID_PARAMETER; |
| 438 | |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 439 | status = NtQueryKey( hkey, KeyFullInformation, buffer, sizeof(buffer), &total_size ); |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 440 | if (status && status != STATUS_BUFFER_OVERFLOW) goto done; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 441 | |
| 442 | if (class) |
| 443 | { |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 444 | /* retry with a dynamically allocated buffer */ |
| 445 | while (status == STATUS_BUFFER_OVERFLOW) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 446 | { |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 447 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 448 | if (!(buf_ptr = HeapAlloc( GetProcessHeap(), 0, total_size ))) |
| 449 | return ERROR_NOT_ENOUGH_MEMORY; |
| 450 | info = (KEY_FULL_INFORMATION *)buf_ptr; |
| 451 | status = NtQueryKey( hkey, KeyFullInformation, buf_ptr, total_size, &total_size ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 452 | } |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 453 | |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 454 | if (status) goto done; |
| 455 | |
| 456 | if (class_len && (info->ClassLength/sizeof(WCHAR) + 1 > *class_len)) |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 457 | { |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 458 | status = STATUS_BUFFER_OVERFLOW; |
| 459 | } |
| 460 | else |
| 461 | { |
| 462 | memcpy( class, buf_ptr + info->ClassOffset, info->ClassLength ); |
| 463 | class[info->ClassLength/sizeof(WCHAR)] = 0; |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 464 | } |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 465 | } |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 466 | else status = STATUS_SUCCESS; |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 467 | |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 468 | if (class_len) *class_len = info->ClassLength / sizeof(WCHAR); |
| 469 | if (subkeys) *subkeys = info->SubKeys; |
| 470 | if (max_subkey) *max_subkey = info->MaxNameLen; |
| 471 | if (max_class) *max_class = info->MaxClassLen; |
| 472 | if (values) *values = info->Values; |
| 473 | if (max_value) *max_value = info->MaxValueNameLen; |
| 474 | if (max_data) *max_data = info->MaxValueDataLen; |
| 475 | if (modif) *modif = info->LastWriteTime; |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 476 | |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 477 | done: |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 478 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 479 | return RtlNtStatusToDosError( status ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | |
| 483 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 484 | * RegQueryInfoKeyA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 485 | */ |
| 486 | DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWORD reserved, |
| 487 | LPDWORD subkeys, LPDWORD max_subkey, LPDWORD max_class, |
| 488 | LPDWORD values, LPDWORD max_value, LPDWORD max_data, |
| 489 | LPDWORD security, FILETIME *modif ) |
| 490 | { |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 491 | NTSTATUS status; |
| 492 | char buffer[256], *buf_ptr = buffer; |
| 493 | KEY_FULL_INFORMATION *info = (KEY_FULL_INFORMATION *)buffer; |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 494 | DWORD total_size, len; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 495 | |
| 496 | TRACE( "(0x%x,%p,%ld,%p,%p,%p,%p,%p,%p,%p,%p)\n", hkey, class, class_len ? *class_len : 0, |
| 497 | reserved, subkeys, max_subkey, values, max_value, max_data, security, modif ); |
| 498 | |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 499 | if (class && !class_len && !(GetVersion() & 0x80000000 /*NT*/)) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 500 | return ERROR_INVALID_PARAMETER; |
| 501 | |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 502 | status = NtQueryKey( hkey, KeyFullInformation, buffer, sizeof(buffer), &total_size ); |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 503 | if (status && status != STATUS_BUFFER_OVERFLOW) goto done; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 504 | |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 505 | if (class || class_len) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 506 | { |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 507 | /* retry with a dynamically allocated buffer */ |
| 508 | while (status == STATUS_BUFFER_OVERFLOW) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 509 | { |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 510 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 511 | if (!(buf_ptr = HeapAlloc( GetProcessHeap(), 0, total_size ))) |
| 512 | return ERROR_NOT_ENOUGH_MEMORY; |
| 513 | info = (KEY_FULL_INFORMATION *)buf_ptr; |
| 514 | status = NtQueryKey( hkey, KeyFullInformation, buf_ptr, total_size, &total_size ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 515 | } |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 516 | |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 517 | if (status) goto done; |
| 518 | |
| 519 | len = WideCharToMultiByte( CP_ACP, 0, |
| 520 | (WCHAR *)(buf_ptr + info->ClassOffset), |
| 521 | info->ClassLength/sizeof(WCHAR), |
| 522 | NULL, 0, NULL, NULL ); |
| 523 | if (class_len) |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 524 | { |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 525 | if (len + 1 > *class_len) status = STATUS_BUFFER_OVERFLOW; |
| 526 | *class_len = len; |
| 527 | } |
| 528 | if (class && !status) |
| 529 | { |
| 530 | WideCharToMultiByte( CP_ACP, 0, |
| 531 | (WCHAR *)(buf_ptr + info->ClassOffset), |
| 532 | info->ClassLength/sizeof(WCHAR), |
| 533 | class, len, NULL, NULL ); |
| 534 | class[len] = 0; |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 535 | } |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 536 | } |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 537 | else status = STATUS_SUCCESS; |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 538 | |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 539 | if (subkeys) *subkeys = info->SubKeys; |
| 540 | if (max_subkey) *max_subkey = info->MaxNameLen; |
| 541 | if (max_class) *max_class = info->MaxClassLen; |
| 542 | if (values) *values = info->Values; |
| 543 | if (max_value) *max_value = info->MaxValueNameLen; |
| 544 | if (max_data) *max_data = info->MaxValueDataLen; |
| 545 | if (modif) *modif = info->LastWriteTime; |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 546 | |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 547 | done: |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 548 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 549 | return RtlNtStatusToDosError( status ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | |
| 553 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 554 | * RegCloseKey [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 555 | * |
| 556 | * Releases the handle of the specified key |
| 557 | * |
| 558 | * PARAMS |
| 559 | * hkey [I] Handle of key to close |
| 560 | * |
| 561 | * RETURNS |
| 562 | * Success: ERROR_SUCCESS |
| 563 | * Failure: Error code |
| 564 | */ |
| 565 | DWORD WINAPI RegCloseKey( HKEY hkey ) |
| 566 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 567 | if (!hkey || hkey >= 0x80000000) return ERROR_SUCCESS; |
| 568 | return RtlNtStatusToDosError( NtClose( hkey ) ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | |
| 572 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 573 | * RegDeleteKeyW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 574 | * |
| 575 | * PARAMS |
| 576 | * hkey [I] Handle to open key |
| 577 | * name [I] Name of subkey to delete |
| 578 | * |
| 579 | * RETURNS |
| 580 | * Success: ERROR_SUCCESS |
| 581 | * Failure: Error code |
| 582 | */ |
| 583 | DWORD WINAPI RegDeleteKeyW( HKEY hkey, LPCWSTR name ) |
| 584 | { |
| 585 | DWORD ret; |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 586 | HKEY tmp; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 587 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 588 | if (!name || !*name) return NtDeleteKey( hkey ); |
| 589 | if (!(ret = RegOpenKeyExW( hkey, name, 0, 0, &tmp ))) |
| 590 | { |
| 591 | ret = RtlNtStatusToDosError( NtDeleteKey( tmp ) ); |
| 592 | RegCloseKey( tmp ); |
| 593 | } |
| 594 | return ret; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | |
| 598 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 599 | * RegDeleteKeyA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 600 | */ |
| 601 | DWORD WINAPI RegDeleteKeyA( HKEY hkey, LPCSTR name ) |
| 602 | { |
| 603 | DWORD ret; |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 604 | HKEY tmp; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 605 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 606 | if (!name || !*name) return NtDeleteKey( hkey ); |
| 607 | if (!(ret = RegOpenKeyExA( hkey, name, 0, 0, &tmp ))) |
| 608 | { |
| 609 | ret = RtlNtStatusToDosError( NtDeleteKey( tmp ) ); |
| 610 | RegCloseKey( tmp ); |
| 611 | } |
| 612 | return ret; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | |
| 616 | |
| 617 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 618 | * RegSetValueExW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 619 | * |
| 620 | * Sets the data and type of a value under a register key |
| 621 | * |
| 622 | * PARAMS |
| 623 | * hkey [I] Handle of key to set value for |
| 624 | * name [I] Name of value to set |
| 625 | * reserved [I] Reserved - must be zero |
| 626 | * type [I] Flag for value type |
| 627 | * data [I] Address of value data |
| 628 | * count [I] Size of value data |
| 629 | * |
| 630 | * RETURNS |
| 631 | * Success: ERROR_SUCCESS |
| 632 | * Failure: Error code |
| 633 | * |
| 634 | * NOTES |
| 635 | * win95 does not care about count for REG_SZ and finds out the len by itself (js) |
| 636 | * NT does definitely care (aj) |
| 637 | */ |
| 638 | DWORD WINAPI RegSetValueExW( HKEY hkey, LPCWSTR name, DWORD reserved, |
| 639 | DWORD type, CONST BYTE *data, DWORD count ) |
| 640 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 641 | UNICODE_STRING nameW; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 642 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 643 | if (count && is_string(type)) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 644 | { |
| 645 | LPCWSTR str = (LPCWSTR)data; |
| 646 | /* if user forgot to count terminating null, add it (yes NT does this) */ |
| 647 | if (str[count / sizeof(WCHAR) - 1] && !str[count / sizeof(WCHAR)]) |
| 648 | count += sizeof(WCHAR); |
| 649 | } |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 650 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 651 | RtlInitUnicodeString( &nameW, name ); |
| 652 | return RtlNtStatusToDosError( NtSetValueKey( hkey, &nameW, 0, type, data, count ) ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | |
| 656 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 657 | * RegSetValueExA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 658 | */ |
| 659 | DWORD WINAPI RegSetValueExA( HKEY hkey, LPCSTR name, DWORD reserved, DWORD type, |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 660 | CONST BYTE *data, DWORD count ) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 661 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 662 | ANSI_STRING nameA; |
| 663 | WCHAR *dataW = NULL; |
| 664 | NTSTATUS status; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 665 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 666 | if (count && is_string(type)) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 667 | { |
| 668 | /* if user forgot to count terminating null, add it (yes NT does this) */ |
| 669 | if (data[count-1] && !data[count]) count++; |
| 670 | } |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 671 | |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 672 | if (is_string( type )) /* need to convert to Unicode */ |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 673 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 674 | DWORD lenW = MultiByteToWideChar( CP_ACP, 0, data, count, NULL, 0 ); |
| 675 | if (!(dataW = HeapAlloc( GetProcessHeap(), 0, lenW*sizeof(WCHAR) ))) |
| 676 | return ERROR_OUTOFMEMORY; |
| 677 | MultiByteToWideChar( CP_ACP, 0, data, count, dataW, lenW ); |
| 678 | count = lenW * sizeof(WCHAR); |
| 679 | data = (BYTE *)dataW; |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 680 | } |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 681 | |
| 682 | RtlInitAnsiString( &nameA, name ); |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 683 | if (!(status = RtlAnsiStringToUnicodeString( &NtCurrentTeb()->StaticUnicodeString, |
| 684 | &nameA, FALSE ))) |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 685 | { |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 686 | status = NtSetValueKey( hkey, &NtCurrentTeb()->StaticUnicodeString, 0, type, data, count ); |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 687 | } |
| 688 | if (dataW) HeapFree( GetProcessHeap(), 0, dataW ); |
| 689 | return RtlNtStatusToDosError( status ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | |
| 693 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 694 | * RegSetValueW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 695 | */ |
| 696 | DWORD WINAPI RegSetValueW( HKEY hkey, LPCWSTR name, DWORD type, LPCWSTR data, DWORD count ) |
| 697 | { |
| 698 | HKEY subkey = hkey; |
| 699 | DWORD ret; |
| 700 | |
| 701 | TRACE("(0x%x,%s,%ld,%s,%ld)\n", hkey, debugstr_w(name), type, debugstr_w(data), count ); |
| 702 | |
| 703 | if (type != REG_SZ) return ERROR_INVALID_PARAMETER; |
| 704 | |
| 705 | if (name && name[0]) /* need to create the subkey */ |
| 706 | { |
| 707 | if ((ret = RegCreateKeyW( hkey, name, &subkey )) != ERROR_SUCCESS) return ret; |
| 708 | } |
| 709 | |
| 710 | ret = RegSetValueExW( subkey, NULL, 0, REG_SZ, (LPBYTE)data, |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 711 | (strlenW( data ) + 1) * sizeof(WCHAR) ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 712 | if (subkey != hkey) RegCloseKey( subkey ); |
| 713 | return ret; |
| 714 | } |
| 715 | |
| 716 | |
| 717 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 718 | * RegSetValueA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 719 | */ |
| 720 | DWORD WINAPI RegSetValueA( HKEY hkey, LPCSTR name, DWORD type, LPCSTR data, DWORD count ) |
| 721 | { |
| 722 | HKEY subkey = hkey; |
| 723 | DWORD ret; |
| 724 | |
| 725 | TRACE("(0x%x,%s,%ld,%s,%ld)\n", hkey, debugstr_a(name), type, debugstr_a(data), count ); |
| 726 | |
| 727 | if (type != REG_SZ) return ERROR_INVALID_PARAMETER; |
| 728 | |
| 729 | if (name && name[0]) /* need to create the subkey */ |
| 730 | { |
| 731 | if ((ret = RegCreateKeyA( hkey, name, &subkey )) != ERROR_SUCCESS) return ret; |
| 732 | } |
| 733 | ret = RegSetValueExA( subkey, NULL, 0, REG_SZ, (LPBYTE)data, strlen(data)+1 ); |
| 734 | if (subkey != hkey) RegCloseKey( subkey ); |
| 735 | return ret; |
| 736 | } |
| 737 | |
| 738 | |
| 739 | |
| 740 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 741 | * RegQueryValueExW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 742 | * |
| 743 | * Retrieves type and data for a specified name associated with an open key |
| 744 | * |
| 745 | * PARAMS |
| 746 | * hkey [I] Handle of key to query |
| 747 | * name [I] Name of value to query |
| 748 | * reserved [I] Reserved - must be NULL |
| 749 | * type [O] Address of buffer for value type. If NULL, the type |
| 750 | * is not required. |
| 751 | * data [O] Address of data buffer. If NULL, the actual data is |
| 752 | * not required. |
| 753 | * count [I/O] Address of data buffer size |
| 754 | * |
| 755 | * RETURNS |
| 756 | * ERROR_SUCCESS: Success |
| 757 | * ERROR_MORE_DATA: !!! if the specified buffer is not big enough to hold the data |
| 758 | * buffer is left untouched. The MS-documentation is wrong (js) !!! |
| 759 | */ |
| 760 | DWORD WINAPI RegQueryValueExW( HKEY hkey, LPCWSTR name, LPDWORD reserved, LPDWORD type, |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 761 | LPBYTE data, LPDWORD count ) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 762 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 763 | NTSTATUS status; |
| 764 | UNICODE_STRING name_str; |
| 765 | DWORD total_size; |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 766 | char buffer[256], *buf_ptr = buffer; |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 767 | KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer; |
| 768 | static const int info_size = sizeof(*info) - sizeof(info->Data); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 769 | |
| 770 | TRACE("(0x%x,%s,%p,%p,%p,%p=%ld)\n", |
| 771 | hkey, debugstr_w(name), reserved, type, data, count, count ? *count : 0 ); |
| 772 | |
Eric Pouech | 2c655f5 | 1999-11-25 22:05:46 +0000 | [diff] [blame] | 773 | if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 774 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 775 | RtlInitUnicodeString( &name_str, name ); |
| 776 | |
| 777 | if (data) total_size = min( sizeof(buffer), *count + info_size ); |
| 778 | else total_size = info_size; |
| 779 | |
| 780 | status = NtQueryValueKey( hkey, &name_str, KeyValuePartialInformation, |
| 781 | buffer, total_size, &total_size ); |
| 782 | if (status && status != STATUS_BUFFER_OVERFLOW) goto done; |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 783 | |
| 784 | if (data) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 785 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 786 | /* retry with a dynamically allocated buffer */ |
| 787 | while (status == STATUS_BUFFER_OVERFLOW && total_size - info_size <= *count) |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 788 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 789 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 790 | if (!(buf_ptr = HeapAlloc( GetProcessHeap(), 0, total_size ))) |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 791 | return ERROR_NOT_ENOUGH_MEMORY; |
| 792 | info = (KEY_VALUE_PARTIAL_INFORMATION *)buf_ptr; |
| 793 | status = NtQueryValueKey( hkey, &name_str, KeyValuePartialInformation, |
| 794 | buf_ptr, total_size, &total_size ); |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 795 | } |
| 796 | |
| 797 | if (!status) |
| 798 | { |
| 799 | memcpy( data, buf_ptr + info_size, total_size - info_size ); |
| 800 | /* if the type is REG_SZ and data is not 0-terminated |
| 801 | * and there is enough space in the buffer NT appends a \0 */ |
| 802 | if (total_size - info_size <= *count-sizeof(WCHAR) && is_string(info->Type)) |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 803 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 804 | WCHAR *ptr = (WCHAR *)(data + total_size - info_size); |
| 805 | if (ptr > (WCHAR *)data && ptr[-1]) *ptr = 0; |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 806 | } |
| 807 | } |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 808 | else if (status != STATUS_BUFFER_OVERFLOW) goto done; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 809 | } |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 810 | else status = STATUS_SUCCESS; |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 811 | |
| 812 | if (type) *type = info->Type; |
| 813 | if (count) *count = total_size - info_size; |
| 814 | |
| 815 | done: |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 816 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 817 | return RtlNtStatusToDosError(status); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 818 | } |
| 819 | |
| 820 | |
| 821 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 822 | * RegQueryValueExA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 823 | * |
| 824 | * NOTES: |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 825 | * the documentation is wrong: if the buffer is too small it remains untouched |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 826 | */ |
| 827 | DWORD WINAPI RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWORD type, |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 828 | LPBYTE data, LPDWORD count ) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 829 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 830 | NTSTATUS status; |
| 831 | ANSI_STRING nameA; |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 832 | DWORD total_size; |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 833 | char buffer[256], *buf_ptr = buffer; |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 834 | KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer; |
| 835 | static const int info_size = sizeof(*info) - sizeof(info->Data); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 836 | |
| 837 | TRACE("(0x%x,%s,%p,%p,%p,%p=%ld)\n", |
| 838 | hkey, debugstr_a(name), reserved, type, data, count, count ? *count : 0 ); |
| 839 | |
Eric Pouech | 2c655f5 | 1999-11-25 22:05:46 +0000 | [diff] [blame] | 840 | if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 841 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 842 | RtlInitAnsiString( &nameA, name ); |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 843 | if ((status = RtlAnsiStringToUnicodeString( &NtCurrentTeb()->StaticUnicodeString, |
| 844 | &nameA, FALSE ))) |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 845 | return RtlNtStatusToDosError(status); |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 846 | |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 847 | status = NtQueryValueKey( hkey, &NtCurrentTeb()->StaticUnicodeString, |
| 848 | KeyValuePartialInformation, buffer, sizeof(buffer), &total_size ); |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 849 | if (status && status != STATUS_BUFFER_OVERFLOW) goto done; |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 850 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 851 | /* we need to fetch the contents for a string type even if not requested, |
| 852 | * because we need to compute the length of the ASCII string. */ |
| 853 | if (data || is_string(info->Type)) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 854 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 855 | /* retry with a dynamically allocated buffer */ |
| 856 | while (status == STATUS_BUFFER_OVERFLOW) |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 857 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 858 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 859 | if (!(buf_ptr = HeapAlloc( GetProcessHeap(), 0, total_size ))) |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 860 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 861 | status = STATUS_NO_MEMORY; |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 862 | goto done; |
| 863 | } |
| 864 | info = (KEY_VALUE_PARTIAL_INFORMATION *)buf_ptr; |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 865 | status = NtQueryValueKey( hkey, &NtCurrentTeb()->StaticUnicodeString, |
| 866 | KeyValuePartialInformation, buf_ptr, total_size, &total_size ); |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 867 | } |
| 868 | |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 869 | if (status) goto done; |
| 870 | |
| 871 | if (is_string(info->Type)) |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 872 | { |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 873 | DWORD len = WideCharToMultiByte( CP_ACP, 0, (WCHAR *)(buf_ptr + info_size), |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 874 | (total_size - info_size) /sizeof(WCHAR), |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 875 | NULL, 0, NULL, NULL ); |
| 876 | if (data && len) |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 877 | { |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 878 | if (len > *count) status = STATUS_BUFFER_OVERFLOW; |
| 879 | else |
| 880 | { |
| 881 | WideCharToMultiByte( CP_ACP, 0, (WCHAR *)(buf_ptr + info_size), |
| 882 | (total_size - info_size) /sizeof(WCHAR), |
| 883 | data, len, NULL, NULL ); |
| 884 | /* if the type is REG_SZ and data is not 0-terminated |
| 885 | * and there is enough space in the buffer NT appends a \0 */ |
| 886 | if (len < *count && data[len-1]) data[len] = 0; |
| 887 | } |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 888 | } |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 889 | total_size = len + info_size; |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 890 | } |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 891 | else if (data) |
| 892 | { |
| 893 | if (total_size - info_size > *count) status = STATUS_BUFFER_OVERFLOW; |
| 894 | else memcpy( data, buf_ptr + info_size, total_size - info_size ); |
| 895 | } |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 896 | } |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 897 | else status = STATUS_SUCCESS; |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 898 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 899 | if (type) *type = info->Type; |
| 900 | if (count) *count = total_size - info_size; |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 901 | |
| 902 | done: |
Alexandre Julliard | 454355e | 2000-10-02 03:46:58 +0000 | [diff] [blame] | 903 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 904 | return RtlNtStatusToDosError(status); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 905 | } |
| 906 | |
| 907 | |
| 908 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 909 | * RegQueryValueW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 910 | */ |
| 911 | DWORD WINAPI RegQueryValueW( HKEY hkey, LPCWSTR name, LPWSTR data, LPLONG count ) |
| 912 | { |
| 913 | DWORD ret; |
| 914 | HKEY subkey = hkey; |
| 915 | |
| 916 | TRACE("(%x,%s,%p,%ld)\n", hkey, debugstr_w(name), data, count ? *count : 0 ); |
| 917 | |
| 918 | if (name && name[0]) |
| 919 | { |
| 920 | if ((ret = RegOpenKeyW( hkey, name, &subkey )) != ERROR_SUCCESS) return ret; |
| 921 | } |
| 922 | ret = RegQueryValueExW( subkey, NULL, NULL, NULL, (LPBYTE)data, count ); |
| 923 | if (subkey != hkey) RegCloseKey( subkey ); |
| 924 | if (ret == ERROR_FILE_NOT_FOUND) |
| 925 | { |
| 926 | /* return empty string if default value not found */ |
| 927 | if (data) *data = 0; |
| 928 | if (count) *count = 1; |
| 929 | ret = ERROR_SUCCESS; |
| 930 | } |
| 931 | return ret; |
| 932 | } |
| 933 | |
| 934 | |
| 935 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 936 | * RegQueryValueA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 937 | */ |
| 938 | DWORD WINAPI RegQueryValueA( HKEY hkey, LPCSTR name, LPSTR data, LPLONG count ) |
| 939 | { |
| 940 | DWORD ret; |
| 941 | HKEY subkey = hkey; |
| 942 | |
| 943 | TRACE("(%x,%s,%p,%ld)\n", hkey, debugstr_a(name), data, count ? *count : 0 ); |
| 944 | |
| 945 | if (name && name[0]) |
| 946 | { |
| 947 | if ((ret = RegOpenKeyA( hkey, name, &subkey )) != ERROR_SUCCESS) return ret; |
| 948 | } |
| 949 | ret = RegQueryValueExA( subkey, NULL, NULL, NULL, (LPBYTE)data, count ); |
| 950 | if (subkey != hkey) RegCloseKey( subkey ); |
| 951 | if (ret == ERROR_FILE_NOT_FOUND) |
| 952 | { |
| 953 | /* return empty string if default value not found */ |
| 954 | if (data) *data = 0; |
| 955 | if (count) *count = 1; |
| 956 | ret = ERROR_SUCCESS; |
| 957 | } |
| 958 | return ret; |
| 959 | } |
| 960 | |
| 961 | |
| 962 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 963 | * RegEnumValueW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 964 | * |
| 965 | * PARAMS |
| 966 | * hkey [I] Handle to key to query |
| 967 | * index [I] Index of value to query |
| 968 | * value [O] Value string |
| 969 | * val_count [I/O] Size of value buffer (in wchars) |
| 970 | * reserved [I] Reserved |
| 971 | * type [O] Type code |
| 972 | * data [O] Value data |
| 973 | * count [I/O] Size of data buffer (in bytes) |
| 974 | */ |
| 975 | |
| 976 | DWORD WINAPI RegEnumValueW( HKEY hkey, DWORD index, LPWSTR value, LPDWORD val_count, |
| 977 | LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count ) |
| 978 | { |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 979 | NTSTATUS status; |
| 980 | DWORD total_size; |
| 981 | char buffer[256], *buf_ptr = buffer; |
| 982 | KEY_VALUE_FULL_INFORMATION *info = (KEY_VALUE_FULL_INFORMATION *)buffer; |
| 983 | static const int info_size = sizeof(*info) - sizeof(info->Name); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 984 | |
| 985 | TRACE("(%x,%ld,%p,%p,%p,%p,%p,%p)\n", |
| 986 | hkey, index, value, val_count, reserved, type, data, count ); |
| 987 | |
| 988 | /* NT only checks count, not val_count */ |
Eric Pouech | 2c655f5 | 1999-11-25 22:05:46 +0000 | [diff] [blame] | 989 | if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 990 | |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 991 | total_size = info_size + (MAX_PATH + 1) * sizeof(WCHAR); |
| 992 | if (data) total_size += *count; |
| 993 | total_size = min( sizeof(buffer), total_size ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 994 | |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 995 | status = NtEnumerateValueKey( hkey, index, KeyValueFullInformation, |
| 996 | buffer, total_size, &total_size ); |
| 997 | if (status && status != STATUS_BUFFER_OVERFLOW) goto done; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 998 | |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 999 | if (value || data) |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 1000 | { |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1001 | /* retry with a dynamically allocated buffer */ |
| 1002 | while (status == STATUS_BUFFER_OVERFLOW) |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 1003 | { |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1004 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 1005 | if (!(buf_ptr = HeapAlloc( GetProcessHeap(), 0, total_size ))) |
| 1006 | return ERROR_NOT_ENOUGH_MEMORY; |
| 1007 | info = (KEY_VALUE_FULL_INFORMATION *)buf_ptr; |
| 1008 | status = NtEnumerateValueKey( hkey, index, KeyValueFullInformation, |
| 1009 | buf_ptr, total_size, &total_size ); |
| 1010 | } |
| 1011 | |
| 1012 | if (status) goto done; |
| 1013 | |
| 1014 | if (value) |
| 1015 | { |
| 1016 | if (info->NameLength/sizeof(WCHAR) >= *val_count) |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 1017 | { |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1018 | status = STATUS_BUFFER_OVERFLOW; |
| 1019 | goto done; |
| 1020 | } |
| 1021 | memcpy( value, info->Name, info->NameLength ); |
| 1022 | *val_count = info->NameLength / sizeof(WCHAR); |
| 1023 | value[*val_count] = 0; |
| 1024 | } |
| 1025 | |
| 1026 | if (data) |
| 1027 | { |
| 1028 | if (total_size - info->DataOffset > *count) |
| 1029 | { |
| 1030 | status = STATUS_BUFFER_OVERFLOW; |
| 1031 | goto done; |
| 1032 | } |
| 1033 | memcpy( data, buf_ptr + info->DataOffset, total_size - info->DataOffset ); |
| 1034 | if (total_size - info->DataOffset <= *count-sizeof(WCHAR) && is_string(info->Type)) |
| 1035 | { |
| 1036 | /* if the type is REG_SZ and data is not 0-terminated |
| 1037 | * and there is enough space in the buffer NT appends a \0 */ |
| 1038 | WCHAR *ptr = (WCHAR *)(data + total_size - info->DataOffset); |
| 1039 | if (ptr > (WCHAR *)data && ptr[-1]) *ptr = 0; |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 1040 | } |
| 1041 | } |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 1042 | } |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 1043 | else status = STATUS_SUCCESS; |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1044 | |
| 1045 | if (type) *type = info->Type; |
| 1046 | if (count) *count = info->DataLength; |
| 1047 | |
| 1048 | done: |
| 1049 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 1050 | return RtlNtStatusToDosError(status); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1051 | } |
| 1052 | |
| 1053 | |
| 1054 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1055 | * RegEnumValueA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1056 | */ |
| 1057 | DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count, |
| 1058 | LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count ) |
| 1059 | { |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1060 | NTSTATUS status; |
| 1061 | DWORD total_size; |
| 1062 | char buffer[256], *buf_ptr = buffer; |
| 1063 | KEY_VALUE_FULL_INFORMATION *info = (KEY_VALUE_FULL_INFORMATION *)buffer; |
| 1064 | static const int info_size = sizeof(*info) - sizeof(info->Name); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1065 | |
| 1066 | TRACE("(%x,%ld,%p,%p,%p,%p,%p,%p)\n", |
| 1067 | hkey, index, value, val_count, reserved, type, data, count ); |
| 1068 | |
| 1069 | /* NT only checks count, not val_count */ |
Eric Pouech | 2c655f5 | 1999-11-25 22:05:46 +0000 | [diff] [blame] | 1070 | if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1071 | |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1072 | total_size = info_size + (MAX_PATH + 1) * sizeof(WCHAR); |
| 1073 | if (data) total_size += *count; |
| 1074 | total_size = min( sizeof(buffer), total_size ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1075 | |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1076 | status = NtEnumerateValueKey( hkey, index, KeyValueFullInformation, |
| 1077 | buffer, total_size, &total_size ); |
| 1078 | if (status && status != STATUS_BUFFER_OVERFLOW) goto done; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1079 | |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1080 | /* we need to fetch the contents for a string type even if not requested, |
| 1081 | * because we need to compute the length of the ASCII string. */ |
| 1082 | if (value || data || is_string(info->Type)) |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 1083 | { |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1084 | /* retry with a dynamically allocated buffer */ |
| 1085 | while (status == STATUS_BUFFER_OVERFLOW) |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 1086 | { |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1087 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 1088 | if (!(buf_ptr = HeapAlloc( GetProcessHeap(), 0, total_size ))) |
| 1089 | return ERROR_NOT_ENOUGH_MEMORY; |
| 1090 | info = (KEY_VALUE_FULL_INFORMATION *)buf_ptr; |
| 1091 | status = NtEnumerateValueKey( hkey, index, KeyValueFullInformation, |
| 1092 | buf_ptr, total_size, &total_size ); |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 1093 | } |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1094 | |
| 1095 | if (status) goto done; |
| 1096 | |
| 1097 | if (value) |
| 1098 | { |
| 1099 | DWORD len = WideCharToMultiByte( CP_ACP, 0, info->Name, info->NameLength/sizeof(WCHAR), |
| 1100 | NULL, 0, NULL, NULL ); |
| 1101 | if (len >= *val_count) |
| 1102 | { |
| 1103 | status = STATUS_BUFFER_OVERFLOW; |
| 1104 | goto done; |
| 1105 | } |
| 1106 | WideCharToMultiByte( CP_ACP, 0, info->Name, info->NameLength/sizeof(WCHAR), |
| 1107 | value, len, NULL, NULL ); |
| 1108 | value[len] = 0; |
| 1109 | *val_count = len; |
| 1110 | } |
| 1111 | |
| 1112 | if (is_string(info->Type)) |
| 1113 | { |
| 1114 | DWORD len = WideCharToMultiByte( CP_ACP, 0, (WCHAR *)(buf_ptr + info->DataOffset), |
| 1115 | (total_size - info->DataOffset) / sizeof(WCHAR), |
| 1116 | NULL, 0, NULL, NULL ); |
| 1117 | if (data && len) |
| 1118 | { |
| 1119 | if (len > *count) |
| 1120 | { |
| 1121 | status = STATUS_BUFFER_OVERFLOW; |
| 1122 | goto done; |
| 1123 | } |
| 1124 | WideCharToMultiByte( CP_ACP, 0, (WCHAR *)(buf_ptr + info->DataOffset), |
| 1125 | (total_size - info->DataOffset) / sizeof(WCHAR), |
| 1126 | data, len, NULL, NULL ); |
| 1127 | /* if the type is REG_SZ and data is not 0-terminated |
| 1128 | * and there is enough space in the buffer NT appends a \0 */ |
| 1129 | if (len < *count && data[len-1]) data[len] = 0; |
| 1130 | } |
| 1131 | info->DataLength = len; |
| 1132 | } |
| 1133 | else if (data) |
| 1134 | { |
| 1135 | if (total_size - info->DataOffset > *count) status = STATUS_BUFFER_OVERFLOW; |
| 1136 | else memcpy( data, buf_ptr + info->DataOffset, total_size - info->DataOffset ); |
| 1137 | } |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 1138 | } |
Alexandre Julliard | c661583 | 2001-02-14 21:45:52 +0000 | [diff] [blame] | 1139 | else status = STATUS_SUCCESS; |
Alexandre Julliard | a01004d | 2000-05-14 22:57:57 +0000 | [diff] [blame] | 1140 | |
Alexandre Julliard | 0b6a79c | 2000-12-15 20:57:00 +0000 | [diff] [blame] | 1141 | if (type) *type = info->Type; |
| 1142 | if (count) *count = info->DataLength; |
| 1143 | |
| 1144 | done: |
| 1145 | if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr ); |
| 1146 | return RtlNtStatusToDosError(status); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1147 | } |
| 1148 | |
| 1149 | |
| 1150 | |
| 1151 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1152 | * RegDeleteValueW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1153 | * |
| 1154 | * PARAMS |
| 1155 | * hkey [I] handle to key |
| 1156 | * name [I] name of value to delete |
| 1157 | * |
| 1158 | * RETURNS |
| 1159 | * error status |
| 1160 | */ |
| 1161 | DWORD WINAPI RegDeleteValueW( HKEY hkey, LPCWSTR name ) |
| 1162 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 1163 | UNICODE_STRING nameW; |
| 1164 | RtlInitUnicodeString( &nameW, name ); |
| 1165 | return RtlNtStatusToDosError( NtDeleteValueKey( hkey, &nameW ) ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1166 | } |
| 1167 | |
| 1168 | |
| 1169 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1170 | * RegDeleteValueA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1171 | */ |
| 1172 | DWORD WINAPI RegDeleteValueA( HKEY hkey, LPCSTR name ) |
| 1173 | { |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 1174 | STRING nameA; |
| 1175 | NTSTATUS status; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1176 | |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 1177 | RtlInitAnsiString( &nameA, name ); |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 1178 | if (!(status = RtlAnsiStringToUnicodeString( &NtCurrentTeb()->StaticUnicodeString, |
| 1179 | &nameA, FALSE ))) |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 1180 | { |
Alexandre Julliard | ab5e975 | 2001-03-23 19:12:01 +0000 | [diff] [blame^] | 1181 | status = NtDeleteValueKey( hkey, &NtCurrentTeb()->StaticUnicodeString ); |
Alexandre Julliard | bcf393a | 2000-10-01 01:44:50 +0000 | [diff] [blame] | 1182 | } |
| 1183 | return RtlNtStatusToDosError( status ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1184 | } |
| 1185 | |
| 1186 | |
| 1187 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1188 | * RegLoadKeyW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1189 | * |
| 1190 | * PARAMS |
| 1191 | * hkey [I] Handle of open key |
| 1192 | * subkey [I] Address of name of subkey |
| 1193 | * filename [I] Address of filename for registry information |
| 1194 | */ |
| 1195 | LONG WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename ) |
| 1196 | { |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1197 | HANDLE file; |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1198 | DWORD ret, len, err = GetLastError(); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1199 | |
| 1200 | TRACE( "(%x,%s,%s)\n", hkey, debugstr_w(subkey), debugstr_w(filename) ); |
| 1201 | |
| 1202 | if (!filename || !*filename) return ERROR_INVALID_PARAMETER; |
| 1203 | if (!subkey || !*subkey) return ERROR_INVALID_PARAMETER; |
| 1204 | |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1205 | len = strlenW( subkey ) * sizeof(WCHAR); |
| 1206 | if (len > MAX_PATH*sizeof(WCHAR)) return ERROR_INVALID_PARAMETER; |
| 1207 | |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1208 | if ((file = CreateFileW( filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, |
François Gouget | da2b6a9 | 2001-01-06 01:29:18 +0000 | [diff] [blame] | 1209 | FILE_ATTRIBUTE_NORMAL, 0 )) == INVALID_HANDLE_VALUE) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1210 | { |
| 1211 | ret = GetLastError(); |
| 1212 | goto done; |
| 1213 | } |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1214 | |
Alexandre Julliard | 67a7499 | 2001-02-27 02:09:16 +0000 | [diff] [blame] | 1215 | SERVER_START_VAR_REQ( load_registry, len ) |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1216 | { |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1217 | req->hkey = hkey; |
| 1218 | req->file = file; |
| 1219 | memcpy( server_data_ptr(req), subkey, len ); |
Alexandre Julliard | 67a7499 | 2001-02-27 02:09:16 +0000 | [diff] [blame] | 1220 | ret = RtlNtStatusToDosError( SERVER_CALL() ); |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1221 | } |
Alexandre Julliard | 67a7499 | 2001-02-27 02:09:16 +0000 | [diff] [blame] | 1222 | SERVER_END_VAR_REQ; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1223 | CloseHandle( file ); |
| 1224 | |
| 1225 | done: |
| 1226 | SetLastError( err ); /* restore the last error code */ |
| 1227 | return ret; |
| 1228 | } |
| 1229 | |
| 1230 | |
| 1231 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1232 | * RegLoadKeyA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1233 | */ |
| 1234 | LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename ) |
| 1235 | { |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1236 | HANDLE file; |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1237 | DWORD ret, len, err = GetLastError(); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1238 | |
| 1239 | TRACE( "(%x,%s,%s)\n", hkey, debugstr_a(subkey), debugstr_a(filename) ); |
| 1240 | |
| 1241 | if (!filename || !*filename) return ERROR_INVALID_PARAMETER; |
| 1242 | if (!subkey || !*subkey) return ERROR_INVALID_PARAMETER; |
| 1243 | |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1244 | len = MultiByteToWideChar( CP_ACP, 0, subkey, strlen(subkey), NULL, 0 ) * sizeof(WCHAR); |
| 1245 | if (len > MAX_PATH*sizeof(WCHAR)) return ERROR_INVALID_PARAMETER; |
| 1246 | |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1247 | if ((file = CreateFileA( filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, |
François Gouget | da2b6a9 | 2001-01-06 01:29:18 +0000 | [diff] [blame] | 1248 | FILE_ATTRIBUTE_NORMAL, 0 )) == INVALID_HANDLE_VALUE) |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1249 | { |
| 1250 | ret = GetLastError(); |
| 1251 | goto done; |
| 1252 | } |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1253 | |
Alexandre Julliard | 67a7499 | 2001-02-27 02:09:16 +0000 | [diff] [blame] | 1254 | SERVER_START_VAR_REQ( load_registry, len ) |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1255 | { |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1256 | req->hkey = hkey; |
| 1257 | req->file = file; |
| 1258 | MultiByteToWideChar( CP_ACP, 0, subkey, strlen(subkey), |
| 1259 | server_data_ptr(req), len/sizeof(WCHAR) ); |
Alexandre Julliard | 67a7499 | 2001-02-27 02:09:16 +0000 | [diff] [blame] | 1260 | ret = RtlNtStatusToDosError( SERVER_CALL() ); |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1261 | } |
Alexandre Julliard | 67a7499 | 2001-02-27 02:09:16 +0000 | [diff] [blame] | 1262 | SERVER_END_VAR_REQ; |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1263 | CloseHandle( file ); |
| 1264 | |
| 1265 | done: |
| 1266 | SetLastError( err ); /* restore the last error code */ |
| 1267 | return ret; |
| 1268 | } |
| 1269 | |
| 1270 | |
| 1271 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1272 | * RegSaveKeyA [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1273 | * |
| 1274 | * PARAMS |
| 1275 | * hkey [I] Handle of key where save begins |
| 1276 | * lpFile [I] Address of filename to save to |
| 1277 | * sa [I] Address of security structure |
| 1278 | */ |
| 1279 | LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa ) |
| 1280 | { |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1281 | char buffer[1024]; |
| 1282 | int count = 0; |
| 1283 | LPSTR name; |
| 1284 | DWORD ret, err; |
| 1285 | HFILE handle; |
| 1286 | |
| 1287 | TRACE( "(%x,%s,%p)\n", hkey, debugstr_a(file), sa ); |
| 1288 | |
| 1289 | if (!file || !*file) return ERROR_INVALID_PARAMETER; |
| 1290 | |
| 1291 | err = GetLastError(); |
| 1292 | GetFullPathNameA( file, sizeof(buffer), buffer, &name ); |
| 1293 | for (;;) |
| 1294 | { |
| 1295 | sprintf( name, "reg%04x.tmp", count++ ); |
| 1296 | handle = CreateFileA( buffer, GENERIC_WRITE, 0, NULL, |
François Gouget | da2b6a9 | 2001-01-06 01:29:18 +0000 | [diff] [blame] | 1297 | CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 ); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1298 | if (handle != INVALID_HANDLE_VALUE) break; |
Alexandre Julliard | 5354417 | 2000-03-26 18:18:03 +0000 | [diff] [blame] | 1299 | if ((ret = GetLastError()) != ERROR_ALREADY_EXISTS) goto done; |
Andreas Mohr | 6297451 | 2000-05-09 22:31:43 +0000 | [diff] [blame] | 1300 | |
| 1301 | /* Something gone haywire ? Please report if this happens abnormally */ |
| 1302 | if (count >= 100) |
| 1303 | MESSAGE("Wow, we are already fiddling with a temp file %s with an ordinal as high as %d !\nYou might want to delete all corresponding temp files in that directory.\n", buffer, count); |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1304 | } |
| 1305 | |
Alexandre Julliard | 67a7499 | 2001-02-27 02:09:16 +0000 | [diff] [blame] | 1306 | SERVER_START_REQ( save_registry ) |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1307 | { |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1308 | req->hkey = hkey; |
| 1309 | req->file = handle; |
Alexandre Julliard | 67a7499 | 2001-02-27 02:09:16 +0000 | [diff] [blame] | 1310 | ret = RtlNtStatusToDosError( SERVER_CALL() ); |
Alexandre Julliard | 57f05e1 | 2000-10-15 00:40:25 +0000 | [diff] [blame] | 1311 | } |
| 1312 | SERVER_END_REQ; |
| 1313 | |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1314 | CloseHandle( handle ); |
| 1315 | if (!ret) |
| 1316 | { |
| 1317 | if (!MoveFileExA( buffer, file, MOVEFILE_REPLACE_EXISTING )) |
| 1318 | { |
| 1319 | ERR( "Failed to move %s to %s\n", buffer, file ); |
| 1320 | ret = GetLastError(); |
| 1321 | } |
| 1322 | } |
| 1323 | if (ret) DeleteFileA( buffer ); |
| 1324 | |
| 1325 | done: |
| 1326 | SetLastError( err ); /* restore last error code */ |
| 1327 | return ret; |
| 1328 | } |
| 1329 | |
| 1330 | |
| 1331 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1332 | * RegSaveKeyW [ADVAPI32.@] |
Alexandre Julliard | 2fab2ef | 1999-11-23 19:41:34 +0000 | [diff] [blame] | 1333 | */ |
| 1334 | LONG WINAPI RegSaveKeyW( HKEY hkey, LPCWSTR file, LPSECURITY_ATTRIBUTES sa ) |
| 1335 | { |
| 1336 | LPSTR fileA = HEAP_strdupWtoA( GetProcessHeap(), 0, file ); |
| 1337 | DWORD ret = RegSaveKeyA( hkey, fileA, sa ); |
| 1338 | if (fileA) HeapFree( GetProcessHeap(), 0, fileA ); |
| 1339 | return ret; |
| 1340 | } |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1341 | |
| 1342 | |
| 1343 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1344 | * RegRestoreKeyW [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1345 | * |
| 1346 | * PARAMS |
| 1347 | * hkey [I] Handle of key where restore begins |
| 1348 | * lpFile [I] Address of filename containing saved tree |
| 1349 | * dwFlags [I] Optional flags |
| 1350 | */ |
| 1351 | LONG WINAPI RegRestoreKeyW( HKEY hkey, LPCWSTR lpFile, DWORD dwFlags ) |
| 1352 | { |
| 1353 | TRACE("(%x,%s,%ld)\n",hkey,debugstr_w(lpFile),dwFlags); |
| 1354 | |
| 1355 | /* It seems to do this check before the hkey check */ |
| 1356 | if (!lpFile || !*lpFile) |
| 1357 | return ERROR_INVALID_PARAMETER; |
| 1358 | |
| 1359 | FIXME("(%x,%s,%ld): stub\n",hkey,debugstr_w(lpFile),dwFlags); |
| 1360 | |
| 1361 | /* Check for file existence */ |
| 1362 | |
| 1363 | return ERROR_SUCCESS; |
| 1364 | } |
| 1365 | |
| 1366 | |
| 1367 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1368 | * RegRestoreKeyA [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1369 | */ |
| 1370 | LONG WINAPI RegRestoreKeyA( HKEY hkey, LPCSTR lpFile, DWORD dwFlags ) |
| 1371 | { |
| 1372 | LPWSTR lpFileW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpFile ); |
| 1373 | LONG ret = RegRestoreKeyW( hkey, lpFileW, dwFlags ); |
| 1374 | HeapFree( GetProcessHeap(), 0, lpFileW ); |
| 1375 | return ret; |
| 1376 | } |
| 1377 | |
| 1378 | |
| 1379 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1380 | * RegUnLoadKeyW [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1381 | * |
| 1382 | * PARAMS |
| 1383 | * hkey [I] Handle of open key |
| 1384 | * lpSubKey [I] Address of name of subkey to unload |
| 1385 | */ |
| 1386 | LONG WINAPI RegUnLoadKeyW( HKEY hkey, LPCWSTR lpSubKey ) |
| 1387 | { |
| 1388 | FIXME("(%x,%s): stub\n",hkey, debugstr_w(lpSubKey)); |
| 1389 | return ERROR_SUCCESS; |
| 1390 | } |
| 1391 | |
| 1392 | |
| 1393 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1394 | * RegUnLoadKeyA [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1395 | */ |
| 1396 | LONG WINAPI RegUnLoadKeyA( HKEY hkey, LPCSTR lpSubKey ) |
| 1397 | { |
| 1398 | LPWSTR lpSubKeyW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpSubKey ); |
| 1399 | LONG ret = RegUnLoadKeyW( hkey, lpSubKeyW ); |
| 1400 | if(lpSubKeyW) HeapFree( GetProcessHeap(), 0, lpSubKeyW); |
| 1401 | return ret; |
| 1402 | } |
| 1403 | |
| 1404 | |
| 1405 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1406 | * RegReplaceKeyW [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1407 | * |
| 1408 | * PARAMS |
| 1409 | * hkey [I] Handle of open key |
| 1410 | * lpSubKey [I] Address of name of subkey |
| 1411 | * lpNewFile [I] Address of filename for file with new data |
| 1412 | * lpOldFile [I] Address of filename for backup file |
| 1413 | */ |
| 1414 | LONG WINAPI RegReplaceKeyW( HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpNewFile, |
| 1415 | LPCWSTR lpOldFile ) |
| 1416 | { |
| 1417 | FIXME("(%x,%s,%s,%s): stub\n", hkey, debugstr_w(lpSubKey), |
| 1418 | debugstr_w(lpNewFile),debugstr_w(lpOldFile)); |
| 1419 | return ERROR_SUCCESS; |
| 1420 | } |
| 1421 | |
| 1422 | |
| 1423 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1424 | * RegReplaceKeyA [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1425 | */ |
| 1426 | LONG WINAPI RegReplaceKeyA( HKEY hkey, LPCSTR lpSubKey, LPCSTR lpNewFile, |
| 1427 | LPCSTR lpOldFile ) |
| 1428 | { |
| 1429 | LPWSTR lpSubKeyW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpSubKey ); |
| 1430 | LPWSTR lpNewFileW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpNewFile ); |
| 1431 | LPWSTR lpOldFileW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpOldFile ); |
| 1432 | LONG ret = RegReplaceKeyW( hkey, lpSubKeyW, lpNewFileW, lpOldFileW ); |
| 1433 | HeapFree( GetProcessHeap(), 0, lpOldFileW ); |
| 1434 | HeapFree( GetProcessHeap(), 0, lpNewFileW ); |
| 1435 | HeapFree( GetProcessHeap(), 0, lpSubKeyW ); |
| 1436 | return ret; |
| 1437 | } |
| 1438 | |
| 1439 | |
| 1440 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1441 | * RegSetKeySecurity [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1442 | * |
| 1443 | * PARAMS |
| 1444 | * hkey [I] Open handle of key to set |
| 1445 | * SecurityInfo [I] Descriptor contents |
| 1446 | * pSecurityDesc [I] Address of descriptor for key |
| 1447 | */ |
| 1448 | LONG WINAPI RegSetKeySecurity( HKEY hkey, SECURITY_INFORMATION SecurityInfo, |
| 1449 | PSECURITY_DESCRIPTOR pSecurityDesc ) |
| 1450 | { |
| 1451 | TRACE("(%x,%ld,%p)\n",hkey,SecurityInfo,pSecurityDesc); |
| 1452 | |
| 1453 | /* It seems to perform this check before the hkey check */ |
| 1454 | if ((SecurityInfo & OWNER_SECURITY_INFORMATION) || |
| 1455 | (SecurityInfo & GROUP_SECURITY_INFORMATION) || |
| 1456 | (SecurityInfo & DACL_SECURITY_INFORMATION) || |
| 1457 | (SecurityInfo & SACL_SECURITY_INFORMATION)) { |
| 1458 | /* Param OK */ |
| 1459 | } else |
| 1460 | return ERROR_INVALID_PARAMETER; |
| 1461 | |
| 1462 | if (!pSecurityDesc) |
| 1463 | return ERROR_INVALID_PARAMETER; |
| 1464 | |
| 1465 | FIXME(":(%x,%ld,%p): stub\n",hkey,SecurityInfo,pSecurityDesc); |
| 1466 | |
| 1467 | return ERROR_SUCCESS; |
| 1468 | } |
| 1469 | |
| 1470 | |
| 1471 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1472 | * RegGetKeySecurity [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1473 | * Retrieves a copy of security descriptor protecting the registry key |
| 1474 | * |
| 1475 | * PARAMS |
| 1476 | * hkey [I] Open handle of key to set |
| 1477 | * SecurityInformation [I] Descriptor contents |
| 1478 | * pSecurityDescriptor [O] Address of descriptor for key |
| 1479 | * lpcbSecurityDescriptor [I/O] Address of size of buffer and description |
| 1480 | * |
| 1481 | * RETURNS |
| 1482 | * Success: ERROR_SUCCESS |
| 1483 | * Failure: Error code |
| 1484 | */ |
| 1485 | LONG WINAPI RegGetKeySecurity( HKEY hkey, SECURITY_INFORMATION SecurityInformation, |
| 1486 | PSECURITY_DESCRIPTOR pSecurityDescriptor, |
| 1487 | LPDWORD lpcbSecurityDescriptor ) |
| 1488 | { |
| 1489 | TRACE("(%x,%ld,%p,%ld)\n",hkey,SecurityInformation,pSecurityDescriptor, |
| 1490 | lpcbSecurityDescriptor?*lpcbSecurityDescriptor:0); |
| 1491 | |
| 1492 | /* FIXME: Check for valid SecurityInformation values */ |
| 1493 | |
| 1494 | if (*lpcbSecurityDescriptor < sizeof(SECURITY_DESCRIPTOR)) |
| 1495 | return ERROR_INSUFFICIENT_BUFFER; |
| 1496 | |
| 1497 | FIXME("(%x,%ld,%p,%ld): stub\n",hkey,SecurityInformation, |
| 1498 | pSecurityDescriptor,lpcbSecurityDescriptor?*lpcbSecurityDescriptor:0); |
| 1499 | |
| 1500 | return ERROR_SUCCESS; |
| 1501 | } |
| 1502 | |
| 1503 | |
| 1504 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1505 | * RegFlushKey [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1506 | * Immediately writes key to registry. |
| 1507 | * Only returns after data has been written to disk. |
| 1508 | * |
| 1509 | * FIXME: does it really wait until data is written ? |
| 1510 | * |
| 1511 | * PARAMS |
| 1512 | * hkey [I] Handle of key to write |
| 1513 | * |
| 1514 | * RETURNS |
| 1515 | * Success: ERROR_SUCCESS |
| 1516 | * Failure: Error code |
| 1517 | */ |
| 1518 | DWORD WINAPI RegFlushKey( HKEY hkey ) |
| 1519 | { |
| 1520 | FIXME( "(%x): stub\n", hkey ); |
| 1521 | return ERROR_SUCCESS; |
| 1522 | } |
| 1523 | |
| 1524 | |
| 1525 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1526 | * RegConnectRegistryW [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1527 | * |
| 1528 | * PARAMS |
| 1529 | * lpMachineName [I] Address of name of remote computer |
| 1530 | * hHey [I] Predefined registry handle |
| 1531 | * phkResult [I] Address of buffer for remote registry handle |
| 1532 | */ |
| 1533 | LONG WINAPI RegConnectRegistryW( LPCWSTR lpMachineName, HKEY hKey, |
| 1534 | LPHKEY phkResult ) |
| 1535 | { |
| 1536 | TRACE("(%s,%x,%p): stub\n",debugstr_w(lpMachineName),hKey,phkResult); |
| 1537 | |
| 1538 | if (!lpMachineName || !*lpMachineName) { |
| 1539 | /* Use the local machine name */ |
| 1540 | return RegOpenKeyA( hKey, "", phkResult ); |
| 1541 | } |
| 1542 | |
| 1543 | FIXME("Cannot connect to %s\n",debugstr_w(lpMachineName)); |
| 1544 | return ERROR_BAD_NETPATH; |
| 1545 | } |
| 1546 | |
| 1547 | |
| 1548 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1549 | * RegConnectRegistryA [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1550 | */ |
| 1551 | LONG WINAPI RegConnectRegistryA( LPCSTR machine, HKEY hkey, LPHKEY reskey ) |
| 1552 | { |
| 1553 | LPWSTR machineW = HEAP_strdupAtoW( GetProcessHeap(), 0, machine ); |
| 1554 | DWORD ret = RegConnectRegistryW( machineW, hkey, reskey ); |
| 1555 | HeapFree( GetProcessHeap(), 0, machineW ); |
| 1556 | return ret; |
| 1557 | } |
| 1558 | |
| 1559 | |
| 1560 | /****************************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 1561 | * RegNotifyChangeKeyValue [ADVAPI32.@] |
Alexandre Julliard | 5ce2329 | 2000-11-30 20:31:41 +0000 | [diff] [blame] | 1562 | * |
| 1563 | * PARAMS |
| 1564 | * hkey [I] Handle of key to watch |
| 1565 | * fWatchSubTree [I] Flag for subkey notification |
| 1566 | * fdwNotifyFilter [I] Changes to be reported |
| 1567 | * hEvent [I] Handle of signaled event |
| 1568 | * fAsync [I] Flag for asynchronous reporting |
| 1569 | */ |
| 1570 | LONG WINAPI RegNotifyChangeKeyValue( HKEY hkey, BOOL fWatchSubTree, |
| 1571 | DWORD fdwNotifyFilter, HANDLE hEvent, |
| 1572 | BOOL fAsync ) |
| 1573 | { |
| 1574 | FIXME("(%x,%i,%ld,%x,%i): stub\n",hkey,fWatchSubTree,fdwNotifyFilter, |
| 1575 | hEvent,fAsync); |
| 1576 | return ERROR_SUCCESS; |
| 1577 | } |